This library allows IPW programs to use string options instead of single-character options. To use this library, a program's Makefile must contain this line before any "include" statements:
STRING_OPTIONS := 1For example, a sample Makefile of a program using string options might look like this:
PGM := foo DESCRIPTION := a sample IPW program SRCS := main.c STRING_OPTIONS := 1 include $(IPW)/make/command
This library contains modified versions of these functions from the standard IPW library:
The modified versions have the same interface; i.e., they are invoked in the same way as their counterparts in the standard library.The difference is that the program's options have names which are strings instead of single-characters. To illustrate this difference, here is the example source code from the man page for the function ipwenter as it would appear with this library:
main( int argc, char *argv[]) { /* "-apple" option; no arguments */ static OPTION_T opt_apple = { "apple", "(option description)", }; /* "-banana" option; >= 3 integer arguments */ static OPTION_T opt_banana = { "banana", "(option description)", INT_OPTARGS, "(arg description)", OPTIONAL, 3, }; /* "-cherry" option; >= 1 real argument; must be specified */ static OPTION_T opt_cherry = { "cherry", "(option description)", REAL_OPTARGS, "(arg description)", REQUIRED, }; /* "-date" option; >= 1 and <= 4 string arguments; must be specified */ static OPTION_T opt_date = { "date", "(option description)", STR_OPTARGS, "(arg description)", REQUIRED, 1, 4 }; static OPTION_T operands = { OPERAND, "(operand description)", STR_OPERANDS, "(operand placeholder)", OPTIONAL }; static OPTION_T *optv[] = { &opt_apple, &opt_banana, &opt_cherry, &opt_date, &operands, 0 }; ipwenter(argc, argv, optv, IPW_DESCRIPTION); ... }
Abbreviating String Options
The user can abbreviate a string option as long as the
abbreviation is distinct. In the example above, the user can specify
the first option in one of the following ways:
-apple -appl -app -ap -a
If there was another option named "apricot", then the shortest abbreviations the user could use for the two "a" options would be "-app" and "-apr".
String options permit more descriptive names for options, and improve the readability of shell scripts containing IPW commands. And yet, when entering IPW commands directly, the user can save keystrokes by using abbreviations for string options.