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