Statistics
| Branch: | Revision:

grapes / som / ChunkBuffer / config.c @ ced82324

History | View | Annotate | Download (852 Bytes)

1
#include <stdlib.h>
2
#include <string.h>
3
#include "config.h"
4

    
5
struct tag {
6
  char name[32];
7
  char value[16];
8
};
9

    
10
#define MAX_TAGS 16
11

    
12
#warning Fix config_parse
13
struct tag *config_parse(const char *cfg)
14
{
15
  /* Fake Implementation */
16
  struct tag *res;
17
  int i = 0;
18

    
19
  res = malloc(sizeof(struct tag) * MAX_TAGS);
20
  if (res == NULL) {
21
    return res;
22
  }
23
  strcpy(res[i].name, "size");
24
  strcpy(res[i++].value, "32");
25
  res[i++].name[0] = 0;
26

    
27
  res = realloc(res, sizeof(struct tag) * i);
28

    
29
  return res;
30
}
31

    
32
int config_value_int(const struct tag *cfg_values, const char *value, int *res)
33
{
34
  int i, done;
35

    
36
  i = 0; done = 0;
37
  while (!done) {
38
    if (!strcmp(cfg_values[i].name, value)) {
39
      *res = atoi(cfg_values[i].value);
40

    
41
      return 1;
42
    }
43
    if (cfg_values[i].name[0] == 0) {
44
      done = 1;
45
    } else {
46
      i++;
47
    }
48
  }
49

    
50
  return 0;
51
}