diff options
author | Daniel Stenberg <daniel@haxx.se> | 2016-11-02 00:08:36 +0100 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2016-11-02 00:31:49 +0100 |
commit | 6b52b7eb2beedf82482209db2192e3620ea32bca (patch) | |
tree | 89b02ded595497624eb84499b4f6778afccb3a4a | |
parent | f9e51fb55d4b43e9b77324190ade1d99aad7d3ba (diff) | |
download | curl-6b52b7eb2beedf82482209db2192e3620ea32bca.tar.gz |
metalink: simplify the hex parsing function
... and now it avoids using the libcurl toupper() function
-rw-r--r-- | src/tool_metalink.c | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/src/tool_metalink.c b/src/tool_metalink.c index 985e7c323..f4173562f 100644 --- a/src/tool_metalink.c +++ b/src/tool_metalink.c @@ -24,6 +24,7 @@ #ifdef USE_METALINK #include <sys/stat.h> +#include <stdlib.h> #ifdef HAVE_FCNTL_H # include <fcntl.h> @@ -92,8 +93,6 @@ struct win32_crypto_hash { # error "Can't compile METALINK support without a crypto library." #endif -#include "strcase.h" - #define ENABLE_CURLX_PRINTF /* use our own printf() functions */ #include "curlx.h" @@ -563,18 +562,13 @@ int Curl_digest_final(digest_context *context, unsigned char *result) static unsigned char hex_to_uint(const char *s) { - int v[2]; - int i; - for(i = 0; i < 2; ++i) { - v[i] = Curl_raw_toupper(s[i]); - if('0' <= v[i] && v[i] <= '9') { - v[i] -= '0'; - } - else if('A' <= v[i] && v[i] <= 'Z') { - v[i] -= 'A'-10; - } - } - return (unsigned char)((v[0] << 4) | v[1]); + char buf[3]; + unsigned long val; + buf[0] = s[0]; + buf[1] = s[1]; + buf[2] = 0; + val = strtoul(buf, NULL, 16); + return (unsigned char)(val&0xff); } /* |