1: #include <X/mit-copyright.h>
2:
3: /* $Header: XParseColor.c,v 10.4 86/02/01 15:37:40 tony Rel $ */
4: /* Copyright Massachusetts Institute of Technology 1985 */
5:
6: #include "XlibInternal.h"
7:
8: Status XParseColor (spec, def)
9: register char *spec;
10: Color *def;
11: {
12: register Display *dpy;
13: register XReq *req;
14: XRep rep;
15: register int n, i;
16: int r, g, b;
17: char c;
18:
19: n = strlen (spec);
20: if (*spec != '#') {
21: GetReq (X_LookupColor, 0);
22: req->param.s[0] = n;
23: Data (dpy, spec, n);
24: if (!_XReply (dpy, &rep))
25: return (0);
26: def->red = rep.param.u[0];
27: def->green = rep.param.u[1];
28: def->blue = rep.param.u[2];
29: return (1);
30: }
31: spec++;
32: n--;
33: if (n != 3 && n != 6 && n != 9 && n != 12)
34: return (0);
35: n /= 3;
36: r = g = b = 0;
37: do {
38: r = g;
39: g = b;
40: b = 0;
41: for (i = n; --i >= 0; ) {
42: c = *spec++;
43: b <<= 4;
44: if (c >= '0' && c <= '9')
45: b |= c - '0';
46: else if (c >= 'A' && c <= 'F')
47: b |= c - ('A' - 10);
48: else if (c >= 'a' && c <= 'f')
49: b |= c - ('a' - 10);
50: else return (0);
51: }
52: } while (*spec);
53: n <<= 2;
54: n = 16 - n;
55: def->red = r << n;
56: def->green = g << n;
57: def->blue = b << n;
58: return (1);
59: }
Defined functions
XParseColor
defined in line
8; used 74 times
- in /usr/src/new/X/XMenu/XMenuCreate.c line
201,
214,
246,
259,
288,
301
- in /usr/src/new/X/Xlib/XCreate.c line
109-125(5)
- in /usr/src/new/X/Xlib/XCreateTerm.c line
121-137(5)
- in /usr/src/new/X/Xlib/Xlib.h line
364
- in /usr/src/new/X/bitmap/bitmap.c line
235-237(3),
255-258(2)
- in /usr/src/new/X/comsat/comsat.c line
451-460(4)
- in /usr/src/new/X/hacks/maze/maze.c line
126-132(3)
- in /usr/src/new/X/libnest/nest.c line
65
- in /usr/src/new/X/pikapix/pikapix.c line
266
- in /usr/src/new/X/uwm/Menu.c line
473-475(2),
488-490(2),
504-506(2)
- in /usr/src/new/X/xclock/xclock.c line
256,
272,
288,
304
- in /usr/src/new/X/xdvi/dv.c line
248-262(5)
- in /usr/src/new/X/xfd/xfd.c line
118,
129,
141
- in /usr/src/new/X/xgedit/gx.c line
326-332(3)
- in /usr/src/new/X/ximpv/impv.c line
354-365(4)
- in /usr/src/new/X/xload/xload.c line
304,
315,
327,
339
- in /usr/src/new/X/xset/xset.c line
187
- in /usr/src/new/X/xsetroot/xsetroot.c line
220,
229,
238,
247
- in /usr/src/new/X/xshell/xshell.c line
309
- in /usr/src/new/X/xterm/main.c line
711,
730,
742,
751,
757-762(2),
785,
794