Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
5563 | serge | 1 | /* |
2 | * (C) Copyright IBM Corporation 2004 |
||
3 | * All Rights Reserved. |
||
4 | * |
||
5 | * Permission is hereby granted, free of charge, to any person obtaining a |
||
6 | * copy of this software and associated documentation files (the "Software"), |
||
7 | * to deal in the Software without restriction, including without limitation |
||
8 | * on the rights to use, copy, modify, merge, publish, distribute, sub |
||
9 | * license, and/or sell copies of the Software, and to permit persons to whom |
||
10 | * the Software is furnished to do so, subject to the following conditions: |
||
11 | * |
||
12 | * The above copyright notice and this permission notice (including the next |
||
13 | * paragraph) shall be included in all copies or substantial portions of the |
||
14 | * Software. |
||
15 | * |
||
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL |
||
19 | * IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
||
21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
||
22 | * DEALINGS IN THE SOFTWARE. |
||
23 | */ |
||
24 | |||
25 | /** |
||
26 | * \file glx_query.c |
||
27 | * Generic utility functions to query internal data from the server. |
||
28 | * |
||
29 | * \author Ian Romanick |
||
30 | */ |
||
31 | |||
32 | #include "glxclient.h" |
||
33 | |||
34 | # include |
||
35 | # include |
||
36 | # include |
||
37 | |||
38 | |||
39 | /** |
||
40 | * Exchange a protocol request for glXQueryServerString. |
||
41 | */ |
||
42 | char * |
||
43 | __glXQueryServerString(Display * dpy, int opcode, CARD32 screen, CARD32 name) |
||
44 | { |
||
45 | xcb_connection_t *c = XGetXCBConnection(dpy); |
||
46 | xcb_glx_query_server_string_reply_t *reply = |
||
47 | xcb_glx_query_server_string_reply(c, |
||
48 | xcb_glx_query_server_string(c, |
||
49 | screen, |
||
50 | name), |
||
51 | NULL); |
||
52 | |||
53 | /* The spec doesn't mention this, but the Xorg server replies with |
||
54 | * a string already terminated with '\0'. */ |
||
55 | uint32_t len = xcb_glx_query_server_string_string_length(reply); |
||
56 | char *buf = malloc(len); |
||
57 | memcpy(buf, xcb_glx_query_server_string_string(reply), len); |
||
58 | free(reply); |
||
59 | |||
60 | return buf; |
||
61 | } |
||
62 | |||
63 | /** |
||
64 | * Exchange a protocol request for glGetString. |
||
65 | */ |
||
66 | char * |
||
67 | __glXGetString(Display * dpy, int opcode, CARD32 contextTag, CARD32 name) |
||
68 | { |
||
69 | xcb_connection_t *c = XGetXCBConnection(dpy); |
||
70 | xcb_glx_get_string_reply_t *reply = xcb_glx_get_string_reply(c, |
||
71 | xcb_glx_get_string |
||
72 | (c, |
||
73 | contextTag, |
||
74 | name), |
||
75 | NULL); |
||
76 | |||
77 | /* The spec doesn't mention this, but the Xorg server replies with |
||
78 | * a string already terminated with '\0'. */ |
||
79 | uint32_t len = xcb_glx_get_string_string_length(reply); |
||
80 | char *buf = malloc(len); |
||
81 | memcpy(buf, xcb_glx_get_string_string(reply), len); |
||
82 | free(reply); |
||
83 | |||
84 | return buf; |
||
85 | } |
||
86 |