X-Git-Url: https://git.draconx.ca/gitweb/upkg.git/blobdiff_plain/94fc44d9acf969477faac61bd60a6812404727f9..03eb9c441bba9f41d36cfd8f2cf1d43a5ee42252:/src/upkg.c diff --git a/src/upkg.c b/src/upkg.c index 82a673d..e1a8a80 100644 --- a/src/upkg.c +++ b/src/upkg.c @@ -25,9 +25,10 @@ #include #include "upkg.h" -#include "module.h" -#include "uobject.h" -#include "exportable.h" +#include +#include +#include +#include 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 (uobject_deserialize(obj, pkg, idx) != 0) { + return -1; } - u_object_export_name(obj, name, sizeof name); + + if (UOBJECT_IS_LOADABLE(obj) && uobject_load(obj) != 0) { + return -1; + } + + uobject_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); + uobject_export(obj, of); if (fclose(of) != 0) { perror(name); - rc = -1; - goto out; + return -1; } -out: - upkg_export_close(f); - return rc; + if (UOBJECT_IS_LOADABLE(obj)) { + uobject_unload(obj); + } + + return 0; } int package_export(struct upkg *pkg) @@ -192,12 +197,16 @@ 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 = uobject_module_get_class(package, class); if (!type) continue; obj = g_object_new(type, NULL); - if (U_OBJECT_IS_EXPORTABLE(obj)) { + if (UOBJECT_IS_EXPORTABLE(obj)) { if (export(pkg, obj, i) != 0) { rc = EXIT_FAILURE; } @@ -244,7 +253,7 @@ int main(int argc, char **argv) return EXIT_FAILURE; } - if (module_init() != 0) + if (uobject_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(); + uobject_module_exit(); return rc; }