int opt, argn;
struct zpm pkg;
char *dbfile;
+ int fail = 0;
int set = 0, clear = 0, showcurrent = 0;
int check = 0, quiet = 0, checkfail = 0, verbose = 0;
- char hash[ZPM_HASH_STRLEN+1];
+ char hash[ZPM_HASH_STRLEN+1] = { 0 };
char *pkgid = 0, *current = 0, *display = hash;
dbfile = getenv("ZPMDB");
exit(EXIT_FAILURE);
}
if (check || showcurrent) {
- current = zpm_db_string(&pkg, "select hash from packages_pkgid where pkgid = %Q", pkgid);
+ current = zpm_package_gethash(&pkg, pkgid, 0);
}
if (check) {
- checkfail = 1;
- if (current) {
- zpm_package_hash(&pkg, pkgid, hash);
- checkfail = strcmp(current, hash);
- }
+ fail = zpm_package_checkhash(&pkg, pkgid, 0);
} else if (set) {
- zpm_package_sethash(&pkg, pkgid, hash);
+ fail = zpm_package_sethash(&pkg, pkgid, hash);
} else if (clear) {
- zpm_package_sethash(&pkg, pkgid, NULL);
- display = NULL;
+ fail = zpm_package_clearhash(&pkg, pkgid);
} else if (showcurrent) {
display = current;
} else {
- zpm_package_hash(&pkg, pkgid, hash);
+ fail = zpm_package_hash(&pkg, pkgid, hash);
}
zpm_close(&pkg);
- if (display && !quiet) {
+ if (display && !quiet && !fail) {
if (verbose) {
printf("%s ", pkgid);
}