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
33 MOD_CheckType (GstBuffer * buf)
37 data = GST_BUFFER_DATA (buf) + MODULEHEADERSIZE;
39 /* Protracker and variants */
40 if ((!memcmp (data, "M.K.", 4)) || (!memcmp (data, "M!K!", 4)))
44 if (((!memcmp (data, "FLT", 3)) || (!memcmp (data, "EXO", 3)))
45 && (isdigit (data[3])))
48 /* Oktalyzer (Amiga) */
49 if (!memcmp (data, "OKTA", 4))
52 /* Oktalyser (Atari) */
53 if (!memcmp (data, "CD81", 4))
57 if ((!memcmp (data + 1, "CHN", 3)) && (isdigit (data[0])))
60 /* Fasttracker or Taketracker */
61 if (((!memcmp (data + 2, "CH", 2)) || (!memcmp (data + 2, "CN", 2)))
62 && (isdigit (data[0])) && (isdigit (data[1])))
69 Mod_669_CheckType (GstBuffer * buf)
73 data = GST_BUFFER_DATA (buf);
75 if (!memcmp (data, "if", 2) || !memcmp (data, "JN", 2))
82 Amf_CheckType (GstBuffer * buf)
86 data = GST_BUFFER_DATA (buf);
88 if (memcmp (data, "AMF", 3))
91 data = GST_BUFFER_DATA (buf) + 3;
93 if (((gint) * data >= 10) && ((gint) * data <= 14))
100 Dsm_CheckType (GstBuffer * buf)
104 data = GST_BUFFER_DATA (buf);
106 if (!memcmp (data, "RIFF", 4) && !memcmp (data + 8, "DSMF", 4))
113 Fam_CheckType (GstBuffer * buf)
116 static unsigned char FARSIG[4 + 3] = { 'F', 'A', 'R', 0xfe, 13, 10, 26 };
118 data = GST_BUFFER_DATA (buf);
120 if ((memcmp (data, FARSIG, 4)) || (memcmp (data + 44, FARSIG + 4, 3)))
127 Gdm_CheckType (GstBuffer * buf)
131 data = GST_BUFFER_DATA (buf);
133 if (!memcmp (data, "GDM\xfe", 4) && !memcmp (data + 71, "GMFS", 4))
140 Imf_CheckType (GstBuffer * buf)
144 data = GST_BUFFER_DATA (buf) + 0x3c;
146 if (!memcmp (data, "IM10", 4))
153 It_CheckType (GstBuffer * buf)
157 data = GST_BUFFER_DATA (buf);
159 if (!memcmp (data, "IMPM", 4))
166 M15_CheckType (GstBuffer * buf)
168 /* FIXME: M15 CheckType to do */
173 Med_CheckType (GstBuffer * buf)
177 data = GST_BUFFER_DATA (buf);
179 if ((!memcmp (data, "MMD0", 4)) || (memcmp (data, "MMD1", 4)))
186 Mtm_CheckType (GstBuffer * buf)
190 data = GST_BUFFER_DATA (buf);
192 if (!memcmp (data, "MTM", 3))
199 Okt_CheckType (GstBuffer * buf)
203 data = GST_BUFFER_DATA (buf);
205 if (!memcmp (data, "OKTSONG", 8))
212 S3m_CheckType (GstBuffer * buf)
216 data = GST_BUFFER_DATA (buf) + 0x2c;
218 if (!memcmp (data, "SCRM", 4))
225 Xm_CheckType (GstBuffer * buf)
229 data = GST_BUFFER_DATA (buf);
231 if (memcmp (data, "Extended Module: ", 17))
234 if (data[37] == 0x1a)