![]() |
yumapro
25.10-1
YumaPro SDK
|
Base64 utility functions for YANG. More...

Functions | |
| status_t | b64_encode (const unsigned char *inbuff, unsigned int inbufflen, unsigned char *outbuff, unsigned int outbufflen, unsigned int linesize, unsigned int *retlen) |
| base64 encode a stream adding padding and line breaks as per spec. More... | |
| status_t | b64_decode (const uint8_t *inbuff, uint32_t inbufflen, uint8_t *outbuff, uint32_t outbufflen, uint32_t *retlen) |
| Decode a base64 string. More... | |
| uint32_t | b64_get_decoded_str_len (const uint8_t *inbuff, size_t inputLen) |
| Calculate the length of the buffer required to decode the base64 string. More... | |
| uint32_t | b64_get_encoded_str_len (uint32_t inbufflen, uint32_t linesize) |
| Get the output buffer size required for encoding the string. More... | |
| boolean | b64_valid_base64 (const char *b64str) |
| Check if a string match base64 encoding or not. More... | |
| void | blob2bin (const char *pblob, unsigned char *pbuff, uint32 bsize) |
| Convert a mySQL BLOB to a binary string. More... | |
| void | bin2blob (const unsigned char *pbuff, char *pblob, uint32 bsize) |
| Convert a binary string to to a mySQL BLOB. More... | |
| uint32 | bobhash (REGISTER const uint8 *k, REGISTER uint32 length, REGISTER uint32 initval) |
| Calculate a 32-bit BOB hash value. More... | |
Base64 utility functions for YANG.
bobhash function is used by the def_reg.c module to hash the registry entries.
The blob utilities are used by yangdump-pro.
The 'binary' data type is supported by these conversion functions.
The –format=sqldb option needs to convert blobs to text.
It is not used anywhere else.
| status_t b64_decode | ( | const uint8_t * | inbuff, |
| uint32_t | inbufflen, | ||
| uint8_t * | outbuff, | ||
| uint32_t | outbufflen, | ||
| uint32_t * | retlen | ||
| ) |
Decode a base64 string.
This function decodes the supplied base 64 string. It has the following constraints:
1 - The length of the supplied base64 string must be divisible by 4
(any other length strings are NOT valid base 64)
2 - If any non base64 characters are encountered the length of
decoded string will be truncated.
3 - CR and LF characters in the encoded string will be skipped.
| inbuff | pointer to buffer of base64 chars |
| inbufflen | number of chars in inbuff |
| outbuff | pointer to the output buffer to use |
| outbufflen | the length of outbuff. |
| retlen | the number of decoded bytes |

| status_t b64_encode | ( | const unsigned char * | inbuff, |
| unsigned int | inbufflen, | ||
| unsigned char * | outbuff, | ||
| unsigned int | outbufflen, | ||
| unsigned int | linesize, | ||
| unsigned int * | retlen | ||
| ) |
base64 encode a stream adding padding and line breaks as per spec.
| inbuff | pointer to buffer of binary chars |
| inbufflen | number of binary chars in inbuff |
| outbuff | pointer to the output buffer to use. |
| outbufflen | max number of chars to write to outbuff |
| linesize | the output line length to use |
| retlen | address of return length |
| uint32_t b64_get_decoded_str_len | ( | const uint8_t * | inbuff, |
| size_t | inputLen | ||
| ) |
Calculate the length of the buffer required to decode the base64 string.
| inbuff | the base64 string to decode. |
| inputLen | the length of inbuff. |

| uint32_t b64_get_encoded_str_len | ( | uint32_t | inbufflen, |
| uint32_t | linesize | ||
| ) |
Get the output buffer size required for encoding the string.
| inbufflen | the size of the input buffer. |
| linesize | the length of each line |

| boolean b64_valid_base64 | ( | const char * | b64str | ) |
Check if a string match base64 encoding or not.
In base64 encoding, the character set is [A-Z,a-z,0-9,and + /], if the rest length is less than 4, pad with '=' character.
^([A-Za-z0-9+/]{4})* means the String start with 0 time or more base64 group
([A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==) means the String must end of 3 forms in [A-Za-z0-9+/]{4} or [A-Za-z0-9+/]{3}= or [A-Za-z0-9+/]{2}==
If the String matches this pattern then it is a valid base64 string which can be decoded.
| b64str | input string to check |

| void bin2blob | ( | const unsigned char * | pbuff, |
| char * | pblob, | ||
| uint32 | bsize | ||
| ) |
Convert a binary string to to a mySQL BLOB.
| pbuff | pointer to buffer to convert; must be at least bsize+1 bytes in length | |
| [out] | pblob | pointer to BLOB to fill in; must be at least bsize * 2 + 1 bytes in length pblob is filled in, and zero-terminated |
| bsize | binary object size |
| void blob2bin | ( | const char * | pblob, |
| unsigned char * | pbuff, | ||
| uint32 | bsize | ||
| ) |
Convert a mySQL BLOB to a binary string.
INPUTS:
| pblob | pointer to BLOB to convert; must be of the same type as the binary object; this blob will be bsize * 2 + 1 bytes in length | |
| [out] | pbuff | pointer to buffer to fill in; must be at least bsize+1 bytes in length; pbuff is filled in |
| bsize | binary object size |
| uint32 bobhash | ( | REGISTER const uint8 * | k, |
| REGISTER uint32 | length, | ||
| REGISTER uint32 | initval | ||
| ) |
Calculate a 32-bit BOB hash value.
@param k the key (the unaligned variable-length array of bytes) @param len len the length of the key, counting by bytes @param initval can be any 4-byte value @return unsigned long has value