File: stash-example.c

package info (click to toggle)
geany 1.22%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 17,444 kB
  • sloc: ansic: 76,211; cpp: 42,611; sh: 11,368; makefile: 650; perl: 60; python: 58; xml: 56; lisp: 48; ada: 48; fortran: 47; cs: 45; java: 41; tcl: 35; asm: 29; sql: 28; ruby: 6; php: 1
file content (23 lines) | stat: -rw-r--r-- 693 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
StashGroup *group;
gboolean china_enabled;
gchar *potter_name;
const gchar filename[] = "/path/data.conf";

/* setup the group */
group = stash_group_new("cup");
stash_group_add_boolean(group, &china_enabled, "china", TRUE);
stash_group_add_string(group, &potter_name, "potter_name", "Miss Clay");

/* load the settings from a file */
if (!stash_group_load_from_file(group, filename))
	g_warning(_("Could not load keyfile %s!"), filename);

/* now use settings china_enabled and potter_name */
...

/* save settings to file */
if (stash_group_save_to_file(group, filename, G_KEY_FILE_NONE) != 0)
	g_error(_("Could not save keyfile %s!"), filename);

/* free memory */
stash_group_free(group);