aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/s3m_extractor.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/s3m_extractor.c')
-rw-r--r--src/plugins/s3m_extractor.c68
1 files changed, 68 insertions, 0 deletions
diff --git a/src/plugins/s3m_extractor.c b/src/plugins/s3m_extractor.c
new file mode 100644
index 0000000..7e8ae40
--- /dev/null
+++ b/src/plugins/s3m_extractor.c
@@ -0,0 +1,68 @@
1/*
2 * This file is part of libextractor.
3 * (C) 2008 Toni Ruottu
4 *
5 * libextractor is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published
7 * by the Free Software Foundation; either version 2, or (at your
8 * option) any later version.
9 *
10 * libextractor is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with libextractor; see the file COPYING. If not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
19 *
20 */
21
22#include "platform.h"
23#include "extractor.h"
24#include "convert.h"
25
26#define HEADER_SIZE 0x70
27
28struct header
29{
30 char title[28];
31 char something[16];
32 char magicid[4];
33};
34
35#define ADD(s,t) do { if (0 != proc (proc_cls, "s3m", t, EXTRACTOR_METAFORMAT_UTF8, "text/plain", s, strlen(s)+1)) return 1; } while (0)
36
37
38/* "extract" keyword from a Scream Tracker 3 Module
39 *
40 * "Scream Tracker 3.01 BETA File Formats And Mixing Info"
41 * was used, while this piece of software was originally
42 * written.
43 *
44 */
45int
46EXTRACTOR_s3m_extract (const unsigned char *data,
47 size_t size,
48 EXTRACTOR_MetaDataProcessor proc,
49 void *proc_cls,
50 const char *options)
51{
52 char title[29];
53 const struct header *head;
54
55 /* Check header size */
56
57 if (size < HEADER_SIZE)
58 return 0;
59 head = (const struct header *) data;
60 if (memcmp (head->magicid, "SCRM", 4))
61 return 0;
62 ADD ("audio/x-s3m", EXTRACTOR_METATYPE_MIMETYPE);
63
64 memcpy (&title, head->title, 28);
65 title[28] = '\0';
66 ADD (title, EXTRACTOR_METATYPE_TITLE);
67 return 0;
68}