commit 24706cad439ae05a6d2930dcc294a9a33835f9f2
parent f42f3aba9ff946d4c31532cefaf8bc844a668b96
Author: Toni Ruottu <toni.ruottu@helsinki.fi>
Date: Tue, 12 Aug 2008 01:43:59 +0000
Added s3m support.
Diffstat:
6 files changed, 107 insertions(+), 1 deletion(-)
diff --git a/AUTHORS b/AUTHORS
@@ -42,6 +42,7 @@ nsfe - Toni Ruottu <toni.ruottu@iki.fi>
applefile - Heikki Lindholm
it - Toni Ruottu <toni.ruottu@iki.fi>
xm - Toni Ruottu <toni.ruottu@iki.fi>
+s3m - Toni Ruottu <toni.ruottu@iki.fi>
General contributors:
Yuri N. Sedunov <aris@altlinux.ru>
diff --git a/ChangeLog b/ChangeLog
@@ -1,3 +1,6 @@
+Tue Aug 12 04:40:49 EEST 2008
+ Added an S3M (Scream Tracker 3 Module) plugin.
+
Tue Aug 12 03:55:01 EEST 2008
Added an XM (eXtended Module) plugin.
diff --git a/NEWS b/NEWS
@@ -1,3 +1,4 @@
+ Added an S3M (Scream Tracker 3 Module) plugin.
Added an XM (eXtended Module) plugin.
Added an IT (Impulse Tracker) plugin.
diff --git a/src/main/extractor.c b/src/main/extractor.c
@@ -265,7 +265,8 @@ libextractor_sid:\
libextractor_nsfe:\
libextractor_nsf:\
libextractor_it:\
-libextractor_xm"
+libextractor_xm:\
+libextractor_s3m"
#define DEFAULT_LIBRARIES MPEGSO EXSO OLESO OGGSO FLACSO QTSO DEFSO
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
@@ -113,6 +113,7 @@ plugin_LTLIBRARIES = $(pdfplugin) \
$(extraqt) \
libextractor_real.la \
libextractor_riff.la \
+ libextractor_s3m.la \
libextractor_sid.la \
libextractor_split.la \
libextractor_tar.la \
@@ -390,6 +391,13 @@ libextractor_xm_la_LDFLAGS = \
libextractor_xm_la_LIBADD = \
$(top_builddir)/src/main/libextractor.la
+libextractor_s3m_la_SOURCES = \
+ s3mextractor.c
+libextractor_s3m_la_LDFLAGS = \
+ $(PLUGINFLAGS) $(retaincommand)
+libextractor_s3m_la_LIBADD = \
+ $(top_builddir)/src/main/libextractor.la
+
libextractor_split_la_SOURCES = \
splitextractor.c
libextractor_split_la_LDFLAGS = \
diff --git a/src/plugins/s3mextractor.c b/src/plugins/s3mextractor.c
@@ -0,0 +1,92 @@
+/*
+ * This file is part of libextractor.
+ * (C) 2008 Toni Ruottu
+ *
+ * libextractor is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2, or (at your
+ * option) any later version.
+ *
+ * libextractor is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with libextractor; see the file COPYING. If not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include "platform.h"
+#include "extractor.h"
+#include "convert.h"
+
+#define HEADER_SIZE 0x70
+
+struct header
+{
+ char title[28];
+ char something[16];
+ char magicid[4];
+};
+
+
+static struct EXTRACTOR_Keywords *addkword
+ (EXTRACTOR_KeywordList * oldhead,
+ const char *phrase, EXTRACTOR_KeywordType type)
+{
+ EXTRACTOR_KeywordList *keyword;
+
+ keyword = malloc (sizeof (EXTRACTOR_KeywordList));
+ keyword->next = oldhead;
+ keyword->keyword = strdup (phrase);
+ keyword->keywordType = type;
+ return (keyword);
+}
+
+
+/* "extract" keyword from a Scream Tracker 3 Module
+ *
+ * "Scream Tracker 3.01 BETA File Formats And Mixing Info"
+ * was used, while this piece of software was originally
+ * written.
+ *
+ */
+struct EXTRACTOR_Keywords *libextractor_s3m_extract
+ (const char *filename,
+ char *data, size_t size, struct EXTRACTOR_Keywords *prev)
+{
+ char title[29];
+ struct header *head;
+
+ /* Check header size */
+
+ if (size < HEADER_SIZE)
+ {
+ return (prev);
+ }
+
+ head = (struct header *) data;
+
+ /* Check "magic" id bytes */
+
+ if (memcmp (head->magicid, "SCRM", 4))
+ {
+ return (prev);
+ }
+
+ /* Mime-type */
+
+ prev = addkword (prev, "audio/x-s3m", EXTRACTOR_MIMETYPE);
+
+ /* Song title */
+
+ memcpy (&title, head->title, 28);
+ title[29] = '\0';
+ prev = addkword (prev, title, EXTRACTOR_TITLE);
+
+ return (prev);
+
+}