aboutsummaryrefslogtreecommitdiffstats
path: root/samples/c/sample1.c
diff options
context:
space:
mode:
authorJonathan McCrohan <jmccrohan@gmail.com>2011-12-01 23:47:41 +0000
committerJonathan McCrohan <jmccrohan@gmail.com>2011-12-01 23:47:41 +0000
commit1eaceca55c7e62892fd28bfbb5fc03240a48cee3 (patch)
tree7243fcd09c57e06e72b15f0044fd2c77babd7843 /samples/c/sample1.c
parentd4b5ddf4bcacd692011f5a597025c38a1262d6ca (diff)
parent429e46051dba814e7d6c74368eb1bba550222cbe (diff)
downloadlibconfig-1eaceca55c7e62892fd28bfbb5fc03240a48cee3.tar.gz
Merge commit 'upstream/1.4.8'
Conflicts: debian/changelog debian/control debian/libconfig++9-dev.install debian/libconfig8.install debian/libconfig9-dev.install debian/rules
Diffstat (limited to 'samples/c/sample1.c')
-rw-r--r--samples/c/sample1.c63
1 files changed, 0 insertions, 63 deletions
diff --git a/samples/c/sample1.c b/samples/c/sample1.c
deleted file mode 100644
index a119c10..0000000
--- a/samples/c/sample1.c
+++ /dev/null
@@ -1,63 +0,0 @@
-/*************************************************************************
- ** Sample1
- ** Load sample.cfg and increment the "X" setting
- *************************************************************************/
-
-#include <stdio.h>
-#include <libconfig.h>
-
-struct config_t cfg;
-
-/***************************************************************************/
-
-int main(int argc, char **argv)
-{
- char *file = "sample.cfg", *var = "x";
-
- if(argc >= 2)
- file = argv[1];
-
- if(argc >= 3)
- var = argv[2];
-
-/* Initialize the configuration */
- config_init(&cfg);
-
- /* Load the file */
- printf("loading [%s]...", file);
- if(!config_read_file(&cfg, file))
- printf("failed\n");
- else
- {
- config_setting_t *setting = NULL;
-
- printf("ok\n");
-
- /* Get the variable setting from the configuration.. */
- printf("increment \"%s\"...", var);
- setting = config_lookup(&cfg, var);
- if(!setting)
- printf("failed\n");
- else
- {
- long x = config_setting_get_int(setting);
- x++;
- config_setting_set_int(setting, x);
- printf("ok (%s=%lu)\n", var, x);
-
- /* Save the changes */
- printf("saving [%s]...", file);
- config_write_file(&cfg, file);
- printf("ok\n");
-
- printf("Done!\n");
- }
- }
-
- /* Free the configuration */
- config_destroy(&cfg);
-
- return 0;
-}
-
-/***************************************************************************/