ref: ea5b5f171623740a74f1b2bef80527c044373502
parent: 9a8cf12227923e3b2b83625d5b91af2f58cd856b
author: Simon Howard <[email protected]>
date: Sun Dec 23 13:25:29 EST 2012
Add standalone build target for mus2mid binary. Subversion-branch: /branches/v2-branch Subversion-revision: 2551
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -234,3 +234,6 @@
midiread : midifile.c
$(CC) -DTEST $(CFLAGS) @LDFLAGS@ $< -o $@
+mus2mid : mus2mid.c memio.c z_native.c i_system.c m_argv.c m_misc.c
+ $(CC) -DSTANDALONE -I$(top_builddir) $(CFLAGS) @LDFLAGS@ $^ -o $@
+
--- a/src/mus2mid.c
+++ b/src/mus2mid.c
@@ -691,3 +691,46 @@
return false;
}
+#ifdef STANDALONE
+
+#include "m_misc.h"
+#include "z_zone.h"
+
+int main(int argc, char *argv[])
+{
+ MEMFILE *src, *dst;
+ byte *infile;
+ long infile_len;
+ void *outfile;
+ size_t outfile_len;
+
+ if (argc != 3)
+ {
+ printf("Usage: %s <musfile> <midfile>\n", argv[0]);
+ exit(-1);
+ }
+
+ Z_Init();
+
+ infile_len = M_ReadFile(argv[1], &infile);
+
+ src = mem_fopen_read(infile, infile_len);
+ dst = mem_fopen_write();
+
+ if (mus2mid(src, dst))
+ {
+ fprintf(stderr, "mus2mid() failed\n");
+ exit(-1);
+ }
+
+ // Write result to output file:
+
+ mem_get_buf(dst, &outfile, &outfile_len);
+
+ M_WriteFile(argv[2], outfile, outfile_len);
+
+ return 0;
+}
+
+#endif
+