annotate src/xrdb.c @ 112299:61e41fbed768

* xterm.h (struct x_display_info): Remove stray semicolon.
author Paul Eggert <eggert@cs.ucla.edu>
date Sun, 16 Jan 2011 23:28:25 -0800
parents ef719132ddfa
children 56d3e9c28eb0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
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,
112218
376148b31b5e Add 2011 to FSF/AIST copyright years.
Glenn Morris <rgm@gnu.org>
parents: 106815
diff changeset
3 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
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
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
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
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
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
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
18 GNU General Public License for more details.
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
19
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
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
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
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
fa9ff387d260 Fix -Wimplicit warnings.
Andreas Schwab <schwab@suse.de>
parents: 19393
diff changeset
25 #ifdef HAVE_UNISTD_H
fa9ff387d260 Fix -Wimplicit warnings.
Andreas Schwab <schwab@suse.de>
parents: 19393
diff changeset
26 #include <unistd.h>
fa9ff387d260 Fix -Wimplicit warnings.
Andreas Schwab <schwab@suse.de>
parents: 19393
diff changeset
27 #endif
fa9ff387d260 Fix -Wimplicit warnings.
Andreas Schwab <schwab@suse.de>
parents: 19393
diff changeset
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
ef747a07f03d Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 19388
diff changeset
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
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
35 #include <X11/Xlib.h>
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
36 #include <X11/Xatom.h>
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
37 #include <X11/X.h>
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
38 #include <X11/Xutil.h>
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
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
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
41 #include <pwd.h>
556
af0eae450bc9 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 485
diff changeset
42 #endif
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
43 #include <sys/stat.h>
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
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
111094
0c681b288c59 Fix compilation with Motif (Bug#7263).
Jan D <jan.h.d@swipnet.se>
parents: 110572
diff changeset
51 #ifdef USE_MOTIF
0c681b288c59 Fix compilation with Motif (Bug#7263).
Jan D <jan.h.d@swipnet.se>
parents: 110572
diff changeset
52 /* For Vdouble_click_time. */
0c681b288c59 Fix compilation with Motif (Bug#7263).
Jan D <jan.h.d@swipnet.se>
parents: 110572
diff changeset
53 #include "keyboard.h"
1934
458a1fceb462 * xrdb.c (getuid): Remove declaration.
Jim Blandy <jimb@redhat.com>
parents: 1389
diff changeset
54 #endif
458a1fceb462 * xrdb.c (getuid): Remove declaration.
Jim Blandy <jimb@redhat.com>
parents: 1389
diff changeset
55
109126
aec1143e8d85 Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 108073
diff changeset
56 extern char *getenv (const char *);
1934
458a1fceb462 * xrdb.c (getuid): Remove declaration.
Jim Blandy <jimb@redhat.com>
parents: 1389
diff changeset
57
3371
fe452e556782 [__bsdi__]: Alternate decls of getpwuid and getpwnam.
Richard M. Stallman <rms@gnu.org>
parents: 3142
diff changeset
58 extern struct passwd *getpwuid (uid_t);
fe452e556782 [__bsdi__]: Alternate decls of getpwuid and getpwnam.
Richard M. Stallman <rms@gnu.org>
parents: 3142
diff changeset
59 extern struct passwd *getpwnam (const char *);
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
60
109726
64732fa6188a Use const char* instead of char*.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109687
diff changeset
61 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
62
109555
05e7e7c46ff0 Use const, move declarations to header files.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109165
diff changeset
63 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
64 const char *class);
05e7e7c46ff0 Use const, move declarations to header files.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109165
diff changeset
65 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
66
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
67
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
68 /* X file search path processing. */
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 /* 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
72 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
73 char *x_customization_string;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
74
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
75
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
76 /* 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
77 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
78 such resource, return zero. */
112023
ac49e05bfcf2 Remove unused declarations
Andreas Schwab <schwab@linux-m68k.org>
parents: 111094
diff changeset
79 static char *
ac49e05bfcf2 Remove unused declarations
Andreas Schwab <schwab@linux-m68k.org>
parents: 111094
diff changeset
80 x_get_customization_string (XrmDatabase db, const char *name,
ac49e05bfcf2 Remove unused declarations
Andreas Schwab <schwab@linux-m68k.org>
parents: 111094
diff changeset
81 const char *class)
4232
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 char *full_name
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
84 = (char *) alloca (strlen (name) + sizeof ("customization") + 3);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
85 char *full_class
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
86 = (char *) alloca (strlen (class) + sizeof ("Customization") + 3);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
87 char *result;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
88
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
89 sprintf (full_name, "%s.%s", name, "customization");
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
90 sprintf (full_class, "%s.%s", class, "Customization");
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
91
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
92 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
93
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
94 if (result)
4538
0fd9dd894f9f (x_get_customization_string): Don't use value of strcpy.
Richard M. Stallman <rms@gnu.org>
parents: 4366
diff changeset
95 {
109687
d6c4fa12ba52 Cleanup xrdb.c.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109573
diff changeset
96 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
97 strcpy (copy, result);
0fd9dd894f9f (x_get_customization_string): Don't use value of strcpy.
Richard M. Stallman <rms@gnu.org>
parents: 4366
diff changeset
98 return copy;
0fd9dd894f9f (x_get_customization_string): Don't use value of strcpy.
Richard M. Stallman <rms@gnu.org>
parents: 4366
diff changeset
99 }
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
100 else
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
101 return 0;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
102 }
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
103
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
104
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
105 /* 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
106 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
107
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
108 %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
109 %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
110 context)
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
111 %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
112 %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
113 (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
114 %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
115 (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
116 we're really supposed to do, dandy.)
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
117 %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
118 (This never gets used.)
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
119 %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
120 (This never gets used either.)
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
121 %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
122 database associated with display.
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
123 (This is x_customization_string.)
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
124
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
125 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
126 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
127 otherwise provided by X.
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
128
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
129 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
130 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
131 alone.
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
132
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
133 Return NULL otherwise. */
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
134
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
135 static char *
110572
a1facefdd4a2 xrdb.c EMACS_INT/int audit.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 109748
diff changeset
136 magic_file_p (const char *string, EMACS_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
137 {
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
138 char *lang = getenv ("LANG");
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 int path_size = 100;
109687
d6c4fa12ba52 Cleanup xrdb.c.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109573
diff changeset
141 char *path = (char *) xmalloc (path_size);
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
142 int path_len = 0;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
143
109555
05e7e7c46ff0 Use const, move declarations to header files.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109165
diff changeset
144 const char *p = string;
4232
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 while (p < string + string_len)
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 /* 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
149 const char *next = NULL;
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
150 int next_len;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
151
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
152 if (*p == '%')
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
153 {
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
154 p++;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
155
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
156 if (p >= string + string_len)
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
157 next_len = 0;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
158 else
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
159 switch (*p)
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
160 {
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
161 case '%':
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
162 next = "%";
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
163 next_len = 1;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
164 break;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
165
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
166 case 'C':
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
167 next = (x_customization_string
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
168 ? x_customization_string
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
169 : "");
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
170 next_len = strlen (next);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
171 break;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
172
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
173 case 'N':
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
174 next = class;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
175 next_len = strlen (class);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
176 break;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
177
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
178 case 'T':
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
179 next = "app-defaults";
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
180 next_len = strlen (next);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
181 break;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
182
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
183 default:
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
184 case 'S':
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
185 next_len = 0;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
186 break;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
187
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
188 case 'L':
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
189 case 'l':
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
190 if (! lang)
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
191 {
109687
d6c4fa12ba52 Cleanup xrdb.c.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109573
diff changeset
192 xfree (path);
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
193 return NULL;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
194 }
29803
3dec4cd5e361 Don't declare xmalloc, xrealloc.
Sam Steingold <sds@gnu.org>
parents: 29756
diff changeset
195
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
196 next = lang;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
197 next_len = strlen (next);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
198 break;
29803
3dec4cd5e361 Don't declare xmalloc, xrealloc.
Sam Steingold <sds@gnu.org>
parents: 29756
diff changeset
199
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
200 case 't':
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
201 case 'c':
109687
d6c4fa12ba52 Cleanup xrdb.c.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109573
diff changeset
202 xfree (path);
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
203 return NULL;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
204 }
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 else
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
207 next = p, next_len = 1;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
208
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
209 /* 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
210 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
211 {
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
212 path_size = (path_len + next_len + 1) * 2;
109687
d6c4fa12ba52 Cleanup xrdb.c.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109573
diff changeset
213 path = (char *) xrealloc (path, path_size);
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
214 }
29803
3dec4cd5e361 Don't declare xmalloc, xrealloc.
Sam Steingold <sds@gnu.org>
parents: 29756
diff changeset
215
109165
750db9f3e6d8 Replace bcopy, bzero, bcmp by memcpy, memmove, memset, memcmp
Andreas Schwab <schwab@linux-m68k.org>
parents: 109139
diff changeset
216 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
217 path_len += next_len;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
218
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
219 p++;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
220
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
221 /* 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
222 if (p >= string + string_len && escaped_suffix)
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 string = escaped_suffix;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
225 string_len = strlen (string);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
226 p = string;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
227 escaped_suffix = NULL;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
228 }
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
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
231 /* Perhaps we should add the SUFFIX now. */
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
232 if (suffix)
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
233 {
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
234 int suffix_len = strlen (suffix);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
235
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
236 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
237 {
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
238 path_size = (path_len + suffix_len + 1);
109687
d6c4fa12ba52 Cleanup xrdb.c.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109573
diff changeset
239 path = (char *) xrealloc (path, path_size);
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
240 }
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
241
109165
750db9f3e6d8 Replace bcopy, bzero, bcmp by memcpy, memmove, memset, memcmp
Andreas Schwab <schwab@linux-m68k.org>
parents: 109139
diff changeset
242 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
243 path_len += suffix_len;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
244 }
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
245
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
246 path[path_len] = '\0';
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 if (! file_p (path))
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
249 {
109687
d6c4fa12ba52 Cleanup xrdb.c.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109573
diff changeset
250 xfree (path);
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
251 return NULL;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
252 }
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
253
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
254 return path;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
255 }
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
256
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
257
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
258 static char *
109126
aec1143e8d85 Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 108073
diff changeset
259 gethomedir (void)
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
260 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
261 struct passwd *pw;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
262 char *ptr;
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
263 char *copy;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
264
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
265 if ((ptr = getenv ("HOME")) == NULL)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
266 {
5917
91caeed50c64 (gethomedir): Look at LOGNAME before USER.
Karl Heuer <kwzh@gnu.org>
parents: 5735
diff changeset
267 if ((ptr = getenv ("LOGNAME")) != NULL
91caeed50c64 (gethomedir): Look at LOGNAME before USER.
Karl Heuer <kwzh@gnu.org>
parents: 5735
diff changeset
268 || (ptr = getenv ("USER")) != NULL)
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
269 pw = getpwnam (ptr);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
270 else
5917
91caeed50c64 (gethomedir): Look at LOGNAME before USER.
Karl Heuer <kwzh@gnu.org>
parents: 5735
diff changeset
271 pw = getpwuid (getuid ());
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
272
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
273 if (pw)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
274 ptr = pw->pw_dir;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
275 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
276
29803
3dec4cd5e361 Don't declare xmalloc, xrealloc.
Sam Steingold <sds@gnu.org>
parents: 29756
diff changeset
277 if (ptr == NULL)
69913
eddb3cab7138 (gethomedir): Use xstrdup.
Romain Francoise <romain@orebokech.com>
parents: 69911
diff changeset
278 return xstrdup ("/");
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
279
109687
d6c4fa12ba52 Cleanup xrdb.c.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109573
diff changeset
280 copy = (char *) xmalloc (strlen (ptr) + 2);
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
281 strcpy (copy, ptr);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
282 strcat (copy, "/");
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
283
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
284 return copy;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
285 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
286
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
287
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
288 static int
109555
05e7e7c46ff0 Use const, move declarations to header files.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109165
diff changeset
289 file_p (const char *filename)
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
290 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
291 struct stat status;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
292
43672
e26d9755d4e8 (file_p): Rename arg `path' to `filename'.
Richard M. Stallman <rms@gnu.org>
parents: 38840
diff changeset
293 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
294 && 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
295 && (S_ISDIR (status.st_mode)) == 0); /* not a directory */
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
296 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
297
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
298
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
299 /* 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
300 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
301 the path name of the one we found otherwise. */
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
302
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
303 static char *
109555
05e7e7c46ff0 Use const, move declarations to header files.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109165
diff changeset
304 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
305 {
109555
05e7e7c46ff0 Use const, move declarations to header files.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109165
diff changeset
306 const char *s, *p;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
307
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
308 for (s = search_path; *s; s = p)
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
309 {
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
310 for (p = s; *p && *p != ':'; p++)
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
311 ;
29803
3dec4cd5e361 Don't declare xmalloc, xrealloc.
Sam Steingold <sds@gnu.org>
parents: 29756
diff changeset
312
5650
1476768ef7fc (S_ISDIR): Define if not defined.
Richard M. Stallman <rms@gnu.org>
parents: 5116
diff changeset
313 if (p > s)
1476768ef7fc (S_ISDIR): Define if not defined.
Richard M. Stallman <rms@gnu.org>
parents: 5116
diff changeset
314 {
109555
05e7e7c46ff0 Use const, move declarations to header files.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109165
diff changeset
315 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
316 suffix);
5650
1476768ef7fc (S_ISDIR): Define if not defined.
Richard M. Stallman <rms@gnu.org>
parents: 5116
diff changeset
317 if (path)
1476768ef7fc (S_ISDIR): Define if not defined.
Richard M. Stallman <rms@gnu.org>
parents: 5116
diff changeset
318 return path;
1476768ef7fc (S_ISDIR): Define if not defined.
Richard M. Stallman <rms@gnu.org>
parents: 5116
diff changeset
319 }
1476768ef7fc (S_ISDIR): Define if not defined.
Richard M. Stallman <rms@gnu.org>
parents: 5116
diff changeset
320 else if (*p == ':')
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
321 {
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
322 char *path;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
323
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
324 s = "%N%S";
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
325 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
326 if (path)
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
327 return path;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
328 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
329
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
330 if (*p == ':')
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
331 p++;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
332 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
333
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
334 return 0;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
335 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
336
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
337 /* Producing databases for individual sources. */
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
338
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
339 static XrmDatabase
109555
05e7e7c46ff0 Use const, move declarations to header files.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109165
diff changeset
340 get_system_app (const char *class)
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
341 {
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
342 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
343 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
344 char *p;
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
345
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
346 path = getenv ("XFILESEARCHPATH");
19388
0f27d1477c21 (get_system_app): Use PATH_X_DEFAULTS.
Richard M. Stallman <rms@gnu.org>
parents: 19318
diff changeset
347 if (! path) path = PATH_X_DEFAULTS;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
348
109748
e2f8226efb99 Fix -Wwrite_strings in general and for Gtk+ specific code.
Jan D <jan.h.d@swipnet.se>
parents: 109726
diff changeset
349 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
350 if (p)
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
351 {
109748
e2f8226efb99 Fix -Wwrite_strings in general and for Gtk+ specific code.
Jan D <jan.h.d@swipnet.se>
parents: 109726
diff changeset
352 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
353 xfree (p);
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
354 }
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
355
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
356 return db;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
357 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
358
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
359
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
360 static XrmDatabase
109126
aec1143e8d85 Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 108073
diff changeset
361 get_fallback (Display *display)
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
362 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
363 return NULL;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
364 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
365
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
366
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
367 static XrmDatabase
109555
05e7e7c46ff0 Use const, move declarations to header files.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109165
diff changeset
368 get_user_app (const char *class)
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
369 {
109748
e2f8226efb99 Fix -Wwrite_strings in general and for Gtk+ specific code.
Jan D <jan.h.d@swipnet.se>
parents: 109726
diff changeset
370 const char *path;
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
371 char *file = 0;
17572
73d867b4a654 (get_user_app): Free the gethomedir value.
Richard M. Stallman <rms@gnu.org>
parents: 14186
diff changeset
372 char *free_it = 0;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
373
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
374 /* 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
375 names, not directories. */
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
376 if (((path = getenv ("XUSERFILESEARCHPATH"))
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
377 && (file = search_magic_path (path, class, 0, 0)))
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
378
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
379 /* 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
380 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
381 || ((path = getenv ("XAPPLRESDIR"))
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
382 && ((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
383 || (file = search_magic_path (path, class, "/%N", 0))))
29803
3dec4cd5e361 Don't declare xmalloc, xrealloc.
Sam Steingold <sds@gnu.org>
parents: 29756
diff changeset
384
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
385 /* 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
386 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
387 || (free_it = gethomedir (),
73d867b4a654 (get_user_app): Free the gethomedir value.
Richard M. Stallman <rms@gnu.org>
parents: 14186
diff changeset
388 ((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
389 || (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
390 {
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
391 XrmDatabase db = XrmGetFileDatabase (file);
109687
d6c4fa12ba52 Cleanup xrdb.c.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109573
diff changeset
392 xfree (file);
d6c4fa12ba52 Cleanup xrdb.c.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109573
diff changeset
393 xfree (free_it);
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
394 return db;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
395 }
17572
73d867b4a654 (get_user_app): Free the gethomedir value.
Richard M. Stallman <rms@gnu.org>
parents: 14186
diff changeset
396
109687
d6c4fa12ba52 Cleanup xrdb.c.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109573
diff changeset
397 xfree (free_it);
17572
73d867b4a654 (get_user_app): Free the gethomedir value.
Richard M. Stallman <rms@gnu.org>
parents: 14186
diff changeset
398 return NULL;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
399 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
400
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
401
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
402 static XrmDatabase
109126
aec1143e8d85 Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 108073
diff changeset
403 get_user_db (Display *display)
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
404 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
405 XrmDatabase db;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
406 char *xdefs;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
407
2126
616aeb5c1432 * xrdb.c (get_user_db): Since xrdb.c doesn't #include xterm.h,
Jim Blandy <jimb@redhat.com>
parents: 1934
diff changeset
408 #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
409 xdefs = XResourceManagerString (display);
777ed2b92359 * xrdb.c (get_user_db): Use XResourceManagerString when available
Jim Blandy <jimb@redhat.com>
parents: 1019
diff changeset
410 #else
1019
aaa628aaf808 * xrdb.c [USG5]: Define SYSV, and then include <unistd.h>. I
Jim Blandy <jimb@redhat.com>
parents: 620
diff changeset
411 xdefs = display->xdefaults;
1051
777ed2b92359 * xrdb.c (get_user_db): Use XResourceManagerString when available
Jim Blandy <jimb@redhat.com>
parents: 1019
diff changeset
412 #endif
777ed2b92359 * xrdb.c (get_user_db): Use XResourceManagerString when available
Jim Blandy <jimb@redhat.com>
parents: 1019
diff changeset
413
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
414 if (xdefs != NULL)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
415 db = XrmGetStringDatabase (xdefs);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
416 else
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
417 {
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
418 char *home;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
419 char *xdefault;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
420
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
421 home = gethomedir ();
109687
d6c4fa12ba52 Cleanup xrdb.c.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109573
diff changeset
422 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
423 strcpy (xdefault, home);
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
424 strcat (xdefault, ".Xdefaults");
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
425 db = XrmGetFileDatabase (xdefault);
109687
d6c4fa12ba52 Cleanup xrdb.c.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109573
diff changeset
426 xfree (home);
d6c4fa12ba52 Cleanup xrdb.c.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109573
diff changeset
427 xfree (xdefault);
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
428 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
429
4366
04bd0c1a6245 * config.h.in (HAVE_XSCREENRESOURCESTRING): New #undef for
Jim Blandy <jimb@redhat.com>
parents: 4233
diff changeset
430 #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
431 /* 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
432 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
433 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
434 {
e67c6c10dd7c * xrdb.c (get_user_db): Remember to free the screen-local resource
Jim Blandy <jimb@redhat.com>
parents: 3654
diff changeset
435 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
436 XFree (xdefs);
e67c6c10dd7c * xrdb.c (get_user_db): Remember to free the screen-local resource
Jim Blandy <jimb@redhat.com>
parents: 3654
diff changeset
437 }
3654
d9313b9a63ad * xrdb.c (get_user_db): Get the screen-specific database too.
Jim Blandy <jimb@redhat.com>
parents: 3371
diff changeset
438 #endif
d9313b9a63ad * xrdb.c (get_user_db): Get the screen-specific database too.
Jim Blandy <jimb@redhat.com>
parents: 3371
diff changeset
439
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
440 return db;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
441 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
442
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
443 static XrmDatabase
109126
aec1143e8d85 Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 108073
diff changeset
444 get_environ_db (void)
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
445 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
446 XrmDatabase db;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
447 char *p;
109726
64732fa6188a Use const char* instead of char*.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109687
diff changeset
448 char *path = 0, *home = 0;
64732fa6188a Use const char* instead of char*.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109687
diff changeset
449 const char *host;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
450
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
451 if ((p = getenv ("XENVIRONMENT")) == NULL)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
452 {
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
453 home = gethomedir ();
5735
87611653922f (x_get_customization_string): Use get_system_name instead of gethostname.
Karl Heuer <kwzh@gnu.org>
parents: 5650
diff changeset
454 host = get_system_name ();
109687
d6c4fa12ba52 Cleanup xrdb.c.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109573
diff changeset
455 path = (char *) xmalloc (strlen (home)
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
456 + sizeof (".Xdefaults-")
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
457 + strlen (host));
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
458 sprintf (path, "%s%s%s", home, ".Xdefaults-", host);
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
459 p = path;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
460 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
461
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
462 db = XrmGetFileDatabase (p);
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
463
109687
d6c4fa12ba52 Cleanup xrdb.c.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109573
diff changeset
464 xfree (path);
d6c4fa12ba52 Cleanup xrdb.c.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109573
diff changeset
465 xfree (home);
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
466
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
467 return db;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
468 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
469
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
470 /* External interface. */
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
471
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
472 /* Types of values that we can find in a database */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
473
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
474 #define XrmStringType "String" /* String representation */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
475 XrmRepresentation x_rm_string; /* Quark representation */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
476
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
477 /* Load X resources based on the display and a possible -xrm option. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
478
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
479 XrmDatabase
109555
05e7e7c46ff0 Use const, move declarations to header files.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109165
diff changeset
480 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
481 const char *myname, const char *myclass)
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
482 {
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
483 XrmDatabase user_database;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
484 XrmDatabase rdb;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
485 XrmDatabase db;
24992
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
486 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
487
109555
05e7e7c46ff0 Use const, move declarations to header files.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109165
diff changeset
488 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
489
25749
275227ca3c0c (get_fallback): Remove unused variable.
Gerd Moellmann <gerd@gnu.org>
parents: 24992
diff changeset
490 #ifdef USE_MOTIF
109555
05e7e7c46ff0 Use const, move declarations to header files.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109165
diff changeset
491 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
492 #endif
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
493
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
494 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
495 #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
496 /* 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
497 I suspect it's because the toolkit version does this elsewhere. */
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
498 XrmInitialize ();
7342
4cf4669565af (x_load_resources) [USE_X_TOOLKIT]: Don't call XrmInitialize.
Richard M. Stallman <rms@gnu.org>
parents: 7307
diff changeset
499 #endif
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
500 rdb = XrmGetStringDatabase ("");
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
501
24992
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
502 /* 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
503 will use some other default font. */
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
504 #ifdef USE_MOTIF
29803
3dec4cd5e361 Don't declare xmalloc, xrealloc.
Sam Steingold <sds@gnu.org>
parents: 29756
diff changeset
505
33084
31fae82503f7 (x_load_resources): Use the class name in the defaults.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31829
diff changeset
506 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
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*fontList: %s", myclass, helv);
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*menu*background: grey75", myclass);
24992
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
511 XrmPutLineResource (&rdb, line);
36739
483ab551a108 (x_load_resources) [USE_MOTIF]: Remove extraneous arg
Gerd Moellmann <gerd@gnu.org>
parents: 33084
diff changeset
512 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
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*verticalScrollBar.background: grey75", 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*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
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.dialog*.background: grey75", 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.Text.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.FilterText.background: white", 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*DirList.background: white", myclass);
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*ItemsList.background: white", myclass);
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*background: grey75", myclass);
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.Text.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);
33084
31fae82503f7 (x_load_resources): Use the class name in the defaults.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31829
diff changeset
532 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
533 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
534 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
535 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
536 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
537 XrmPutLineResource (&rdb, line);
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
538
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
539 /* 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
540 dialog from `double-click-time'. */
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
541 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
542 {
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
543 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
544 myclass, XFASTINT (Vdouble_click_time));
24992
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
545 XrmPutLineResource (&rdb, line);
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
546 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
547 myclass, XFASTINT (Vdouble_click_time));
24992
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
548 XrmPutLineResource (&rdb, line);
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
549 }
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
550
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
551 #else /* not USE_MOTIF */
29803
3dec4cd5e361 Don't declare xmalloc, xrealloc.
Sam Steingold <sds@gnu.org>
parents: 29756
diff changeset
552
29755
ab23e43de97d (x_load_resources): Set default resources for resource
Dave Love <fx@gnu.org>
parents: 25749
diff changeset
553 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
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.dialog*.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);
29755
ab23e43de97d (x_load_resources): Set default resources for resource
Dave Love <fx@gnu.org>
parents: 25749
diff changeset
557 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
558 XrmPutLineResource (&rdb, line);
29755
ab23e43de97d (x_load_resources): Set default resources for resource
Dave Love <fx@gnu.org>
parents: 25749
diff changeset
559 sprintf (line, "*XlwMenu*background: grey75");
24992
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
560 XrmPutLineResource (&rdb, line);
29755
ab23e43de97d (x_load_resources): Set default resources for resource
Dave Love <fx@gnu.org>
parents: 25749
diff changeset
561 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
562 XrmPutLineResource (&rdb, line);
29803
3dec4cd5e361 Don't declare xmalloc, xrealloc.
Sam Steingold <sds@gnu.org>
parents: 29756
diff changeset
563
24992
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
564 #endif /* not USE_MOTIF */
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
565
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
566 user_database = get_user_db (display);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
567
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
568 /* 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
569 to decode paths. */
109687
d6c4fa12ba52 Cleanup xrdb.c.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109573
diff changeset
570 xfree (x_customization_string);
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
571 x_customization_string
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
572 = 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
573
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
574 /* Get application system defaults */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
575 db = get_system_app (myclass);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
576 if (db != NULL)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
577 XrmMergeDatabases (db, &rdb);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
578
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
579 /* Get Fallback resources */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
580 db = get_fallback (display);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
581 if (db != NULL)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
582 XrmMergeDatabases (db, &rdb);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
583
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
584 /* Get application user defaults */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
585 db = get_user_app (myclass);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
586 if (db != NULL)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
587 XrmMergeDatabases (db, &rdb);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
588
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
589 /* get User defaults */
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
590 if (user_database != NULL)
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
591 XrmMergeDatabases (user_database, &rdb);
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
592
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
593 /* Get Environment defaults. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
594 db = get_environ_db ();
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
595 if (db != NULL)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
596 XrmMergeDatabases (db, &rdb);
29803
3dec4cd5e361 Don't declare xmalloc, xrealloc.
Sam Steingold <sds@gnu.org>
parents: 29756
diff changeset
597
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
598 /* Last, merge in any specification from the command line. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
599 if (xrm_string != NULL)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
600 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
601 db = XrmGetStringDatabase (xrm_string);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
602 if (db != NULL)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
603 XrmMergeDatabases (db, &rdb);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
604 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
605
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
606 return rdb;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
607 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
608
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
609
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
610 /* Retrieve the value of the resource specified by NAME with class CLASS
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
611 and of type TYPE from database RDB. The value is returned in RET_VALUE. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
612
112023
ac49e05bfcf2 Remove unused declarations
Andreas Schwab <schwab@linux-m68k.org>
parents: 111094
diff changeset
613 static int
ac49e05bfcf2 Remove unused declarations
Andreas Schwab <schwab@linux-m68k.org>
parents: 111094
diff changeset
614 x_get_resource (XrmDatabase rdb, const char *name, const char *class,
ac49e05bfcf2 Remove unused declarations
Andreas Schwab <schwab@linux-m68k.org>
parents: 111094
diff changeset
615 XrmRepresentation expected_type, XrmValue *ret_value)
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
616 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
617 XrmValue value;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
618 XrmName namelist[100];
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
619 XrmClass classlist[100];
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
620 XrmRepresentation type;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
621
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
622 XrmStringToNameList(name, namelist);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
623 XrmStringToClassList(class, classlist);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
624
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
625 if (XrmQGetResource (rdb, namelist, classlist, &type, &value) == True
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
626 && (type == expected_type))
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
627 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
628 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
629 ret_value->addr = (char *) value.addr;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
630 else
109165
750db9f3e6d8 Replace bcopy, bzero, bcmp by memcpy, memmove, memset, memcmp
Andreas Schwab <schwab@linux-m68k.org>
parents: 109139
diff changeset
631 memcpy (ret_value->addr, value.addr, ret_value->size);
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
632
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
633 return value.size;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
634 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
635
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
636 return 0;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
637 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
638
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
639 /* Retrieve the string resource specified by NAME with CLASS from
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
640 database RDB. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
641
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
642 char *
109555
05e7e7c46ff0 Use const, move declarations to header files.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109165
diff changeset
643 x_get_string_resource (XrmDatabase rdb, const char *name, const char *class)
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
644 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
645 XrmValue value;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
646
105069
4cbb223d0b1c The --quick command line option now ignores X resources and Registry settings.
Juanma Barranquero <lekktu@gmail.com>
parents: 101091
diff changeset
647 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
648 /* --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
649 return NULL;
4cbb223d0b1c The --quick command line option now ignores X resources and Registry settings.
Juanma Barranquero <lekktu@gmail.com>
parents: 101091
diff changeset
650
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
651 if (x_get_resource (rdb, name, class, x_rm_string, &value))
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
652 return (char *) value.addr;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
653
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
654 return (char *) 0;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
655 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
656
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
657 /* Stand-alone test facilities. */
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
658
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
659 #ifdef TESTRM
4232
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 typedef char **List;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
662 #define arg_listify(len, list) (list)
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
663 #define car(list) (*(list))
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
664 #define cdr(list) (list + 1)
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
665 #define NIL(list) (! *(list))
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
666 #define free_arglist(list)
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 static List
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
669 member (elt, list)
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
670 char *elt;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
671 List list;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
672 {
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
673 List p;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
674
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
675 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
676 if (! strcmp (elt, car (p)))
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
677 return p;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
678
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
679 return p;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
680 }
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
681
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
682 static void
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
683 fatal (msg, prog, x1, x2, x3, x4, x5)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
684 char *msg, *prog;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
685 int x1, x2, x3, x4, x5;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
686 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
687 if (errno)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
688 perror (prog);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
689
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
690 (void) fprintf (stderr, msg, prog, x1, x2, x3, x4, x5);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
691 exit (1);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
692 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
693
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
694 main (argc, argv)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
695 int argc;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
696 char **argv;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
697 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
698 Display *display;
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
699 char *displayname, *resource_string, *class, *name;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
700 XrmDatabase xdb;
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
701 List arg_list, lp;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
702
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
703 arg_list = arg_listify (argc, argv);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
704
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
705 lp = member ("-d", arg_list);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
706 if (!NIL (lp))
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
707 displayname = car (cdr (lp));
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
708 else
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
709 displayname = "localhost:0.0";
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
710
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
711 lp = member ("-xrm", arg_list);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
712 if (! NIL (lp))
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
713 resource_string = car (cdr (lp));
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
714 else
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
715 resource_string = (char *) 0;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
716
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
717 lp = member ("-c", arg_list);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
718 if (! NIL (lp))
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
719 class = car (cdr (lp));
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
720 else
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
721 class = "Emacs";
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
722
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
723 lp = member ("-n", arg_list);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
724 if (! NIL (lp))
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
725 name = car (cdr (lp));
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
726 else
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
727 name = "emacs";
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
728
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
729 free_arglist (arg_list);
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
730
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
731 if (!(display = XOpenDisplay (displayname)))
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
732 fatal ("Can't open display '%s'\n", XDisplayName (displayname));
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
733
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
734 xdb = x_load_resources (display, resource_string, name, class);
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
735
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
736 /* In a real program, you'd want to also do this: */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
737 display->db = xdb;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
738
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
739 while (1)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
740 {
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
741 char query_name[90];
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
742 char query_class[90];
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 ("Name: ");
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
745 gets (query_name);
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
746
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
747 if (strlen (query_name))
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
748 {
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
749 char *value;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
750
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
751 printf ("Class: ");
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
752 gets (query_class);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
753
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
754 value = x_get_string_resource (xdb, query_name, query_class);
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
755
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
756 if (value != NULL)
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
757 printf ("\t%s(%s): %s\n\n", query_name, query_class, value);
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
758 else
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
759 printf ("\tNo Value.\n\n");
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
760 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
761 else
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
762 break;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
763 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
764 printf ("\tExit.\n\n");
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
765
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
766 XCloseDisplay (display);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
767 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
768 #endif /* TESTRM */
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 43672
diff changeset
769