]> git.draconx.ca Git - upkg.git/blobdiff - src/upkg.c
Implement dynamic loading of modules.
[upkg.git] / src / upkg.c
index bcbee2fbcd291b5522ea551942e81c5ec07ed729..f2ad3bc937db97dd768c6656b8f6038a0ac315ed 100644 (file)
@@ -22,9 +22,9 @@
 #include <glib-object.h>
 
 #include "upkg.h"
+#include "module.h"
 #include "serializable.h"
 #include "exportable.h"
-#include "music.h"
 
 void print_upkg_flags(const char *prefix, unsigned long flags)
 {
@@ -57,13 +57,14 @@ int main(int argc, char **argv)
 {
        struct upkg *pkg;
 
-       g_type_init();
-
        if (argc < 2) {
                fprintf(stderr, "usage: upkg file\n");
                return EXIT_FAILURE;
        }
 
+       if (module_init() != 0)
+               return EXIT_FAILURE;
+
        pkg = upkg_fopen(argv[1]);
        if (!pkg) {
                fprintf(stderr, "failed to open package!\n");
@@ -86,7 +87,12 @@ int main(int argc, char **argv)
        printf("Exports: %lu\n", pkg->export_count);
        printf("Imports: %lu\n", pkg->import_count);
 
-       GObject *music = u_music_new();
+       UPkgModule *m = upkg_module_new("engine");
+       g_type_module_use(G_TYPE_MODULE(m));
+
+       GObject *music = g_object_new(g_type_from_name("EngineMusic"), NULL);
+       if (!music)
+               return EXIT_FAILURE;
        struct upkg_file *f = upkg_export_open(pkg, 0);
        upkg_deserialize(music, f);
 
@@ -99,5 +105,7 @@ int main(int argc, char **argv)
        printf("Wrote %s\n", name);
 
        upkg_close(pkg);
+       module_exit();
+
        return 0;
 }