XrmParseCommand()XrmParseCommand()NameXrmParseCommand – load a resource database from command-line arguments.
Synopsis
void XrmParseCommand(database, table, table_count, name, argc_in_out,
argv_in_out)
XrmDatabase *database;
XrmOptionDescList table;
int table_count;
char *name;
int *argc_in_out;
char **argv_in_out;
Arguments
database Specifies a pointer to the resource database. If database
contains NULL, a new resource database is created and a
pointer to it is returned in database. If a database is cre‐
ated, it is created in the current locale.
table Specifies table of command-line arguments to be parsed.
table_count
Specifies the number of entries in the table.
name Specifies the application name.
argc_in_out
Before the call, specifies the number of arguments. After
the call, returns the number of arguments not parsed.
argv_in_out
Before the call, specifies a pointer to the command-line
arguments. After the call, returns a pointer to a string
containing the command-line arguments that could not be
parsed.
DescriptionXrmParseCommand() parses an (argc_in_out, argv_in_out) pair according
to the specified option table, loads recognized options into the speci‐
fied database with the type "String" and modifies the (argc_in_out,
argv_in_out) pair to remove all recognized options.
The specified table is used to parse the command line. Recognized
entries in the table are removed from argv_in_out, and entries are made
in the specified resource database. The table entries contain informa‐
tion on the option string, the option name, which style of option and a
value to provide if the option kind is XrmoptionNoArg. See the example
table below. The option names are compared byte-for-byte to arguments
in argv, independent of any locale. The resource values given in the
table are stored in the resource database without modification. All
resource database entries are created using a "String" representation
type.
argc_in_out specifies the number of arguments in argv_in_out and is set
to the remaining number of arguments that were not parsed. name should
be the name of your application for use in building the database entry.
name is prepended to the specifier in the option table before storing
the specification. No separating (binding) character is inserted. The
table must contain either a dot (.) or an asterisk (*) as the first
character in each specifier entry. The specifier entry can contain
multiple components. If the name arguments and the specifiers are not
in the Host Portable Character Encoding, the result is implementation-
dependent.
The following is a typical options table:
static XrmOptionDescRec opTable[ ] = {
{"-background", "*background", XrmoptionSepArg, (XPointer) NULL},
{"-bd", "*borderColor", XrmoptionSepArg, (XPointer) NULL},
{"-bg", "*background", XrmoptionSepArg, (XPointer) NULL},
{"-borderwidth", "*TopLevelShell.borderWidth", XrmoptionSepArg, (XPointer) NULL},
{"-bordercolor", "*borderColor", XrmoptionSepArg, (XPointer) NULL},
{"-bw", "*TopLevelShell.borderWidth", XrmoptionSepArg, (XPointer) NULL},
{"-display", ".display", XrmoptionSepArg, (XPointer) NULL},
{"-fg", "*foreground", XrmoptionSepArg, (XPointer) NULL},
{"-fn", "*font", XrmoptionSepArg, (XPointer) NULL},
{"-font", "*font", XrmoptionSepArg, (XPointer) NULL},
{"-foreground", "*foreground", XrmoptionSepArg, (XPointer) NULL},
{"-geometry", ".TopLevelShell.geometry", XrmoptionSepArg, (XPointer) NULL},
{"-iconic", ".TopLevelShell.iconic", XrmoptionNoArg, (XPointer) "on"},
{"-name", ".name", XrmoptionSepArg, (XPointer) NULL},
{"-reverse", "*reverseVideo", XrmoptionNoArg, (XPointer) "on"},
{"-rv", "*reverseVideo", XrmoptionNoArg, (XPointer) "on"},
{"-synchronous", ".synchronous", XrmoptionNoArg, (XPointer) "on"},
{"-title", ".TopLevelShell.title", XrmoptionSepArg, (XPointer) NULL},
{"-xrm", NULL, XrmoptionResArg, (XPointer) NULL},
};
In this table, if the -background (or -bg) option is used to set back‐
ground colors, the stored resource specifier will match all resources
of attribute background. If the -borderwidth option is used, the
stored resource specifier applies only to border width attributes of
class TopLevelShell (that is, outermost windows, including pop-up win‐
dows). If the -title option is used to set a window name, only the
topmost application windows receive the resource.
When parsing the command line, any unique unambiguous abbreviation for
an option name in the table is considered a match for the option. Note
that uppercase and lowercase matter.
For more information, see Volume One, Chapter 13, Managing User Prefer‐
ences.
Structures
XrmDatabase is a pointer to an opaque data type.
typedef enum {
XrmoptionNoArg, /* value is specified in OptionDescRec.value */
XrmoptionIsArg, /* value is the option string itself */
XrmoptionStickyArg, /* value is chars immediately following option */
XrmoptionSepArg, /* value is next argument in argv */
XrmoptionResArg, /* resource and value in next argument in argv */
XrmoptionSkipArg, /* ignore this option and next argument in argv */
XrmoptionSkipLine, /* ignore this option and the rest of argv */
XrmoptionSkipNArgs /* new in R4: ignore this option, skip */
/* number specified in next argument */
} XrmOptionKind;
typedef struct {
char *option; /* option specification string in argv */
char *resourceName; /* binding & resource name (w/out application name) */
XrmOptionKind argKind; /* which style of option it is */
XPointer value; /* value to provide if XrmoptionNoArg */
} XrmOptionDescRec, *XrmOptionDescList;
See AlsoXrmDestroyDatabase(), XrmGetFileDatabase(), XrmGetResource(), XrmGet‐
StringDatabase(), XrmInitialize(), XrmMergeDatabases(), XrmPutFile‐
Database(), XrmPutLineResource(), XrmPutResource(), XrmPutStringRe‐
source(), XrmQGetResource(), XrmQGetSearchList(), XrmQGetSearchRe‐
source(), XrmQPutResource(), XrmQPutStringResource(), XrmQuark‐
ToString(), XrmStringToBindingQuarkList(), XrmStringToQuarkList(), Xrm‐
StringToQuark(), XrmUniqueQuark().
Xlib - Resource Manager XrmParseCommand()