Example_Eet_Basic(3)

NAME
Example_Eet_Basic - Very basic Eet example

1 //Compile with:
2 // gcc -o eet-basic eet-basic.c `pkg-config --cflags --libs eet`
3
4 #include <Eet.h>
5
6 int
7 main(void)
8 {
9    Eet_File *ef;
10    char *ret;
11    int size;
12    char *entries[] =
13    {
14       "Entry 1",
15       "Big text string here compared to others",
16       "Eet is cool"
17    };
18
19    eet_init();
20
21    // blindly open an file for output and write strings with their NUL char
22    ef = eet_open("test.eet", EET_FILE_MODE_WRITE);
23    eet_write(ef, "Entry 1", entries[0], strlen(entries[0]) + 1, 0);
24    eet_write(ef, "Entry 2", entries[1], strlen(entries[1]) + 1, 1);
25    eet_write(ef, "Entry 3", entries[2], strlen(entries[2]) + 1, 0);
26    eet_close(ef);
27
28    // open the file again and blindly get the entries we wrote
29    ef = eet_open("test.eet", EET_FILE_MODE_READ);
30    ret = eet_read(ef, "Entry 1", &size);
31    printf("%s, ret);
32    free(ret);
33    ret = eet_read(ef, "Entry 2", &size);
34    printf("%s, ret);
35    free(ret);
36    ret = eet_read(ef, "Entry 3", &size);
37    printf("%s, ret);
38    free(ret);
39    eet_close(ef);
40
41    eet_shutdown();
42 }
43