]> git.draconx.ca Git - upkg.git/blobdiff - src/upkg.c
uobject: Take a package/index tuple instead of a upkg_file for deserialize.
[upkg.git] / src / upkg.c
index ed6d4dfdeaf8a9844d51e4f22d3a6eda1912699d..ef44bf68e48a47934e43851a8a9d4ae53c4df480 100644 (file)
@@ -28,6 +28,7 @@
 #include "module.h"
 #include "uobject.h"
 #include "exportable.h"
+#include "loadable.h"
 
 enum {
        MODE_INFO,
@@ -153,14 +154,17 @@ 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;
 
-       if (u_object_deserialize(obj, f) != 0) {
+       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);
@@ -170,14 +174,18 @@ static int export(struct upkg *pkg, GObject *obj, unsigned idx)
                return -1;
        }
 
-       rc = u_object_export(obj, of);
+       u_object_export(obj, of);
 
        if (fclose(of) != 0) {
                perror(name);
                return -1;
        }
 
-       return rc;
+       if (U_OBJECT_IS_LOADABLE(obj)) {
+               u_object_unload(obj);
+       }
+
+       return 0;
 }
 
 int package_export(struct upkg *pkg)
@@ -189,6 +197,10 @@ 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);
                if (!type) continue;