annotate src/xrdb.c @ 101492:3f77442b1edf

* term/ns-win.el (ns-insert-working-text, ns-delete-working-text): Remove from global map and key definitions. (ns-toggle-toolbar, ns-info-prefs): Add to global map and key definitions. (ns-show-preferences-help, ns-unput-working-text): New functions. (ns-unecho-working-text): Update message.
author Adrian Robert <Adrian.B.Robert@gmail.com>
date Sun, 25 Jan 2009 19:50:16 +0000
parents 9e4d0326f86c
children 4cbb223d0b1c
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,
100951
e038c1a8307c Add 2009 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 95479
diff changeset
3 2005, 2006, 2007, 2008, 2009 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
1019
aaa628aaf808 * xrdb.c [USG5]: Define SYSV, and then include <unistd.h>. I
Jim Blandy <jimb@redhat.com>
parents: 620
diff changeset
23 #ifdef emacs
4696
1fc792473491 Include <config.h> instead of "config.h".
Roland McGrath <roland@gnu.org>
parents: 4538
diff changeset
24 #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
25 #endif
aaa628aaf808 * xrdb.c [USG5]: Define SYSV, and then include <unistd.h>. I
Jim Blandy <jimb@redhat.com>
parents: 620
diff changeset
26
21514
fa9ff387d260 Fix -Wimplicit warnings.
Andreas Schwab <schwab@suse.de>
parents: 19393
diff changeset
27 #ifdef HAVE_UNISTD_H
fa9ff387d260 Fix -Wimplicit warnings.
Andreas Schwab <schwab@suse.de>
parents: 19393
diff changeset
28 #include <unistd.h>
fa9ff387d260 Fix -Wimplicit warnings.
Andreas Schwab <schwab@suse.de>
parents: 19393
diff changeset
29 #endif
fa9ff387d260 Fix -Wimplicit warnings.
Andreas Schwab <schwab@suse.de>
parents: 19393
diff changeset
30
24412
d11ac02f9d6a Use epaths.h istead of paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 21514
diff changeset
31 #include <epaths.h>
19393
ef747a07f03d Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 19388
diff changeset
32
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
33 #include <stdio.h>
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
34
1019
aaa628aaf808 * xrdb.c [USG5]: Define SYSV, and then include <unistd.h>. I
Jim Blandy <jimb@redhat.com>
parents: 620
diff changeset
35 #if 1 /* I'd really appreciate it if this code could go away... -JimB */
38840
4fe55fd0a408 (SYSV): Don't define on Solaris 2.
Gerd Moellmann <gerd@gnu.org>
parents: 36739
diff changeset
36 /* This avoids lossage in the `dual-universe' headers on AT&T SysV
4fe55fd0a408 (SYSV): Don't define on Solaris 2.
Gerd Moellmann <gerd@gnu.org>
parents: 36739
diff changeset
37 X11. Don't do it on Solaris, because it breaks compilation with
4fe55fd0a408 (SYSV): Don't define on Solaris 2.
Gerd Moellmann <gerd@gnu.org>
parents: 36739
diff changeset
38 XFree86 4.0.3 (and probably many other X11R6 releases) on Solaris
4fe55fd0a408 (SYSV): Don't define on Solaris 2.
Gerd Moellmann <gerd@gnu.org>
parents: 36739
diff changeset
39 2 */
4fe55fd0a408 (SYSV): Don't define on Solaris 2.
Gerd Moellmann <gerd@gnu.org>
parents: 36739
diff changeset
40 #if defined(USG5) && !defined(SOLARIS2)
8295
51cebd28b474 [USG5] (SYSV): Don't define if already defined.
Richard M. Stallman <rms@gnu.org>
parents: 7342
diff changeset
41 #ifndef SYSV
1019
aaa628aaf808 * xrdb.c [USG5]: Define SYSV, and then include <unistd.h>. I
Jim Blandy <jimb@redhat.com>
parents: 620
diff changeset
42 #define SYSV
8295
51cebd28b474 [USG5] (SYSV): Don't define if already defined.
Richard M. Stallman <rms@gnu.org>
parents: 7342
diff changeset
43 #endif
38840
4fe55fd0a408 (SYSV): Don't define on Solaris 2.
Gerd Moellmann <gerd@gnu.org>
parents: 36739
diff changeset
44 #endif /* USG5 && !SOLARIS2 */
1019
aaa628aaf808 * xrdb.c [USG5]: Define SYSV, and then include <unistd.h>. I
Jim Blandy <jimb@redhat.com>
parents: 620
diff changeset
45
aaa628aaf808 * xrdb.c [USG5]: Define SYSV, and then include <unistd.h>. I
Jim Blandy <jimb@redhat.com>
parents: 620
diff changeset
46 #endif /* 1 */
1389
517c3893ec5b * xterm.c, xrdb.c: #include <stdio.h> before "xterm.h", to avoid
Jim Blandy <jimb@redhat.com>
parents: 1200
diff changeset
47
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
48 #include <X11/Xlib.h>
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
49 #include <X11/Xatom.h>
1126
94d76dbb5ce6 * xrdb.c: Don't include <X11/Xos.h>. Under R4, it stupidly
Jim Blandy <jimb@redhat.com>
parents: 1051
diff changeset
50 #if 0
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
51 #include <X11/Xos.h>
1126
94d76dbb5ce6 * xrdb.c: Don't include <X11/Xos.h>. Under R4, it stupidly
Jim Blandy <jimb@redhat.com>
parents: 1051
diff changeset
52 #endif
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
53 #include <X11/X.h>
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
54 #include <X11/Xutil.h>
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
55 #include <X11/Xresource.h>
61700
8a54ce1fae6a Remove reference to defunct vms-pwd.h.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 60830
diff changeset
56 #ifdef HAVE_PWD_H
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
57 #include <pwd.h>
556
af0eae450bc9 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 485
diff changeset
58 #endif
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
59 #include <sys/stat.h>
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
60
5650
1476768ef7fc (S_ISDIR): Define if not defined.
Richard M. Stallman <rms@gnu.org>
parents: 5116
diff changeset
61 #if !defined(S_ISDIR) && defined(S_IFDIR)
1476768ef7fc (S_ISDIR): Define if not defined.
Richard M. Stallman <rms@gnu.org>
parents: 5116
diff changeset
62 #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
63 #endif
1476768ef7fc (S_ISDIR): Define if not defined.
Richard M. Stallman <rms@gnu.org>
parents: 5116
diff changeset
64
24992
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
65 #include "lisp.h"
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
66
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
67 extern char *getenv ();
1934
458a1fceb462 * xrdb.c (getuid): Remove declaration.
Jim Blandy <jimb@redhat.com>
parents: 1389
diff changeset
68
458a1fceb462 * xrdb.c (getuid): Remove declaration.
Jim Blandy <jimb@redhat.com>
parents: 1389
diff changeset
69 /* This does cause trouble on AIX. I'm going to take the comment at
458a1fceb462 * xrdb.c (getuid): Remove declaration.
Jim Blandy <jimb@redhat.com>
parents: 1389
diff changeset
70 face value. */
458a1fceb462 * xrdb.c (getuid): Remove declaration.
Jim Blandy <jimb@redhat.com>
parents: 1389
diff changeset
71 #if 0
1126
94d76dbb5ce6 * xrdb.c: Don't include <X11/Xos.h>. Under R4, it stupidly
Jim Blandy <jimb@redhat.com>
parents: 1051
diff changeset
72 extern short getuid (); /* If this causes portability problems,
94d76dbb5ce6 * xrdb.c: Don't include <X11/Xos.h>. Under R4, it stupidly
Jim Blandy <jimb@redhat.com>
parents: 1051
diff changeset
73 I think we should just delete it; it'll
94d76dbb5ce6 * xrdb.c: Don't include <X11/Xos.h>. Under R4, it stupidly
Jim Blandy <jimb@redhat.com>
parents: 1051
diff changeset
74 default to `int' anyway. */
1934
458a1fceb462 * xrdb.c (getuid): Remove declaration.
Jim Blandy <jimb@redhat.com>
parents: 1389
diff changeset
75 #endif
458a1fceb462 * xrdb.c (getuid): Remove declaration.
Jim Blandy <jimb@redhat.com>
parents: 1389
diff changeset
76
8775
36f01bbb7d71 (getpwuid, getpwnam): Test just DECLARE_GETPWUID_WITH_UID_T, not __bsdi__.
Richard M. Stallman <rms@gnu.org>
parents: 8295
diff changeset
77 #ifdef DECLARE_GETPWUID_WITH_UID_T
3371
fe452e556782 [__bsdi__]: Alternate decls of getpwuid and getpwnam.
Richard M. Stallman <rms@gnu.org>
parents: 3142
diff changeset
78 extern struct passwd *getpwuid (uid_t);
fe452e556782 [__bsdi__]: Alternate decls of getpwuid and getpwnam.
Richard M. Stallman <rms@gnu.org>
parents: 3142
diff changeset
79 extern struct passwd *getpwnam (const char *);
fe452e556782 [__bsdi__]: Alternate decls of getpwuid and getpwnam.
Richard M. Stallman <rms@gnu.org>
parents: 3142
diff changeset
80 #else
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
81 extern struct passwd *getpwuid ();
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
82 extern struct passwd *getpwnam ();
3371
fe452e556782 [__bsdi__]: Alternate decls of getpwuid and getpwnam.
Richard M. Stallman <rms@gnu.org>
parents: 3142
diff changeset
83 #endif
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
84
5735
87611653922f (x_get_customization_string): Use get_system_name instead of gethostname.
Karl Heuer <kwzh@gnu.org>
parents: 5650
diff changeset
85 extern char *get_system_name ();
87611653922f (x_get_customization_string): Use get_system_name instead of gethostname.
Karl Heuer <kwzh@gnu.org>
parents: 5650
diff changeset
86
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
87 /* Make sure not to #include anything after these definitions. Let's
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
88 not step on anyone's prototypes. */
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
89 #ifdef emacs
68631
e51361e03895 (malloc, realloc, free) [emacs]: Undefine macros before defining.
Ken Raeburn <raeburn@raeburn.org>
parents: 64770
diff changeset
90 /* darwin.h may have already defined these. */
e51361e03895 (malloc, realloc, free) [emacs]: Undefine macros before defining.
Ken Raeburn <raeburn@raeburn.org>
parents: 64770
diff changeset
91 #undef malloc
e51361e03895 (malloc, realloc, free) [emacs]: Undefine macros before defining.
Ken Raeburn <raeburn@raeburn.org>
parents: 64770
diff changeset
92 #undef realloc
e51361e03895 (malloc, realloc, free) [emacs]: Undefine macros before defining.
Ken Raeburn <raeburn@raeburn.org>
parents: 64770
diff changeset
93 #undef free
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
94 #define malloc xmalloc
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
95 #define realloc xrealloc
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
96 #define free xfree
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
97 #endif
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
98
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
99 char *x_get_string_resource ();
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
100 static int file_p ();
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
101
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
102
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
103 /* X file search path processing. */
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
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
106 /* 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
107 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
108 char *x_customization_string;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
109
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
110
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
111 /* 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
112 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
113 such resource, return zero. */
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
114 char *
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
115 x_get_customization_string (db, name, class)
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
116 XrmDatabase db;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
117 char *name, *class;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
118 {
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
119 char *full_name
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
120 = (char *) alloca (strlen (name) + sizeof ("customization") + 3);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
121 char *full_class
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
122 = (char *) alloca (strlen (class) + sizeof ("Customization") + 3);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
123 char *result;
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 sprintf (full_name, "%s.%s", name, "customization");
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
126 sprintf (full_class, "%s.%s", class, "Customization");
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
127
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
128 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
129
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
130 if (result)
4538
0fd9dd894f9f (x_get_customization_string): Don't use value of strcpy.
Richard M. Stallman <rms@gnu.org>
parents: 4366
diff changeset
131 {
0fd9dd894f9f (x_get_customization_string): Don't use value of strcpy.
Richard M. Stallman <rms@gnu.org>
parents: 4366
diff changeset
132 char *copy = (char *) malloc (strlen (result) + 1);
0fd9dd894f9f (x_get_customization_string): Don't use value of strcpy.
Richard M. Stallman <rms@gnu.org>
parents: 4366
diff changeset
133 strcpy (copy, result);
0fd9dd894f9f (x_get_customization_string): Don't use value of strcpy.
Richard M. Stallman <rms@gnu.org>
parents: 4366
diff changeset
134 return copy;
0fd9dd894f9f (x_get_customization_string): Don't use value of strcpy.
Richard M. Stallman <rms@gnu.org>
parents: 4366
diff changeset
135 }
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
136 else
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
137 return 0;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
138 }
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
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
141 /* 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
142 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
143
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
144 %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
145 %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
146 context)
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
147 %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
148 %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
149 (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
150 %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
151 (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
152 we're really supposed to do, dandy.)
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
153 %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
154 (This never gets used.)
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
155 %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
156 (This never gets used either.)
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
157 %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
158 database associated with display.
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
159 (This is x_customization_string.)
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 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
162 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
163 otherwise provided by X.
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
164
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
165 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
166 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
167 alone.
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
168
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
169 Return NULL otherwise. */
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
170
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
171 static char *
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
172 magic_file_p (string, string_len, class, escaped_suffix, suffix)
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
173 char *string;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
174 int string_len;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
175 char *class, *escaped_suffix, *suffix;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
176 {
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
177 char *lang = getenv ("LANG");
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
178
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
179 int path_size = 100;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
180 char *path = (char *) malloc (path_size);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
181 int path_len = 0;
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 char *p = string;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
184
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
185 while (p < string + string_len)
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
186 {
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
187 /* The chunk we're about to stick on the end of result. */
31829
43566b0aec59 Avoid some more compiler warnings.
Gerd Moellmann <gerd@gnu.org>
parents: 29865
diff changeset
188 char *next = NULL;
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
189 int next_len;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
190
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
191 if (*p == '%')
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
192 {
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
193 p++;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
194
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
195 if (p >= string + string_len)
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
196 next_len = 0;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
197 else
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
198 switch (*p)
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
199 {
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
200 case '%':
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
201 next = "%";
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
202 next_len = 1;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
203 break;
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 case 'C':
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
206 next = (x_customization_string
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
207 ? x_customization_string
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 next_len = strlen (next);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
210 break;
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 case 'N':
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
213 next = class;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
214 next_len = strlen (class);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
215 break;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
216
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
217 case 'T':
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
218 next = "app-defaults";
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
219 next_len = strlen (next);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
220 break;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
221
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
222 default:
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
223 case 'S':
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
224 next_len = 0;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
225 break;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
226
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
227 case 'L':
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
228 case 'l':
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
229 if (! lang)
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 free (path);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
232 return NULL;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
233 }
29803
3dec4cd5e361 Don't declare xmalloc, xrealloc.
Sam Steingold <sds@gnu.org>
parents: 29756
diff changeset
234
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
235 next = lang;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
236 next_len = strlen (next);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
237 break;
29803
3dec4cd5e361 Don't declare xmalloc, xrealloc.
Sam Steingold <sds@gnu.org>
parents: 29756
diff changeset
238
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
239 case 't':
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
240 case 'c':
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
241 free (path);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
242 return NULL;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
243 }
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 else
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
246 next = p, next_len = 1;
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 /* 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
249 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
250 {
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
251 path_size = (path_len + next_len + 1) * 2;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
252 path = (char *) realloc (path, path_size);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
253 }
29803
3dec4cd5e361 Don't declare xmalloc, xrealloc.
Sam Steingold <sds@gnu.org>
parents: 29756
diff changeset
254
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
255 bcopy (next, path + path_len, next_len);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
256 path_len += next_len;
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 p++;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
259
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
260 /* 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
261 if (p >= string + string_len && escaped_suffix)
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
262 {
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
263 string = escaped_suffix;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
264 string_len = strlen (string);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
265 p = string;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
266 escaped_suffix = NULL;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
267 }
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
268 }
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
269
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
270 /* Perhaps we should add the SUFFIX now. */
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
271 if (suffix)
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
272 {
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
273 int suffix_len = strlen (suffix);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
274
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
275 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
276 {
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
277 path_size = (path_len + suffix_len + 1);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
278 path = (char *) realloc (path, path_size);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
279 }
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
280
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
281 bcopy (suffix, path + path_len, suffix_len);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
282 path_len += suffix_len;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
283 }
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
284
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
285 path[path_len] = '\0';
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
286
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
287 if (! file_p (path))
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
288 {
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
289 free (path);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
290 return NULL;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
291 }
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
292
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
293 return path;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
294 }
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
295
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
296
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
297 static char *
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
298 gethomedir ()
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
299 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
300 struct passwd *pw;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
301 char *ptr;
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
302 char *copy;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
303
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
304 if ((ptr = getenv ("HOME")) == NULL)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
305 {
5917
91caeed50c64 (gethomedir): Look at LOGNAME before USER.
Karl Heuer <kwzh@gnu.org>
parents: 5735
diff changeset
306 if ((ptr = getenv ("LOGNAME")) != NULL
91caeed50c64 (gethomedir): Look at LOGNAME before USER.
Karl Heuer <kwzh@gnu.org>
parents: 5735
diff changeset
307 || (ptr = getenv ("USER")) != NULL)
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
308 pw = getpwnam (ptr);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
309 else
5917
91caeed50c64 (gethomedir): Look at LOGNAME before USER.
Karl Heuer <kwzh@gnu.org>
parents: 5735
diff changeset
310 pw = getpwuid (getuid ());
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
311
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
312 if (pw)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
313 ptr = pw->pw_dir;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
314 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
315
29803
3dec4cd5e361 Don't declare xmalloc, xrealloc.
Sam Steingold <sds@gnu.org>
parents: 29756
diff changeset
316 if (ptr == NULL)
69913
eddb3cab7138 (gethomedir): Use xstrdup.
Romain Francoise <romain@orebokech.com>
parents: 69911
diff changeset
317 return xstrdup ("/");
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
318
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
319 copy = (char *) malloc (strlen (ptr) + 2);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
320 strcpy (copy, ptr);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
321 strcat (copy, "/");
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
322
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
323 return copy;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
324 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
325
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
326
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
327 static int
43672
e26d9755d4e8 (file_p): Rename arg `path' to `filename'.
Richard M. Stallman <rms@gnu.org>
parents: 38840
diff changeset
328 file_p (filename)
e26d9755d4e8 (file_p): Rename arg `path' to `filename'.
Richard M. Stallman <rms@gnu.org>
parents: 38840
diff changeset
329 char *filename;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
330 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
331 struct stat status;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
332
43672
e26d9755d4e8 (file_p): Rename arg `path' to `filename'.
Richard M. Stallman <rms@gnu.org>
parents: 38840
diff changeset
333 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
334 && 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
335 && (S_ISDIR (status.st_mode)) == 0); /* not a directory */
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
336 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
337
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
338
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
339 /* 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
340 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
341 the path name of the one we found otherwise. */
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
342
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
343 static char *
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
344 search_magic_path (search_path, class, escaped_suffix, suffix)
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
345 char *search_path, *class, *escaped_suffix, *suffix;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
346 {
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
347 register char *s, *p;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
348
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
349 for (s = search_path; *s; s = p)
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
350 {
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
351 for (p = s; *p && *p != ':'; p++)
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
352 ;
29803
3dec4cd5e361 Don't declare xmalloc, xrealloc.
Sam Steingold <sds@gnu.org>
parents: 29756
diff changeset
353
5650
1476768ef7fc (S_ISDIR): Define if not defined.
Richard M. Stallman <rms@gnu.org>
parents: 5116
diff changeset
354 if (p > s)
1476768ef7fc (S_ISDIR): Define if not defined.
Richard M. Stallman <rms@gnu.org>
parents: 5116
diff changeset
355 {
1476768ef7fc (S_ISDIR): Define if not defined.
Richard M. Stallman <rms@gnu.org>
parents: 5116
diff changeset
356 char *path = magic_file_p (s, p - s, class, escaped_suffix, suffix);
1476768ef7fc (S_ISDIR): Define if not defined.
Richard M. Stallman <rms@gnu.org>
parents: 5116
diff changeset
357 if (path)
1476768ef7fc (S_ISDIR): Define if not defined.
Richard M. Stallman <rms@gnu.org>
parents: 5116
diff changeset
358 return path;
1476768ef7fc (S_ISDIR): Define if not defined.
Richard M. Stallman <rms@gnu.org>
parents: 5116
diff changeset
359 }
1476768ef7fc (S_ISDIR): Define if not defined.
Richard M. Stallman <rms@gnu.org>
parents: 5116
diff changeset
360 else if (*p == ':')
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
361 {
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
362 char *path;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
363
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
364 s = "%N%S";
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
365 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
366 if (path)
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
367 return path;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
368 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
369
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
370 if (*p == ':')
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
371 p++;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
372 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
373
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
374 return 0;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
375 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
376
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
377 /* Producing databases for individual sources. */
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
378
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
379 static XrmDatabase
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
380 get_system_app (class)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
381 char *class;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
382 {
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
383 XrmDatabase db = NULL;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
384 char *path;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
385
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
386 path = getenv ("XFILESEARCHPATH");
19388
0f27d1477c21 (get_system_app): Use PATH_X_DEFAULTS.
Richard M. Stallman <rms@gnu.org>
parents: 19318
diff changeset
387 if (! path) path = PATH_X_DEFAULTS;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
388
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
389 path = search_magic_path (path, class, 0, 0);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
390 if (path)
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
391 {
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
392 db = XrmGetFileDatabase (path);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
393 free (path);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
394 }
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
395
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
396 return db;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
397 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
398
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
399
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
400 static XrmDatabase
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
401 get_fallback (display)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
402 Display *display;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
403 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
404 return NULL;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
405 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
406
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
407
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
408 static XrmDatabase
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
409 get_user_app (class)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
410 char *class;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
411 {
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
412 char *path;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
413 char *file = 0;
17572
73d867b4a654 (get_user_app): Free the gethomedir value.
Richard M. Stallman <rms@gnu.org>
parents: 14186
diff changeset
414 char *free_it = 0;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
415
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
416 /* 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
417 names, not directories. */
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
418 if (((path = getenv ("XUSERFILESEARCHPATH"))
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
419 && (file = search_magic_path (path, class, 0, 0)))
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 /* 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
422 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
423 || ((path = getenv ("XAPPLRESDIR"))
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
424 && ((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
425 || (file = search_magic_path (path, class, "/%N", 0))))
29803
3dec4cd5e361 Don't declare xmalloc, xrealloc.
Sam Steingold <sds@gnu.org>
parents: 29756
diff changeset
426
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
427 /* 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
428 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
429 || (free_it = gethomedir (),
73d867b4a654 (get_user_app): Free the gethomedir value.
Richard M. Stallman <rms@gnu.org>
parents: 14186
diff changeset
430 ((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
431 || (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
432 {
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
433 XrmDatabase db = XrmGetFileDatabase (file);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
434 free (file);
95479
9588c3703f38 remove useless if-before-free tests
Jim Meyering <jim@meyering.net>
parents: 94963
diff changeset
435 free (free_it);
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
436 return db;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
437 }
17572
73d867b4a654 (get_user_app): Free the gethomedir value.
Richard M. Stallman <rms@gnu.org>
parents: 14186
diff changeset
438
95479
9588c3703f38 remove useless if-before-free tests
Jim Meyering <jim@meyering.net>
parents: 94963
diff changeset
439 free (free_it);
17572
73d867b4a654 (get_user_app): Free the gethomedir value.
Richard M. Stallman <rms@gnu.org>
parents: 14186
diff changeset
440 return NULL;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
441 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
442
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
443
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
444 static XrmDatabase
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
445 get_user_db (display)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
446 Display *display;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
447 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
448 XrmDatabase db;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
449 char *xdefs;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
450
2126
616aeb5c1432 * xrdb.c (get_user_db): Since xrdb.c doesn't #include xterm.h,
Jim Blandy <jimb@redhat.com>
parents: 1934
diff changeset
451 #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
452 xdefs = XResourceManagerString (display);
777ed2b92359 * xrdb.c (get_user_db): Use XResourceManagerString when available
Jim Blandy <jimb@redhat.com>
parents: 1019
diff changeset
453 #else
1019
aaa628aaf808 * xrdb.c [USG5]: Define SYSV, and then include <unistd.h>. I
Jim Blandy <jimb@redhat.com>
parents: 620
diff changeset
454 xdefs = display->xdefaults;
1051
777ed2b92359 * xrdb.c (get_user_db): Use XResourceManagerString when available
Jim Blandy <jimb@redhat.com>
parents: 1019
diff changeset
455 #endif
777ed2b92359 * xrdb.c (get_user_db): Use XResourceManagerString when available
Jim Blandy <jimb@redhat.com>
parents: 1019
diff changeset
456
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
457 if (xdefs != NULL)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
458 db = XrmGetStringDatabase (xdefs);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
459 else
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
460 {
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
461 char *home;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
462 char *xdefault;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
463
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
464 home = gethomedir ();
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
465 xdefault = (char *) malloc (strlen (home) + sizeof (".Xdefaults"));
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
466 strcpy (xdefault, home);
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
467 strcat (xdefault, ".Xdefaults");
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
468 db = XrmGetFileDatabase (xdefault);
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
469 free (home);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
470 free (xdefault);
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
471 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
472
4366
04bd0c1a6245 * config.h.in (HAVE_XSCREENRESOURCESTRING): New #undef for
Jim Blandy <jimb@redhat.com>
parents: 4233
diff changeset
473 #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
474 /* 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
475 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
476 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
477 {
e67c6c10dd7c * xrdb.c (get_user_db): Remember to free the screen-local resource
Jim Blandy <jimb@redhat.com>
parents: 3654
diff changeset
478 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
479 XFree (xdefs);
e67c6c10dd7c * xrdb.c (get_user_db): Remember to free the screen-local resource
Jim Blandy <jimb@redhat.com>
parents: 3654
diff changeset
480 }
3654
d9313b9a63ad * xrdb.c (get_user_db): Get the screen-specific database too.
Jim Blandy <jimb@redhat.com>
parents: 3371
diff changeset
481 #endif
d9313b9a63ad * xrdb.c (get_user_db): Get the screen-specific database too.
Jim Blandy <jimb@redhat.com>
parents: 3371
diff changeset
482
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
483 return db;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
484 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
485
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
486 static XrmDatabase
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
487 get_environ_db ()
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
488 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
489 XrmDatabase db;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
490 char *p;
5735
87611653922f (x_get_customization_string): Use get_system_name instead of gethostname.
Karl Heuer <kwzh@gnu.org>
parents: 5650
diff changeset
491 char *path = 0, *home = 0, *host;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
492
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
493 if ((p = getenv ("XENVIRONMENT")) == NULL)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
494 {
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
495 home = gethomedir ();
5735
87611653922f (x_get_customization_string): Use get_system_name instead of gethostname.
Karl Heuer <kwzh@gnu.org>
parents: 5650
diff changeset
496 host = get_system_name ();
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
497 path = (char *) malloc (strlen (home)
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
498 + sizeof (".Xdefaults-")
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
499 + strlen (host));
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
500 sprintf (path, "%s%s%s", home, ".Xdefaults-", host);
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
501 p = path;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
502 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
503
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
504 db = XrmGetFileDatabase (p);
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
505
95479
9588c3703f38 remove useless if-before-free tests
Jim Meyering <jim@meyering.net>
parents: 94963
diff changeset
506 free (path);
9588c3703f38 remove useless if-before-free tests
Jim Meyering <jim@meyering.net>
parents: 94963
diff changeset
507 free (home);
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
508
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
509 return db;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
510 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
511
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
512 /* External interface. */
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
513
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
514 /* Types of values that we can find in a database */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
515
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
516 #define XrmStringType "String" /* String representation */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
517 XrmRepresentation x_rm_string; /* Quark representation */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
518
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
519 /* Load X resources based on the display and a possible -xrm option. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
520
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
521 XrmDatabase
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
522 x_load_resources (display, xrm_string, myname, myclass)
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
523 Display *display;
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
524 char *xrm_string, *myname, *myclass;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
525 {
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
526 XrmDatabase user_database;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
527 XrmDatabase rdb;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
528 XrmDatabase db;
24992
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
529 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
530
24992
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
531 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
532
25749
275227ca3c0c (get_fallback): Remove unused variable.
Gerd Moellmann <gerd@gnu.org>
parents: 24992
diff changeset
533 #ifdef USE_MOTIF
24992
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
534 char *courier = "-*-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-1";
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
535 extern Lisp_Object Vdouble_click_time;
25749
275227ca3c0c (get_fallback): Remove unused variable.
Gerd Moellmann <gerd@gnu.org>
parents: 24992
diff changeset
536 #endif
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
537
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
538 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
539 #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
540 /* 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
541 I suspect it's because the toolkit version does this elsewhere. */
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
542 XrmInitialize ();
7342
4cf4669565af (x_load_resources) [USE_X_TOOLKIT]: Don't call XrmInitialize.
Richard M. Stallman <rms@gnu.org>
parents: 7307
diff changeset
543 #endif
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
544 rdb = XrmGetStringDatabase ("");
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
545
24992
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
546 /* 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
547 will use some other default font. */
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
548 #ifdef USE_MOTIF
29803
3dec4cd5e361 Don't declare xmalloc, xrealloc.
Sam Steingold <sds@gnu.org>
parents: 29756
diff changeset
549
33084
31fae82503f7 (x_load_resources): Use the class name in the defaults.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31829
diff changeset
550 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
551 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
552 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
553 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
554 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
555 XrmPutLineResource (&rdb, line);
36739
483ab551a108 (x_load_resources) [USE_MOTIF]: Remove extraneous arg
Gerd Moellmann <gerd@gnu.org>
parents: 33084
diff changeset
556 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
557 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
558 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
559 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
560 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
561 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
562 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
563 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
564 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
565 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
566 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
567 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
568 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
569 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
570 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
571 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
572 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
573 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
574 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
575 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
576 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
577 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
578 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
579 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
580 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
581 XrmPutLineResource (&rdb, line);
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
582
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
583 /* 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
584 dialog from `double-click-time'. */
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
585 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
586 {
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
587 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
588 myclass, XFASTINT (Vdouble_click_time));
24992
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
589 XrmPutLineResource (&rdb, line);
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
590 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
591 myclass, XFASTINT (Vdouble_click_time));
24992
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
592 XrmPutLineResource (&rdb, line);
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
593 }
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
594
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
595 #else /* not USE_MOTIF */
29803
3dec4cd5e361 Don't declare xmalloc, xrealloc.
Sam Steingold <sds@gnu.org>
parents: 29756
diff changeset
596
29755
ab23e43de97d (x_load_resources): Set default resources for resource
Dave Love <fx@gnu.org>
parents: 25749
diff changeset
597 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
598 XrmPutLineResource (&rdb, line);
29755
ab23e43de97d (x_load_resources): Set default resources for resource
Dave Love <fx@gnu.org>
parents: 25749
diff changeset
599 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
600 XrmPutLineResource (&rdb, line);
29755
ab23e43de97d (x_load_resources): Set default resources for resource
Dave Love <fx@gnu.org>
parents: 25749
diff changeset
601 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
602 XrmPutLineResource (&rdb, line);
29755
ab23e43de97d (x_load_resources): Set default resources for resource
Dave Love <fx@gnu.org>
parents: 25749
diff changeset
603 sprintf (line, "*XlwMenu*background: grey75");
24992
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
604 XrmPutLineResource (&rdb, line);
29755
ab23e43de97d (x_load_resources): Set default resources for resource
Dave Love <fx@gnu.org>
parents: 25749
diff changeset
605 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
606 XrmPutLineResource (&rdb, line);
29803
3dec4cd5e361 Don't declare xmalloc, xrealloc.
Sam Steingold <sds@gnu.org>
parents: 29756
diff changeset
607
24992
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
608 #endif /* not USE_MOTIF */
f1632be03391 (x_load_resources): Set double-click time defaults
Gerd Moellmann <gerd@gnu.org>
parents: 24412
diff changeset
609
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
610 user_database = get_user_db (display);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
611
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
612 /* 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
613 to decode paths. */
95479
9588c3703f38 remove useless if-before-free tests
Jim Meyering <jim@meyering.net>
parents: 94963
diff changeset
614 free (x_customization_string);
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
615 x_customization_string
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
616 = 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
617
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
618 /* Get application system defaults */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
619 db = get_system_app (myclass);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
620 if (db != NULL)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
621 XrmMergeDatabases (db, &rdb);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
622
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
623 /* Get Fallback resources */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
624 db = get_fallback (display);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
625 if (db != NULL)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
626 XrmMergeDatabases (db, &rdb);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
627
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
628 /* Get application user defaults */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
629 db = get_user_app (myclass);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
630 if (db != NULL)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
631 XrmMergeDatabases (db, &rdb);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
632
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
633 /* get User defaults */
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
634 if (user_database != NULL)
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
635 XrmMergeDatabases (user_database, &rdb);
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
636
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
637 /* Get Environment defaults. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
638 db = get_environ_db ();
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
639 if (db != NULL)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
640 XrmMergeDatabases (db, &rdb);
29803
3dec4cd5e361 Don't declare xmalloc, xrealloc.
Sam Steingold <sds@gnu.org>
parents: 29756
diff changeset
641
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
642 /* Last, merge in any specification from the command line. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
643 if (xrm_string != NULL)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
644 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
645 db = XrmGetStringDatabase (xrm_string);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
646 if (db != NULL)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
647 XrmMergeDatabases (db, &rdb);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
648 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
649
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
650 return rdb;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
651 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
652
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
653
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
654 /* Retrieve the value of the resource specified by NAME with class CLASS
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
655 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
656
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
657 int
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
658 x_get_resource (rdb, name, class, expected_type, ret_value)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
659 XrmDatabase rdb;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
660 char *name, *class;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
661 XrmRepresentation expected_type;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
662 XrmValue *ret_value;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
663 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
664 XrmValue value;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
665 XrmName namelist[100];
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
666 XrmClass classlist[100];
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
667 XrmRepresentation type;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
668
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
669 XrmStringToNameList(name, namelist);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
670 XrmStringToClassList(class, classlist);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
671
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
672 if (XrmQGetResource (rdb, namelist, classlist, &type, &value) == True
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
673 && (type == expected_type))
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
674 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
675 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
676 ret_value->addr = (char *) value.addr;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
677 else
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
678 bcopy (value.addr, ret_value->addr, ret_value->size);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
679
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
680 return value.size;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
681 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
682
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
683 return 0;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
684 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
685
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
686 /* Retrieve the string resource specified by NAME with CLASS from
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
687 database RDB. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
688
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
689 char *
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
690 x_get_string_resource (rdb, name, class)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
691 XrmDatabase rdb;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
692 char *name, *class;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
693 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
694 XrmValue value;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
695
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
696 if (x_get_resource (rdb, name, class, x_rm_string, &value))
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
697 return (char *) value.addr;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
698
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
699 return (char *) 0;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
700 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
701
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
702 /* Stand-alone test facilities. */
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
703
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
704 #ifdef TESTRM
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
705
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
706 typedef char **List;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
707 #define arg_listify(len, list) (list)
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
708 #define car(list) (*(list))
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
709 #define cdr(list) (list + 1)
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
710 #define NIL(list) (! *(list))
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
711 #define free_arglist(list)
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
712
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
713 static List
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
714 member (elt, list)
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
715 char *elt;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
716 List list;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
717 {
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
718 List p;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
719
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
720 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
721 if (! strcmp (elt, car (p)))
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
722 return p;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
723
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
724 return p;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
725 }
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
726
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
727 static void
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
728 fatal (msg, prog, x1, x2, x3, x4, x5)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
729 char *msg, *prog;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
730 int x1, x2, x3, x4, x5;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
731 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
732 extern int errno;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
733
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
734 if (errno)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
735 perror (prog);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
736
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
737 (void) fprintf (stderr, msg, prog, x1, x2, x3, x4, x5);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
738 exit (1);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
739 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
740
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
741 main (argc, argv)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
742 int argc;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
743 char **argv;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
744 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
745 Display *display;
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
746 char *displayname, *resource_string, *class, *name;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
747 XrmDatabase xdb;
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
748 List arg_list, lp;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
749
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
750 arg_list = arg_listify (argc, argv);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
751
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
752 lp = member ("-d", arg_list);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
753 if (!NIL (lp))
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
754 displayname = car (cdr (lp));
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
755 else
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
756 displayname = "localhost:0.0";
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
757
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
758 lp = member ("-xrm", arg_list);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
759 if (! NIL (lp))
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
760 resource_string = car (cdr (lp));
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 resource_string = (char *) 0;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
763
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
764 lp = member ("-c", arg_list);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
765 if (! NIL (lp))
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
766 class = car (cdr (lp));
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
767 else
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
768 class = "Emacs";
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
769
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
770 lp = member ("-n", arg_list);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
771 if (! NIL (lp))
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
772 name = car (cdr (lp));
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
773 else
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
774 name = "emacs";
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
775
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
776 free_arglist (arg_list);
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
777
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
778 if (!(display = XOpenDisplay (displayname)))
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
779 fatal ("Can't open display '%s'\n", XDisplayName (displayname));
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
780
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
781 xdb = x_load_resources (display, resource_string, name, class);
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
782
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
783 /* In a real program, you'd want to also do this: */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
784 display->db = xdb;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
785
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
786 while (1)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
787 {
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
788 char query_name[90];
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
789 char query_class[90];
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
790
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
791 printf ("Name: ");
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
792 gets (query_name);
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
793
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
794 if (strlen (query_name))
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
795 {
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
796 char *value;
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
797
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
798 printf ("Class: ");
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
799 gets (query_class);
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
800
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
801 value = x_get_string_resource (xdb, query_name, query_class);
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
802
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
803 if (value != NULL)
4232
f533d585cfc8 Implement search for app-defaults directory and
Jim Blandy <jimb@redhat.com>
parents: 3873
diff changeset
804 printf ("\t%s(%s): %s\n\n", query_name, query_class, value);
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
805 else
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
806 printf ("\tNo Value.\n\n");
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
807 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
808 else
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
809 break;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
810 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
811 printf ("\tExit.\n\n");
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
812
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
813 XCloseDisplay (display);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
814 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
815 #endif /* TESTRM */
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 43672
diff changeset
816
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 43672
diff changeset
817 /* arch-tag: 37e6fbab-ed05-4363-9e76-6c4109ed511f
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 43672
diff changeset
818 (do not change this comment) */