X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=lib%2Fzpm.c;h=501cc98d9a01e848f4ed53afd7109e2bdc3174cd;hb=d6319f7ea0a76de91bc01d9734d235b494c40198;hp=3cc7632d76280dacb9e4be3957a1794415a7d4a5;hpb=1eaf53ac134e49a81c82739d4ee8c98bdd975948;p=zpackage diff --git a/lib/zpm.c b/lib/zpm.c index 3cc7632..501cc98 100644 --- 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 */