aboutsummaryrefslogtreecommitdiffstats
path: root/samples/c/stub.c
diff options
context:
space:
mode:
authorJonathan McCrohan <jmccrohan@gmail.com>2011-12-01 22:56:23 +0000
committerJonathan McCrohan <jmccrohan@gmail.com>2011-12-01 22:56:23 +0000
commit429e46051dba814e7d6c74368eb1bba550222cbe (patch)
treeed1dd43cd23c69f156aae2165006a16a66262cef /samples/c/stub.c
parent58bf1382be0cbcf3f9649286fd2719b789a1595f (diff)
downloadlibconfig-429e46051dba814e7d6c74368eb1bba550222cbe.tar.gz
Imported Upstream version 1.4.8upstream/1.4.8
Diffstat (limited to '')
-rw-r--r--samples/c/stub.c84
1 files changed, 0 insertions, 84 deletions
diff --git a/samples/c/stub.c b/samples/c/stub.c
deleted file mode 100644
index a4608b7..0000000
--- a/samples/c/stub.c
+++ /dev/null
@@ -1,84 +0,0 @@
-#ifdef _MSC_VER
-#pragma warning (disable: 4996)
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include "libconfig.h"
-
-int main(int argc, char **argv)
-{
- config_t cfg;
- FILE *fp;
- int i, x;
- const char *s;
- const config_setting_t *array;
- config_setting_t *old;
-
- fp = fopen("test.cfg", "rb");
-
- if(! fp)
- {
- printf("Unable to open test.cfg\n");
- exit(1);
- }
-
- config_init(&cfg);
- x = config_read(&cfg, fp);
-
- fclose(fp);
-
- if(! x)
- {
- printf("error on line %d: %s\n", cfg.error_line, cfg.error_text);
- exit(1);
- }
-
- if(! config_lookup_string(&cfg, "application.group1.group2.zzz", &s))
- puts("NOT FOUND");
- else
- printf("found: %s\n", s);
-
- array = config_lookup(&cfg, "application.group1.my_array");
- if(array)
- {
- for(i = 0; i < config_setting_length(array); i++)
- {
- long val = config_setting_get_int_elem(array, i);
- printf("value [%i]: %ld\n", i, val);
- }
- }
-
- {
- config_setting_t *root = config_root_setting(&cfg);
-
- config_setting_t *new = config_setting_add(root, "foobar",
- CONFIG_TYPE_LIST);
-
- config_setting_t *newgrp, *newval;
-
-
- if(! config_setting_set_float_elem(new, -1, 3.141592654))
- puts("FAILED");
-
- if(! config_setting_set_string_elem(new, -1, "Hello, world!"))
- puts("FAILED");
-
- newgrp = config_setting_add(new, NULL, CONFIG_TYPE_GROUP);
-
- newval = config_setting_add(newgrp, "baz", CONFIG_TYPE_INT);
-
- old = config_lookup(&cfg, "application.group1");
-
- printf("old is: %p\n", old);
- config_setting_remove(old, "group2");
- }
-
- config_write(&cfg, stdout);
-
-
- config_destroy(&cfg);
-
-
- return(0);
-}