util/xmlconfig: Indent to Mesa style.

I'm heavily editing this code, and having Mesa's style not apply sucks.

Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6916>
This commit is contained in:
Eric Anholt 2020-09-10 16:54:38 -07:00 committed by Marge Bot
parent 91ccbb399f
commit 4f37161a8f
2 changed files with 890 additions and 888 deletions

View file

@ -67,7 +67,7 @@ be_verbose(void)
static uint32_t static uint32_t
findOption(const driOptionCache *cache, const char *name) findOption(const driOptionCache *cache, const char *name)
{ {
uint32_t len = strlen (name); uint32_t len = strlen(name);
uint32_t size = 1 << cache->tableSize, mask = size - 1; uint32_t size = 1 << cache->tableSize, mask = size - 1;
uint32_t hash = 0; uint32_t hash = 0;
uint32_t i, shift; uint32_t i, shift;
@ -83,7 +83,7 @@ findOption(const driOptionCache *cache, const char *name)
/* if we hit an empty entry then the option is not defined (yet) */ /* if we hit an empty entry then the option is not defined (yet) */
if (cache->info[hash].name == 0) if (cache->info[hash].name == 0)
break; break;
else if (!strcmp (name, cache->info[hash].name)) else if (!strcmp(name, cache->info[hash].name))
break; break;
} }
/* this assertion fails if the hash table is full */ /* this assertion fails if the hash table is full */
@ -95,20 +95,20 @@ findOption(const driOptionCache *cache, const char *name)
/** \brief Like strdup with error checking. */ /** \brief Like strdup with error checking. */
#define XSTRDUP(dest,source) do { \ #define XSTRDUP(dest,source) do { \
if (!(dest = strdup(source))) { \ if (!(dest = strdup(source))) { \
fprintf (stderr, "%s: %d: out of memory.\n", __FILE__, __LINE__); \ fprintf(stderr, "%s: %d: out of memory.\n", __FILE__, __LINE__); \
abort(); \ abort(); \
} \ } \
} while (0) } while (0)
static int compare (const void *a, const void *b) { static int compare(const void *a, const void *b) {
return strcmp (*(char *const*)a, *(char *const*)b); return strcmp(*(char *const*)a, *(char *const*)b);
} }
/** \brief Binary search in a string array. */ /** \brief Binary search in a string array. */
static uint32_t static uint32_t
bsearchStr (const XML_Char *name, const XML_Char *elems[], uint32_t count) bsearchStr(const XML_Char *name, const XML_Char *elems[], uint32_t count)
{ {
const XML_Char **found; const XML_Char **found;
found = bsearch (&name, elems, count, sizeof (XML_Char *), compare); found = bsearch(&name, elems, count, sizeof(XML_Char *), compare);
if (found) if (found)
return found - elems; return found - elems;
else else
@ -133,7 +133,7 @@ strToI(const XML_Char *string, const XML_Char **tail, int base)
bool numberFound = false; bool numberFound = false;
const XML_Char *start = string; const XML_Char *start = string;
assert (radix >= 2 && radix <= 36); assert(radix >= 2 && radix <= 36);
if (*string == '-') { if (*string == '-') {
sign = -1; sign = -1;
@ -223,7 +223,7 @@ strToF(const XML_Char *string, const XML_Char **tail)
*tail = string; *tail = string;
if (*string == 'e' || *string == 'E') { if (*string == 'e' || *string == 'E') {
const XML_Char *expTail; const XML_Char *expTail;
exponent = strToI (string+1, &expTail, 10); exponent = strToI(string+1, &expTail, 10);
if (expTail == string+1) if (expTail == string+1)
exponent = 0; exponent = 0;
else else
@ -233,12 +233,12 @@ strToF(const XML_Char *string, const XML_Char **tail)
string = numStart; string = numStart;
/* scale of the first digit */ /* scale of the first digit */
scale = sign * (float)pow (10.0, (double)(pointPos-1 + exponent)); scale = sign * (float)pow(10.0, (double)(pointPos-1 + exponent));
/* second pass: parse digits */ /* second pass: parse digits */
do { do {
if (*string != '.') { if (*string != '.') {
assert (*string >= '0' && *string <= '9'); assert(*string >= '0' && *string <= '9');
result += scale * (float)(*string - '0'); result += scale * (float)(*string - '0');
scale *= 0.1f; scale *= 0.1f;
nDigits--; nDigits--;
@ -255,13 +255,13 @@ parseValue(driOptionValue *v, driOptionType type, const XML_Char *string)
{ {
const XML_Char *tail = NULL; const XML_Char *tail = NULL;
/* skip leading white-space */ /* skip leading white-space */
string += strspn (string, " \f\n\r\t\v"); string += strspn(string, " \f\n\r\t\v");
switch (type) { switch (type) {
case DRI_BOOL: case DRI_BOOL:
if (!strcmp (string, "false")) { if (!strcmp(string, "false")) {
v->_bool = false; v->_bool = false;
tail = string + 5; tail = string + 5;
} else if (!strcmp (string, "true")) { } else if (!strcmp(string, "true")) {
v->_bool = true; v->_bool = true;
tail = string + 4; tail = string + 4;
} }
@ -270,13 +270,13 @@ parseValue(driOptionValue *v, driOptionType type, const XML_Char *string)
break; break;
case DRI_ENUM: /* enum is just a special integer */ case DRI_ENUM: /* enum is just a special integer */
case DRI_INT: case DRI_INT:
v->_int = strToI (string, &tail, 0); v->_int = strToI(string, &tail, 0);
break; break;
case DRI_FLOAT: case DRI_FLOAT:
v->_float = strToF (string, &tail); v->_float = strToF(string, &tail);
break; break;
case DRI_STRING: case DRI_STRING:
free (v->_string); free(v->_string);
v->_string = strndup(string, STRING_CONF_MAXLEN); v->_string = strndup(string, STRING_CONF_MAXLEN);
return true; return true;
} }
@ -285,7 +285,7 @@ parseValue(driOptionValue *v, driOptionType type, const XML_Char *string)
return false; /* empty string (or containing only white-space) */ return false; /* empty string (or containing only white-space) */
/* skip trailing white space */ /* skip trailing white space */
if (*tail) if (*tail)
tail += strspn (tail, " \f\n\r\t\v"); tail += strspn(tail, " \f\n\r\t\v");
if (*tail) if (*tail)
return false; /* something left over that is not part of value */ return false; /* something left over that is not part of value */
@ -300,7 +300,7 @@ parseRanges(driOptionInfo *info, const XML_Char *string)
uint32_t nRanges, i; uint32_t nRanges, i;
driOptionRange *ranges; driOptionRange *ranges;
XSTRDUP (cp, string); XSTRDUP(cp, string);
/* pass 1: determine the number of ranges (number of commas + 1) */ /* pass 1: determine the number of ranges (number of commas + 1) */
range = cp; range = cp;
for (nRanges = 1; *range; ++range) for (nRanges = 1; *range; ++range)
@ -308,7 +308,7 @@ parseRanges(driOptionInfo *info, const XML_Char *string)
++nRanges; ++nRanges;
if ((ranges = malloc(nRanges*sizeof(driOptionRange))) == NULL) { if ((ranges = malloc(nRanges*sizeof(driOptionRange))) == NULL) {
fprintf (stderr, "%s: %d: out of memory.\n", __FILE__, __LINE__); fprintf(stderr, "%s: %d: out of memory.\n", __FILE__, __LINE__);
abort(); abort();
} }
@ -316,15 +316,15 @@ parseRanges(driOptionInfo *info, const XML_Char *string)
range = cp; range = cp;
for (i = 0; i < nRanges; ++i) { for (i = 0; i < nRanges; ++i) {
XML_Char *end, *sep; XML_Char *end, *sep;
assert (range); assert(range);
end = strchr (range, ','); end = strchr(range, ',');
if (end) if (end)
*end = '\0'; *end = '\0';
sep = strchr (range, ':'); sep = strchr(range, ':');
if (sep) { /* non-empty interval */ if (sep) { /* non-empty interval */
*sep = '\0'; *sep = '\0';
if (!parseValue (&ranges[i].start, info->type, range) || if (!parseValue(&ranges[i].start, info->type, range) ||
!parseValue (&ranges[i].end, info->type, sep+1)) !parseValue(&ranges[i].end, info->type, sep+1))
break; break;
if (info->type == DRI_INT && if (info->type == DRI_INT &&
ranges[i].start._int > ranges[i].end._int) ranges[i].start._int > ranges[i].end._int)
@ -333,7 +333,7 @@ parseRanges(driOptionInfo *info, const XML_Char *string)
ranges[i].start._float > ranges[i].end._float) ranges[i].start._float > ranges[i].end._float)
break; break;
} else { /* empty interval */ } else { /* empty interval */
if (!parseValue (&ranges[i].start, info->type, range)) if (!parseValue(&ranges[i].start, info->type, range))
break; break;
ranges[i].end = ranges[i].start; ranges[i].end = ranges[i].start;
} }
@ -347,7 +347,7 @@ parseRanges(driOptionInfo *info, const XML_Char *string)
free(ranges); free(ranges);
return false; return false;
} else } else
assert (range == NULL); assert(range == NULL);
info->nRanges = nRanges; info->nRanges = nRanges;
info->ranges = ranges; info->ranges = ranges;
@ -359,7 +359,7 @@ static bool
checkValue(const driOptionValue *v, const driOptionInfo *info) checkValue(const driOptionValue *v, const driOptionInfo *info)
{ {
uint32_t i; uint32_t i;
assert (info->type != DRI_BOOL); /* should be caught by the parser */ assert(info->type != DRI_BOOL); /* should be caught by the parser */
if (info->nRanges == 0) if (info->nRanges == 0)
return true; return true;
switch (info->type) { switch (info->type) {
@ -379,7 +379,7 @@ checkValue(const driOptionValue *v, const driOptionInfo *info)
case DRI_STRING: case DRI_STRING:
break; break;
default: default:
assert (0); /* should never happen */ assert(0); /* should never happen */
} }
return false; return false;
} }
@ -409,45 +409,45 @@ __driUtilMessage(const char *f, ...)
} }
/** \brief Output a warning message. */ /** \brief Output a warning message. */
#define XML_WARNING1(msg) do {\ #define XML_WARNING1(msg) do { \
__driUtilMessage ("Warning in %s line %d, column %d: "msg, data->name, \ __driUtilMessage("Warning in %s line %d, column %d: "msg, data->name, \
(int) XML_GetCurrentLineNumber(data->parser), \ (int) XML_GetCurrentLineNumber(data->parser), \
(int) XML_GetCurrentColumnNumber(data->parser)); \ (int) XML_GetCurrentColumnNumber(data->parser)); \
} while (0) } while (0)
#define XML_WARNING(msg, ...) do { \ #define XML_WARNING(msg, ...) do { \
__driUtilMessage ("Warning in %s line %d, column %d: "msg, data->name, \ __driUtilMessage("Warning in %s line %d, column %d: "msg, data->name, \
(int) XML_GetCurrentLineNumber(data->parser), \ (int) XML_GetCurrentLineNumber(data->parser), \
(int) XML_GetCurrentColumnNumber(data->parser), \ (int) XML_GetCurrentColumnNumber(data->parser), \
##__VA_ARGS__); \ ##__VA_ARGS__); \
} while (0) } while (0)
/** \brief Output an error message. */ /** \brief Output an error message. */
#define XML_ERROR1(msg) do { \ #define XML_ERROR1(msg) do { \
__driUtilMessage ("Error in %s line %d, column %d: "msg, data->name, \ __driUtilMessage("Error in %s line %d, column %d: "msg, data->name, \
(int) XML_GetCurrentLineNumber(data->parser), \ (int) XML_GetCurrentLineNumber(data->parser), \
(int) XML_GetCurrentColumnNumber(data->parser)); \ (int) XML_GetCurrentColumnNumber(data->parser)); \
} while (0) } while (0)
#define XML_ERROR(msg, ...) do { \ #define XML_ERROR(msg, ...) do { \
__driUtilMessage ("Error in %s line %d, column %d: "msg, data->name, \ __driUtilMessage("Error in %s line %d, column %d: "msg, data->name, \
(int) XML_GetCurrentLineNumber(data->parser), \ (int) XML_GetCurrentLineNumber(data->parser), \
(int) XML_GetCurrentColumnNumber(data->parser), \ (int) XML_GetCurrentColumnNumber(data->parser), \
##__VA_ARGS__); \ ##__VA_ARGS__); \
} while (0) } while (0)
/** \brief Output a fatal error message and abort. */ /** \brief Output a fatal error message and abort. */
#define XML_FATAL1(msg) do { \ #define XML_FATAL1(msg) do { \
fprintf (stderr, "Fatal error in %s line %d, column %d: "msg"\n", \ fprintf(stderr, "Fatal error in %s line %d, column %d: "msg"\n", \
data->name, \ data->name, \
(int) XML_GetCurrentLineNumber(data->parser), \ (int) XML_GetCurrentLineNumber(data->parser), \
(int) XML_GetCurrentColumnNumber(data->parser)); \ (int) XML_GetCurrentColumnNumber(data->parser)); \
abort();\ abort(); \
} while (0) } while (0)
#define XML_FATAL(msg, ...) do { \ #define XML_FATAL(msg, ...) do { \
fprintf (stderr, "Fatal error in %s line %d, column %d: "msg"\n", \ fprintf(stderr, "Fatal error in %s line %d, column %d: "msg"\n", \
data->name, \ data->name, \
(int) XML_GetCurrentLineNumber(data->parser), \ (int) XML_GetCurrentLineNumber(data->parser), \
(int) XML_GetCurrentColumnNumber(data->parser), \ (int) XML_GetCurrentColumnNumber(data->parser), \
##__VA_ARGS__); \ ##__VA_ARGS__); \
abort();\ abort(); \
} while (0) } while (0)
/** \brief Parser context for __driConfigOptions. */ /** \brief Parser context for __driConfigOptions. */
struct OptInfoData { struct OptInfoData {
@ -483,16 +483,16 @@ parseEnumAttr(struct OptInfoData *data, const XML_Char **attr)
driOptionValue v; driOptionValue v;
uint32_t opt = data->curOption; uint32_t opt = data->curOption;
for (i = 0; attr[i]; i += 2) { for (i = 0; attr[i]; i += 2) {
if (!strcmp (attr[i], "value")) value = attr[i+1]; if (!strcmp(attr[i], "value")) value = attr[i+1];
else if (!strcmp (attr[i], "text")) text = attr[i+1]; else if (!strcmp(attr[i], "text")) text = attr[i+1];
else XML_FATAL("illegal enum attribute: %s.", attr[i]); else XML_FATAL("illegal enum attribute: %s.", attr[i]);
} }
if (!value) XML_FATAL1 ("value attribute missing in enum."); if (!value) XML_FATAL1("value attribute missing in enum.");
if (!text) XML_FATAL1 ("text attribute missing in enum."); if (!text) XML_FATAL1("text attribute missing in enum.");
if (!parseValue (&v, data->cache->info[opt].type, value)) if (!parseValue(&v, data->cache->info[opt].type, value))
XML_FATAL ("illegal enum value: %s.", value); XML_FATAL("illegal enum value: %s.", value);
if (!checkValue (&v, &data->cache->info[opt])) if (!checkValue(&v, &data->cache->info[opt]))
XML_FATAL ("enum value out of valid range: %s.", value); XML_FATAL("enum value out of valid range: %s.", value);
} }
/** \brief Parse attributes of a description element. /** \brief Parse attributes of a description element.
@ -506,12 +506,12 @@ parseDescAttr(struct OptInfoData *data, const XML_Char **attr)
uint32_t i; uint32_t i;
const XML_Char *lang = NULL, *text = NULL; const XML_Char *lang = NULL, *text = NULL;
for (i = 0; attr[i]; i += 2) { for (i = 0; attr[i]; i += 2) {
if (!strcmp (attr[i], "lang")) lang = attr[i+1]; if (!strcmp(attr[i], "lang")) lang = attr[i+1];
else if (!strcmp (attr[i], "text")) text = attr[i+1]; else if (!strcmp(attr[i], "text")) text = attr[i+1];
else XML_FATAL("illegal description attribute: %s.", attr[i]); else XML_FATAL("illegal description attribute: %s.", attr[i]);
} }
if (!lang) XML_FATAL1 ("lang attribute missing in description."); if (!lang) XML_FATAL1("lang attribute missing in description.");
if (!text) XML_FATAL1 ("text attribute missing in description."); if (!text) XML_FATAL1("text attribute missing in description.");
} }
/** \brief Parse attributes of an option element. */ /** \brief Parse attributes of an option element. */
@ -525,36 +525,36 @@ parseOptInfoAttr(struct OptInfoData *data, const XML_Char **attr)
driOptionCache *cache = data->cache; driOptionCache *cache = data->cache;
uint32_t opt, i; uint32_t opt, i;
for (i = 0; attr[i]; i += 2) { for (i = 0; attr[i]; i += 2) {
uint32_t attrName = bsearchStr (attr[i], optAttr, OA_COUNT); uint32_t attrName = bsearchStr(attr[i], optAttr, OA_COUNT);
if (attrName >= OA_COUNT) if (attrName >= OA_COUNT)
XML_FATAL ("illegal option attribute: %s", attr[i]); XML_FATAL("illegal option attribute: %s", attr[i]);
attrVal[attrName] = attr[i+1]; attrVal[attrName] = attr[i+1];
} }
if (!attrVal[OA_NAME]) XML_FATAL1 ("name attribute missing in option."); if (!attrVal[OA_NAME]) XML_FATAL1("name attribute missing in option.");
if (!attrVal[OA_TYPE]) XML_FATAL1 ("type attribute missing in option."); if (!attrVal[OA_TYPE]) XML_FATAL1("type attribute missing in option.");
if (!attrVal[OA_DEFAULT]) XML_FATAL1 ("default attribute missing in option."); if (!attrVal[OA_DEFAULT]) XML_FATAL1("default attribute missing in option.");
opt = findOption (cache, attrVal[OA_NAME]); opt = findOption(cache, attrVal[OA_NAME]);
if (cache->info[opt].name) if (cache->info[opt].name)
XML_FATAL ("option %s redefined.", attrVal[OA_NAME]); XML_FATAL("option %s redefined.", attrVal[OA_NAME]);
data->curOption = opt; data->curOption = opt;
XSTRDUP (cache->info[opt].name, attrVal[OA_NAME]); XSTRDUP(cache->info[opt].name, attrVal[OA_NAME]);
if (!strcmp (attrVal[OA_TYPE], "bool")) if (!strcmp(attrVal[OA_TYPE], "bool"))
cache->info[opt].type = DRI_BOOL; cache->info[opt].type = DRI_BOOL;
else if (!strcmp (attrVal[OA_TYPE], "enum")) else if (!strcmp(attrVal[OA_TYPE], "enum"))
cache->info[opt].type = DRI_ENUM; cache->info[opt].type = DRI_ENUM;
else if (!strcmp (attrVal[OA_TYPE], "int")) else if (!strcmp(attrVal[OA_TYPE], "int"))
cache->info[opt].type = DRI_INT; cache->info[opt].type = DRI_INT;
else if (!strcmp (attrVal[OA_TYPE], "float")) else if (!strcmp(attrVal[OA_TYPE], "float"))
cache->info[opt].type = DRI_FLOAT; cache->info[opt].type = DRI_FLOAT;
else if (!strcmp (attrVal[OA_TYPE], "string")) else if (!strcmp(attrVal[OA_TYPE], "string"))
cache->info[opt].type = DRI_STRING; cache->info[opt].type = DRI_STRING;
else else
XML_FATAL ("illegal type in option: %s.", attrVal[OA_TYPE]); XML_FATAL("illegal type in option: %s.", attrVal[OA_TYPE]);
defaultVal = getenv (cache->info[opt].name); defaultVal = getenv(cache->info[opt].name);
if (defaultVal != NULL) { if (defaultVal != NULL) {
/* don't use XML_WARNING, we want the user to see this! */ /* don't use XML_WARNING, we want the user to see this! */
if (be_verbose()) { if (be_verbose()) {
@ -564,19 +564,19 @@ parseOptInfoAttr(struct OptInfoData *data, const XML_Char **attr)
} }
} else } else
defaultVal = attrVal[OA_DEFAULT]; defaultVal = attrVal[OA_DEFAULT];
if (!parseValue (&cache->values[opt], cache->info[opt].type, defaultVal)) if (!parseValue(&cache->values[opt], cache->info[opt].type, defaultVal))
XML_FATAL ("illegal default value for %s: %s.", cache->info[opt].name, defaultVal); XML_FATAL("illegal default value for %s: %s.", cache->info[opt].name, defaultVal);
if (attrVal[OA_VALID]) { if (attrVal[OA_VALID]) {
if (cache->info[opt].type == DRI_BOOL) if (cache->info[opt].type == DRI_BOOL)
XML_FATAL1 ("boolean option with valid attribute."); XML_FATAL1("boolean option with valid attribute.");
if (!parseRanges (&cache->info[opt], attrVal[OA_VALID])) if (!parseRanges(&cache->info[opt], attrVal[OA_VALID]))
XML_FATAL ("illegal valid attribute: %s.", attrVal[OA_VALID]); XML_FATAL("illegal valid attribute: %s.", attrVal[OA_VALID]);
if (!checkValue (&cache->values[opt], &cache->info[opt])) if (!checkValue(&cache->values[opt], &cache->info[opt]))
XML_FATAL ("default value out of valid range '%s': %s.", XML_FATAL("default value out of valid range '%s': %s.",
attrVal[OA_VALID], defaultVal); attrVal[OA_VALID], defaultVal);
} else if (cache->info[opt].type == DRI_ENUM) { } else if (cache->info[opt].type == DRI_ENUM) {
XML_FATAL1 ("valid attribute missing in option (mandatory for enums)."); XML_FATAL1("valid attribute missing in option (mandatory for enums).");
} else { } else {
cache->info[opt].nRanges = 0; cache->info[opt].nRanges = 0;
cache->info[opt].ranges = NULL; cache->info[opt].ranges = NULL;
@ -588,52 +588,52 @@ static void
optInfoStartElem(void *userData, const XML_Char *name, const XML_Char **attr) optInfoStartElem(void *userData, const XML_Char *name, const XML_Char **attr)
{ {
struct OptInfoData *data = (struct OptInfoData *)userData; struct OptInfoData *data = (struct OptInfoData *)userData;
enum OptInfoElem elem = bsearchStr (name, OptInfoElems, OI_COUNT); enum OptInfoElem elem = bsearchStr(name, OptInfoElems, OI_COUNT);
switch (elem) { switch (elem) {
case OI_DRIINFO: case OI_DRIINFO:
if (data->inDriInfo) if (data->inDriInfo)
XML_FATAL1 ("nested <driinfo> elements."); XML_FATAL1("nested <driinfo> elements.");
if (attr[0]) if (attr[0])
XML_FATAL1 ("attributes specified on <driinfo> element."); XML_FATAL1("attributes specified on <driinfo> element.");
data->inDriInfo = true; data->inDriInfo = true;
break; break;
case OI_SECTION: case OI_SECTION:
if (!data->inDriInfo) if (!data->inDriInfo)
XML_FATAL1 ("<section> must be inside <driinfo>."); XML_FATAL1("<section> must be inside <driinfo>.");
if (data->inSection) if (data->inSection)
XML_FATAL1 ("nested <section> elements."); XML_FATAL1("nested <section> elements.");
if (attr[0]) if (attr[0])
XML_FATAL1 ("attributes specified on <section> element."); XML_FATAL1("attributes specified on <section> element.");
data->inSection = true; data->inSection = true;
break; break;
case OI_DESCRIPTION: case OI_DESCRIPTION:
if (!data->inSection && !data->inOption) if (!data->inSection && !data->inOption)
XML_FATAL1 ("<description> must be inside <description> or <option."); XML_FATAL1("<description> must be inside <description> or <option.");
if (data->inDesc) if (data->inDesc)
XML_FATAL1 ("nested <description> elements."); XML_FATAL1("nested <description> elements.");
data->inDesc = true; data->inDesc = true;
parseDescAttr (data, attr); parseDescAttr(data, attr);
break; break;
case OI_OPTION: case OI_OPTION:
if (!data->inSection) if (!data->inSection)
XML_FATAL1 ("<option> must be inside <section>."); XML_FATAL1("<option> must be inside <section>.");
if (data->inDesc) if (data->inDesc)
XML_FATAL1 ("<option> nested in <description> element."); XML_FATAL1("<option> nested in <description> element.");
if (data->inOption) if (data->inOption)
XML_FATAL1 ("nested <option> elements."); XML_FATAL1("nested <option> elements.");
data->inOption = true; data->inOption = true;
parseOptInfoAttr (data, attr); parseOptInfoAttr(data, attr);
break; break;
case OI_ENUM: case OI_ENUM:
if (!(data->inOption && data->inDesc)) if (!(data->inOption && data->inDesc))
XML_FATAL1 ("<enum> must be inside <option> and <description>."); XML_FATAL1("<enum> must be inside <option> and <description>.");
if (data->inEnum) if (data->inEnum)
XML_FATAL1 ("nested <enum> elements."); XML_FATAL1("nested <enum> elements.");
data->inEnum = true; data->inEnum = true;
parseEnumAttr (data, attr); parseEnumAttr(data, attr);
break; break;
default: default:
XML_FATAL ("unknown element: %s.", name); XML_FATAL("unknown element: %s.", name);
} }
} }
@ -642,7 +642,7 @@ static void
optInfoEndElem(void *userData, const XML_Char *name) optInfoEndElem(void *userData, const XML_Char *name)
{ {
struct OptInfoData *data = (struct OptInfoData *)userData; struct OptInfoData *data = (struct OptInfoData *)userData;
enum OptInfoElem elem = bsearchStr (name, OptInfoElems, OI_COUNT); enum OptInfoElem elem = bsearchStr(name, OptInfoElems, OI_COUNT);
switch (elem) { switch (elem) {
case OI_DRIINFO: case OI_DRIINFO:
data->inDriInfo = false; data->inDriInfo = false;
@ -660,7 +660,7 @@ optInfoEndElem(void *userData, const XML_Char *name)
data->inEnum = false; data->inEnum = false;
break; break;
default: default:
assert (0); /* should have been caught by StartElem */ assert(0); /* should have been caught by StartElem */
} }
} }
@ -676,16 +676,16 @@ driParseOptionInfo(driOptionCache *info, const char *configOptions)
* config options we've ever seen in a driver. * config options we've ever seen in a driver.
*/ */
info->tableSize = 6; info->tableSize = 6;
info->info = calloc(1 << info->tableSize, sizeof (driOptionInfo)); info->info = calloc(1 << info->tableSize, sizeof(driOptionInfo));
info->values = calloc(1 << info->tableSize, sizeof (driOptionValue)); info->values = calloc(1 << info->tableSize, sizeof(driOptionValue));
if (info->info == NULL || info->values == NULL) { if (info->info == NULL || info->values == NULL) {
fprintf (stderr, "%s: %d: out of memory.\n", __FILE__, __LINE__); fprintf(stderr, "%s: %d: out of memory.\n", __FILE__, __LINE__);
abort(); abort();
} }
p = XML_ParserCreate ("UTF-8"); /* always UTF-8 */ p = XML_ParserCreate("UTF-8"); /* always UTF-8 */
XML_SetElementHandler (p, optInfoStartElem, optInfoEndElem); XML_SetElementHandler(p, optInfoStartElem, optInfoEndElem);
XML_SetUserData (p, data); XML_SetUserData(p, data);
userData.name = "__driConfigOptions"; userData.name = "__driConfigOptions";
userData.parser = p; userData.parser = p;
@ -697,11 +697,11 @@ driParseOptionInfo(driOptionCache *info, const char *configOptions)
userData.inEnum = false; userData.inEnum = false;
userData.curOption = -1; userData.curOption = -1;
status = XML_Parse (p, configOptions, strlen (configOptions), 1); status = XML_Parse(p, configOptions, strlen(configOptions), 1);
if (!status) if (!status)
XML_FATAL ("%s.", XML_ErrorString(XML_GetErrorCode(p))); XML_FATAL("%s.", XML_ErrorString(XML_GetErrorCode(p)));
XML_ParserFree (p); XML_ParserFree(p);
} }
/** \brief Parser context for configuration files. */ /** \brief Parser context for configuration files. */
@ -743,18 +743,19 @@ parseDeviceAttr(struct OptConfData *data, const XML_Char **attr)
uint32_t i; uint32_t i;
const XML_Char *driver = NULL, *screen = NULL, *kernel = NULL; const XML_Char *driver = NULL, *screen = NULL, *kernel = NULL;
for (i = 0; attr[i]; i += 2) { for (i = 0; attr[i]; i += 2) {
if (!strcmp (attr[i], "driver")) driver = attr[i+1]; if (!strcmp(attr[i], "driver")) driver = attr[i+1];
else if (!strcmp (attr[i], "screen")) screen = attr[i+1]; else if (!strcmp(attr[i], "screen")) screen = attr[i+1];
else if (!strcmp (attr[i], "kernel_driver")) kernel = attr[i+1]; else if (!strcmp(attr[i], "kernel_driver")) kernel = attr[i+1];
else XML_WARNING("unknown device attribute: %s.", attr[i]); else XML_WARNING("unknown device attribute: %s.", attr[i]);
} }
if (driver && strcmp (driver, data->driverName)) if (driver && strcmp(driver, data->driverName))
data->ignoringDevice = data->inDevice; data->ignoringDevice = data->inDevice;
else if (kernel && (!data->kernelDriverName || strcmp (kernel, data->kernelDriverName))) else if (kernel && (!data->kernelDriverName ||
strcmp(kernel, data->kernelDriverName)))
data->ignoringDevice = data->inDevice; data->ignoringDevice = data->inDevice;
else if (screen) { else if (screen) {
driOptionValue screenNum; driOptionValue screenNum;
if (!parseValue (&screenNum, DRI_INT, screen)) if (!parseValue(&screenNum, DRI_INT, screen))
XML_WARNING("illegal screen number: %s.", screen); XML_WARNING("illegal screen number: %s.", screen);
else if (screenNum._int != data->screenNum) else if (screenNum._int != data->screenNum)
data->ignoringDevice = data->inDevice; data->ignoringDevice = data->inDevice;
@ -789,16 +790,16 @@ parseAppAttr(struct OptConfData *data, const XML_Char **attr)
}; };
for (i = 0; attr[i]; i += 2) { for (i = 0; attr[i]; i += 2) {
if (!strcmp (attr[i], "name")) /* not needed here */; if (!strcmp(attr[i], "name")) /* not needed here */;
else if (!strcmp (attr[i], "executable")) exec = attr[i+1]; else if (!strcmp(attr[i], "executable")) exec = attr[i+1];
else if (!strcmp (attr[i], "sha1")) sha1 = attr[i+1]; else if (!strcmp(attr[i], "sha1")) sha1 = attr[i+1];
else if (!strcmp (attr[i], "application_name_match")) else if (!strcmp(attr[i], "application_name_match"))
application_name_match = attr[i+1]; application_name_match = attr[i+1];
else if (!strcmp (attr[i], "application_versions")) else if (!strcmp(attr[i], "application_versions"))
application_versions = attr[i+1]; application_versions = attr[i+1];
else XML_WARNING("unknown application attribute: %s.", attr[i]); else XML_WARNING("unknown application attribute: %s.", attr[i]);
} }
if (exec && strcmp (exec, data->execName)) { if (exec && strcmp(exec, data->execName)) {
data->ignoringApp = data->inApp; data->ignoringApp = data->inApp;
} else if (sha1) { } else if (sha1) {
/* SHA1_DIGEST_STRING_LENGTH includes terminating null byte */ /* SHA1_DIGEST_STRING_LENGTH includes terminating null byte */
@ -827,16 +828,16 @@ parseAppAttr(struct OptConfData *data, const XML_Char **attr)
} else if (application_name_match) { } else if (application_name_match) {
regex_t re; regex_t re;
if (regcomp (&re, application_name_match, REG_EXTENDED|REG_NOSUB) == 0) { if (regcomp(&re, application_name_match, REG_EXTENDED|REG_NOSUB) == 0) {
if (regexec (&re, data->applicationName, 0, NULL, 0) == REG_NOMATCH) if (regexec(&re, data->applicationName, 0, NULL, 0) == REG_NOMATCH)
data->ignoringApp = data->inApp; data->ignoringApp = data->inApp;
regfree (&re); regfree(&re);
} else } else
XML_WARNING ("Invalid application_name_match=\"%s\".", application_name_match); XML_WARNING("Invalid application_name_match=\"%s\".", application_name_match);
} }
if (application_versions) { if (application_versions) {
if (parseRanges (&version_ranges, application_versions) && if (parseRanges(&version_ranges, application_versions) &&
!valueInRanges (&version_ranges, data->applicationVersion)) !valueInRanges(&version_ranges, data->applicationVersion))
data->ignoringApp = data->inApp; data->ignoringApp = data->inApp;
} }
} }
@ -851,24 +852,24 @@ parseEngineAttr(struct OptConfData *data, const XML_Char **attr)
.type = DRI_INT, .type = DRI_INT,
}; };
for (i = 0; attr[i]; i += 2) { for (i = 0; attr[i]; i += 2) {
if (!strcmp (attr[i], "name")) /* not needed here */; if (!strcmp(attr[i], "name")) /* not needed here */;
else if (!strcmp (attr[i], "engine_name_match")) engine_name_match = attr[i+1]; else if (!strcmp(attr[i], "engine_name_match")) engine_name_match = attr[i+1];
else if (!strcmp (attr[i], "engine_versions")) engine_versions = attr[i+1]; else if (!strcmp(attr[i], "engine_versions")) engine_versions = attr[i+1];
else XML_WARNING("unknown application attribute: %s.", attr[i]); else XML_WARNING("unknown application attribute: %s.", attr[i]);
} }
if (engine_name_match) { if (engine_name_match) {
regex_t re; regex_t re;
if (regcomp (&re, engine_name_match, REG_EXTENDED|REG_NOSUB) == 0) { if (regcomp(&re, engine_name_match, REG_EXTENDED|REG_NOSUB) == 0) {
if (regexec (&re, data->engineName, 0, NULL, 0) == REG_NOMATCH) if (regexec(&re, data->engineName, 0, NULL, 0) == REG_NOMATCH)
data->ignoringApp = data->inApp; data->ignoringApp = data->inApp;
regfree (&re); regfree(&re);
} else } else
XML_WARNING ("Invalid engine_name_match=\"%s\".", engine_name_match); XML_WARNING("Invalid engine_name_match=\"%s\".", engine_name_match);
} }
if (engine_versions) { if (engine_versions) {
if (parseRanges (&version_ranges, engine_versions) && if (parseRanges(&version_ranges, engine_versions) &&
!valueInRanges (&version_ranges, data->engineVersion)) !valueInRanges(&version_ranges, data->engineVersion))
data->ignoringApp = data->inApp; data->ignoringApp = data->inApp;
} }
@ -882,28 +883,28 @@ parseOptConfAttr(struct OptConfData *data, const XML_Char **attr)
uint32_t i; uint32_t i;
const XML_Char *name = NULL, *value = NULL; const XML_Char *name = NULL, *value = NULL;
for (i = 0; attr[i]; i += 2) { for (i = 0; attr[i]; i += 2) {
if (!strcmp (attr[i], "name")) name = attr[i+1]; if (!strcmp(attr[i], "name")) name = attr[i+1];
else if (!strcmp (attr[i], "value")) value = attr[i+1]; else if (!strcmp(attr[i], "value")) value = attr[i+1];
else XML_WARNING("unknown option attribute: %s.", attr[i]); else XML_WARNING("unknown option attribute: %s.", attr[i]);
} }
if (!name) XML_WARNING1 ("name attribute missing in option."); if (!name) XML_WARNING1("name attribute missing in option.");
if (!value) XML_WARNING1 ("value attribute missing in option."); if (!value) XML_WARNING1("value attribute missing in option.");
if (name && value) { if (name && value) {
driOptionCache *cache = data->cache; driOptionCache *cache = data->cache;
uint32_t opt = findOption (cache, name); uint32_t opt = findOption(cache, name);
if (cache->info[opt].name == NULL) if (cache->info[opt].name == NULL)
/* don't use XML_WARNING, drirc defines options for all drivers, /* don't use XML_WARNING, drirc defines options for all drivers,
* but not all drivers support them */ * but not all drivers support them */
return; return;
else if (getenv (cache->info[opt].name)) { else if (getenv(cache->info[opt].name)) {
/* don't use XML_WARNING, we want the user to see this! */ /* don't use XML_WARNING, we want the user to see this! */
if (be_verbose()) { if (be_verbose()) {
fprintf(stderr, fprintf(stderr,
"ATTENTION: option value of option %s ignored.\n", "ATTENTION: option value of option %s ignored.\n",
cache->info[opt].name); cache->info[opt].name);
} }
} else if (!parseValue (&cache->values[opt], cache->info[opt].type, value)) } else if (!parseValue(&cache->values[opt], cache->info[opt].type, value))
XML_WARNING ("illegal option value: %s.", value); XML_WARNING("illegal option value: %s.", value);
} }
} }
@ -913,53 +914,53 @@ optConfStartElem(void *userData, const XML_Char *name,
const XML_Char **attr) const XML_Char **attr)
{ {
struct OptConfData *data = (struct OptConfData *)userData; struct OptConfData *data = (struct OptConfData *)userData;
enum OptConfElem elem = bsearchStr (name, OptConfElems, OC_COUNT); enum OptConfElem elem = bsearchStr(name, OptConfElems, OC_COUNT);
switch (elem) { switch (elem) {
case OC_DRICONF: case OC_DRICONF:
if (data->inDriConf) if (data->inDriConf)
XML_WARNING1 ("nested <driconf> elements."); XML_WARNING1("nested <driconf> elements.");
if (attr[0]) if (attr[0])
XML_WARNING1 ("attributes specified on <driconf> element."); XML_WARNING1("attributes specified on <driconf> element.");
data->inDriConf++; data->inDriConf++;
break; break;
case OC_DEVICE: case OC_DEVICE:
if (!data->inDriConf) if (!data->inDriConf)
XML_WARNING1 ("<device> should be inside <driconf>."); XML_WARNING1("<device> should be inside <driconf>.");
if (data->inDevice) if (data->inDevice)
XML_WARNING1 ("nested <device> elements."); XML_WARNING1("nested <device> elements.");
data->inDevice++; data->inDevice++;
if (!data->ignoringDevice && !data->ignoringApp) if (!data->ignoringDevice && !data->ignoringApp)
parseDeviceAttr (data, attr); parseDeviceAttr(data, attr);
break; break;
case OC_APPLICATION: case OC_APPLICATION:
if (!data->inDevice) if (!data->inDevice)
XML_WARNING1 ("<application> should be inside <device>."); XML_WARNING1("<application> should be inside <device>.");
if (data->inApp) if (data->inApp)
XML_WARNING1 ("nested <application> or <engine> elements."); XML_WARNING1("nested <application> or <engine> elements.");
data->inApp++; data->inApp++;
if (!data->ignoringDevice && !data->ignoringApp) if (!data->ignoringDevice && !data->ignoringApp)
parseAppAttr (data, attr); parseAppAttr(data, attr);
break; break;
case OC_ENGINE: case OC_ENGINE:
if (!data->inDevice) if (!data->inDevice)
XML_WARNING1 ("<engine> should be inside <device>."); XML_WARNING1("<engine> should be inside <device>.");
if (data->inApp) if (data->inApp)
XML_WARNING1 ("nested <application> or <engine> elements."); XML_WARNING1("nested <application> or <engine> elements.");
data->inApp++; data->inApp++;
if (!data->ignoringDevice && !data->ignoringApp) if (!data->ignoringDevice && !data->ignoringApp)
parseEngineAttr (data, attr); parseEngineAttr(data, attr);
break; break;
case OC_OPTION: case OC_OPTION:
if (!data->inApp) if (!data->inApp)
XML_WARNING1 ("<option> should be inside <application>."); XML_WARNING1("<option> should be inside <application>.");
if (data->inOption) if (data->inOption)
XML_WARNING1 ("nested <option> elements."); XML_WARNING1("nested <option> elements.");
data->inOption++; data->inOption++;
if (!data->ignoringDevice && !data->ignoringApp) if (!data->ignoringDevice && !data->ignoringApp)
parseOptConfAttr (data, attr); parseOptConfAttr(data, attr);
break; break;
default: default:
XML_WARNING ("unknown element: %s.", name); XML_WARNING("unknown element: %s.", name);
} }
} }
@ -968,7 +969,7 @@ static void
optConfEndElem(void *userData, const XML_Char *name) optConfEndElem(void *userData, const XML_Char *name)
{ {
struct OptConfData *data = (struct OptConfData *)userData; struct OptConfData *data = (struct OptConfData *)userData;
enum OptConfElem elem = bsearchStr (name, OptConfElems, OC_COUNT); enum OptConfElem elem = bsearchStr(name, OptConfElems, OC_COUNT);
switch (elem) { switch (elem) {
case OC_DRICONF: case OC_DRICONF:
data->inDriConf--; data->inDriConf--;
@ -997,13 +998,13 @@ initOptionCache(driOptionCache *cache, const driOptionCache *info)
unsigned i, size = 1 << info->tableSize; unsigned i, size = 1 << info->tableSize;
cache->info = info->info; cache->info = info->info;
cache->tableSize = info->tableSize; cache->tableSize = info->tableSize;
cache->values = malloc((1<<info->tableSize) * sizeof (driOptionValue)); cache->values = malloc((1<<info->tableSize) * sizeof(driOptionValue));
if (cache->values == NULL) { if (cache->values == NULL) {
fprintf (stderr, "%s: %d: out of memory.\n", __FILE__, __LINE__); fprintf(stderr, "%s: %d: out of memory.\n", __FILE__, __LINE__);
abort(); abort();
} }
memcpy (cache->values, info->values, memcpy(cache->values, info->values,
(1<<info->tableSize) * sizeof (driOptionValue)); (1<<info->tableSize) * sizeof(driOptionValue));
for (i = 0; i < size; ++i) { for (i = 0; i < size; ++i) {
if (cache->info[i].type == DRI_STRING) if (cache->info[i].type == DRI_STRING)
XSTRDUP(cache->values[i]._string, info->values[i]._string); XSTRDUP(cache->values[i]._string, info->values[i]._string);
@ -1014,39 +1015,39 @@ static void
_parseOneConfigFile(XML_Parser p) _parseOneConfigFile(XML_Parser p)
{ {
#define BUF_SIZE 0x1000 #define BUF_SIZE 0x1000
struct OptConfData *data = (struct OptConfData *)XML_GetUserData (p); struct OptConfData *data = (struct OptConfData *)XML_GetUserData(p);
int status; int status;
int fd; int fd;
if ((fd = open (data->name, O_RDONLY)) == -1) { if ((fd = open(data->name, O_RDONLY)) == -1) {
__driUtilMessage ("Can't open configuration file %s: %s.", __driUtilMessage("Can't open configuration file %s: %s.",
data->name, strerror (errno)); data->name, strerror(errno));
return; return;
} }
while (1) { while (1) {
int bytesRead; int bytesRead;
void *buffer = XML_GetBuffer (p, BUF_SIZE); void *buffer = XML_GetBuffer(p, BUF_SIZE);
if (!buffer) { if (!buffer) {
__driUtilMessage ("Can't allocate parser buffer."); __driUtilMessage("Can't allocate parser buffer.");
break; break;
} }
bytesRead = read (fd, buffer, BUF_SIZE); bytesRead = read(fd, buffer, BUF_SIZE);
if (bytesRead == -1) { if (bytesRead == -1) {
__driUtilMessage ("Error reading from configuration file %s: %s.", __driUtilMessage("Error reading from configuration file %s: %s.",
data->name, strerror (errno)); data->name, strerror(errno));
break; break;
} }
status = XML_ParseBuffer (p, bytesRead, bytesRead == 0); status = XML_ParseBuffer(p, bytesRead, bytesRead == 0);
if (!status) { if (!status) {
XML_ERROR ("%s.", XML_ErrorString(XML_GetErrorCode(p))); XML_ERROR("%s.", XML_ErrorString(XML_GetErrorCode(p)));
break; break;
} }
if (bytesRead == 0) if (bytesRead == 0)
break; break;
} }
close (fd); close(fd);
#undef BUF_SIZE #undef BUF_SIZE
} }
@ -1056,9 +1057,9 @@ parseOneConfigFile(struct OptConfData *data, const char *filename)
{ {
XML_Parser p; XML_Parser p;
p = XML_ParserCreate (NULL); /* use encoding specified by file */ p = XML_ParserCreate(NULL); /* use encoding specified by file */
XML_SetElementHandler (p, optConfStartElem, optConfEndElem); XML_SetElementHandler(p, optConfStartElem, optConfEndElem);
XML_SetUserData (p, data); XML_SetUserData(p, data);
data->parser = p; data->parser = p;
data->name = filename; data->name = filename;
data->ignoringDevice = 0; data->ignoringDevice = 0;
@ -1068,8 +1069,8 @@ parseOneConfigFile(struct OptConfData *data, const char *filename)
data->inApp = 0; data->inApp = 0;
data->inOption = 0; data->inOption = 0;
_parseOneConfigFile (p); _parseOneConfigFile(p);
XML_ParserFree (p); XML_ParserFree(p);
} }
static int static int
@ -1086,7 +1087,8 @@ scandir_filter(const struct dirent *ent)
return 0; return 0;
#endif #endif
if (fnmatch("*.conf", ent->d_name, 0)) int len = strlen(ent->d_name);
if (len > 5 && strcmp(ent->d_name + len - 5, ".conf") == 0)
return 0; return 0;
return 1; return 1;
@ -1133,7 +1135,7 @@ driParseConfigFiles(driOptionCache *cache, const driOptionCache *info,
char *home; char *home;
struct OptConfData userData; struct OptConfData userData;
initOptionCache (cache, info); initOptionCache(cache, info);
userData.cache = cache; userData.cache = cache;
userData.screenNum = screenNum; userData.screenNum = screenNum;
@ -1148,7 +1150,7 @@ driParseConfigFiles(driOptionCache *cache, const driOptionCache *info,
parseConfigDir(&userData, DATADIR "/drirc.d"); parseConfigDir(&userData, DATADIR "/drirc.d");
parseOneConfigFile(&userData, SYSCONFDIR "/drirc"); parseOneConfigFile(&userData, SYSCONFDIR "/drirc");
if ((home = getenv ("HOME"))) { if ((home = getenv("HOME"))) {
char filename[PATH_MAX]; char filename[PATH_MAX];
snprintf(filename, PATH_MAX, "%s/.drirc", home); snprintf(filename, PATH_MAX, "%s/.drirc", home);
@ -1189,46 +1191,46 @@ unsigned char
driCheckOption(const driOptionCache *cache, const char *name, driCheckOption(const driOptionCache *cache, const char *name,
driOptionType type) driOptionType type)
{ {
uint32_t i = findOption (cache, name); uint32_t i = findOption(cache, name);
return cache->info[i].name != NULL && cache->info[i].type == type; return cache->info[i].name != NULL && cache->info[i].type == type;
} }
unsigned char unsigned char
driQueryOptionb(const driOptionCache *cache, const char *name) driQueryOptionb(const driOptionCache *cache, const char *name)
{ {
uint32_t i = findOption (cache, name); uint32_t i = findOption(cache, name);
/* make sure the option is defined and has the correct type */ /* make sure the option is defined and has the correct type */
assert (cache->info[i].name != NULL); assert(cache->info[i].name != NULL);
assert (cache->info[i].type == DRI_BOOL); assert(cache->info[i].type == DRI_BOOL);
return cache->values[i]._bool; return cache->values[i]._bool;
} }
int int
driQueryOptioni(const driOptionCache *cache, const char *name) driQueryOptioni(const driOptionCache *cache, const char *name)
{ {
uint32_t i = findOption (cache, name); uint32_t i = findOption(cache, name);
/* make sure the option is defined and has the correct type */ /* make sure the option is defined and has the correct type */
assert (cache->info[i].name != NULL); assert(cache->info[i].name != NULL);
assert (cache->info[i].type == DRI_INT || cache->info[i].type == DRI_ENUM); assert(cache->info[i].type == DRI_INT || cache->info[i].type == DRI_ENUM);
return cache->values[i]._int; return cache->values[i]._int;
} }
float float
driQueryOptionf(const driOptionCache *cache, const char *name) driQueryOptionf(const driOptionCache *cache, const char *name)
{ {
uint32_t i = findOption (cache, name); uint32_t i = findOption(cache, name);
/* make sure the option is defined and has the correct type */ /* make sure the option is defined and has the correct type */
assert (cache->info[i].name != NULL); assert(cache->info[i].name != NULL);
assert (cache->info[i].type == DRI_FLOAT); assert(cache->info[i].type == DRI_FLOAT);
return cache->values[i]._float; return cache->values[i]._float;
} }
char * char *
driQueryOptionstr(const driOptionCache *cache, const char *name) driQueryOptionstr(const driOptionCache *cache, const char *name)
{ {
uint32_t i = findOption (cache, name); uint32_t i = findOption(cache, name);
/* make sure the option is defined and has the correct type */ /* make sure the option is defined and has the correct type */
assert (cache->info[i].name != NULL); assert(cache->info[i].name != NULL);
assert (cache->info[i].type == DRI_STRING); assert(cache->info[i].type == DRI_STRING);
return cache->values[i]._string; return cache->values[i]._string;
} }

View file

@ -103,13 +103,13 @@ typedef struct driOptionCache {
* it must be a public symbol __driConfigOptions. It is also passed as a * it must be a public symbol __driConfigOptions. It is also passed as a
* parameter to driParseOptionInfo in order to avoid driver-independent code * parameter to driParseOptionInfo in order to avoid driver-independent code
* depending on symbols in driver-specific code. */ * depending on symbols in driver-specific code. */
void driParseOptionInfo (driOptionCache *info, void driParseOptionInfo(driOptionCache *info,
const char *configOptions); const char *configOptions);
/** \brief Initialize option cache from info and parse configuration files /** \brief Initialize option cache from info and parse configuration files
* *
* To be called in <driver>CreateContext. screenNum, driverName, * To be called in <driver>CreateContext. screenNum, driverName,
* kernelDriverName, applicationName and engineName select device sections. */ * kernelDriverName, applicationName and engineName select device sections. */
void driParseConfigFiles (driOptionCache *cache, const driOptionCache *info, void driParseConfigFiles(driOptionCache *cache, const driOptionCache *info,
int screenNum, const char *driverName, int screenNum, const char *driverName,
const char *kernelDriverName, const char *kernelDriverName,
const char *applicationName, uint32_t applicationVersion, const char *applicationName, uint32_t applicationVersion,
@ -117,24 +117,24 @@ void driParseConfigFiles (driOptionCache *cache, const driOptionCache *info,
/** \brief Destroy option info /** \brief Destroy option info
* *
* To be called in <driver>DestroyScreen */ * To be called in <driver>DestroyScreen */
void driDestroyOptionInfo (driOptionCache *info); void driDestroyOptionInfo(driOptionCache *info);
/** \brief Destroy option cache /** \brief Destroy option cache
* *
* To be called in <driver>DestroyContext */ * To be called in <driver>DestroyContext */
void driDestroyOptionCache (driOptionCache *cache); void driDestroyOptionCache(driOptionCache *cache);
/** \brief Check if there exists a certain option */ /** \brief Check if there exists a certain option */
unsigned char driCheckOption (const driOptionCache *cache, const char *name, unsigned char driCheckOption(const driOptionCache *cache, const char *name,
driOptionType type); driOptionType type);
/** \brief Query a boolean option value */ /** \brief Query a boolean option value */
unsigned char driQueryOptionb (const driOptionCache *cache, const char *name); unsigned char driQueryOptionb(const driOptionCache *cache, const char *name);
/** \brief Query an integer option value */ /** \brief Query an integer option value */
int driQueryOptioni (const driOptionCache *cache, const char *name); int driQueryOptioni(const driOptionCache *cache, const char *name);
/** \brief Query a floating-point option value */ /** \brief Query a floating-point option value */
float driQueryOptionf (const driOptionCache *cache, const char *name); float driQueryOptionf(const driOptionCache *cache, const char *name);
/** \brief Query a string option value */ /** \brief Query a string option value */
char *driQueryOptionstr (const driOptionCache *cache, const char *name); char *driQueryOptionstr(const driOptionCache *cache, const char *name);
/** /**
* Returns a hash of the options for this application. * Returns a hash of the options for this application.