]> git.draconx.ca Git - upkg.git/blobdiff - src/upkg.c
package: Allow opening by filename in addition to package name.
[upkg.git] / src / upkg.c
index 0388e29f317be8390b821595256206835a0725cb..b3e27a33e719f5227ba13f4f5d861222ba177a28 100644 (file)
@@ -28,6 +28,7 @@
 #include <uobject/exportable.h>
 #include <uobject/loadable.h>
 #include <uobject/module.h>
+#include <uobject/package.h>
 
 enum {
        MODE_INFO,
@@ -53,6 +54,7 @@ void print_version(void)
        printf("%s\n", PACKAGE_STRING);
        puts("\
 Copyright (C) 2009 Nick Bowler.\n\
+License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.\n\
 This is free software: you are free to change and redistribute it.\n\
 There is NO WARRANTY, to the extent permitted by law."
        );
@@ -284,7 +286,7 @@ int package_export(struct upkg *pkg)
 
 int main(int argc, char **argv)
 {
-       struct upkg *pkg;
+       UPkg *upkg;
        unsigned mode = MODE_INFO;
        int opt, rc = EXIT_FAILURE;
 
@@ -321,22 +323,22 @@ int main(int argc, char **argv)
        if (u_object_module_init() != 0)
                return EXIT_FAILURE;
 
-       pkg = upkg_fopen(argv[optind]);
-       if (!pkg) {
+       upkg = U_PKG(u_pkg_new_by_file(argv[optind]));
+       if (!upkg) {
                fprintf(stderr, "failed to open package!\n");
                return EXIT_FAILURE;
        }
 
        switch (mode) {
        case MODE_INFO:
-               rc = package_info(pkg);
+               rc = package_info(upkg->pkg);
                break;
        case MODE_EXPORT:
-               rc = package_export(pkg);
+               rc = package_export(upkg->pkg);
                break;
        }
 
-       upkg_close(pkg);
+       g_object_unref(upkg);
        u_object_module_exit();
        return rc;
 }