Functions to create, destroy and do basic manipulation of Eet_File handles.
Eet File Ciphered Main Functions
Most of the Eet File Main Functions have alternative versions that accounts for ciphers to protect their content.
typedef enum _Eet_File_Mode Eet_File_Mode
Modes that a file can be opened.
typedef struct _Eet_File Eet_File
Opaque handle that defines an Eet file (or memory).
typedef struct _Eet_Dictionary Eet_Dictionary
Opaque handle that defines a file-backed (mmaped) dictionary of strings.
enum _Eet_File_Mode { , EET_FILE_MODE_READ, EET_FILE_MODE_WRITE, EET_FILE_MODE_READ_WRITE }
Modes that a file can be opened.
EAPI Eet_File * eet_open (const char *file, Eet_File_Mode mode)
Open an eet file on disk, and returns a handle to it.
EAPI Eet_File * eet_memopen_read (const void *data, size_t size)
Open an eet file directly from a memory location.
EAPI Eet_File_Mode eet_mode_get (Eet_File *ef)
Get the mode an Eet_File was opened with.
EAPI Eet_Error eet_close (Eet_File *ef)
Close an eet file handle and flush and writes pending.
EAPI Eet_Error eet_sync (Eet_File *ef)
Sync content of an eet file handle, flushing pending writes.
EAPI Eet_Dictionary * eet_dictionary_get (Eet_File *ef)
Return a handle to the shared string dictionary of the Eet file.
EAPI int eet_dictionary_string_check (Eet_Dictionary *ed, const char *string)
Check if a given string comes from a given dictionary.
EAPI void * eet_read (Eet_File *ef, const char *name, int *size_ret)
Read a specified entry from an eet file and return data.
EAPI const void * eet_read_direct (Eet_File *ef, const char *name, int *size_ret)
Read a specified entry from an eet file and return data.
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.
EAPI int eet_delete (Eet_File *ef, const char *name)
Delete a specified entry from an Eet file being written or re-written.
EAPI char ** eet_list (Eet_File *ef, const char *glob, int *count_ret)
List all entries in eet file matching shell glob.
EAPI int eet_num_entries (Eet_File *ef)
Return the number of entries in the specified eet file.
Functions to create, destroy and do basic manipulation of Eet_File handles.
Opaque handle that defines an Eet file (or memory). See also:
eet_memopen_read()
eet_close()
Modes that a file can be opened.
Modes that a file can be opened.
Enumerator:
Close an eet file handle and flush and writes pending. Parameters:
This function will flush any pending writes to disk if the eet file was opened for write, and free all data associated with the file handle and file, and close the file.
If the eet file handle is not valid nothing will be done.
Since:
Delete a specified entry from an Eet file being written or re-written. Parameters:
Returns:
This function will delete the specified chunk of data from the eet file and return greater than 0 on success. 0 will be returned on failure.
The eet file handle must be a valid file handle for an eet file opened for writing. If it is not, 0 will be returned and no action will be performed.
Name, must not be NULL, otherwise 0 will be returned.
Since:
References EET_FILE_MODE_READ.
Return a handle to the shared string dictionary of the Eet file. Parameters:
Returns:
This function returns a handle to the dictionary of an Eet file whose handle is ef, if a dictionary exists. NULL is returned otherwise or if the file handle is known to be invalid.
See also:
Since:
Referenced by eet_data_dump_cipher(), eet_data_node_read_cipher(), eet_data_node_write_cipher(), eet_data_read_cipher(), eet_data_undump_cipher(), and eet_data_write_cipher().
Check if a given string comes from a given dictionary. Parameters:
Returns:
This checks the given dictionary to see if the given string is actually inside that dictionary (i.e. comes from it) and returns 1 if it does. If the dictionary handle is invlide, the string is NULL or the string is not in the dictionary, 0 is returned.
Since:
List all entries in eet file matching shell glob. Parameters:
Returns:
This function will list all entries in the eet file matching the supplied shell glob and return an allocated list of their names, if there are any, and if no memory errors occur.
The eet file handle must be valid and glob must not be NULL, or NULL will be returned and count_ret will be filled with 0.
The calling program must call free() on the array returned, but NOT on the string pointers in the array. They are taken as read-only internals from the eet file handle. They are only valid as long as the file handle is not closed. When it is closed those pointers in the array are now not valid and should not be used.
On success the array returned will have a list of string pointers that are the names of the entries that matched, and count_ret will have the number of entries in this array placed in it.
Hint: an easy way to list all entries in an eet file is to use a glob value of '*'.
Since:
References EET_FILE_MODE_READ, and EET_FILE_MODE_READ_WRITE.
Open an eet file directly from a memory location. The data are not copied, so you must keep them around as long as the eet file is open. Their is currently no cache for this kind of Eet_File, so it's reopen every time you do use eet_memopen_read.
Since:
References EET_FILE_MODE_READ.
Get the mode an Eet_File was opened with. Parameters:
Returns:
Since:
Return the number of entries in the specified eet file. Parameters:
Returns:
Since:
References EET_FILE_MODE_READ, and EET_FILE_MODE_READ_WRITE.
Open an eet file on disk, and returns a handle to it. Parameters:
Returns:
This function will open an exiting eet file for reading, and build the directory table in memory and return a handle to the file, if it exists and can be read, and no memory errors occur on the way, otherwise NULL will be returned.
It will also open an eet file for writing. This will, if successful, delete the original file and replace it with a new empty file, till the eet file handle is closed or flushed. If it cannot be opened for writing or a memory error occurs, NULL is returned.
You can also open the file for read/write. If you then write a key that does not exist it will be created, if the key exists it will be replaced by the new data.
Example:
#include <Eet.h>
#include <stdio.h>
#include <string.h>
int
main(int argc, char **argv)
{
Eet_File *ef;
char buf[1024], *ret, **list;
int size, num, i;
eet_init();
strcpy(buf, 'Here is a string of data to save!');
ef = eet_open('/tmp/my_file.eet', EET_FILE_MODE_WRITE);
if (!ef) return -1;
if (!eet_write(ef, '/key/to_store/at', buf, 1024, 1))
fprintf(stderr, 'Error writing data!);
eet_close(ef);
ef = eet_open('/tmp/my_file.eet', EET_FILE_MODE_READ);
if (!ef) return -1;
list = eet_list(ef, '*', &num);
if (list)
{
for (i = 0; i < num; i++)
printf('Key stored: %s, list[i]);
free(list);
}
ret = eet_read(ef, '/key/to_store/at', &size);
if (ret)
{
printf('Data read (%i bytes):s, size, ret);
free(ret);
}
eet_close(ef);
eet_shutdown();
return 0;
}
Since:
References EET_FILE_MODE_READ, EET_FILE_MODE_READ_WRITE, EET_FILE_MODE_WRITE, and eet_sync().
Read a specified entry from an eet file and return data. Parameters:
Returns:
This function finds an entry in the eet file that is stored under the name specified, and returns that data, decompressed, if successful. NULL is returned if the lookup fails or if memory errors are encountered. It is the job of the calling program to call free() on the returned data. The number of bytes in the returned data chunk are placed in size_ret.
If the eet file handle is not valid NULL is returned and size_ret is filled with 0.
See also:
Since:
Read a specified entry from an eet file and return data. Parameters:
Returns:
This function finds an entry in the eet file that is stored under the name specified, and returns that data if not compressed and successful. NULL is returned if the lookup fails or if memory errors are encountered or if the data is comrpessed. The calling program must never call free() on the returned data. The number of bytes in the returned data chunk are placed in size_ret.
If the eet file handle is not valid NULL is returned and size_ret is filled with 0.
Since:
References EET_FILE_MODE_READ, and EET_FILE_MODE_READ_WRITE.
Referenced by eet_data_dump_cipher(), eet_data_image_header_read_cipher(), eet_data_image_read_cipher(), eet_data_image_read_to_surface_cipher(), eet_data_node_read_cipher(), and eet_data_read_cipher().
Sync content of an eet file handle, flushing pending writes. Parameters:
This function will flush any pending writes to disk. The eet file must be opened for write.
If the eet file handle is not valid nothing will be done.
Since:
References EET_ERROR_BAD_OBJECT, EET_ERROR_NONE, EET_ERROR_NOT_WRITABLE, EET_FILE_MODE_READ_WRITE, and EET_FILE_MODE_WRITE.
Write a specified entry to an eet file handle. Parameters:
Returns:
This function will write the specified chunk of data to the eet file and return greater than 0 on success. 0 will be returned on failure.
The eet file handle must be a valid file handle for an eet file opened for writing. If it is not, 0 will be returned and no action will be performed.
Name, and data must not be NULL, and size must be > 0. If these conditions are not met, 0 will be returned.
The data will be copied (and optionally compressed) in ram, pending a flush to disk (it will stay in ram till the eet file handle is closed though).
See also:
Since:
References eet_write_cipher().
Generated automatically by Doxygen for Eet from the source code.