home *** CD-ROM | disk | FTP | other *** search
- From: brad@hcx1.ssd.csd.harris.com (Brad Appleton)
- Newsgroups: comp.sources.misc
- Subject: v18i102: parseargs - functions to parse command line arguments, Patch04b/4
- Message-ID: <1991Apr26.040231.18775@sparky.IMD.Sterling.COM>
- Date: 26 Apr 91 04:02:31 GMT
- Approved: kent@sparky.imd.sterling.com
- X-Checksum-Snefru: 4aa525d0 1f549e4d 8ed6ed4e 4087294b
-
- Submitted-by: Brad Appleton <brad@hcx1.ssd.csd.harris.com>
- Posting-number: Volume 18, Issue 102
- Archive-name: parseargs/patch04b
- Patch-To: parseargs: Volume 17, Issue 45-57
-
- #!/bin/sh
- # This is part 2 of a multipart archive
- # do not concatenate these parts, unpack them in order with /bin/sh
- # file DOCPATCH continued
- #
- if test ! -r _shar_seq_.tmp; then
- echo 'Please unpack part 1 first!'
- exit 1
- fi
- (read Scheck
- if test "$Scheck" != 2; then
- echo Please unpack part "$Scheck" next!
- exit 1
- else
- exit 0
- fi
- ) < _shar_seq_.tmp || exit 1
- echo 'x - continuing file DOCPATCH'
- sed 's/^X//' << 'SHAR_EOF' >> 'DOCPATCH' &&
- ! non-string types are copied implicitly (for example, integer
- ! arguments are stored in binary form, so the original string
- ! value need not be saved), so this argument can usually be
- ! ignored. Put simply, this flag is 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
- ***************
- *** 915,920 ****
- --- 914,920 ----
- X #define REALLOC(ptr,size) ((! ptr) ? malloc(size) : realloc(ptr, size))
- X typedef ARGVEC_T(FILE *) FILEvec_t;
- X
- + BOOL argReadFile( ARGDESC *ad, char *vp, BOOL copyf )
- X
- X
- X
- ***************
- *** 929,935 ****
- X
- X
- X
- - BOOL argReadFile( ARGDESC *ad, char *vp, BOOL copyf )
- X {
- X register FILE *fp;
- X fp = fopen(vp, "r");
- --- 929,934 ----
- ***************
- *** 958,969 ****
- X }
- X
- X LONG OPTIONS
- ! Under UNIX, Parseargs also allows for long options in addi-
- ! tion to single character options. Long options are denoted
- ! by a `+' character (which may be changed using keywordpre-
- ! fix). The keyword that is used is the first word in the
- ! prompt field of an argument descriptor entry. Long options
- ! are case insensitive! An argument to a long option may be
- X separated from the long option by an equal sign (`=') or by
- X one or more whitespace characters. Thus, if an entry looks
- X like:
- --- 957,972 ----
- X }
- X
- X LONG OPTIONS
- ! Under UNIX, MS-DOS, and OS/2, parseargs also allows for long
- ! options in addition to single character options. Under
- ! UNIX, long options are denoted by a `+' character. Under
- ! MS-DOS, and OS/2, long options are denoted by the second
- ! character in the SWITCHAR environment variable. If there is
- ! no second character, then if the first character is `-',
- ! then a `+' is used, otherwise a `/' is used. The keyword
- ! that is used is the first word in the prompt field of an
- ! argument descriptor entry. Long options are case insensi-
- ! tive! Under UNIX, an argument to a long option may be
- X separated from the long option by an equal sign (`=') or by
- X one or more whitespace characters. Thus, if an entry looks
- X like:
- ***************
- *** 973,989 ****
- X
- X The long option names for ``-?'' in the default argument
- X descriptor are ``+help'' and ``+?'' (respectively). In addi-
- ! tion, ``++'' or ``+endopts'' may be used to indicate the end
- ! of options so that all remaining arguments will be inter-
- ! preted as positional parameters (even if one begins with a
- ! `+' or a `-').
- X
- - Under VAX/VMS and AmigaDOS, single-character options are not
- - used and the ``long'' name (in the prompt field of an argu-
- - ment descriptor) is always used to match for possible
- X
- X
- X
- X Page 15
- X
- X
- --- 976,989 ----
- X
- X The long option names for ``-?'' in the default argument
- X descriptor are ``+help'' and ``+?'' (respectively). In addi-
- ! tion, ``++'' may be used to indicate the end of options so
- ! that all remaining arguments will be interpreted as posi-
- ! tional parameters (even if one begins with a `+' or a `-').
- X
- X
- X
- X
- +
- X Page 15
- X
- X
- ***************
- *** 995,1002 ****
- 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
- --- 995,1012 ----
- X
- X
- X
- ! Under MS-DOS, and OS/2, an argument to a long-option must be
- ! separated from the long option by an equal sign (`=')
- ! (unless the first character of $SWITCHAR is a `-', in which
- ! case UNIX syntax is used). The long option names for ``/?''
- ! in the default argument descriptor are ``/help'' and ``/?''
- ! (respectively).
- X
- + Under VAX/VMS and AmigaDOS, single-character options are not
- + used and the ``long'' name (in the prompt field of an argu-
- + ment descriptor) is always used to match for possible argu-
- + ments (or keywords, or qualifiers).
- +
- 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
- ***************
- *** 1003,1016 ****
- X in the prompt field (as in ``+count=4'' and ``+rep-
- X count=4'').
- X
- ! Under UNIX and VAX/VMS, only the number of characters
- ! required to uniquely identify the desired argument are
- ! needed, but at least two characters must be given (unless
- ! the prompt field is itself less than two characters long).
- ! This means that using the above example, that ``+rep=4'' and
- ! ``+cou=4'' would also work but ``+c=4'' would NOT (in other
- ! words, if you only want to use one character, use ``-c4''
- ! instead).
- X
- X Under VAX/VMS, the possibilities using the above example
- X would be: ``/REPCOUNT=4'', ``/COUNT=4'', ``/REP=4'', and
- --- 1013,1026 ----
- X in the prompt field (as in ``+count=4'' and ``+rep-
- X count=4'').
- X
- ! Under all systems except AmigaDOS, only the number of char-
- ! acters required to uniquely identify the desired argument
- ! are needed, but at least two characters must be given
- ! (unless the prompt field is itself less than two characters
- ! long). This means that using the above example, that
- ! ``+rep=4'' and ``+cou=4'' would also work but ``+c=4'' would
- ! NOT (in other words, if you only want to use one character,
- ! use ``-c4'' instead).
- X
- X Under VAX/VMS, the possibilities using the above example
- X would be: ``/REPCOUNT=4'', ``/COUNT=4'', ``/REP=4'', and
- ***************
- *** 1037,1055 ****
- X A command-line syntax error was encountered
- X
- X pe_DEFARGS
- - An attempt (using parsecntl) was made to change the
- - default arg-search list of a command to point to an
- - argdesc-array which already has the given command on
- - its default arg-search list (which would cause an
- - infinite loop when attempting to match an unknown
- - command-line argument).
- X
- - pe_NOMATCH
- - Unable to match the named argument. This occurs when
- - the argument keyword name passed to parsecntl (using
- X
- X
- -
- X Page 16
- X
- X
- --- 1047,1055 ----
- ***************
- *** 1061,1066 ****
- --- 1061,1076 ----
- X
- X
- X
- + An attempt (using parsecntl) was made to change the
- + default arg-search list of a command to point to an
- + argdesc-array which already has the given command on
- + its default arg-search list (which would cause an
- + infinite loop when attempting to match an unknown
- + command-line argument).
- +
- + pe_NOMATCH
- + Unable to match the named argument. This occurs when
- + 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
- ***************
- *** 1074,1081 ****
- X Bad command for parsecntl. This occurs if an unknown
- X function-code was passed to parsecntl.
- X
- X SEE ALSO
- ! argtype(3), parseargs(1), syserr(3)
- X The ``C Advisor'' column in UNIX Review Vol. 7 No. 11.
- X
- X CAVEATS
- --- 1084,1144 ----
- X Bad command for parsecntl. This occurs if an unknown
- X function-code was passed to parsecntl.
- X
- + SIDE EFFECTS
- + Each of the functions in the parseargs library will set the
- + external character string ProgName to be the name of the
- + last command that was operated upon by any of the library
- + routines.
- +
- + When an argument-descriptor array is first encountered by
- + any of the parseargs library routines, it is initially com-
- + piled into an intermediate form that is more convenient to
- + manipulate. As a direct result, it is not advisable to
- + attempt to index directly into the array to manipulate one
- + of the argument descriptors (because the argdesc that you
- + thought was there may actually be somewhere else). After the
- + array has been given its initial value(s), only parsecntl(3)
- + should be used to manipulate or query the attributes of an
- + argument descriptor.
- +
- + DOCUMENTING YOUR COMMANDS
- + The commands that you write with parseargs(3) may be docu-
- + mented using parseargs(1). Just copy the argument descriptor
- + array into a separate file, and invoke parseargs(1) with the
- + -M option and pass it the command-name (dont forget to
- + redirect input to come from your newly created file). It is
- + important to note that the only portion of that argdesc
- + array to insert into your file is the portion starting with
- + the very first command-line argument, all the way down to
- + (and including) the ENDOFARGS or END_ARGUMENTS entry.
- +
- +
- +
- +
- +
- + Page 17
- +
- +
- +
- +
- +
- +
- + PARSEARGS(3) PARSEARGS(3)
- +
- +
- +
- + FILES
- + /usr/local/lib/libparse.a
- + Link library for parseargs.
- +
- + /usr/local/include/parseargs.h
- + Include file for parseargs.
- +
- + /usr/local/include/useful.h
- + Include file for portability.
- +
- X SEE ALSO
- ! argtype(3), parseargs(1), parsecntl(3)
- X The ``C Advisor'' column in UNIX Review Vol. 7 No. 11.
- X
- X CAVEATS
- ***************
- *** 1113,1134 ****
- X Hence multiple ``leading dash'' arguments may specified as
- X follows:
- X
- X
- X
- X
- - Page 17
- X
- X
- X
- X
- X
- X
- - PARSEARGS(3) PARSEARGS(3)
- 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.
- --- 1176,1198 ----
- X Hence multiple ``leading dash'' arguments may specified as
- X follows:
- X
- + -f-dash_arg1 -f-dash_arg2 ...
- X
- X
- X
- X
- X
- + Page 18
- X
- X
- X
- X
- X
- X
- + PARSEARGS(3) PARSEARGS(3)
- 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.
- ***************
- *** 1182,1188 ****
- X
- X
- X
- ! Page 18
- X
- X
- X
- --- 1246,1254 ----
- X
- X
- X
- !
- !
- ! Page 19
- X
- X
- X
- *** /hx1d3/lp/brad/parseargs_patch03/parseargs/parsecntl3.txt Wed Apr 10 09:47:48 1991
- --- parsecntl3.txt Mon Apr 15 08:31:38 1991
- ***************
- *** 12,18 ****
- X SYNOPSIS
- X #include <parseargs.h>
- X
- ! int parsecntl( ARGDESC argd[], parsecntl_t func, parsemode_t mode, ... )
- X
- X
- X DESCRIPTION
- --- 12,18 ----
- X SYNOPSIS
- X #include <parseargs.h>
- X
- ! int parsecntl( ARGDESC argd[], parsecntl_t func, parsemode_t mode, ... );
- X
- X
- X DESCRIPTION
- ***************
- *** 210,217 ****
- X PARSE MODES
- X Parsecntl may be used to read current command attributes,
- X write (assign) new command attributes, or both. The mode
- ! argument to parsecntl determines the which of these three
- ! alternatives are desired. If the programmer merely wishes to
- X assign new attributes, then invoking parsecntl in pc_WRITE
- X mode and passing the new attributes will do the job. If the
- X programmer wishes simply to query attributes, then invoking
- --- 210,217 ----
- X PARSE MODES
- X Parsecntl may be used to read current command attributes,
- X write (assign) new command attributes, or both. The mode
- ! argument to parsecntl determines which of these three alter-
- ! natives are desired. If the programmer merely wishes to
- X assign new attributes, then invoking parsecntl in pc_WRITE
- X mode and passing the new attributes will do the job. If the
- X programmer wishes simply to query attributes, then invoking
- ***************
- *** 227,233 ****
- X ing it returns 0) the desired attributes will have been
- X assigned and the object that contained the new attribute
- X settings will now contain the attribute settings that were
- ! in effect before parsecntl was invoked.
- X
- X PARSE FLAGS
- X The following bitmasks may be combined in order to modify
- --- 227,233 ----
- X ing it returns 0) the desired attributes will have been
- X assigned and the object that contained the new attribute
- X settings will now contain the attribute settings that were
- ! in effect immediately before parsecntl was invoked.
- X
- X PARSE FLAGS
- X The following bitmasks may be combined in order to modify
- ***************
- *** 246,254 ****
- X pa_IGNORE
- X Ignore any unrecognized or improperly specified
- X command-line arguments and continue execution of the
- ! program. Normally, if an argument is unmatched (or is
- ! improperly specified), a usage message is printed pro-
- ! gram execution is terminated.
- X
- X pa_OPTSONLY
- X Under UNIX, setting this flag will disable the parsing
- --- 246,254 ----
- X pa_IGNORE
- X Ignore any unrecognized or improperly specified
- X command-line arguments and continue execution of the
- ! program. Normally, if a required argument is unmatched
- ! (or an argument is improperly specified), a usage mes-
- ! sage is printed program execution is terminated.
- X
- X pa_OPTSONLY
- X Under UNIX, setting this flag will disable the parsing
- ***************
- *** 292,299 ****
- X pa_ANYCASE
- X Setting this flag will cause character-case to be
- X ignored when attempting to match single-character argu-
- ! ment names (i.e. causes "-i" and "-I" will be con-
- ! sidered equivalent).
- X
- X pa_ARGV0
- X Normally, the parseargs library will assume that the
- --- 292,299 ----
- X pa_ANYCASE
- X Setting this flag will cause character-case to be
- X ignored when attempting to match single-character argu-
- ! ment names (i.e. causes "-i" and "-I" to be considered
- ! equivalent).
- X
- X pa_ARGV0
- X Normally, the parseargs library will assume that the
- ***************
- *** 314,326 ****
- X Keeping this flag on until the final set of arguments
- X is parsed will cause parseargs to not check for missing
- X arguments until the last set of arguments has been
- ! parsed (by the final call to *parseargs).
- X
- X pa_CONTINUE
- X Setting this flag will cause subsequent calls to the
- X parseargs library to NOT reset the current command-
- X state. Hence, all arguments will not be initially set
- - to "NOT GIVEN" and other (normal) initializations are
- X
- X
- X
- --- 314,326 ----
- X Keeping this flag on until the final set of arguments
- X is parsed will cause parseargs to not check for missing
- X arguments until the last set of arguments has been
- ! parsed (by the final call to one of the functions in
- ! the parseargs library).
- X
- X pa_CONTINUE
- X Setting this flag will cause subsequent calls to the
- X parseargs library to NOT reset the current command-
- X state. Hence, all arguments will not be initially set
- X
- X
- X
- ***************
- *** 335,340 ****
- --- 335,341 ----
- X
- X
- X
- + to "NOT GIVEN" and other (normal) initializations are
- X not be performed. This is useful in conjunction with
- X the pa_NOCHECK flag when more than one call to par-
- X seargs is required to parse all the command arguments.
- ***************
- *** 386,392 ****
- X
- X ARGNOVAL
- X The associated command argument takes no value (as in
- - "-x value"); Its mere presence (or lack thereof) on the
- X
- X
- X
- --- 387,392 ----
- ***************
- *** 401,406 ****
- --- 401,407 ----
- X
- X
- 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-
- ***************
- *** 452,458 ****
- X The argument WAS given on the command-line.
- X
- X ARGVALGIVEN
- - The value for this argument was given on the command-
- X
- X
- X
- --- 453,458 ----
- ***************
- *** 467,472 ****
- --- 467,473 ----
- X
- X
- X
- + The value for this argument was given on the command-
- X line.
- X
- X ARGVALSEP
- ***************
- *** 521,527 ****
- X
- X
- X
- -
- X Page 8
- X
- X
- --- 522,527 ----
- ***************
- *** 543,571 ****
- X Bad command for parsecntl. This occurs if an unknown
- X function-code was passed to parsecntl.
- X
- X SEE ALSO
- ! argtype(3),
- ! parseargs(3),
- ! parseargs(1)
- X
- X AUTHOR
- X Brad Appleton (brad@ssd.csd.harris.com)
- X Harris Computer Systems, Fort Lauderdale, FL USA
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- X
- X
- X
- --- 543,571 ----
- X Bad command for parsecntl. This occurs if an unknown
- X function-code was passed to parsecntl.
- X
- + SIDE EFFECTS
- + Each of the functions in the parseargs library will set the
- + external character string ProgName to be the name of the
- + last command that was operated upon by any of the library
- + routines.
- +
- + When an argument-descriptor array is first encountered by
- + any of the parseargs library routines, it is initially com-
- + piled into an intermediate form that is more convenient to
- + manipulate. As a direct result, it is not advisable to
- + attempt to index directly into the array to manipulate one
- + of the argument descriptors (because the argdesc that you
- + thought was there may actually be somewhere else). After the
- + array has been given its initial value(s), only parsecntl(3)
- + should be used to manipulate or query the attributes of an
- + argument descriptor.
- +
- X SEE ALSO
- ! argtype(3), parseargs(3), parseargs(1)
- X
- X AUTHOR
- X Brad Appleton (brad@ssd.csd.harris.com)
- X Harris Computer Systems, Fort Lauderdale, FL USA
- X
- X
- X
- SHAR_EOF
- echo 'File DOCPATCH is complete' &&
- chmod 0664 DOCPATCH ||
- echo 'restore of DOCPATCH failed'
- Wc_c="`wc -c < 'DOCPATCH'`"
- test 66103 -eq "$Wc_c" ||
- echo 'DOCPATCH: original size 66103, current size' "$Wc_c"
- # ============= Makefile ==============
- echo 'x - extracting Makefile (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'Makefile' &&
- # $Header: Makefile,v 2.1 89/12/30 20:59:01 eric Exp $
- X
- ###
- # operating-system dependent stuff
- ###
- .UNIVERSE = att
- #.UNIVERSE = ucb
- OS_TYPE = unix
- # OS_DEFS = -D${OS_TYPE} -D${.UNIVERSE}_universe
- X
- ###
- # targets
- ###
- NAME = parseargs
- PROGRAM = ${NAME}
- LIBRARY = ${NAME}
- STYLE = unix
- X
- ###
- # target directories
- ###
- LOCAL = /usr/local
- LIBDIR = ${LOCAL}/lib
- INCDIR = ${LOCAL}/include
- X
- ###
- # compilation options
- ###
- INCLUDES = -I.
- # MODEL = -Ms
- # MODELNAME = S
- OPT = -O
- # OPT = -g
- TEST_DEFS =
- USR_DEFS = -DUSE_PAGER
- DEFINES = ${OS_DEFS} ${USR_DEFS} ${TEST_DEFS} -D${STYLE}_style
- OPTIONS =
- CFLAGS = ${OPT} ${MODEL} ${INCLUDES} ${DEFINES} ${OPTIONS}
- LINTFLAGS = ${INCLUDES} ${DEFINES} ${OPTIONS}
- X
- ###
- # libraries
- ###
- LIBARGS = ${MODELNAME}lib${STYLE}_args.a
- LIBFILE = ${MODELNAME}libparse.a
- LOCLIBS = ${LIBARGS}
- # SYSLIBS = -lm -lcurses -ltermcap
- LIBS = ${LOCLIBS} ${SYSLIBS}
- X
- ###
- # commands
- ###
- AR = ar rvu
- DEL = rm -f
- COPY = cp
- CHDIR = cd
- LINT = lint
- MKTAGS = ctags
- PRINT = pr
- RANLIB = ranlib
- SHAR = shar
- SQZ = compress -v
- STRIP = strip
- X
- ###
- # files used
- ###
- DOCS= doc/Makefile \
- X doc/argtype.man3 \
- X doc/parseargs.man1 \
- X doc/parseargs.man3 \
- X doc/parsecntl.man3 \
- X doc/arg_macros.inc \
- X doc/argdesc.inc \
- X doc/argflags.inc \
- X doc/argvalopt.inc \
- X doc/bugs.inc \
- X doc/caveats.inc \
- X doc/cmd_macros.inc \
- X doc/defargs.inc \
- X doc/effects.inc \
- X doc/env_args.inc \
- X doc/env_parse.inc \
- X doc/env_usage.inc \
- X doc/fparseargs3.inc \
- X doc/lib_bugs.inc \
- X doc/lparseargs3.inc \
- X doc/multivals.inc \
- X doc/parseargs1.inc \
- X doc/parseargs3.inc \
- X doc/parsecntl3.inc \
- X doc/parsecntls.inc \
- X doc/parseflags.inc \
- X doc/parsemodes.inc \
- X doc/returns.inc \
- X doc/sh_arrays.inc \
- X doc/shells.inc \
- X doc/sparseargs3.inc \
- X doc/usage3.inc \
- X doc/vparseargs3.inc
- SCRIPTS = test.sh test.csh test.ksh test.rc test.awk test.pl
- TEMPLATES = ${NAME}.pl ${NAME}.awk
- XXXFILES = Intro README MANIFEST Makefile Makefile.cpp
- X
- HDRS = ${NAME}.h \
- X patchlevel.h \
- X pgopen.h \
- X strfuncs.h \
- X useful.h
- X
- SRCS = ${NAME}.c \
- X argtype.c \
- X arglist.c \
- X amiga_args.c \
- X ibm_args.c \
- X pgopen.c \
- X stest.c \
- X strfuncs.c \
- X syserr.c \
- X unix_args.c \
- X unix_man.c \
- X vms_args.c \
- X vprintf.c \
- X winsize.c \
- X xparse.c
- X
- OBJS = ${STYLE}_args.o \
- X arglist.o \
- X argtype.o \
- X pgopen.o \
- X strfuncs.o \
- X syserr.o \
- X vprintf.o \
- X winsize.o \
- X xparse.o
- X
- PROG_OBJS = ${NAME}.o unix_man.o
- TEST_OBJS = stest.o
- X
- FILES = ${XXFILES} ${DOCS} ${HDRS} ${SRCS} ${TEMPLATES} ${SCRIPTS}
- X
- ###
- # target dependencies
- ###
- all: ${LIBARGS} test ${PROGRAM}
- X
- test: ${STYLE}_test
- X
- ${STYLE}_test : stest.o ${LOCLIBS}
- X ${CC} ${CFLAGS} -o ${STYLE}_test stest.o ${LOCLIBS} ${SYSLIBS}
- X
- ${LIBARGS}: ${OBJS}
- X ${AR} $@ ${OBJS}
- X ${RANLIB} $@
- X
- ${PROGRAM}: ${PROG_OBJS} ${LOCLIBS}
- X ${CC} ${CFLAGS} -o $@ ${PROG_OBJS} ${LOCLIBS} ${SYSLIBS}
- X
- ###
- # object dependencies
- ###
- ${NAME}.o: ${NAME}.c ${NAME}.h patchlevel.h strfuncs.h useful.h
- amiga_args.o: amiga_args.c ${NAME}.h pgopen.h strfuncs.h useful.h
- arglist.o: arglist.c ${NAME}.h strfuncs.h useful.h
- argtype.o: argtype.c ${NAME}.h strfuncs.h useful.h
- ibm_args.o: ibm_args.c ${NAME}.h pgopen.h strfuncs.h useful.h
- pgopen.o: pgopen.c useful.h
- stest.o: stest.c ${NAME}.h useful.h
- strfuncs.o: strfuncs.c useful.h
- syserr.o: syserr.c useful.h
- unix_args.o: unix_args.c ${NAME}.h pgopen.h strfuncs.h useful.h
- unix_man.o: unix_man.c ${NAME}.h strfuncs.h useful.h
- vms_args.o: vms_args.c ${NAME}.h pgopen.h strfuncs.h useful.h
- vprintf.o: vprintf.c useful.h
- winsize.o: winsize.c useful.h
- xparse.o: xparse.c ${NAME}.h strfuncs.h useful.h
- X
- ###
- # installation dependencies
- ###
- install: ${INCDIR}/${NAME}.h \
- X ${LIBDIR}/${LIBFILE} \
- X ${LOCAL}/${PROGRAM}
- X
- X ${INCDIR}/${NAME}.h: ${NAME}.h useful.h
- X ( ${CHDIR} ${INCDIR}; ${DEL} ${NAME}.h useful.h )
- X ${COPY} ${NAME}.h useful.h ${INCDIR}
- X
- X ${LIBDIR}/${LIBFILE}: ${LIBARGS}
- X ${DEL} ${LIBDIR}/${LIBFILE}
- X ${COPY} ${LIBARGS} ${LIBDIR}/${LIBFILE}
- X ${RANLIB} ${LIBDIR}/${LIBFILE}
- X
- X ${LOCAL}/${PROGRAM}: ${PROGRAM} ${TEMPLATES}
- X ( ${CHDIR} ${LOCAL} ; ${DEL} ${PROGRAM} ${TEMPLATES} )
- X ${COPY} ${PROGRAM} ${TEMPLATES} ${LOCAL}
- X ${STRIP} ${LOCAL}/${PROGRAM}
- X
- ###
- # maintenance dependencies
- ###
- lint: ${SRCS}
- X ${LINT} ${LINTFLAGS} ${SRCS}
- X
- shar: ${NAME}.shar
- X
- ${NAME}.shar: ${FILES}
- X ${DEL} ${NAME}.shar
- X ${SHAR} ${FILES} >${NAME}.shar
- X
- clean:
- X ${DEL} ${OBJS} ${PROG_OBJS} ${TEST_OBJS}
- X ${DEL} tags core .exrc
- X
- clobber: clean
- X ${DEL} ${LIBARGS} ${PROGRAM} ${STYLE}_test
- X
- tags: ${SRCS} ${HDRS}
- X ${MKTAGS} ${SRCS} ${HDRS}
- X
- collapse: clobber shar
- X ${SQZ} ${NAME}.shar
- X ${DEL} ${FILES}
- X
- print: ${SRCS} ${HDRS}
- X @${PRINT} ${SRCS} ${HDRS}
- X
- SHAR_EOF
- chmod 0664 Makefile ||
- echo 'restore of Makefile failed'
- Wc_c="`wc -c < 'Makefile'`"
- test 4610 -eq "$Wc_c" ||
- echo 'Makefile: original size 4610, current size' "$Wc_c"
- # ============= PATCH ==============
- echo 'x - extracting PATCH (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'PATCH' &&
- *** /hx1d3/lp/brad/parseargs_patch03/parseargs/MANIFEST Wed Apr 10 09:46:29 1991
- --- MANIFEST Thu Apr 11 11:04:22 1991
- ***************
- *** 8,14 ****
- X amiga_args.c 4 parse AmigaDOS command-lines
- X arglist.c 2 implement the listXxxx functions for arglists
- X argtype.c 5 implement the argXxxx argument type functions
- ! doc/ 1 directory containing documentation
- X doc/Makefile 2 makefile for the documentation
- X doc/arg_macros.inc 2 describe arg-xxx and ARG_XXX macros
- X doc/argdesc.inc 2 describe an ARGDESC structure
- --- 8,14 ----
- X amiga_args.c 4 parse AmigaDOS command-lines
- X arglist.c 2 implement the listXxxx functions for arglists
- X argtype.c 5 implement the argXxxx argument type functions
- ! doc 1 directory containing documentation
- X doc/Makefile 2 makefile for the documentation
- X doc/arg_macros.inc 2 describe arg-xxx and ARG_XXX macros
- X doc/argdesc.inc 2 describe an ARGDESC structure
- ***************
- *** 19,25 ****
- X doc/caveats.inc 1 CAVEATS section for parseargs(1) and (3)
- X doc/cmd_macros.inc 1 describe CMD_XXX macros
- X doc/defargs.inc 1 describe the default argdesc-array
- ! doc/env_args.inc 1 describe use of $CMD_ARGS
- X doc/env_parse.inc 2 describe use of $PARSECNTL
- X doc/env_usage.inc 2 describe use of $USAGECNTL
- X doc/fparseargs3.inc 1 describe fparseargs(3)
- --- 19,26 ----
- X doc/caveats.inc 1 CAVEATS section for parseargs(1) and (3)
- X doc/cmd_macros.inc 1 describe CMD_XXX macros
- X doc/defargs.inc 1 describe the default argdesc-array
- ! doc/effects.inc 1 describe the side-effects of parseargs(3)
- ! doc/env_args.inc 2 describe use of $CMD_ARGS
- X doc/env_parse.inc 2 describe use of $PARSECNTL
- X doc/env_usage.inc 2 describe use of $USAGECNTL
- X doc/fparseargs3.inc 1 describe fparseargs(3)
- ***************
- *** 46,51 ****
- --- 47,53 ----
- X parseargs.c 7 C source for parseargs(1)
- X parseargs.h 6 include file for parseargs library
- X parseargs.pl 2 parseargs for perl
- + patchlevel.h 1 list of patches (most recent first)
- X pgopen.c 4 pipe output to a pager
- X pgopen.h 1 include file for pgopen.c
- X stest.c 3 test progarm for parseargs(3)
- *** /hx1d3/lp/brad/parseargs_patch03/parseargs/Makefile.cpp Wed Apr 10 09:46:32 1991
- --- Makefile.cpp Thu Apr 11 11:04:27 1991
- ***************
- *** 24,29 ****
- --- 24,30 ----
- X # define RANLIB_CMD ranlib
- X # define SHAR_CMD shar
- X # define SQZ_CMD compress -v
- + # define STRIP_CMD strip
- X #endif
- X
- X #ifdef vms
- ***************
- *** 47,52 ****
- --- 48,54 ----
- X # define RANLIB_CMD ranlib
- X # define SHAR_CMD shar
- X # define SQZ_CMD compress/file
- + # define STRIP_CMD strip
- X #endif
- X
- X #if ( defined(AZTEC) || defined(MANX) )
- ***************
- *** 70,75 ****
- --- 72,78 ----
- X # define RANLIB_CMD ranlib
- X # define SHAR_CMD shar
- X # define SQZ_CMD compress -v
- + # define STRIP_CMD strip
- X #endif
- X
- X #ifdef MS_DOS
- ***************
- *** 93,98 ****
- --- 96,102 ----
- X # define RANLIB_CMD ranlib
- X # define SHAR_CMD shar
- X # define SQZ_CMD arc -c
- + # define STRIP_CMD strip
- X #endif
- X
- X #ifdef OS2
- ***************
- *** 116,121 ****
- --- 120,126 ----
- X # define RANLIB_CMD ranlib
- X # define SHAR_CMD shar
- X # define SQZ_CMD arc -c
- + # define STRIP_CMD strip
- X #endif
- X
- X REM $Header: Makefile,v 2.1 89/12/30 20:59:01 eric Exp $
- ***************
- *** 179,184 ****
- --- 184,190 ----
- X RANLIB = RANLIB_CMD
- X SHAR = SHAR_CMD
- X SQZ = SQZ_CMD
- + STRIP = STRIP_CMD
- X
- X REMLINE
- X REM files used
- ***************
- *** 196,201 ****
- --- 202,208 ----
- X doc/caveats.inc \
- X doc/cmd_macros.inc \
- X doc/defargs.inc \
- + doc/effects.inc \
- X doc/env_args.inc \
- X doc/env_parse.inc \
- X doc/env_usage.inc \
- ***************
- *** 275,281 ****
- X REMLINE
- X REM object dependencies
- X REMLINE
- ! ${NAME}.o: ${NAME}.c ${NAME}.h strfuncs.h useful.h
- X amiga_args.o: amiga_args.c ${NAME}.h pgopen.h strfuncs.h useful.h
- X arglist.o: arglist.c ${NAME}.h strfuncs.h useful.h
- X argtype.o: argtype.c ${NAME}.h strfuncs.h useful.h
- --- 282,288 ----
- X REMLINE
- X REM object dependencies
- X REMLINE
- ! ${NAME}.o: ${NAME}.c ${NAME}.h patchlevel.h strfuncs.h useful.h
- X amiga_args.o: amiga_args.c ${NAME}.h pgopen.h strfuncs.h useful.h
- X arglist.o: arglist.c ${NAME}.h strfuncs.h useful.h
- X argtype.o: argtype.c ${NAME}.h strfuncs.h useful.h
- ***************
- *** 310,315 ****
- --- 317,323 ----
- X _Pathname(${LOCAL},${PROGRAM}): ${PROGRAM} ${TEMPLATES}
- X ( ${CHDIR} ${LOCAL} ; ${DEL} ${PROGRAM} ${TEMPLATES} )
- X ${COPY} ${PROGRAM} ${TEMPLATES} ${LOCAL}
- + ${STRIP} _Pathname(${LOCAL},${PROGRAM})
- X
- X REMLINE
- X REM maintenance dependencies
- *** /hx1d3/lp/brad/parseargs_patch03/parseargs/amiga_args.c Wed Apr 10 09:46:39 1991
- --- amiga_args.c Thu Apr 11 11:04:36 1991
- ***************
- *** 156,163 ****
- X }
- X
- X flags = arg_flags(ad); /* save flags */
- ! if ( ARG_isGIVEN(ad) ) /* reset flags for this appearance */
- ! BCLEAR( arg_flags(ad), ARGVALGIVEN | ARGVALSEP );
- X
- X if ( p ) { /* matched NAME=VALUE */
- X if ( ARG_isMULTIVAL(ad) )
- --- 156,165 ----
- X }
- X
- X flags = arg_flags(ad); /* save flags */
- ! if ( ARG_isGIVEN(ad) ) {
- ! BCLEAR( arg_flags(ad), ARGVALSEP | ARGKEYWORD );
- ! if ( !ARG_isMULTIVAL(ad) ) BCLEAR( arg_flags(ad), ARGVALGIVEN );
- ! }
- X
- X if ( p ) { /* matched NAME=VALUE */
- X if ( ARG_isMULTIVAL(ad) )
- ***************
- *** 199,206 ****
- X }
- X else if (cmd_prev(cmd)) {
- X flags = arg_flags(cmd_prev(cmd)); /* save flags */
- ! if ( ARG_isGIVEN(cmd_prev(cmd)) ) /* reset flags */
- ! BCLEAR( arg_flags(cmd_prev(cmd)), ARGVALGIVEN | ARGVALSEP );
- X
- X /* previous value may have required a keyword */
- X BSET( arg_flags(cmd_prev(cmd)), ARGVALSEP );
- --- 201,210 ----
- X }
- X else if (cmd_prev(cmd)) {
- X flags = arg_flags(cmd_prev(cmd)); /* save flags */
- ! if ( ARG_isGIVEN(cmd_prev(cmd)) ) { /* reset flags */
- ! BCLEAR( arg_flags(cmd_prev(cmd)), ARGVALSEP );
- ! if ( !ARG_isMULTIVAL(ad) ) BCLEAR( arg_flags(ad), ARGVALGIVEN );
- ! }
- X
- X /* previous value may have required a keyword */
- X BSET( arg_flags(cmd_prev(cmd)), ARGVALSEP );
- ***************
- *** 223,233 ****
- X continue;
- X }
- X else { /* it's a positional argument or a list item */
- ! if (cmd_list(cmd)) { /* its a list item */
- X flags = arg_flags(cmd_list(cmd)); /* save flags */
- ! if ( ARG_isGIVEN(cmd_list(cmd)) ) /* reset flags */
- ! BCLEAR( arg_flags(cmd_list(cmd)), ARGVALGIVEN | ARGVALSEP );
- !
- X BSET( arg_flags(cmd_list(cmd)), ARGVALSEP );
- X
- X if ( !HANDLE(cmd_list(cmd), *av, cmd_flags(cmd)) ) {
- --- 227,237 ----
- X continue;
- X }
- X else { /* it's a positional argument or a list item */
- ! if ( cmd_list(cmd) ) { /* its a list item */
- X flags = arg_flags(cmd_list(cmd)); /* save flags */
- ! if ( ARG_isGIVEN(cmd_list(cmd)) ) { /* reset flags */
- ! BCLEAR( arg_flags(cmd_list(cmd)), ARGVALSEP );
- ! }
- X BSET( arg_flags(cmd_list(cmd)), ARGVALSEP );
- X
- X if ( !HANDLE(cmd_list(cmd), *av, cmd_flags(cmd)) ) {
- ***************
- *** 262,270 ****
- X }
- X else {
- X flags = arg_flags(ad); /* save flags */
- ! if ( ARG_isGIVEN(ad) ) /* reset flags for this appearance */
- ! BCLEAR( arg_flags(ad), ARGVALGIVEN | ARGVALSEP );
- !
- X BSET( arg_flags(ad), ARGVALSEP );
- X
- X /* try to convert */
- --- 266,275 ----
- X }
- X else {
- X flags = arg_flags(ad); /* save flags */
- ! if ( ARG_isGIVEN(ad) ) { /* reset flags for this appearance */
- ! BCLEAR( arg_flags(ad), ARGVALSEP );
- ! if (! ARG_isMULTIVAL(ad)) BCLEAR(arg_flags(ad), ARGVALGIVEN);
- ! }
- X BSET( arg_flags(ad), ARGVALSEP );
- X
- X /* try to convert */
- *** /hx1d3/lp/brad/parseargs_patch03/parseargs/argtype.c Wed Apr 10 09:52:05 1991
- --- argtype.c Thu Apr 11 11:04:44 1991
- ***************
- *** 40,47 ****
- X #define REALLOC(ptr,size) (( ! ptr ) ? malloc(size) : realloc(ptr, size) )
- X EXTERN VOID syserr ARGS((const char *, ...));
- X EXTERN VOID usrerr ARGS((const char *, ...));
- ! EXTERN long strtol ARGS((char *, char **, int));
- ! EXTERN double strtod ARGS((const char *, char **));
- X
- X
- X /***************************************************************************
- --- 40,47 ----
- X #define REALLOC(ptr,size) (( ! ptr ) ? malloc(size) : realloc(ptr, size) )
- X EXTERN VOID syserr ARGS((const char *, ...));
- X EXTERN VOID usrerr ARGS((const char *, ...));
- ! /* EXTERN long strtol ARGS((char *, char **, int)); */
- ! /* EXTERN double strtod ARGS((const char *, char **)); */
- X
- X
- X /***************************************************************************
- ***************
- *** 82,90 ****
- X ** similarly. One of these routines is called when an argument of that
- X ** particular type is matched by one of the argument parsing function in
- X ** parseargs(3). When such an argument is matched, its argument transla-
- ! ** tion routines is invoked and is passed (1) the address of the argument
- X ** descriptor for the matched argument, (2) the possible argument string
- ! ** for that matched argument, and (3) a boolean filed that is TRUE only
- X ** if the second parameter points to temporary storage (indicating that
- X ** some copying may need to be done instead of just pointing to the same
- X ** object).
- --- 82,90 ----
- X ** similarly. One of these routines is called when an argument of that
- X ** particular type is matched by one of the argument parsing function in
- X ** parseargs(3). When such an argument is matched, its argument transla-
- ! ** tion routine is invoked and is passed (1) the address of the argument
- X ** descriptor for the matched argument, (2) the possible argument string
- ! ** for that matched argument, and (3) a boolean field that is TRUE only
- X ** if the second parameter points to temporary storage (indicating that
- X ** some copying may need to be done instead of just pointing to the same
- X ** object).
- ***************
- *** 645,664 ****
- X ** ArgOutput attempts to redirect the file-pointer addressed by ad_valp
- X ** to the file named by the given value. The file is opened for writing.
- X **
- ! ** In either case, ad_valp should be of type (FILE *) (and not a pointer
- ! ** to a file pointer as in (FILE **)!!!
- X **
- X ** If the given files cannot be opened, then an error message is printed
- X ** and the associated input/output streams are closed.
- X ***^^**********************************************************************/
- X
- X /*ARGSUSED*/
- X BOOL argInput PARMS(ad, vp, copyf)
- X {
- ! /* note that ad_valp is a file pointer
- ! ** (so dont use &fp in the arg-desc)
- ! */
- X FILE *fp = (FILE *)arg_valp(ad);
- X BOOL error = FALSE;
- X
- X /* redirect file pointer to read from file */
- --- 645,676 ----
- X ** ArgOutput attempts to redirect the file-pointer addressed by ad_valp
- X ** to the file named by the given value. The file is opened for writing.
- X **
- ! ** In either case, ad_valp should be of type (FILE **) (a pointer to a
- ! ** file pointer) and not a mere file pointer as in (FILE *)!!!
- X **
- X ** If the given files cannot be opened, then an error message is printed
- X ** and the associated input/output streams are closed.
- X ***^^**********************************************************************/
- X
- + /*
- + ** slight problem here - on VMS, as_valp should be of type FILE **
- + ** but on Unix (emulating VMS) it needs to be of type FILE *.
- + ** we get around this using the following:
- + */
- + # ifdef vms
- + # define FP *fp
- + # else
- + # define FP fp
- + # endif
- +
- X /*ARGSUSED*/
- X BOOL argInput PARMS(ad, vp, copyf)
- X {
- ! #ifdef vms
- ! FILE **fp = (FILE **)arg_valp(ad);
- ! #else
- X FILE *fp = (FILE *)arg_valp(ad);
- + #endif
- X BOOL error = FALSE;
- X
- X /* redirect file pointer to read from file */
- ***************
- *** 667,675 ****
- X error = TRUE;
- X }
- X
- ! if ( !error && !fp )
- X error = TRUE;
- ! else if ( !error && !freopen(vp, "r", fp) )
- X error = TRUE;
- X
- X if ( error ) {
- --- 679,687 ----
- X error = TRUE;
- X }
- X
- ! if ( !error && !FP )
- X error = TRUE;
- ! else if ( !error && !freopen(vp, "r", FP) )
- X error = TRUE;
- X
- X if ( error ) {
- ***************
- *** 683,692 ****
- X /*ARGSUSED*/
- X BOOL argOutput PARMS(ad, vp, copyf)
- X {
- ! /* note that ad_valp is a file pointer
- ! ** (so dont use &fp in the arg-desc)
- ! */
- X FILE *fp = (FILE *)arg_valp(ad);
- X BOOL error = FALSE;
- X
- X /* redirect file pointer to write to file */
- --- 695,705 ----
- X /*ARGSUSED*/
- X BOOL argOutput PARMS(ad, vp, copyf)
- X {
- ! #ifdef vms
- ! FILE **fp = (FILE **)arg_valp(ad);
- ! #else
- X FILE *fp = (FILE *)arg_valp(ad);
- + #endif
- X BOOL error = FALSE;
- X
- X /* redirect file pointer to write to file */
- ***************
- *** 695,703 ****
- X error = TRUE;
- X }
- X
- ! if ( !error && !fp )
- X error = TRUE;
- ! else if ( !error && !freopen(vp, "a", fp) )
- X error = TRUE;
- X
- X if ( error ) {
- --- 708,716 ----
- X error = TRUE;
- X }
- X
- ! if ( !error && !FP )
- X error = TRUE;
- ! else if ( !error && !freopen(vp, "a", FP) )
- X error = TRUE;
- X
- X if ( error ) {
- ***************
- *** 707,710 ****
- --- 720,724 ----
- X return (TRUE);
- X }
- X
- + # undef FP
- X #endif /* vms_style */
- *** /hx1d3/lp/brad/parseargs_patch03/parseargs/ibm_args.c Wed Apr 10 09:47:26 1991
- --- ibm_args.c Thu Apr 11 11:06:43 1991
- ***************
- *** 252,259 ****
- X }
- X
- X flags = arg_flags(ad);
- ! if ( ARG_isGIVEN(ad) )
- ! BCLEAR( arg_flags(ad), ARGVALSEP | ARGVALGIVEN | ARGKEYWORD );
- X
- X BSET( arg_flags(ad), ARGKEYWORD );
- X
- --- 252,261 ----
- X }
- X
- X flags = arg_flags(ad);
- ! if ( ARG_isGIVEN(ad) ) {
- ! BCLEAR( arg_flags(ad), ARGVALSEP | ARGKEYWORD );
- ! if ( !ARG_isMULTIVAL(ad) ) BCLEAR( arg_flags(ad), ARGVALGIVEN );
- ! }
- X
- X BSET( arg_flags(ad), ARGKEYWORD );
- X
- ***************
- *** 362,369 ****
- X }/* if unknown-option */
- X
- X flags = arg_flags(ad);
- ! if ( ARG_isGIVEN(ad) )
- ! BCLEAR( arg_flags(ad), ARGVALSEP | ARGVALGIVEN | ARGKEYWORD );
- X
- X if ( ARG_isMULTIVAL(ad) ) {
- X cmd_list(cmd) = ad;
- --- 364,373 ----
- X }/* if unknown-option */
- X
- X flags = arg_flags(ad);
- ! if ( ARG_isGIVEN(ad) ) {
- ! BCLEAR( arg_flags(ad), ARGVALSEP | ARGKEYWORD );
- ! if ( !ARG_isMULTIVAL(ad) ) BCLEAR( arg_flags(ad), ARGVALGIVEN );
- ! }
- X
- X if ( ARG_isMULTIVAL(ad) ) {
- X cmd_list(cmd) = ad;
- ***************
- *** 444,454 ****
- X }/*elif option*/
- X else {
- X /* parsing a list of arguments */
- ! if( cmd_list(cmd) ) {
- X ad = cmd_list(cmd);
- X flags = arg_flags(ad);
- ! if ( ARG_isGIVEN(ad) )
- ! BCLEAR( arg_flags(ad), ARGVALSEP | ARGVALGIVEN | ARGKEYWORD );
- X
- X BSET( arg_flags(ad), ARGVALSEP );
- X
- --- 448,459 ----
- X }/*elif option*/
- X else {
- X /* parsing a list of arguments */
- ! if ( cmd_list(cmd) ) {
- X ad = cmd_list(cmd);
- X flags = arg_flags(ad);
- ! if ( ARG_isGIVEN(ad) ) {
- ! BCLEAR( arg_flags(ad), ARGVALSEP | ARGKEYWORD );
- ! }
- X
- X BSET( arg_flags(ad), ARGVALSEP );
- X
- ***************
- *** 481,488 ****
- X }
- X
- X flags = arg_flags(ad);
- ! if ( ARG_isGIVEN(ad) )
- ! BCLEAR( arg_flags(ad), ARGVALSEP | ARGVALGIVEN | ARGKEYWORD );
- X
- X if ( ARG_isMULTIVAL(ad) ) {
- X cmd_list(cmd) = ad;
- --- 486,495 ----
- X }
- X
- X flags = arg_flags(ad);
- ! if ( ARG_isGIVEN(ad) ) {
- ! BCLEAR( arg_flags(ad), ARGVALSEP | ARGKEYWORD );
- ! if ( !ARG_isMULTIVAL(ad) ) BCLEAR( arg_flags(ad), ARGVALGIVEN );
- ! }
- X
- X if ( ARG_isMULTIVAL(ad) ) {
- X cmd_list(cmd) = ad;
- *** /hx1d3/lp/brad/parseargs_patch03/parseargs/parseargs.awk Wed Apr 10 09:47:27 1991
- --- parseargs.awk Thu Apr 11 11:06:52 1991
- ***************
- *** 59,64 ****
- --- 59,66 ----
- X ## The exit code returned by parseargs(1).
- X ##
- X ## ^BUGS:
- + ## Assumes that short-options are NOT disabled by $PARSECNTL.
- + ##
- X ## Due to the limited ability of awk, scripts using parseargs(1) cannot
- X ## use short-options (with a dash '-') because awk will attempt to interpret
- X ## any such arguments as options to awk and remove them from ARGV (regardless
- ***************
- *** 97,103 ****
- X if ( ! PARSEOUTPUT ) PARSEOUTPUT = TMPFILE "out";
- X
- X ## build the options and required arguments for parseargs(1)
- ! PARSEARGS = sprintf( "parseargs -s awk %s -- '%s'", PARSEOPTS, PROGNAME );
- X
- X ## quote each elemnt in argv and append it to the parseargs-command
- X for ( i = 1 ; i <= argc ; i++ ) {
- --- 99,106 ----
- X if ( ! PARSEOUTPUT ) PARSEOUTPUT = TMPFILE "out";
- X
- X ## build the options and required arguments for parseargs(1)
- ! PARSEARGS = sprintf( "parseargs -s awk %s -S '\t' -- '%s'",
- ! PARSEOPTS, PROGNAME );
- X
- X ## quote each elemnt in argv and append it to the parseargs-command
- X for ( i = 1 ; i <= argc ; i++ ) {
- *** /hx1d3/lp/brad/parseargs_patch03/parseargs/parseargs.c Wed Apr 10 09:54:07 1991
- --- parseargs.c Thu Apr 11 11:07:09 1991
- ***************
- *** 7,12 ****
- --- 7,13 ----
- X ** to parse command-line arguments for shell scripts. At the present,
- X ** time, VMS/DCL is not yet supported (nor are MS-DOS Batch-files).
- X **
- + **
- X ** Given a command name, a vector of string-valued arguments such as that
- X ** passed to a shell script, and a specification string describing the
- X ** possible arguments, parseargs matches actual arguments to possible
- ***************
- *** 18,34 ****
- X ** through the use of the "PARSECNTL" environment variable.
- X **
- X ** Given the command name and the argument specification string,
- ! ** parsearg -U
- ! ** prints a reasonably friendly version of the usage of the
- ! ** calling program on standard diagnostic output. The "verbosity" of
- ! ** the usage message may be controlled through the use of the
- ! ** "USAGECNTL" environment variable.
- X **
- X ** Given the command name and the argument specification string,
- ! ** parsearg -M
- X ** prints a template of the command-syntax on standard output that is
- X ** suitable for input to nroff or troff using the -man macro package.
- X **
- X ** ^SEE_ALSO:
- X ** argtype(3), parseargs(1), parseargs(3), parsecntl(3),
- X ** parseargs.pl, parseargs.awk
- --- 19,39 ----
- X ** through the use of the "PARSECNTL" environment variable.
- X **
- X ** Given the command name and the argument specification string,
- ! ** parseargs -U
- ! ** prints a reasonably friendly version of the usage of the calling program
- ! ** on standard diagnostic output. The "verbosity" of the usage message may
- ! ** be controlled through the use of the "USAGECNTL" environment variable.
- X **
- X ** Given the command name and the argument specification string,
- ! ** parseargs -M
- X ** prints a template of the command-syntax on standard output that is
- X ** suitable for input to nroff or troff using the -man macro package.
- X **
- + ** Given no other arguments,
- + ** parseargs -#
- + ** prints on standard output, the current version and patchlevel of the
- + ** running version of parseargs.
- + **
- X ** ^SEE_ALSO:
- X ** argtype(3), parseargs(1), parseargs(3), parsecntl(3),
- X ** parseargs.pl, parseargs.awk
- ***************
- *** 64,84 ****
- X ** newlines will be translated into spaces, or characters following a
- X ** newline may be lost, in any variables that are set by parseargs.
- X **
- - ** Parseargs(1) is subject to the same caveats as parseargs(3).
- - ** Refer to the CAVEATS section of the parseargs(3) for more information.
- - **
- X ** ^HISTORY:
- X ** 07/18/90 Brad Appleton <brad@ssd.csd.harris.com> Created
- X ***^^**********************************************************************/
- X
- - #include <fcntl.h>
- X #include <stdio.h>
- X #include <useful.h>
- X #include "strfuncs.h"
- X
- X #define PARSEARGS_PRIVATE /* include private definitions */
- X #include "parseargs.h"
- X
- X /*************************************************************************
- X ** ^SECTION: RETURN-CODES
- X **
- --- 69,98 ----
- X ** newlines will be translated into spaces, or characters following a
- X ** newline may be lost, in any variables that are set by parseargs.
- X **
- X ** ^HISTORY:
- X ** 07/18/90 Brad Appleton <brad@ssd.csd.harris.com> Created
- + **
- + ** 02/--/91 Brad Appleton <brad@ssd.csd.harris.com>
- + ** - Added awk, perl, and rc to the list of shells to generate output for
- + ** - added calls to vecFree in cleanup()
- + **
- + ** 03/31/91 Brad Appleton <brad@ssd.csd.harris.com>
- + ** - fixed bug in cleanup for SunOS (added free_vectors())
- + ** - fixed printing of single quotes for perl scripts
- + ** - added -C option for case-insensitivity
- + ** - added hidden -# option to print current version and patchlevel
- X ***^^**********************************************************************/
- X
- X #include <stdio.h>
- + #include <errno.h>
- X #include <useful.h>
- X #include "strfuncs.h"
- + #include "patchlevel.h"
- X
- X #define PARSEARGS_PRIVATE /* include private definitions */
- X #include "parseargs.h"
- X
- +
- X /*************************************************************************
- X ** ^SECTION: RETURN-CODES
- X **
- ***************
- *** 91,97 ****
- X /* -- No errors, success!!
- X */
- X #define e_USAGE 1
- ! /* -- No errors were encountered. A usage-message (or manual-page-template)
- X ** was explicitly requested (and printed) by the user.
- X */
- X #define e_SYNTAX 2
- --- 105,111 ----
- X /* -- No errors, success!!
- X */
- X #define e_USAGE 1
- ! /* -- No errors were encountered. A usage-message, or manual-page-template
- X ** was explicitly requested (and printed) by the user.
- X */
- X #define e_SYNTAX 2
- ***************
- *** 233,239 ****
- X { "ARGV", "%s\n", "", "\n\n", "'\034'", "\n" },
- X
- X /* PERL : Positional parms in ARGV; Assignment Syntax: $name=value\n; */
- ! { "ARGV", "$%s = ", "", ";\n", "'.\"%c\".'", "'" }
- X };
- X /*************************************************************************/
- X
- --- 247,253 ----
- X { "ARGV", "%s\n", "", "\n\n", "'\034'", "\n" },
- X
- X /* PERL : Positional parms in ARGV; Assignment Syntax: $name=value\n; */
- ! { "ARGV", "$%s = ", "'", "';\n", "\\'", "'" }
- X };
- X /*************************************************************************/
- X
- ***************
- *** 281,289 ****
- X EXTERN VOID manpage ARGS((const ARGDESC *));
- X EXTERN VOID perror ARGS((const char *));
- X
- - extern int errno; /* system wide error level */
- -
- X /*************************************************************************/
- X /*
- X ** variables that are set via command-line arguments
- X */
- --- 295,316 ----
- X EXTERN VOID manpage ARGS((const ARGDESC *));
- X EXTERN VOID perror ARGS((const char *));
- X
- X /*************************************************************************/
- +
- + /*ARGSUSED*/
- + #ifdef __ANSI_C__
- + static BOOL argVers( register ARGDESC *ad, register char *vp, BOOL copyf )
- + #else
- + static BOOL argVers( ad, vp, copyf )
- + register ARGDESC *ad;
- + register char *vp;
- + BOOL copyf;
- + #endif
- + {
- + printf( "%s\n", _Ident );
- + exit( e_USAGE );
- + }
- +
- X /*
- X ** variables that are set via command-line arguments
- X */
- ***************
- *** 312,317 ****
- --- 339,346 ----
- X static BOOL PrManual = FALSE; /* ?just print manual page(s)? */
- X static BOOL Prompt = FALSE; /* ?prompt for missing args? */
- X static BOOL Ignore = FALSE; /* ?ignore bad syntax and continue? */
- + static BOOL AnyCase = FALSE; /* ?case-insensitivity? */
- + static BOOL Flags1st = FALSE; /* ?non-positionals first? */
- X
- X /*************************************************************************/
- X /* now we are ready to define the command-line */
- ***************
- *** 329,334 ****
- --- 358,366 ----
- X shell assignment statements."
- X
- X CMD_ARGUMENTS
- + '#', ARGNOVAL, argVers, __ NULL,
- + "VERsion : just print program version, dont parse command-line",
- +
- X 'U', ARGOPT, argBool, __ &PrUsage,
- X "usage : just print program usage, dont parse command-line",
- X
- ***************
- *** 341,346 ****
- --- 373,381 ----
- X 'F', ARGOPT, argStr, __ &StrFalse,
- X "FALSEstr : string to use for FALSE Booleans (default=\"\")",
- X
- + 'C', ARGOPT, argBool, __ &AnyCase,
- + "caseignore : parse options using case-insensitivity",
- +
- X 'A', ARGOPT, argBool, __ &ModArr,
- X "array : modify the behavior of arrays",
- X
- ***************
- *** 376,381 ****
- --- 411,419 ----
- X "ignore : ignore bad command-line syntax and continue processing \
- X (instead of aborting)",
- X
- + '1', ARGOPT, argBool, __ &Flags1st,
- + "1st : force non-positional arguments to precede all positional arguments",
- +
- X '-', ARGOPT, argDummy, __ NULL,
- X "+ : end of options - all remaining arguments are interpreted as \
- SHAR_EOF
- true || echo 'restore of PATCH failed'
- echo 'End of part 2'
- echo 'File PATCH is continued in part 3'
- echo 3 > _shar_seq_.tmp
- exit 0
- exit 0 # Just in case...
- --
- Kent Landfield INTERNET: kent@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@uunet.uu.net.
-