1 #define _POSIX_C_SOURCE 2
12 fprintf(stderr, "zpm-findpkg [-I] [-s <status> ...] [-S <status>] [package]\n");
15 int main(int ac, char **av){
20 int set = 0, clear = 0, showcurrent = 0;
24 dbfile = getenv("ZPMDB");
26 dbfile = "/var/lib/zpm/local.db";
34 while ((opt = getopt(ac, av, "f:sScqe")) != -1) {
36 case 'f': dbfile = optarg; break;
37 case 's': set = 1; break;
38 case 'S': clear = 1; break;
39 case 'c': check = 1; break;
40 case 'q': quiet = 1; break;
41 case 'e': showcurrent = 1; break;
51 fprintf(stderr, "must specify db\n");
55 char *pkgid = av[argn];
56 char hash[ZPM_HASH_STRLEN+1];
57 char *current = 0, *display = hash;
60 if (zpm_open(&pkg, dbfile)) {
61 if (check || showcurrent) {
62 current = zpm_db_string(&pkg, "select hash from packages_pkgid where pkgid = %Q", pkgid);
68 zpm_package_hash(&pkg, pkgid, hash);
69 checkfail = strcmp(current, hash);
72 zpm_package_sethash(&pkg, pkgid, hash);
74 zpm_package_sethash(&pkg, pkgid, NULL);
76 } else if (showcurrent) {
79 zpm_package_hash(&pkg, pkgid, hash);
83 if (display && !quiet) {
84 printf("%s\n", display);
89 return checkfail ? EXIT_FAILURE : 0;