dovecot-2.2: fs-dict: Implemented hex-encoding for values.
dovecot at dovecot.org
dovecot at dovecot.org
Mon Oct 12 14:14:21 UTC 2015
details: http://hg.dovecot.org/dovecot-2.2/rev/719e7f8fd70b
changeset: 19295:719e7f8fd70b
user: Timo Sirainen <tss at iki.fi>
date: Mon Oct 12 17:12:17 2015 +0300
description:
fs-dict: Implemented hex-encoding for values.
diffstat:
src/lib-fs/fs-dict.c | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)
diffs (42 lines):
diff -r d96595e2363b -r 719e7f8fd70b src/lib-fs/fs-dict.c
--- a/src/lib-fs/fs-dict.c Mon Oct 12 15:57:42 2015 +0300
+++ b/src/lib-fs/fs-dict.c Mon Oct 12 17:12:17 2015 +0300
@@ -4,6 +4,7 @@
#include "buffer.h"
#include "str.h"
#include "guid.h"
+#include "hex-binary.h"
#include "base64.h"
#include "istream.h"
#include "ostream.h"
@@ -12,6 +13,7 @@
enum fs_dict_value_encoding {
FS_DICT_VALUE_ENCODING_RAW,
+ FS_DICT_VALUE_ENCODING_HEX,
FS_DICT_VALUE_ENCODING_BASE64
};
@@ -58,6 +60,8 @@
encoding_str = t_strdup_until(args, p++);
if (strcmp(encoding_str, "raw") == 0)
fs->encoding = FS_DICT_VALUE_ENCODING_RAW;
+ else if (strcmp(encoding_str, "hex") == 0)
+ fs->encoding = FS_DICT_VALUE_ENCODING_HEX;
else if (strcmp(encoding_str, "base64") == 0)
fs->encoding = FS_DICT_VALUE_ENCODING_BASE64;
else {
@@ -196,6 +200,13 @@
case FS_DICT_VALUE_ENCODING_RAW:
dict_set(trans, file->key, str_c(file->write_buffer));
break;
+ case FS_DICT_VALUE_ENCODING_HEX: {
+ string_t *hex = t_str_new(file->write_buffer->used * 2 + 1);
+ binary_to_hex_append(hex, file->write_buffer->data,
+ file->write_buffer->used);
+ dict_set(trans, file->key, str_c(hex));
+ break;
+ }
case FS_DICT_VALUE_ENCODING_BASE64: {
const unsigned int base64_size =
MAX_BASE64_ENCODED_SIZE(file->write_buffer->used);
More information about the dovecot-cvs
mailing list