next up previous contents
Next: Colors Up: Programming Tips Previous: Catching Motion Events

Getting arguments

To get a value from .Xdefaults use

char* XGetDefault(display,program_name, option)
char *program_name;
char *option;
To parse a geometry string, use
int XGetGeometry(geometry,x,y,width,height);
   int *x,*y;   /*RETURN */
   unsigned int *width, *height;  /*RETURN*/
The bits in the returned integer show how many values have been returned. The bits are XValue,YValue, WidthValue, HeightValue, XNegative and YNegative.

If you are likely to have many possible command line arguments, use XrmInitialise() to initialise a resource manager, then

XrmDatabase XrmGetFileDatabase(resource_file)
char *resource_file;
This will create a database from a file than has a format like .Xdefaults. To merge in any arguments on the command line, use
void XrmParseCommand(db,table, table_length, prog_name, argc, argv);
XrmDatabase db;
XrmOptionDescList table; /* a table of possible options */
int table_length;
char *prog_name; 
int *argc /* supplies the number of arguments, returns number unprocessed*/
char **argv;  /* supplies arguments, returns those unprocessed */
table is a pointer to an array of structures of the following type
typedef struct {
   char *option;          /* the command line flag */
   char *resouce;         /* the .X11defaults style string */
   XrmOptionKind argkind; /* XrmoptionSepArg, XrmoptionStickyArg,etc
                             (see /usr/include/X11/Xresource.h  */
   caddr_t value;         /* what to use if argkind is XrmoptionNoArg
                             (use NULL otherwise) */
} XrmOptionDescRec

Tim Love
Mon Mar 11 17:03:18 GMT 1996