drirc: Add string support
[mesa.git] / src / mesa / drivers / dri / common / xmlconfig.h
1 /*
2 * XML DRI client-side driver configuration
3 * Copyright (C) 2003 Felix Kuehling
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 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included
13 * in all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * FELIX KUEHLING, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
21 * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 *
23 */
24 /**
25 * \file xmlconfig.h
26 * \brief Driver-independent client-side part of the XML configuration
27 * \author Felix Kuehling
28 */
29
30 #ifndef __XMLCONFIG_H
31 #define __XMLCONFIG_H
32
33 #include <stdbool.h>
34
35 #define STRING_CONF_MAXLEN 25
36
37 /** \brief Option data types */
38 typedef enum driOptionType {
39 DRI_BOOL, DRI_ENUM, DRI_INT, DRI_FLOAT, DRI_STRING
40 } driOptionType;
41
42 /** \brief Option value */
43 typedef union driOptionValue {
44 bool _bool; /**< \brief Boolean */
45 int _int; /**< \brief Integer or Enum */
46 float _float; /**< \brief Floating-point */
47 char *_string; /**< \brief String */
48 } driOptionValue;
49
50 /** \brief Single range of valid values
51 *
52 * For empty ranges (a single value) start == end */
53 typedef struct driOptionRange {
54 driOptionValue start; /**< \brief Start */
55 driOptionValue end; /**< \brief End */
56 } driOptionRange;
57
58 /** \brief Information about an option */
59 typedef struct driOptionInfo {
60 char *name; /**< \brief Name */
61 driOptionType type; /**< \brief Type */
62 driOptionRange *ranges; /**< \brief Array of ranges */
63 uint nRanges; /**< \brief Number of ranges */
64 } driOptionInfo;
65
66 /** \brief Option cache
67 *
68 * \li One in <driver>Screen caching option info and the default values
69 * \li One in each <driver>Context with the actual values for that context */
70 typedef struct driOptionCache {
71 driOptionInfo *info;
72 /**< \brief Array of option infos
73 *
74 * Points to the same array in the screen and all contexts */
75 driOptionValue *values;
76 /**< \brief Array of option values
77 *
78 * \li Default values in screen
79 * \li Actual values in contexts
80 */
81 uint tableSize;
82 /**< \brief Size of the arrays
83 *
84 * In the current implementation it's not actually a size but log2(size).
85 * The value is the same in the screen and all contexts. */
86 } driOptionCache;
87
88 /** \brief Parse XML option info from configOptions
89 *
90 * To be called in <driver>CreateScreen
91 *
92 * \param info pointer to a driOptionCache that will store the option info
93 * \param configOptions XML document describing available configuration opts
94 *
95 * For the option information to be available to external configuration tools
96 * it must be a public symbol __driConfigOptions. It is also passed as a
97 * parameter to driParseOptionInfo in order to avoid driver-independent code
98 * depending on symbols in driver-specific code. */
99 void driParseOptionInfo (driOptionCache *info,
100 const char *configOptions);
101 /** \brief Initialize option cache from info and parse configuration files
102 *
103 * To be called in <driver>CreateContext. screenNum and driverName select
104 * device sections. */
105 void driParseConfigFiles (driOptionCache *cache, const driOptionCache *info,
106 int screenNum, const char *driverName);
107 /** \brief Destroy option info
108 *
109 * To be called in <driver>DestroyScreen */
110 void driDestroyOptionInfo (driOptionCache *info);
111 /** \brief Destroy option cache
112 *
113 * To be called in <driver>DestroyContext */
114 void driDestroyOptionCache (driOptionCache *cache);
115
116 /** \brief Check if there exists a certain option */
117 bool driCheckOption (const driOptionCache *cache, const char *name,
118 driOptionType type);
119
120 /** \brief Query a boolean option value */
121 bool driQueryOptionb (const driOptionCache *cache, const char *name);
122 /** \brief Query an integer option value */
123 int driQueryOptioni (const driOptionCache *cache, const char *name);
124 /** \brief Query a floating-point option value */
125 float driQueryOptionf (const driOptionCache *cache, const char *name);
126 /** \brief Query a string option value */
127 char *driQueryOptionstr (const driOptionCache *cache, const char *name);
128
129 #endif