Browse Prior Art Database

Parsing Technique for Command Line Parameters

IP.com Disclosure Number: IPCOM000110059D
Original Publication Date: 1992-Oct-01
Included in the Prior Art Database: 2005-Mar-25
Document File: 3 page(s) / 122K

Publishing Venue

IBM

Related People

Lahey, LC: AUTHOR

Abstract

Disclosed is a technique that allows the use of a common function for parsing the command-line parameters of a group of executable programs that may have a common set of parameters. If the parameters are uniquely identifiable, then their relative position on the command-line does not matter. If they are not uniquely identifiable, then they may still be parsed in this manner if relative parameter order is significant.

This text was extracted from an ASCII text file.
This is the abbreviated version, containing approximately 52% of the total text.

Parsing Technique for Command Line Parameters

       Disclosed is a technique that allows the use of a common
function for parsing the command-line parameters of a group of
executable programs that may have a common set of parameters.  If the
parameters are uniquely identifiable, then their relative position on
the command-line does not matter.  If they are not uniquely
identifiable, then they may still be parsed in this manner if
relative parameter order is significant.

      This parsing technique solves the common parameter
parsing/validation problem by employing bit masks that identify which
parameters are possible for each function, bit masks identifying each
parameter, validation functions for each parameter type, and an array
that is created to map each parameter type to the actual input
parameter value.  This technique will parse all command-line
parameters successfully when they are uniquely identifiable by the
validation functions, or (if they are not uniquely identifiable) when
indistinguishable parameters are specified in relative order.

      This technique is best illustrated by example.  The example
below is described in 3 parts: initialization, parsing, and parameter
assignment.
*    INITIALIZATION

      In this example, let us assume that there are 5 related
commands that use (possibly) different subsets of 8 distinct
parameter types (i.e., these parameter types may be differentiated by
some validating routine).  Each command would be assigned a bit mask
identifying which parameters are valid for the given command, e.g.,
*    COMMAND1 may use parameters of type 1 only -> bitmask 10000000
*    COMMAND2 may use parameters of type 1 and 8 -> bitmask 10000001
*    COMMAND3 may use parameters of type 1, 4, 6, and 7 -> bitmask
10010110
*    etc.

      Also, each parameter is assigned a unique bitmask, i.e.,
*    PARM1 is assigned bitmask 10000000 (parm1_mask)
*    PARM2 is assigned bitmask 01000000 (parm2_mask)
*    PARM8 is assigned bitmask 00000001 (parm8_mask)
*    etc.

      An array of pointers must also be declared.  This array must
have as many pointer elements as the maximum number of parameter
types (in this case 8).  The pointers in this array are initialized
to NULL and will be set to point to the actual parameter input
strings as they are found.

      Each type of parameter also needs a validation routine that can
uniquely identify that parameter type.  These validation routines may
differentiate parameter type based on such criteria as numeric vs.
alphabetic strings, parameter string lengths, pre-parameter
identi...