]> pd.if.org Git - zpackage/blob - zpm-addfile.c
fd8d67b4c50231331d6e721f301fa26b5216e6ca
[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         /* this is really just read env */
16         zpm_readopts(&pkg, ac, av);
17
18         if (zpm_open(&pkg, av[1])) {
19                 zpm_begin(&pkg);
20                 for (i=2; i<ac; i++) {
21                         if (zpm_import(&pkg, av[2], 0, hash)) {
22                                 fprintf(stdout, "%s\n", hash);
23         //                      zpm_addtopackage(&pkg, hash, 0);
24                                 //fprintf(stdout, "%s %s\n", hash, av[2]);
25                         } else {
26                                 zpm_rollback(&pkg);
27                                 zpm_close(&pkg);
28                                 exit(1);
29                         }
30                 }
31         } else {
32                 fprintf(stderr, "failed to open database %s\n", av[1]);
33                 exit(EXIT_FAILURE);
34         }
35
36         zpm_commit(&pkg);
37         zpm_close(&pkg);
38         return 0;
39 }