File: opts.c

package info (click to toggle)
fookb 2.21-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 360 kB
  • ctags: 49
  • sloc: ansic: 567; makefile: 85; sh: 44
file content (115 lines) | stat: -rw-r--r-- 2,672 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/*
 * File: opts.c
 *
 * Created: Sun Sep 26 00:10:42 1999
 */

#include <stdio.h>

#ifdef HAVE_LIBPROPLIST
#ifdef HAVE_PROPLIST_H
#define PROPLIST
#endif
#endif

#include <string.h>

#include <X11/Xlib.h>		/* X Window standard header */
#include <X11/Xresource.h>	/* X resource manager stuff */

#include "fookb.h"
#include "opts.h"

static int tblentr = 6;		/* There are 6 recognized
				   options */
static XrmOptionDescRec tbl[] = {
	{"-icon1", ".icon1",
	 XrmoptionSepArg,
	 (XPointer) NULL},
	{"-icon2", ".icon2",
	 XrmoptionSepArg,
	 (XPointer) NULL},
	{"-icon3", ".icon3",
	 XrmoptionSepArg,
	 (XPointer) NULL},
	{"-icon4", ".icon4",
	 XrmoptionSepArg,
	 (XPointer) NULL},
	{"-iconboom", ".iconBoom",
	 XrmoptionSepArg,
	 (XPointer) NULL},
	{"-display", ".display",
	 XrmoptionSepArg,
	 (XPointer) NULL}
};

void ParseOptions(argc, argv)
int *argc;
register char *argv[];
{
	XrmValue value;
	char *str_type[20];
	mydispname[0] = '\0';

	XrmParseCommand(&cmdlineDB, tbl, tblentr, "fookb", argc, argv);

#ifdef DEBUG
	puts("Hereiam");
#endif

	if (1 != *argc) {
		puts("Fookb v 2.13");
		puts("\tUsage: fookb [options]");
		puts("Possible options:");
		puts("-icon1 xpm_file\t\tIcon to show for the 1st Xkb group");
		puts("-icon2 xpm_file\t\tIcon to show for the 2nd Xkb group");
		puts("-icon3 xpm_file\t\tIcon to show for the 3rd Xkb group");
		puts("-icon4 xpm_file\t\tIcon to show for the 4th Xkb group");
		puts("-iconboom xpm_file\tIcon to show when Xkb system goes crazy");
		puts("-display X_display\tX display to use (normally not needed)");
		puts("");
#ifdef PROPLIST
		puts("Command line parameters takes precedence over X resources or configuration file!");
		printf("Configuration file location: ");
#ifdef WMAKER
		puts("~/GNUstep/Defaults/FOOkb");
#else
		puts("~/.fookb");
#endif
#else
		puts("Command line paramaters takes precedence over X resources!");
#endif
		exit(0);
	}

	/* We should get display now -- we need it for access to other
	   databases */
	if (XrmGetResource(cmdlineDB, "fookb.display", "Fookb.Display",
			   str_type, &value) == True) {
		(void) strncpy(mydispname, value.addr, (size_t)value.size);
#ifdef DEBUG
		puts(mydispname);
#endif
	}

}

void MoreOptions()
{

	XrmDatabase servDB, appDB;

	appDB = XrmGetFileDatabase
		("/usr/X11R6/lib/X11/app-defaults/Fookb");
	(void) XrmMergeDatabases(appDB, &finalDB);	/* Fookb defaults file
							   added into final
							   database */

	/* Let's look: does xrdb load server defautls? (As a property of
	   root window.) */
	if (XResourceManagerString(dpy) != NULL) {
		servDB = XrmGetStringDatabase(XResourceManagerString(dpy));
		XrmMergeDatabases(servDB, &finalDB);
	}

}