Development experience of senior Linux programmers

Source: Internet
Author: User
Tags imap
: This article mainly introduces the development experience of senior Linux programmers. For more information about PHP tutorials, see. Since the first time using the simple environment vi supported by SunOS in the middle of 1980s, the Emacs editor has become a standard tool for Murray. "It can be used on UNIX of various genres, which is one of the main reasons I chose for cross-platform development," he said.

Linux developers: Understand your shell

Murray requires that you understand your shell. "Bash, tcsh, and csh-shell are your most basic software development tools," he stressed. "It can do a lot of amazing things. All work depends on it ...... And its powerful functions ". As an example to illustrate the powerful functions of common shell scripts, there is a file that can be downloaded in the references section, including a set of scripts, used to obtain updated RPM packages released by Red Hat and merge them into the original and customized packages. After downloading and decompressing the file, you can find the script in the/developerworks/rpm_update_scripts directory. The final result is a directory that includes the latest version of all software packages and an hdlist file for network installation upgrades.

The following code snippet implements automatic updates to the Red Hat RPM package to create an installable version that uses the latest RPM. This is a basic step for anyone who maintains a public Linux server. For us, we usually maintain a large number of network services on many public Linux servers. The following are some scripts that can automatically update the latest security and functions.

The script below demonstrates that common shell programming technology can be widely used in various system configurations and program design applications. The script uses the bourne shell, which is the most common shell in different UNIX systems. This ensures that these very lightweight codes can be slightly modified or used on different UNIX systems without modification. It is easy to modify the Red Hat software package specification to apply it to other Linux releases.

Freshen. sh update the RPM package on the site using the specified RPM ftp to update the original RPM list. Execute the filter to replace the updated RPM package. Finally, the long release list is updated based on the new RPM software package obtained from the image update site.

Listing 1. fresh. sh

#! /Bin/sh

Rh_ver = $1

Rh_path = $2

Update_dir =$ {rh_path}/RH $ {rh_ver}-updates

Custom_dir =$ {rh_path}/RH $ {rh_ver}-custom

Install_dir =$ {rh_path}/RH $ {rh_ver}-install

# Sanity check for the original directory.

# Create update and install directories if they don't exist

[-D $ {update_dir}] | mkdir $ {update_dir}

[-D $ {install_dir}/RedHat/RPMS] | mkdir-p $ {install_dir}/RedHat/RPMS

# Get latest updates from fresh rpms FTP site

./Get_update.sh $ {rh_ver }$ {update_dir}

# Create/update hardlinks from update, and custom directories

# To the install directory. We assume that original RPMS are already

# Hardlinked to the install directory, so all we need to do is filter

# Out any replaced by updated packages.

./Do-links.sh $ {update_dir }$ {install_dir}/RedHat/RPMS

[-D $ {custom_dir}] &./do-links.sh $ {custom_dir}

$ {Install_dir}/RedHat/RPMS

# Filter out all but the latest version of everything.

/Filter-rpms.pl $ install_dir/RedHat/RPMS

# Rebuild the hard disk lists

/Usr/lib/anaconda-runtime/genhdlist $ {install_dir}

Freshen. sh calls the do-links.sh and get_update.sh to set the source, destination (omitted from the source RPM Package; hard link used to set the target RPM), and retrieve updates, respectively.

Listing 2. do-links.sh

#! /Bin/sh

Src = $1

Dest = $2

# For file in $ src/*; do

For file in 'find $ src-name *. rpm-! -Name *. src. rpm-print '; do

Base = 'basename $ file ;'

If test! -F $ dest/$ base; then

Echo "Linking $ file ";

Ln $ file $ dest

Else

Echo "EXISTS: $ file ";

Fi

Done

Listing 3. get_update.sh

#! /Bin/sh

Rh_ver = $1

Dest = $2

Echo "Retrieving updates for version $ {rh_ver} to $ dest"

Lftp <EOF

Open ftp.freshrpms.net

Mirror-n pub/redhat/linux/updates/$ {rh_ver}/en/OS/i386 $ dest/i386

Mirror-n pub/redhat/linux/updates/$ {rh_ver}/en/OS/ist $ dest/IST

Mirror-n pub/redhat/linux/updates/$ {rh_ver}/en/OS/i586 $ dest/i568

Mirror-n pub/redhat/linux/updates/$ {rh_ver}/en/OS/i686 $ dest/i686

Mirror-n pub/redhat/linux/updates/$ {rh_ver}/en/OS/SRPMS $ dest/SRPMS

Mirror-n pub/redhat/linux/updates/$ {rh_ver}/en/OS/noarch $ dest/noarch

Java and Linux

