c-icap-doc  0.1
Functions
utility funtions


Utility functions More...

Functions

int ci_base64_decode (const char *str, char *result, int len)
 
Decodes a base64 encoded string. More...
 
int ci_base64_encode (const unsigned char *data, size_t datalen, char *out, size_t outlen)
 
Produces a base64 encoded string. More...
 
int ci_encoding_method (const char *content_encoding)
 
Return the encoding method integer representation from string. More...
 
int ci_uncompress_preview (int compress_method, const char *buf, int len, char *unzipped_buf, int *unzipped_buf_len)
 
Uncompress a zipped string. More...
 
const char * ci_decompress_error (int err)
 
Return a string representation of a decompress error code. More...
 
int ci_decompress_to_membuf (int encoding_format, const char *inbuf, size_t inlen, struct ci_membuf *outbuf, ci_off_t max_size)
 
Uncompress any compressed data that c-icap understands and writes the output to the outbuf object, regardless of algorithm More...
 
int ci_decompress_to_simple_file (int encoding_format, const char *inbuf, size_t inlen, struct ci_simple_file *outbuf, ci_off_t max_size)
 
More...
 
int ci_inflate_to_membuf (const char *inbuf, size_t inlen, struct ci_membuf *outbuf, ci_off_t max_size)
 
Uncompress deflate/gzip compressed data and writes the output to the outbuf object More...
 
int ci_inflate_to_simple_file (const char *inbuf, size_t inlen, struct ci_simple_file *outbuf, ci_off_t max_size)
 
More...
 
int ci_bzunzip_to_membuf (const char *inbuf, size_t inlen, struct ci_membuf *outbuf, ci_off_t max_size)
 
Uncompress bzip2 compressed data and writes the output to the outbuf object More...
 
int ci_bzunzip_to_simple_file (const char *inbuf, size_t inlen, struct ci_simple_file *outbuf, ci_off_t max_size)
 
More...
 
int ci_brinflate_to_membuf (const char *inbuf, size_t inlen, struct ci_membuf *outbuf, ci_off_t max_size)
 
Uncompress brotli compressed data and writes the output to the outbuf object More...
 
int ci_brinflate_to_simple_file (const char *inbuf, size_t inlen, struct ci_simple_file *outbuf, ci_off_t max_size)
 
More...
 
int ci_compress_to_membuf (int encoding_format, const char *inbuf, size_t inlen, struct ci_membuf *outbuf, ci_off_t max_size)
 
Compress any uncompressed data that c-icap understands and writes the output to the outbuf object, regardless of algorithm More...
 
int ci_compress_to_simple_file (int encoding_format, const char *inbuf, size_t inlen, struct ci_simple_file *outbuf, ci_off_t max_size)
 
More...
 
int ci_deflate_to_membuf (const char *inbuf, size_t inlen, struct ci_membuf *outbuf, ci_off_t max_size)
 
Compress deflate uncompressed data and writes the output to the outbuf object More...
 
int ci_deflate_to_simple_file (const char *inbuf, size_t inlen, struct ci_simple_file *outbuf, ci_off_t max_size)
 
More...
 
int ci_gzip_to_membuf (const char *inbuf, size_t inlen, struct ci_membuf *outbuf, ci_off_t max_size)
 
Compress gzip uncompressed data and writes the output to the outbuf object More...
 
int ci_gzip_to_simple_file (const char *inbuf, size_t inlen, struct ci_simple_file *outbuf, ci_off_t max_size)
 
More...
 
int ci_bzzip_to_membuf (const char *inbuf, size_t inlen, struct ci_membuf *outbuf, ci_off_t max_size)
 
Compress bzip2 uncompressed data and writes the output to the outbuf object More...
 
int ci_bzzip_to_simple_file (const char *inbuf, size_t inlen, struct ci_simple_file *outbuf, ci_off_t max_size)
 
More...
 
int ci_brdeflate_to_membuf (const char *inbuf, size_t inlen, struct ci_membuf *outbuf, ci_off_t max_size)
 
Compress brotli uncompressed data and writes the output to the outbuf object More...
 
int ci_brdeflate_to_simple_file (const char *inbuf, size_t inlen, struct ci_simple_file *outbuf, ci_off_t max_size)
 
More...
 
char * ci_base64_decode_dup (const char *str)
 
Decodes a base64 encoded string, and also allocate memory for the result. More...
 
int ci_http_response_content_encoding (ci_request_t *req)
 
Return the encoding method integer representation from string. More...
 

Detailed Description


Utility functions

Function Documentation

◆ ci_base64_decode()

int ci_base64_decode ( const char *  str,
char *  result,
int  len 
)


Decodes a base64 encoded string.

Parameters
stris a buffer which holds the base64 encoded data
resultis a buffer where the decoded data will be stored
lenis the length of the result buffer
Returns
the number of decoded bytes

◆ ci_base64_decode_dup()

