General utility methods used in the SDK codebase. More...
Functions | |
ATO_EXPORT int | ato_base64decode_array (ato_Ctx *ctx, ato_String **data, const char *b64, size_t len) |
Accepts a Base64 array and returns the decoded (possibly binary) data and data length in an ato_String. More... | |
ATO_EXPORT int | ato_base64encode_array (ato_Ctx *ctx, ato_String **b64, const char *data, size_t len) |
Accepts data and returns the Base64 encoded data as an ato_String. More... | |
ATO_EXPORT char * | ato_new_pseudo_guid (ato_Ctx *ctx, char *guidstr) |
Generate a null terminated (pseudo) guid. More... | |
ATO_EXPORT void * | ato_alloc (size_t sz) |
Alloc sz memory within the library. More... | |
ATO_EXPORT void * | ato_free (void *v) |
Free v if not NULL and return NULL. More... | |
General utility methods used in the SDK codebase.
They are available to use by application developers should they so wish.
Note: in API comments elsewhere, the terms "string" generally refers to a '\0' terminated char array (C string), whereas "ato string" refers the ato_String object.
ATO_EXPORT int ato_base64decode_array | ( | ato_Ctx * | ctx, |
ato_String ** | data, | ||
const char * | b64, | ||
size_t | len | ||
) |
Accepts a Base64 array and returns the decoded (possibly binary) data and data length in an ato_String.
To access content, use ato_str_value() and ato_str_len().
ctx | the current thread local Context |
data | the address of ato_String buffer for the decoded content - caller must free using ato_str_free(). |
b64 | the encoded base64 array to decode. |
len | the length of the b64 array |
ATO_EXPORT int ato_base64encode_array | ( | ato_Ctx * | ctx, |
ato_String ** | b64, | ||
const char * | data, | ||
size_t | len | ||
) |
Accepts data and returns the Base64 encoded data as an ato_String.
To access content, use ato_str_value() and ato_str_len().
ctx | the current thread local Context |
b64 | the address of ato_String buffer for the encoded content - caller must free using ato_str_free(). |
data | the content - possibly binary |
len | the length of the content |
ATO_EXPORT char* ato_new_pseudo_guid | ( | ato_Ctx * | ctx, |
char * | guidstr | ||
) |
Generate a null terminated (pseudo) guid.
Make sure the guidstr buff is big enough - 50 chars will do.
Not robust (guaranteed to be really GUID) but suitable for testing purposes.
ctx | the current thread local Context |
guidstr | the address of the buffer to write the guid to. |
ATO_EXPORT void* ato_alloc | ( | size_t | sz | ) |
Alloc sz memory within the library.
Use ato_free() to free.
sz | the size to allocate |
ATO_EXPORT void* ato_free | ( | void * | v | ) |
Free v if not NULL and return NULL.
Any strings allocated by the dependant libraries should be freed using this. That is, the library that allocates memory, should free it. If client code frees such memory, it may work, or may result in segmentation faults.
v | the buffer to free |