Statistics
| Branch: | Revision:

grapes / src / Tests / config_test.c @ c5922d21

History | View | Annotate | Download (814 Bytes)

1
/*
2
 *  Copyright (c) 2010 Luca Abeni
3
 *
4
 *  This is free software; see gpl-3.0.txt
5
 */
6

    
7
#include <stdlib.h>
8
#include <stdio.h>
9
#include "grapes_config.h"
10

    
11
int main(int argc, char *argv[])
12
{
13
  struct tag *cfg_tags;
14
  int size=-1, len=-1, dummy=-1, res;
15
  
16
  cfg_tags = grapes_config_parse("size=10");
17
  res = grapes_config_value_int(cfg_tags, "size", &size);
18
  printf("%d: Is %d = %d?\n", res, size, 10);
19
  free(cfg_tags);
20

    
21
  cfg_tags = grapes_config_parse("len=5,size=10");
22
  res = grapes_config_value_int(cfg_tags, "size", &size);
23
  res = grapes_config_value_int(cfg_tags, "len", &len);
24
  printf("%d: Is %d = %d?\n", res, size, 10);
25
  printf("%d: Is %d = %d?\n", res, len, 5);
26
  res = grapes_config_value_int(cfg_tags, "blah", &dummy);
27
  printf("%d: Is %d = ...?\n", res, dummy);
28
  free(cfg_tags);
29

    
30
  return 0;
31
}