source: squid-ssl/trunk/fuentes/include/base64.h @ 5495

Last change on this file since 5495 was 5495, checked in by Juanma, 2 years ago

Initial release

File size: 2.3 KB
Line 
1/*
2 * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
3 *
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
7 */
8
9#ifndef _SQUID_BASE64_H
10#define _SQUID_BASE64_H
11
12#ifdef __cplusplus
13extern "C" {
14#endif
15
16// Decoding functions
17
18/// Calculate the decoded length of a given nul-terminated encoded string.
19/// NULL pointer and empty strings are accepted, result is zero.
20/// Any return value <= zero means no decoded result can be produced.
21extern int base64_decode_len(const char *encodedData);
22
23/// Decode a base-64 encoded blob into a provided buffer.
24/// Will not terminate the resulting string.
25/// In-place decoding overlap is supported if result is equal or earlier that the source pointer.
26///
27/// \return number of bytes filled in result.
28extern int base64_decode(char *result, unsigned int result_max_size, const char *encoded);
29
30// Encoding functions
31
32/// Calculate the buffer size required to hold the encoded form of
33/// a string of length 'decodedLen' including all terminator bytes.
34extern int base64_encode_len(int decodedLen);
35
36/// Base-64 encode a string into a given buffer.
37/// Will not terminate the resulting string.
38/// \return the number of bytes filled in result.
39extern int base64_encode(char *result, int result_max_size, const char *data, int data_size);
40
41/// Base-64 encode a string into a given buffer.
42/// Will terminate the resulting string.
43/// \return the number of bytes filled in result. Including the terminator.
44extern int base64_encode_str(char *result, int result_max_size, const char *data, int data_size);
45
46// Old encoder. Now a wrapper for the new. Takes a binary array of known length.
47// Output is presented in a static buffer which will only remain valid until next call.
48// Ensures a nul-terminated result. Will always return non-NULL.
49extern const char *base64_encode_bin(const char *data, int len);
50
51// Old encoder. Now a wrapper for the new.
52// Output is presented in a static buffer which will only remain valid until next call.
53// Ensures a nul-terminated result. Will always return non-NULL.
54extern const char *old_base64_encode(const char *decoded);
55
56#ifdef __cplusplus
57}
58#endif
59#endif /* _SQUID_BASE64_H */
60
Note: See TracBrowser for help on using the repository browser.