summaryrefslogtreecommitdiff
path: root/src/io.c
diff options
context:
space:
mode:
authorTimo Teras <timo.teras@iki.fi>2009-07-14 19:14:05 +0300
committerTimo Teras <timo.teras@iki.fi>2009-07-14 19:14:05 +0300
commit981bc118f8bdf1df6c23c096a52c890a87ee3e5e (patch)
tree73063efdb73ce4ee3511cc827181ff9c6b28427e /src/io.c
parente9eaedff5071b94d166973f13df90e47ff4936fe (diff)
downloadapk-tools-981bc118f8bdf1df6c23c096a52c890a87ee3e5e.tar.gz
apk-tools-981bc118f8bdf1df6c23c096a52c890a87ee3e5e.tar.bz2
apk-tools-981bc118f8bdf1df6c23c096a52c890a87ee3e5e.tar.xz
apk-tools-981bc118f8bdf1df6c23c096a52c890a87ee3e5e.zip
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.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/io.c b/src/io.c
index 26c0ebf..335b14d 100644
--- a/src/io.c
+++ b/src/io.c
@@ -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);
}