|
libpcp
0.2.1
|
Z85 Encoding functions. More...
Functions | |
| unsigned char * | pcp_padfour (unsigned char *src, size_t srclen, size_t *dstlen) |
| Zero-pad some input data. | |
| size_t | pcp_unpadfour (unsigned char *src, size_t srclen) |
| Unpad padded input data. | |
| unsigned char * | pcp_z85_decode (char *z85block, size_t *dstlen) |
| Decode data from Z85 encoding. | |
| char * | pcp_z85_encode (unsigned char *raw, size_t srclen, size_t *dstlen) |
| Encode data to Z85 encoding. | |
| char * | pcp_readz85file (FILE *infile) |
| Read a Z85 encoded file. | |
| char * | pcp_readz85string (unsigned char *input, size_t bufsize) |
| Read a Z85 encoded string. | |
Z85 Encoding functions.
The Z85 encoding format is described here: ZeroMQ Spec.32. It's part of ZeroMQ. Z85 is based on ASCII85 with a couple of modifications (portability, readability etc).
To fulfil the requirements of the ZeroMQ Z85 functions, PCP does some additional preparations of raw input before actually doing the encoding, since the input for zmq_z85_encode() must be divisible by 4. Therefore we pad the input with zeroes and remove them after decoding.
| unsigned char* pcp_padfour | ( | unsigned char * | src, |
| size_t | srclen, | ||
| size_t * | dstlen | ||
| ) |
Zero-pad some input data.
This function allocates new memory for the returned data. It puts the original pointer into it and adds a number of zeros so that the result has a size divisable by 4.
| [in] | src | Unpadded data. |
| [in] | srclen | Size of unpadded data. |
| [in] | dstlen | Returned size of padded data (pointer to int). |
| char* pcp_readz85file | ( | FILE * | infile | ) |
Read a Z85 encoded file.
Reads a file and returns the raw Z85 encoded string. It ignores newlines, comments and Headerstrings.
| [in] | infile | FILE stream to read from. |
| char* pcp_readz85string | ( | unsigned char * | input, |
| size_t | bufsize | ||
| ) |
Read a Z85 encoded string.
Parses the given input string and returns the raw Z85 encoded string. It ignores newlines, comments and Headerstrings.
| [in] | input | Z85 encoded string. |
| [in] | bufsize | Size of the string. |
| size_t pcp_unpadfour | ( | unsigned char * | src, |
| size_t | srclen | ||
| ) |
Unpad padded input data.
It just calculates the size of the unpadded result (size - all trailing zeroes). Doesn't allocate any memory or modify anything.
| [in] | src | Padded data. |
| [in] | srclen | Size of padded data. |
| unsigned char* pcp_z85_decode | ( | char * | z85block, |
| size_t * | dstlen | ||
| ) |
Decode data from Z85 encoding.
The input z85block may contain newlines which will be removed.
| [in] | z85block | The Z85 encoded string. |
| [in] | dstlen | Returned size of decoded data (pointer to int). |
| char* pcp_z85_encode | ( | unsigned char * | raw, |
| size_t | srclen, | ||
| size_t * | dstlen | ||
| ) |
Encode data to Z85 encoding.
Beside Z85 encoding it also adds a newline everiy 72 characters.
| [in] | raw | Pointer to raw data. |
| [in] | srclen | Size of the data. |
| [in] | dstlen | Returned size of encoded data (pointer to int). |
1.8.2