+/*
+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 <http://www.gnu.org/licenses/>.
+
+Author: Eleni Maria Stea <elene.mst@gmail.com>
+*/
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
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 {
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);
}
}
}
while(list) {
if(strcmp(list->key, name) == 0) {
- return list->val;
+ return list->str_val;
}
list = list->next;
}
{
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;
}
}