atobase 3.2.0
ATOMAS atobase

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...
 

Detailed Description

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.

Function Documentation

◆ ato_base64decode_array()

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().

Parameters
ctxthe current thread local Context
datathe address of ato_String buffer for the decoded content - caller must free using ato_str_free().
b64the encoded base64 array to decode.
lenthe length of the b64 array
Returns
ATO_ERR_OK or an error.

◆ ato_base64encode_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().

Parameters
ctxthe current thread local Context
b64the address of ato_String buffer for the encoded content - caller must free using ato_str_free().
datathe content - possibly binary
lenthe length of the content
Returns
ATO_ERR_OK or an error.

◆ ato_new_pseudo_guid()

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.

Parameters
ctxthe current thread local Context
guidstrthe address of the buffer to write the guid to.
Returns
guidstr or NULL if it failed.

◆ ato_alloc()

ATO_EXPORT void * ato_alloc ( size_t  sz)

Alloc sz memory within the library.

Use ato_free() to free.

Parameters
szthe size to allocate
Returns
the buffer.

◆ ato_free()

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.

Parameters
vthe buffer to free
Returns
NULL