char* ci_base64_decode_dup ( const char *  str)


Decodes a base64 encoded string, and also allocate memory for the result.

Parameters
stris a buffer which holds the base64 encoded data
Returns
a pointer to the decoded string. It uses malloc to allocate space for the decoded string so the free function should used to release the allocated memory.

◆ ci_base64_encode()

int ci_base64_encode ( const unsigned char *  data,
size_t  datalen,
char *  out,
size_t  outlen 
)


Produces a base64 encoded string.

Parameters
datais a buffer which holds the data to be encoded
datalenis the length of the data buffer
outis a buffer where the encoded data will be stored
outlenis the length of the out buffer
Returns
the number of decoded bytes

◆ ci_brdeflate_to_membuf()

int ci_brdeflate_to_membuf ( const char *  inbuf,
size_t  inlen,
struct ci_membuf *  outbuf,
ci_off_t  max_size 
)


Compress brotli uncompressed data and writes the output to the outbuf object

Parameters
inbufis a buffer which holds the unzipped data
inlenis the length of the buffer buf
outbufwhere to put zipped data
max_sizeif it is greater than zero, the output data limit
Returns
CI_COMP_OK on success, CI_COMP_ERR_NONE, if maxsize exceed, an CI_COMPRESS_ERRORS code otherwise

◆ ci_brdeflate_to_simple_file()

int ci_brdeflate_to_simple_file ( const char *  inbuf,
size_t  inlen,
struct ci_simple_file *  outbuf,
ci_off_t  max_size 
)


◆ ci_brinflate_to_membuf()

int ci_brinflate_to_membuf ( const char *  inbuf,
size_t  inlen,
struct ci_membuf *  outbuf,
ci_off_t  max_size 
)


Uncompress brotli compressed data and writes the output to the outbuf object

Parameters
inbufis a buffer which holds the zipped data
inlenis the length of the buffer buf
outbufwhere to put unzipped data
max_sizeif it is greater than zero, the output data limit
Returns
CI_UNCOMP_OK on success, CI_UNCOMP_ERR_NONE, if maxsize exceed, an CI_UNCOMPRESS_ERRORS code otherwise

◆ ci_brinflate_to_simple_file()

int ci_brinflate_to_simple_file ( const char *  inbuf,
size_t  inlen,
struct ci_simple_file *  outbuf,
ci_off_t  max_size 
)


◆ ci_bzunzip_to_membuf()

int ci_bzunzip_to_membuf ( const char *  inbuf,
size_t  inlen,
struct ci_membuf *  outbuf,
ci_off_t  max_size 
)


Uncompress bzip2 compressed data and writes the output to the outbuf object

Parameters
inbufis a buffer which holds the zipped data
inlenis the length of the buffer buf
outbufwhere to put unzipped data
max_sizeif it is greater than zero, the output data limit
Returns
CI_UNCOMP_OK on success, CI_UNCOMP_ERR_NONE, if maxsize exceed, an CI_UNCOMPRESS_ERRORS code otherwise

◆ ci_bzunzip_to_simple_file()

int ci_bzunzip_to_simple_file ( const char *  inbuf,
size_t  inlen,
struct ci_simple_file *  outbuf,
ci_off_t  max_size 
)


◆ ci_bzzip_to_membuf()

int ci_bzzip_to_membuf ( const char *  inbuf,
size_t  inlen,
struct ci_membuf *  outbuf,
ci_off_t  max_size 
)


Compress bzip2 uncompressed data and writes the output to the outbuf object

Parameters
inbufis a buffer which holds the unzipped data
inlenis the length of the buffer buf
outbufwhere to put zipped data
max_sizeif it is greater than zero, the output data limit
Returns
CI_COMP_OK on success, CI_COMP_ERR_NONE, if maxsize exceed, an CI_COMPRESS_ERRORS code otherwise

◆ ci_bzzip_to_simple_file()

int ci_bzzip_to_simple_file ( const char *  inbuf,
size_t  inlen,
struct ci_simple_file *  outbuf,
ci_off_t  max_size 
)


◆ ci_compress_to_membuf()

int ci_compress_to_membuf ( int  encoding_format,
const char *  inbuf,
size_t  inlen,
struct ci_membuf *  outbuf,
ci_off_t  max_size 
)


Compress any uncompressed data that c-icap understands and writes the output to the outbuf object, regardless of algorithm

Parameters
encoding_formatis the enum for the encoding type
inbufis a buffer which holds the unzipped data
inlenis the length of the buffer buf
outbufwhere to put zipped data
max_sizeif it is greater than zero, the output data limit
Returns
CI_COMP_OK on success, CI_COMP_ERR_NONE, if maxsize exceed, an CI_COMPRESS_ERRORS code otherwise

◆ ci_compress_to_simple_file()

int ci_compress_to_simple_file ( int  encoding_format,
const char *  inbuf,
size_t  inlen,
struct ci_simple_file *  outbuf,
ci_off_t  max_size 
)


