dovecot-2.2: lib: Added numpack_decode32()

dovecot at dovecot.org dovecot at dovecot.org
Sat Apr 25 08:24:39 UTC 2015


details:   http://hg.dovecot.org/dovecot-2.2/rev/1c275f718758
changeset: 18480:1c275f718758
user:      Timo Sirainen <tss at iki.fi>
date:      Sat Apr 25 11:22:39 2015 +0300
description:
lib: Added numpack_decode32()

diffstat:

 src/lib/numpack.c |  13 +++++++++++++
 src/lib/numpack.h |   1 +
 2 files changed, 14 insertions(+), 0 deletions(-)

diffs (30 lines):

diff -r 008632bdfd2c -r 1c275f718758 src/lib/numpack.c
--- a/src/lib/numpack.c	Fri Apr 24 16:03:51 2015 +0300
+++ b/src/lib/numpack.c	Sat Apr 25 11:22:39 2015 +0300
@@ -41,3 +41,16 @@
 	*num_r = value;
 	return 0;
 }
+
+int numpack_decode32(const uint8_t **p, const uint8_t *end, uint32_t *num_r)
+{
+	uint64_t num;
+
+	if (numpack_decode(p, end, &num) < 0)
+		return -1;
+	if (num > 4294967295U)
+		return -1;
+
+	*num_r = (uint32_t)num;
+	return 0;
+}
diff -r 008632bdfd2c -r 1c275f718758 src/lib/numpack.h
--- a/src/lib/numpack.h	Fri Apr 24 16:03:51 2015 +0300
+++ b/src/lib/numpack.h	Sat Apr 25 11:22:39 2015 +0300
@@ -6,5 +6,6 @@
 
 void numpack_encode(buffer_t *buf, uint64_t num);
 int numpack_decode(const uint8_t **p, const uint8_t *end, uint64_t *num_r);
+int numpack_decode32(const uint8_t **p, const uint8_t *end, uint32_t *num_r);
 
 #endif


More information about the dovecot-cvs mailing list