In Codemonks, a lot of development work is completed in Java on Linux. The combination of these two tools provides a platform for creating commercial-quality Web applications, Murray said. "In the process of doing these projects, we found that we need to understand the customer's existing application code as a whole," he recalled. Locks. c (in the/developerworks/locks Directory of the compressed file downloaded) is a code snippet for Java Virtual Machine Profiler Interface (JVMPI) read/Write locks and a large amount of debugging code.

Representatives of Linux developers

"Do not write system-specific code when the situation permits," Murray said. Instead, he overcame the difficulty by "writing cross-platform code ". The hired Murray insists that his biggest capital will always be "to write code with commercial quality, to build and provide network services, to customize the OS or kernel, and it is completely based on a reliable open-source platform ".

The following is a code snippet from a cross-platform custom IMAP server developed by developers of Linux and MacOS X. The code implements a simple growth cache for processing strings. This avoids cache overflow (do not forget those security vulnerabilities), and does not need to be re-allocated every time you do something. It is implemented by maintaining a simple variable-length cache, which can be full or cleared. This cache has been used by an IMAP server for an experiment. This server is completed by a team after a week of intense work.

In addition to the implementation of a simple string buffer, this code also implements a variable-size string array. It completes a simple interface. after writing a string, you can mark it and continue writing the next one. In addition, this will save space allocation and organize messy code together.

The complete IMAP server code will be released some time this year.

Listing 4. part of the custom IMAP server

# Ifndef HOED_BUF_H

# Define HOED_BUF_H

Typedef struct {

Char * str;

Int size;

Int length;

Int str_start;

Int max_size;

Int n_strings;

Int size_strings;

Int * str_posn;

Char ** str_set;

} Hoed_buf_t;

# If _ GNUC _> 2 | (_ GNUC _ = 2 & _ GNUC_MINOR _> 4)

# Define PRINTF (f, a) _ attribute _ (format (printf, f, )))

# Else

# Define PRINTF (f,)

# Endif

Extern hoed_buf_t * hoed_buf_alloc (int init_size, int max_size );

Extern void hoed_buf_free (hoed_buf_t *);

Extern void hoed_buf_reset (hoed_buf_t *);

Extern void hoed_buf_new_string (hoed_buf_t *);

Extern char ** hoed_buf_get_set (hoed_buf_t *, int * n_string );

Extern char * hoed_buf_put_char (hoed_buf_t *, char toadd );

Extern char * hoed_buf_sprintf (hoed_buf_t *, const char * format ,...)

PRINTF (2, 3 );

Extern char * hoed_buf_strcat (hoed_buf_t *, const char * append );

Extern char * hoed_buf_cat_sprintf (hoed_buf_t *, const char * format ,...)

PRINTF (2, 3 );

# Endif/* HOED_BUF_H */

A killer Linux application

For Murray, there are two killer Linux applications: Emacs and Netscape Navigator. "Emacs may be the most impressive and widely used Linux-based application," he said. "The other is Netscape Navigator. Once, we wanted to support more than 20 types of UNIX, and I finished all the work on Linux ".

"What's interesting is that Linux-based applications may run on many different UNIX systems or even install Cygwin Windows systems," he continued ."

What is the future of Linux?

Currently, Murray is working on several Linux projects, from distributed Office applications supporting email, messages, and shared databases to network applications using standard tools (standard tools include: apache/Tomcat, PHP, PostgreSQL, MySQL, and Linux ). Murray has his own company dedicated to providing host services for network services and network applications.

For Murray, the List of Linux-powered applications is growing. "There are many," he said. "The list of Oracle, WebSphere, Apache, PostgresQL, MySQL, Cyrus IMAP... is very long and growing ."

For Murray, this is the end of Linux. "All our servers run Linux. regardless of the target platform, our main development is on Linux. we recommend Linux to users to run server applications," he said. "The pace of rapid development of Linux, the wide support of open source code organizations, and low development costs. if you combine these, you will know that Linux is a platform that is hard to beat ".

Get free LAMP Brothers original PHP Tutorial CD/the elaborate PHP Essentials edition, details consulting official website Customer Service: http://www.lampbrother.net

PHPCMS secondary development http://yun.itxdl.cn/online/phpcms/index.php? U = 5

Develop http://yun.itxdl.cn/online/weixin/index.php? U = 5

Mobile internet server development http://yun.itxdl.cn/online/server/index.php? U = 5

Javascript http://yun.itxdl.cn/online/js/index.php course? U = 5

CTO training camp http://yun.itxdl.cn/online/cto/index.php? U = 5

The above section introduces the development experience of senior Linux programmers, including some content, and hopes to help those who are interested in PHP tutorials.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.