added support for numerical values in option struct
authorEleni Maria Stea <elene.mst@gmail.com>
Tue, 12 Feb 2013 11:55:38 +0000 (13:55 +0200)
committerEleni Maria Stea <elene.mst@gmail.com>
Tue, 12 Feb 2013 11:55:38 +0000 (13:55 +0200)
src/cfg.c
src/cfg.h
src/gliar.c

index 8902d9c..124449e 100644 (file)
--- 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);
                        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;
                                } else {
                                        free(opt);
                                        opt = 0;
@@ -72,15 +74,16 @@ struct cfgopt *gliar_load_cfg(const char *fname)
                        }
                } else {
                        char *tmp;
                        }
                } 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) {
                                if(prev_len) {
-                                       strcat(opt->val, " ");
-                                       strcat(opt->val, line);
+                                       strcat(opt->str_val, " ");
+                                       strcat(opt->str_val, line);
                                } else {
                                } 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) {
 
        while(list) {
                if(strcmp(list->key, name) == 0) {
-                       return list->val;
+                       return list->str_val;
                }
                list = list->next;
        }
                }
                list = list->next;
        }
@@ -114,7 +117,7 @@ void gliar_print_opt(struct cfgopt *list)
 {
        printf("OPTIONS\n");
        while(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;
        }
 }
                list = list->next;
        }
 }
index 5013e66..4f18d2d 100644 (file)
--- a/src/cfg.h
+++ b/src/cfg.h
@@ -23,9 +23,14 @@ Author: Eleni Maria Stea <elene.mst@gmail.com>
 #ifndef CFG_H_
 #define CFG_H_
 
 #ifndef CFG_H_
 #define CFG_H_
 
+enum TYPE {unknown, flt, dbl, boolean, integer, str};
+
 struct cfgopt {
        char *key;
 struct cfgopt {
        char *key;
-       char *val;
+       char *str_val;
+
+  double num_val;
+  enum TYPE type;
 
        struct cfgopt *next;
 };
 
        struct cfgopt *next;
 };
index e730a40..0508a10 100644 (file)
@@ -30,7 +30,22 @@ Author: Eleni Maria Stea <elene.mst@gmail.com>
 #include "cfg.h"
 
 static int done_init;
 #include "cfg.h"
 
 static int done_init;
+
 static const GLubyte* (*gl_get_string)(GLenum);
 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)
 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_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;
 
        done_init = 1;
        return 0;