-
Notifications
You must be signed in to change notification settings - Fork 0
Utils
Sudheer edited this page Apr 2, 2023
·
19 revisions
Miscellaneous utilities, not necessarilty related to the main theme of the efio library. These are intended for usage in lua to achieve respective functionalities not available in pure lua.
Can be refactored in the future as a separate library along with many such utility functions
DESCRIPTION: returns the maximum value of a float
DESCRIPTION: returns the maximum value of a double
DESCRIPTION: returns the maximum value of a long double
DESCRIPTION: returns 1 if the input float is not a number
ARGUMENTS:
float f
DESCRIPTION: returns 1 if the input float is infinity
ARGUMENTS:
float f
DESCRIPTION: returns 1 if the input double is not a number
ARGUMENTS:
double d
DESCRIPTION: returns 1 if the input double is infinity
ARGUMENTS:
double d
DESCRIPTION:
Encodes the given input binary data to HEX string format.
Memory needed for the returned string is allocated within and the calling functions is
expected to free the memory.
PARAMETERS:
const unsigned char *data : binary data
size_t input_length : size of the binary data
size_t *output_length : pointer to variable of type size_t where the length of the output
buffer will be written
RETURN:
output_length
unsigned char * : output buffer
DESCRIPTION:
Decodes the input hex string
Memory needed for the returned binary data is allocated within and the calling functions is
expected to free the memory.
PARAMETERS:
const unsigned char *data : string data
size_t input_length : size of the string data
size_t *output_length : pointer to variable of type size_t where the length of the output
buffer will be written
RETURN:
output_length
unsigned char * : output buffer
DESCRIPTION:
Encodes the given input binary data to base64 string format.
Memory needed for the returned string is allocated within and the calling functions are
expected to free the memory.
PARAMETERS:
const unsigned char *data : binary data
size_t input_length : size of the binary data
size_t *output_length : pointer to variable of type size_t where the length of the output
buffer will be written
RETURN:
output_length
unsigned char * : output buffer
DESCRIPTION:
Decodes the input base64 encoded string
Memory needed for the returned binary data is allocated within and the calling functions are
expected to free the memory.
PARAMETERS:
const unsigned char *data : string data
size_t input_length : size of the string data
size_t *output_length : pointer to variable of type size_t where the length of the output
buffer will be written
RETURN:
output_length
unsigned char * : output buffer
DESCRIPTION:
Compresses the input buffer of given size using zlib, and at Z_DEFAULT_COMPRESSION level
Memory needed for the returned binary data is allocated within and the calling functions are
expected to free the memory.
PARAMETERS:
void * data : input buffer, data to be compressed
size_t in_size : size of the input data
void ** out_ptr : pointer to to be allocated pointer where the compressed data will be written
size_t * out_len : pointer to variable of type size_t where the length of the output
buffer will be written
RETURN:
int ret : Z_OK (0) in case of successful compression, error value otherwise
DESCRIPTION:
Decompresses the input buffer of given size using zlib.
Memory needed for the returned binary data is allocated within and the calling functions are
expected to free the memory.
PARAMETERS:
void * data : input compressed data
size_t in_size : size of the input data
void ** out_ptr : pointer to to be allocated pointer where the decompressed data will be written
size_t * out_len : pointer to variable of type size_t where the length of the output
buffer will be written
RETURN:
int ret : Z_OK (0) in case of successful compression, error value otherwise
DESCRIPTION:
Returns the string discription of the given error
PARAMETERS:
int ret : integer value returned by either of compress or uncompress functions above
RETURN:
const char * : Descripton of the error message