Use of the source code in apue2-general Linux technology-Linux programming and kernel information. The following is a detailed description. Download the source code and decompress it to a directory, such as my ~ /New/apue
Go to the directory, modify Make. defines. linux, and assign WKDIR to the directory decompressed above.
Go to the std subdirectory, modify linux. mk, and change the command nawk to awk.
Make
The apue. h contained in the example is located in the include sub-folder of the decompressed directory, so make some modifications to the corresponding original file. For example, in the program my_ls.c in fig1.3, I put it in ~ /New/apue/src:
CODE: # include "../include/apue. h"
# Include
Int main (int argc, char * argv [])
{
DIR * dp;
Struct dirent * dirp;
If (argc! = 2)
Err_quit ("usage: % s directory_name", argv [0]);
If (dp = opendir (argv [1]) = NULL)
Err_sys ("can't open % s", argv [1]);
While (dirp = readdir (dp ))! = NULL)
Printf ("% s \ n", dirp-> d_name );
Closedir (dp );
Exit (0 );
} |