libdata-gcf  1.1.2
Functions
Base 36 routines

Functions

int gcf_base36_decode (uint32_t code, char *id)
 Decode a base36 integer into a string. More...
 
int gcf_base36_encode (const char *id, uint32_t *code)
 Encode a string to a base36 integer. More...
 

Detailed Description

A small set of routines for manipulating the base 36 IDs used in GCF block headers.

Function Documentation

◆ gcf_base36_decode()

int gcf_base36_decode ( uint32_t  code,
char *  id 
)

Decode a base36 integer into a string.

Parameters
codeThe integer value to decode.
[out]idBuffer into which the string (null-terminated) is written.
Return values
0on success.
-1on error (and see gcf_errstr).

Decodes the base-36 encoded string in code, storing the result in id. The buffer id must have at least 7 bytes free (6 for the decoded ID, and one for the terminating null). The operation can only fail if the topmost bit of code is set (since the ID is defined as being 31-bit).

◆ gcf_base36_encode()

int gcf_base36_encode ( const char *  id,
uint32_t *  code 
)

Encode a string to a base36 integer.

Parameters
idThe string to encode.
[out]codeThe encoded base 36 integer.
Return values
0on success.
-1on error (and see gcf_errstr).

Encodes the string id into a base 36 integer, which is stored in code. The operation will fail if the string is too long or contains characters not in the set A-Z or 0-9. The result will only ever use 31 bits. The operation is not case sensitive. If the string cannot be encoded, -1 will be returned, nothing will be written to code.