13 int main(int ac, char **av){
18 fprintf(stderr, "usage: db hash file\n");
21 zpm_open(&pkg, av[1]);
22 zpm_extract(&pkg, av[2], av[3], mode);
27 int main(int ac, char **av) {
42 fprintf(stderr, "usage: db hash file\n");
46 rc = sqlite3_open(av[1], &db);
48 SQLERROR(sqlite3_errmsg(db));
53 rc = sqlite3_prepare(db, "select size, content from files where hash = ?", -1, &ifile,0);
54 if (rc != SQLITE_OK) {
55 SQLERROR(sqlite3_errmsg(db));
63 sqlite3_bind_text(ifile, 1, hash, 64, SQLITE_STATIC);
65 rc = sqlite3_step(ifile);
67 if (rc == SQLITE_DONE) {
68 /* didn't find a row */
69 sqlite3_finalize(ifile);
71 fprintf(stderr, "no such hash\n");
74 /* either way we're done with this now */
76 if (rc != SQLITE_ROW) {
77 SQLERROR(sqlite3_errmsg(db));
78 sqlite3_finalize(ifile);
83 type = sqlite3_column_type(ifile, 0);
84 if (type == SQLITE_NULL) {
85 fprintf(stderr, "no file size\n");
86 sqlite3_finalize(ifile);
90 type = sqlite3_column_type(ifile, 1);
91 if (type == SQLITE_NULL) {
92 fprintf(stderr, "no file data\n");
93 sqlite3_finalize(ifile);
97 size = sqlite3_column_int64(ifile, 0);
98 xzdata = (void *)sqlite3_column_blob(ifile, 1);
99 blobsize = sqlite3_column_bytes(ifile, 1);
101 out = fopen(filename, "w");
103 fprintf(stderr, "can't open output file %s\n", filename);
104 sqlite3_finalize(ifile);
108 //fwrite(xzdata, blobsize, 1, stdout);
110 fprintf(stderr, "uncompressing %d bytes at %p, expect %lld\n", blobsize, xzdata, (long long int)size);
111 uncompresslzma(xzdata, blobsize, out);
114 sqlite3_finalize(ifile);