X-Git-Url: http://git.mutantstargoat.com?a=blobdiff_plain;f=src%2Fcfg.c;h=124449edaab9b00631019ba7e6960a86a67dff36;hb=1a777c7b08fc99b51cd2dc72188d45ee6d82804a;hp=4f317d2818531c7d42bc0338a66bcb67d5ab755b;hpb=b82d60137dc0b16ef451936fcc97fa8f25fe7b33;p=libgliar
diff --git a/src/cfg.c b/src/cfg.c
index 4f317d2..124449e 100644
--- a/src/cfg.c
+++ b/src/cfg.c
@@ -1,3 +1,25 @@
+/*
+libgliar - a library that can fake the OpenGL context info returned by
+the glGet OpenGL calls
+
+Copyright (C) 2013 Canonical Ltd
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see .
+
+Author: Eleni Maria Stea
+*/
+
#include
#include
#include
@@ -42,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;
@@ -50,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);
}
}
}
@@ -81,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;
}
@@ -92,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;
}
}