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;
21 int check = 0, quiet = 0, checkfail = 0, verbose = 0;
22 char hash[ZPM_HASH_STRLEN+1];
23 char *pkgid = 0, *current = 0, *display = hash;
25 dbfile = getenv("ZPMDB");
27 dbfile = "/var/lib/zpm/local.db";
35 while ((opt = getopt(ac, av, "f:sScqev")) != -1) {
37 case 'f': dbfile = optarg; break;
38 case 's': set = 1; break;
39 case 'S': clear = 1; break;
40 case 'c': check = 1; break;
41 case 'q': quiet = 1; break;
42 case 'e': showcurrent = 1; break;
43 case 'v': verbose = 1; break;
53 fprintf(stderr, "must specify db\n");
57 if (zpm_open(&pkg, dbfile)) {
58 pkgid = zpm_findpkg(&pkg, av[argn], NULL);
62 if (check || showcurrent) {
63 current = zpm_db_string(&pkg, "select hash from packages_pkgid where pkgid = %Q", pkgid);
69 zpm_package_hash(&pkg, pkgid, hash);
70 checkfail = strcmp(current, hash);
73 zpm_package_sethash(&pkg, pkgid, hash);
75 zpm_package_sethash(&pkg, pkgid, NULL);
77 } else if (showcurrent) {
80 zpm_package_hash(&pkg, pkgid, hash);
84 if (display && !quiet) {
88 printf("%s\n", display);
93 return checkfail ? EXIT_FAILURE : 0;