Mercurial > emacs
annotate src/xrdb.c @ 110399:e4c19190baef
Fix bug #6933 regarding `half' width fringes.
fringe.el (fringe-mode, fringe-query-style): Use 4 pixels, not
5, for `half' width fringes. (Bug#6933)
| author | Eli Zaretskii <eliz@gnu.org> |
|---|---|
| date | Fri, 17 Sep 2010 23:07:57 +0200 |
| parents | e2f8226efb99 |
| children | a1facefdd4a2 |
| rev | line source |
|---|---|
| 159 | 1 /* Deal with the X Resource Manager. |
|
64770
a0d1312ede66
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64084
diff
changeset
|
2 Copyright (C) 1990, 1993, 1994, 2000, 2001, 2002, 2003, 2004, |
| 106815 | 3 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. |
| 159 | 4 |
|
101091
9e4d0326f86c
Comment (add Author:, based on authors.el).
Glenn Morris <rgm@gnu.org>
parents:
100951
diff
changeset
|
5 Author: Joseph Arceneaux |
|
9e4d0326f86c
Comment (add Author:, based on authors.el).
Glenn Morris <rgm@gnu.org>
parents:
100951
diff
changeset
|
6 Created: 4/90 |
|
9e4d0326f86c
Comment (add Author:, based on authors.el).
Glenn Morris <rgm@gnu.org>
parents:
100951
diff
changeset
|
7 |
|
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
10463
diff
changeset
|
8 This file is part of GNU Emacs. |
|
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
10463
diff
changeset
|
9 |
|
94963
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94942
diff
changeset
|
10 GNU Emacs is free software: you can redistribute it and/or modify |
| 159 | 11 it under the terms of the GNU General Public License as published by |
|
94963
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94942
diff
changeset
|
12 the Free Software Foundation, either version 3 of the License, or |
|
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94942
diff
changeset
|
13 (at your option) any later version. |
| 159 | 14 |
|
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
10463
diff
changeset
|
15 GNU Emacs is distributed in the hope that it will be useful, |
| 159 | 16 but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 18 GNU General Public License for more details. | |
| 19 | |
| 20 You should have received a copy of the GNU General Public License | |
|
94963
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94942
diff
changeset
|
21 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ |
| 159 | 22 |
|
4696
1fc792473491
Include <config.h> instead of "config.h".
Roland McGrath <roland@gnu.org>
parents:
4538
diff
changeset
|
23 #include <config.h> |
|
1019
aaa628aaf808
* xrdb.c [USG5]: Define SYSV, and then include <unistd.h>. I
Jim Blandy <jimb@redhat.com>
parents:
620
diff
changeset
|
24 |
| 21514 | 25 #ifdef HAVE_UNISTD_H |
| 26 #include <unistd.h> | |
| 27 #endif | |
| 28 | |
|
107737
912a8c0c9a8a
Remove extern errno declarations.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106815
diff
changeset
|
29 #include <errno.h> |
|
24412
d11ac02f9d6a
Use epaths.h istead of paths.h.
Richard M. Stallman <rms@gnu.org>
parents:
21514
diff
changeset
|
30 #include <epaths.h> |
| 19393 | 31 |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
32 #include <stdio.h> |
|
105669
68dd71358159
* alloc.c: Do not define struct catchtag.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105069
diff
changeset
|
33 #include <setjmp.h> |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
34 |
| 159 | 35 #include <X11/Xlib.h> |
| 36 #include <X11/Xatom.h> | |
| 37 #include <X11/X.h> | |
| 38 #include <X11/Xutil.h> | |
| 39 #include <X11/Xresource.h> | |
|
61700
8a54ce1fae6a
Remove reference to defunct vms-pwd.h.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
60830
diff
changeset
|
40 #ifdef HAVE_PWD_H |
| 159 | 41 #include <pwd.h> |
| 556 | 42 #endif |
| 159 | 43 #include <sys/stat.h> |
| 44 | |
|
5650
1476768ef7fc
(S_ISDIR): Define if not defined.
Richard M. Stallman <rms@gnu.org>
parents:
5116
diff
changeset
|
45 #if !defined(S_ISDIR) && defined(S_IFDIR) |
|
1476768ef7fc
(S_ISDIR): Define if not defined.
Richard M. Stallman <rms@gnu.org>
parents:
5116
diff
changeset
|
46 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) |
|
1476768ef7fc
(S_ISDIR): Define if not defined.
Richard M. Stallman <rms@gnu.org>
parents:
5116
diff
changeset
|
47 #endif |
|
1476768ef7fc
(S_ISDIR): Define if not defined.
Richard M. Stallman <rms@gnu.org>
parents:
5116
diff
changeset
|
48 |
|
24992
f1632be03391
(x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents:
24412
diff
changeset
|
49 #include "lisp.h" |
|
f1632be03391
(x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents:
24412
diff
changeset
|
50 |
|
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
108073
diff
changeset
|
51 extern char *getenv (const char *); |
|
1934
458a1fceb462
* xrdb.c (getuid): Remove declaration.
Jim Blandy <jimb@redhat.com>
parents:
1389
diff
changeset
|
52 |
|
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
108073
diff
changeset
|
53 extern struct passwd *getpwuid (uid_t); |
|
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
108073
diff
changeset
|
54 extern struct passwd *getpwnam (const char *); |
| 159 | 55 |
|
109726
64732fa6188a
Use const char* instead of char*.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109687
diff
changeset
|
56 extern const char *get_system_name (void); |
|
5735
87611653922f
(x_get_customization_string): Use get_system_name instead of gethostname.
Karl Heuer <kwzh@gnu.org>
parents:
5650
diff
changeset
|
57 |
|
109555
05e7e7c46ff0
Use const, move declarations to header files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109165
diff
changeset
|
58 char *x_get_string_resource (XrmDatabase rdb, const char *name, |
|
05e7e7c46ff0
Use const, move declarations to header files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109165
diff
changeset
|
59 const char *class); |
|
05e7e7c46ff0
Use const, move declarations to header files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109165
diff
changeset
|
60 static int file_p (const char *filename); |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
61 |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
62 |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
63 /* X file search path processing. */ |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
64 |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
65 |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
66 /* The string which gets substituted for the %C escape in XFILESEARCHPATH |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
67 and friends, or zero if none was specified. */ |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
68 char *x_customization_string; |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
69 |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
70 |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
71 /* Return the value of the emacs.customization (Emacs.Customization) |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
72 resource, for later use in search path decoding. If we find no |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
73 such resource, return zero. */ |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
74 char * |
|
109555
05e7e7c46ff0
Use const, move declarations to header files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109165
diff
changeset
|
75 x_get_customization_string (XrmDatabase db, const char *name, const char *class) |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
76 { |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
77 char *full_name |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
78 = (char *) alloca (strlen (name) + sizeof ("customization") + 3); |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
79 char *full_class |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
80 = (char *) alloca (strlen (class) + sizeof ("Customization") + 3); |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
81 char *result; |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
82 |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
83 sprintf (full_name, "%s.%s", name, "customization"); |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
84 sprintf (full_class, "%s.%s", class, "Customization"); |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
85 |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
86 result = x_get_string_resource (db, full_name, full_class); |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
87 |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
88 if (result) |
|
4538
0fd9dd894f9f
(x_get_customization_string): Don't use value of strcpy.
Richard M. Stallman <rms@gnu.org>
parents:
4366
diff
changeset
|
89 { |
| 109687 | 90 char *copy = (char *) xmalloc (strlen (result) + 1); |
|
4538
0fd9dd894f9f
(x_get_customization_string): Don't use value of strcpy.
Richard M. Stallman <rms@gnu.org>
parents:
4366
diff
changeset
|
91 strcpy (copy, result); |
|
0fd9dd894f9f
(x_get_customization_string): Don't use value of strcpy.
Richard M. Stallman <rms@gnu.org>
parents:
4366
diff
changeset
|
92 return copy; |
|
0fd9dd894f9f
(x_get_customization_string): Don't use value of strcpy.
Richard M. Stallman <rms@gnu.org>
parents:
4366
diff
changeset
|
93 } |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
94 else |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
95 return 0; |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
96 } |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
97 |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
98 |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
99 /* Expand all the Xt-style %-escapes in STRING, whose length is given |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
100 by STRING_LEN. Here are the escapes we're supposed to recognize: |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
101 |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
102 %N The value of the application's class name |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
103 %T The value of the type parameter ("app-defaults" in this |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
104 context) |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
105 %S The value of the suffix parameter ("" in this context) |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
106 %L The language string associated with the specified display |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
107 (We use the "LANG" environment variable here, if it's set.) |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
108 %l The language part of the display's language string |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
109 (We treat this just like %L. If someone can tell us what |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
110 we're really supposed to do, dandy.) |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
111 %t The territory part of the display's language string |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
112 (This never gets used.) |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
113 %c The codeset part of the display's language string |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
114 (This never gets used either.) |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
115 %C The customization string retrieved from the resource |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
116 database associated with display. |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
117 (This is x_customization_string.) |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
118 |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
119 Return the expanded file name if it exists and is readable, and |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
120 refers to %L only when the LANG environment variable is set, or |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
121 otherwise provided by X. |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
122 |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
123 ESCAPED_SUFFIX and SUFFIX are postpended to STRING if they are |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
124 non-zero. %-escapes in ESCAPED_SUFFIX are expanded; STRING is left |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
125 alone. |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
126 |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
127 Return NULL otherwise. */ |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
128 |
| 159 | 129 static char * |
|
109555
05e7e7c46ff0
Use const, move declarations to header files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109165
diff
changeset
|
130 magic_file_p (const char *string, int string_len, const char *class, const char *escaped_suffix, const char *suffix) |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
131 { |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
132 char *lang = getenv ("LANG"); |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
133 |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
134 int path_size = 100; |
| 109687 | 135 char *path = (char *) xmalloc (path_size); |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
136 int path_len = 0; |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
137 |
|
109555
05e7e7c46ff0
Use const, move declarations to header files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109165
diff
changeset
|
138 const char *p = string; |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
139 |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
140 while (p < string + string_len) |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
141 { |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
142 /* The chunk we're about to stick on the end of result. */ |
|
109555
05e7e7c46ff0
Use const, move declarations to header files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109165
diff
changeset
|
143 const char *next = NULL; |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
144 int next_len; |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
145 |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
146 if (*p == '%') |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
147 { |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
148 p++; |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
149 |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
150 if (p >= string + string_len) |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
151 next_len = 0; |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
152 else |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
153 switch (*p) |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
154 { |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
155 case '%': |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
156 next = "%"; |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
157 next_len = 1; |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
158 break; |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
159 |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
160 case 'C': |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
161 next = (x_customization_string |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
162 ? x_customization_string |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
163 : ""); |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
164 next_len = strlen (next); |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
165 break; |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
166 |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
167 case 'N': |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
168 next = class; |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
169 next_len = strlen (class); |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
170 break; |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
171 |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
172 case 'T': |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
173 next = "app-defaults"; |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
174 next_len = strlen (next); |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
175 break; |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
176 |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
177 default: |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
178 case 'S': |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
179 next_len = 0; |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
180 break; |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
181 |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
182 case 'L': |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
183 case 'l': |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
184 if (! lang) |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
185 { |
| 109687 | 186 xfree (path); |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
187 return NULL; |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
188 } |
|
29803
3dec4cd5e361
Don't declare xmalloc, xrealloc.
Sam Steingold <sds@gnu.org>
parents:
29756
diff
changeset
|
189 |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
190 next = lang; |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
191 next_len = strlen (next); |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
192 break; |
|
29803
3dec4cd5e361
Don't declare xmalloc, xrealloc.
Sam Steingold <sds@gnu.org>
parents:
29756
diff
changeset
|
193 |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
194 case 't': |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
195 case 'c': |
| 109687 | 196 xfree (path); |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
197 return NULL; |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
198 } |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
199 } |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
200 else |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
201 next = p, next_len = 1; |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
202 |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
203 /* Do we have room for this component followed by a '\0' ? */ |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
204 if (path_len + next_len + 1 > path_size) |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
205 { |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
206 path_size = (path_len + next_len + 1) * 2; |
| 109687 | 207 path = (char *) xrealloc (path, path_size); |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
208 } |
|
29803
3dec4cd5e361
Don't declare xmalloc, xrealloc.
Sam Steingold <sds@gnu.org>
parents:
29756
diff
changeset
|
209 |
|
109165
750db9f3e6d8
Replace bcopy, bzero, bcmp by memcpy, memmove, memset, memcmp
Andreas Schwab <schwab@linux-m68k.org>
parents:
109139
diff
changeset
|
210 memcpy (path + path_len, next, next_len); |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
211 path_len += next_len; |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
212 |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
213 p++; |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
214 |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
215 /* If we've reached the end of the string, append ESCAPED_SUFFIX. */ |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
216 if (p >= string + string_len && escaped_suffix) |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
217 { |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
218 string = escaped_suffix; |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
219 string_len = strlen (string); |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
220 p = string; |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
221 escaped_suffix = NULL; |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
222 } |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
223 } |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
224 |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
225 /* Perhaps we should add the SUFFIX now. */ |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
226 if (suffix) |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
227 { |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
228 int suffix_len = strlen (suffix); |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
229 |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
230 if (path_len + suffix_len + 1 > path_size) |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
231 { |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
232 path_size = (path_len + suffix_len + 1); |
| 109687 | 233 path = (char *) xrealloc (path, path_size); |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
234 } |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
235 |
|
109165
750db9f3e6d8
Replace bcopy, bzero, bcmp by memcpy, memmove, memset, memcmp
Andreas Schwab <schwab@linux-m68k.org>
parents:
109139
diff
changeset
|
236 memcpy (path + path_len, suffix, suffix_len); |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
237 path_len += suffix_len; |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
238 } |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
239 |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
240 path[path_len] = '\0'; |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
241 |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
242 if (! file_p (path)) |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
243 { |
| 109687 | 244 xfree (path); |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
245 return NULL; |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
246 } |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
247 |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
248 return path; |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
249 } |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
250 |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
251 |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
252 static char * |
|
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
108073
diff
changeset
|
253 gethomedir (void) |
| 159 | 254 { |
| 255 struct passwd *pw; | |
| 256 char *ptr; | |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
257 char *copy; |
| 159 | 258 |
| 259 if ((ptr = getenv ("HOME")) == NULL) | |
| 260 { | |
|
5917
91caeed50c64
(gethomedir): Look at LOGNAME before USER.
Karl Heuer <kwzh@gnu.org>
parents:
5735
diff
changeset
|
261 if ((ptr = getenv ("LOGNAME")) != NULL |
|
91caeed50c64
(gethomedir): Look at LOGNAME before USER.
Karl Heuer <kwzh@gnu.org>
parents:
5735
diff
changeset
|
262 || (ptr = getenv ("USER")) != NULL) |
| 159 | 263 pw = getpwnam (ptr); |
| 264 else | |
|
5917
91caeed50c64
(gethomedir): Look at LOGNAME before USER.
Karl Heuer <kwzh@gnu.org>
parents:
5735
diff
changeset
|
265 pw = getpwuid (getuid ()); |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
266 |
| 159 | 267 if (pw) |
| 268 ptr = pw->pw_dir; | |
| 269 } | |
| 270 | |
|
29803
3dec4cd5e361
Don't declare xmalloc, xrealloc.
Sam Steingold <sds@gnu.org>
parents:
29756
diff
changeset
|
271 if (ptr == NULL) |
|
69913
eddb3cab7138
(gethomedir): Use xstrdup.
Romain Francoise <romain@orebokech.com>
parents:
69911
diff
changeset
|
272 return xstrdup ("/"); |
| 159 | 273 |
| 109687 | 274 copy = (char *) xmalloc (strlen (ptr) + 2); |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
275 strcpy (copy, ptr); |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
276 strcat (copy, "/"); |
| 159 | 277 |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
278 return copy; |
| 159 | 279 } |
| 280 | |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
281 |
| 159 | 282 static int |
|
109555
05e7e7c46ff0
Use const, move declarations to header files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109165
diff
changeset
|
283 file_p (const char *filename) |
| 159 | 284 { |
| 285 struct stat status; | |
| 286 | |
|
43672
e26d9755d4e8
(file_p): Rename arg `path' to `filename'.
Richard M. Stallman <rms@gnu.org>
parents:
38840
diff
changeset
|
287 return (access (filename, 4) == 0 /* exists and is readable */ |
|
e26d9755d4e8
(file_p): Rename arg `path' to `filename'.
Richard M. Stallman <rms@gnu.org>
parents:
38840
diff
changeset
|
288 && stat (filename, &status) == 0 /* get the status */ |
|
5650
1476768ef7fc
(S_ISDIR): Define if not defined.
Richard M. Stallman <rms@gnu.org>
parents:
5116
diff
changeset
|
289 && (S_ISDIR (status.st_mode)) == 0); /* not a directory */ |
| 159 | 290 } |
| 291 | |
| 292 | |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
293 /* Find the first element of SEARCH_PATH which exists and is readable, |
|
29803
3dec4cd5e361
Don't declare xmalloc, xrealloc.
Sam Steingold <sds@gnu.org>
parents:
29756
diff
changeset
|
294 after expanding the %-escapes. Return 0 if we didn't find any, and |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
295 the path name of the one we found otherwise. */ |
| 159 | 296 |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
297 static char * |
|
109555
05e7e7c46ff0
Use const, move declarations to header files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109165
diff
changeset
|
298 search_magic_path (const char *search_path, const char *class, const char *escaped_suffix, const char *suffix) |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
299 { |
|
109555
05e7e7c46ff0
Use const, move declarations to header files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109165
diff
changeset
|
300 const char *s, *p; |
| 159 | 301 |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
302 for (s = search_path; *s; s = p) |
| 159 | 303 { |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
304 for (p = s; *p && *p != ':'; p++) |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
305 ; |
|
29803
3dec4cd5e361
Don't declare xmalloc, xrealloc.
Sam Steingold <sds@gnu.org>
parents:
29756
diff
changeset
|
306 |
|
5650
1476768ef7fc
(S_ISDIR): Define if not defined.
Richard M. Stallman <rms@gnu.org>
parents:
5116
diff
changeset
|
307 if (p > s) |
|
1476768ef7fc
(S_ISDIR): Define if not defined.
Richard M. Stallman <rms@gnu.org>
parents:
5116
diff
changeset
|
308 { |
|
109555
05e7e7c46ff0
Use const, move declarations to header files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109165
diff
changeset
|
309 char *path = magic_file_p (s, p - s, class, escaped_suffix, |
|
05e7e7c46ff0
Use const, move declarations to header files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109165
diff
changeset
|
310 suffix); |
|
5650
1476768ef7fc
(S_ISDIR): Define if not defined.
Richard M. Stallman <rms@gnu.org>
parents:
5116
diff
changeset
|
311 if (path) |
|
1476768ef7fc
(S_ISDIR): Define if not defined.
Richard M. Stallman <rms@gnu.org>
parents:
5116
diff
changeset
|
312 return path; |
|
1476768ef7fc
(S_ISDIR): Define if not defined.
Richard M. Stallman <rms@gnu.org>
parents:
5116
diff
changeset
|
313 } |
|
1476768ef7fc
(S_ISDIR): Define if not defined.
Richard M. Stallman <rms@gnu.org>
parents:
5116
diff
changeset
|
314 else if (*p == ':') |
| 159 | 315 { |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
316 char *path; |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
317 |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
318 s = "%N%S"; |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
319 path = magic_file_p (s, strlen (s), class, escaped_suffix, suffix); |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
320 if (path) |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
321 return path; |
| 159 | 322 } |
| 323 | |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
324 if (*p == ':') |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
325 p++; |
| 159 | 326 } |
| 327 | |
| 328 return 0; | |
| 329 } | |
| 330 | |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
331 /* Producing databases for individual sources. */ |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
332 |
| 159 | 333 static XrmDatabase |
|
109555
05e7e7c46ff0
Use const, move declarations to header files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109165
diff
changeset
|
334 get_system_app (const char *class) |
| 159 | 335 { |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
336 XrmDatabase db = NULL; |
|
109748
e2f8226efb99
Fix -Wwrite_strings in general and for Gtk+ specific code.
Jan D <jan.h.d@swipnet.se>
parents:
109726
diff
changeset
|
337 const char *path; |
|
e2f8226efb99
Fix -Wwrite_strings in general and for Gtk+ specific code.
Jan D <jan.h.d@swipnet.se>
parents:
109726
diff
changeset
|
338 char *p; |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
339 |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
340 path = getenv ("XFILESEARCHPATH"); |
|
19388
0f27d1477c21
(get_system_app): Use PATH_X_DEFAULTS.
Richard M. Stallman <rms@gnu.org>
parents:
19318
diff
changeset
|
341 if (! path) path = PATH_X_DEFAULTS; |
| 159 | 342 |
|
109748
e2f8226efb99
Fix -Wwrite_strings in general and for Gtk+ specific code.
Jan D <jan.h.d@swipnet.se>
parents:
109726
diff
changeset
|
343 p = search_magic_path (path, class, 0, 0); |
|
e2f8226efb99
Fix -Wwrite_strings in general and for Gtk+ specific code.
Jan D <jan.h.d@swipnet.se>
parents:
109726
diff
changeset
|
344 if (p) |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
345 { |
|
109748
e2f8226efb99
Fix -Wwrite_strings in general and for Gtk+ specific code.
Jan D <jan.h.d@swipnet.se>
parents:
109726
diff
changeset
|
346 db = XrmGetFileDatabase (p); |
|
e2f8226efb99
Fix -Wwrite_strings in general and for Gtk+ specific code.
Jan D <jan.h.d@swipnet.se>
parents:
109726
diff
changeset
|
347 xfree (p); |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
348 } |
| 159 | 349 |
| 350 return db; | |
| 351 } | |
| 352 | |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
353 |
| 159 | 354 static XrmDatabase |
|
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
108073
diff
changeset
|
355 get_fallback (Display *display) |
| 159 | 356 { |
| 357 return NULL; | |
| 358 } | |
| 359 | |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
360 |
| 159 | 361 static XrmDatabase |
|
109555
05e7e7c46ff0
Use const, move declarations to header files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109165
diff
changeset
|
362 get_user_app (const char *class) |
| 159 | 363 { |
|
109748
e2f8226efb99
Fix -Wwrite_strings in general and for Gtk+ specific code.
Jan D <jan.h.d@swipnet.se>
parents:
109726
diff
changeset
|
364 const char *path; |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
365 char *file = 0; |
|
17572
73d867b4a654
(get_user_app): Free the gethomedir value.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
366 char *free_it = 0; |
| 159 | 367 |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
368 /* Check for XUSERFILESEARCHPATH. It is a path of complete file |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
369 names, not directories. */ |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
370 if (((path = getenv ("XUSERFILESEARCHPATH")) |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
371 && (file = search_magic_path (path, class, 0, 0))) |
| 159 | 372 |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
373 /* Check for APPLRESDIR; it is a path of directories. In each, |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
374 we have to search for LANG/CLASS and then CLASS. */ |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
375 || ((path = getenv ("XAPPLRESDIR")) |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
376 && ((file = search_magic_path (path, class, "/%L/%N", 0)) |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
377 || (file = search_magic_path (path, class, "/%N", 0)))) |
|
29803
3dec4cd5e361
Don't declare xmalloc, xrealloc.
Sam Steingold <sds@gnu.org>
parents:
29756
diff
changeset
|
378 |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
379 /* Check in the home directory. This is a bit of a hack; let's |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
380 hope one's home directory doesn't contain any %-escapes. */ |
|
17572
73d867b4a654
(get_user_app): Free the gethomedir value.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
381 || (free_it = gethomedir (), |
|
73d867b4a654
(get_user_app): Free the gethomedir value.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
382 ((file = search_magic_path (free_it, class, "%L/%N", 0)) |
|
73d867b4a654
(get_user_app): Free the gethomedir value.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
383 || (file = search_magic_path (free_it, class, "%N", 0))))) |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
384 { |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
385 XrmDatabase db = XrmGetFileDatabase (file); |
| 109687 | 386 xfree (file); |
| 387 xfree (free_it); | |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
388 return db; |
| 159 | 389 } |
|
17572
73d867b4a654
(get_user_app): Free the gethomedir value.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
390 |
| 109687 | 391 xfree (free_it); |
|
17572
73d867b4a654
(get_user_app): Free the gethomedir value.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
392 return NULL; |
| 159 | 393 } |
| 394 | |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
395 |
| 159 | 396 static XrmDatabase |
|
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
108073
diff
changeset
|
397 get_user_db (Display *display) |
| 159 | 398 { |
| 399 XrmDatabase db; | |
| 400 char *xdefs; | |
| 401 | |
|
2126
616aeb5c1432
* xrdb.c (get_user_db): Since xrdb.c doesn't #include xterm.h,
Jim Blandy <jimb@redhat.com>
parents:
1934
diff
changeset
|
402 #ifdef PBaseSize /* Cheap way to test for X11R4 or later. */ |
|
1051
777ed2b92359
* xrdb.c (get_user_db): Use XResourceManagerString when available
Jim Blandy <jimb@redhat.com>
parents:
1019
diff
changeset
|
403 xdefs = XResourceManagerString (display); |
|
777ed2b92359
* xrdb.c (get_user_db): Use XResourceManagerString when available
Jim Blandy <jimb@redhat.com>
parents:
1019
diff
changeset
|
404 #else |
|
1019
aaa628aaf808
* xrdb.c [USG5]: Define SYSV, and then include <unistd.h>. I
Jim Blandy <jimb@redhat.com>
parents:
620
diff
changeset
|
405 xdefs = display->xdefaults; |
|
1051
777ed2b92359
* xrdb.c (get_user_db): Use XResourceManagerString when available
Jim Blandy <jimb@redhat.com>
parents:
1019
diff
changeset
|
406 #endif |
|
777ed2b92359
* xrdb.c (get_user_db): Use XResourceManagerString when available
Jim Blandy <jimb@redhat.com>
parents:
1019
diff
changeset
|
407 |
| 159 | 408 if (xdefs != NULL) |
| 409 db = XrmGetStringDatabase (xdefs); | |
| 410 else | |
| 411 { | |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
412 char *home; |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
413 char *xdefault; |
| 159 | 414 |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
415 home = gethomedir (); |
| 109687 | 416 xdefault = (char *) xmalloc (strlen (home) + sizeof (".Xdefaults")); |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
417 strcpy (xdefault, home); |
| 159 | 418 strcat (xdefault, ".Xdefaults"); |
| 419 db = XrmGetFileDatabase (xdefault); | |
| 109687 | 420 xfree (home); |
| 421 xfree (xdefault); | |
| 159 | 422 } |
| 423 | |
|
4366
04bd0c1a6245
* config.h.in (HAVE_XSCREENRESOURCESTRING): New #undef for
Jim Blandy <jimb@redhat.com>
parents:
4233
diff
changeset
|
424 #ifdef HAVE_XSCREENRESOURCESTRING |
|
3654
d9313b9a63ad
* xrdb.c (get_user_db): Get the screen-specific database too.
Jim Blandy <jimb@redhat.com>
parents:
3371
diff
changeset
|
425 /* Get the screen-specific resources too. */ |
|
d9313b9a63ad
* xrdb.c (get_user_db): Get the screen-specific database too.
Jim Blandy <jimb@redhat.com>
parents:
3371
diff
changeset
|
426 xdefs = XScreenResourceString (DefaultScreenOfDisplay (display)); |
|
d9313b9a63ad
* xrdb.c (get_user_db): Get the screen-specific database too.
Jim Blandy <jimb@redhat.com>
parents:
3371
diff
changeset
|
427 if (xdefs != NULL) |
|
3873
e67c6c10dd7c
* xrdb.c (get_user_db): Remember to free the screen-local resource
Jim Blandy <jimb@redhat.com>
parents:
3654
diff
changeset
|
428 { |
|
e67c6c10dd7c
* xrdb.c (get_user_db): Remember to free the screen-local resource
Jim Blandy <jimb@redhat.com>
parents:
3654
diff
changeset
|
429 XrmMergeDatabases (XrmGetStringDatabase (xdefs), &db); |
|
e67c6c10dd7c
* xrdb.c (get_user_db): Remember to free the screen-local resource
Jim Blandy <jimb@redhat.com>
parents:
3654
diff
changeset
|
430 XFree (xdefs); |
|
e67c6c10dd7c
* xrdb.c (get_user_db): Remember to free the screen-local resource
Jim Blandy <jimb@redhat.com>
parents:
3654
diff
changeset
|
431 } |
|
3654
d9313b9a63ad
* xrdb.c (get_user_db): Get the screen-specific database too.
Jim Blandy <jimb@redhat.com>
parents:
3371
diff
changeset
|
432 #endif |
|
d9313b9a63ad
* xrdb.c (get_user_db): Get the screen-specific database too.
Jim Blandy <jimb@redhat.com>
parents:
3371
diff
changeset
|
433 |
| 159 | 434 return db; |
| 435 } | |
| 436 | |
| 437 static XrmDatabase | |
|
109126
aec1143e8d85
Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
108073
diff
changeset
|
438 get_environ_db (void) |
| 159 | 439 { |
| 440 XrmDatabase db; | |
| 441 char *p; | |
|
109726
64732fa6188a
Use const char* instead of char*.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109687
diff
changeset
|
442 char *path = 0, *home = 0; |
|
64732fa6188a
Use const char* instead of char*.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109687
diff
changeset
|
443 const char *host; |
| 159 | 444 |
| 445 if ((p = getenv ("XENVIRONMENT")) == NULL) | |
| 446 { | |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
447 home = gethomedir (); |
|
5735
87611653922f
(x_get_customization_string): Use get_system_name instead of gethostname.
Karl Heuer <kwzh@gnu.org>
parents:
5650
diff
changeset
|
448 host = get_system_name (); |
| 109687 | 449 path = (char *) xmalloc (strlen (home) |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
450 + sizeof (".Xdefaults-") |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
451 + strlen (host)); |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
452 sprintf (path, "%s%s%s", home, ".Xdefaults-", host); |
| 159 | 453 p = path; |
| 454 } | |
| 455 | |
| 456 db = XrmGetFileDatabase (p); | |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
457 |
| 109687 | 458 xfree (path); |
| 459 xfree (home); | |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
460 |
| 159 | 461 return db; |
| 462 } | |
| 463 | |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
464 /* External interface. */ |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
465 |
| 159 | 466 /* Types of values that we can find in a database */ |
| 467 | |
| 468 #define XrmStringType "String" /* String representation */ | |
| 469 XrmRepresentation x_rm_string; /* Quark representation */ | |
| 470 | |
| 471 /* Load X resources based on the display and a possible -xrm option. */ | |
| 472 | |
| 473 XrmDatabase | |
|
109555
05e7e7c46ff0
Use const, move declarations to header files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109165
diff
changeset
|
474 x_load_resources (Display *display, const char *xrm_string, |
|
05e7e7c46ff0
Use const, move declarations to header files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109165
diff
changeset
|
475 const char *myname, const char *myclass) |
| 159 | 476 { |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
477 XrmDatabase user_database; |
| 159 | 478 XrmDatabase rdb; |
| 479 XrmDatabase db; | |
|
24992
f1632be03391
(x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents:
24412
diff
changeset
|
480 char line[256]; |
|
60830
35cf88000489
* xrdb.c (x_load_resources): Undo previous change (2005-03-18).
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
60717
diff
changeset
|
481 |
|
109555
05e7e7c46ff0
Use const, move declarations to header files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109165
diff
changeset
|
482 const char *helv = "-*-helvetica-medium-r-*--*-120-*-*-*-*-iso8859-1"; |
|
60830
35cf88000489
* xrdb.c (x_load_resources): Undo previous change (2005-03-18).
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
60717
diff
changeset
|
483 |
|
25749
275227ca3c0c
(get_fallback): Remove unused variable.
Gerd Moellmann <gerd@gnu.org>
parents:
24992
diff
changeset
|
484 #ifdef USE_MOTIF |
|
109555
05e7e7c46ff0
Use const, move declarations to header files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109165
diff
changeset
|
485 const char *courier = "-*-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-1"; |
|
25749
275227ca3c0c
(get_fallback): Remove unused variable.
Gerd Moellmann <gerd@gnu.org>
parents:
24992
diff
changeset
|
486 #endif |
| 159 | 487 |
| 488 x_rm_string = XrmStringToQuark (XrmStringType); | |
|
7342
4cf4669565af
(x_load_resources) [USE_X_TOOLKIT]: Don't call XrmInitialize.
Richard M. Stallman <rms@gnu.org>
parents:
7307
diff
changeset
|
489 #ifndef USE_X_TOOLKIT |
|
4cf4669565af
(x_load_resources) [USE_X_TOOLKIT]: Don't call XrmInitialize.
Richard M. Stallman <rms@gnu.org>
parents:
7307
diff
changeset
|
490 /* pmr@osf.org says this shouldn't be done if USE_X_TOOLKIT. |
|
4cf4669565af
(x_load_resources) [USE_X_TOOLKIT]: Don't call XrmInitialize.
Richard M. Stallman <rms@gnu.org>
parents:
7307
diff
changeset
|
491 I suspect it's because the toolkit version does this elsewhere. */ |
| 159 | 492 XrmInitialize (); |
|
7342
4cf4669565af
(x_load_resources) [USE_X_TOOLKIT]: Don't call XrmInitialize.
Richard M. Stallman <rms@gnu.org>
parents:
7307
diff
changeset
|
493 #endif |
| 159 | 494 rdb = XrmGetStringDatabase (""); |
| 495 | |
|
24992
f1632be03391
(x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents:
24412
diff
changeset
|
496 /* Add some font defaults. If the font `helv' doesn't exist, widgets |
|
f1632be03391
(x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents:
24412
diff
changeset
|
497 will use some other default font. */ |
|
f1632be03391
(x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents:
24412
diff
changeset
|
498 #ifdef USE_MOTIF |
|
29803
3dec4cd5e361
Don't declare xmalloc, xrealloc.
Sam Steingold <sds@gnu.org>
parents:
29756
diff
changeset
|
499 |
|
33084
31fae82503f7
(x_load_resources): Use the class name in the defaults.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31829
diff
changeset
|
500 sprintf (line, "%s.pane.background: grey75", myclass); |
|
29865
6b6699c7fce3
(x_load_resources): Add default resource for scroll bar's
Gerd Moellmann <gerd@gnu.org>
parents:
29803
diff
changeset
|
501 XrmPutLineResource (&rdb, line); |
|
33084
31fae82503f7
(x_load_resources): Use the class name in the defaults.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31829
diff
changeset
|
502 sprintf (line, "%s*fontList: %s", myclass, helv); |
|
24992
f1632be03391
(x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents:
24412
diff
changeset
|
503 XrmPutLineResource (&rdb, line); |
|
33084
31fae82503f7
(x_load_resources): Use the class name in the defaults.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31829
diff
changeset
|
504 sprintf (line, "%s*menu*background: grey75", myclass); |
|
24992
f1632be03391
(x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents:
24412
diff
changeset
|
505 XrmPutLineResource (&rdb, line); |
|
36739
483ab551a108
(x_load_resources) [USE_MOTIF]: Remove extraneous arg
Gerd Moellmann <gerd@gnu.org>
parents:
33084
diff
changeset
|
506 sprintf (line, "%s*menubar*background: grey75", myclass); |
|
24992
f1632be03391
(x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents:
24412
diff
changeset
|
507 XrmPutLineResource (&rdb, line); |
|
33084
31fae82503f7
(x_load_resources): Use the class name in the defaults.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31829
diff
changeset
|
508 sprintf (line, "%s*verticalScrollBar.background: grey75", myclass); |
|
24992
f1632be03391
(x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents:
24412
diff
changeset
|
509 XrmPutLineResource (&rdb, line); |
|
33084
31fae82503f7
(x_load_resources): Use the class name in the defaults.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31829
diff
changeset
|
510 sprintf (line, "%s*verticalScrollBar.troughColor: grey75", myclass); |
|
29865
6b6699c7fce3
(x_load_resources): Add default resource for scroll bar's
Gerd Moellmann <gerd@gnu.org>
parents:
29803
diff
changeset
|
511 XrmPutLineResource (&rdb, line); |
|
33084
31fae82503f7
(x_load_resources): Use the class name in the defaults.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31829
diff
changeset
|
512 sprintf (line, "%s.dialog*.background: grey75", myclass); |
|
24992
f1632be03391
(x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents:
24412
diff
changeset
|
513 XrmPutLineResource (&rdb, line); |
|
33084
31fae82503f7
(x_load_resources): Use the class name in the defaults.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31829
diff
changeset
|
514 sprintf (line, "%s*fsb.Text.background: white", myclass); |
|
24992
f1632be03391
(x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents:
24412
diff
changeset
|
515 XrmPutLineResource (&rdb, line); |
|
33084
31fae82503f7
(x_load_resources): Use the class name in the defaults.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31829
diff
changeset
|
516 sprintf (line, "%s*fsb.FilterText.background: white", myclass); |
|
24992
f1632be03391
(x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents:
24412
diff
changeset
|
517 XrmPutLineResource (&rdb, line); |
|
33084
31fae82503f7
(x_load_resources): Use the class name in the defaults.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31829
diff
changeset
|
518 sprintf (line, "%s*fsb*DirList.background: white", myclass); |
|
24992
f1632be03391
(x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents:
24412
diff
changeset
|
519 XrmPutLineResource (&rdb, line); |
|
33084
31fae82503f7
(x_load_resources): Use the class name in the defaults.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31829
diff
changeset
|
520 sprintf (line, "%s*fsb*ItemsList.background: white", myclass); |
|
24992
f1632be03391
(x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents:
24412
diff
changeset
|
521 XrmPutLineResource (&rdb, line); |
|
33084
31fae82503f7
(x_load_resources): Use the class name in the defaults.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31829
diff
changeset
|
522 sprintf (line, "%s*fsb*background: grey75", myclass); |
|
24992
f1632be03391
(x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents:
24412
diff
changeset
|
523 XrmPutLineResource (&rdb, line); |
|
33084
31fae82503f7
(x_load_resources): Use the class name in the defaults.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31829
diff
changeset
|
524 sprintf (line, "%s*fsb.Text.fontList: %s", myclass, courier); |
|
24992
f1632be03391
(x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents:
24412
diff
changeset
|
525 XrmPutLineResource (&rdb, line); |
|
33084
31fae82503f7
(x_load_resources): Use the class name in the defaults.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31829
diff
changeset
|
526 sprintf (line, "%s*fsb.FilterText.fontList: %s", myclass, courier); |
|
24992
f1632be03391
(x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents:
24412
diff
changeset
|
527 XrmPutLineResource (&rdb, line); |
|
33084
31fae82503f7
(x_load_resources): Use the class name in the defaults.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31829
diff
changeset
|
528 sprintf (line, "%s*fsb*ItemsList.fontList: %s", myclass, courier); |
|
24992
f1632be03391
(x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents:
24412
diff
changeset
|
529 XrmPutLineResource (&rdb, line); |
|
33084
31fae82503f7
(x_load_resources): Use the class name in the defaults.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31829
diff
changeset
|
530 sprintf (line, "%s*fsb*DirList.fontList: %s", myclass, courier); |
|
24992
f1632be03391
(x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents:
24412
diff
changeset
|
531 XrmPutLineResource (&rdb, line); |
|
f1632be03391
(x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents:
24412
diff
changeset
|
532 |
|
f1632be03391
(x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents:
24412
diff
changeset
|
533 /* Set double click time of list boxes in the file selection |
|
f1632be03391
(x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents:
24412
diff
changeset
|
534 dialog from `double-click-time'. */ |
|
f1632be03391
(x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents:
24412
diff
changeset
|
535 if (INTEGERP (Vdouble_click_time) && XINT (Vdouble_click_time) > 0) |
|
f1632be03391
(x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents:
24412
diff
changeset
|
536 { |
|
f1632be03391
(x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents:
24412
diff
changeset
|
537 sprintf (line, "%s*fsb*DirList.doubleClickInterval: %d", |
|
33084
31fae82503f7
(x_load_resources): Use the class name in the defaults.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31829
diff
changeset
|
538 myclass, XFASTINT (Vdouble_click_time)); |
|
24992
f1632be03391
(x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents:
24412
diff
changeset
|
539 XrmPutLineResource (&rdb, line); |
|
f1632be03391
(x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents:
24412
diff
changeset
|
540 sprintf (line, "%s*fsb*ItemsList.doubleClickInterval: %d", |
|
33084
31fae82503f7
(x_load_resources): Use the class name in the defaults.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31829
diff
changeset
|
541 myclass, XFASTINT (Vdouble_click_time)); |
|
24992
f1632be03391
(x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents:
24412
diff
changeset
|
542 XrmPutLineResource (&rdb, line); |
|
f1632be03391
(x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents:
24412
diff
changeset
|
543 } |
|
f1632be03391
(x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents:
24412
diff
changeset
|
544 |
|
f1632be03391
(x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents:
24412
diff
changeset
|
545 #else /* not USE_MOTIF */ |
|
29803
3dec4cd5e361
Don't declare xmalloc, xrealloc.
Sam Steingold <sds@gnu.org>
parents:
29756
diff
changeset
|
546 |
|
29755
ab23e43de97d
(x_load_resources): Set default resources for resource
Dave Love <fx@gnu.org>
parents:
25749
diff
changeset
|
547 sprintf (line, "Emacs.dialog*.font: %s", helv); |
|
24992
f1632be03391
(x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents:
24412
diff
changeset
|
548 XrmPutLineResource (&rdb, line); |
|
29755
ab23e43de97d
(x_load_resources): Set default resources for resource
Dave Love <fx@gnu.org>
parents:
25749
diff
changeset
|
549 sprintf (line, "Emacs.dialog*.background: grey75"); |
|
24992
f1632be03391
(x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents:
24412
diff
changeset
|
550 XrmPutLineResource (&rdb, line); |
|
29755
ab23e43de97d
(x_load_resources): Set default resources for resource
Dave Love <fx@gnu.org>
parents:
25749
diff
changeset
|
551 sprintf (line, "*XlwMenu*font: %s", helv); |
|
24992
f1632be03391
(x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents:
24412
diff
changeset
|
552 XrmPutLineResource (&rdb, line); |
|
29755
ab23e43de97d
(x_load_resources): Set default resources for resource
Dave Love <fx@gnu.org>
parents:
25749
diff
changeset
|
553 sprintf (line, "*XlwMenu*background: grey75"); |
|
24992
f1632be03391
(x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents:
24412
diff
changeset
|
554 XrmPutLineResource (&rdb, line); |
|
29755
ab23e43de97d
(x_load_resources): Set default resources for resource
Dave Love <fx@gnu.org>
parents:
25749
diff
changeset
|
555 sprintf (line, "Emacs*verticalScrollBar.background: grey75"); |
|
24992
f1632be03391
(x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents:
24412
diff
changeset
|
556 XrmPutLineResource (&rdb, line); |
|
29803
3dec4cd5e361
Don't declare xmalloc, xrealloc.
Sam Steingold <sds@gnu.org>
parents:
29756
diff
changeset
|
557 |
|
24992
f1632be03391
(x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents:
24412
diff
changeset
|
558 #endif /* not USE_MOTIF */ |
|
f1632be03391
(x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents:
24412
diff
changeset
|
559 |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
560 user_database = get_user_db (display); |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
561 |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
562 /* Figure out what the "customization string" is, so we can use it |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
563 to decode paths. */ |
| 109687 | 564 xfree (x_customization_string); |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
565 x_customization_string |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
566 = x_get_customization_string (user_database, myname, myclass); |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
567 |
| 159 | 568 /* Get application system defaults */ |
| 569 db = get_system_app (myclass); | |
| 570 if (db != NULL) | |
| 571 XrmMergeDatabases (db, &rdb); | |
| 572 | |
| 573 /* Get Fallback resources */ | |
| 574 db = get_fallback (display); | |
| 575 if (db != NULL) | |
| 576 XrmMergeDatabases (db, &rdb); | |
| 577 | |
| 578 /* Get application user defaults */ | |
| 579 db = get_user_app (myclass); | |
| 580 if (db != NULL) | |
| 581 XrmMergeDatabases (db, &rdb); | |
| 582 | |
| 583 /* get User defaults */ | |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
584 if (user_database != NULL) |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
585 XrmMergeDatabases (user_database, &rdb); |
| 159 | 586 |
| 587 /* Get Environment defaults. */ | |
| 588 db = get_environ_db (); | |
| 589 if (db != NULL) | |
| 590 XrmMergeDatabases (db, &rdb); | |
|
29803
3dec4cd5e361
Don't declare xmalloc, xrealloc.
Sam Steingold <sds@gnu.org>
parents:
29756
diff
changeset
|
591 |
| 159 | 592 /* Last, merge in any specification from the command line. */ |
| 593 if (xrm_string != NULL) | |
| 594 { | |
| 595 db = XrmGetStringDatabase (xrm_string); | |
| 596 if (db != NULL) | |
| 597 XrmMergeDatabases (db, &rdb); | |
| 598 } | |
| 599 | |
| 600 return rdb; | |
| 601 } | |
| 602 | |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
603 |
| 159 | 604 /* Retrieve the value of the resource specified by NAME with class CLASS |
| 605 and of type TYPE from database RDB. The value is returned in RET_VALUE. */ | |
| 606 | |
| 607 int | |
|
109555
05e7e7c46ff0
Use const, move declarations to header files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109165
diff
changeset
|
608 x_get_resource (XrmDatabase rdb, const char *name, const char *class, XrmRepresentation expected_type, XrmValue *ret_value) |
| 159 | 609 { |
| 610 XrmValue value; | |
| 611 XrmName namelist[100]; | |
| 612 XrmClass classlist[100]; | |
| 613 XrmRepresentation type; | |
| 614 | |
| 615 XrmStringToNameList(name, namelist); | |
| 616 XrmStringToClassList(class, classlist); | |
| 617 | |
| 618 if (XrmQGetResource (rdb, namelist, classlist, &type, &value) == True | |
| 619 && (type == expected_type)) | |
| 620 { | |
| 621 if (type == x_rm_string) | |
|
1200
d2360c870787
* xrdb.c (x_get_resource): Cast the value being assigned to
Jim Blandy <jimb@redhat.com>
parents:
1126
diff
changeset
|
622 ret_value->addr = (char *) value.addr; |
| 159 | 623 else |
|
109165
750db9f3e6d8
Replace bcopy, bzero, bcmp by memcpy, memmove, memset, memcmp
Andreas Schwab <schwab@linux-m68k.org>
parents:
109139
diff
changeset
|
624 memcpy (ret_value->addr, value.addr, ret_value->size); |
| 159 | 625 |
| 626 return value.size; | |
| 627 } | |
| 628 | |
| 629 return 0; | |
| 630 } | |
| 631 | |
| 632 /* Retrieve the string resource specified by NAME with CLASS from | |
| 633 database RDB. */ | |
| 634 | |
| 635 char * | |
|
109555
05e7e7c46ff0
Use const, move declarations to header files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109165
diff
changeset
|
636 x_get_string_resource (XrmDatabase rdb, const char *name, const char *class) |
| 159 | 637 { |
| 638 XrmValue value; | |
| 639 | |
|
105069
4cbb223d0b1c
The --quick command line option now ignores X resources and Registry settings.
Juanma Barranquero <lekktu@gmail.com>
parents:
101091
diff
changeset
|
640 if (inhibit_x_resources) |
|
4cbb223d0b1c
The --quick command line option now ignores X resources and Registry settings.
Juanma Barranquero <lekktu@gmail.com>
parents:
101091
diff
changeset
|
641 /* --quick was passed, so this is a no-op. */ |
|
4cbb223d0b1c
The --quick command line option now ignores X resources and Registry settings.
Juanma Barranquero <lekktu@gmail.com>
parents:
101091
diff
changeset
|
642 return NULL; |
|
4cbb223d0b1c
The --quick command line option now ignores X resources and Registry settings.
Juanma Barranquero <lekktu@gmail.com>
parents:
101091
diff
changeset
|
643 |
| 159 | 644 if (x_get_resource (rdb, name, class, x_rm_string, &value)) |
| 645 return (char *) value.addr; | |
| 646 | |
| 647 return (char *) 0; | |
| 648 } | |
| 649 | |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
650 /* Stand-alone test facilities. */ |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
651 |
| 159 | 652 #ifdef TESTRM |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
653 |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
654 typedef char **List; |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
655 #define arg_listify(len, list) (list) |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
656 #define car(list) (*(list)) |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
657 #define cdr(list) (list + 1) |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
658 #define NIL(list) (! *(list)) |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
659 #define free_arglist(list) |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
660 |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
661 static List |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
662 member (elt, list) |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
663 char *elt; |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
664 List list; |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
665 { |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
666 List p; |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
667 |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
668 for (p = list; ! NIL (p); p = cdr (p)) |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
669 if (! strcmp (elt, car (p))) |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
670 return p; |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
671 |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
672 return p; |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
673 } |
| 159 | 674 |
| 675 static void | |
| 676 fatal (msg, prog, x1, x2, x3, x4, x5) | |
| 677 char *msg, *prog; | |
| 678 int x1, x2, x3, x4, x5; | |
| 679 { | |
| 680 if (errno) | |
| 681 perror (prog); | |
| 682 | |
| 683 (void) fprintf (stderr, msg, prog, x1, x2, x3, x4, x5); | |
| 684 exit (1); | |
| 685 } | |
| 686 | |
| 687 main (argc, argv) | |
| 688 int argc; | |
| 689 char **argv; | |
| 690 { | |
| 691 Display *display; | |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
692 char *displayname, *resource_string, *class, *name; |
| 159 | 693 XrmDatabase xdb; |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
694 List arg_list, lp; |
| 159 | 695 |
| 696 arg_list = arg_listify (argc, argv); | |
| 697 | |
| 698 lp = member ("-d", arg_list); | |
| 699 if (!NIL (lp)) | |
| 700 displayname = car (cdr (lp)); | |
| 701 else | |
| 702 displayname = "localhost:0.0"; | |
| 703 | |
| 704 lp = member ("-xrm", arg_list); | |
| 705 if (! NIL (lp)) | |
| 706 resource_string = car (cdr (lp)); | |
| 707 else | |
| 708 resource_string = (char *) 0; | |
| 709 | |
| 710 lp = member ("-c", arg_list); | |
| 711 if (! NIL (lp)) | |
| 712 class = car (cdr (lp)); | |
| 713 else | |
| 714 class = "Emacs"; | |
| 715 | |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
716 lp = member ("-n", arg_list); |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
717 if (! NIL (lp)) |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
718 name = car (cdr (lp)); |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
719 else |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
720 name = "emacs"; |
| 159 | 721 |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
722 free_arglist (arg_list); |
| 159 | 723 |
| 724 if (!(display = XOpenDisplay (displayname))) | |
| 725 fatal ("Can't open display '%s'\n", XDisplayName (displayname)); | |
| 726 | |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
727 xdb = x_load_resources (display, resource_string, name, class); |
| 159 | 728 |
| 729 /* In a real program, you'd want to also do this: */ | |
| 730 display->db = xdb; | |
| 731 | |
| 732 while (1) | |
| 733 { | |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
734 char query_name[90]; |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
735 char query_class[90]; |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
736 |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
737 printf ("Name: "); |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
738 gets (query_name); |
| 159 | 739 |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
740 if (strlen (query_name)) |
| 159 | 741 { |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
742 char *value; |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
743 |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
744 printf ("Class: "); |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
745 gets (query_class); |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
746 |
|
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
747 value = x_get_string_resource (xdb, query_name, query_class); |
| 159 | 748 |
| 749 if (value != NULL) | |
|
4232
f533d585cfc8
Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents:
3873
diff
changeset
|
750 printf ("\t%s(%s): %s\n\n", query_name, query_class, value); |
| 159 | 751 else |
| 752 printf ("\tNo Value.\n\n"); | |
| 753 } | |
| 754 else | |
| 755 break; | |
| 756 } | |
| 757 printf ("\tExit.\n\n"); | |
| 758 | |
| 759 XCloseDisplay (display); | |
| 760 } | |
| 761 #endif /* TESTRM */ | |
| 52401 | 762 |
| 763 /* arch-tag: 37e6fbab-ed05-4363-9e76-6c4109ed511f | |
| 764 (do not change this comment) */ |
