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
|
int main(int argc, char **argv) {
char *joeval = NULL;
size_t xval = -1;
int onoff = -1;
int lcpret = -1;
int i = 0;
int onoff2 = 0;
uint32_t ipaddr;
lc_register_var("Section", LC_VAR_SECTION, NULL, 0);
lc_register_var("Somesection", LC_VAR_SECTION, NULL, 0);
lc_register_var("Section.Test", LC_VAR_STRING, &joeval, 'j');
lc_register_var("bob", LC_VAR_SIZE_SIZE_T, &xval, 's');
lc_register_var("Somesection.Free", LC_VAR_BOOL, &onoff, 0);
lc_register_var("long", LC_VAR_BOOL_BY_EXISTANCE, &onoff2, 'l');
lc_register_var("ipaddr", LC_VAR_IP, &ipaddr, 'i');
lc_register_callback("sally", 0, LC_VAR_STRING, sally_cmd, NULL);
lc_register_callback("HELP", 'h', LC_VAR_NONE, help_cmd, NULL);
lc_register_callback("*.ifmodule", 0, LC_VAR_NONE, cmd_ifmodule, NULL);
lcpret = lc_process_file("testapp", "http://10.8.0.2/test.conf", LC_CONF_APACHE);
lcpret = lc_process(argc, argv, "testapp", LC_CONF_APACHE, "test.cfg");
lc_cleanup();
if (lcpret < 0) {
fprintf(stderr, "Error processing config file: %s\n", lc_geterrstr());
return(EXIT_FAILURE);
}
if (joeval != NULL) {
fprintf(stderr, "joeval = \"%s\"\n", joeval);
} else {
fprintf(stderr, "joeval = \"(null)\"\n");
}
fprintf(stderr, "xval = %llu\n", (unsigned long long) xval);
|
|
|
>
>
>
>
>
<
>
>
|
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
|
int main(int argc, char **argv) {
char *joeval = NULL;
size_t xval = -1;
int onoff = -1;
int lcpret = -1;
int i = 0;
int onoff2 = 0;
uint32_t ipaddr = 0;
lc_register_var("Section", LC_VAR_SECTION, NULL, 0);
lc_register_var("Somesection", LC_VAR_SECTION, NULL, 0);
lc_register_var("Section.Test", LC_VAR_STRING, &joeval, 'j');
lc_register_var("bob", LC_VAR_SIZE_SIZE_T, &xval, 's');
lc_register_var("Somesection.Free", LC_VAR_BOOL, &onoff, 0);
lc_register_var("long", LC_VAR_BOOL_BY_EXISTANCE, &onoff2, 'l');
lc_register_var("ipaddr", LC_VAR_IP, &ipaddr, 'i');
lc_register_callback("sally", 0, LC_VAR_STRING, sally_cmd, NULL);
lc_register_callback("HELP", 'h', LC_VAR_NONE, help_cmd, NULL);
lc_register_callback("*.ifmodule", 0, LC_VAR_NONE, cmd_ifmodule, NULL);
lcpret = lc_process_file("testapp", "build/test.conf", LC_CONF_APACHE);
if (lcpret < 0) {
fprintf(stderr, "Error processing config file: %s\n", lc_geterrstr());
return(EXIT_FAILURE);
}
lcpret = lc_process(argc, argv, "testapp", LC_CONF_APACHE, "test.cfg");
if (lcpret < 0) {
fprintf(stderr, "Error processing config file: %s\n", lc_geterrstr());
return(EXIT_FAILURE);
}
lc_cleanup();
if (joeval != NULL) {
fprintf(stderr, "joeval = \"%s\"\n", joeval);
} else {
fprintf(stderr, "joeval = \"(null)\"\n");
}
fprintf(stderr, "xval = %llu\n", (unsigned long long) xval);
|