15.9 Parsing Command Line Options

The XrmParseCommand() function can be used to parse the command line arguments to a program and modify a resource database with selected entries from the command line.

typedef enum {
	XrmoptionNoArg,		/* Value is specified in XrmOptionDescRec.value		*/
	XrmoptionIsArg,		/* Value is the option string itself			*/
	XrmoptionStickyArg,	/* Value is characters immediately following option	*/
	XrmoptionSepArg,	/* Value is next argument in argv			*/
	XrmoptionResArg,	/* Resource and value in next argument in argv 		*/
	XrmoptionSkipArg,	/* Ignore this option and the next argument in argv	*/
	XrmoptionSkipLine,	/* Ignore this option and the rest of argv		*/
	XrmoptionSkipNArgs	/* Ignore this option and the next
				     XrmOptionDescRec.value arguments in argv 		*/
} XrmOptionKind;

Note that XrmoptionSkipArg is equivalent to XrmoptionSkipNArgs with the XrmOptionDescRec.value field containing the value one. Note also that the value zero for XrmoptionSkipNArgs indicates that only the option itself is to be skipped.

typedef struct {
	char *option;		/* Option specification string in argv		    	*/
	char *specifier;	/* Binding and resource name (sans application name)    */
	XrmOptionKind argKind;	/* Which style of option it is	    			*/
	XPointer value;		/* Value to provide if XrmoptionNoArg or
				     XrmoptionSkipNArgs   				*/
} XrmOptionDescRec, *XrmOptionDescList;

To load a resource database from a C command line, use XrmParseCommand().

Next Chapter: Application Utility Functions

Christophe Tronche, [email protected]