2 * Copyright © 2011 Intel Corporation
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:
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
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.
23 #ifdef HAVE_DIX_CONFIG_H
24 #include <dix-config.h>
27 #include "glxserver.h"
28 #include "indirect_dispatch.h"
29 #include "glxbyteorder.h"
33 set_client_info(__GLXclientState
* cl
, xGLXSetClientInfoARBReq
* req
,
34 unsigned bytes_per_version
)
39 /* Verify that the size of the packet matches the size inferred from the
40 * sizes specified for the various fields.
42 const unsigned expected_size
= sz_xGLXSetClientInfoARBReq
43 + (req
->numVersions
* bytes_per_version
)
44 + __GLX_PAD(req
->numGLExtensionBytes
)
45 + __GLX_PAD(req
->numGLXExtensionBytes
);
47 if (req
->length
!= (expected_size
/ 4))
50 /* Verify that the actual length of the GL extension string matches what's
51 * encoded in protocol packet.
53 gl_extensions
= (char *) (req
+ 1) + (req
->numVersions
* bytes_per_version
);
54 if (req
->numGLExtensionBytes
!= 0
55 && memchr(gl_extensions
, 0,
56 __GLX_PAD(req
->numGLExtensionBytes
)) == NULL
)
59 /* Verify that the actual length of the GLX extension string matches
60 * what's encoded in protocol packet.
62 glx_extensions
= gl_extensions
+ __GLX_PAD(req
->numGLExtensionBytes
);
63 if (req
->numGLXExtensionBytes
!= 0
64 && memchr(glx_extensions
, 0,
65 __GLX_PAD(req
->numGLXExtensionBytes
)) == NULL
)
68 free(cl
->GLClientextensions
);
69 cl
->GLClientextensions
= strdup(gl_extensions
);
75 __glXDisp_SetClientInfoARB(__GLXclientState
* cl
, GLbyte
* pc
)
77 return set_client_info(cl
, (xGLXSetClientInfoARBReq
*) pc
, 8);
81 __glXDispSwap_SetClientInfoARB(__GLXclientState
* cl
, GLbyte
* pc
)
83 xGLXSetClientInfoARBReq
*req
= (xGLXSetClientInfoARBReq
*) pc
;
85 req
->length
= bswap_16(req
->length
);
86 req
->numVersions
= bswap_32(req
->numVersions
);
87 req
->numGLExtensionBytes
= bswap_32(req
->numGLExtensionBytes
);
88 req
->numGLXExtensionBytes
= bswap_32(req
->numGLXExtensionBytes
);
90 return __glXDisp_SetClientInfoARB(cl
, pc
);
94 __glXDisp_SetClientInfo2ARB(__GLXclientState
* cl
, GLbyte
* pc
)
96 return set_client_info(cl
, (xGLXSetClientInfoARBReq
*) pc
, 12);
100 __glXDispSwap_SetClientInfo2ARB(__GLXclientState
* cl
, GLbyte
* pc
)
102 xGLXSetClientInfoARBReq
*req
= (xGLXSetClientInfoARBReq
*) pc
;
104 req
->length
= bswap_16(req
->length
);
105 req
->numVersions
= bswap_32(req
->numVersions
);
106 req
->numGLExtensionBytes
= bswap_32(req
->numGLExtensionBytes
);
107 req
->numGLXExtensionBytes
= bswap_32(req
->numGLXExtensionBytes
);
109 return __glXDisp_SetClientInfo2ARB(cl
, pc
);