eet_data_write_cipher

Langue: en

Version: 343272 (ubuntu - 24/10/10)

Section: 3 (Bibliothèques de fonctions)

NAME

Eet Data Serialization using A Ciphers -

Most of the Eet Data Serialization have alternative versions that accounts for ciphers to protect their content.

Functions


EAPI void * eet_data_read_cipher (Eet_File *ef, Eet_Data_Descriptor *edd, const char *name, const char *cipher_key)
Read a data structure from an eet file and decodes it using a cipher.
EAPI int eet_data_write_cipher (Eet_File *ef, Eet_Data_Descriptor *edd, const char *name, const char *cipher_key, const void *data, int compress)
Write a data structure from memory and store in an eet file using a cipher.
EAPI int eet_data_text_dump_cipher (const void *data_in, const char *cipher_key, int size_in, void(*dumpfunc)(void *data, const char *str), void *dumpdata)
Dump an eet encoded data structure into ascii text using a cipher.
EAPI void * eet_data_text_undump_cipher (const char *text, const char *cipher_key, int textlen, int *size_ret)
Take an ascii encoding from eet_data_text_dump() and re-encode in binary using a cipher.
EAPI int eet_data_dump_cipher (Eet_File *ef, const char *name, const char *cipher_key, void(*dumpfunc)(void *data, const char *str), void *dumpdata)
Dump an eet encoded data structure from an eet file into ascii text using a cipher.
EAPI int eet_data_undump_cipher (Eet_File *ef, const char *name, const char *cipher_key, const char *text, int textlen, int compress)
Take an ascii encoding from eet_data_dump() and re-encode in binary using a cipher.
EAPI void * eet_data_descriptor_decode_cipher (Eet_Data_Descriptor *edd, const void *data_in, const char *cipher_key, int size_in)
Decode a data structure from an arbitary location in memory using a cipher.
EAPI void * eet_data_descriptor_encode_cipher (Eet_Data_Descriptor *edd, const void *data_in, const char *cipher_key, int *size_ret)
Encode a data struct to memory and return that encoded data using a cipher.

Detailed Description

Most of the Eet Data Serialization have alternative versions that accounts for ciphers to protect their content.

See also:

Cipher, Identity and Protection Mechanisms

Function Documentation

EAPI void* eet_data_descriptor_decode_cipher (Eet_Data_Descriptor * edd, const void * data_in, const char * cipher_key, int size_in)

Decode a data structure from an arbitary location in memory using a cipher. Parameters:

edd The data descriptor to use when decoding.
data_in The pointer to the data to decode into a struct.
cipher_key The key to use as cipher.
size_in The size of the data pointed to in bytes.

Returns:

NULL on failure, or a valid decoded struct pointer on success.

This function will decode a data structure that has been encoded using eet_data_descriptor_encode(), and return a data structure with all its elements filled out, if successful, or NULL on failure.

The data to be decoded is stored at the memory pointed to by data_in, and is described by the descriptor pointed to by edd. The data size is passed in as the value to size_in, ande must be greater than 0 to succeed.

This function is useful for decoding data structures delivered to the application by means other than an eet file, such as an IPC or socket connection, raw files, shared memory etc.

Please see eet_data_read() for more information.

See also:

eet_data_descriptor_decode()

Since:

1.0.0

Referenced by eet_data_descriptor_decode().

EAPI void* eet_data_descriptor_encode_cipher (Eet_Data_Descriptor * edd, const void * data_in, const char * cipher_key, int * size_ret)

Encode a data struct to memory and return that encoded data using a cipher. Parameters:

edd The data descriptor to use when encoding.
data_in The pointer to the struct to encode into data.
cipher_key The key to use as cipher.
size_ret pointer to the an int to be filled with the decoded size.

Returns:

NULL on failure, or a valid encoded data chunk on success.

This function takes a data structutre in memory and encodes it into a serialised chunk of data that can be decoded again by eet_data_descriptor_decode(). This is useful for being able to transmit data structures across sockets, pipes, IPC or shared file mechanisms, without having to worry about memory space, machine type, endianess etc.

The parameter edd must point to a valid data descriptor, and data_in must point to the right data structure to encode. If not, the encoding may fail.

On success a non NULL valid pointer is returned and what size_ret points to is set to the size of this decoded data, in bytes. When the encoded data is no longer needed, call free() on it. On failure NULL is returned and what size_ret points to is set to 0.

Please see eet_data_write() for more information.

See also:

eet_data_descriptor_encode()

Since:

1.0.0

Referenced by eet_connection_send(), and eet_data_descriptor_encode().

EAPI int eet_data_dump_cipher (Eet_File * ef, const char * name, const char * cipher_key, void(*)(void *data, const char *str) dumpfunc, void * dumpdata)

Dump an eet encoded data structure from an eet file into ascii text using a cipher. Parameters:

ef A valid eet file handle.
name Name of the entry. eg: '/base/file_i_want'.
cipher_key The key to use as cipher.
dumpfunc The function to call passed a string when new data is converted to text
dumpdata The data to pass to the dumpfunc callback.

Returns:

1 on success, 0 on failure

This function will take an open and valid eet file from eet_open() request the data encoded by eet_data_descriptor_encode() corresponding to the key name and convert it into human readable ascii text. It does this by calling the dumpfunc callback for all new text that is generated. This callback should append to any existing text buffer and will be passed the pointer dumpdata as a parameter as well as a string with new text to be appended.

