/*1* (C) Copyright IBM Corporation 20042* All Rights Reserved.3*4* Permission is hereby granted, free of charge, to any person obtaining a5* copy of this software and associated documentation files (the "Software"),6* to deal in the Software without restriction, including without limitation7* on the rights to use, copy, modify, merge, publish, distribute, sub8* license, and/or sell copies of the Software, and to permit persons to whom9* the Software is furnished to do so, subject to the following conditions:10*11* The above copyright notice and this permission notice (including the next12* paragraph) shall be included in all copies or substantial portions of the13* Software.14*15* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR16* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,17* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL18* IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER19* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING20* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER21* DEALINGS IN THE SOFTWARE.22*/2324/**25* \file glx_query.c26* Generic utility functions to query internal data from the server.27*28* \author Ian Romanick <[email protected]>29*/3031#include "glxclient.h"3233# include <X11/Xlib-xcb.h>34# include <xcb/xcb.h>35# include <xcb/glx.h>363738/**39* Exchange a protocol request for glXQueryServerString.40*/41char *42__glXQueryServerString(Display * dpy, CARD32 screen, CARD32 name)43{44xcb_connection_t *c = XGetXCBConnection(dpy);45xcb_glx_query_server_string_reply_t *reply =46xcb_glx_query_server_string_reply(c,47xcb_glx_query_server_string(c,48screen,49name),50NULL);5152if (!reply)53return NULL;5455/* The spec doesn't mention this, but the Xorg server replies with56* a string already terminated with '\0'. */57uint32_t len = xcb_glx_query_server_string_string_length(reply);58char *buf = malloc(len);59memcpy(buf, xcb_glx_query_server_string_string(reply), len);60free(reply);6162return buf;63}6465/**66* Exchange a protocol request for glGetString.67*/68char *69__glXGetString(Display * dpy, CARD32 contextTag, CARD32 name)70{71xcb_connection_t *c = XGetXCBConnection(dpy);72xcb_glx_get_string_reply_t *reply = xcb_glx_get_string_reply(c,73xcb_glx_get_string74(c,75contextTag,76name),77NULL);7879if (!reply)80return NULL;8182/* The spec doesn't mention this, but the Xorg server replies with83* a string already terminated with '\0'. */84uint32_t len = xcb_glx_get_string_string_length(reply);85char *buf = malloc(len);86memcpy(buf, xcb_glx_get_string_string(reply), len);87free(reply);8889return buf;90}91929394