[settings] Add "base64" setting type

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2015-04-24 13:54:40 +01:00
parent 1205721cbd
commit dc15a5a779
3 changed files with 57 additions and 0 deletions

View File

@@ -39,6 +39,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#include <ipxe/uuid.h>
#include <ipxe/uri.h>
#include <ipxe/base16.h>
#include <ipxe/base64.h>
#include <ipxe/pci.h>
#include <ipxe/init.h>
#include <ipxe/version.h>
@@ -2120,6 +2121,46 @@ const struct setting_type setting_type_hexraw __setting_type = {
.format = format_hex_raw_setting,
};
/**
* Parse Base64-encoded setting value
*
* @v type Setting type
* @v value Formatted setting value
* @v buf Buffer to contain raw value
* @v len Length of buffer
* @v size Integer size, in bytes
* @ret len Length of raw value, or negative error
*/
static int parse_base64_setting ( const struct setting_type *type __unused,
const char *value, void *buf, size_t len ) {
return base64_decode ( value, buf, len );
}
/**
* Format Base64-encoded setting value
*
* @v type Setting type
* @v raw Raw setting value
* @v raw_len Length of raw setting value
* @v buf Buffer to contain formatted value
* @v len Length of buffer
* @ret len Length of formatted value, or negative error
*/
static int format_base64_setting ( const struct setting_type *type __unused,
const void *raw, size_t raw_len,
char *buf, size_t len ) {
return base64_encode ( raw, raw_len, buf, len );
}
/** A Base64-encoded setting */
const struct setting_type setting_type_base64 __setting_type = {
.name = "base64",
.parse = parse_base64_setting,
.format = format_base64_setting,
};
/**
* Format UUID setting value
*