- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files
- Examples

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\n", ret);
32 free(ret);
33 ret = eet_read(ef, "Entry 2", &size);
34 printf("%s\n", ret);
35 free(ret);
36 ret = eet_read(ef, "Entry 3", &size);
37 printf("%s\n", ret);
38 free(ret);
39 eet_close(ef);
40
41 eet_shutdown();
42 }
43
eet_open
EAPI Eet_File * eet_open(const char *file, Eet_File_Mode mode)
Open an eet file on disk, and returns a handle to it.
Definition: eet_lib.c:1500
Eet_File
struct _Eet_File Eet_File
Opaque handle that defines an Eet file (or memory).
Definition: Eet.h:518
EET_FILE_MODE_READ
File is read-only.
Definition: Eet.h:474
eet_shutdown
EAPI int eet_shutdown(void)
Shut down the EET library.
Definition: eet_lib.c:619
eet_read
EAPI void * eet_read(Eet_File *ef, const char *name, int *size_ret)
Read a specified entry from an eet file and return data.
Definition: eet_lib.c:1942
Eet.h
The file that provides the eet functions.
EET_FILE_MODE_WRITE
File is write-only.
Definition: Eet.h:475
eet_close
EAPI Eet_Error eet_close(Eet_File *ef)
Close an eet file handle and flush pending writes.
Definition: eet_lib.c:1750
eet_write
EAPI int eet_write(Eet_File *ef, const char *name, const void *data, int size, int compress)
Write a specified entry to an eet file handle.
Definition: eet_lib.c:2575
eet_init
EAPI int eet_init(void)
Initialize the EET library.
Definition: eet_lib.c:536