NAME parscl - parse command line arguments SYNOPSIS integer function parscl (str, buf) character str (ARB), buf (MAXARGBUF) DESCRIPTION 'Parscl' is used to parse most standard Subsystem command line formats automatically. It examines the command line, parses it according to instructions present in its arguments, and makes the result available to the user for further processing. This processing is normally done with the aid of a set of standard Subsystem macros, described below. All arguments handled by 'parscl' are deleted from the command line, so any remaining special cases may be handled by the user. The argument 'str' is a string describing the syntax of the command line. The argument 'buf' is a one-dimensional array of characters normally declared with the standard Subsystem macro 'ARG_DECL'. The function return is OK if the command line parsed successfully, ERR if an illegal option was seen or a required parameter was missing. 'Parscl' handles several types of arguments. "Flag" arguments are single-letter flags, preceded by a hyphen or dash, that have no parameters and may be grouped together in a single argument; for example, "-a" or "-acq". Arguments with parameters may have a string or integer value following the single-letter, or present in the next argument in the command line. For example, "-p1", "-p 1", "-nfilename", or "-n filename". Parameters for such arguments may be optional or required. Finally, some arguments may be ignored entirely, while others may not be allowable at all. The argument 'str' contains a specification of allowable arguments and their types. Each specification consists of an option letter (case is ignored) followed by a type in angle brackets. The following types are allowable: 'f' or 'flag' for flag arguments, 'ign' or 'ignored' for ignorable arguments, 'na' for arguments that are not allowable, 'oi' or 'opt int' for arguments with an optional integer parameter, 'os' or 'opt str' for arguments with an optional string parameter, 'ri' or 'req int' for arguments with a required integer parameter, and 'rs' or 'req str' for arguments with a required string parameter. For example, a command with the syntax -u [-l ] [-i []] would pass the following string to 'parscl': u l i Order of arguments on the command line is unimportant, as well as the case of the option letter used. The command line is typically parsed and then examined with a number of standard Subsystem macros. 'ARG_DECL' is used to declare the buffer required by 'parscl'. 'PARSE_COMMAND_LINE(str,msg)' is used to invoke 'parscl'; 'str' is passed to 'parscl' as its first argument, and 'msg' is passed to 'error' to be printed if the command line could not be parsed. For example, one might use PARSE_COMMAND_LINE ("uli"s, "usage: cmd -u [-l] [-i[]]"p) Once 'parscl' has been called in this manner, default values for optional parameters may be supplied with 'ARG_DEFAULT_INT' and 'ARG_DEFAULT_STR': ARG_DEFAULT_STR(i,"/dev/stdin1"s) One may test for the presence of an argument on the command line with 'ARG_PRESENT', and retrieve argument values with 'ARG_VALUE' and 'ARG_TEXT': if (ARG_PRESENT (l)) lower = ARG_VALUE (l) else lower = 1 Once as much as possible of this kind of argument parsing is complete, the user may examine any remaining arguments by fetching them with 'getarg'. IMPLEMENTATION 'Parscl' scans the specification string and builds a 26 element array. Each element of the array corresponds to a letter A - Z and contains an integer describing the type of argument expected when that letter is encounterd. Then 'parscl' scans the command line arguments, skipping those that do not begin with a hyphen or have a letter as the second character. Arguments that begin with hyphens are examined further. If the letter in the second position of the argument is to be ignored, it is skipped. Flag arguments are simply marked "present" in the argument buffer. Values for string parameters are stored in the argument buffer for later retrieval. Values for integer parameters are converted with 'gctoi' (thus allowing arbitrary radix representation) then stored in the argument buffer. CALLS ctoc, delarg, gctoi, getarg, mapdn, strbsr ARGUMENTS MODIFIED buf SEE ALSO delarg (2), getarg (2), gfnarg (2)