-static const char hex[128] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0,
- 0, 10,11,12,13,14,15,0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 10,11,12,13,14,15,0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
-
-static XImage *
-parse_xpm_data (Display *dpy, Visual *visual, Colormap colormap, int depth,
- unsigned long transparent_color,
- unsigned const char * const * data,
- int *width_ret, int *height_ret,
- unsigned long **pixels_ret, int *npixels_ret)
-{
- int w, h, ncolors, nbytes;
- char c;
- int i;
- struct {
- char byte;
- int cr; int cg; int cb;
- int mr; int mg; int mb;
- } cmap[256];
- unsigned char rmap[256];
-
- unsigned long *pixels;
- XImage *ximage = 0;
-
- if (4 != sscanf (*data, "%d %d %d %d %c", &w, &h, &ncolors, &nbytes, &c))
- abort();
- if (ncolors < 1 || ncolors > 255)
- abort();
- if (nbytes != 1)
- abort();
- data++;
- for (i = 0; i < ncolors; i++)
- {
- const unsigned char *line = *data;
- cmap[i].byte = *line++;
- while (*line)
- {
- int r, g, b;
- char which;
- while (*line == ' ' || *line == '\t')
- line++;
- which = *line++;
- if (which != 'c' && which != 'm')
- abort();
- while (*line == ' ' || *line == '\t')
- line++;
- if (!strncasecmp(line, "None", 4))
- {
- r = g = b = -1;
- line += 4;
- }
- else
- {
- if (*line == '#')
- line++;
- r = (hex[(int) line[0]] << 4) | hex[(int) line[1]]; line += 2;
- g = (hex[(int) line[0]] << 4) | hex[(int) line[1]]; line += 2;
- b = (hex[(int) line[0]] << 4) | hex[(int) line[1]]; line += 2;
- }