aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Janík2002-04-28 13:38:13 +0000
committerPavel Janík2002-04-28 13:38:13 +0000
commit2bad4ee209b4a7b1770f9777ef74b554a5f606bf (patch)
tree011b4e1828663e05ee899d28bbe68b94444eff84
parent9d5ebed11bf0de17bcf7441fa97297417dcb95f4 (diff)
downloademacs-2bad4ee209b4a7b1770f9777ef74b554a5f606bf.tar.gz
emacs-2bad4ee209b4a7b1770f9777ef74b554a5f606bf.zip
Remove unused file.
-rw-r--r--lwlib/ChangeLog3
-rw-r--r--lwlib/Imakefile244
-rw-r--r--lwlib/dispatch.c275
-rw-r--r--lwlib/dispatch.h2
-rw-r--r--lwlib/xrdb-cpp.c188
-rw-r--r--lwlib/xrdb.c74
6 files changed, 2 insertions, 784 deletions
diff --git a/lwlib/ChangeLog b/lwlib/ChangeLog
index 31805423a89..28626ddc255 100644
--- a/lwlib/ChangeLog
+++ b/lwlib/ChangeLog
@@ -4,7 +4,8 @@
4 (xrdb-cpp.o): Remove target. 4 (xrdb-cpp.o): Remove target.
5 Remove unused defines. 5 Remove unused defines.
6 6
7 * xrdb.c, xrdb-cpp.c, Imakefile: Remove unused file. 7 * xrdb.c, xrdb-cpp.c, Imakefile, dispatch.c, dispatch.h:
8 Remove unused file.
8 9
9 * lwlib.c (instantiate_widget_instance): Remove duplicated 10 * lwlib.c (instantiate_widget_instance): Remove duplicated
10 prototype. 11 prototype.
diff --git a/lwlib/Imakefile b/lwlib/Imakefile
deleted file mode 100644
index 86f2bc15f89..00000000000
--- a/lwlib/Imakefile
+++ /dev/null
@@ -1,244 +0,0 @@
1/**/# Imakefile file for liblw.a, Copyright (c) 1992-1993 Lucid, Inc.
2
3/*
4 * If you have Motif and want to provide support for Motif widgets in lwlib,
5 * then define USE_MOTIF.
6 *
7 * If you have OpenLook and want to provide support for OpenLook widgets in
8 * lwlib, then define USE_OLIT.
9 *
10 * Otherwise, define USE_LUCID to use Lucid's own Motif-lookalike widgets,
11 * which are included in this directory.
12 *
13 * You cannot define USE_MOTIF and USE_OLIT at the same time, but USE_LUCID
14 * may be defined along with either of the other two.
15 *
16 * The OLIT menubar is slow, and possibly buggy. We recommend against using
17 * it unless you'd like to try to improve it (which we encourage.)
18 *
19 * The Lucid menubar is much faster than the Motif menubar, but is missing
20 * a few features (most notably stay-up menus and keyboard traversal.) But
21 * since it has the Motif look-and-feel, we recommend using it even if you
22 * have Motif.
23 *
24 * Currently, only the Motif widgets provide support for dialog boxes. If
25 * you don't have Motif, you will not be able to pop up dialog boxes from
26 * emacs. If you define both USE_LUCID and USE_MOTIF, then the menus will
27 * be implemented with Lucid widgets, and the dialog boxes will be
28 * implemented with Motif widgets.
29 *
30 * It shouldn't take much work to add support for non-Motif dialog boxes;
31 * all that one need do is add code that implements Athena versions of the
32 * xm_create_dialog(), xm_update_one_widget(), and xm_update_one_value()
33 * routines in lwlib-Xm.c. If you do this, please send us the code.
34 *
35 * If you have your X11 source tree online, then you should define
36 * INCLUDE_EXTENSIONS to cause this library to contain some useful functions
37 * which Xt should provide but doesn't. You can only do this if you have
38 * the source tree online, because these functions require access to internal
39 * Xt data structures that are not defined in the exported header files.
40 * If you define INCLUDE_EXTENSIONS, then the variable $TOP must point at the
41 * root of the X11 source tree.
42 *
43 * To build a "shared" version of lwlib as well, define BUILD_SHARED_LIB.
44 * If INCLUDE_EXTENSIONS is defined, and you want to link with a dynamic
45 * version of Xt, it may be necessary to build a shared version of lwlib as
46 * well, as the X libraries sometimes put *different code* in the dynamic
47 * and shared versions of their libraries, for some reason I don't understand.
48 *
49 * Remember, if you build and install a shared version of lwlib, you may need
50 * to run ldconfig(8) before anything will realize that it exists.
51 *
52 * To compile with support for Lucid's Energize Programming System, you must
53 * define all of ENERGIZE, USE_LUCID, USE_MOTIF, and INCLUDE_EXTENSIONS.
54 */
55
56#define USE_LUCID
57/* #define USE_MOTIF */
58/* #define USE_OLIT */
59/* #define BUILD_SHARED_LIB */
60/* #define ENERGIZE */
61
62/* #define INCLUDE_EXTENSIONS */
63
64
65#ifdef INCLUDE_EXTENSIONS /* this is where it is at our site */
66 TOP = /$(WHICH_X)/mit
67#endif
68
69/*
70 *
71 * You shouldn't need to edit anything below this point.
72 *
73 */
74
75#ifdef ENERGIZE
76# if !defined(USE_LUCID) || !defined(USE_MOTIF) || !defined(INCLUDE_EXTENSIONS)
77ERROR! Energize requires Lucid widgets, Motif, and X Extensions.
78# endif
79#endif /* ENERGIZE */
80
81
82#ifdef BUILD_SHARED_LIB
83SOLWREV=1.0
84#endif
85
86#if (ProjectX == 4)
87 STD_DEFINES = LibraryDefines
88 CDEBUGFLAGS = LibraryCDebugFlags
89 EXT_DEFINES = -DTHIS_IS_X11R4
90 WHICH_X = x11r4
91#define SpecialLibObjectRule SpecialObjectRule
92#else /* !4 */
93#if (ProjectX == 5)
94#ifdef BUILD_SHARED_LIB
95# define DoSharedLib YES
96# define DoNormalLib YES
97#endif
98#include <Library.tmpl>
99 EXT_DEFINES = -DTHIS_IS_X11R5 -DINCLUDE_ALLOCA_H
100 WHICH_X = x11r5
101#else /* !5 */
102 EXT_DEFINES = "ERROR! Imakefile was unable to determine whether this is X11r4 or X11r5."
103#endif /* !5 */
104#endif /* !4 */
105
106 LUCID_SRCS = lwlib-Xlw.c xlwmenu.c
107 LUCID_OBJS = lwlib-Xlw.o xlwmenu.o
108 MOTIF_SRCS = lwlib-Xm.c
109 MOTIF_OBJS = lwlib-Xm.o
110 OLIT_SRCS = lwlib-Xol.c lwlib-Xol-mb.c
111 OLIT_OBJS = lwlib-Xol.o lwlib-Xol-mb.o
112
113#ifdef INCLUDE_EXTENSIONS
114 EXT_SRCS = dispatch.c xrdb-cpp.c xrdb.c
115 EXT_OBJS = dispatch.o xrdb-cpp.o xrdb.o
116#endif
117
118#if (defined(USE_MOTIF) && defined(USE_OLIT))
119TOOLKIT_DEFINES = "ERROR! You cannot define both USE_MOTIF and USE_OLIT at the same time (in Imakefile)."
120#else
121# if (defined(USE_MOTIF) && defined(USE_LUCID))
122TOOLKIT_DEFINES = -DUSE_MOTIF -DUSE_LUCID
123 TOOLKIT_SRCS = $(MOTIF_SRC) $(LUCID_SRCS)
124 TOOLKIT_OBJS = $(MOTIF_OBJS) $(LUCID_OBJS)
125# else
126# if (defined(USE_OLIT) && defined(USE_LUCID))
127 DEFINES = -DUSE_OLIT -DUSE_LUCID
128 TOOLKIT_SRCS = $(OLIT_SRC) $(LUCID_SRCS)
129 TOOLKIT_OBJS = $(OLIT_OBJS) $(LUCID_OBJS)
130# else
131# if defined(USE_OLIT)
132TOOLKIT_DEFINES = -DUSE_OLIT
133 TOOLKIT_SRCS = $(OLIT_SRC)
134 TOOLKIT_OBJS = $(OLIT_OBJS)
135# else
136# if defined(USE_MOTIF)
137TOOLKIT_DEFINES = -DUSE_MOTIF
138 TOOLKIT_SRCS = $(MOTIF_SRC)
139 TOOLKIT_OBJS = $(MOTIF_OBJS)
140# else
141# if defined(USE_LUCID)
142TOOLKIT_DEFINES = -DUSE_LUCID
143 TOOLKIT_SRCS = $(LUCID_SRC)
144 TOOLKIT_OBJS = $(LUCID_OBJS)
145# else
146TOOLKIT_DEFINES = "ERROR! At least one of USE_MOTIF, USE_LUCID or USE_OLIT must be defined in Imakefile."
147# endif
148# endif
149# endif
150# endif
151# endif
152#endif
153
154#ifdef ENERGIZE
155# ifndef USE_MOTIF
156 EZ_OBJS = "ERROR! ENERGIZE requires USE_MOTIF to be defined in Imakefile."
157# else
158 EZ_OBJS = energize/blpsheet.o energize/build.o energize/classbr_ps.o \
159 energize/ctreebr_ps.o energize/debuggerps.o \
160 energize/editmode.o energize/leb_psheet.o \
161 energize/projectdisp.o energize/projectps.o \
162 energize/search.o energize/target.o
163 ENERGIZEP = -DENERGIZE
164# endif
165#endif
166
167 SRCS = lwlib.c $(TOOLKIT_SRCS) lwlib-utils.c $(EXT_SRCS)
168 OBJS = lwlib.o $(TOOLKIT_OBJS) lwlib-utils.o $(EXT_OBJS) $(EZ_OBJS)
169 EXT_FLAGS = -I$(TOOLKITSRC) $(EXT_DEFINES)
170 LIBNAME = liblw.a
171
172
173#if defined(ENERGIZE) && defined(BUILD_SHARED_LIB)
174all::
175 @if [ ! -d shared ]; then mkdir shared; else exit 0; fi
176 @if [ ! -d energize/shared ]; then mkdir energize/shared; \
177 else exit 0; fi
178 @if [ ! -h shared/energize ]; \
179 then cd shared ; ln -s ../energize/shared energize ; \
180 else exit 0; fi
181
182clean::
183 $(RM) shared/energize
184#endif
185
186
187#ifdef BUILD_SHARED_LIB
188# if (ProjectX == 4)
189SharedLibraryObjectRule ()
190NormalSharedLibraryTarget(lw,$(SOLWREV),$(OBJS))
191# else /* X != 4 */
192LibraryObjectRule ()
193SharedLibraryTarget(lw,$(SOLWREV),$(OBJS),shared,..)
194# endif /* X != 4 */
195#else /* !BUILD_SHARED_LIB */
196NormalLibraryObjectRule ()
197#endif /* !BUILD_SHARED_LIB */
198
199NormalLibraryTarget (lw,$(OBJS))
200MakefileSubdirs (energize)
201DependTarget ()
202
203#ifdef ENERGIZE
204
205energize/Imakefile:
206 -mkdir energize
207 -(cd energize ; sh -c "ln -s ../$(VPATH)/energize/* .")
208
209/* #### we should automatically edit BUILD_SHARED_LIB into/out of the energize
210 Imakefile, since that's the only thing down there that changes */
211energize/Makefile: energize/Imakefile Imakefile
212 $(MAKE) $(MFLAGS) Makefiles
213
214Makefile::
215 $(RM) energize/Makefile
216
217$(EZ_OBJS): energize/Makefile
218 ${RM} $@ ; cd energize ; $(MAKE) $(MFLAGS) CC="$(CC)" CFLAGS="$(CFLAGS)"
219
220clean::
221 cd energize ; $(MAKE) $(MFLAGS) clean
222
223#endif
224
225#if defined(BUILD_SHARED_LIB) && (ProjectX == 4)
226# define LWObjectRule SpecialSharedObjectRule
227#else
228# define LWObjectRule SpecialLibObjectRule
229#endif
230
231CPPDEFS=-DCPP_PROGRAM=\"CppCmd\"
232
233LWObjectRule (lwlib.o, lwlib.c, $(TOOLKIT_DEFINES))
234LWObjectRule (dispatch.o, dispatch.c, $(EXT_FLAGS))
235LWObjectRule (xrdb-cpp.o, xrdb-cpp.c, $(EXT_FLAGS) "$(CPPDEFS)")
236LWObjectRule (xrdb.o, xrdb.c, $(EXT_FLAGS))
237LWObjectRule (lwlib-Xm.o, lwlib-Xm.c, $(ENERGIZEP))
238
239lwlib-utils.o: lwlib-utils.h
240lwlib.o: lwlib.h lwlib-internal.h
241lwlib-Xlw.o: lwlib.h lwlib-internal.h
242lwlib-Xm.o: lwlib.h lwlib-internal.h lwlib-utils.h
243lwlib-Xol.o: lwlib.h lwlib-internal.h
244lwlib-Xol-mb.o: lwlib-Xol-mb.h lwlib-Xol-mbP.h
diff --git a/lwlib/dispatch.c b/lwlib/dispatch.c
deleted file mode 100644
index 7e70a43105b..00000000000
--- a/lwlib/dispatch.c
+++ /dev/null
@@ -1,275 +0,0 @@
1/* Defines a function to find the Widget that XtDispatchEvent() would use.
2 Copyright (C) 1992 Lucid, Inc.
3
4This file is part of the Lucid Widget Library.
5
6The Lucid Widget Library is free software; you can redistribute it and/or
7modify it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 1, or (at your option)
9any later version.
10
11The Lucid Widget Library is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU Emacs; see the file COPYING. If not, write to
18the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19Boston, MA 02111-1307, USA. */
20
21/*
22 * The function XtWidgetToDispatchTo(), given an XEvent, returns the
23 * widget that XtDispatchEvent() would send that event to if called now.
24 * This file copies much code from the X11r4 Xt source, and is thus a
25 * portability problem. It also requires data structures defined in
26 * IntrinsicI.h, which is a non-exported Xt header file, so you can't
27 * compile this file unless you have the Xt sources online.
28 */
29
30#ifdef HAVE_CONFIG_H
31#include <config.h>
32#endif
33
34#include <IntrinsicI.h> /* Don't change this: see comments in Imakefile. */
35#include <X11/Xatom.h>
36#include "dispatch.h"
37
38#include <X11/Xlib.h>
39#include <X11/cursorfont.h>
40#include <X11/Xutil.h>
41
42#ifdef XlibSpecificationRelease
43#if XlibSpecificationRelease >= 5
44#define HAVE_X11R5
45#endif
46#endif
47
48/* ## All of the code on this page was copied from the X11R5 lib/Xt/Event.c,
49 ## but is compatible with X11R4; the code in Event.c is different, but
50 ## functionally equivalent for our purposes.
51 */
52
53#if __STDC__
54#define Const const
55#else
56#define Const /**/
57#endif
58
59#define NonMaskableMask ((EventMask)0x80000000L)
60
61#define COMP_EXPOSE (widget->core.widget_class->core_class.compress_exposure)
62#define COMP_EXPOSE_TYPE (COMP_EXPOSE & 0x0f)
63#define GRAPHICS_EXPOSE ((XtExposeGraphicsExpose & COMP_EXPOSE) || \
64 (XtExposeGraphicsExposeMerged & COMP_EXPOSE))
65#define NO_EXPOSE (XtExposeNoExpose & COMP_EXPOSE)
66
67
68/* -- lots of stuff we don't need to copy, omitted -- */
69
70
71static EventMask Const masks[] = {
72 0, /* Error, should never see */
73 0, /* Reply, should never see */
74 KeyPressMask, /* KeyPress */
75 KeyReleaseMask, /* KeyRelease */
76 ButtonPressMask, /* ButtonPress */
77 ButtonReleaseMask, /* ButtonRelease */
78 PointerMotionMask /* MotionNotify */
79 | ButtonMotionMask,
80 EnterWindowMask, /* EnterNotify */
81 LeaveWindowMask, /* LeaveNotify */
82 FocusChangeMask, /* FocusIn */
83 FocusChangeMask, /* FocusOut */
84 KeymapStateMask, /* KeymapNotify */
85 ExposureMask, /* Expose */
86 NonMaskableMask, /* GraphicsExpose, in GC */
87 NonMaskableMask, /* NoExpose, in GC */
88 VisibilityChangeMask, /* VisibilityNotify */
89 SubstructureNotifyMask, /* CreateNotify */
90 StructureNotifyMask /* DestroyNotify */
91 | SubstructureNotifyMask,
92 StructureNotifyMask /* UnmapNotify */
93 | SubstructureNotifyMask,
94 StructureNotifyMask /* MapNotify */
95 | SubstructureNotifyMask,
96 SubstructureRedirectMask, /* MapRequest */
97 StructureNotifyMask /* ReparentNotify */
98 | SubstructureNotifyMask,
99 StructureNotifyMask /* ConfigureNotify */
100 | SubstructureNotifyMask,
101 SubstructureRedirectMask, /* ConfigureRequest */
102 StructureNotifyMask /* GravityNotify */
103 | SubstructureNotifyMask,
104 ResizeRedirectMask, /* ResizeRequest */
105 StructureNotifyMask /* CirculateNotify */
106 | SubstructureNotifyMask,
107 SubstructureRedirectMask, /* CirculateRequest */
108 PropertyChangeMask, /* PropertyNotify */
109 NonMaskableMask, /* SelectionClear */
110 NonMaskableMask, /* SelectionRequest */
111 NonMaskableMask, /* SelectionNotify */
112 ColormapChangeMask, /* ColormapNotify */
113 NonMaskableMask, /* ClientMessage */
114 NonMaskableMask /* MappingNotify */
115};
116
117#ifndef HAVE_X11R5
118
119static /* in R5, this is not static, so we don't need to define it at all */
120EventMask _XtConvertTypeToMask (eventType)
121 int eventType;
122{
123 eventType &= 0x7f; /* Events sent with XSendEvent have high bit set. */
124 if (eventType < XtNumber(masks))
125 return masks[eventType];
126 else
127 return 0;
128}
129
130#endif /* not HAVE_X11R5 */
131
132/* -- _XtOnGrabList() omitted -- */
133
134
135static Widget LookupSpringLoaded(grabList)
136 XtGrabList grabList;
137{
138 XtGrabList gl;
139
140 for (gl = grabList; gl != NULL; gl = gl->next) {
141 if (gl->spring_loaded)
142 if (XtIsSensitive(gl->widget))
143 return gl->widget;
144 else
145 return NULL;
146 if (gl->exclusive) break;
147 }
148 return NULL;
149}
150
151
152
153/* This function is new. */
154
155static Boolean WouldDispatchEvent(event, widget, mask, pd)
156 register XEvent *event;
157 Widget widget;
158 EventMask mask;
159 XtPerDisplay pd;
160{
161 XtEventRec *p;
162 Boolean would_dispatched = False;
163
164 if ((mask == ExposureMask) ||
165 ((event->type == NoExpose) && NO_EXPOSE) ||
166 ((event->type == GraphicsExpose) && GRAPHICS_EXPOSE) )
167 if (widget->core.widget_class->core_class.expose != NULL )
168 return True;
169
170
171 if ((mask == VisibilityChangeMask) &&
172 XtClass(widget)->core_class.visible_interest)
173 return True;
174
175 for (p=widget->core.event_table; p != NULL; p = p->next)
176 if ((mask & p->mask) != 0
177#ifndef HAVE_X11R5
178 || (mask == 0 && p->non_filter)
179#endif
180 )
181 return True;
182
183 return False;
184}
185
186
187/* #### This function is mostly copied from DecideToDispatch().
188 */
189
190typedef enum _GrabType {pass, ignore, remap} GrabType;
191
192Widget
193XtWidgetToDispatchTo (XEvent* event)
194{
195 register Widget widget;
196 EventMask mask;
197 GrabType grabType;
198 Widget dspWidget;
199 Time time = 0;
200 XtPerDisplay pd;
201 XtPerDisplayInput pdi;
202 XtGrabList grabList;
203
204 widget = XtWindowToWidget (event->xany.display, event->xany.window);
205 pd = _XtGetPerDisplay(event->xany.display);
206 pdi = _XtGetPerDisplayInput(event->xany.display);
207 grabList = *_XtGetGrabList(pdi);
208
209 mask = _XtConvertTypeToMask(event->xany.type);
210 grabType = pass;
211 switch (event->xany.type & 0x7f) {
212 case KeyPress:
213 case KeyRelease: grabType = remap; break;
214 case ButtonPress:
215 case ButtonRelease: grabType = remap; break;
216 case MotionNotify: grabType = ignore;
217#define XKnownButtons (Button1MotionMask|Button2MotionMask|Button3MotionMask|\
218 Button4MotionMask|Button5MotionMask)
219 mask |= (event->xmotion.state & XKnownButtons);
220#undef XKnownButtons
221 break;
222 case EnterNotify: grabType = ignore; break;
223 }
224
225 if (widget == NULL) {
226 if (grabType != remap) return False;
227 /* event occurred in a non-widget window, but we've promised also
228 to dispatch it to the nearest accessible spring_loaded widget */
229 else if ((widget = LookupSpringLoaded(grabList)) != NULL)
230 return widget;
231 return False;
232 }
233
234 switch(grabType) {
235 case pass:
236 return widget;
237
238 case ignore:
239 if ((grabList == NULL || _XtOnGrabList(widget,grabList))
240 && XtIsSensitive(widget)) {
241 return widget;
242 }
243 return NULL;
244
245 case remap:
246
247 {
248 Widget was_dispatched_to= NULL;
249 extern Widget _XtFindRemapWidget();
250 extern void _XtUngrabBadGrabs();
251
252 dspWidget = _XtFindRemapWidget(event, widget, mask, pdi);
253
254 if ((grabList == NULL ||
255 _XtOnGrabList(dspWidget, grabList)) &&
256 XtIsSensitive(dspWidget)) {
257 if (WouldDispatchEvent (event, dspWidget, mask, pd))
258 was_dispatched_to = dspWidget;
259 }
260
261 /* Also dispatch to nearest accessible spring_loaded. */
262 /* Fetch this afterward to reflect modal list changes */
263 grabList = *_XtGetGrabList(pdi);
264 widget = LookupSpringLoaded(grabList);
265 if (widget != NULL && widget != dspWidget) {
266 if (!was_dispatched_to)
267 was_dispatched_to = widget;
268 }
269
270 return was_dispatched_to;
271 }
272 }
273 /* should never reach here */
274 return NULL;
275}
diff --git a/lwlib/dispatch.h b/lwlib/dispatch.h
deleted file mode 100644
index 175284508f4..00000000000
--- a/lwlib/dispatch.h
+++ /dev/null
@@ -1,2 +0,0 @@
1
2Widget XtWidgetToDispatchTo (XEvent *);
diff --git a/lwlib/xrdb-cpp.c b/lwlib/xrdb-cpp.c
deleted file mode 100644
index b6a167c0517..00000000000
--- a/lwlib/xrdb-cpp.c
+++ /dev/null
@@ -1,188 +0,0 @@
1/* A general interface to the widgets of different toolkits.
2 Copyright (C) 1992, 1993 Lucid, Inc.
3
4This file is part of the Lucid Widget Library.
5
6The Lucid Widget Library is free software; you can redistribute it and/or
7modify it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2, or (at your option)
9any later version.
10
11The Lucid Widget Library is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU Emacs; see the file COPYING. If not, write to
18the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19Boston, MA 02111-1307, USA. */
20
21/* This code reads a resource database file and filters it through cpp
22 with the same set of preprocessor defines that `xrdb' uses.
23 Call lwlib_xrdb_initialize(dpy) once, and then call the function
24 lwlib_GetFileDatabase() instead of XrmGetFileDatabase(),
25 and lwlib_CombineFileDatabase() instead of XrmCombineFileDatabase().
26 */
27
28#ifndef __STDC_EXTENDED__
29#define __STDC_EXTENDED__
30#endif
31
32#ifdef HAVE_CONFIG_H
33#include <config.h>
34#endif
35
36#include <stdio.h>
37#include <ctype.h>
38#include <X11/Xlib.h>
39#include <X11/Xos.h>
40#include <X11/Intrinsic.h>
41#include <X11/Xmu/SysUtil.h>
42#include <sys/stat.h>
43
44extern char *index ();
45
46static int
47file_p (path)
48 char *path;
49{
50 struct stat status;
51
52 return (access (path, R_OK) == 0 /* exists and is readable */
53 && stat (path, &status) == 0 /* get the status */
54 && (status.st_mode & S_IFDIR) == 0); /* not a directory */
55}
56
57#ifndef CPP_PROGRAM
58#define CPP_PROGRAM "/lib/cpp"
59#endif
60
61static char cpp_string [BUFSIZ];
62static char *cpp_file = 0;
63
64#define Resolution(pixels, mm) ((((pixels) * 100000 / (mm)) + 50) / 100)
65
66void
67lwlib_xrdb_initialize (display)
68 Display *display;
69{
70 Screen *screen;
71 Visual *visual;
72 char server [255];
73 char *colon, *s;
74
75#define Push(str) \
76 (strncpy (s, str, sizeof(str)), s += (sizeof(str)-1))
77
78#define Print(str, thing) \
79 (sprintf (s, str, thing), s = index (s, 0))
80
81 s = cpp_string;
82 Push (CPP_PROGRAM);
83
84 Push (" -DCLIENTHOST=");
85 XmuGetHostname (s, sizeof (cpp_string) - (s - cpp_string));
86 s = index (s, 0);
87 Push (" -DSERVERHOST=");
88 strcpy (s, XDisplayName (DisplayString (display)));
89 colon = index (s, ':');
90 if (colon == s)
91 {
92 XmuGetHostname (s, sizeof (cpp_string) - (s - cpp_string));
93 s = index (s, 0);
94 }
95 else if (colon)
96 s = colon;
97 else
98 s = index (s, 0);
99
100 Print (" -DVERSION=%d", ProtocolVersion(display));
101 Print (" -DREVISION=%d", ProtocolRevision(display));
102 Print (" -DVENDOR=\"%s\"", ServerVendor(display));
103 Print (" -DRELEASE=%d", VendorRelease(display));
104 screen = DefaultScreenOfDisplay(display);
105 visual = DefaultVisualOfScreen(screen);
106 Print (" -DWIDTH=%d", screen->width);
107 Print (" -DHEIGHT=%d", screen->height);
108 Print (" -DX_RESOLUTION=%d", Resolution(screen->width,screen->mwidth));
109 Print (" -DY_RESOLUTION=%d", Resolution(screen->height,screen->mheight));
110 Print (" -DPLANES=%d", DisplayPlanes(display, DefaultScreen(display)));
111 Print (" -DBITS_PER_RGB=%d", visual->bits_per_rgb);
112 switch(visual->class) {
113 case StaticGray: Print (" -DCLASS=%s", "StaticGray"); break;
114 case GrayScale: Print (" -DCLASS=%s", "GrayScale"); break;
115 case StaticColor: Print (" -DCLASS=%s", "StaticColor");
116 Print (" -DCOLOR", 0); break;
117 case PseudoColor: Print (" -DCLASS=%s", "PseudoColor");
118 Print (" -DCOLOR", 0); break;
119 case TrueColor: Print (" -DCLASS=%s", "TrueColor");
120 Print (" -DCOLOR", 0); break;
121 case DirectColor: Print (" -DCLASS=%s", "DirectColor");
122 Print (" -DCOLOR", 0); break;
123 default:
124 fprintf (stderr, "unexpected visual class=%d\n", visual->class);
125 exit (-1);
126 }
127 *s++ = ' ';
128 *s = 0;
129 cpp_file = s;
130}
131
132XrmDatabase
133lwlib_GetFileDatabase (path)
134 char *path;
135{
136 XrmDatabase db = 0;
137 char line [BUFSIZ];
138 char *s;
139 FILE *file;
140
141 if (! file_p (path))
142 return 0;
143
144 strcpy (cpp_file, path);
145 if (! (file = popen (cpp_string, "r")))
146 {
147 fprintf (stderr,
148 "couldn't execute %s; resource file %s file not munged.\n",
149 CPP_PROGRAM, path);
150 return XrmGetFileDatabase (path);
151 }
152 while (s = fgets (line, sizeof (line), file))
153 {
154 char ch, *tail;
155 if (*s == '!') continue;
156 for (; ((ch = *s) != '\n') && isspace(ch); s++);
157 if ((ch == '\0') || (ch == '\n') || (ch == '#')) continue;
158 tail = s + strlen (s);
159 if (tail - s < 3) continue; /* this would be syntactically incorrect */
160 while (*(tail-1) == '\n' && /* handle \ at end of line */
161 *(tail-2) == '\\')
162 {
163 if (! fgets (tail, sizeof (line) - (tail - line), file))
164 continue;
165 tail += strlen (tail);
166 }
167 XrmPutLineResource (&db, s);
168 }
169 pclose (file);
170 return db;
171}
172
173#ifdef THIS_IS_X11R5
174
175int
176lwlib_CombineFileDatabase (path, target_db, override)
177 char *path;
178 XrmDatabase *target_db;
179 Bool override;
180{
181 XrmDatabase source_db = lwlib_GetFileDatabase (path);
182 if (! source_db)
183 return (! file_p (path));
184 XrmCombineDatabase (source_db, target_db, override);
185 return 1;
186}
187
188#endif /* r5 */
diff --git a/lwlib/xrdb.c b/lwlib/xrdb.c
deleted file mode 100644
index d777c303d61..00000000000
--- a/lwlib/xrdb.c
+++ /dev/null
@@ -1,74 +0,0 @@
1/* This file overrides the R4 or R5 mit/lib/Xt/Initialize.c, except that
2 the functions lwlib_GetFileDatabase(), lwlib_CombineFileDatabase(), and
3 lwlib_xrdb_initialize() are called. By doing this silly cpp hack, we
4 avoid version skew problems.
5 */
6
7#ifdef HAVE_CONFIG_H
8#include <config.h>
9#endif
10
11#include <X11/Xlib.h>
12#include <X11/cursorfont.h>
13#include <X11/Xutil.h>
14
15#ifdef XlibSpecificationRelease
16#if XlibSpecificationRelease >= 5
17#define HAVE_X11R5
18#endif
19#endif
20
21extern struct _XrmHashBucketRec *lwlib_GetFileDatabase ();
22extern void lwlib_xrdb_initialize ();
23
24/* Replace all calls to XrmGetFileDatabase() with lwlib_GetFileDatabase(),
25 calls to XrmCombineFileDatabase() with lwlib_CombineFileDatabase(), and
26 rename the defined _XtDisplayInitialize() function.
27 */
28#define XrmGetFileDatabase lwlib_GetFileDatabase
29#define XrmCombineFileDatabase lwlib_CombineFileDatabase
30#define _XtDisplayInitialize _orig_XtDisplayInitialize
31
32/* Suck in the original code. Don't change this: see comments in Imakefile. */
33#include "Initialize.c"
34
35#undef XrmGetFileDatabase
36#undef XrmCombineFileDatabase
37#undef _XtDisplayInitialize
38
39/* Now provide a definition of _XtDisplayInitialize() which invokes the
40 original code after calling our initialization hook. Note that the R4
41 and R5 versions of _XtDisplayInitialize() take different arguments.
42 */
43
44#ifndef HAVE_X11R5
45
46void _XtDisplayInitialize(dpy, pd, name, class, urlist, num_urs, argc, argv)
47 Display *dpy;
48 XtPerDisplay pd;
49 String name, class;
50 XrmOptionDescRec *urlist;
51 Cardinal num_urs;
52 Cardinal *argc;
53 char *argv[];
54{
55 lwlib_xrdb_initialize(dpy);
56 _orig_XtDisplayInitialize(dpy, pd, name, class, urlist, num_urs, argc, argv);
57}
58
59#else /* HAVE_X11R5 */
60
61void _XtDisplayInitialize(dpy, pd, name, urlist, num_urs, argc, argv)
62 Display *dpy;
63 XtPerDisplay pd;
64 String name;
65 XrmOptionDescRec *urlist;
66 Cardinal num_urs;
67 int *argc;
68 char **argv;
69{
70 lwlib_xrdb_initialize(dpy);
71 _orig_XtDisplayInitialize(dpy, pd, name, urlist, num_urs, argc, argv);
72}
73
74#endif /* HAVE_X11R5 */