annotate src/xrdb.c @ 4062:d7f5f18ddbc5

(ispell-menu-map): New keymap--both fn and var.
author Richard M. Stallman <rms@gnu.org>
date Mon, 12 Jul 1993 20:31:52 +0000
parents e67c6c10dd7c
children f533d585cfc8
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.
2961
e94a593c3952 Updated copyright years.
Jim Blandy <jimb@redhat.com>
parents: 2126
diff changeset
2 Copyright (C) 1990, 1993 Free Software Foundation.
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4 This program is free software; you can redistribute it and/or modify
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5 it under the terms of the GNU General Public License as published by
620
88a29c720fa7 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 556
diff changeset
6 the Free Software Foundation; either version 2, or (at your option)
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
7 any later version.
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
8
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
9 This program is distributed in the hope that it will be useful,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
12 GNU General Public License for more details.
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
13
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
14 You should have received a copy of the GNU General Public License
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
15 along with this program; see the file COPYING. If not, write to
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
16 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
17
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
18 /* Written by jla, 4/90 */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
19
1019
aaa628aaf808 * xrdb.c [USG5]: Define SYSV, and then include <unistd.h>. I
Jim Blandy <jimb@redhat.com>
parents: 620
diff changeset
20 #ifdef emacs
aaa628aaf808 * xrdb.c [USG5]: Define SYSV, and then include <unistd.h>. I
Jim Blandy <jimb@redhat.com>
parents: 620
diff changeset
21 #include "config.h"
aaa628aaf808 * xrdb.c [USG5]: Define SYSV, and then include <unistd.h>. I
Jim Blandy <jimb@redhat.com>
parents: 620
diff changeset
22 #endif
aaa628aaf808 * xrdb.c [USG5]: Define SYSV, and then include <unistd.h>. I
Jim Blandy <jimb@redhat.com>
parents: 620
diff changeset
23
aaa628aaf808 * xrdb.c [USG5]: Define SYSV, and then include <unistd.h>. I
Jim Blandy <jimb@redhat.com>
parents: 620
diff changeset
24 #if 1 /* I'd really appreciate it if this code could go away... -JimB */
aaa628aaf808 * xrdb.c [USG5]: Define SYSV, and then include <unistd.h>. I
Jim Blandy <jimb@redhat.com>
parents: 620
diff changeset
25 /* this avoids lossage in the `dual-universe' headers on AT&T SysV X11 */
aaa628aaf808 * xrdb.c [USG5]: Define SYSV, and then include <unistd.h>. I
Jim Blandy <jimb@redhat.com>
parents: 620
diff changeset
26 #ifdef USG5
aaa628aaf808 * xrdb.c [USG5]: Define SYSV, and then include <unistd.h>. I
Jim Blandy <jimb@redhat.com>
parents: 620
diff changeset
27 #define SYSV
aaa628aaf808 * xrdb.c [USG5]: Define SYSV, and then include <unistd.h>. I
Jim Blandy <jimb@redhat.com>
parents: 620
diff changeset
28 #include <unistd.h>
aaa628aaf808 * xrdb.c [USG5]: Define SYSV, and then include <unistd.h>. I
Jim Blandy <jimb@redhat.com>
parents: 620
diff changeset
29 #endif /* USG5 */
aaa628aaf808 * xrdb.c [USG5]: Define SYSV, and then include <unistd.h>. I
Jim Blandy <jimb@redhat.com>
parents: 620
diff changeset
30
aaa628aaf808 * xrdb.c [USG5]: Define SYSV, and then include <unistd.h>. I
Jim Blandy <jimb@redhat.com>
parents: 620
diff changeset
31 #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
32
517c3893ec5b * xterm.c, xrdb.c: #include <stdio.h> before "xterm.h", to avoid
Jim Blandy <jimb@redhat.com>
parents: 1200
diff changeset
33 /* This should be included before the X include files; otherwise, we get
517c3893ec5b * xterm.c, xrdb.c: #include <stdio.h> before "xterm.h", to avoid
Jim Blandy <jimb@redhat.com>
parents: 1200
diff changeset
34 warnings about redefining NULL under BSD 4.3. */
517c3893ec5b * xterm.c, xrdb.c: #include <stdio.h> before "xterm.h", to avoid
Jim Blandy <jimb@redhat.com>
parents: 1200
diff changeset
35 #include <sys/param.h>
517c3893ec5b * xterm.c, xrdb.c: #include <stdio.h> before "xterm.h", to avoid
Jim Blandy <jimb@redhat.com>
parents: 1200
diff changeset
36
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
37 #include <X11/Xlib.h>
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
38 #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
39 #if 0
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
40 #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
41 #endif
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
42 #include <X11/X.h>
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
43 #include <X11/Xutil.h>
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
44 #include <X11/Xresource.h>
556
af0eae450bc9 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 485
diff changeset
45 #ifdef VMS
af0eae450bc9 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 485
diff changeset
46 #include "vms-pwd.h"
af0eae450bc9 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 485
diff changeset
47 #else
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
48 #include <pwd.h>
556
af0eae450bc9 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 485
diff changeset
49 #endif
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
50 #include <sys/stat.h>
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
51
1019
aaa628aaf808 * xrdb.c [USG5]: Define SYSV, and then include <unistd.h>. I
Jim Blandy <jimb@redhat.com>
parents: 620
diff changeset
52 #ifndef MAXPATHLEN
aaa628aaf808 * xrdb.c [USG5]: Define SYSV, and then include <unistd.h>. I
Jim Blandy <jimb@redhat.com>
parents: 620
diff changeset
53 #define MAXPATHLEN 256
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
54 #endif
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
55
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
56 extern char *getenv ();
1934
458a1fceb462 * xrdb.c (getuid): Remove declaration.
Jim Blandy <jimb@redhat.com>
parents: 1389
diff changeset
57
458a1fceb462 * xrdb.c (getuid): Remove declaration.
Jim Blandy <jimb@redhat.com>
parents: 1389
diff changeset
58 /* 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
59 face value. */
458a1fceb462 * xrdb.c (getuid): Remove declaration.
Jim Blandy <jimb@redhat.com>
parents: 1389
diff changeset
60 #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
61 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
62 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
63 default to `int' anyway. */
1934
458a1fceb462 * xrdb.c (getuid): Remove declaration.
Jim Blandy <jimb@redhat.com>
parents: 1389
diff changeset
64 #endif
458a1fceb462 * xrdb.c (getuid): Remove declaration.
Jim Blandy <jimb@redhat.com>
parents: 1389
diff changeset
65
3371
fe452e556782 [__bsdi__]: Alternate decls of getpwuid and getpwnam.
Richard M. Stallman <rms@gnu.org>
parents: 3142
diff changeset
66 #ifdef __bsdi__
fe452e556782 [__bsdi__]: Alternate decls of getpwuid and getpwnam.
Richard M. Stallman <rms@gnu.org>
parents: 3142
diff changeset
67 extern struct passwd *getpwuid (uid_t);
fe452e556782 [__bsdi__]: Alternate decls of getpwuid and getpwnam.
Richard M. Stallman <rms@gnu.org>
parents: 3142
diff changeset
68 extern struct passwd *getpwnam (const char *);
fe452e556782 [__bsdi__]: Alternate decls of getpwuid and getpwnam.
Richard M. Stallman <rms@gnu.org>
parents: 3142
diff changeset
69 #else
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
70 extern struct passwd *getpwuid ();
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
71 extern struct passwd *getpwnam ();
3371
fe452e556782 [__bsdi__]: Alternate decls of getpwuid and getpwnam.
Richard M. Stallman <rms@gnu.org>
parents: 3142
diff changeset
72 #endif
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
73
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
74 static char *
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
75 gethomedir (dirname)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
76 char *dirname;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
77 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
78 int uid;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
79 struct passwd *pw;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
80 char *ptr;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
81
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
82 if ((ptr = getenv ("HOME")) == NULL)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
83 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
84 if ((ptr = getenv ("USER")) != NULL)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
85 pw = getpwnam (ptr);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
86 else
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
87 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
88 uid = getuid ();
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
89 pw = getpwuid (uid);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
90 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
91 if (pw)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
92 ptr = pw->pw_dir;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
93 else
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
94 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
95 ptr = NULL;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
96 *dirname = '\0';
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
97 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
98 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
99
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
100 if (ptr != NULL)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
101 strcpy (dirname, ptr);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
102
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
103 dirname += strlen (dirname);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
104 *dirname = '/';
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
105 dirname++;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
106 *dirname = '\0';
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
107
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
108 return dirname;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
109 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
110
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
111 static int
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
112 file_p (path)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
113 char *path;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
114 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
115 struct stat status;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
116
1126
94d76dbb5ce6 * xrdb.c: Don't include <X11/Xos.h>. Under R4, it stupidly
Jim Blandy <jimb@redhat.com>
parents: 1051
diff changeset
117 return (access (path, 4) == 0 /* exists and is readable */
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
118 && stat (path, &status) == 0 /* get the status */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
119 && (status.st_mode & S_IFDIR) == 0); /* not a directory */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
120 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
121
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
122 #if 0
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
123 #define X_DEFAULT_SEARCH_PATH "/usr/lib/X11/"
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
124 #endif
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
125
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
126 /* Isn't this just disgusting? */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
127
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
128 #define X_DEFAULT_SEARCH_PATH "/usr/lib/X11/%L/%T/%N%S:/usr/lib/X11/%l/%T/%N%S:/usr/lib/X11/%T/%N%S"
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
129
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
130 static int
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
131 decode_magic (string, file, return_path)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
132 char *string, *file, *return_path;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
133 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
134 char *p = string;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
135 char *t = return_path;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
136
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
137 while (*p)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
138 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
139 if (*p == '%')
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
140 switch (*++p)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
141 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
142 case '%':
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
143 *t++ = '%';
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
144 p++;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
145 break;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
146
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
147 case 'N':
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
148 case 'T':
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
149 case 'S':
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
150 case 'L':
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
151 case 'l':
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
152 case 't':
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
153 case 'c':
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
154 default:
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
155 p++;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
156 if (*t == '/' && *p == '/')
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
157 p++;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
158 break;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
159 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
160 else
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
161 *t++ = *p++;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
162 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
163 *t = '\0';
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
164 strcat (return_path, file);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
165
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
166 if (file_p (return_path))
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
167 return 1;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
168
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
169 return_path[0] = '\0';
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
170 return 0;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
171 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
172
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
173 static int
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
174 magic_searchpath_decoder (incantation_string, file, return_path)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
175 char *incantation_string, *return_path, *file;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
176 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
177 register char *s = incantation_string;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
178 register char *p;
620
88a29c720fa7 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 556
diff changeset
179
88a29c720fa7 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 556
diff changeset
180 /* Must be big enough for "%N%S". */
88a29c720fa7 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 556
diff changeset
181 register int string_size = MAXPATHLEN;
88a29c720fa7 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 556
diff changeset
182 register char *string = (char *) alloca (string_size * sizeof (*string));
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
183
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
184 while (*s)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
185 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
186 p = s;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
187
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
188 while (*p && *p != ':')
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
189 p++;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
190
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
191 if (*p == ':' && *(p + 1) == ':')
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
192 {
620
88a29c720fa7 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 556
diff changeset
193 /* We know string is big enough for this. */
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
194 bcopy ("%N%S", string, 5);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
195 if (decode_magic (string, file, return_path))
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
196 return 1;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
197
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
198 s = p + 1;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
199 continue;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
200 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
201
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
202 if (p > s)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
203 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
204 int len = p - s;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
205
620
88a29c720fa7 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 556
diff changeset
206 if (string_size < len+1)
88a29c720fa7 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 556
diff changeset
207 {
88a29c720fa7 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 556
diff changeset
208 string_size = 2 * len;
88a29c720fa7 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 556
diff changeset
209 string = (char *) alloca (string_size * sizeof (*string));
88a29c720fa7 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 556
diff changeset
210 }
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
211 bcopy (s, string, len);
3142
3466d61e7b09 (magic_searchpath_decoder): Fix typos.
Richard M. Stallman <rms@gnu.org>
parents: 2961
diff changeset
212 string[len] = '\0';
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
213 if (decode_magic (string, file, return_path))
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
214 return 1;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
215 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
216
3142
3466d61e7b09 (magic_searchpath_decoder): Fix typos.
Richard M. Stallman <rms@gnu.org>
parents: 2961
diff changeset
217 if (p && *p != 0)
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
218 s = p + 1;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
219 else
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
220 return 0;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
221 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
222
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
223 return 0;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
224 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
225
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
226 static XrmDatabase
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
227 get_system_app (class)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
228 char *class;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
229 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
230 XrmDatabase db;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
231 char path[MAXPATHLEN];
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
232 char *p;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
233
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
234 if ((p = getenv ("XFILESEARCHPATH")) == NULL)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
235 p = X_DEFAULT_SEARCH_PATH;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
236
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
237 if (! magic_searchpath_decoder (p, class, path))
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
238 return NULL;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
239
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
240 db = XrmGetFileDatabase (path);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
241 return db;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
242 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
243
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
244 static XrmDatabase
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
245 get_fallback (display)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
246 Display *display;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
247 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
248 XrmDatabase db;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
249
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
250 return NULL;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
251 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
252
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
253 static XrmDatabase
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
254 get_user_app (class)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
255 char *class;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
256 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
257 XrmDatabase db;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
258 char *magic_path;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
259 char path[MAXPATHLEN];
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
260
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
261 if ((magic_path = getenv ("XUSERFILESEARCHPATH")) == NULL)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
262 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
263 char homedir[MAXPATHLEN];
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
264 char *default_magic;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
265 char *p;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
266
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
267 gethomedir (homedir);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
268
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
269 if ((p = getenv ("XAPPLRESDIR")) == NULL)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
270 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
271 default_magic = "%s/%%L/%%N:%s/%%l/%%N:%s/%%N";
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
272 magic_path = (char *) alloca ((3 * strlen (homedir))
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
273 + strlen (default_magic));
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
274 sprintf (magic_path, default_magic, homedir, homedir, homedir);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
275 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
276 else
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
277 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
278 default_magic = "%s/%%L/%%N:%s/%%l/%%N:%s/%%N:%s/%%N";
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
279 magic_path = (char *) alloca ((3 * strlen (p))
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
280 + strlen (default_magic)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
281 + strlen (homedir));
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
282 sprintf (magic_path, default_magic, p, p, p, homedir);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
283 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
284 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
285
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
286 if (! magic_searchpath_decoder (magic_path, class, path))
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
287 return NULL;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
288
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
289 db = XrmGetFileDatabase (path);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
290 return db;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
291 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
292
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
293 static XrmDatabase
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
294 get_user_db (display)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
295 Display *display;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
296 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
297 XrmDatabase db;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
298 char *xdefs;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
299
2126
616aeb5c1432 * xrdb.c (get_user_db): Since xrdb.c doesn't #include xterm.h,
Jim Blandy <jimb@redhat.com>
parents: 1934
diff changeset
300 #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
301 xdefs = XResourceManagerString (display);
777ed2b92359 * xrdb.c (get_user_db): Use XResourceManagerString when available
Jim Blandy <jimb@redhat.com>
parents: 1019
diff changeset
302 #else
1019
aaa628aaf808 * xrdb.c [USG5]: Define SYSV, and then include <unistd.h>. I
Jim Blandy <jimb@redhat.com>
parents: 620
diff changeset
303 xdefs = display->xdefaults;
1051
777ed2b92359 * xrdb.c (get_user_db): Use XResourceManagerString when available
Jim Blandy <jimb@redhat.com>
parents: 1019
diff changeset
304 #endif
777ed2b92359 * xrdb.c (get_user_db): Use XResourceManagerString when available
Jim Blandy <jimb@redhat.com>
parents: 1019
diff changeset
305
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
306 if (xdefs != NULL)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
307 db = XrmGetStringDatabase (xdefs);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
308 else
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
309 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
310 char xdefault[MAXPATHLEN];
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
311
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
312 gethomedir (xdefault);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
313 strcat (xdefault, ".Xdefaults");
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
314 db = XrmGetFileDatabase (xdefault);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
315 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
316
3654
d9313b9a63ad * xrdb.c (get_user_db): Get the screen-specific database too.
Jim Blandy <jimb@redhat.com>
parents: 3371
diff changeset
317 #ifdef XlibSpecificationRelease
d9313b9a63ad * xrdb.c (get_user_db): Get the screen-specific database too.
Jim Blandy <jimb@redhat.com>
parents: 3371
diff changeset
318 #if XlibSpecificationRelease >= 5
d9313b9a63ad * xrdb.c (get_user_db): Get the screen-specific database too.
Jim Blandy <jimb@redhat.com>
parents: 3371
diff changeset
319 /* 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
320 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
321 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
322 {
e67c6c10dd7c * xrdb.c (get_user_db): Remember to free the screen-local resource
Jim Blandy <jimb@redhat.com>
parents: 3654
diff changeset
323 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
324 XFree (xdefs);
e67c6c10dd7c * xrdb.c (get_user_db): Remember to free the screen-local resource
Jim Blandy <jimb@redhat.com>
parents: 3654
diff changeset
325 }
3654
d9313b9a63ad * xrdb.c (get_user_db): Get the screen-specific database too.
Jim Blandy <jimb@redhat.com>
parents: 3371
diff changeset
326 #endif
d9313b9a63ad * xrdb.c (get_user_db): Get the screen-specific database too.
Jim Blandy <jimb@redhat.com>
parents: 3371
diff changeset
327 #endif
d9313b9a63ad * xrdb.c (get_user_db): Get the screen-specific database too.
Jim Blandy <jimb@redhat.com>
parents: 3371
diff changeset
328
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
329 return db;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
330 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
331
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
332 static XrmDatabase
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
333 get_environ_db ()
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
334 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
335 XrmDatabase db;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
336 char *p;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
337 char path[MAXPATHLEN];
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
338
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
339 if ((p = getenv ("XENVIRONMENT")) == NULL)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
340 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
341 gethomedir (path);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
342 strcat (path, ".Xdefaults-");
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
343 gethostname (path + strlen (path), MAXPATHLEN - strlen (path));
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
344 p = path;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
345 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
346
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
347 db = XrmGetFileDatabase (p);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
348 return db;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
349 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
350
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
351 /* Types of values that we can find in a database */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
352
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
353 #define XrmStringType "String" /* String representation */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
354 XrmRepresentation x_rm_string; /* Quark representation */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
355
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
356 /* Load X resources based on the display and a possible -xrm option. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
357
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
358 XrmDatabase
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
359 x_load_resources (display, xrm_string, myclass)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
360 Display *display;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
361 char *xrm_string, *myclass;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
362 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
363 char *xdefs;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
364 XrmDatabase rdb;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
365 XrmDatabase db;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
366
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
367 x_rm_string = XrmStringToQuark (XrmStringType);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
368 XrmInitialize ();
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
369 rdb = XrmGetStringDatabase ("");
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
370
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
371 /* Get application system defaults */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
372 db = get_system_app (myclass);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
373 if (db != NULL)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
374 XrmMergeDatabases (db, &rdb);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
375
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
376 /* Get Fallback resources */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
377 db = get_fallback (display);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
378 if (db != NULL)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
379 XrmMergeDatabases (db, &rdb);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
380
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
381 /* Get application user defaults */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
382 db = get_user_app (myclass);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
383 if (db != NULL)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
384 XrmMergeDatabases (db, &rdb);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
385
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
386 /* get User defaults */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
387 db = get_user_db (display);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
388 if (db != NULL)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
389 XrmMergeDatabases (db, &rdb);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
390
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
391 /* Get Environment defaults. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
392 db = get_environ_db ();
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
393 if (db != NULL)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
394 XrmMergeDatabases (db, &rdb);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
395
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
396 /* Last, merge in any specification from the command line. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
397 if (xrm_string != NULL)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
398 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
399 db = XrmGetStringDatabase (xrm_string);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
400 if (db != NULL)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
401 XrmMergeDatabases (db, &rdb);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
402 }
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 rdb;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
405 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
406
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
407 /* Retrieve the value of the resource specified by NAME with class CLASS
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
408 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
409
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
410 int
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
411 x_get_resource (rdb, name, class, expected_type, ret_value)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
412 XrmDatabase rdb;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
413 char *name, *class;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
414 XrmRepresentation expected_type;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
415 XrmValue *ret_value;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
416 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
417 XrmValue value;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
418 XrmName namelist[100];
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
419 XrmClass classlist[100];
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
420 XrmRepresentation type;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
421
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
422 XrmStringToNameList(name, namelist);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
423 XrmStringToClassList(class, classlist);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
424
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
425 if (XrmQGetResource (rdb, namelist, classlist, &type, &value) == True
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
426 && (type == expected_type))
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
427 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
428 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
429 ret_value->addr = (char *) value.addr;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
430 else
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
431 bcopy (value.addr, ret_value->addr, ret_value->size);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
432
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
433 return value.size;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
434 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
435
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
436 return 0;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
437 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
438
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
439 /* Retrieve the string resource specified by NAME with CLASS from
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
440 database RDB. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
441
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
442 char *
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
443 x_get_string_resource (rdb, name, class)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
444 XrmDatabase rdb;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
445 char *name, *class;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
446 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
447 XrmValue value;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
448
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
449 if (x_get_resource (rdb, name, class, x_rm_string, &value))
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
450 return (char *) value.addr;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
451
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
452 return (char *) 0;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
453 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
454
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
455 #ifdef TESTRM
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
456 #include <stdio.h>
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
457 #include "arg-list.h"
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
458
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
459 static void
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
460 fatal (msg, prog, x1, x2, x3, x4, x5)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
461 char *msg, *prog;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
462 int x1, x2, x3, x4, x5;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
463 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
464 extern int errno;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
465
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
466 if (errno)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
467 perror (prog);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
468
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
469 (void) fprintf (stderr, msg, prog, x1, x2, x3, x4, x5);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
470 exit (1);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
471 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
472
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
473 main (argc, argv)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
474 int argc;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
475 char **argv;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
476 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
477 Display *display;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
478 char *displayname, *resource_string, *class;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
479 XrmDatabase xdb;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
480 List *arg_list, *lp;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
481
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
482 arg_list = arg_listify (argc, argv);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
483
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
484 lp = member ("-d", arg_list);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
485 if (!NIL (lp))
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
486 displayname = car (cdr (lp));
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
487 else
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
488 displayname = "localhost:0.0";
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
489
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
490 lp = member ("-xrm", arg_list);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
491 if (! NIL (lp))
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
492 resource_string = car (cdr (lp));
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
493 else
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
494 resource_string = (char *) 0;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
495
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
496 lp = member ("-c", arg_list);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
497 if (! NIL (lp))
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
498 class = car (cdr (lp));
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
499 else
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
500 class = "Emacs";
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
501
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
502 free_arglist (arg_list);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
503
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
504
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
505
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
506 if (!(display = XOpenDisplay (displayname)))
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
507 fatal ("Can't open display '%s'\n", XDisplayName (displayname));
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
508
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
509 xdb = x_load_resources (display, resource_string, class);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
510
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
511 #if 0
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
512 /* In a real program, you'd want to also do this: */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
513 display->db = xdb;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
514 #endif
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
515
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
516 while (1)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
517 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
518 char line[90];
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
519
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
520 printf ("String: ");
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
521 gets (line);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
522 if (strlen (line))
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
523 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
524 char *value = x_get_string_resource (xdb, line, class);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
525
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
526 if (value != NULL)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
527 printf ("\t%s: %s\n\n", line, value);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
528 else
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
529 printf ("\tNo Value.\n\n");
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
530 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
531 else
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
532 break;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
533 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
534 printf ("\tExit.\n\n");
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
535
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
536 XCloseDisplay (display);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
537 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
538 #endif /* TESTRM */