Mercurial > hg > xemacs-beta
comparison src/xmu.c @ 70:131b0175ea99 r20-0b30
Import from CVS: tag r20-0b30
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:02:59 +0200 |
parents | 56c54cf7c5b6 |
children | 54cc21c15cbb |
comparison
equal
deleted
inserted
replaced
69:804d1389bcd6 | 70:131b0175ea99 |
---|---|
165 | 165 |
166 #define MAX_SIZE 255 | 166 #define MAX_SIZE 255 |
167 | 167 |
168 /* shared data for the image read/parse logic */ | 168 /* shared data for the image read/parse logic */ |
169 static short hexTable[256]; /* conversion value */ | 169 static short hexTable[256]; /* conversion value */ |
170 static int hex_initialized; /* easier to fill in at run time */ | 170 static Bool initialized = False; /* easier to fill in at run time */ |
171 | 171 |
172 | 172 |
173 /* | 173 /* |
174 * Table index for the hex values. Initialized once, first time. | 174 * Table index for the hex values. Initialized once, first time. |
175 * Used for translation value or delimiter significance lookup. | 175 * Used for translation value or delimiter significance lookup. |
176 */ | 176 */ |
177 static void initHexTable (void) | 177 static void initHexTable() |
178 { | 178 { |
179 /* | 179 /* |
180 * We build the table at run time for several reasons: | 180 * We build the table at run time for several reasons: |
181 * | 181 * |
182 * 1. portable to non-ASCII machines. | 182 * 1. portable to non-ASCII machines. |
199 /* delimiters of significance are flagged w/ negative value */ | 199 /* delimiters of significance are flagged w/ negative value */ |
200 hexTable[' '] = -1; hexTable[','] = -1; | 200 hexTable[' '] = -1; hexTable[','] = -1; |
201 hexTable['}'] = -1; hexTable['\n'] = -1; | 201 hexTable['}'] = -1; hexTable['\n'] = -1; |
202 hexTable['\t'] = -1; | 202 hexTable['\t'] = -1; |
203 | 203 |
204 hex_initialized = 1; | 204 initialized = True; |
205 } | 205 } |
206 | 206 |
207 /* | 207 /* |
208 * read next hex value in the input stream, return -1 if EOF | 208 * read next hex value in the input stream, return -1 if EOF |
209 */ | 209 */ |
210 static int NextInt (FILE *fstream) | 210 static int NextInt (fstream) |
211 FILE *fstream; | |
211 { | 212 { |
212 int ch; | 213 int ch; |
213 int value = 0; | 214 int value = 0; |
214 int gotone = 0; | 215 int gotone = 0; |
215 int done = 0; | 216 int done = 0; |
240 * The data returned by the following routine is always in left-most byte | 241 * The data returned by the following routine is always in left-most byte |
241 * first and left-most bit first. If it doesn't return BitmapSuccess then | 242 * first and left-most bit first. If it doesn't return BitmapSuccess then |
242 * its arguments won't have been touched. This routine should look as much | 243 * its arguments won't have been touched. This routine should look as much |
243 * like the Xlib routine XReadBitmapfile as possible. | 244 * like the Xlib routine XReadBitmapfile as possible. |
244 */ | 245 */ |
245 int XmuReadBitmapData ( | 246 int XmuReadBitmapData (fstream, width, height, datap, x_hot, y_hot) |
246 FILE *fstream, /* handle on file */ | 247 FILE *fstream; /* handle on file */ |
247 unsigned int *width, /* RETURNED */ | 248 unsigned int *width, *height; /* RETURNED */ |
248 unsigned int *height, /* RETURNED */ | 249 unsigned char **datap; /* RETURNED */ |
249 unsigned char **datap, /* RETURNED */ | 250 int *x_hot, *y_hot; /* RETURNED */ |
250 int *x_hot, int *y_hot) /* RETURNED */ | |
251 { | 251 { |
252 unsigned char *data = NULL; /* working variable */ | 252 unsigned char *data = NULL; /* working variable */ |
253 char line[MAX_SIZE]; /* input line from file */ | 253 char line[MAX_SIZE]; /* input line from file */ |
254 int size; /* number of bytes of data */ | 254 int size; /* number of bytes of data */ |
255 char name_and_type[MAX_SIZE]; /* an input line */ | 255 char name_and_type[MAX_SIZE]; /* an input line */ |
266 #ifndef Xmalloc | 266 #ifndef Xmalloc |
267 #define Xmalloc(size) malloc(size) | 267 #define Xmalloc(size) malloc(size) |
268 #endif | 268 #endif |
269 | 269 |
270 /* first time initialization */ | 270 /* first time initialization */ |
271 if (!hex_initialized) initHexTable(); | 271 if (initialized == False) initHexTable(); |
272 | 272 |
273 /* error cleanup and return macro */ | 273 /* error cleanup and return macro */ |
274 #define RETURN(code) { if (data) free (data); return code; } | 274 #define RETURN(code) { if (data) free (data); return code; } |
275 | 275 |
276 while (fgets(line, MAX_SIZE, fstream)) { | 276 while (fgets(line, MAX_SIZE, fstream)) { |
367 | 367 |
368 RETURN (BitmapSuccess); | 368 RETURN (BitmapSuccess); |
369 } | 369 } |
370 | 370 |
371 | 371 |
372 int XmuReadBitmapDataFromFile (const char *filename, | 372 #if NeedFunctionPrototypes |
373 /* Remaining args are RETURNED */ | 373 int XmuReadBitmapDataFromFile (const char *filename, unsigned int *width, |
374 unsigned int *width, | 374 unsigned int *height, unsigned char **datap, |
375 unsigned int *height, | |
376 unsigned char **datap, | |
377 int *x_hot, int *y_hot) | 375 int *x_hot, int *y_hot) |
376 #else | |
377 int XmuReadBitmapDataFromFile (filename, width, height, datap, x_hot, y_hot) | |
378 char *filename; | |
379 unsigned int *width, *height; /* RETURNED */ | |
380 unsigned char **datap; /* RETURNED */ | |
381 int *x_hot, *y_hot; /* RETURNED */ | |
382 #endif | |
378 { | 383 { |
379 FILE *fstream; | 384 FILE *fstream; |
380 int status; | 385 int status; |
381 | 386 |
382 if ((fstream = fopen (filename, "r")) == NULL) { | 387 if ((fstream = fopen (filename, "r")) == NULL) { |
389 | 394 |
390 /* | 395 /* |
391 * XmuPrintDefaultErrorMessage - print a nice error that looks like the usual | 396 * XmuPrintDefaultErrorMessage - print a nice error that looks like the usual |
392 * message. Returns 1 if the caller should consider exitting else 0. | 397 * message. Returns 1 if the caller should consider exitting else 0. |
393 */ | 398 */ |
394 int XmuPrintDefaultErrorMessage (Display *dpy, XErrorEvent *event, FILE *fp) | 399 int XmuPrintDefaultErrorMessage (dpy, event, fp) |
400 Display *dpy; | |
401 XErrorEvent *event; | |
402 FILE *fp; | |
395 { | 403 { |
396 char buffer[BUFSIZ]; | 404 char buffer[BUFSIZ]; |
397 char mesg[BUFSIZ]; | 405 char mesg[BUFSIZ]; |
398 char number[32]; | 406 char number[32]; |
399 char *mtype = "XlibMessage"; | 407 char *mtype = "XlibMessage"; |
514 /* | 522 /* |
515 * XmuSimpleErrorHandler - ignore errors for XQueryTree, XGetWindowAttributes, | 523 * XmuSimpleErrorHandler - ignore errors for XQueryTree, XGetWindowAttributes, |
516 * and XGetGeometry; print a message for everything else. In all case, do | 524 * and XGetGeometry; print a message for everything else. In all case, do |
517 * not exit. | 525 * not exit. |
518 */ | 526 */ |
519 int XmuSimpleErrorHandler (Display *dpy, XErrorEvent *errorp) | 527 int XmuSimpleErrorHandler (dpy, errorp) |
528 Display *dpy; | |
529 XErrorEvent *errorp; | |
520 { | 530 { |
521 switch (errorp->request_code) { | 531 switch (errorp->request_code) { |
522 case X_QueryTree: | 532 case X_QueryTree: |
523 case X_GetWindowAttributes: | 533 case X_GetWindowAttributes: |
524 if (errorp->error_code == BadWindow) return 0; | 534 if (errorp->error_code == BadWindow) return 0; |