See also:

eet_data_dump()

Since:

1.0.0

References eet_dictionary_get(), eet_node_del(), eet_node_dump(), eet_read_cipher(), and eet_read_direct().

Referenced by eet_data_dump().

EAPI void* eet_data_read_cipher (Eet_File * ef, Eet_Data_Descriptor * edd, const char * name, const char * cipher_key)

Read a data structure from an eet file and decodes it using a cipher. Parameters:

ef The eet file handle to read from.
edd The data descriptor handle to use when decoding.
name The key the data is stored under in the eet file.
cipher_key The key to use as cipher.

Returns:

A pointer to the decoded data structure.

This function decodes a data structure stored in an eet file, returning a pointer to it if it decoded successfully, or NULL on failure. This can save a programmer dozens of hours of work in writing configuration file parsing and writing code, as eet does all that work for the program and presents a program-friendly data structure, just as the programmer likes. Eet can handle members being added or deleted from the data in storage and safely zero-fills unfilled members if they were not found in the data. It checks sizes and headers whenever it reads data, allowing the programmer to not worry about corrupt data.

Once a data structure has been described by the programmer with the fields they wish to save or load, storing or retrieving a data structure from an eet file, or from a chunk of memory is as simple as a single function call.

See also:

eet_data_read()

Since:

1.0.0

References eet_dictionary_get(), eet_read_cipher(), and eet_read_direct().

Referenced by eet_data_read().

EAPI int eet_data_text_dump_cipher (const void * data_in, const char * cipher_key, int size_in, void(*)(void *data, const char *str) dumpfunc, void * dumpdata)

Dump an eet encoded data structure into ascii text using a cipher. Parameters:

data_in The pointer to the data to decode into a struct.
cipher_key The key to use as cipher.
size_in The size of the data pointed to in bytes.
dumpfunc The function to call passed a string when new data is converted to text
dumpdata The data to pass to the dumpfunc callback.

Returns:

1 on success, 0 on failure

This function will take a chunk of data encoded by eet_data_descriptor_encode() and convert it into human readable ascii text. It does this by calling the dumpfunc callback for all new text that is generated. This callback should append to any existing text buffer and will be passed the pointer dumpdata as a parameter as well as a string with new text to be appended.

Example:

  void output(void *data, const char *string)
  {
    printf('%s', string);
  }
 
  void dump(const char *file)
  {
    FILE *f;
    int len;
    void *data;
 
    f = fopen(file, 'r');
    fseek(f, 0, SEEK_END);
    len = ftell(f);
    rewind(f);
    data = malloc(len);
    fread(data, len, 1, f);
    fclose(f);
    eet_data_text_dump_cipher(data, cipher_key, len, output, NULL);
  }
 

See also:

eet_data_text_dump()

Since:

1.0.0

References eet_node_del(), and eet_node_dump().

Referenced by eet_data_text_dump().

EAPI void* eet_data_text_undump_cipher (const char * text, const char * cipher_key, int textlen, int * size_ret)

Take an ascii encoding from eet_data_text_dump() and re-encode in binary using a cipher. Parameters:

text The pointer to the string data to parse and encode.
cipher_key The key to use as cipher.
textlen The size of the string in bytes (not including 0 byte terminator).
size_ret This gets filled in with the encoded data blob size in bytes.

Returns:

The encoded data on success, NULL on failure.

This function will parse the string pointed to by text and return an encoded data lump the same way eet_data_descriptor_encode() takes an in-memory data struct and encodes into a binary blob. text is a normal C string.

See also:

eet_data_text_undump()

Since:

1.0.0

Referenced by eet_data_text_undump().

EAPI int eet_data_undump_cipher (Eet_File * ef, const char * name, const char * cipher_key, const char * text, int textlen, int compress)

Take an ascii encoding from eet_data_dump() and re-encode in binary using a cipher. Parameters:

ef A valid eet file handle.
name Name of the entry. eg: '/base/file_i_want'.
cipher_key The key to use as cipher.
text The pointer to the string data to parse and encode.
textlen The size of the string in bytes (not including 0 byte terminator).
compress Compression flags (1 == compress, 0 = don't compress).

Returns:

1 on success, 0 on failure

This function will parse the string pointed to by text, encode it the same way eet_data_descriptor_encode() takes an in-memory data struct and encodes into a binary blob.

The data (optionally compressed) will be in ram, pending a flush to disk (it will stay in ram till the eet file handle is closed though).

See also:

eet_data_undump()

Since:

1.0.0

References eet_dictionary_get(), and eet_write_cipher().

Referenced by eet_data_undump().

EAPI int eet_data_write_cipher (Eet_File * ef, Eet_Data_Descriptor * edd, const char * name, const char * cipher_key, const void * data, int compress)

Write a data structure from memory and store in an eet file using a cipher. Parameters:

ef The eet file handle to write to.
edd The data descriptor to use when encoding.
name The key to store the data under in the eet file.
cipher_key The key to use as cipher.
data A pointer to the data structure to ssave and encode.
compress Compression flags for storage.

Returns:

bytes written on successful write, 0 on failure.

This function is the reverse of eet_data_read(), saving a data structure to an eet file.

See also:

eet_data_write_cipher()

Since:

1.0.0

References eet_dictionary_get(), and eet_write_cipher().

Referenced by eet_data_write().

Author

Generated automatically by Doxygen for Eet from the source code.