[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r17706: {tor} Expose hex_decode_digit from util.c (tor/trunk/src/common)
Author: nickm
Date: 2008-12-19 13:51:52 -0500 (Fri, 19 Dec 2008)
New Revision: 17706
Modified:
tor/trunk/src/common/util.c
tor/trunk/src/common/util.h
Log:
Expose hex_decode_digit from util.c
Modified: tor/trunk/src/common/util.c
===================================================================
--- tor/trunk/src/common/util.c 2008-12-19 18:51:49 UTC (rev 17705)
+++ tor/trunk/src/common/util.c 2008-12-19 18:51:52 UTC (rev 17706)
@@ -758,7 +758,7 @@
/** Helper: given a hex digit, return its value, or -1 if it isn't hex. */
static INLINE int
-hex_decode_digit(char c)
+_hex_decode_digit(char c)
{
switch (c) {
case '0': return 0;
@@ -782,6 +782,13 @@
}
}
+/** Helper: given a hex digit, return its value, or -1 if it isn't hex. */
+int
+hex_decode_digit(char c)
+{
+ return _hex_decode_digit(c);
+}
+
/** Given a hexadecimal string of <b>srclen</b> bytes in <b>src</b>, decode it
* and store the result in the <b>destlen</b>-byte buffer at <b>dest</b>.
* Return 0 on success, -1 on failure. */
@@ -797,8 +804,8 @@
return -1;
end = src+srclen;
while (src<end) {
- v1 = hex_decode_digit(*src);
- v2 = hex_decode_digit(*(src+1));
+ v1 = _hex_decode_digit(*src);
+ v2 = _hex_decode_digit(*(src+1));
if (v1<0||v2<0)
return -1;
*(uint8_t*)dest = (v1<<4)|v2;
Modified: tor/trunk/src/common/util.h
===================================================================
--- tor/trunk/src/common/util.h 2008-12-19 18:51:49 UTC (rev 17705)
+++ tor/trunk/src/common/util.h 2008-12-19 18:51:52 UTC (rev 17706)
@@ -198,6 +198,7 @@
void wrap_string(struct smartlist_t *out, const char *string, size_t width,
const char *prefix0, const char *prefixRest);
+int hex_decode_digit(char c);
void base16_encode(char *dest, size_t destlen, const char *src, size_t srclen);
int base16_decode(char *dest, size_t destlen, const char *src, size_t srclen);