diff options
author | Karel Klic <kklic@redhat.com> | 2011-06-13 16:46:42 +0200 |
---|---|---|
committer | Karel Klic <kklic@redhat.com> | 2011-06-13 16:46:42 +0200 |
commit | 8edc80c6a08ef30d02cad35b736c0c7dcb62a7f3 (patch) | |
tree | b747ef4d0e24ad4cf2980f0681a93408011dbcd6 /libreport/src/lib/binhex.c | |
parent | 6dcdb4a5cb3ed68eb7d72cc65e58055d1e4f7c65 (diff) | |
parent | 16f9e8da051b87164b77bf9a42a61ae9a97fb5fd (diff) | |
download | abrt-8edc80c6a08ef30d02cad35b736c0c7dcb62a7f3.tar.gz abrt-8edc80c6a08ef30d02cad35b736c0c7dcb62a7f3.tar.xz abrt-8edc80c6a08ef30d02cad35b736c0c7dcb62a7f3.zip |
Merge branch 'master' of ssh://git.fedorahosted.org/git/abrt
Diffstat (limited to 'libreport/src/lib/binhex.c')
-rw-r--r-- | libreport/src/lib/binhex.c | 74 |
1 files changed, 0 insertions, 74 deletions
diff --git a/libreport/src/lib/binhex.c b/libreport/src/lib/binhex.c deleted file mode 100644 index 238fda0c..00000000 --- a/libreport/src/lib/binhex.c +++ /dev/null @@ -1,74 +0,0 @@ -/* - Copyright (C) 2010 ABRT team - Copyright (C) 2010 RedHat Inc - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License version 2 - as published by the Free Software Foundation. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ -#include "libreport.h" - -static const char hexdigits_locase[] = "0123456789abcdef"; - -/* Emit a string of hex representation of bytes */ -char *bin2hex(char *dst, const char *str, int count) -{ - while (count) { - unsigned char c = *str++; - /* put lowercase hex digits */ - *dst++ = hexdigits_locase[c >> 4]; - *dst++ = hexdigits_locase[c & 0xf]; - count--; - } - return dst; -} - -/* Convert "xxxxxxxx" hex string to binary, no more than COUNT bytes */ -char *hex2bin(char *dst, const char *str, int count) -{ - /* Parts commented out with // allow parsing - * of strings like "xx:x:x:xx:xx:xx:xxxxxx" - * (IPv6, ethernet addresses and the like). - */ - errno = EINVAL; - while (*str && count) { - uint8_t val; - uint8_t c; - - c = *str++; - if (isdigit(c)) - val = c - '0'; - else if ((c|0x20) >= 'a' && (c|0x20) <= 'f') - val = (c|0x20) - ('a' - 10); - else - return NULL; - val <<= 4; - c = *str; - if (isdigit(c)) - val |= c - '0'; - else if ((c|0x20) >= 'a' && (c|0x20) <= 'f') - val |= (c|0x20) - ('a' - 10); - //else if (c == ':' || c == '\0') - // val >>= 4; - else - return NULL; - - *dst++ = val; - //if (c != '\0') - str++; - //if (*str == ':') - // str++; - count--; - } - errno = (*str ? ERANGE : 0); - return dst; -} |