diff options
| author | Michael Brown | 2009-02-13 15:54:13 +0100 |
|---|---|---|
| committer | Michael Brown | 2009-02-13 15:54:13 +0100 |
| commit | d900ae05d7eb66dd85ea21598b646d51ca56474a (patch) | |
| tree | bb32d5df8acd1eb9d5fee6b81aa1a522e6727bb0 /src/include | |
| parent | [settings] Handle errors in fetchf_uristring() (diff) | |
| download | ipxe-d900ae05d7eb66dd85ea21598b646d51ca56474a.tar.gz ipxe-d900ae05d7eb66dd85ea21598b646d51ca56474a.tar.xz ipxe-d900ae05d7eb66dd85ea21598b646d51ca56474a.zip | |
[base64] Add base64 encoding functions
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/gpxe/base64.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/include/gpxe/base64.h b/src/include/gpxe/base64.h new file mode 100644 index 000000000..3321971a1 --- /dev/null +++ b/src/include/gpxe/base64.h @@ -0,0 +1,24 @@ +#ifndef _GPXE_BASE64_H +#define _GPXE_BASE64_H + +/** @file + * + * Base64 encoding + * + */ + +#include <stdint.h> + +/** + * Calculate length of base64-encoded string + * + * @v raw_len Raw string length (excluding NUL) + * @ret encoded_len Encoded string length (excluding NUL) + */ +static inline size_t base64_encoded_len ( size_t raw_len ) { + return ( ( ( raw_len + 3 - 1 ) / 3 ) * 4 ); +} + +extern void base64_encode ( const char *raw, char *encoded ); + +#endif /* _GPXE_BASE64_H */ |
