Statistics
| Branch: | Revision:

grapes / som / ChunkBuffer / config.c @ 03dddbe7

History | View | Annotate | Download (788 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

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

    
26
  return res;
27
}
28

    
29
int config_value_int(const struct tag *cfg_values, const char *value, int *res)
30
{
31
  int i, done;
32

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

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

    
47
  return 0;
48
}