623 lines
22 KiB
Cython
623 lines
22 KiB
Cython
"""
|
|
|
|
Decode Image data header only to get information.
|
|
:param data: The encoded pixel data.
|
|
:param size: The size, in bytes, of the encoded pixel data.
|
|
:param w: A pointer to the unsigned int to hold the width in pixels.
|
|
:param h: A pointer to the unsigned int to hold the height in pixels.
|
|
:param alpha: A pointer to the int to hold the alpha flag.
|
|
:param compress: A pointer to the int to hold the compression amount.
|
|
:param quality: A pointer to the int to hold the quality amount.
|
|
:param lossy: A pointer to the int to hold the lossiness flag.
|
|
:return: 1 on success, 0 on failure.
|
|
|
|
This function works exactly like eet_data_image_header_read(), but instead
|
|
of reading from an Eet file, it takes the buffer of size @p size pointed
|
|
by @p data, which must be a valid Eet encoded image.
|
|
|
|
On success the function returns 1 indicating the header was read and
|
|
decoded properly, or 0 on failure.
|
|
|
|
@see eet_data_image_header_read()
|
|
@see eet_data_image_header_decode_cipher()
|
|
|
|
:since: 1.0.0
|
|
|
|
"""
|
|
EAPI int
|
|
eet_data_image_header_decode(const void *data,
|
|
int size,
|
|
unsigned int *w,
|
|
unsigned int *h,
|
|
int *alpha,
|
|
int *compress,
|
|
int *quality,
|
|
int *lossy);
|
|
|
|
"""
|
|
|
|
Decode Image data into pixel data.
|
|
:param data: The encoded pixel data.
|
|
:param size: The size, in bytes, of the encoded pixel data.
|
|
:param w: A pointer to the unsigned int to hold the width in pixels.
|
|
:param h: A pointer to the unsigned int to hold the height in pixels.
|
|
:param alpha: A pointer to the int to hold the alpha flag.
|
|
:param compress: A pointer to the int to hold the compression amount.
|
|
:param quality: A pointer to the int to hold the quality amount.
|
|
:param lossy: A pointer to the int to hold the lossiness flag.
|
|
:return: The image pixel data decoded
|
|
|
|
This function takes encoded pixel data and decodes it into raw RGBA
|
|
pixels on success.
|
|
|
|
It works exactly like eet_data_image_read(), but it takes the encoded
|
|
data in the @p data buffer of size @p size, instead of reading from a file.
|
|
All the others parameters are also the same.
|
|
|
|
On success the function returns a pointer to the image data decoded. The
|
|
calling application is responsible for calling free() on the image data
|
|
when it is done with it. On failure NULL is returned and the parameter
|
|
values may not contain any sensible data.
|
|
|
|
@see eet_data_image_read()
|
|
@see eet_data_image_decode_cipher()
|
|
|
|
:since: 1.0.0
|
|
|
|
"""
|
|
EAPI void *
|
|
eet_data_image_decode(const void *data,
|
|
int size,
|
|
unsigned int *w,
|
|
unsigned int *h,
|
|
int *alpha,
|
|
int *compress,
|
|
int *quality,
|
|
int *lossy);
|
|
|
|
"""
|
|
|
|
Decode Image data into pixel data and stores in the given buffer.
|
|
:param data: The encoded pixel data.
|
|
:param size: The size, in bytes, of the encoded pixel data.
|
|
:param src_x: The starting x coordinate from where to dump the stream.
|
|
:param src_y: The starting y coordinate from where to dump the stream.
|
|
:param d: A pointer to the pixel surface.
|
|
:param w: The expected width in pixels of the pixel surface to decode.
|
|
:param h: The expected height in pixels of the pixel surface to decode.
|
|
:param row_stride: The length of a pixels line in the destination surface.
|
|
:param alpha: A pointer to the int to hold the alpha flag.
|
|
:param compress: A pointer to the int to hold the compression amount.
|
|
:param quality: A pointer to the int to hold the quality amount.
|
|
:param lossy: A pointer to the int to hold the lossiness flag.
|
|
:return: 1 on success, 0 otherwise.
|
|
|
|
Like eet_data_image_read_to_surface(), but reading the given @p data buffer
|
|
instead of a file.
|
|
|
|
On success the function returns 1, and 0 on failure. On failure the
|
|
parameter values may not contain any sensible data.
|
|
|
|
@see eet_data_image_read_to_surface()
|
|
@see eet_data_image_decode_to_surface_cipher()
|
|
|
|
:since: 1.0.2
|
|
|
|
"""
|
|
EAPI int
|
|
eet_data_image_decode_to_surface(const void *data,
|
|
int size,
|
|
unsigned int src_x,
|
|
unsigned int src_y,
|
|
unsigned int *d,
|
|
unsigned int w,
|
|
unsigned int h,
|
|
unsigned int row_stride,
|
|
int *alpha,
|
|
int *compress,
|
|
int *quality,
|
|
int *lossy);
|
|
|
|
"""
|
|
|
|
Encode image data for storage or transmission.
|
|
:param data: A pointer to the image pixel data.
|
|
:param size_ret: A pointer to an int to hold the size of the returned data.
|
|
:param w: The width of the image in pixels.
|
|
:param h: The height of the image in pixels.
|
|
:param alpha: The alpha channel flag.
|
|
:param compress: The compression amount.
|
|
:param quality: The quality encoding amount.
|
|
:param lossy: The lossiness flag.
|
|
:return: The encoded image data.
|
|
|
|
This function stakes image pixel data and encodes it with compression and
|
|
possible loss of quality (as a trade off for size) for storage or
|
|
transmission to another system.
|
|
|
|
It works like eet_data_image_write(), but instead of writing the encoded
|
|
image into an Eet file, it allocates a new buffer of the size required and
|
|
returns the encoded data in it.
|
|
|
|
On success this function returns a pointer to the encoded data that you
|
|
can free with free() when no longer needed.
|
|
|
|
@see eet_data_image_write()
|
|
@see eet_data_image_read()
|
|
@see eet_data_image_encode_cipher()
|
|
|
|
:since: 1.0.0
|
|
|
|
"""
|
|
EAPI void *
|
|
eet_data_image_encode(const void *data,
|
|
int *size_ret,
|
|
unsigned int w,
|
|
unsigned int h,
|
|
int alpha,
|
|
int compress,
|
|
int quality,
|
|
int lossy);
|
|
|
|
|
|
"""
|
|
|
|
Decode Image data header only to get information using a cipher.
|
|
:param data: The encoded pixel data.
|
|
:param cipher_key: The key to use as cipher.
|
|
:param size: The size, in bytes, of the encoded pixel data.
|
|
:param w: A pointer to the unsigned int to hold the width in pixels.
|
|
:param h: A pointer to the unsigned int to hold the height in pixels.
|
|
:param alpha: A pointer to the int to hold the alpha flag.
|
|
:param compress: A pointer to the int to hold the compression amount.
|
|
:param quality: A pointer to the int to hold the quality amount.
|
|
:param lossy: A pointer to the int to hold the lossiness flag.
|
|
:return: 1 on success, 0 on failure.
|
|
|
|
This function takes encoded pixel data and decodes it into raw RGBA
|
|
pixels on success.
|
|
|
|
The other parameters of the image (width, height etc.) are placed into
|
|
the values pointed to (they must be supplied). The pixel data is a linear
|
|
array of pixels starting from the top-left of the image scanning row by
|
|
row from left to right. Each pixel is a 32bit value, with the high byte
|
|
being the alpha channel, the next being red, then green, and the low byte
|
|
being blue. The width and height are measured in pixels and will be
|
|
greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
|
|
that the alpha channel is not used. 1 denotes that it is significant.
|
|
Compress is filled with the compression value/amount the image was
|
|
stored with. The quality value is filled with the quality encoding of
|
|
the image file (0 - 100). The lossy flags is either 0 or 1 as to if
|
|
the image was encoded lossily or not.
|
|
|
|
On success the function returns 1 indicating the header was read and
|
|
decoded properly, or 0 on failure.
|
|
|
|
@see eet_data_image_header_decode()
|
|
|
|
:since: 1.0.0
|
|
|
|
"""
|
|
EAPI int
|
|
eet_data_image_header_decode_cipher(const void *data,
|
|
const char *cipher_key,
|
|
int size,
|
|
unsigned int *w,
|
|
unsigned int *h,
|
|
int *alpha,
|
|
int *compress,
|
|
int *quality,
|
|
int *lossy);
|
|
|
|
"""
|
|
|
|
Decode Image data into pixel data using a cipher.
|
|
:param data: The encoded pixel data.
|
|
:param cipher_key: The key to use as cipher.
|
|
:param size: The size, in bytes, of the encoded pixel data.
|
|
:param w: A pointer to the unsigned int to hold the width in pixels.
|
|
:param h: A pointer to the unsigned int to hold the height in pixels.
|
|
:param alpha: A pointer to the int to hold the alpha flag.
|
|
:param compress: A pointer to the int to hold the compression amount.
|
|
:param quality: A pointer to the int to hold the quality amount.
|
|
:param lossy: A pointer to the int to hold the lossiness flag.
|
|
:return: The image pixel data decoded
|
|
|
|
This function takes encoded pixel data and decodes it into raw RGBA
|
|
pixels on success.
|
|
|
|
The other parameters of the image (width, height etc.) are placed into
|
|
the values pointed to (they must be supplied). The pixel data is a linear
|
|
array of pixels starting from the top-left of the image scanning row by
|
|
row from left to right. Each pixel is a 32bit value, with the high byte
|
|
being the alpha channel, the next being red, then green, and the low byte
|
|
being blue. The width and height are measured in pixels and will be
|
|
greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
|
|
that the alpha channel is not used. 1 denotes that it is significant.
|
|
Compress is filled with the compression value/amount the image was
|
|
stored with. The quality value is filled with the quality encoding of
|
|
the image file (0 - 100). The lossy flags is either 0 or 1 as to if
|
|
the image was encoded lossily or not.
|
|
|
|
On success the function returns a pointer to the image data decoded. The
|
|
calling application is responsible for calling free() on the image data
|
|
when it is done with it. On failure NULL is returned and the parameter
|
|
values may not contain any sensible data.
|
|
|
|
@see eet_data_image_decode()
|
|
|
|
:since: 1.0.0
|
|
|
|
"""
|
|
EAPI void *
|
|
eet_data_image_decode_cipher(const void *data,
|
|
const char *cipher_key,
|
|
int size,
|
|
unsigned int *w,
|
|
unsigned int *h,
|
|
int *alpha,
|
|
int *compress,
|
|
int *quality,
|
|
int *lossy);
|
|
|
|
"""
|
|
|
|
Decode Image data into pixel data using a cipher.
|
|
:param data: The encoded pixel data.
|
|
:param cipher_key: The key to use as cipher.
|
|
:param size: The size, in bytes, of the encoded pixel data.
|
|
:param src_x: The starting x coordinate from where to dump the stream.
|
|
:param src_y: The starting y coordinate from where to dump the stream.
|
|
:param d: A pointer to the pixel surface.
|
|
:param w: The expected width in pixels of the pixel surface to decode.
|
|
:param h: The expected height in pixels of the pixel surface to decode.
|
|
:param row_stride: The length of a pixels line in the destination surface.
|
|
:param alpha: A pointer to the int to hold the alpha flag.
|
|
:param compress: A pointer to the int to hold the compression amount.
|
|
:param quality: A pointer to the int to hold the quality amount.
|
|
:param lossy: A pointer to the int to hold the lossiness flag.
|
|
:return: 1 on success, 0 otherwise.
|
|
|
|
This function takes encoded pixel data and decodes it into raw RGBA
|
|
pixels on success.
|
|
|
|
The other parameters of the image (alpha, compress etc.) are placed into
|
|
the values pointed to (they must be supplied). The pixel data is a linear
|
|
array of pixels starting from the top-left of the image scanning row by
|
|
row from left to right. Each pixel is a 32bit value, with the high byte
|
|
being the alpha channel, the next being red, then green, and the low byte
|
|
being blue. The width and height are measured in pixels and will be
|
|
greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
|
|
that the alpha channel is not used. 1 denotes that it is significant.
|
|
Compress is filled with the compression value/amount the image was
|
|
stored with. The quality value is filled with the quality encoding of
|
|
the image file (0 - 100). The lossy flags is either 0 or 1 as to if
|
|
the image was encoded lossily or not.
|
|
|
|
On success the function returns 1, and 0 on failure. On failure the
|
|
parameter values may not contain any sensible data.
|
|
|
|
@see eet_data_image_decode_to_surface()
|
|
|
|
:since: 1.0.2
|
|
|
|
"""
|
|
EAPI int
|
|
eet_data_image_decode_to_surface_cipher(const void *data,
|
|
const char *cipher_key,
|
|
int size,
|
|
unsigned int src_x,
|
|
unsigned int src_y,
|
|
unsigned int *d,
|
|
unsigned int w,
|
|
unsigned int h,
|
|
unsigned int row_stride,
|
|
int *alpha,
|
|
int *compress,
|
|
int *quality,
|
|
int *lossy);
|
|
|
|
"""
|
|
|
|
Encode image data for storage or transmission using a cipher.
|
|
:param data: A pointer to the image pixel data.
|
|
:param cipher_key: The key to use as cipher.
|
|
:param size_ret: A pointer to an int to hold the size of the returned data.
|
|
:param w: The width of the image in pixels.
|
|
:param h: The height of the image in pixels.
|
|
:param alpha: The alpha channel flag.
|
|
:param compress: The compression amount.
|
|
:param quality: The quality encoding amount.
|
|
:param lossy: The lossiness flag.
|
|
:return: The encoded image data.
|
|
|
|
This function stakes image pixel data and encodes it with compression and
|
|
possible loss of quality (as a trade off for size) for storage or
|
|
transmission to another system.
|
|
|
|
The data expected is the same format as returned by eet_data_image_read.
|
|
If this is not the case weird things may happen. Width and height must
|
|
be between 1 and 8000 pixels. The alpha flags can be 0 or 1 (0 meaning
|
|
the alpha values are not useful and 1 meaning they are). Compress can
|
|
be from 0 to 9 (0 meaning no compression, 9 meaning full compression).
|
|
This is only used if the image is not lossily encoded. Quality is used on
|
|
lossy compression and should be a value from 0 to 100. The lossy flag
|
|
can be 0 or 1. 0 means encode losslessly and 1 means to encode with
|
|
image quality loss (but then have a much smaller encoding).
|
|
|
|
On success this function returns a pointer to the encoded data that you
|
|
can free with free() when no longer needed.
|
|
|
|
@see eet_data_image_encode()
|
|
|
|
:since: 1.0.0
|
|
|
|
"""
|
|
EAPI void *
|
|
eet_data_image_encode_cipher(const void *data,
|
|
const char *cipher_key,
|
|
unsigned int w,
|
|
unsigned int h,
|
|
int alpha,
|
|
int compress,
|
|
int quality,
|
|
int lossy,
|
|
int *size_ret);
|
|
|
|
|
|
|
|
|
|
typedef void (*Eet_Dump_Callback)(void *data, const char *str);
|
|
|
|
"""
|
|
|
|
Dump an eet encoded data structure into ascii text
|
|
:param data_in: The pointer to the data to decode into a struct.
|
|
:param size_in: The size of the data pointed to in bytes.
|
|
:param dumpfunc: The function to call passed a string when new
|
|
data is converted to text
|
|
:param dumpdata: The data to pass to the @p dumpfunc callback.
|
|
:return: 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 @p dumpfunc callback
|
|
for all new text that is generated. This callback should append
|
|
to any existing text buffer and will be passed the pointer @p
|
|
dumpdata as a parameter as well as a string with new text to be
|
|
appended.
|
|
|
|
Example:
|
|
|
|
@code
|
|
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(data, len, output, NULL);
|
|
}
|
|
@endcode
|
|
|
|
:see: eet_data_text_dump_cipher()
|
|
|
|
:since: 1.0.0
|
|
|
|
"""
|
|
EAPI int
|
|
eet_data_text_dump(const void *data_in,
|
|
int size_in,
|
|
Eet_Dump_Callback dumpfunc,
|
|
void *dumpdata);
|
|
|
|
"""
|
|
|
|
Take an ascii encoding from eet_data_text_dump() and re-encode in binary.
|
|
:param text: The pointer to the string data to parse and encode.
|
|
:param textlen: The size of the string in bytes (not including 0
|
|
byte terminator).
|
|
:param size_ret: This gets filled in with the encoded data blob
|
|
size in bytes.
|
|
:return: The encoded data on success, NULL on failure.
|
|
|
|
This function will parse the string pointed to by @p 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. @p text is a normal
|
|
C string.
|
|
|
|
:see: eet_data_text_undump_cipher()
|
|
|
|
:since: 1.0.0
|
|
|
|
"""
|
|
EAPI void *
|
|
eet_data_text_undump(const char *text,
|
|
int textlen,
|
|
int *size_ret);
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
Read a data structure from an eet extended attribute and decodes it using a cipher.
|
|
:param filename: The file to extract the extended attribute from.
|
|
:param attribute: The attribute to get the data from.
|
|
:param edd: The data descriptor handle to use when decoding.
|
|
:param cipher_key: The key to use as cipher.
|
|
:return: A pointer to the decoded data structure.
|
|
|
|
This function decodes a data structure stored in an eet extended attribute,
|
|
returning a pointer to it if it decoded successfully, or NULL on failure.
|
|
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, from a chunk of memory or from an extended attribute
|
|
is as simple as a single function call.
|
|
|
|
:since: 1.5.0
|
|
|
|
"""
|
|
EAPI void *
|
|
eet_data_xattr_cipher_get(const char *filename,
|
|
const char *attribute,
|
|
Eet_Data_Descriptor *edd,
|
|
const char *cipher_key);
|
|
|
|
|
|
"""
|
|
|
|
Write a data structure from memory and store in an eet extended attribute
|
|
using a cipher.
|
|
:param filename: The file to write the extended attribute to.
|
|
:param attribute: The attribute to store the data to.
|
|
:param edd: The data descriptor to use when encoding.
|
|
:param cipher_key: The key to use as cipher.
|
|
:param data: A pointer to the data structure to save and encode.
|
|
:param flags: The policy to use when setting the data.
|
|
:return: EINA_TRUE on success, EINA_FALSE on failure.
|
|
|
|
This function is the reverse of eet_data_xattr_cipher_get(), saving a data structure
|
|
to an eet extended attribute.
|
|
|
|
:since: 1.5.0
|
|
|
|
"""
|
|
EAPI Eina_Bool
|
|
eet_data_xattr_cipher_set(const char *filename,
|
|
const char *attribute,
|
|
Eet_Data_Descriptor *edd,
|
|
const char *cipher_key,
|
|
const void *data,
|
|
Eina_Xattr_Flags flags);
|
|
|
|
"""
|
|
|
|
Dump an eet encoded data structure into ascii text using a cipher.
|
|
:param data_in: The pointer to the data to decode into a struct.
|
|
:param cipher_key: The key to use as cipher.
|
|
:param size_in: The size of the data pointed to in bytes.
|
|
:param dumpfunc: The function to call passed a string when new
|
|
data is converted to text
|
|
:param dumpdata: The data to pass to the @p dumpfunc callback.
|
|
:return: 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 @p dumpfunc callback
|
|
for all new text that is generated. This callback should append
|
|
to any existing text buffer and will be passed the pointer @p
|
|
dumpdata as a parameter as well as a string with new text to be
|
|
appended.
|
|
|
|
Example:
|
|
|
|
@code
|
|
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);
|
|
}
|
|
@endcode
|
|
|
|
:see: eet_data_text_dump()
|
|
|
|
:since: 1.0.0
|
|
|
|
"""
|
|
EAPI int
|
|
eet_data_text_dump_cipher(const void *data_in,
|
|
const char *cipher_key,
|
|
int size_in,
|
|
Eet_Dump_Callback dumpfunc,
|
|
void *dumpdata);
|
|
|
|
"""
|
|
|
|
Take an ascii encoding from eet_data_text_dump() and re-encode
|
|
in binary using a cipher.
|
|
:param text: The pointer to the string data to parse and encode.
|
|
:param cipher_key: The key to use as cipher.
|
|
:param textlen: The size of the string in bytes (not including 0
|
|
byte terminator).
|
|
:param size_ret: This gets filled in with the encoded data blob
|
|
size in bytes.
|
|
:return: The encoded data on success, NULL on failure.
|
|
|
|
This function will parse the string pointed to by @p 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. @p text is a normal
|
|
C string.
|
|
|
|
:see: eet_data_text_undump()
|
|
|
|
:since: 1.0.0
|
|
|
|
"""
|
|
EAPI void *
|
|
eet_data_text_undump_cipher(const char *text,
|
|
const char *cipher_key,
|
|
int textlen,
|
|
int *size_ret);
|
|
|
|
|
|
"""
|
|
|
|
TODO FIX ME
|
|
|
|
"""
|
|
EAPI Eet_Node *
|
|
eet_data_node_decode_cipher(const void *data_in,
|
|
const char *cipher_key,
|
|
int size_in);
|
|
|
|
|
|
"""
|
|
|
|
Display the x509 der certificate to out.
|
|
|
|
:param certificate: the x509 certificate to print
|
|
:param der_length: The length the certificate.
|
|
:param out: where to print.
|
|
|
|
@warning You need to compile signature support in EET.
|
|
:since: 1.2.0
|
|
|
|
"""
|
|
EAPI void
|
|
eet_identity_certificate_print(const unsigned char *certificate,
|
|
int der_length,
|
|
FILE *out);
|