|
|
1.1 root 1: #include <X/mit-copyright.h>
2:
3: /* $Header: XGetColCells.c,v 10.5 86/04/22 15:30:25 jg Rel $ */
4: /* Copyright Massachusetts Institute of Technology 1985 */
5:
6: #include "XlibInternal.h"
7: Status XGetColorCells (contig, ncolors, nplanes, planes, pixels)
8: int contig;
9: int ncolors;
10: int nplanes;
11: int *planes;
12: register int pixels[];
13: {
14: register Display *dpy;
15: register XReq *req;
16: XRep rep;
17:
18: GetReq (X_GetColorCells, 0);
19: req->func = contig;
20: req->params0 = ncolors;
21: req->params1 = nplanes;
22: if (!_XReply (dpy, &rep)) {
23: *planes = 0;
24: return (0);
25: }
26: *planes = rep.paramu0;
27: if (!ncolors)
28: return (1);
29:
30: /* "pixels" is an array of ints, but the protocol
31: * returns an array of shorts. Therefore data must be copied. */
32: {
33: register int i;
34: int nbytes = ncolors*2;
35: #ifdef BIGSHORTS
36: register ushort_p *proto_pixels = (ushort_p *) malloc (nbytes);
37: _XReadPad (dpy, (char *)proto_pixels, nbytes);
38: UnpackShorts(proto_pixels, (short *)pixels, nbytes);
39: #else
40: register u_short *proto_pixels = (u_short *) malloc (nbytes);
41: _XReadPad (dpy, proto_pixels, nbytes);
42: for (i=0;i<ncolors;i++)
43: pixels[i] = proto_pixels[i];
44: #endif
45: free ((char *)proto_pixels);
46: return (1);
47: }
48: }
49:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.