23 #define _WIN32_IE 0x501
25 #define _WIN32_IE 0x400
50 unsigned int entryCount;
85 ERR(
"config parse error: bad line \"%s\"\n",
buffer);
95 WARN(
"config warning: extra data after block: \"%s\"\n",
buffer+i);
103 if(strcasecmp(cfgBlocks[i].
name,
buffer+1) == 0)
105 nextBlock = cfgBlocks+
i;
106 TRACE(
"found block '%s'\n", nextBlock->name);
116 ERR(
"config parse error: error reallocating config blocks\n");
119 cfgBlocks = nextBlock;
124 nextBlock->entries =
NULL;
125 nextBlock->entryCount = 0;
127 TRACE(
"found new block '%s'\n", nextBlock->name);
129 curBlock = nextBlock;
141 ERR(
"config parse error: malformed option line: \"%s\"\n",
buffer);
154 ERR(
"config parse error: option without a value: \"%s\"\n",
buffer);
164 ent = curBlock->entries;
165 while((
unsigned int)(ent-curBlock->entries) < curBlock->entryCount)
167 if(strcasecmp(ent->key,
buffer) == 0)
172 if((
unsigned int)(ent-curBlock->entries) >= curBlock->entryCount)
178 ERR(
"config parse error: error reallocating config entries\n");
181 curBlock->entries = ent;
182 ent = curBlock->entries + curBlock->entryCount;
183 curBlock->entryCount++;
198 }
while(i >= 0 && isspace(
buffer[i]));
204 TRACE(
"found '%s' = '%s'\n", ent->key, ent->value);
214 cfgBlocks->name =
strdup(
"general");
230 f = fopen(
"/etc/openal/alsoft.conf",
"r");
236 if((str=getenv(
"HOME")) !=
NULL && *str)
247 if((str=getenv(
"ALSOFT_CONF")) !=
NULL && *str)
265 for(j = 0;j < cfgBlocks[
i].entryCount;j++)
278 const char *
GetConfigValue(
const char *blockName,
const char *keyName,
const char *def)
286 blockName =
"general";
290 if(strcasecmp(cfgBlocks[i].
name, blockName) != 0)
293 for(j = 0;j < cfgBlocks[
i].entryCount;j++)
295 if(strcasecmp(cfgBlocks[i].
entries[j].key, keyName) == 0)
297 TRACE(
"Found %s:%s = \"%s\"\n", blockName, keyName,
299 if(cfgBlocks[i].
entries[j].value[0])
300 return cfgBlocks[
i].entries[
j].value;
306 TRACE(
"Key %s:%s not found\n", blockName, keyName);
319 if(!val[0])
return 0;
328 if(!val[0])
return 0;
330 *ret = strtol(val,
NULL, 0);
337 if(!val[0])
return 0;
339 *ret = strtoul(val,
NULL, 0);
346 if(!val[0])
return 0;
349 *ret = strtof(val,
NULL);
351 *ret = (float)strtod(val,
NULL);
360 if(!val[0])
return !!def;
361 return (strcasecmp(val,
"true") == 0 || strcasecmp(val,
"yes") == 0 ||
362 strcasecmp(val,
"on") == 0 || atoi(val) != 0);
int ConfigValueStr(const char *blockName, const char *keyName, const char **ret)
GLuint const GLfloat * val
char * strdup(const char *inStr)
int ConfigValueInt(const char *blockName, const char *keyName, int *ret)
int ConfigValueUInt(const char *blockName, const char *keyName, unsigned int *ret)
EGLImageKHR EGLint * name
int ConfigValueExists(const char *blockName, const char *keyName)
const char * GetConfigValue(const char *blockName, const char *keyName, const char *def)
EGLContext EGLenum EGLClientBuffer buffer
int GetConfigValueBool(const char *blockName, const char *keyName, int def)
static void LoadConfigFromFile(FILE *f)
struct ConfigBlock ConfigBlock
struct ConfigEntry ConfigEntry
static ConfigBlock * cfgBlocks
EGLSurface EGLint void ** value
int ConfigValueFloat(const char *blockName, const char *keyName, float *ret)
static unsigned int cfgCount