Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

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