summaryrefslogtreecommitdiff
path: root/dumb/dumb-kode54/src/it/readriff.c
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <wakeroid@gmail.com>2009-07-19 11:31:03 +0200
committerGravatar Alexey Yakovenko <wakeroid@gmail.com>2009-07-19 11:31:03 +0200
commitbe5c03f0510d62bb86c9a11b77977123239b2c7e (patch)
tree33ffc42a8135109e7ca9185072c61d21ddcb3289 /dumb/dumb-kode54/src/it/readriff.c
parentde9ab352f11a333eaf49030e581bb911b30abb3c (diff)
switched to kode54's version of dumb
Diffstat (limited to 'dumb/dumb-kode54/src/it/readriff.c')
-rw-r--r--dumb/dumb-kode54/src/it/readriff.c73
1 files changed, 73 insertions, 0 deletions
diff --git a/dumb/dumb-kode54/src/it/readriff.c b/dumb/dumb-kode54/src/it/readriff.c
new file mode 100644
index 00000000..615e555c
--- /dev/null
+++ b/dumb/dumb-kode54/src/it/readriff.c
@@ -0,0 +1,73 @@
+/* _______ ____ __ ___ ___
+ * \ _ \ \ / \ / \ \ / / ' ' '
+ * | | \ \ | | || | \/ | . .
+ * | | | | | | || ||\ /| |
+ * | | | | | | || || \/ | | ' ' '
+ * | | | | | | || || | | . .
+ * | |_/ / \ \__// || | |
+ * /_______/ynamic \____/niversal /__\ /____\usic /| . . ibliotheque
+ * / \
+ * / . \
+ * readriff.c - Code to read a RIFF module file / / \ \
+ * from memory. | < / \_
+ * | \/ /\ /
+ * \_ / > /
+ * By Chris Moeller. | \ / /
+ * | ' /
+ * \__/
+ */
+
+#include "dumb.h"
+#include "internal/it.h"
+#include "internal/riff.h"
+
+
+DUH *dumb_read_riff_amff( struct riff * stream );
+DUH *dumb_read_riff_am( struct riff * stream );
+DUH *dumb_read_riff_dsmf( struct riff * stream );
+
+/* dumb_read_riff_quick(): reads a RIFF file into a DUH struct, returning a
+ * pointer to the DUH struct. When you have finished with it, you must pass
+ * the pointer to unload_duh() so that the memory can be freed.
+ */
+DUH *dumb_read_riff_quick( DUMBFILE * f )
+{
+ DUH * duh;
+ struct riff * stream;
+
+ {
+ unsigned char * buffer = 0;
+ unsigned size = 0;
+ unsigned read;
+ do
+ {
+ buffer = realloc( buffer, 32768 + size );
+ if ( ! buffer ) return 0;
+ read = dumbfile_getnc( buffer + size, 32768, f );
+ if ( read < 0 )
+ {
+ free( buffer );
+ return 0;
+ }
+ size += read;
+ }
+ while ( read == 32768 );
+ stream = riff_parse( buffer, size, 1 );
+ if ( ! stream ) stream = riff_parse( buffer, size, 0 );
+ free( buffer );
+ }
+
+ if ( ! stream ) return 0;
+
+ if ( stream->type == DUMB_ID( 'A', 'M', ' ', ' ' ) )
+ duh = dumb_read_riff_am( stream );
+ else if ( stream->type == DUMB_ID( 'A', 'M', 'F', 'F' ) )
+ duh = dumb_read_riff_amff( stream );
+ else if ( stream->type == DUMB_ID( 'D', 'S', 'M', 'F' ) )
+ duh = dumb_read_riff_dsmf( stream );
+ else duh = 0;
+
+ riff_free( stream );
+
+ return duh;
+}