Utah Raster Toolkit  9999-git
URT Development version (post-3.1b)
XGetHClrs.c
Go to the documentation of this file.
1 #ifndef XLIBINT_H_NOT_AVAILABLE
2 
3 /* $XConsortium: XGetHClrs.c,v 11.10 88/09/06 16:07:50 martin Exp $ */
4 /* Copyright Massachusetts Institute of Technology 1986 */
5 
6 #include <X11/X.h>
7 #include <X11/Xlib.h>
8 #include <X11/Xutil.h>
9 #define NEED_REPLIES
10 #include <X11/Xlibint.h>
11 
12 static int counter;
13 static Status *st;
14 static Status status;
15 
16 static int dummy_handle_x_errors( dpy, event)
17  Display *dpy;
18  XErrorEvent *event;
19 {
20  st[counter++] = 0;
21  status = False;
22  return 0;
23 }
24 
25 
27 register Display *dpy;
28 Colormap cmap;
29 XColor *defs;
30 int ndefs;
31 Status *statuses;
32 {
33  xAllocColorReply rep;
34  register xAllocColorReq *req;
35  int (*function)();
36  int i;
37  Status return_status;
38 
39  XSync(dpy, False);
40 
41  function = XSetErrorHandler( dummy_handle_x_errors );
42  st = statuses;
43 
44  LockDisplay(dpy);
45 
46  for (i = 0; i < ndefs; i++)
47  {
48  GetReq(AllocColor, req);
49 
50  req->cmap = cmap;
51  req->red = defs[i].red;
52  req->green = defs[i].green;
53  req->blue = defs[i].blue;
54  }
55 
56  status = True;
57  for (counter = 0; counter < ndefs; counter++)
58  {
59  statuses[counter] = _XReply(dpy, (xReply *) &rep, 0, xTrue);
60  if (statuses[counter]) {
61  defs[counter].pixel = rep.pixel;
62  defs[counter].red = rep.red;
63  defs[counter].green = rep.green;
64  defs[counter].blue = rep.blue;
65  }
66  else
67  status = False;
68  }
69  return_status = status;
70 
71  UnlockDisplay(dpy);
72  SyncHandle();
73 
74  XSetErrorHandler( function );
75 
76  return(return_status);
77 }
78 #endif /* !XLIBINT_H_NOT_AVAILABLE */
static int status
Definition: XGetHClrs.c:14
static int * st
Definition: XGetHClrs.c:13
static int counter
Definition: XGetHClrs.c:12
int XAllocColors(register Display *dpy, Colormap cmap, XColor *defs, int ndefs, int *statuses)