#include <errno.h>
#include <dirent.h>
#include <sys/stat.h>
-#include <regex.h>
#endif
+#include <regex.h>
#include <fcntl.h>
#include <math.h>
#include "strndup.h"
return output;
}
-#if WITH_XMLCONFIG
-
/**
* Print message to \c stderr if the \c LIBGL_DEBUG environment variable
* is set.
}
}
+/* 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. */
#define XML_WARNING1(msg) do { \
__driUtilMessage("Warning in %s line %d, column %d: "msg, data->name, \
/** \brief Parser context for configuration files. */
struct OptConfData {
const char *name;
+#if WITH_XMLCONFIG
XML_Parser parser;
+#endif
driOptionCache *cache;
int screenNum;
const char *driverName, *execName;
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. */
static unsigned char
parseRange(driOptionInfo *info, const char *string)
}
}
+#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. */
static void
optConfStartElem(void *userData, const char *name,
const char *engineName, uint32_t engineVersion)
{
initOptionCache(cache, info);
-
-#if WITH_XMLCONFIG
- char *home;
struct OptConfData userData;
userData.cache = cache;
userData.engineVersion = engineVersion;
userData.execName = execname ?: util_get_process_name();
+#if WITH_XMLCONFIG
+ char *home;
+
parseConfigDir(&userData, datadir);
parseOneConfigFile(&userData, SYSCONFDIR "/drirc");