libextractor

GNU libextractor
Log | Files | Refs | Submodules | README | LICENSE

commit 560e0aa9da06367629c80b8797e0dcdaffed7037
parent cc3cdf90fa4d9b6aba129cd30da7149e047f35d9
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sat, 19 Dec 2009 12:37:09 +0000

s3m

Diffstat:
Msrc/plugins/Makefile.am | 14++++++--------
Asrc/plugins/s3m_extractor.c | 68++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Dsrc/plugins/s3mextractor.c | 92-------------------------------------------------------------------------------
3 files changed, 74 insertions(+), 100 deletions(-)

diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am @@ -102,6 +102,7 @@ plugin_LTLIBRARIES = \ libextractor_real.la \ libextractor_riff.la \ $(rpm) \ + libextractor_s3m.la \ libextractor_sid.la \ libextractor_tar.la \ $(thumbgtk) \ @@ -290,6 +291,11 @@ libextractor_rpm_la_LDFLAGS = \ libextractor_rpm_la_LIBADD = \ -lrpm +libextractor_s3m_la_SOURCES = \ + s3m_extractor.c +libextractor_s3m_la_LDFLAGS = \ + $(PLUGINFLAGS) + libextractor_sid_la_SOURCES = \ sid_extractor.c libextractor_sid_la_LDFLAGS = \ @@ -349,7 +355,6 @@ OLD_LIBS = \ $(extrampeg) \ libextractor_nsf.la \ libextractor_nsfe.la \ - libextractor_s3m.la \ libextractor_tar.la \ $(thumbqt) \ libextractor_xm.la \ @@ -392,13 +397,6 @@ libextractor_nsfe_la_LDFLAGS = \ libextractor_nsfe_la_LIBADD = \ $(top_builddir)/src/main/libextractor.la -libextractor_s3m_la_SOURCES = \ - s3mextractor.c -libextractor_s3m_la_LDFLAGS = \ - $(PLUGINFLAGS) -libextractor_s3m_la_LIBADD = \ - $(top_builddir)/src/main/libextractor.la - libextractor_thumbnailqt_la_SOURCES = \ thumbnailextractorqt.cc libextractor_thumbnailqt_la_LDFLAGS = \ diff --git a/src/plugins/s3m_extractor.c b/src/plugins/s3m_extractor.c @@ -0,0 +1,68 @@ +/* + * 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]; +}; + +#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) + + +/* "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. + * + */ +int +EXTRACTOR_s3m_extract (const unsigned char *data, + size_t size, + EXTRACTOR_MetaDataProcessor proc, + void *proc_cls, + const char *options) +{ + char title[29]; + const struct header *head; + + /* Check header size */ + + if (size < HEADER_SIZE) + return 0; + head = (const struct header *) data; + if (memcmp (head->magicid, "SCRM", 4)) + return 0; + ADD ("audio/x-s3m", EXTRACTOR_METATYPE_MIMETYPE); + + memcpy (&title, head->title, 28); + title[28] = '\0'; + ADD (title, EXTRACTOR_METATYPE_TITLE); + return 0; +} diff --git a/src/plugins/s3mextractor.c b/src/plugins/s3mextractor.c @@ -1,92 +0,0 @@ -/* - * 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[28] = '\0'; - prev = addkword (prev, title, EXTRACTOR_TITLE); - - return (prev); - -}