|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - downloadIndex: ┃ T m ┃
Length: 3485 (0xd9d) Types: TextFile Names: »mkprog.1«
└─⟦a0efdde77⟧ Bits:30001252 EUUGD11 Tape, 1987 Spring Conference Helsinki └─ ⟦this⟧ »EUUGD11/euug-87hel/sec1/mkprog/mkprog.1«
.TH MKPROG 1 local .SH NAME mkprog \- make skeleton of program .SH SYNOPSIS .B mkprog [ .B \-RSfi ] [ .B -o option_string ] [ .B \-n prog_name ] [ .B \-t tab_indent] .SH DESCRIPTION .I mkprog will make a skeleton of a program, which includes the ``boiler-plate'' that almost all programs contain. That includes certain external declarations, the code for interpreting specified command line options, and the code for for looping over named files, with standard input as the default. .PP The generated program will interpret command line arguments using getopt(3). It will interpret the file '-' as being standard input, and will accept it (once) in any position among the files to be read. If compiled on a UNIX system it will check that all files are readable, using access(2), before opening any of them. Files are opened using a modified form of efopen(3h), modified from Kernighan and Pike to recognize \&'-' as representing standard input. .PP The program so made is normally placed in .IR prog.c . To get a feel for the generated code, give the command: .IP mkprog \-o ab .PP and look at the program produced in .IR prog.c . .PP The most important flag is the .B \-o flag, which is followed by a string containing the flags that the generated program is to interpret. Flags must be a single letter each. If they represent a binary option the letter is followed by nothing, if they precede a numerical valued option the flag must be followed by a .BR # , and if they introduce a string value the flag must be followed by a .BR $ . So .IP mkprog \-o \'ab#c$\' .PP will produce a program which interprets a binary flag, .IR a , a flag followed by a numerical argument, .IR b , and a flag followed by a string argument, .IR c . That program would be invoked, for example, as .IP prog \-a \-b 17 \-c string .PP Internally, a binary option like a sets a variable that would be called .IR a_flag , a flag followed by a numerical argument would assign its value to an int variable called .IR b_value , while a flag followed by a string value will make a character pointer called .I c_string point to it. .PP Such variables are initialized explicitly to zero in the case of .I ints and to the null pointer in the case of .IR *char 's. .PP The binary flags interpreted are: .TP .B \-R produce a header for .IR rcs (1). .TP .B \-S produce a header for .IR sccs (1). .TP .B \-f Produce a skeleton for a program that does not read files. .TP \-h Produce an include file, called .I prog.h by default, containing the global declarations. A suitable include statement is generated in the source file. .PP The flags introducing arguments are: .TP .BI \-n " prog_name" Produces a program called .I prog_name.c rather than the default .IR prog.c . Also, if the .I \-h flag is present, the include file will be named .IR prog_name.h . .TP .BI \-t " tab_indent" The program is indented in increments of .IR tab_indent . The default is 4. .SH LIMITATIONS The most serious limitation is in the naming of the variables that relate to the string and numerical options, and in the assignment of default values. It is easy to write a program that will accept, for each flag, a name and initial value for the corresponding variable. It is not clear how much easier such a program would be in practice. Variable names can (and usually should) be changed with global substitutions, and the initialization statements stand out where they can be conveniently edited. .SH SEE ALSO getopt(3), efopen(3h)