eet-basic.c

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

eet-basic.c
//Compile with:
// gcc -o eet-basic eet-basic.c `pkg-config --cflags --libs eet`
#include <Eet.h>
int
main(void)
{
Eet_File *ef;
char *ret;
int size;
char *entries[] =
{
"Entry 1",
"Big text string here compared to others",
"Eet is cool"
};
eet_init();
// blindly open an file for output and write strings with their NUL char
ef = eet_open("test.eet", EET_FILE_MODE_WRITE);
eet_write(ef, "Entry 1", entries[0], strlen(entries[0]) + 1, 0);
eet_write(ef, "Entry 2", entries[1], strlen(entries[1]) + 1, 1);
eet_write(ef, "Entry 3", entries[2], strlen(entries[2]) + 1, 0);
eet_close(ef);
// open the file again and blindly get the entries we wrote
ef = eet_open("test.eet", EET_FILE_MODE_READ);
ret = eet_read(ef, "Entry 1", &size);
printf("%s\n", ret);
free(ret);
ret = eet_read(ef, "Entry 2", &size);
printf("%s\n", ret);
free(ret);
ret = eet_read(ef, "Entry 3", &size);
printf("%s\n", ret);
free(ret);
eet_close(ef);
eet_shutdown();
}
Eet.h
The file that provides the eet functions.
eet_close
EAPI Eet_Error eet_close(Eet_File *ef)
Closes an eet file handle and flush pending writes.
Definition: eet_lib.c:1899
eet_open
EAPI Eet_File * eet_open(const char *file, Eet_File_Mode mode)
Opens an eet file on disk, and returns a handle to it.
Definition: eet_lib.c:1499
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:2492
Eet_File
struct _Eet_File Eet_File
Opaque handle that defines an Eet file (or memory).
Definition: Eet.h:527
eet_read
EAPI void * eet_read(Eet_File *ef, const char *name, int *size_ret)
Reads a specified entry from an eet file and return data.
Definition: eet_lib.c:2006
EET_FILE_MODE_READ
@ EET_FILE_MODE_READ
File is read-only.
Definition: Eet.h:479
EET_FILE_MODE_WRITE
@ EET_FILE_MODE_WRITE
File is write-only.
Definition: Eet.h:480
eet_init
EAPI int eet_init(void)
Initializes the EET library.
Definition: eet_lib.c:540
eet_shutdown
EAPI int eet_shutdown(void)
Shuts down the EET library.
Definition: eet_lib.c:594