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/** \brief Option data types */
34typedef enum driOptionType {
35    DRI_BOOL, DRI_ENUM, DRI_INT, DRI_FLOAT
36} driOptionType;
37
38/** \brief Option value */
39typedef union driOptionValue {
40    GLboolean _bool; /**< \brief Boolean */
41    GLint _int;      /**< \brief Integer or Enum */
42    GLfloat _float;  /**< \brief Floating-point */
43} driOptionValue;
44
45/** \brief Single range of valid values
46 *
47 * For empty ranges (a single value) start == end */
48typedef struct driOptionRange {
49    driOptionValue start; /**< \brief Start */
50    driOptionValue end;   /**< \brief End */
51} driOptionRange;
52
53/** \brief Information about an option */
54typedef struct driOptionInfo {
55    char *name;             /**< \brief Name */
56    driOptionType type;     /**< \brief Type */
57    driOptionRange *ranges; /**< \brief Array of ranges */
58    GLuint nRanges;         /**< \brief Number of ranges */
59} driOptionInfo;
60
61/** \brief Option cache
62 *
63 * \li One in <driver>Screen caching option info and the default values
64 * \li One in each <driver>Context with the actual values for that context */
65typedef struct driOptionCache {
66    driOptionInfo *info;
67  /**< \brief Array of option infos
68   *
69   * Points to the same array in the screen and all contexts */
70    driOptionValue *values;
71  /**< \brief Array of option values
72   *
73   * \li Default values in screen
74   * \li Actual values in contexts
75   */
76    GLuint tableSize;
77  /**< \brief Size of the arrays
78   *
79   * Depending on the hash function this may differ from __driNConfigOptions.
80   * In the current implementation it's not actually a size but log2(size).
81   * The value is the same in the screen and all contexts. */
82} driOptionCache;
83
84/** \brief Parse XML option info from configOptions
85 *
86 * To be called in <driver>CreateScreen
87 *
88 * \param info    pointer to a driOptionCache that will store the option info
89 * \param configOptions   XML document describing available configuration opts
90 * \param nConfigOptions  number of options, used to choose a hash table size
91 *
92 * For the option information to be available to external configuration tools
93 * it must be a public symbol __driConfigOptions. It is also passed as a
94 * parameter to driParseOptionInfo in order to avoid driver-independent code
95 * depending on symbols in driver-specific code. */
96void driParseOptionInfo (driOptionCache *info,
97			 const char *configOptions, GLuint nConfigOptions);
98/** \brief Initialize option cache from info and parse configuration files
99 *
100 * To be called in <driver>CreateContext. screenNum and driverName select
101 * device sections. */
102void driParseConfigFiles (driOptionCache *cache, const driOptionCache *info,
103			  GLint screenNum, const char *driverName);
104/** \brief Destroy option info
105 *
106 * To be called in <driver>DestroyScreen */
107void driDestroyOptionInfo (driOptionCache *info);
108/** \brief Destroy option cache
109 *
110 * To be called in <driver>DestroyContext */
111void driDestroyOptionCache (driOptionCache *cache);
112
113/** \brief Check if there exists a certain option */
114GLboolean driCheckOption (const driOptionCache *cache, const char *name,
115			  driOptionType type);
116
117/** \brief Query a boolean option value */
118GLboolean driQueryOptionb (const driOptionCache *cache, const char *name);
119/** \brief Query an integer option value */
120GLint driQueryOptioni (const driOptionCache *cache, const char *name);
121/** \brief Query a floating-point option value */
122GLfloat driQueryOptionf (const driOptionCache *cache, const char *name);
123
124#endif
125