From 1a777c7b08fc99b51cd2dc72188d45ee6d82804a Mon Sep 17 00:00:00 2001 From: Eleni Maria Stea Date: Tue, 12 Feb 2013 13:55:38 +0200 Subject: [PATCH] added support for numerical values in option struct --- src/cfg.c | 21 ++++++++++++--------- src/cfg.h | 7 ++++++- src/gliar.c | 28 ++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 10 deletions(-) diff --git a/src/cfg.c b/src/cfg.c index 8902d9c..124449e 100644 --- a/src/cfg.c +++ b/src/cfg.c @@ -64,7 +64,9 @@ struct cfgopt *gliar_load_cfg(const char *fname) if((opt = malloc(sizeof *opt))) { if((opt->key = malloc(strlen(line) + 1))) { strcpy(opt->key, line); - opt->val = 0; + opt->str_val = 0; + opt->num_val = 0; + opt->type = unknown; } else { free(opt); opt = 0; @@ -72,15 +74,16 @@ struct cfgopt *gliar_load_cfg(const char *fname) } } else { char *tmp; - int prev_len = opt->val ? strlen(opt->val) : 0; + int prev_len = opt->str_val ? strlen(opt->str_val) : 0; - if(opt && (tmp = realloc(opt->val, prev_len + strlen(line) + 2))) { - opt->val = tmp; + if(opt && (tmp = realloc(opt->str_val, prev_len + strlen(line) + 2))) { + opt->type = str; + opt->str_val = tmp; if(prev_len) { - strcat(opt->val, " "); - strcat(opt->val, line); + strcat(opt->str_val, " "); + strcat(opt->str_val, line); } else { - strcpy(opt->val, line); + strcpy(opt->str_val, line); } } } @@ -103,7 +106,7 @@ const char *gliar_find_opt(struct cfgopt *list, const char *name) while(list) { if(strcmp(list->key, name) == 0) { - return list->val; + return list->str_val; } list = list->next; } @@ -114,7 +117,7 @@ void gliar_print_opt(struct cfgopt *list) { printf("OPTIONS\n"); while(list) { - printf("\"%s\" -> \"%s\"\n", list->key, list->val); + printf("\"%s\" -> \"%s\"\n", list->key, list->str_val); list = list->next; } } diff --git a/src/cfg.h b/src/cfg.h index 5013e66..4f18d2d 100644 --- a/src/cfg.h +++ b/src/cfg.h @@ -23,9 +23,14 @@ Author: Eleni Maria Stea #ifndef CFG_H_ #define CFG_H_ +enum TYPE {unknown, flt, dbl, boolean, integer, str}; + struct cfgopt { char *key; - char *val; + char *str_val; + + double num_val; + enum TYPE type; struct cfgopt *next; }; diff --git a/src/gliar.c b/src/gliar.c index e730a40..0508a10 100644 --- a/src/gliar.c +++ b/src/gliar.c @@ -30,7 +30,22 @@ Author: Eleni Maria Stea #include "cfg.h" static int done_init; + static const GLubyte* (*gl_get_string)(GLenum); +/*static const GLubyte* (*gl_get_stringi)(GLenum, GLuint); + +static const void* (*gl_get_booleanv)(GLenum, GLboolean*); +static const void* (*gl_get_doublev)(GLenum, GLdouble*); +static const void* (*gl_get_floatv)(GLenum, GLfloat*); +static const void* (*gl_get_integerv)(GLenum, GLint*); +static const void* (*gl_get_integer64v)(GLenum, GLint64*); + +static const void* (*gl_get_booleani_v)(GLenum, GLuint, GLboolean*); +static const void* (*gl_get_doublei_v)(GLenum, GLuint, GLdouble*); +static const void* (*gl_get_floati_v)(GLenum, GLuint, GLfloat*); +static const void* (*gl_get_integeri_v)(GLenum, GLuint, GLint*); +static const void* (*gl_get_integer64i_v)(GLenum, GLuint, GLint64*);*/ + static struct cfgopt *cfglist; static int init(void) @@ -58,6 +73,19 @@ static int init(void) } gl_get_string = dlsym(RTLD_NEXT, "glGetString"); +/* gl_get_stringi = dlsym(RTLD_NEXT, "glGetStringi"); + + gl_get_booleanv = dlsym(RTLD_NEXT, "glGetBooleanv"); + gl_get_doublev = dlsym(RTLD_NEXT, "glGetDoublev"); + gl_get_floatv = dlsym(RTLD_NEXT, "glGetFloatv"); + gl_get_integerv = dlsym(RTLD_NEXT, "glGetIntegerv"); + gl_get_integer64v = dlsym(RTLD_NEXT, "glGetInteger64v"); + + gl_get_booleani_v = dlsym(RTLD_NEXT, "glGetBooleani_v"); + gl_get_doublei_v = dlsym(RTLD_NEXT, "glGetDoublei_v"); + gl_get_floati_v = dlsym(RTLD_NEXT, "glGetFloati_v"); + gl_get_integeri_v = dlsym(RTLD_NEXT, "glGetIntegeri_v"); + gl_get_integer64i_v = dlsym(RTLD_NEXT, "glGetInteger64i_v");*/ done_init = 1; return 0; -- 1.7.10.4