mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-07 02:48:06 +02:00
xmlconfig: Reshuffle to keep attr processing
For the static-table alternative to WITH_XMLCONFIG, we are going to want to re-use the element attribute processing, to avoid duplicating things like engine name regexp matching and version range matching. This just shuffles things around a bit so we can re-use useful parts in the next patch. Signed-off-by: Rob Clark <robdclark@chromium.org> Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9179>
This commit is contained in:
parent
a6b0ceb341
commit
c83400e673
1 changed files with 41 additions and 33 deletions
|
|
@ -42,8 +42,8 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <regex.h>
|
|
||||||
#endif
|
#endif
|
||||||
|
#include <regex.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include "strndup.h"
|
#include "strndup.h"
|
||||||
|
|
@ -520,8 +520,6 @@ driGetOptionsXml(const driOptionDescription *configOptions, unsigned numOptions)
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if WITH_XMLCONFIG
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Print message to \c stderr if the \c LIBGL_DEBUG environment variable
|
* Print message to \c stderr if the \c LIBGL_DEBUG environment variable
|
||||||
* is set.
|
* is set.
|
||||||
|
|
@ -546,6 +544,12 @@ __driUtilMessage(const char *f, ...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* We don't have real line/column # info in static-config case: */
|
||||||
|
#if !WITH_XML_CONFIG
|
||||||
|
# define XML_GetCurrentLineNumber(p) -1
|
||||||
|
# define XML_GetCurrentColumnNumber(p) -1
|
||||||
|
#endif
|
||||||
|
|
||||||
/** \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, \
|
||||||
|
|
@ -574,7 +578,9 @@ __driUtilMessage(const char *f, ...)
|
||||||
/** \brief Parser context for configuration files. */
|
/** \brief Parser context for configuration files. */
|
||||||
struct OptConfData {
|
struct OptConfData {
|
||||||
const char *name;
|
const char *name;
|
||||||
|
#if WITH_XMLCONFIG
|
||||||
XML_Parser parser;
|
XML_Parser parser;
|
||||||
|
#endif
|
||||||
driOptionCache *cache;
|
driOptionCache *cache;
|
||||||
int screenNum;
|
int screenNum;
|
||||||
const char *driverName, *execName;
|
const char *driverName, *execName;
|
||||||
|
|
@ -591,33 +597,6 @@ struct OptConfData {
|
||||||
uint32_t inOption;
|
uint32_t inOption;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** \brief Elements in configuration files. */
|
|
||||||
enum OptConfElem {
|
|
||||||
OC_APPLICATION = 0, OC_DEVICE, OC_DRICONF, OC_ENGINE, OC_OPTION, OC_COUNT
|
|
||||||
};
|
|
||||||
static const char *OptConfElems[] = {
|
|
||||||
[OC_APPLICATION] = "application",
|
|
||||||
[OC_DEVICE] = "device",
|
|
||||||
[OC_DRICONF] = "driconf",
|
|
||||||
[OC_ENGINE] = "engine",
|
|
||||||
[OC_OPTION] = "option",
|
|
||||||
};
|
|
||||||
|
|
||||||
static int compare(const void *a, const void *b) {
|
|
||||||
return strcmp(*(char *const*)a, *(char *const*)b);
|
|
||||||
}
|
|
||||||
/** \brief Binary search in a string array. */
|
|
||||||
static uint32_t
|
|
||||||
bsearchStr(const char *name, const char *elems[], uint32_t count)
|
|
||||||
{
|
|
||||||
const char **found;
|
|
||||||
found = bsearch(&name, elems, count, sizeof(char *), compare);
|
|
||||||
if (found)
|
|
||||||
return found - elems;
|
|
||||||
else
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** \brief Parse a list of ranges of type info->type. */
|
/** \brief Parse a list of ranges of type info->type. */
|
||||||
static unsigned char
|
static unsigned char
|
||||||
parseRange(driOptionInfo *info, const char *string)
|
parseRange(driOptionInfo *info, const char *string)
|
||||||
|
|
@ -820,6 +799,35 @@ parseOptConfAttr(struct OptConfData *data, const char **attr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if WITH_XMLCONFIG
|
||||||
|
|
||||||
|
/** \brief Elements in configuration files. */
|
||||||
|
enum OptConfElem {
|
||||||
|
OC_APPLICATION = 0, OC_DEVICE, OC_DRICONF, OC_ENGINE, OC_OPTION, OC_COUNT
|
||||||
|
};
|
||||||
|
static const char *OptConfElems[] = {
|
||||||
|
[OC_APPLICATION] = "application",
|
||||||
|
[OC_DEVICE] = "device",
|
||||||
|
[OC_DRICONF] = "driconf",
|
||||||
|
[OC_ENGINE] = "engine",
|
||||||
|
[OC_OPTION] = "option",
|
||||||
|
};
|
||||||
|
|
||||||
|
static int compare(const void *a, const void *b) {
|
||||||
|
return strcmp(*(char *const*)a, *(char *const*)b);
|
||||||
|
}
|
||||||
|
/** \brief Binary search in a string array. */
|
||||||
|
static uint32_t
|
||||||
|
bsearchStr(const char *name, const char *elems[], uint32_t count)
|
||||||
|
{
|
||||||
|
const char **found;
|
||||||
|
found = bsearch(&name, elems, count, sizeof(char *), compare);
|
||||||
|
if (found)
|
||||||
|
return found - elems;
|
||||||
|
else
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
/** \brief Handler for start element events. */
|
/** \brief Handler for start element events. */
|
||||||
static void
|
static void
|
||||||
optConfStartElem(void *userData, const char *name,
|
optConfStartElem(void *userData, const char *name,
|
||||||
|
|
@ -1061,9 +1069,6 @@ driParseConfigFiles(driOptionCache *cache, const driOptionCache *info,
|
||||||
const char *engineName, uint32_t engineVersion)
|
const char *engineName, uint32_t engineVersion)
|
||||||
{
|
{
|
||||||
initOptionCache(cache, info);
|
initOptionCache(cache, info);
|
||||||
|
|
||||||
#if WITH_XMLCONFIG
|
|
||||||
char *home;
|
|
||||||
struct OptConfData userData;
|
struct OptConfData userData;
|
||||||
|
|
||||||
userData.cache = cache;
|
userData.cache = cache;
|
||||||
|
|
@ -1076,6 +1081,9 @@ driParseConfigFiles(driOptionCache *cache, const driOptionCache *info,
|
||||||
userData.engineVersion = engineVersion;
|
userData.engineVersion = engineVersion;
|
||||||
userData.execName = execname ?: util_get_process_name();
|
userData.execName = execname ?: util_get_process_name();
|
||||||
|
|
||||||
|
#if WITH_XMLCONFIG
|
||||||
|
char *home;
|
||||||
|
|
||||||
parseConfigDir(&userData, datadir);
|
parseConfigDir(&userData, datadir);
|
||||||
parseOneConfigFile(&userData, SYSCONFDIR "/drirc");
|
parseOneConfigFile(&userData, SYSCONFDIR "/drirc");
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue