-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.c
More file actions
38 lines (30 loc) · 1.05 KB
/
example.c
File metadata and controls
38 lines (30 loc) · 1.05 KB
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
// eINI simple usage example
#include <stdio.h>
#include <stdlib.h>
#include "eini.h"
// Handler function. For this test, we just define a function that prints what
// it gets. In real life, you'll want one that performs error checking and
// updates your program's configuration.
void handler_func(const wchar_t *section, const wchar_t *key,
const wchar_t *value, const char *path, const unsigned line) {
printf("Line %d of %s: Got %ls.%ls='%ls'\n", line, path, section, key, value);
}
// Error function. For this test, we just define a function that prints the
// error message.
void error_func(const wchar_t *error, const char *path, const unsigned line) {
printf("Error in %s line %d: %ls\n", path, line, error);
}
int main(int argc, char **argv) {
// User must provide the .ini file to parse as an argument
if (1 == argc) {
printf("Usage: %s <.ini file>\n", argv[0]);
exit(-1);
}
// Initialize eINI
eini_init();
// Parse
eini(handler_func, error_func, argv[1]);
// Wind down eINI and exit
eini_winddown();
exit(0);
}