]> pd.if.org Git - zpackage/blobdiff - zpm-init.c
fix compile process for elf programs
[zpackage] / zpm-init.c
index ad92bc6064857c39f6ad8fed0d9f4d4e90f37469..9a0f839f0ee11c8703e623805d754ff858d71a68 100644 (file)
@@ -4,12 +4,23 @@
 
 int main(int ac, char **av){
        struct zpm pkg;
+       int rv;
+       char *path;
 
-       if (ac < 2) {
-               fprintf(stderr, "usage: path\n");
+       path = getenv("ZPMDB");
+
+       if (ac > 1) {
+               path = av[1];
+       }
+
+       if (!path) {
+               fprintf(stderr, "usage: zpm-init [path]\n");
                return 1;
        }
-       zpm_open(&pkg, av[1]);
-       zpm_close(&pkg);
-       return 0;
+       rv = zpm_init(&pkg, path);
+       if (rv) {
+               zpm_close(&pkg);
+       }
+
+       return rv ? 0 : 1;
 }