diff options
author | Timo Teras <timo.teras@iki.fi> | 2009-07-14 19:14:05 +0300 |
---|---|---|
committer | Timo Teras <timo.teras@iki.fi> | 2009-07-14 19:14:05 +0300 |
commit | 981bc118f8bdf1df6c23c096a52c890a87ee3e5e (patch) | |
tree | 73063efdb73ce4ee3511cc827181ff9c6b28427e /src/io.c | |
parent | e9eaedff5071b94d166973f13df90e47ff4936fe (diff) | |
download | aports-981bc118f8bdf1df6c23c096a52c890a87ee3e5e.tar.bz2 aports-981bc118f8bdf1df6c23c096a52c890a87ee3e5e.tar.xz |
db: live with sha1 and md5
this also convers scripts file to a tar archive.
Diffstat (limited to 'src/io.c')
-rw-r--r-- | src/io.c | 14 |
1 files changed, 9 insertions, 5 deletions
@@ -440,11 +440,10 @@ err_fd: return APK_BLOB_NULL; } -int apk_file_get_info(const char *filename, struct apk_file_info *fi) +int apk_file_get_info(const char *filename, int checksum, struct apk_file_info *fi) { struct stat st; struct apk_bstream *bs; - csum_ctx_t ctx; if (stat(filename, &st) != 0) return -1; @@ -458,14 +457,19 @@ int apk_file_get_info(const char *filename, struct apk_file_info *fi) .device = st.st_dev, }; + if (checksum == APK_CHECKSUM_NONE) + return 0; + bs = apk_bstream_from_file(filename); if (bs != NULL) { + EVP_MD_CTX mdctx; apk_blob_t blob; - csum_init(&ctx); + EVP_DigestInit(&mdctx, apk_get_digest(checksum)); while (!APK_BLOB_IS_NULL(blob = bs->read(bs, APK_BLOB_NULL))) - csum_process(&ctx, (void*) blob.ptr, blob.len); - csum_finish(&ctx, fi->csum); + EVP_DigestUpdate(&mdctx, (void*) blob.ptr, blob.len); + fi->csum.type = EVP_MD_CTX_size(&mdctx); + EVP_DigestFinal(&mdctx, fi->csum.data, NULL); bs->close(bs, NULL); } |