aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Shaw <[email protected]>2004-02-21 22:12:29 +0000
committerDavid Shaw <[email protected]>2004-02-21 22:12:29 +0000
commitfcc02ac22a1175b63436e2b6b1cc002c847b12f5 (patch)
treea294831c151010736c91322681e4a5b0227a108b
parent* main.h, misc.c (hextobyte): Removed. It's in libutil.a now. (diff)
downloadgnupg-fcc02ac22a1175b63436e2b6b1cc002c847b12f5.tar.gz
gnupg-fcc02ac22a1175b63436e2b6b1cc002c847b12f5.zip
* miscutil.c (hextobyte): Moved here from g10/misc.c so I can use it in
the keyserver helpers.
-rw-r--r--util/ChangeLog5
-rw-r--r--util/miscutil.c25
2 files changed, 30 insertions, 0 deletions
diff --git a/util/ChangeLog b/util/ChangeLog
index f7abb8e57..69a2f9610 100644
--- a/util/ChangeLog
+++ b/util/ChangeLog
@@ -1,3 +1,8 @@
+2004-02-21 David Shaw <[email protected]>
+
+ * miscutil.c (hextobyte): Moved here from g10/misc.c so I can use
+ it in the keyserver helpers.
+
2004-02-20 David Shaw <[email protected]>
* mkdtemp.c: New (moved from g10/), setenv.c: New, unsetenv.c:
diff --git a/util/miscutil.c b/util/miscutil.c
index 16c382d86..82fe6a935 100644
--- a/util/miscutil.c
+++ b/util/miscutil.c
@@ -430,3 +430,28 @@ match_multistr(const char *multistr,const char *match)
return 0;
}
+
+int
+hextobyte( const char *s )
+{
+ int c;
+
+ if( *s >= '0' && *s <= '9' )
+ c = 16 * (*s - '0');
+ else if( *s >= 'A' && *s <= 'F' )
+ c = 16 * (10 + *s - 'A');
+ else if( *s >= 'a' && *s <= 'f' )
+ c = 16 * (10 + *s - 'a');
+ else
+ return -1;
+ s++;
+ if( *s >= '0' && *s <= '9' )
+ c += *s - '0';
+ else if( *s >= 'A' && *s <= 'F' )
+ c += 10 + *s - 'A';
+ else if( *s >= 'a' && *s <= 'f' )
+ c += 10 + *s - 'a';
+ else
+ return -1;
+ return c;
+}