13 * -t : use a temp file, then move into place, possible reverse the sense
16 * -m : mode (i.e. final mode)
18 * -l : log all actions
19 * -d : logging database file, if different
21 * check if file exists, if it does, and has the same hash, do
22 * nothing, unless -f is given
26 int main(int ac, char **av){
31 fprintf(stderr, "usage: db hash file\n");
34 zpm_open(&pkg, av[1]);
35 rv = zpm_extract(&pkg, av[2], av[3], 0600);
42 int main(int ac, char **av) {
57 fprintf(stderr, "usage: db hash file\n");
61 rc = sqlite3_open(av[1], &db);
63 SQLERROR(sqlite3_errmsg(db));
68 rc = sqlite3_prepare(db, "select size, content from files where hash = ?", -1, &ifile,0);
69 if (rc != SQLITE_OK) {
70 SQLERROR(sqlite3_errmsg(db));
78 sqlite3_bind_text(ifile, 1, hash, 64, SQLITE_STATIC);
80 rc = sqlite3_step(ifile);
82 if (rc == SQLITE_DONE) {
83 /* didn't find a row */
84 sqlite3_finalize(ifile);
86 fprintf(stderr, "no such hash\n");
89 /* either way we're done with this now */
91 if (rc != SQLITE_ROW) {
92 SQLERROR(sqlite3_errmsg(db));
93 sqlite3_finalize(ifile);
98 type = sqlite3_column_type(ifile, 0);
99 if (type == SQLITE_NULL) {
100 fprintf(stderr, "no file size\n");
101 sqlite3_finalize(ifile);
105 type = sqlite3_column_type(ifile, 1);
106 if (type == SQLITE_NULL) {
107 fprintf(stderr, "no file data\n");
108 sqlite3_finalize(ifile);
112 size = sqlite3_column_int64(ifile, 0);
113 xzdata = (void *)sqlite3_column_blob(ifile, 1);
114 blobsize = sqlite3_column_bytes(ifile, 1);
116 out = fopen(filename, "w");
118 fprintf(stderr, "can't open output file %s\n", filename);
119 sqlite3_finalize(ifile);
123 //fwrite(xzdata, blobsize, 1, stdout);
125 fprintf(stderr, "uncompressing %d bytes at %p, expect %lld\n", blobsize, xzdata, (long long int)size);
126 uncompresslzma(xzdata, blobsize, out);
129 sqlite3_finalize(ifile);