]>
git.ipfire.org Git - thirdparty/squid.git/blob - include/base64.h
1 #ifndef _SQUID_BASE64_H
2 #define _SQUID_BASE64_H
10 /// Calculate the decoded length of a given nul-terminated encoded string.
11 /// NULL pointer and empty strings are accepted, result is zero.
12 /// Any return value <= zero means no decoded result can be produced.
13 extern int base64_decode_len(const char *encodedData
);
15 /// Decode a base-64 encoded blob into a provided buffer.
16 /// Will not terminate the resulting string.
17 /// In-place decoding overlap is supported if result is equal or earlier that the source pointer.
19 /// \return number of bytes filled in result.
20 extern int base64_decode(char *result
, unsigned int result_max_size
, const char *encoded
);
25 /// Calculate the buffer size required to hold the encoded form of
26 /// a string of length 'decodedLen' including all terminator bytes.
27 extern int base64_encode_len(int decodedLen
);
29 /// Base-64 encode a string into a given buffer.
30 /// Will not terminate the resulting string.
31 /// \return the number of bytes filled in result.
32 extern int base64_encode(char *result
, int result_max_size
, const char *data
, int data_size
);
34 /// Base-64 encode a string into a given buffer.
35 /// Will terminate the resulting string.
36 /// \return the number of bytes filled in result. Including the terminator.
37 extern int base64_encode_str(char *result
, int result_max_size
, const char *data
, int data_size
);
39 // Old encoder. Now a wrapper for the new. Takes a binary array of known length.
40 // Output is presented in a static buffer which will only remain valid until next call.
41 // Ensures a nul-terminated result. Will always return non-NULL.
42 extern const char *base64_encode_bin(const char *data
, int len
);
44 // Old encoder. Now a wrapper for the new.
45 // Output is presented in a static buffer which will only remain valid until next call.
46 // Ensures a nul-terminated result. Will always return non-NULL.
47 extern const char *old_base64_encode(const char *decoded
);
53 #endif /* _SQUID_BASE64_H */