summaryrefslogtreecommitdiff
path: root/src/repodata.c
diff options
context:
space:
mode:
authorMichael Schroeder <mls@suse.de>2011-03-03 16:43:40 +0100
committerMichael Schroeder <mls@suse.de>2011-03-03 16:43:40 +0100
commitf7dc6ef9777348a23f0f8d2795a508467e4f978d (patch)
tree8fb91179cc1dd4b0a887bdb63323ba9d0c638dbe /src/repodata.c
parent8d01524d480dccb7324bf525a3110840166dd010 (diff)
downloadlibsolv-f7dc6ef9777348a23f0f8d2795a508467e4f978d.tar.gz
libsolv-f7dc6ef9777348a23f0f8d2795a508467e4f978d.tar.bz2
libsolv-f7dc6ef9777348a23f0f8d2795a508467e4f978d.zip
- add pool_freetmpspace, pool_tmpappend, pool_bin2hex, sat_dupappend, sat_hex2bin, sat_bin2hex
Diffstat (limited to 'src/repodata.c')
-rw-r--r--src/repodata.c42
1 files changed, 3 insertions, 39 deletions
diff --git a/src/repodata.c b/src/repodata.c
index 958152d..bde6579 100644
--- a/src/repodata.c
+++ b/src/repodata.c
@@ -2102,31 +2102,6 @@ repodata_set_bin_checksum(Repodata *data, Id solvid, Id keyname, Id type,
data->attrdatalen += l;
}
-static int
-hexstr2bytes(unsigned char *buf, const char *str, int buflen)
-{
- int i;
- for (i = 0; i < buflen; i++)
- {
-#define c2h(c) (((c)>='0' && (c)<='9') ? ((c)-'0') \
- : ((c)>='a' && (c)<='f') ? ((c)-('a'-10)) \
- : ((c)>='A' && (c)<='F') ? ((c)-('A'-10)) \
- : -1)
- int v = c2h(*str);
- str++;
- if (v < 0)
- return 0;
- buf[i] = v;
- v = c2h(*str);
- str++;
- if (v < 0)
- return 0;
- buf[i] = (buf[i] << 4) | v;
-#undef c2h
- }
- return buflen;
-}
-
void
repodata_set_checksum(Repodata *data, Id solvid, Id keyname, Id type,
const char *str)
@@ -2136,7 +2111,7 @@ repodata_set_checksum(Repodata *data, Id solvid, Id keyname, Id type,
if (!(l = sat_chksum_len(type)))
return;
- if (hexstr2bytes(buf, str, l) != l)
+ if (l > sizeof(buf) || sat_hex2bin(&str, buf, l) != l)
return;
repodata_set_bin_checksum(data, solvid, keyname, type, buf);
}
@@ -2144,22 +2119,11 @@ repodata_set_checksum(Repodata *data, Id solvid, Id keyname, Id type,
const char *
repodata_chk2str(Repodata *data, Id type, const unsigned char *buf)
{
- int i, l;
- char *str, *s;
+ int l;
if (!(l = sat_chksum_len(type)))
return "";
- s = str = pool_alloctmpspace(data->repo->pool, 2 * l + 1);
- for (i = 0; i < l; i++)
- {
- unsigned char v = buf[i];
- unsigned char w = v >> 4;
- *s++ = w >= 10 ? w + ('a' - 10) : w + '0';
- w = v & 15;
- *s++ = w >= 10 ? w + ('a' - 10) : w + '0';
- }
- *s = 0;
- return str;
+ return pool_bin2hex(data->repo->pool, buf, l);
}
/* rpm filenames don't contain the epoch, so strip it */