xzdata = (void *)sqlite3_column_blob(ifile, 1);
blobsize = sqlite3_column_bytes(ifile, 1);
- out = fopen(path, "w");
+ if (strcmp(path, "-")) {
+ out = fopen(path, "w");
+ } else {
+ out = stdout;
+ }
if (!out) {
fprintf(stderr, "can't open output file %s\n", path);
sqlite3_finalize(ifile);
sqlite3_close(db);
- return 5;
+ return 0;
}
//fwrite(xzdata, blobsize, 1, stdout);
sqlite3_finalize(ifile);
- return 0;
-
+ return 1;
}
/* flags 0, close mmap, flags 1, return mmap fd */
. tap.sh
-plan 4
+plan 5
PF=test.db
sha=$(zpm-hash test.foo2)
okstreq $hash $sha extracted hash matches
+sha=$(zpm-extract $PF $hash - | zpm-hash)
+okstreq $hash $sha stdout extract hash matches
+
finish
rm -f test.*
int main(int ac, char **av){
struct zpm pkg;
int mode = 0644;
+ int rv;
if (ac < 3) {
fprintf(stderr, "usage: db hash file\n");
return 1;
}
zpm_open(&pkg, av[1]);
- zpm_extract(&pkg, av[2], av[3], mode);
+ rv = zpm_extract(&pkg, av[2], av[3], mode);
zpm_close(&pkg);
+ return rv ? 0 : 1;
}
#else