gst-indent
[platform/upstream/gst-plugins-good.git] / ext / mikmod / mikmod_types.c
1 /* GStreamer
2  * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
3  *
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.
8  *
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.
13  *
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.
18  */
19
20 #ifdef HAVE_CONFIG_H
21 #include "config.h"
22 #endif
23
24 #include <gst/gst.h>
25 #include "mikmod_types.h"
26 #include <string.h>             /* memcmp */
27 #include <ctype.h>              /* isdigit */
28
29 #define MODULEHEADERSIZE 0x438
30
31
32 gboolean
33 MOD_CheckType (GstBuffer * buf)
34 {
35   gchar *data;
36
37   data = GST_BUFFER_DATA (buf) + MODULEHEADERSIZE;
38
39   /* Protracker and variants */
40   if ((!memcmp (data, "M.K.", 4)) || (!memcmp (data, "M!K!", 4)))
41     return TRUE;
42
43   /* Star Tracker */
44   if (((!memcmp (data, "FLT", 3)) || (!memcmp (data, "EXO", 3)))
45       && (isdigit (data[3])))
46     return TRUE;
47
48   /* Oktalyzer (Amiga) */
49   if (!memcmp (data, "OKTA", 4))
50     return TRUE;
51
52   /* Oktalyser (Atari) */
53   if (!memcmp (data, "CD81", 4))
54     return TRUE;
55
56   /* Fasttracker */
57   if ((!memcmp (data + 1, "CHN", 3)) && (isdigit (data[0])))
58     return TRUE;
59
60   /* Fasttracker or Taketracker */
61   if (((!memcmp (data + 2, "CH", 2)) || (!memcmp (data + 2, "CN", 2)))
62       && (isdigit (data[0])) && (isdigit (data[1])))
63     return TRUE;
64
65   return FALSE;
66 }
67
68 gboolean
69 Mod_669_CheckType (GstBuffer * buf)
70 {
71   gchar *data;
72
73   data = GST_BUFFER_DATA (buf);
74
75   if (!memcmp (data, "if", 2) || !memcmp (data, "JN", 2))
76     return TRUE;
77
78   return FALSE;
79 }
80
81 gboolean
82 Amf_CheckType (GstBuffer * buf)
83 {
84   gchar *data;
85
86   data = GST_BUFFER_DATA (buf);
87
88   if (memcmp (data, "AMF", 3))
89     return FALSE;
90
91   data = GST_BUFFER_DATA (buf) + 3;
92
93   if (((gint) * data >= 10) && ((gint) * data <= 14))
94     return TRUE;
95
96   return FALSE;
97 }
98
99 gboolean
100 Dsm_CheckType (GstBuffer * buf)
101 {
102   gchar *data;
103
104   data = GST_BUFFER_DATA (buf);
105
106   if (!memcmp (data, "RIFF", 4) && !memcmp (data + 8, "DSMF", 4))
107     return TRUE;
108
109   return FALSE;
110 }
111
112 gboolean
113 Fam_CheckType (GstBuffer * buf)
114 {
115   gchar *data;
116   static unsigned char FARSIG[4 + 3] = { 'F', 'A', 'R', 0xfe, 13, 10, 26 };
117
118   data = GST_BUFFER_DATA (buf);
119
120   if ((memcmp (data, FARSIG, 4)) || (memcmp (data + 44, FARSIG + 4, 3)))
121     return FALSE;
122
123   return 1;
124 }
125
126 gboolean
127 Gdm_CheckType (GstBuffer * buf)
128 {
129   gchar *data;
130
131   data = GST_BUFFER_DATA (buf);
132
133   if (!memcmp (data, "GDM\xfe", 4) && !memcmp (data + 71, "GMFS", 4))
134     return TRUE;
135
136   return FALSE;
137 }
138
139 gboolean
140 Imf_CheckType (GstBuffer * buf)
141 {
142   gchar *data;
143
144   data = GST_BUFFER_DATA (buf) + 0x3c;
145
146   if (!memcmp (data, "IM10", 4))
147     return TRUE;
148
149   return FALSE;
150 }
151
152 gboolean
153 It_CheckType (GstBuffer * buf)
154 {
155   gchar *data;
156
157   data = GST_BUFFER_DATA (buf);
158
159   if (!memcmp (data, "IMPM", 4))
160     return TRUE;
161
162   return FALSE;
163 }
164
165 gboolean
166 M15_CheckType (GstBuffer * buf)
167 {
168   /* FIXME: M15 CheckType to do */
169   return FALSE;
170 }
171
172 gboolean
173 Med_CheckType (GstBuffer * buf)
174 {
175   gchar *data;
176
177   data = GST_BUFFER_DATA (buf);
178
179   if ((!memcmp (data, "MMD0", 4)) || (memcmp (data, "MMD1", 4)))
180     return TRUE;
181
182   return FALSE;
183 }
184
185 gboolean
186 Mtm_CheckType (GstBuffer * buf)
187 {
188   gchar *data;
189
190   data = GST_BUFFER_DATA (buf);
191
192   if (!memcmp (data, "MTM", 3))
193     return TRUE;
194
195   return FALSE;
196 }
197
198 gboolean
199 Okt_CheckType (GstBuffer * buf)
200 {
201   gchar *data;
202
203   data = GST_BUFFER_DATA (buf);
204
205   if (!memcmp (data, "OKTSONG", 8))
206     return TRUE;
207
208   return FALSE;
209 }
210
211 gboolean
212 S3m_CheckType (GstBuffer * buf)
213 {
214   gchar *data;
215
216   data = GST_BUFFER_DATA (buf) + 0x2c;
217
218   if (!memcmp (data, "SCRM", 4))
219     return TRUE;
220
221   return FALSE;
222 }
223
224 gboolean
225 Xm_CheckType (GstBuffer * buf)
226 {
227   gchar *data;
228
229   data = GST_BUFFER_DATA (buf);
230
231   if (memcmp (data, "Extended Module: ", 17))
232     return FALSE;
233
234   if (data[37] == 0x1a)
235     return TRUE;
236
237   return FALSE;
238 }