◆ ci_decompress_error()

const char* ci_decompress_error ( int  err)


Return a string representation of a decompress error code.

Parameters
erra CI_UNCOMPRESS_ERRORS error code

◆ ci_decompress_to_membuf()

int ci_decompress_to_membuf ( int  encoding_format,
const char *  inbuf,
size_t  inlen,
struct ci_membuf *  outbuf,
ci_off_t  max_size 
)


Uncompress any compressed data that c-icap understands and writes the output to the outbuf object, regardless of algorithm

Parameters
encoding_formatis the enum for the encoding type
inbufis a buffer which holds the zipped data
inlenis the length of the buffer buf
outbufwhere to put unzipped data
max_sizeif it is greater than zero, the output data limit
Returns
CI_UNCOMP_OK on success, CI_UNCOMP_ERR_NONE, if maxsize exceed, an CI_UNCOMPRESS_ERRORS code otherwise

◆ ci_decompress_to_simple_file()

int ci_decompress_to_simple_file ( int  encoding_format,
const char *  inbuf,
size_t  inlen,
struct ci_simple_file *  outbuf,
ci_off_t  max_size 
)


◆ ci_deflate_to_membuf()

int ci_deflate_to_membuf ( const char *  inbuf,
size_t  inlen,
struct ci_membuf *  outbuf,
ci_off_t  max_size 
)


Compress deflate uncompressed data and writes the output to the outbuf object

Parameters
inbufis a buffer which holds the unzipped data
inlenis the length of the buffer buf
outbufwhere to put zipped data
max_sizeif it is greater than zero, the output data limit
Returns
CI_COMP_OK on success, CI_COMP_ERR_NONE, if maxsize exceed, an CI_COMPRESS_ERRORS code otherwise

◆ ci_deflate_to_simple_file()

int ci_deflate_to_simple_file ( const char *  inbuf,
size_t  inlen,
struct ci_simple_file *  outbuf,
ci_off_t  max_size 
)


◆ ci_encoding_method()

int ci_encoding_method ( const char *  content_encoding)


Return the encoding method integer representation from string.

Parameters
content_encodingThe content encoding name
Returns
the CI_ENCODE_* representation

◆ ci_gzip_to_membuf()

int ci_gzip_to_membuf ( const char *  inbuf,
size_t  inlen,
struct ci_membuf *  outbuf,
ci_off_t  max_size 
)


Compress gzip uncompressed data and writes the output to the outbuf object

Parameters
inbufis a buffer which holds the unzipped data
inlenis the length of the buffer buf
outbufwhere to put zipped data
max_sizeif it is greater than zero, the output data limit
Returns
CI_COMP_OK on success, CI_COMP_ERR_NONE, if maxsize exceed, an CI_COMPRESS_ERRORS code otherwise

◆ ci_gzip_to_simple_file()

int ci_gzip_to_simple_file ( const char *  inbuf,
size_t  inlen,
struct ci_simple_file *  outbuf,
ci_off_t  max_size 
)


◆ ci_http_response_content_encoding()

int ci_http_response_content_encoding ( ci_request_t req)


Return the encoding method integer representation from string.

Parameters
reqis a pointer to the current ICAP request object.
Returns
the content encoding, CI_ENCODE_NONE for no encoding or CI_ENCODE_UNKNOWN for non RESPMOD ICAP requests

◆ ci_inflate_to_membuf()

int ci_inflate_to_membuf ( const char *  inbuf,
size_t  inlen,
struct ci_membuf *  outbuf,
ci_off_t  max_size 
)


Uncompress deflate/gzip compressed data and writes the output to the outbuf object

Parameters
inbufis a buffer which holds the zipped data
inlenis the length of the buffer buf
outbufwhere to put unzipped data
max_sizeif it is greater than zero, the output data limit
Returns
CI_UNCOMP_OK on success, CI_UNCOMP_ERR_NONE, if maxsize exceed, an CI_UNCOMPRESS_ERRORS code otherwise

◆ ci_inflate_to_simple_file()

int ci_inflate_to_simple_file ( const char *  inbuf,
size_t  inlen,
struct ci_simple_file *  outbuf,
ci_off_t  max_size 
)


◆ ci_uncompress_preview()

int ci_uncompress_preview ( int  compress_method,
const char *  buf,
int  len,
char *  unzipped_buf,
int *  unzipped_buf_len 
)


Uncompress a zipped string.

Parameters
compress_methodCI_ENCODE_GZIP, CI_ENCODED_DEFLATE or CI_CI_ENCODE_BZIP2
bufis a buffer which holds the zipped data
lenis the length of the buffer buf
unzipped_bufis the buffer where to store unzipped data
unzipped_buf_lenis the length of the buffer to store unzipped data, and updated with the length of unzipped data
Returns
CI_OK on success CI_ERROR on error