v17i075: parseargs - functions to parse command line arguments, Patch03
Brad Appleton
brad at hcx1.ssd.csd.harris.com
Sat Mar 30 05:25:17 AEST 1991
Submitted-by: Brad Appleton <brad at hcx1.ssd.csd.harris.com>
Posting-number: Volume 17, Issue 75
Archive-name: parseargs/patch03
Patch-To: parseargs: Volume 17, Issue 45-57
This is a patch for the ascii version of the parseargs documentation.
It corresponds to the previous patch (patch2) that I sent.
______________________ "And miles to go before I sleep." ______________________
Brad Appleton Harris Corp., Computer Systems Division
Software Engineer 2101 West Cypress Creek Road, M/S 161
brad at ssd.csd.harris.com Fort Lauderdale, FL 33309-1892 USA
...!uunet!hcx1!brad Phone: (305) 973-5360
~~~~~~~~~~~~~~~~~~~~ Disclaimer: I said it, not my company! ~~~~~~~~~~~~~~~~~~~
#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:
# "End of shell archive."
# Contents: PATCH
# Wrapped by brad at hcx2 on Tue Mar 26 12:05:39 1991
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'PATCH' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'PATCH'\"
else
echo shar: Extracting \"'PATCH'\" \(36746 characters\)
sed "s/^X//" >'PATCH' <<'END_OF_FILE'
X*** argtype3.txt.OLD Tue Mar 26 12:01:39 1991
X--- argtype3.txt Tue Mar 26 11:59:44 1991
X***************
X*** 38,54 ****
X DESCRIPTION
X Each of these converts a parameter value to the internal
X form, including validity checking. Their parameters and
X! return values all behave similarly. One of these routines
X! are called when an argunent of that particular type is
X! matched by one of the argument parsing function in par-
X! seargs(3). When such an argument is matched, its argument
X! translation routines is invoked and is passed (1) the
X! address of the argument descriptor for the matched argument,
X! (2) the possible argument string for that matched argument,
X! and (3) a boolean filed that is TRUE only if the second
X! parameter points to temporary storage (indicating that some
X! copying may need to be done instead of just pointing to the
X! same object).
X
X Once the argument translation routine is invoked, it is
X responsible for converting the argument string to the
X--- 38,54 ----
X DESCRIPTION
X Each of these converts a parameter value to the internal
X form, including validity checking. Their parameters and
X! return values all behave similarly. One of these routines is
X! called when an argument of that particular type is matched
X! by one of the argument parsing function in parseargs(3).
X! When such an argument is matched, its argument translation
X! routines is invoked and is passed (1) the address of the
X! argument descriptor for the matched argument, (2) the possi-
X! ble argument string for that matched argument, and (3) a
X! boolean filed that is TRUE only if the second parameter
X! points to temporary storage (indicating that some copying
X! may need to be done instead of just pointing to the same
X! object).
X
X Once the argument translation routine is invoked, it is
X responsible for converting the argument string to the
X***************
X*** 91,103 ****
X still match other arguments.
X
X
X! PSEUDO-TYPES
X ArgUsage is used to specify an argument that causes the com-
X mand usage to be printed.
X
X ArgDummy is used to force an item to show up in usage-
X messages but the item itself is never matched against any
X! argumenmts from the command-line.
X
X ArgEnd is used by Amiga style command-lines to indicate an
X argument that forces all remaining arguments to be con-
X--- 91,103 ----
X still match other arguments.
X
X
X! PSEUDO-TYPES: argUsage, argDummy, argEnd
X ArgUsage is used to specify an argument that causes the com-
X mand usage to be printed.
X
X ArgDummy is used to force an item to show up in usage-
X messages but the item itself is never matched against any
X! arguments from the command-line.
X
X ArgEnd is used by Amiga style command-lines to indicate an
X argument that forces all remaining arguments to be con-
X***************
X*** 108,114 ****
X available for identification in the corresponding command-
X line styles.
X
X! STRING-TYPES
X ArgStr is one of the few argument translation routines that
X actually uses the copyf flag. If copyf is true then the
X string is duplicated.
X--- 108,114 ----
X available for identification in the corresponding command-
X line styles.
X
X! STRING-TYPES: argStr
X ArgStr is one of the few argument translation routines that
X actually uses the copyf flag. If copyf is true then the
X string is duplicated.
X***************
X*** 137,143 ****
X
X
X
X! CHARACTER-TYPES
X ArgChar assigns the given character to the value referenced
X by arg_valp(ad) (unless the argument is a vector in which
X case the given character is appended to the end).
X--- 137,143 ----
X
X
X
X! CHARACTER-TYPES: argChar
X ArgChar assigns the given character to the value referenced
X by arg_valp(ad) (unless the argument is a vector in which
X case the given character is appended to the end).
X***************
X*** 150,156 ****
X Unlike argStr, argChar will translate character escape
X sequences such as `\n' and `\012'.
X
X! INTEGER-TYPES
X Each of these functions converts the given string to the
X desired integral type. The value may be specified as an
X octal number by specifying the first digit to be 0. Simi-
X--- 150,156 ----
X Unlike argStr, argChar will translate character escape
X sequences such as `\n' and `\012'.
X
X! INTEGER-TYPES: argInt, argShort, argLong
X Each of these functions converts the given string to the
X desired integral type. The value may be specified as an
X octal number by specifying the first digit to be 0. Simi-
X***************
X*** 157,167 ****
X larly, If the first two characters are `0x' then the number
X is treated as hexadecimal.
X
X! FLOATING-POINT-TYPES
X Each of these functions converts the given string to the
X desired floating-point type.
X
X! BOOLEAN-TYPES
X ArgBool and argSBool set a boolean value (if no value is
X given). ArgUBool unsets a boolean value (if no value is
X given). ArgTBool toggles a boolean value (if no value is
X--- 157,167 ----
X larly, If the first two characters are `0x' then the number
X is treated as hexadecimal.
X
X! FLOATING-POINT-TYPES: argFloat, argDouble
X Each of these functions converts the given string to the
X desired floating-point type.
X
X! BOOLEAN-TYPES: argBool, argSBool, argTBool, argUBool
X ArgBool and argSBool set a boolean value (if no value is
X given). ArgUBool unsets a boolean value (if no value is
X given). ArgTBool toggles a boolean value (if no value is
X***************
X*** 209,215 ****
X ``1'', ``+'', ``ON'', or ``TRUE''
X The corresponding boolean flag is set to TRUE.
X
X! LIST TYPES
X The listStr argument translation routine is only intended
X for use on behalf of arguments that have the ARGLIST flag
X enabled. It will allocate space for a new node (and for the
X--- 209,215 ----
X ``1'', ``+'', ``ON'', or ``TRUE''
X The corresponding boolean flag is set to TRUE.
X
X! LIST TYPES: listStr
X The listStr argument translation routine is only intended
X for use on behalf of arguments that have the ARGLIST flag
X enabled. It will allocate space for a new node (and for the
X***************
X*** 229,235 ****
X followed by the type of the items in the vector.
X
X SEE ALSO
X! parseargs(3), parseargs(1),
X
X
X
X--- 229,235 ----
X followed by the type of the items in the vector.
X
X SEE ALSO
X! parseargs(3), parseargs(3), parsecntl(1),
X
X
X
X*** parseargs1.txt.OLD Tue Mar 26 12:01:48 1991
X--- parseargs1.txt Tue Mar 26 11:59:52 1991
X***************
X*** 81,87 ****
X the desired type, and diagnoses problems such as missing
X arguments, extra arguments, and argument values that are
X syntactically incorrect. Other behavior such as prompting
X! the user for missing arguments and ignoring as command-line
X syntax may be specified on the command-line through the use
X of various options, or through the use of the ``PARSECNTL''
X environment variable.
X--- 81,87 ----
X the desired type, and diagnoses problems such as missing
X arguments, extra arguments, and argument values that are
X syntactically incorrect. Other behavior such as prompting
X! the user for missing arguments and ignoring bad command-line
X syntax may be specified on the command-line through the use
X of various options, or through the use of the ``PARSECNTL''
X environment variable.
X***************
X*** 233,243 ****
X ``sh'', ``csh'', ``ksh'', ``tcsh'', ``bash'', ``rc'',
X ``awk'', and ``perl'' as valid command interpreters. Awk
X output is slightly different from that of the other shells
X! in that the actual variable setting are not printed but each
X! line of an associative array is printed (the first field is
X! the array index, the second is the value for that index).
X! If no shell is specified, then the Bourne shell (``sh'')
X! will be assumed.
X
X If the user wishes to use a value other than ``TRUE'' for a
X boolean flag that is true, this may be done using the -T
X--- 233,243 ----
X ``sh'', ``csh'', ``ksh'', ``tcsh'', ``bash'', ``rc'',
X ``awk'', and ``perl'' as valid command interpreters. Awk
X output is slightly different from that of the other shells
X! in that the actual variable settings are not printed but
X! each line of an associative array is printed (the first
X! field is the array index, the second is the value for that
X! index). If no shell is specified, then the Bourne shell
X! (``sh'') will be assumed.
X
X If the user wishes to use a value other than ``TRUE'' for a
X boolean flag that is true, this may be done using the -T
X***************
X*** 274,280 ****
X parseargs to be able to distinguish options to itself from
X options for the calling program.
X
X! The default behavior of parseargs is allow both single-
X character options and long-options (keywords) on the
X command-line. The user may specify that only options (long-
X options) are to be permitted by specifying the -o (-l)
X--- 274,280 ----
X parseargs to be able to distinguish options to itself from
X options for the calling program.
X
X! The default behavior of parseargs is to allow both single-
X character options and long-options (keywords) on the
X command-line. The user may specify that only options (long-
X options) are to be permitted by specifying the -o (-l)
X***************
X*** 340,349 ****
X positional parameters of the calling program will be re-
X assigned to the contents of the argument list.
X
X! For the awk and perl, if the variable name corresponding to
X! the ARGLIST argument is ``ARGV'', then the positional
X! parameters of the calling program will be re-assigned to the
X! contents of the argument list.
X Bourne Shell Argument Lists
X
X For the Bourne shell, if the associated variable name is NOT
X--- 340,349 ----
X positional parameters of the calling program will be re-
X assigned to the contents of the argument list.
X
X! For awk and perl, if the variable name corresponding to the
X! ARGLIST argument is ``ARGV'', then the positional parameters
X! of the calling program will be re-assigned to the contents
X! of the argument list.
X Bourne Shell Argument Lists
X
X For the Bourne shell, if the associated variable name is NOT
X***************
X*** 471,479 ****
X
X For perl, each argument list is considered an array and is
X set using the following syntax:
X! @name=( arg1 , arg2 , ... )
X
X-
X The word-lists used by the C shell, the arrays used by the
X Korn shell, the Plan 9 shell, awk, perl, and the positional
X parameters used by all shells (if overwritten by parseargs)
X--- 471,479 ----
X
X For perl, each argument list is considered an array and is
X set using the following syntax:
X! @name=( arg1 , arg2 , ... );
X! A Final Note on Argument Lists
X
X The word-lists used by the C shell, the arrays used by the
X Korn shell, the Plan 9 shell, awk, perl, and the positional
X parameters used by all shells (if overwritten by parseargs)
X***************
X*** 493,499 ****
X is parsed. The command-line will over-ride any options that
X are specified in this environment variable (except that
X ARGLISTs and ARGVECs set in ``CMD_ARGS'' will be appended
X! from the command-line
X
X It is important to note that the contents of the
X ``CMD_ARGS'' environment variable are NOT expanded by the
X--- 493,499 ----
X is parsed. The command-line will over-ride any options that
X are specified in this environment variable (except that
X ARGLISTs and ARGVECs set in ``CMD_ARGS'' will be appended
X! from the command-line if they are selected).
X
X It is important to note that the contents of the
X ``CMD_ARGS'' environment variable are NOT expanded by the
X***************
X*** 552,558 ****
X Ignore any unrecognized or improperly specified
X command-line arguments and continue execution of the
X program. Normally, if an argument is unmatched (or is
X! improperly specified), a usage message is printed
X program execution is terminated.
X
X OptsOnly
X--- 552,558 ----
X Ignore any unrecognized or improperly specified
X command-line arguments and continue execution of the
X program. Normally, if an argument is unmatched (or is
X! improperly specified), a usage message is printed and
X program execution is terminated.
X
X OptsOnly
X***************
X*** 599,612 ****
X
X
X
X! Setting this flag cause character-case to be ignored
X when attempting to match single-character argument
X names (i.e. causes "-i" and "-I" will be considered
X equivalent).
X
X If the environment variable ``PARSECNTL'' is empty or
X! undefined, then parsing behavior set by the programmer is
X! used. If the programmer has not explicitly used
X parsecntl(3) to modify the parsing behavior, then the
X default behavior will be ``Flags1st'' for Unix systems,
X ``!Prompt + !Ignore'' for AmigaDOS systems, ``CaseIgnore''
X--- 599,612 ----
X
X
X
X! Setting this flag causes character-case to be ignored
X when attempting to match single-character argument
X names (i.e. causes "-i" and "-I" will be considered
X equivalent).
X
X If the environment variable ``PARSECNTL'' is empty or
X! undefined, then the parsing behavior set by the programmer
X! is used. If the programmer has not explicitly used
X parsecntl(3) to modify the parsing behavior, then the
X default behavior will be ``Flags1st'' for Unix systems,
X ``!Prompt + !Ignore'' for AmigaDOS systems, ``CaseIgnore''
X*** parseargs3.txt.OLD Tue Mar 26 12:01:58 1991
X--- parseargs3.txt Tue Mar 26 12:00:11 1991
X***************
X*** 15,21 ****
X int fparseargs( FILE *fp, ARGDESC *argd )
X int lparseargs( ArgList *argls, ARGDESC *argd )
X int sparseargs( char *str, ARGDESC *argd )
X! int vparseargs( ARGDESC *argd, ... )
X void usage( const ARGDESC *argd )
X
X DESCRIPTION
X--- 15,21 ----
X int fparseargs( FILE *fp, ARGDESC *argd )
X int lparseargs( ArgList *argls, ARGDESC *argd )
X int sparseargs( char *str, ARGDESC *argd )
X! int vparseargs( ARGDESC *argd, int argc, ... )
X void usage( const ARGDESC *argd )
X
X DESCRIPTION
X***************
X*** 39,45 ****
X ``-v\nval'' is a not).
X
X Given an ArgList and an argdesc array, lparseargs will parse
X! arguments in a file in much the same manner as parseargs.
X
X Given a single string and an argdesc array, sparseargs will
X parse arguments from a string in much the same manner as
X--- 39,46 ----
X ``-v\nval'' is a not).
X
X Given an ArgList and an argdesc array, lparseargs will parse
X! arguments in an ArgList in much the same manner as par-
X! seargs.
X
X Given a single string and an argdesc array, sparseargs will
X parse arguments from a string in much the same manner as
X***************
X*** 56,62 ****
X to parse, and a (possibly NULL terminated) list of
X argument-strings and parses them in much the same manner as
X parseargs. Unlike sparseargs, vparseargs assumes that all
X- parameters are already split up into tokens, hence any
X
X
X
X--- 57,62 ----
X***************
X*** 71,79 ****
X
X
X
X! whitespace characters contained in any of the string-
X! parameters are used as is (and will be considered a part of
X! an argument name or value).
X
X
X Given an argdesc array, usage will print the usage for the
X--- 71,80 ----
X
X
X
X! parameters are already split up into tokens, hence any whi-
X! tespace characters contained in any of the string-parameters
X! are used as is (and will be considered a part of an argument
X! name or value).
X
X
X Given an argdesc array, usage will print the usage for the
X***************
X*** 103,109 ****
X
X argTypePtr_t ad_type;
X This field is a pointer to a type conversion function
X! (such as the ones provided in argtype(3). The type
X conversion function is responsible for verifying the
X validity of the argument, allocating any necessary
X storage for its internal representation, and converting
X--- 104,110 ----
X
X argTypePtr_t ad_type;
X This field is a pointer to a type conversion function
X! (such as the ones provided in argtype(3)). The type
X conversion function is responsible for verifying the
X validity of the argument, allocating any necessary
X storage for its internal representation, and converting
X***************
X*** 121,128 ****
X
X ARBPTR ad_valp;
X This field is a generic pointer to the storage used to
X! represent the internal value of the command-line argu-
X! ment. It may be a pointer to a number, a boolean value,
X
X
X
X--- 122,128 ----
X
X ARBPTR ad_valp;
X This field is a generic pointer to the storage used to
X! represent the internal value of the command-line
X
X
X
X***************
X*** 137,163 ****
X
X
X
X! a string, a list, or anything else for which there
X! exists a corresponding arg-type function to use in the
X! ad_type field. In the case of of parseargs(1) this
X! field must be the name of the corresponding shell vari-
X! able which eventually hold the value of the argument
X! given on the command-line.
X
X const char *ad_prompt;
X This field contains the long-name of the argument and
X an optional description (the description must be
X separated from the long-name by at least one whitespace
X! characters and may optionally be enclosed in a set of
X balanced delimiters (such as parentheses, curly-braces,
X! square-brackets, or angle-brackets. If the long-name
X contains any uppercase characters, then the substring
X of long-name consisting of all uppercase characters is
X! used as the argument name and the entire long-name is
X! used as the name of the argument-value (if a value my
X! be supplied). The long-name may be matched by supplying
X! a unique prefix of either the argument name or the
X! argument-value name.
X
X DEFINING ARGDESC ARRAYS
X When defining an argdesc array, the first item in the list
X--- 137,164 ----
X
X
X
X! argument. It may be a pointer to a number, a boolean
X! value, a string, a list, or anything else for which
X! there exists a corresponding arg-type function to use
X! in the ad_type field. In the case of of parseargs(1)
X! this field must be the name of the corresponding shell
X! variable which will eventually hold the value of the
X! argument given on the command-line.
X
X const char *ad_prompt;
X This field contains the long-name of the argument and
X an optional description (the description must be
X separated from the long-name by at least one whitespace
X! character and may optionally be enclosed in a set of
X balanced delimiters (such as parentheses, curly-braces,
X! square-brackets, or angle-brackets). If the long-name
X contains any uppercase characters, then the substring
X of long-name consisting of all uppercase characters is
X! used as the argument keyword and the entire long-name
X! is used as the name of the argument (if a value my be
X! supplied). The long-name may be matched by supplying a
X! unique prefix of either the argument keyword or the
X! argument name.
X
X DEFINING ARGDESC ARRAYS
X When defining an argdesc array, the first item in the list
X***************
X*** 186,197 ****
X ENDOFARGS
X };
X
X- This describes a program accepting up to three flag argu-
X- ments and one or two positional arguments, plus a list of
X- additional file arguments. Only the first positional
X
X
X
X Page 3
X
X
X--- 187,197 ----
X ENDOFARGS
X };
X
X
X
X
X+
X+
X Page 3
X
X
X***************
X*** 203,209 ****
X
X
X
X! argument is required. The possible flags (in UNIX) are:
X
X -c count An integer repetition count. This defaults to
X two.
X--- 203,212 ----
X
X
X
X! This describes a program accepting up to three flag argu-
X! ments and one or two positional arguments, plus a list of
X! additional file arguments. Only the first positional argu-
X! ment is required. The possible flags (in UNIX) are:
X
X -c count An integer repetition count. This defaults to
X two.
X***************
X*** 251,263 ****
X "-x value"); Its mere presence (or lack thereof) on the
X command-line is sufficient to determine the necessary
X action(s) to take (as in "-x"). Boolean argument types
X! and Pseudo-argument types automatically default to ARG-
X! NOVAL.
X
X- ARGVALOPT
X
X
X-
X Page 4
X
X
X--- 254,263 ----
X "-x value"); Its mere presence (or lack thereof) on the
X command-line is sufficient to determine the necessary
X action(s) to take (as in "-x"). Boolean argument types
X! and Pseudo-argument types automatically default to
X
X
X
X Page 4
X
X
X***************
X*** 269,274 ****
X--- 269,277 ----
X
X
X
X+ ARGNOVAL.
X+
X+ ARGVALOPT
X This flag is used to indicate that the command-line
X argument takes a value (as in "-s string" or
X "/str=string") but that the value to this command-line
X***************
X*** 318,326 ****
X line.
X
X ARGVALSEP
X- The value to this argument was supplied in a separate
X- argv element from the argument itself (as in "-x value"
X- as opposed to "-xvalue").
X
X
X
X--- 321,326 ----
X***************
X*** 335,340 ****
X--- 335,344 ----
X
X
X
X+ The value to this argument was supplied in a separate
X+ argv element from the argument itself (as in "-x value"
X+ as opposed to "-xvalue").
X+
X ARGKEYWORD
X This argument was matched as a keyword (long-form) on
X the command-line and not as a single character.
X***************
X*** 383,395 ****
X provided.
X
X arg_description(ad)
X- Return the description string (or an empty string if no
X- description was given) for this argument.
X
X- ARG_isPOSITIONAL(ad)
X
X
X-
X Page 6
X
X
X--- 387,395 ----
X***************
X*** 401,406 ****
X--- 401,410 ----
X
X
X
X+ Return the description string (or an empty string if no
X+ description was given) for this argument.
X+
X+ ARG_isPOSITIONAL(ad)
X Evaluates to TRUE if this argument may be positionally
X matched.
X
X***************
X*** 449,461 ****
X arrays. The "old-style" is still accepted (but if used it is
X recommended that the STARTOFARGS macro is used in conjunc-
X tion with ENDOFARGS). An example use of these macros
X- (which, with one exception, all begin with ``CMD'') follows:
X- #include <parseargs.h>
X
X- static BOOL bflag = FALSE;
X
X
X-
X Page 7
X
X
X--- 453,461 ----
X***************
X*** 467,472 ****
X--- 467,476 ----
X
X
X
X+ (which, with one exception, all begin with ``CMD'') follows:
X+ #include <parseargs.h>
X+
X+ static BOOL bflag = FALSE;
X static char *arg1 = CHARNULL;
X static char *arg2 = CHARNULL;
X
X***************
X*** 515,524 ****
X keywords to display command-usage for all command-line
X styles. In Addition, for VMS style commands, the qualifiers
X /INPUT=file, /OUTPUT=file, and /ERROR=file, may be used to
X- redirect stdin, stdout, and stderr (respectively) to a file.
X- For AmigaDOS style commands, the keyword ``ENDKWDS'' may be
X- used to disable parsing for any more keywords on the
X- command-line.
X
X
X
X--- 519,524 ----
X***************
X*** 533,538 ****
X--- 533,543 ----
X
X
X
X+ redirect stdin, stdout, and stderr (respectively) to a file.
X+ For AmigaDOS style commands, the keyword ``ENDKWDS'' may be
X+ used to disable parsing for any more keywords on the
X+ command-line.
X+
X SUPPLYING DEFAULT ARGUMENTS
X Programs that use parseargs may be given default arguments
X under UNIX and PCs through the use of environment variables
X***************
X*** 543,549 ****
X is parsed. The command-line will over-ride any options that
X are specified in this environment variable (except that
X ARGLISTs and ARGVECs set in ``CMD_ARGS'' will be appended
X! from the command-line
X
X It is important to note that the contents of the
X ``CMD_ARGS'' environment variable are NOT expanded by the
X--- 548,554 ----
X is parsed. The command-line will over-ride any options that
X are specified in this environment variable (except that
X ARGLISTs and ARGVECs set in ``CMD_ARGS'' will be appended
X! from the command-line if they are selected).
X
X It is important to note that the contents of the
X ``CMD_ARGS'' environment variable are NOT expanded by the
X***************
X*** 579,593 ****
X Prompt
X Prompt the user for any missing arguments that are
X required on the command-line. No special escaping or
X! quoting is performed on the user input. Required argu-
X! ments that expect a list of values will be repeatedly
X! prompted for (one item per line) until a blank line
X! (followed by a carriage return) is entered.
X
X- Ignore
X
X
X-
X Page 9
X
X
X--- 584,593 ----
X Prompt
X Prompt the user for any missing arguments that are
X required on the command-line. No special escaping or
X! quoting is performed on the user input. Required
X
X
X
X Page 9
X
X
X***************
X*** 599,609 ****
X
X
X
X Ignore any unrecognized or improperly specified
X command-line arguments and continue execution of the
X program. Normally, if an argument is unmatched (or is
X! improperly specified), a usage message is printed pro-
X! gram execution is terminated.
X
X OptsOnly
X Under UNIX, setting this flag will disable the parsing
X--- 599,614 ----
X
X
X
X+ arguments that expect a list of values will be repeat-
X+ edly prompted for (one item per line) until a blank
X+ line (followed by a carriage return) is entered.
X+
X+ Ignore
X Ignore any unrecognized or improperly specified
X command-line arguments and continue execution of the
X program. Normally, if an argument is unmatched (or is
X! improperly specified), a usage message is printed and
X! program execution is terminated.
X
X OptsOnly
X Under UNIX, setting this flag will disable the parsing
X***************
X*** 635,659 ****
X positional argument.
X
X CaseIgnore
X! Setting this flag cause character-case to be ignored
X when attempting to match single-character argument
X names (i.e. causes "-i" and "-I" will be considered
X equivalent).
X
X If the environment variable ``PARSECNTL'' is empty or unde-
X! fined, then parsing behavior set by the programmer is used.
X! If the programmer has not explicitly used parsecntl(3) to
X! modify the parsing behavior, then the default behavior will
X! be ``Flags1st'' for Unix systems, ``!Prompt + !Ignore'' for
X! AmigaDOS systems, ``CaseIgnore'' for MS-DOS and OS/2 sys-
X! tems, and ``Prompt'' for VMS systems.
X
X- USAGE MESSAGES
X- Through the use of an environment variable (or a VMS sym-
X- bol), the user may control the syntax and the verbosity of
X
X
X-
X Page 10
X
X
X--- 640,659 ----
X positional argument.
X
X CaseIgnore
X! Setting this flag causes character-case to be ignored
X when attempting to match single-character argument
X names (i.e. causes "-i" and "-I" will be considered
X equivalent).
X
X If the environment variable ``PARSECNTL'' is empty or unde-
X! fined, then the parsing behavior set by the programmer is
X! used. If the programmer has not explicitly used par-
X! secntl(3) to modify the parsing behavior, then the default
X! behavior will be ``Flags1st'' for Unix systems, ``!Prompt +
X! !Ignore'' for AmigaDOS systems, ``CaseIgnore'' for MS-DOS
X
X
X
X Page 10
X
X
X***************
X*** 665,670 ****
X--- 665,675 ----
X
X
X
X+ and OS/2 systems, and ``Prompt'' for VMS systems.
X+
X+ USAGE MESSAGES
X+ Through the use of an environment variable (or a VMS sym-
X+ bol), the user may control the syntax and the verbosity of
X the command-usage messages that are printed by parseargs.
X The desired level of verbosity may be set by defining the
X environment variable ``USAGECNTL" to be a combination of
X***************
X*** 712,725 ****
X LongOpts
X Long-option syntax is displayed.
X
X- KeyWords
X- Same as LongOpts.
X
X
X
X-
X-
X-
X Page 11
X
X
X--- 717,725 ----
X***************
X*** 731,736 ****
X--- 731,739 ----
X
X
X
X+ KeyWords
X+ Same as LongOpts.
X+
X If the environment variable ``USAGECNTL'' is empty or unde-
X fined, then the default usage level (which is presently
X ``Verbose + Options'') will be used.
X***************
X*** 751,765 ****
X ArgList structure. L_NEXT returns the address of the next
X item in the list and L_STRING returns the string-value of
X the current list-item. L_FLAGS return the arg-flags for a
X! given item in the list. With non-multivalued, only the flags
X! in the argument descriptor are needed; lists and vectors
X! however need a set of flags for each item they contain. Once
X! an arg-list has been created, it may be deallocated using
X! the function listFree. ListFree takes two parameters, the
X! first of which is the address of the first item in the arg-
X! list, and the second of which is a boolean value that is
X! TRUE only if each value pointed to by each item should also
X! be deallocated.
X
X An alternative to argument-lists is argument vectors (or
X arg-vectors). Arg-vectors use the ARGVEC flag instead of
X--- 754,766 ----
X ArgList structure. L_NEXT returns the address of the next
X item in the list and L_STRING returns the string-value of
X the current list-item. L_FLAGS return the arg-flags for a
X! given item in the list. With non-multivalued arguments, only
X! the flags in the argument descriptor are needed; lists and
X! vectors however need a set of flags for each item they con-
X! tain. Once an arg-list has been created, it may be deallo-
X! cated using the function listFree. ListFree takes one param-
X! eter: first of which is the address of the first item in the
X! arg-list.
X
X An alternative to argument-lists is argument vectors (or
X arg-vectors). Arg-vectors use the ARGVEC flag instead of
X***************
X*** 782,788 ****
X
X ( StrVec.array[ StrVec.count ] == (char *)NULL )
X
X- is always true, and character-vectors will always have an
X
X
X
X--- 783,788 ----
X***************
X*** 797,802 ****
X--- 797,803 ----
X
X
X
X+ is always true, and character-vectors will always have an
X extra NUL-character at the end such that:
X
X ( CharVec.array[ CharVec.count ] == '\0' )
X***************
X*** 848,854 ****
X printf( "String[%d]=%s, flags=%x\n",
X i, StrVec.array[i], StrVec.flags[i] );
X
X- for ( i = 0 ; i < NumVec.count ; i++ )
X
X
X
X--- 849,854 ----
X***************
X*** 863,868 ****
X--- 863,869 ----
X
X
X
X+ for ( i = 0 ; i < NumVec.count ; i++ )
X printf( "Number[%d]=%s, flags=%x\n",
X i, NumVec.array[i], NumVec.flags[i] );
X
X***************
X*** 887,900 ****
X being converted. Its main use is to find the location in
X which to store the converted value, located in
X argd->ad_valp. The string value to be converted is passed
X! in argp (which will be NULL if the ARGNOVAL flag was set for
X the corresponding entry in the arg-descriptor table). The
X! copyf flag is TRUE if the argp string value must be copied
X when saved. Most non-string types are copied implicitly
X (for example, integer arguments are stored in binary form,
X so the original string value need not be saved), so this
X argument can usually be ignored. Put simply, this flag is
X! TRUE when argp points to a temporary buffer area.
X
X If the type function successfully converts the value, and
X uses the entire value, it should return TRUE. If the type
X--- 888,901 ----
X being converted. Its main use is to find the location in
X which to store the converted value, located in
X argd->ad_valp. The string value to be converted is passed
X! in vp (which will be NULL if the ARGNOVAL flag was set for
X the corresponding entry in the arg-descriptor table). The
X! copyf flag is TRUE if the vp string value must be copied
X when saved. Most non-string types are copied implicitly
X (for example, integer arguments are stored in binary form,
X so the original string value need not be saved), so this
X argument can usually be ignored. Put simply, this flag is
X! TRUE when vp points to a temporary buffer area.
X
X If the type function successfully converts the value, and
X uses the entire value, it should return TRUE. If the type
X***************
X*** 914,920 ****
X #define REALLOC(ptr,size) ((! ptr) ? malloc(size) : realloc(ptr, size))
X typedef ARGVEC_T(FILE *) FILEvec_t;
X
X- BOOL argReadFile( ARGDESC *ad, char *vp, BOOL copyf )
X
X
X
X--- 915,920 ----
X***************
X*** 929,934 ****
X--- 929,935 ----
X
X
X
X+ BOOL argReadFile( ARGDESC *ad, char *vp, BOOL copyf )
X {
X register FILE *fp;
X fp = fopen(vp, "r");
X***************
X*** 979,986 ****
X
X Under VAX/VMS and AmigaDOS, single-character options are not
X used and the ``long'' name (in the prompt field of an argu-
X! ment descriptor) is always used to match for possible argu-
X! ments (or keywords, or qualifiers).
X
X
X
X--- 980,986 ----
X
X Under VAX/VMS and AmigaDOS, single-character options are not
X used and the ``long'' name (in the prompt field of an argu-
X! ment descriptor) is always used to match for possible
X
X
X
X***************
X*** 995,1000 ****
X--- 995,1002 ----
X
X
X
X+ arguments (or keywords, or qualifiers).
X+
X For all supported operating systems, a long option may be
X matched in one of two ways: it may match all uppercase char-
X acters in the prompt field, or it may match all characters
X***************
X*** 1045,1052 ****
X pe_NOMATCH
X Unable to match the named argument. This occurs when
X the argument keyword name passed to parsecntl (using
X- the pc_ARGFLAGS functions code) was found in the given
X- argdesc-array or in its default-list.
X
X
X
X--- 1047,1052 ----
X***************
X*** 1061,1066 ****
X--- 1061,1069 ----
X
X
X
X+ the pc_ARGFLAGS functions code) was found in the given
X+ argdesc-array or in its default-list.
X+
X pe_BADMODE
X Bad mode for given command in parsecntl. This occurs
X when pc_WRITE or pc_RDWR mode is passed to parsecntl in
X***************
X*** 1110,1121 ****
X Hence multiple ``leading dash'' arguments may specified as
X follows:
X
X- -f-dash_arg1 -f-dash_arg2 ...
X
X
X
X-
X-
X Page 17
X
X
X--- 1113,1121 ----
X***************
X*** 1127,1139 ****
X
X
X
X BUGS
X When a non-multivalued argument appears more than once on
X the command-line then only the last value supplied is used.
X A problem occurs however in the following scenario: suppose
X! `-s' is an option that takes an optional string argument (nd
X! suppose `-x' is some boolean flag). Then if the following
X! command-line is issued:
X
X command -s string -x -s
X
X--- 1127,1141 ----
X
X
X
X+ -f-dash_arg1 -f-dash_arg2 ...
X+
X BUGS
X When a non-multivalued argument appears more than once on
X the command-line then only the last value supplied is used.
X A problem occurs however in the following scenario: suppose
X! `-s' is an option that takes an optional string argument
X! (and suppose `-x' is some boolean flag). Then if the follow-
X! ing command-line is issued:
X
X command -s string -x -s
X
X***************
X*** 1159,1166 ****
X argument flags ARGPOS, ARGVALOPT, ARGVALREQ, ARGVALGIVEN,
X ARGNOVAL, and ARGVEC; and VAX/VMS version and IBM-PC version
X by Brad Appleton
X-
X-
X
X
X
X--- 1161,1166 ----
XNo differences encountered
END_OF_FILE
if test 36746 -ne `wc -c <'PATCH'`; then
echo shar: \"'PATCH'\" unpacked with wrong size!
fi
# end of 'PATCH'
fi
echo shar: End of shell archive.
exit 0
exit 0 # Just in case...
--
Kent Landfield INTERNET: kent at sparky.IMD.Sterling.COM
Sterling Software, IMD UUCP: uunet!sparky!kent
Phone: (402) 291-8300 FAX: (402) 291-4362
Please send comp.sources.misc-related mail to kent at uunet.uu.net.
More information about the Comp.sources.misc
mailing list