5 static int prow(void *f, int ncols, char **vals, char **cols) {
9 cols = 0; /* suppress warning */
10 for (i=3;i<ncols;i++) {
11 if (i>3) fprintf(out, "\t");
12 fprintf(out, "%s", vals[i]);
18 int main(int ac, char **av){
20 char *select = "select package, version, release, package||'-'||version||'-'||release as pkgid from packages";
21 char *group = "group by package having max( version||'-'||release collate vercmp) order by length(package), package, version||'-'||release collate vercmp";
23 // char *select = "select package, version, release, package||'-'||version||'-'||release as pkgid from packages";
24 // char *order = "order by package, version collate vercmp, cast(release as integer)";
28 fprintf(stderr, "usage: db path\n");
32 /* this is really just read env */
33 zpm_readopts(&pkg, ac, av);
35 /* given a package name, get the packages */
36 /* no package name, get all */
38 if (zpm_open(&pkg, av[1])) {
40 // char where[1024] = "";
42 /* TODO allow more args to nail down version and release */
44 sprintf(sql, "%s where package = '%s' %s;",
45 select, av[2], group);
47 sprintf(sql, "%s %s;", select, group);
50 /* install a collation function */
52 /* sqlite seems to need the columns in the result to
53 * do the sort right */
54 // zpm_exec(&pkg, "select package, version, release, package||'-'||version||'-'||release as pkgid from packages order by package, version collate vercmp, cast(release as integer)", prow, stdout, &errmsg);
55 // fprintf(stdout, "\n");
57 zpm_exec(&pkg, sql, prow, stdout, &errmsg);