![]() |
NSPR 2.0: Command line option processingNSPR provides a mechanism to process command line options. This facility is similar to that available on many UNIX platforms known as getopt (see UNIX man getopt). The NSPR version of this capability allows processing based on the standard C language main() function definition's argc and argv. There are no modifications to values of those symbols during the processing.The syntax of the command line is generically as follows:
The token "naked" is not associated with any option (and is therefore naked). Any number of naked values may be included in the command line. Since they have no known option association, they are position dependent, but none the less, useful. An object is created by the client to hold the state of the options processing. Sharing that handle with other threads may produce non-deterministic results. Having multiple such state objects, each accessed by a different thread, is supported (though we struggle for a reason why).
PLOptState *PL_CreateOptState(
PRIntn argc, char **argv, const char *options);
If the function fails to return a valid handle the reason for the failure
will be contained in the calling thread's error structure (see PR_GetError()).
A non-NULL return pointer will point to an object of type
PLOptState. The pointer will remain valid until it is destroyed
by calling PL_DestroyOptState() and is required for all
subsequent processing.
typedef struct PLOptState
{
char option;
const char *value;
PLOptionInternal *internal;
} PLOptState;
The object PLOptState not only allows the implementation
to record the progress of the processing, it is also used as the area where
the majority of the results are made available to the client. The actual
value returned from the option processing function only indicates the validity
of the values stored in this object.
typedef enum {PL_OPT_OK, PL_OPT_EOL, PL_OPT_BAD } PLOptStatus;
Once the options processing has run to completion, the state object allocated by PL_CreateOptState() must be dismissed. That is accomplished by calling DestroyOptState(). void PL_DestroyOptState(PLOptState *opt); Last updated: Tue Mar 10 10:02:19 PST
1998
|
|||||||||||||||||||
|
Copyright © 1998-2000 The Mozilla Organization.
Last modified July 22, 1998. |
|||||||||||||||||||