]> pd.if.org Git - zpackage/blobdiff - lib/zpm.c
remove xcbc
[zpackage] / lib / zpm.c
index 3cc7632d76280dacb9e4be3957a1794415a7d4a5..501cc98d9a01e848f4ed53afd7109e2bdc3174cd 100644 (file)
--- a/lib/zpm.c
+++ b/lib/zpm.c
@@ -53,6 +53,13 @@ int zpm_rollback(struct zpm *z) {
        return 1;
 }
 
+int zpm_readonly(struct zpm *z) {
+       if (z->db && sqlite3_db_readonly(z->db, "main")) {
+               return 1;
+       }
+       return 0;
+}
+
 int zpm_db_set_pragma(struct zpm *db, int pragma, int value) {
        int rc;
        char *sql;
@@ -581,11 +588,9 @@ int zpm_import(struct zpm *zpm, char *path, uint32_t flags, char *hash) {
        int fd;
        void *content = 0;
        struct stat sbuf;
-       unsigned char tmp[32];
-       struct sha256_state md;
        sqlite3_stmt *ifile = 0;
        int haverow = 0,havedata = 0;
-       int j,rc,type;
+       int rc,type;
        char hashbuf[65];
 
        /* xz compress it */
@@ -642,13 +647,7 @@ int zpm_import(struct zpm *zpm, char *path, uint32_t flags, char *hash) {
                return 0;
        }
 
-       /* get hash */
-       sha256_init(&md);
-       sha256_process(&md, content, sbuf.st_size);
-       sha256_done(&md, tmp);
-       for (j=0;j<32;j++) {
-               sprintf(hash+j*2, "%02x", (unsigned)tmp[j]);
-       }
+       zpm_hash_mem(content, sbuf.st_size, hash);
        hash[64] = 0;
 
        /* TODO check null */