]> git.draconx.ca Git - upkg.git/blobdiff - src/upkg.c
uobject: Namespace changes.
[upkg.git] / src / upkg.c
index 82a673d100ccc6c522bd597713608ab40d3cd7fb..a8c7c7e560ca02bb61bd66d3e36e352d4bcd2b80 100644 (file)
 #include <glib-object.h>
 
 #include "upkg.h"
-#include "module.h"
-#include "uobject.h"
-#include "exportable.h"
+#include <uobject/uobject.h>
+#include <uobject/exportable.h>
+#include <uobject/loadable.h>
+#include <uobject/module.h>
 
 enum {
        MODE_INFO,
@@ -153,34 +154,38 @@ int package_info(struct upkg *pkg)
 
 static int export(struct upkg *pkg, GObject *obj, unsigned idx)
 {
-       struct upkg_file *f = upkg_export_open(pkg, idx);
        char name[256];
        FILE *of;
-       int rc = -1;
 
-       if (u_object_deserialize(obj, f) != 0) {
-               goto out;
+       if (u_object_deserialize(obj, pkg, idx) != 0) {
+               return -1;
        }
+
+       if (U_OBJECT_IS_LOADABLE(obj) && u_object_load(obj) != 0) {
+               return -1;
+       }
+
        u_object_export_name(obj, name, sizeof name);
 
        printf("exporting %s to %s\n", upkg_export_name(pkg, idx), name);
        of = fopen(name, "wb");
        if (!of) {
                perror(name);
-               goto out;
+               return -1;
        }
 
-       rc = u_object_export(obj, of);
+       u_object_export(obj, of);
 
        if (fclose(of) != 0) {
                perror(name);
-               rc = -1;
-               goto out;
+               return -1;
        }
 
-out:
-       upkg_export_close(f);
-       return rc;
+       if (U_OBJECT_IS_LOADABLE(obj)) {
+               u_object_unload(obj);
+       }
+
+       return 0;
 }
 
 int package_export(struct upkg *pkg)
@@ -192,8 +197,12 @@ int package_export(struct upkg *pkg)
 
        for (unsigned i = 0; i < pkg->export_count; i++) {
                class = upkg_export_class(pkg, i, &package);
+               if (!class) {
+                       fprintf(stderr, "error getting class information.\n");
+                       return EXIT_FAILURE;
+               }
 
-               type = module_get_class(package, class);
+               type = u_object_module_get_class(package, class);
                if (!type) continue;
 
                obj = g_object_new(type, NULL);
@@ -244,7 +253,7 @@ int main(int argc, char **argv)
                return EXIT_FAILURE;
        }
 
-       if (module_init() != 0)
+       if (u_object_module_init() != 0)
                return EXIT_FAILURE;
 
        pkg = upkg_fopen(argv[optind]);
@@ -263,6 +272,6 @@ int main(int argc, char **argv)
        }
 
        upkg_close(pkg);
-       module_exit();
+       u_object_module_exit();
        return rc;
 }