comparison src/xmu.c @ 16:0293115a14e9 r19-15b91

Import from CVS: tag r19-15b91
author cvs
date Mon, 13 Aug 2007 08:49:20 +0200
parents 376386a54a3c
children 56c54cf7c5b6
comparison
equal deleted inserted replaced
15:ad457d5f7d04 16:0293115a14e9
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() 177 static void initHexTable (void)
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.
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 (fstream) 210 static int NextInt (FILE *fstream)
211 FILE *fstream;
212 { 211 {
213 int ch; 212 int ch;
214 int value = 0; 213 int value = 0;
215 int gotone = 0; 214 int gotone = 0;
216 int done = 0; 215 int done = 0;
241 * The data returned by the following routine is always in left-most byte 240 * The data returned by the following routine is always in left-most byte
242 * first and left-most bit first. If it doesn't return BitmapSuccess then 241 * first and left-most bit first. If it doesn't return BitmapSuccess then
243 * its arguments won't have been touched. This routine should look as much 242 * its arguments won't have been touched. This routine should look as much
244 * like the Xlib routine XReadBitmapfile as possible. 243 * like the Xlib routine XReadBitmapfile as possible.
245 */ 244 */
246 int XmuReadBitmapData (fstream, width, height, datap, x_hot, y_hot) 245 int XmuReadBitmapData (
247 FILE *fstream; /* handle on file */ 246 FILE *fstream, /* handle on file */
248 unsigned int *width, *height; /* RETURNED */ 247 unsigned int *width, /* RETURNED */
249 unsigned char **datap; /* RETURNED */ 248 unsigned int *height, /* RETURNED */
250 int *x_hot, *y_hot; /* RETURNED */ 249 unsigned char **datap, /* 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 */
367 367
368 RETURN (BitmapSuccess); 368 RETURN (BitmapSuccess);
369 } 369 }
370 370
371 371
372 #if NeedFunctionPrototypes 372 int XmuReadBitmapDataFromFile (const char *filename,
373 int XmuReadBitmapDataFromFile (const char *filename, unsigned int *width, 373 /* Remaining args are RETURNED */
374 unsigned int *height, unsigned char **datap, 374 unsigned int *width,
375 unsigned int *height,
376 unsigned char **datap,
375 int *x_hot, int *y_hot) 377 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
383 { 378 {
384 FILE *fstream; 379 FILE *fstream;
385 int status; 380 int status;
386 381
387 if ((fstream = fopen (filename, "r")) == NULL) { 382 if ((fstream = fopen (filename, "r")) == NULL) {
394 389
395 /* 390 /*
396 * XmuPrintDefaultErrorMessage - print a nice error that looks like the usual 391 * XmuPrintDefaultErrorMessage - print a nice error that looks like the usual
397 * message. Returns 1 if the caller should consider exitting else 0. 392 * message. Returns 1 if the caller should consider exitting else 0.
398 */ 393 */
399 int XmuPrintDefaultErrorMessage (dpy, event, fp) 394 int XmuPrintDefaultErrorMessage (Display *dpy, XErrorEvent *event, FILE *fp)
400 Display *dpy;
401 XErrorEvent *event;
402 FILE *fp;
403 { 395 {
404 char buffer[BUFSIZ]; 396 char buffer[BUFSIZ];
405 char mesg[BUFSIZ]; 397 char mesg[BUFSIZ];
406 char number[32]; 398 char number[32];
407 char *mtype = "XlibMessage"; 399 char *mtype = "XlibMessage";
522 /* 514 /*
523 * XmuSimpleErrorHandler - ignore errors for XQueryTree, XGetWindowAttributes, 515 * XmuSimpleErrorHandler - ignore errors for XQueryTree, XGetWindowAttributes,
524 * and XGetGeometry; print a message for everything else. In all case, do 516 * and XGetGeometry; print a message for everything else. In all case, do
525 * not exit. 517 * not exit.
526 */ 518 */
527 int XmuSimpleErrorHandler (dpy, errorp) 519 int XmuSimpleErrorHandler (Display *dpy, XErrorEvent *errorp)
528 Display *dpy;
529 XErrorEvent *errorp;
530 { 520 {
531 switch (errorp->request_code) { 521 switch (errorp->request_code) {
532 case X_QueryTree: 522 case X_QueryTree:
533 case X_GetWindowAttributes: 523 case X_GetWindowAttributes:
534 if (errorp->error_code == BadWindow) return 0; 524 if (errorp->error_code == BadWindow) return 0;