4 Best viewed with vim5, using ts=4
6 wmgeneral was taken from wmppp.
8 It has a lot of routines which most of the wm* programs use.
10 ------------------------------------------------------------
12 Author: Martijn Pieterse (pieterse@xs4all.nl)
17 11/08/2002 (Brad Jorsch, anomie@users.sourceforge.net)
18 * Moved all the rc-file related stuff to rcfile.[ch]
20 28/08/2001 (Brad Jorsch, anomie@users.sourceforge.net)
21 * Added EnableMouseRegion and DisableMouseRegion
22 * Got annoyed with the 81-character lines. Fixed it. If you don't like
23 it, find a different copy of wmgeneral.c ;)
24 * GraphicsExpose events are enabled here.
25 * GetXPM is exported. It optionally takes an XpmColorSymbol array.
26 * GetColor is exported.
28 30/09/2000 (Brad Jorsch, anomie@users.sourceforge.net)
29 * You know, wmgen.mask sounds like a much nicer place to store the
30 mask... why don't we do that?
32 21/09/1999 (Brad Jorsch, anomie@users.sourceforge.net)
33 * Changed openXwindow to use only the filename, sans path,
34 as the name and class properties of the app.
36 14/09/1998 (Dave Clark, clarkd@skyia.com)
37 * Updated createXBMfromXPM routine
38 * Now supports >256 colors
39 11/09/1998 (Martijn Pieterse, pieterse@xs4all.nl)
40 * Removed a bug from parse_rcfile. You could
41 not use "start" in a command if a label was
43 * Changed the needed geometry string.
44 We don't use window size, and don't support
46 03/09/1998 (Martijn Pieterse, pieterse@xs4all.nl)
48 02/09/1998 (Martijn Pieterse, pieterse@xs4all.nl)
49 * Added -geometry support (untested)
50 28/08/1998 (Martijn Pieterse, pieterse@xs4all.nl)
51 * Added createXBMfromXPM routine
52 * Saves a lot of work with changing xpm's.
53 02/05/1998 (Martijn Pieterse, pieterse@xs4all.nl)
54 * changed the read_rc_file to parse_rcfile, as suggested by Marcelo E. Magallon
55 * debugged the parse_rc file.
56 30/04/1998 (Martijn Pieterse, pieterse@xs4all.nl)
57 * Ripped similar code from all the wm* programs,
58 and put them in a single file.
68 /******************************************************************************\
70 \******************************************************************************/
72 void parse_rcfile(const char *filename
, rckeys
*keys
) {
76 char *tokens
= " :\t\n";
80 fp
= fopen(filename
, "r");
82 while (fgets(temp
, 128, fp
)) {
85 q
= strtok(q
, tokens
);
86 while (key
>= 0 && keys
[key
].label
) {
87 if ((!strcmp(q
, keys
[key
].label
))) {
88 p
= strstr(temp
, keys
[key
].label
);
89 p
+= strlen(keys
[key
].label
);
90 p
+= strspn(p
, tokens
);
91 if ((i
= strcspn(p
, "#\n"))) p
[i
] = 0;
93 *keys
[key
].var
= strdup(p
);
103 /******************************************************************************\
105 \******************************************************************************/
107 void parse_rcfile2(const char *filename
, rckeys2
*keys
) {
111 char *tokens
= " :\t\n";
116 fp
= fopen(filename
, "r");
118 while (fgets(temp
, 128, fp
)) {
120 while (key
>= 0 && keys
[key
].label
) {
121 if ((p
= strstr(temp
, keys
[key
].label
))) {
122 p
+= strlen(keys
[key
].label
);
123 p
+= strspn(p
, tokens
);
124 if ((i
= strcspn(p
, "#\n"))) p
[i
] = 0;
125 free(*keys
[key
].var
);
126 *keys
[key
].var
= strdup(p
);