1 /*
2  * Copyright © 2001 Keith Packard, member of The XFree86 Project, Inc.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice (including the next
12  * paragraph) shall be included in all copies or substantial portions of the
13  * Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21  * DEALINGS IN THE SOFTWARE.
22  */
23 
24 #include "scope.h"
25 #include "x11.h"
26 #include "shmscope.h"
27 
28 void
MitshmQueryVersion(FD fd,const unsigned char * buf)29 MitshmQueryVersion(FD fd, const unsigned char *buf)
30 {
31     PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* MitshmRequest */
32     PrintField(buf, 1, 1, MITSHMREQUEST,
33                MITSHMREQUESTHEADER); /* MitshmSwitch */
34     if (Verbose < 1)
35         return;
36     if (Verbose > 1)
37         PrintField(SBf, 0, 4, CARD32, "sequence number");
38 
39     printreqlen(buf, fd, CONST2(2));
40 }
41 
42 void
MitshmQueryVersionReply(FD fd,const unsigned char * buf)43 MitshmQueryVersionReply(FD fd, const unsigned char *buf)
44 {
45     PrintField(RBf, 0, 1, REPLY, REPLYHEADER); /* MitshmRequest reply */
46     if (Verbose < 1)
47         return;
48     PrintField(RBf, 1, 1, BOOL, "shared-pixmaps"); /* shared Pixmaps */
49     printfield(buf, 2, 2, CARD16, "sequence number");
50     printfield(buf, 4, 4, DVALUE4(0), "reply length");
51     PrintField(buf, 8, 2, CARD16, "major-version");
52     PrintField(buf, 10, 2, CARD16, "minor-version");
53     PrintField(buf, 12, 2, CARD16, "uid");
54     PrintField(buf, 14, 2, CARD16, "gid");
55     PrintField(buf, 16, 1, CARD8, "pixmap-format");
56 }
57 
58 void
MitshmAttach(FD fd,const unsigned char * buf)59 MitshmAttach(FD fd, const unsigned char *buf)
60 {
61     PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* MitshmRequest */
62     PrintField(buf, 1, 1, MITSHMREQUEST,
63                MITSHMREQUESTHEADER); /* MitshmSwitch */
64     if (Verbose < 1)
65         return;
66     if (Verbose > 1)
67         PrintField(SBf, 0, 4, CARD32, "sequence number");
68 
69     printreqlen(buf, fd, CONST2(2));
70     PrintField(buf, 4, 4, CARD32, "shmseg");
71     PrintField(buf, 8, 4, CARD32, "shmid");
72     PrintField(buf, 12, 1, BOOL, "read-only");
73 }
74 
75 void
MitshmDetach(FD fd,const unsigned char * buf)76 MitshmDetach(FD fd, const unsigned char *buf)
77 {
78     PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* MitshmRequest */
79     PrintField(buf, 1, 1, MITSHMREQUEST,
80                MITSHMREQUESTHEADER); /* MitshmSwitch */
81     if (Verbose < 1)
82         return;
83     if (Verbose > 1)
84         PrintField(SBf, 0, 4, CARD32, "sequence number");
85 
86     printreqlen(buf, fd, CONST2(2));
87     PrintField(buf, 4, 4, CARD32, "shmseg");
88 }
89 
90 void
MitshmPutImage(FD fd,const unsigned char * buf)91 MitshmPutImage(FD fd, const unsigned char *buf)
92 {
93     PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* MitshmRequest */
94     PrintField(buf, 1, 1, MITSHMREQUEST,
95                MITSHMREQUESTHEADER); /* MitshmSwitch */
96     if (Verbose < 1)
97         return;
98     if (Verbose > 1)
99         PrintField(SBf, 0, 4, CARD32, "sequence number");
100 
101     printreqlen(buf, fd, CONST2(2));
102     PrintField(buf, 4, 4, DRAWABLE, "drawable");
103     PrintField(buf, 8, 4, GCONTEXT, "gc");
104     PrintField(buf, 12, 2, CARD16, "total-width");
105     PrintField(buf, 14, 2, CARD16, "total-height");
106     PrintField(buf, 16, 2, CARD16, "src-x");
107     PrintField(buf, 18, 2, CARD16, "src-y");
108     PrintField(buf, 20, 2, CARD16, "src-width");
109     PrintField(buf, 22, 2, CARD16, "src-height");
110     PrintField(buf, 24, 2, INT16, "dst-x");
111     PrintField(buf, 26, 2, INT16, "dst-y");
112     PrintField(buf, 28, 1, CARD8, "depth");
113     PrintField(buf, 29, 1, CARD8, "format");
114     PrintField(buf, 30, 1, BOOL, "send-event");
115     PrintField(buf, 31, 1, CARD8, "bpad");
116     PrintField(buf, 32, 4, CARD32, "shmseg");
117     PrintField(buf, 36, 4, CARD32, "offset");
118 }
119 
120 void
MitshmGetImage(FD fd,const unsigned char * buf)121 MitshmGetImage(FD fd, const unsigned char *buf)
122 {
123     PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* MitshmRequest */
124     PrintField(buf, 1, 1, MITSHMREQUEST,
125                MITSHMREQUESTHEADER); /* MitshmSwitch */
126     if (Verbose < 1)
127         return;
128     if (Verbose > 1)
129         PrintField(SBf, 0, 4, CARD32, "sequence number");
130 
131     printreqlen(buf, fd, DVALUE2(5 + n));
132     PrintField(buf, 4, 4, DRAWABLE, "drawable");
133     PrintField(buf, 8, 2, INT16, "x");
134     PrintField(buf, 10, 2, INT16, "y");
135     PrintField(buf, 12, 2, CARD16, "width");
136     PrintField(buf, 14, 2, CARD16, "height");
137     PrintField(buf, 16, 4, CARD32, "planemask");
138     PrintField(buf, 20, 1, CARD8, "format");
139     PrintField(buf, 24, 4, CARD32, "shmseg");
140     PrintField(buf, 28, 4, CARD32, "offset");
141 }
142 
143 void
MitshmGetImageReply(FD fd,const unsigned char * buf)144 MitshmGetImageReply(FD fd, const unsigned char *buf)
145 {
146     PrintField(RBf, 0, 1, REPLY, REPLYHEADER); /* MitshmRequest reply */
147     if (Verbose < 1)
148         return;
149     PrintField(RBf, 1, 1, CARD8, "depth"); /* shared Pixmaps */
150     printfield(buf, 2, 2, CARD16, "sequence number");
151     printfield(buf, 4, 4, DVALUE4(0), "reply length");
152     PrintField(buf, 8, 4, VISUALID, "visual");
153 }
154 
155 void
MitshmCreatePixmap(FD fd,const unsigned char * buf)156 MitshmCreatePixmap(FD fd, const unsigned char *buf)
157 {
158     PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* MitshmRequest */
159     PrintField(buf, 1, 1, MITSHMREQUEST,
160                MITSHMREQUESTHEADER); /* MitshmSwitch */
161     if (Verbose < 1)
162         return;
163     if (Verbose > 1)
164         PrintField(SBf, 0, 4, CARD32, "sequence number");
165 
166     printreqlen(buf, fd, DVALUE2(3 + n));
167     PrintField(buf, 4, 4, PIXMAP, "pid");
168     PrintField(buf, 8, 4, DRAWABLE, "drawable");
169     PrintField(buf, 12, 2, CARD16, "width");
170     PrintField(buf, 14, 2, CARD16, "height");
171     PrintField(buf, 16, 1, CARD8, "depth");
172     PrintField(buf, 20, 4, CARD32, "shmseg");
173     PrintField(buf, 24, 4, CARD32, "offset");
174 }
175 
176 void
MitshmShmSegError(FD fd,const unsigned char * buf)177 MitshmShmSegError(FD fd, const unsigned char *buf)
178 {
179 }
180