File: test-ve-config.c

package info (click to toggle)
genius 1.0.24-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 27,952 kB
  • sloc: ansic: 105,597; xml: 67,672; sh: 4,537; makefile: 2,089; lex: 499; yacc: 298; perl: 54; python: 22
file content (76 lines) | stat: -rw-r--r-- 2,439 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/* Config test routines
 *
 * (c) 2002 George Lebl
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

#include <config.h>
#include <glib.h>
#include <stdio.h>
#include "ve-config.h"

/* tests done ona gdm.conf like file */

int
main (int argc, char *argv[])
{
	GList *list;
	VeConfig *config = ve_config_new (argv[1]);

	printf ("Get all sections:\n");
	list = ve_config_get_sections (config);
	while (list != NULL) {
		printf ("%s\n", (char *)list->data);
		list = list->next;
	}
	printf ("\n");

	printf ("Get all keys in section 'greeter':\n");
	list = ve_config_get_keys (config, "greeter");
	while (list != NULL) {
		printf ("%s\n", (char *)list->data);
		list = list->next;
	}
	printf ("\n");

	printf ("daemon/AutomaticLoginEnable=%d\n",
		 (int) ve_config_get_bool
		 (config, "daemon/AutomaticLoginEnable=false"));
	printf ("gui/MaxIconHeight=%d\n",
		 ve_config_get_int
		 (config, "gui/MaxIconHeight=99"));
	printf ("gui/MaxIconWidth=%d\n",
		 ve_config_get_int
		 (config, "gui/MaxIconWidth"));
	printf ("test=%s\n",
		 ve_config_get_string
		 (config, "test=test"));
	printf ("greeter/Welcome=%s\n",
		 ve_config_get_translated_string
		 (config, "greeter/Welcome=test"));
	ve_config_set_string (config, "greeter/DefaultLocale=en_US", "BAH!");
	ve_config_set_string (config, "greeter/DefaultLocale1=en_US", "BAFAN!");
	ve_config_set_string (config, "greeter/DefaultLocale2", "BAFAN2!");
	ve_config_set_string (config, "test=gogo", "bebe");
	ve_config_set_int (config, "greeter/foo", 12);
	ve_config_set_int (config, "greeter/bar=1", 13);
	ve_config_set_int (config, "queque/lolo=1", 14);
	ve_config_set_bool (config, "queque/quaqua", FALSE);
	ve_config_save (config, TRUE /* force */);
	ve_config_destroy (config);
	return 0;
}