2 * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
25 #include "mikmod_types.h"
26 #include <string.h> /* memcmp */
27 #include <ctype.h> /* isdigit */
29 #define MODULEHEADERSIZE 0x438
32 gboolean MOD_CheckType( GstBuffer *buf )
36 data = GST_BUFFER_DATA( buf ) + MODULEHEADERSIZE;
38 /* Protracker and variants */
39 if (( ! memcmp( data, "M.K.", 4 )) || ( ! memcmp( data, "M!K!", 4 )))
43 if ((( ! memcmp( data, "FLT", 3 )) || ( ! memcmp( data, "EXO", 3 ))) && ( isdigit( data[3] )))
46 /* Oktalyzer (Amiga) */
47 if (! memcmp( data, "OKTA", 4 ))
50 /* Oktalyser (Atari) */
51 if ( ! memcmp( data, "CD81", 4 ))
55 if (( ! memcmp( data + 1, "CHN", 3 )) && ( isdigit( data[0] )))
58 /* Fasttracker or Taketracker */
59 if ((( ! memcmp( data + 2, "CH", 2 )) || ( ! memcmp( data + 2, "CN", 2 ))) && ( isdigit( data[0] )) && ( isdigit( data[1] )))
65 gboolean Mod_669_CheckType( GstBuffer *buf )
69 data = GST_BUFFER_DATA( buf );
71 if( ! memcmp( data, "if", 2 ) || ! memcmp( data, "JN", 2 ))
77 gboolean Amf_CheckType( GstBuffer *buf )
81 data = GST_BUFFER_DATA( buf );
83 if( memcmp( data, "AMF", 3) )
86 data = GST_BUFFER_DATA( buf ) + 3;
88 if (( (gint)*data >= 10 ) && ( (gint)*data <= 14 ))
94 gboolean Dsm_CheckType( GstBuffer *buf )
98 data = GST_BUFFER_DATA( buf );
100 if( ! memcmp( data, "RIFF", 4 ) && ! memcmp( data + 8, "DSMF", 4 ))
106 gboolean Fam_CheckType( GstBuffer *buf )
109 static unsigned char FARSIG[4+3]={'F','A','R',0xfe,13,10,26};
111 data = GST_BUFFER_DATA( buf );
113 if(( memcmp( data, FARSIG, 4 )) || ( memcmp( data + 44, FARSIG + 4, 3 )))
119 gboolean Gdm_CheckType( GstBuffer *buf )
123 data = GST_BUFFER_DATA( buf );
125 if ( ! memcmp( data, "GDM\xfe", 4 ) && ! memcmp( data + 71, "GMFS", 4 ))
131 gboolean Imf_CheckType( GstBuffer *buf )
135 data = GST_BUFFER_DATA( buf ) + 0x3c;
137 if( ! memcmp( data, "IM10", 4))
143 gboolean It_CheckType( GstBuffer *buf )
147 data = GST_BUFFER_DATA( buf );
149 if( ! memcmp( data, "IMPM", 4 ))
155 gboolean M15_CheckType( GstBuffer *buf )
157 /* FIXME: M15 CheckType to do */
161 gboolean Med_CheckType( GstBuffer *buf )
165 data = GST_BUFFER_DATA( buf );
167 if(( ! memcmp(data, "MMD0", 4 )) || ( memcmp( data, "MMD1", 4 )))
173 gboolean Mtm_CheckType( GstBuffer *buf )
177 data = GST_BUFFER_DATA( buf );
179 if( ! memcmp( data, "MTM", 3 ))
185 gboolean Okt_CheckType( GstBuffer *buf )
189 data = GST_BUFFER_DATA( buf );
191 if( ! memcmp( data, "OKTSONG", 8 ))
197 gboolean S3m_CheckType( GstBuffer *buf )
201 data = GST_BUFFER_DATA( buf ) + 0x2c;
203 if( ! memcmp( data, "SCRM", 4 ))
209 gboolean Xm_CheckType( GstBuffer *buf )
213 data = GST_BUFFER_DATA( buf );
215 if( memcmp( data, "Extended Module: ", 17 ))
218 if( data[ 37 ] == 0x1a )