if (!zpm || zpm->error || !callback) return 0;
s = sqlite3_str_new(zpm->db);
- sqlite3_str_appendall(s, "select * from packagefiles_pkgid where ");
+ sqlite3_str_appendall(s, "select * from packagefiles_status where ");
if (where) {
sqlite3_str_appendf(s, "%s", where);
sqlite3_str_appendf(s, " and printf('%%s-%%s-%%s', package, version, release) = %Q", pkgid);
}
-
sql = sqlite3_str_value(s);
if (!sql) {
sqlite3_str_finish(s);
char *program;
char *pkgid;
char *nullstr;
+ char *filter;
int errcontinue;
int errors;
int (*callback)(void*,int,char**,char**);
/* suppress unused warnings */
- if (ncols < 4) {
+ if (ncols < 6) {
fprintf(stderr, "can't find path names\n");
return 1;
}
// printf("path cols %d %p %p\n", ncols, vals, cols);
- fprintf(stdout, "%s\n", vals[3]);
+ fprintf(stdout, "%s\n", vals[5]);
#if 0
cols = 0;
f = 0;
return 0;
}
-void parse_package(char *pstr, char *name, char *ver, int *rel) {
- if (name) *name = 0;
- if (ver) *ver = 0;
- if (rel) *rel = -1;
-
- /* string - ver - rel */
- /* rel is all digits */
- /* possible forms:
- * ^(.+)-([0-9][^-]*)-([\d+])$
- * ^(.+)-([0-9][^-]*)$
- * ^(.+)$
- * The main problem in parsing is that the package name itself
- * can contain a '-', so you can't just split on '-'
- * Also, the version can be just digits.
- */
-
- /* everything up to the first '-' is in the name */
- while (*pstr) {
- if (*pstr == '-' && isdigit(*(pstr+1))) {
- break;
- }
- if (name) {
- *name++ = *pstr;
- }
- pstr++;
- }
- if (name) *name = 0;
- if (*pstr == '-') {
- pstr++;
- }
- while (*pstr && *pstr != '-') {
- if (ver) {
- *ver++ = *pstr;
- }
- pstr++;
- }
- if (ver) *ver = 0;
- if (*pstr == '-') {
- pstr++;
- }
- if (rel && *pstr) {
- *rel = atoi(pstr);
- }
-}
-
#ifdef PATH_MAX
#define PATHLEN PATH_MAX
#else
int main(int ac, char **av){
struct zpm pkg;
- char *s;
int opt;
- struct config conf = { "/var/lib/zpm/local.db", 0, 0, 0, "", 0, 0, printpaths
- };
+ struct config conf = { 0 };
+
+ conf.dbfile = getenv("ZPMDB");
+ conf.callback = printpaths;
+ conf.nullstr = "";
- if ((s = getenv("ZPMDB"))) {
- /* TODO does this need to be copied ? */
- conf.dbfile = s;
+ if (!conf.dbfile) {
+ conf.dbfile = "/var/lib/zpm/local.db";
}
/*
* otherwise'
*/
- while ((opt = getopt(ac, av, "f:c:n:C")) != -1) {
+ while ((opt = getopt(ac, av, "f:c:n:Cp:F:")) != -1) {
switch (opt) {
case 'f': conf.dbfile = optarg;
break;
case 'n':
conf.nullstr = optarg;
break;
+ case 'p':
+ conf.pkgid = optarg;
+ break;
+ case 'F': conf.filter = optarg;
+ break;
default:
usage();
exit(EXIT_FAILURE);
}
char *errmsg = 0;
- if (argn < ac) {
- conf.pkgid = av[argn];
- // fprintf(stderr, "set pkgid to %s\n", conf.pkgid);
- argn++;
- } else {
- fprintf(stderr, "must specify pkgid\n");
- usage();
- exit(EXIT_FAILURE);
- }
-
/* TODO lookup pkgid via zpm-findpkg equivalent */
if (argn < ac) {
/* TODO set conf.args to remaining arguments */
}
- /* install a collation function */
- // zpm_addvercmp(&pkg);
-
- if (!zpm_foreach_path(&pkg, conf.pkgid, 0, conf.callback, &conf, &errmsg)) {
+ if (!zpm_foreach_path(&pkg, conf.pkgid, conf.filter, conf.callback, &conf, &errmsg)) {
if (errmsg) {
fprintf(stderr, "database error: %s\n", errmsg);
exit(EXIT_FAILURE);