]> pd.if.org Git - zpackage/blob - zpm-addfile.c
add where clause argument to findpkg
[zpackage] / zpm-addfile.c
1 #include <stdlib.h>
2 #include <stdio.h>
3 #include "zpm.h"
4
5 int main(int ac, char **av){
6         struct zpm pkg;
7         char hash[65];
8         int i;
9
10         if (ac < 3) {
11                 fprintf(stderr, "usage: db path\n");
12                 return 1;
13         }
14
15         if (zpm_open(&pkg, av[1])) {
16                 zpm_begin(&pkg);
17                 for (i=2; i<ac; i++) {
18                         if (zpm_import(&pkg, av[i], 0, hash)) {
19                                 fprintf(stdout, "%s\n", hash);
20         //                      zpm_addtopackage(&pkg, hash, 0);
21                                 //fprintf(stdout, "%s %s\n", hash, av[2]);
22                         } else {
23                                 zpm_rollback(&pkg);
24                                 zpm_close(&pkg);
25                                 exit(1);
26                         }
27                 }
28         } else {
29                 fprintf(stderr, "failed to open database %s\n", av[1]);
30                 exit(EXIT_FAILURE);
31         }
32
33         zpm_commit(&pkg);
34         zpm_close(&pkg);
35         return 0;
36 }