- char *tmp;
- int prev_len = opt->val ? strlen(opt->val) : 0;
-
- if(opt && (tmp = realloc(opt->val, prev_len + strlen(line) + 2))) {
- opt->val = tmp;
- if(prev_len) {
- strcat(opt->val, " ");
- strcat(opt->val, line);
- } else {
- strcpy(opt->val, line);
+ /* found a value for the current key (opt->key) */
+ int i, num, new_sz = opt->str_count + 1;
+ char **tmp;
+ char *end;
+
+ if(filter) {
+ for(i=0; i<filter->str_count; i++) {
+ if(strcmp(line, filter->str_val[i]) == 0) {
+ break;
+ }
+ }
+
+ if(i == filter->str_count) {
+ /* the string is not in the valid list, ignore it */
+ fprintf(stderr, "GLIAR: extension %s not supported, ignoring\n", line);
+ continue;
+ }
+ }
+
+ num = strtol(line, &end, 10);
+ if(!*end) {
+ opt->num_val = num;
+ opt->type = GLIAR_NUMBER;
+ }
+
+ if(opt && (tmp = realloc(opt->str_val, new_sz * sizeof(char*)))) {
+ opt->str_val = tmp;
+ if((opt->str_val[new_sz - 1] = malloc(strlen(line) + 1))) {
+ strcpy(opt->str_val[new_sz -1], line);
+ opt->str_count = new_sz;