]> git.draconx.ca Git - upkg.git/blobdiff - src/upkg.c
Initial UObject implementation plus a dumb music extractor.
[upkg.git] / src / upkg.c
index 20b7336155a1077840d171889aff71b859e68e6d..bcbee2fbcd291b5522ea551942e81c5ec07ed729 100644 (file)
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <glib-object.h>
+
 #include "upkg.h"
+#include "serializable.h"
+#include "exportable.h"
+#include "music.h"
 
 void print_upkg_flags(const char *prefix, unsigned long flags)
 {
@@ -52,6 +57,8 @@ int main(int argc, char **argv)
 {
        struct upkg *pkg;
 
+       g_type_init();
+
        if (argc < 2) {
                fprintf(stderr, "usage: upkg file\n");
                return EXIT_FAILURE;
@@ -79,6 +86,18 @@ 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();
+       struct upkg_file *f = upkg_export_open(pkg, 0);
+       upkg_deserialize(music, f);
+
+       char name[256];
+       upkg_export_name(music, name, sizeof name);
+       FILE *fp = fopen(name, "wb");
+       if (!fp) return EXIT_FAILURE;
+       upkg_export(music, fp);
+       fclose(fp);
+       printf("Wrote %s\n", name);
+
        upkg_close(pkg);
        return 0;
 }