]> pd.if.org Git - zpackage/blob - lib/foreach_path.c
fix table resize bug in jsw_hlib
[zpackage] / lib / foreach_path.c
1 #define _POSIX_C_SOURCE 2
2 #include <stdlib.h>
3 #include <unistd.h>
4 #include <sys/types.h>
5 #include <sys/wait.h>
6
7 #include <string.h>
8
9 #include "sqlite3.h"
10 #include "zpm.h"
11
12 int zpm_foreach_path(struct zpm *zpm, char *pkgid, 
13 int (*callback)(void *f, int ncols, char **vals, char **cols),
14 void *data, char **errmsg) {
15
16         char *files = "select * from packagefiles where"
17                 " printf('%%s-%%s-%%s', package, version, release) = %Q"
18                 " order by path"
19                 ;
20
21         char *sql;
22
23         sql = sqlite3_mprintf(files, pkgid);
24         if (!sql) {
25                 return 0;
26                 zpm->error = 1;
27         }
28
29         zpm_exec(zpm, sql, callback, data, errmsg);
30         if (errmsg) {
31                 zpm->error = 2;
32                 return 0;
33         }
34
35         return 1;
36 }