0
|
1 /* This file contains compatibility routines for systems without Xmu.
|
|
2 * You would be better served by installing Xmu on your machine or
|
|
3 * yelling at your vendor to ship it.
|
|
4 */
|
|
5
|
|
6 /* XEmacs changes: rindex -> strrchr */
|
|
7
|
|
8 /* Synched up with: Not in FSF. */
|
|
9
|
|
10 #include <config.h>
|
|
11
|
|
12 #ifndef HAVE_XMU
|
|
13 /*
|
|
14 * Copyright 1989 Massachusetts Institute of Technology
|
|
15 *
|
|
16 * Permission to use, copy, modify, and distribute this software and its
|
|
17 * documentation for any purpose and without fee is hereby granted, provided
|
|
18 * that the above copyright notice appear in all copies and that both that
|
|
19 * copyright notice and this permission notice appear in supporting
|
|
20 * documentation, and that the name of M.I.T. not be used in advertising
|
|
21 * or publicity pertaining to distribution of the software without specific,
|
|
22 * written prior permission. M.I.T. makes no representations about the
|
|
23 * suitability of this software for any purpose. It is provided "as is"
|
|
24 * without express or implied warranty.
|
|
25 *
|
|
26 * M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
|
|
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
|
|
28 * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
29 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
183
|
30 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
0
|
31 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
32 */
|
|
33 #include <X11/cursorfont.h>
|
163
|
34 #if 0 /* mrb */
|
0
|
35 #include <X11/Xos.h>
|
163
|
36 #endif
|
0
|
37 #include <X11/Xlib.h>
|
|
38 #include <X11/Xutil.h>
|
|
39 #include <X11/Intrinsic.h>
|
|
40
|
|
41 /* for XmuCopyISOLatin1Lowered */
|
|
42 #define XK_LATIN1
|
|
43 #include <X11/keysymdef.h>
|
|
44 #undef XK_LATIN1
|
|
45
|
|
46 #if (XtSpecificationRelease >= 5)
|
|
47 /*
|
|
48 * Don't know why, but this works with X11R5, not X11R4.
|
|
49 * Anyway, _XExtension is defined in Xlib.h in X11R4, so we do not need
|
|
50 * Xlibint in that case...
|
|
51 */
|
|
52 #include <X11/Xlibint.h>
|
|
53 #endif
|
|
54 #include <X11/Xproto.h>
|
|
55 #include <stdio.h>
|
|
56 #include <ctype.h>
|
|
57
|
|
58
|
203
|
59 int XmuCursorNameToIndex (CONST char *name)
|
0
|
60 {
|
203
|
61 static CONST struct _CursorName {
|
|
62 CONST char *name;
|
0
|
63 unsigned int shape;
|
|
64 } cursor_names[] = {
|
|
65 {"x_cursor", XC_X_cursor},
|
|
66 {"arrow", XC_arrow},
|
|
67 {"based_arrow_down", XC_based_arrow_down},
|
|
68 {"based_arrow_up", XC_based_arrow_up},
|
|
69 {"boat", XC_boat},
|
|
70 {"bogosity", XC_bogosity},
|
|
71 {"bottom_left_corner", XC_bottom_left_corner},
|
|
72 {"bottom_right_corner", XC_bottom_right_corner},
|
|
73 {"bottom_side", XC_bottom_side},
|
|
74 {"bottom_tee", XC_bottom_tee},
|
|
75 {"box_spiral", XC_box_spiral},
|
|
76 {"center_ptr", XC_center_ptr},
|
|
77 {"circle", XC_circle},
|
|
78 {"clock", XC_clock},
|
|
79 {"coffee_mug", XC_coffee_mug},
|
|
80 {"cross", XC_cross},
|
|
81 {"cross_reverse", XC_cross_reverse},
|
|
82 {"crosshair", XC_crosshair},
|
|
83 {"diamond_cross", XC_diamond_cross},
|
|
84 {"dot", XC_dot},
|
|
85 {"dotbox", XC_dotbox},
|
|
86 {"double_arrow", XC_double_arrow},
|
|
87 {"draft_large", XC_draft_large},
|
|
88 {"draft_small", XC_draft_small},
|
|
89 {"draped_box", XC_draped_box},
|
|
90 {"exchange", XC_exchange},
|
|
91 {"fleur", XC_fleur},
|
|
92 {"gobbler", XC_gobbler},
|
|
93 {"gumby", XC_gumby},
|
|
94 {"hand1", XC_hand1},
|
|
95 {"hand2", XC_hand2},
|
|
96 {"heart", XC_heart},
|
|
97 {"icon", XC_icon},
|
|
98 {"iron_cross", XC_iron_cross},
|
|
99 {"left_ptr", XC_left_ptr},
|
|
100 {"left_side", XC_left_side},
|
|
101 {"left_tee", XC_left_tee},
|
|
102 {"leftbutton", XC_leftbutton},
|
|
103 {"ll_angle", XC_ll_angle},
|
|
104 {"lr_angle", XC_lr_angle},
|
|
105 {"man", XC_man},
|
|
106 {"middlebutton", XC_middlebutton},
|
|
107 {"mouse", XC_mouse},
|
|
108 {"pencil", XC_pencil},
|
|
109 {"pirate", XC_pirate},
|
|
110 {"plus", XC_plus},
|
|
111 {"question_arrow", XC_question_arrow},
|
|
112 {"right_ptr", XC_right_ptr},
|
|
113 {"right_side", XC_right_side},
|
|
114 {"right_tee", XC_right_tee},
|
|
115 {"rightbutton", XC_rightbutton},
|
|
116 {"rtl_logo", XC_rtl_logo},
|
|
117 {"sailboat", XC_sailboat},
|
|
118 {"sb_down_arrow", XC_sb_down_arrow},
|
|
119 {"sb_h_double_arrow", XC_sb_h_double_arrow},
|
|
120 {"sb_left_arrow", XC_sb_left_arrow},
|
|
121 {"sb_right_arrow", XC_sb_right_arrow},
|
|
122 {"sb_up_arrow", XC_sb_up_arrow},
|
|
123 {"sb_v_double_arrow", XC_sb_v_double_arrow},
|
|
124 {"shuttle", XC_shuttle},
|
|
125 {"sizing", XC_sizing},
|
|
126 {"spider", XC_spider},
|
|
127 {"spraycan", XC_spraycan},
|
|
128 {"star", XC_star},
|
|
129 {"target", XC_target},
|
|
130 {"tcross", XC_tcross},
|
|
131 {"top_left_arrow", XC_top_left_arrow},
|
|
132 {"top_left_corner", XC_top_left_corner},
|
|
133 {"top_right_corner", XC_top_right_corner},
|
|
134 {"top_side", XC_top_side},
|
|
135 {"top_tee", XC_top_tee},
|
|
136 {"trek", XC_trek},
|
|
137 {"ul_angle", XC_ul_angle},
|
|
138 {"umbrella", XC_umbrella},
|
|
139 {"ur_angle", XC_ur_angle},
|
|
140 {"watch", XC_watch},
|
|
141 {"xterm", XC_xterm},
|
|
142 };
|
203
|
143 CONST struct _CursorName *table;
|
0
|
144 int i;
|
|
145 char tmp[40];
|
183
|
146
|
0
|
147 if (strlen (name) >= sizeof tmp) return -1;
|
183
|
148 for (i=0; i<strlen(name); i++)
|
0
|
149 if (isupper((unsigned char) name[i]))
|
|
150 tmp[i] = tolower((unsigned char) name[i]);
|
|
151 else
|
|
152 tmp[i] = name[i];
|
|
153 tmp[i] = 0;
|
|
154
|
|
155 for (i=0, table=cursor_names; i < XtNumber(cursor_names); i++, table++ ) {
|
|
156 if (strcmp(tmp, table->name) == 0) return table->shape;
|
|
157 }
|
|
158
|
|
159 return -1;
|
|
160 }
|
|
161
|
|
162
|
|
163 /*
|
|
164 * Based on an optimized version provided by Jim Becker, Auguest 5, 1988.
|
|
165 */
|
|
166
|
|
167
|
|
168 #define MAX_SIZE 255
|
|
169
|
|
170 /* shared data for the image read/parse logic */
|
|
171 static short hexTable[256]; /* conversion value */
|
120
|
172 static int hex_initialized; /* easier to fill in at run time */
|
0
|
173
|
|
174
|
|
175 /*
|
|
176 * Table index for the hex values. Initialized once, first time.
|
|
177 * Used for translation value or delimiter significance lookup.
|
|
178 */
|
74
|
179 static void initHexTable (void)
|
0
|
180 {
|
|
181 /*
|
|
182 * We build the table at run time for several reasons:
|
|
183 *
|
|
184 * 1. portable to non-ASCII machines.
|
|
185 * 2. still reentrant since we set the init flag after setting table.
|
|
186 * 3. easier to extend.
|
|
187 * 4. less prone to bugs.
|
|
188 */
|
|
189 hexTable['0'] = 0; hexTable['1'] = 1;
|
|
190 hexTable['2'] = 2; hexTable['3'] = 3;
|
|
191 hexTable['4'] = 4; hexTable['5'] = 5;
|
|
192 hexTable['6'] = 6; hexTable['7'] = 7;
|
|
193 hexTable['8'] = 8; hexTable['9'] = 9;
|
|
194 hexTable['A'] = 10; hexTable['B'] = 11;
|
|
195 hexTable['C'] = 12; hexTable['D'] = 13;
|
|
196 hexTable['E'] = 14; hexTable['F'] = 15;
|
|
197 hexTable['a'] = 10; hexTable['b'] = 11;
|
|
198 hexTable['c'] = 12; hexTable['d'] = 13;
|
|
199 hexTable['e'] = 14; hexTable['f'] = 15;
|
|
200
|
|
201 /* delimiters of significance are flagged w/ negative value */
|
|
202 hexTable[' '] = -1; hexTable[','] = -1;
|
|
203 hexTable['}'] = -1; hexTable['\n'] = -1;
|
|
204 hexTable['\t'] = -1;
|
183
|
205
|
120
|
206 hex_initialized = 1;
|
0
|
207 }
|
|
208
|
|
209 /*
|
|
210 * read next hex value in the input stream, return -1 if EOF
|
|
211 */
|
74
|
212 static int NextInt (FILE *fstream)
|
0
|
213 {
|
|
214 int ch;
|
|
215 int value = 0;
|
|
216 int gotone = 0;
|
|
217 int done = 0;
|
183
|
218
|
0
|
219 /* loop, accumulate hex value until find delimiter */
|
|
220 /* skip any initial delimiters found in read stream */
|
|
221
|
|
222 while (!done) {
|
|
223 ch = getc(fstream);
|
|
224 if (ch == EOF) {
|
|
225 value = -1;
|
|
226 done++;
|
|
227 } else {
|
|
228 /* trim high bits, check type and accumulate */
|
|
229 ch &= 0xff;
|
|
230 if (isascii(ch) && isxdigit(ch)) {
|
|
231 value = (value << 4) + hexTable[ch];
|
|
232 gotone++;
|
|
233 } else if ((hexTable[ch]) < 0 && gotone)
|
|
234 done++;
|
|
235 }
|
|
236 }
|
|
237 return value;
|
|
238 }
|
|
239
|
|
240
|
|
241 /*
|
|
242 * The data returned by the following routine is always in left-most byte
|
|
243 * first and left-most bit first. If it doesn't return BitmapSuccess then
|
|
244 * its arguments won't have been touched. This routine should look as much
|
|
245 * like the Xlib routine XReadBitmapfile as possible.
|
|
246 */
|
74
|
247 int XmuReadBitmapData (
|
|
248 FILE *fstream, /* handle on file */
|
|
249 unsigned int *width, /* RETURNED */
|
|
250 unsigned int *height, /* RETURNED */
|
|
251 unsigned char **datap, /* RETURNED */
|
|
252 int *x_hot, int *y_hot) /* RETURNED */
|
0
|
253 {
|
|
254 unsigned char *data = NULL; /* working variable */
|
|
255 char line[MAX_SIZE]; /* input line from file */
|
|
256 int size; /* number of bytes of data */
|
|
257 char name_and_type[MAX_SIZE]; /* an input line */
|
|
258 char *type; /* for parsing */
|
|
259 int value; /* from an input line */
|
|
260 int version10p; /* boolean, old format */
|
|
261 int padding; /* to handle alignment */
|
|
262 int bytes_per_line; /* per scanline of data */
|
|
263 unsigned int ww = 0; /* width */
|
|
264 unsigned int hh = 0; /* height */
|
|
265 int hx = -1; /* x hotspot */
|
|
266 int hy = -1; /* y hotspot */
|
|
267
|
|
268 #ifndef Xmalloc
|
|
269 #define Xmalloc(size) malloc(size)
|
|
270 #endif
|
|
271
|
|
272 /* first time initialization */
|
120
|
273 if (!hex_initialized) initHexTable();
|
0
|
274
|
|
275 /* error cleanup and return macro */
|
|
276 #define RETURN(code) { if (data) free (data); return code; }
|
|
277
|
|
278 while (fgets(line, MAX_SIZE, fstream)) {
|
|
279 if (strlen(line) == MAX_SIZE-1) {
|
|
280 RETURN (BitmapFileInvalid);
|
|
281 }
|
|
282 if (sscanf(line,"#define %s %d",name_and_type,&value) == 2) {
|
|
283 if (!(type = strrchr(name_and_type, '_')))
|
|
284 type = name_and_type;
|
|
285 else
|
|
286 type++;
|
|
287
|
|
288 if (!strcmp("width", type))
|
|
289 ww = (unsigned int) value;
|
|
290 if (!strcmp("height", type))
|
|
291 hh = (unsigned int) value;
|
|
292 if (!strcmp("hot", type)) {
|
|
293 if (type-- == name_and_type || type-- == name_and_type)
|
|
294 continue;
|
|
295 if (!strcmp("x_hot", type))
|
|
296 hx = value;
|
|
297 if (!strcmp("y_hot", type))
|
|
298 hy = value;
|
|
299 }
|
|
300 continue;
|
|
301 }
|
183
|
302
|
0
|
303 if (sscanf(line, "static short %s = {", name_and_type) == 1)
|
|
304 version10p = 1;
|
|
305 else if (sscanf(line,"static unsigned char %s = {",name_and_type) == 1)
|
|
306 version10p = 0;
|
|
307 else if (sscanf(line, "static char %s = {", name_and_type) == 1)
|
|
308 version10p = 0;
|
|
309 else
|
|
310 continue;
|
|
311
|
|
312 if (!(type = strrchr(name_and_type, '_')))
|
|
313 type = name_and_type;
|
|
314 else
|
|
315 type++;
|
|
316
|
|
317 if (strcmp("bits[]", type))
|
|
318 continue;
|
183
|
319
|
0
|
320 if (!ww || !hh)
|
|
321 RETURN (BitmapFileInvalid);
|
|
322
|
|
323 if ((ww % 16) && ((ww % 16) < 9) && version10p)
|
|
324 padding = 1;
|
|
325 else
|
|
326 padding = 0;
|
|
327
|
|
328 bytes_per_line = (ww+7)/8 + padding;
|
|
329
|
|
330 size = bytes_per_line * hh;
|
|
331 data = (unsigned char *) Xmalloc ((unsigned int) size);
|
183
|
332 if (!data)
|
0
|
333 RETURN (BitmapNoMemory);
|
|
334
|
|
335 if (version10p) {
|
|
336 unsigned char *ptr;
|
|
337 int bytes;
|
|
338
|
|
339 for (bytes=0, ptr=data; bytes<size; (bytes += 2)) {
|
|
340 if ((value = NextInt(fstream)) < 0)
|
|
341 RETURN (BitmapFileInvalid);
|
|
342 *(ptr++) = value;
|
|
343 if (!padding || ((bytes+2) % bytes_per_line))
|
|
344 *(ptr++) = value >> 8;
|
|
345 }
|
|
346 } else {
|
|
347 unsigned char *ptr;
|
|
348 int bytes;
|
|
349
|
|
350 for (bytes=0, ptr=data; bytes<size; bytes++, ptr++) {
|
183
|
351 if ((value = NextInt(fstream)) < 0)
|
0
|
352 RETURN (BitmapFileInvalid);
|
|
353 *ptr=value;
|
|
354 }
|
|
355 }
|
|
356 break;
|
|
357 } /* end while */
|
|
358
|
|
359 if (data == NULL) {
|
|
360 RETURN (BitmapFileInvalid);
|
|
361 }
|
|
362
|
|
363 *datap = data;
|
|
364 data = NULL;
|
|
365 *width = ww;
|
|
366 *height = hh;
|
|
367 if (x_hot) *x_hot = hx;
|
|
368 if (y_hot) *y_hot = hy;
|
|
369
|
|
370 RETURN (BitmapSuccess);
|
|
371 }
|
|
372
|
|
373
|
203
|
374 int XmuReadBitmapDataFromFile (CONST char *filename,
|
74
|
375 /* Remaining args are RETURNED */
|
183
|
376 unsigned int *width,
|
74
|
377 unsigned int *height,
|
|
378 unsigned char **datap,
|
0
|
379 int *x_hot, int *y_hot)
|
|
380 {
|
|
381 FILE *fstream;
|
|
382 int status;
|
|
383
|
|
384 if ((fstream = fopen (filename, "r")) == NULL) {
|
|
385 return BitmapOpenFailed;
|
|
386 }
|
|
387 status = XmuReadBitmapData (fstream, width, height, datap, x_hot, y_hot);
|
|
388 fclose (fstream);
|
|
389 return status;
|
|
390 }
|
|
391
|
|
392 /*
|
183
|
393 * XmuPrintDefaultErrorMessage - print a nice error that looks like the usual
|
0
|
394 * message. Returns 1 if the caller should consider exitting else 0.
|
|
395 */
|
74
|
396 int XmuPrintDefaultErrorMessage (Display *dpy, XErrorEvent *event, FILE *fp)
|
0
|
397 {
|
|
398 char buffer[BUFSIZ];
|
|
399 char mesg[BUFSIZ];
|
|
400 char number[32];
|
|
401 char *mtype = "XlibMessage";
|
|
402 _XExtension *ext = (_XExtension *)NULL;
|
|
403 XGetErrorText(dpy, event->error_code, buffer, BUFSIZ);
|
|
404 XGetErrorDatabaseText(dpy, mtype, "XError", "X Error", mesg, BUFSIZ);
|
183
|
405 fprintf(fp, "%s: %s\n ", mesg, buffer);
|
|
406 XGetErrorDatabaseText(dpy, mtype, "MajorCode", "Request Major code %d",
|
0
|
407 mesg, BUFSIZ);
|
183
|
408 fprintf(fp, mesg, event->request_code);
|
0
|
409 if (event->request_code < 128) {
|
|
410 sprintf(number, "%d", event->request_code);
|
|
411 XGetErrorDatabaseText(dpy, "XRequest", number, "", buffer, BUFSIZ);
|
|
412 } else {
|
|
413 /* XXX this is non-portable */
|
|
414 for (ext = dpy->ext_procs;
|
|
415 ext && (ext->codes.major_opcode != event->request_code);
|
|
416 ext = ext->next)
|
|
417 ;
|
|
418 if (ext)
|
|
419 strcpy(buffer, ext->name);
|
|
420 else
|
|
421 buffer[0] = '\0';
|
|
422 }
|
183
|
423 fprintf(fp, " (%s)", buffer);
|
0
|
424 fputs("\n ", fp);
|
|
425 #if (XtSpecificationRelease >= 5)
|
|
426 if (event->request_code >= 128) {
|
|
427 XGetErrorDatabaseText(dpy, mtype, "MinorCode", "Request Minor code %d",
|
|
428 mesg, BUFSIZ);
|
183
|
429 fprintf(fp, mesg, event->minor_code);
|
0
|
430 if (ext) {
|
|
431 sprintf(mesg, "%s.%d", ext->name, event->minor_code);
|
|
432 XGetErrorDatabaseText(dpy, "XRequest", mesg, "", buffer, BUFSIZ);
|
183
|
433 fprintf(fp, " (%s)", buffer);
|
0
|
434 }
|
|
435 fputs("\n ", fp);
|
|
436 }
|
|
437 if (event->error_code >= 128) {
|
|
438 /* let extensions try to print the values */
|
|
439 /* XXX this is non-portable code */
|
|
440 for (ext = dpy->ext_procs; ext; ext = ext->next) {
|
|
441 if (ext->error_values)
|
|
442 (*ext->error_values)(dpy, event, fp);
|
|
443 }
|
|
444 /* the rest is a fallback, providing a simple default */
|
|
445 /* kludge, try to find the extension that caused it */
|
|
446 buffer[0] = '\0';
|
|
447 for (ext = dpy->ext_procs; ext; ext = ext->next) {
|
183
|
448 if (ext->error_string)
|
0
|
449 (*ext->error_string)(dpy, event->error_code, &ext->codes,
|
|
450 buffer, BUFSIZ);
|
|
451 if (buffer[0])
|
|
452 break;
|
183
|
453 }
|
0
|
454 if (buffer[0])
|
|
455 sprintf(buffer, "%s.%d", ext->name,
|
|
456 event->error_code - ext->codes.first_error);
|
|
457 else
|
|
458 strcpy(buffer, "Value");
|
|
459 XGetErrorDatabaseText(dpy, mtype, buffer, "", mesg, BUFSIZ);
|
|
460 if (*mesg) {
|
183
|
461 fprintf(fp, mesg, event->resourceid);
|
0
|
462 fputs("\n ", fp);
|
|
463 }
|
|
464 } else if ((event->error_code == BadWindow) ||
|
|
465 (event->error_code == BadPixmap) ||
|
|
466 (event->error_code == BadCursor) ||
|
|
467 (event->error_code == BadFont) ||
|
|
468 (event->error_code == BadDrawable) ||
|
|
469 (event->error_code == BadColor) ||
|
|
470 (event->error_code == BadGC) ||
|
|
471 (event->error_code == BadIDChoice) ||
|
|
472 (event->error_code == BadValue) ||
|
|
473 (event->error_code == BadAtom)) {
|
|
474 if (event->error_code == BadValue)
|
|
475 XGetErrorDatabaseText(dpy, mtype, "Value", "Value 0x%x",
|
|
476 mesg, BUFSIZ);
|
|
477 else if (event->error_code == BadAtom)
|
|
478 XGetErrorDatabaseText(dpy, mtype, "AtomID", "AtomID 0x%x",
|
|
479 mesg, BUFSIZ);
|
|
480 else
|
|
481 XGetErrorDatabaseText(dpy, mtype, "ResourceID", "ResourceID 0x%x",
|
|
482 mesg, BUFSIZ);
|
183
|
483 fprintf(fp, mesg, event->resourceid);
|
0
|
484 fputs("\n ", fp);
|
|
485 }
|
|
486 #elif (XtSpecificationRelease == 4)
|
|
487 XGetErrorDatabaseText(dpy, mtype, "MinorCode", "Request Minor code %d",
|
|
488 mesg, BUFSIZ);
|
183
|
489 fprintf(fp, mesg, event->minor_code);
|
0
|
490 fputs("\n ", fp);
|
|
491 if (ext) {
|
|
492 sprintf(mesg, "%s.%d", ext->name, event->minor_code);
|
|
493 XGetErrorDatabaseText(dpy, "XRequest", mesg, "", buffer, BUFSIZ);
|
183
|
494 fprintf(fp, " (%s)", buffer);
|
0
|
495 }
|
|
496 XGetErrorDatabaseText(dpy, mtype, "ResourceID", "ResourceID 0x%x",
|
|
497 mesg, BUFSIZ);
|
183
|
498 fprintf(fp, mesg, event->resourceid);
|
0
|
499 fputs("\n ", fp);
|
|
500 #else
|
|
501 ERROR! Unsupported release of X11
|
|
502 #endif
|
183
|
503 XGetErrorDatabaseText(dpy, mtype, "ErrorSerial", "Error Serial #%d",
|
0
|
504 mesg, BUFSIZ);
|
183
|
505 fprintf(fp, mesg, event->serial);
|
0
|
506 fputs("\n ", fp);
|
|
507 XGetErrorDatabaseText(dpy, mtype, "CurrentSerial", "Current Serial #%d",
|
|
508 mesg, BUFSIZ);
|
183
|
509 fprintf(fp, mesg, NextRequest(dpy)-1);
|
0
|
510 fputs("\n", fp);
|
|
511 if (event->error_code == BadImplementation) return 0;
|
|
512 return 1;
|
|
513 }
|
|
514
|
|
515
|
|
516 /*
|
|
517 * XmuSimpleErrorHandler - ignore errors for XQueryTree, XGetWindowAttributes,
|
|
518 * and XGetGeometry; print a message for everything else. In all case, do
|
|
519 * not exit.
|
|
520 */
|
74
|
521 int XmuSimpleErrorHandler (Display *dpy, XErrorEvent *errorp)
|
0
|
522 {
|
|
523 switch (errorp->request_code) {
|
|
524 case X_QueryTree:
|
|
525 case X_GetWindowAttributes:
|
|
526 if (errorp->error_code == BadWindow) return 0;
|
|
527 break;
|
|
528 case X_GetGeometry:
|
|
529 if (errorp->error_code == BadDrawable) return 0;
|
|
530 break;
|
|
531 }
|
|
532 /* got a "real" X error */
|
|
533 return XmuPrintDefaultErrorMessage (dpy, errorp, stderr);
|
183
|
534 }
|
0
|
535
|
185
|
536 void XmuCopyISOLatin1Lowered(char *dst, CONST char *src)
|
0
|
537 {
|
169
|
538 unsigned char *dest = (unsigned char *) dst;
|
|
539 unsigned char *source = (unsigned char *) src;
|
0
|
540
|
169
|
541 for ( ; *source; source++, dest++)
|
0
|
542 {
|
|
543 if ((*source >= XK_A) && (*source <= XK_Z))
|
|
544 *dest = *source + (XK_a - XK_A);
|
|
545 else if ((*source >= XK_Agrave) && (*source <= XK_Odiaeresis))
|
|
546 *dest = *source + (XK_agrave - XK_Agrave);
|
|
547 else if ((*source >= XK_Ooblique) && (*source <= XK_Thorn))
|
|
548 *dest = *source + (XK_oslash - XK_Ooblique);
|
|
549 else
|
|
550 *dest = *source;
|
|
551 }
|
|
552 *dest = '\0';
|
|
553 }
|
|
554 #endif /* !HAVE_XMU */
|