diff options
author | Simon Howard | 2012-12-23 18:25:29 +0000 |
---|---|---|
committer | Simon Howard | 2012-12-23 18:25:29 +0000 |
commit | ea5b5f171623740a74f1b2bef80527c044373502 (patch) | |
tree | 93c3a1638aed54c39f9494a88c0138ce77116e3b | |
parent | 9a8cf12227923e3b2b83625d5b91af2f58cd856b (diff) | |
download | chocolate-doom-ea5b5f171623740a74f1b2bef80527c044373502.tar.gz chocolate-doom-ea5b5f171623740a74f1b2bef80527c044373502.tar.bz2 chocolate-doom-ea5b5f171623740a74f1b2bef80527c044373502.zip |
Add standalone build target for mus2mid binary.
Subversion-branch: /branches/v2-branch
Subversion-revision: 2551
-rw-r--r-- | src/Makefile.am | 3 | ||||
-rw-r--r-- | src/mus2mid.c | 43 |
2 files changed, 46 insertions, 0 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 8f393089..a67660e2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -234,3 +234,6 @@ endif 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 $@ + diff --git a/src/mus2mid.c b/src/mus2mid.c index 88d24c97..739037e1 100644 --- a/src/mus2mid.c +++ b/src/mus2mid.c @@ -691,3 +691,46 @@ boolean mus2mid(MEMFILE *musinput, MEMFILE *midioutput) 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 + |