# include <stdlib.h>
# include <libgen.h>
-static const char *__getProgramName () {
+static const char *
+__getProgramName()
+{
static const char *progname;
if (progname == NULL) {
/* This is a hack. It's said to work on OpenBSD, NetBSD and GNU.
* Rogelio M.Serrano Jr. reported it's also working with UCLIBC. It's
* used as a last resort, if there is no documented facility available. */
-static const char *__getProgramName () {
+static const char *
+__getProgramName()
+{
extern const char *__progname;
char * arg = strrchr(__progname, '/');
if (arg)
#endif
/** \brief Find an option in an option cache with the name as key */
-static uint32_t findOption (const driOptionCache *cache, const char *name) {
+static uint32_t
+findOption(const driOptionCache *cache, const char *name)
+{
uint32_t len = strlen (name);
uint32_t size = 1 << cache->tableSize, mask = size - 1;
uint32_t hash = 0;
return strcmp (*(char *const*)a, *(char *const*)b);
}
/** \brief Binary search in a string array. */
-static uint32_t bsearchStr (const XML_Char *name,
- const XML_Char *elems[], uint32_t count) {
+static uint32_t
+bsearchStr (const XML_Char *name, const XML_Char *elems[], uint32_t count)
+{
const XML_Char **found;
found = bsearch (&name, elems, count, sizeof (XML_Char *), compare);
if (found)
* returning tail points to the first character that is not part of
* the integer number. If no number was found then tail points to the
* start of the input string. */
-static int strToI (const XML_Char *string, const XML_Char **tail, int base) {
+static int
+strToI(const XML_Char *string, const XML_Char **tail, int base)
+{
int radix = base == 0 ? 10 : base;
int result = 0;
int sign = 1;
* to the start of the input string.
*
* Uses two passes for maximum accuracy. */
-static float strToF (const XML_Char *string, const XML_Char **tail) {
+static float
+strToF(const XML_Char *string, const XML_Char **tail)
+{
int nDigits = 0, pointPos, exponent;
float sign = 1.0f, result = 0.0f, scale;
const XML_Char *start = string, *numStart;
}
/** \brief Parse a value of a given type. */
-static unsigned char parseValue (driOptionValue *v, driOptionType type,
- const XML_Char *string) {
+static unsigned char
+parseValue(driOptionValue *v, driOptionType type, const XML_Char *string)
+{
const XML_Char *tail = NULL;
/* skip leading white-space */
string += strspn (string, " \f\n\r\t\v");
}
/** \brief Parse a list of ranges of type info->type. */
-static unsigned char parseRanges (driOptionInfo *info, const XML_Char *string) {
+static unsigned char
+parseRanges(driOptionInfo *info, const XML_Char *string)
+{
XML_Char *cp, *range;
uint32_t nRanges, i;
driOptionRange *ranges;
}
/** \brief Check if a value is in one of info->ranges. */
-static bool checkValue (const driOptionValue *v, const driOptionInfo *info) {
+static bool
+checkValue(const driOptionValue *v, const driOptionInfo *info)
+{
uint32_t i;
assert (info->type != DRI_BOOL); /* should be caught by the parser */
if (info->nRanges == 0)
* We're not actually interested in the data. Just make sure this is ok
* for external configuration tools.
*/
-static void parseEnumAttr (struct OptInfoData *data, const XML_Char **attr) {
+static void
+parseEnumAttr(struct OptInfoData *data, const XML_Char **attr)
+{
uint32_t i;
const XML_Char *value = NULL, *text = NULL;
driOptionValue v;
* We're not actually interested in the data. Just make sure this is ok
* for external configuration tools.
*/
-static void parseDescAttr (struct OptInfoData *data, const XML_Char **attr) {
+static void
+parseDescAttr(struct OptInfoData *data, const XML_Char **attr)
+{
uint32_t i;
const XML_Char *lang = NULL, *text = NULL;
for (i = 0; attr[i]; i += 2) {
}
/** \brief Parse attributes of an option element. */
-static void parseOptInfoAttr (struct OptInfoData *data, const XML_Char **attr) {
+static void
+parseOptInfoAttr(struct OptInfoData *data, const XML_Char **attr)
+{
enum OptAttr {OA_DEFAULT = 0, OA_NAME, OA_TYPE, OA_VALID, OA_COUNT};
static const XML_Char *optAttr[] = {"default", "name", "type", "valid"};
const XML_Char *attrVal[OA_COUNT] = {NULL, NULL, NULL, NULL};
}
/** \brief Handler for start element events. */
-static void optInfoStartElem (void *userData, const XML_Char *name,
- const XML_Char **attr) {
+static void
+optInfoStartElem(void *userData, const XML_Char *name, const XML_Char **attr)
+{
struct OptInfoData *data = (struct OptInfoData *)userData;
enum OptInfoElem elem = bsearchStr (name, OptInfoElems, OI_COUNT);
switch (elem) {
}
/** \brief Handler for end element events. */
-static void optInfoEndElem (void *userData, const XML_Char *name) {
+static void
+optInfoEndElem(void *userData, const XML_Char *name)
+{
struct OptInfoData *data = (struct OptInfoData *)userData;
enum OptInfoElem elem = bsearchStr (name, OptInfoElems, OI_COUNT);
switch (elem) {
}
}
-void driParseOptionInfo (driOptionCache *info, const char *configOptions) {
+void
+driParseOptionInfo(driOptionCache *info, const char *configOptions)
+{
XML_Parser p;
int status;
struct OptInfoData userData;
};
/** \brief Parse attributes of a device element. */
-static void parseDeviceAttr (struct OptConfData *data, const XML_Char **attr) {
+static void
+parseDeviceAttr(struct OptConfData *data, const XML_Char **attr)
+{
uint32_t i;
const XML_Char *driver = NULL, *screen = NULL;
for (i = 0; attr[i]; i += 2) {
}
/** \brief Parse attributes of an application element. */
-static void parseAppAttr (struct OptConfData *data, const XML_Char **attr) {
+static void
+parseAppAttr(struct OptConfData *data, const XML_Char **attr)
+{
uint32_t i;
const XML_Char *exec = NULL;
for (i = 0; attr[i]; i += 2) {
}
/** \brief Parse attributes of an option element. */
-static void parseOptConfAttr (struct OptConfData *data, const XML_Char **attr) {
+static void
+parseOptConfAttr(struct OptConfData *data, const XML_Char **attr)
+{
uint32_t i;
const XML_Char *name = NULL, *value = NULL;
for (i = 0; attr[i]; i += 2) {
}
/** \brief Handler for start element events. */
-static void optConfStartElem (void *userData, const XML_Char *name,
- const XML_Char **attr) {
+static void
+optConfStartElem(void *userData, const XML_Char *name,
+ const XML_Char **attr)
+{
struct OptConfData *data = (struct OptConfData *)userData;
enum OptConfElem elem = bsearchStr (name, OptConfElems, OC_COUNT);
switch (elem) {
}
/** \brief Handler for end element events. */
-static void optConfEndElem (void *userData, const XML_Char *name) {
+static void
+optConfEndElem(void *userData, const XML_Char *name)
+{
struct OptConfData *data = (struct OptConfData *)userData;
enum OptConfElem elem = bsearchStr (name, OptConfElems, OC_COUNT);
switch (elem) {
}
/** \brief Initialize an option cache based on info */
-static void initOptionCache (driOptionCache *cache, const driOptionCache *info) {
+static void
+initOptionCache(driOptionCache *cache, const driOptionCache *info)
+{
GLuint i, size = 1 << info->tableSize;
cache->info = info->info;
cache->tableSize = info->tableSize;
}
/** \brief Parse the named configuration file */
-static void parseOneConfigFile (XML_Parser p) {
+static void
+parseOneConfigFile(XML_Parser p)
+{
#define BUF_SIZE 0x1000
struct OptConfData *data = (struct OptConfData *)XML_GetUserData (p);
int status;
#define SYSCONFDIR "/etc"
#endif
-void driParseConfigFiles (driOptionCache *cache, const driOptionCache *info,
- int screenNum, const char *driverName) {
+void
+driParseConfigFiles(driOptionCache *cache, const driOptionCache *info,
+ int screenNum, const char *driverName)
+{
char *filenames[2] = { SYSCONFDIR "/drirc", NULL};
char *home;
uint32_t i;
free(filenames[1]);
}
-void driDestroyOptionInfo (driOptionCache *info) {
- driDestroyOptionCache (info);
+void
+driDestroyOptionInfo(driOptionCache *info)
+{
+ driDestroyOptionCache(info);
if (info->info) {
uint32_t i, size = 1 << info->tableSize;
for (i = 0; i < size; ++i) {
}
}
-void driDestroyOptionCache (driOptionCache *cache) {
+void
+driDestroyOptionCache(driOptionCache *cache)
+{
if (cache->info) {
GLuint i, size = 1 << cache->tableSize;
for (i = 0; i < size; ++i) {
free(cache->values);
}
-unsigned char driCheckOption (const driOptionCache *cache, const char *name,
- driOptionType type) {
+unsigned char
+driCheckOption(const driOptionCache *cache, const char *name,
+ driOptionType type)
+{
uint32_t i = findOption (cache, name);
return cache->info[i].name != NULL && cache->info[i].type == type;
}
-unsigned char driQueryOptionb (const driOptionCache *cache, const char *name) {
+unsigned char
+driQueryOptionb(const driOptionCache *cache, const char *name)
+{
uint32_t i = findOption (cache, name);
/* make sure the option is defined and has the correct type */
assert (cache->info[i].name != NULL);
return cache->values[i]._bool;
}
-int driQueryOptioni (const driOptionCache *cache, const char *name) {
+int
+driQueryOptioni(const driOptionCache *cache, const char *name)
+{
uint32_t i = findOption (cache, name);
/* make sure the option is defined and has the correct type */
assert (cache->info[i].name != NULL);
return cache->values[i]._int;
}
-float driQueryOptionf (const driOptionCache *cache, const char *name) {
+float
+driQueryOptionf(const driOptionCache *cache, const char *name)
+{
uint32_t i = findOption (cache, name);
/* make sure the option is defined and has the correct type */
assert (cache->info[i].name != NULL);
return cache->values[i]._float;
}
-char *driQueryOptionstr (const driOptionCache *cache, const char *name) {
+char *
+driQueryOptionstr(const driOptionCache *cache, const char *name)
+{
GLuint i = findOption (cache, name);
/* make sure the option is defined and has the correct type */
assert (cache->info[i].name != NULL);