libextractor

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

commit 490c91e4b97423f88085d11a163502b389fb2d32
parent b7382eee137f67f959da59912d5d9b9e5587e834
Author: Christian Grothoff <christian@grothoff.org>
Date:   Tue, 14 Aug 2012 22:56:55 +0000

xm testcase


Diffstat:
Msrc/plugins/Makefile.am | 10+++++++++-
Asrc/plugins/test_xm.c | 85+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Asrc/plugins/testdata/xm_diesel.xm | 0
Msrc/plugins/xm_extractor.c | 11+++++++++--
4 files changed, 103 insertions(+), 3 deletions(-)

diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am @@ -34,7 +34,8 @@ EXTRA_DIST = template_extractor.c \ testdata/odf_cg.odt \ testdata/deb_bzip2.deb \ testdata/nsf_arkanoid.nsf \ - testdata/nsfe_classics.nsfe + testdata/nsfe_classics.nsfe \ + testdata/xm_diesel.xm if HAVE_VORBISFILE PLUGIN_OGG=libextractor_ogg.la @@ -119,6 +120,7 @@ check_PROGRAMS = \ test_png \ test_odf \ test_zip \ + test_xm \ test_nsf \ test_nsfe \ $(TEST_ZLIB) \ @@ -151,6 +153,11 @@ libextractor_xm_la_SOURCES = \ libextractor_xm_la_LDFLAGS = \ $(PLUGINFLAGS) +test_xm_SOURCES = \ + test_xm.c +test_xm_LDADD = \ + $(top_builddir)/src/plugins/libtest.la + libextractor_deb_la_SOURCES = \ deb_extractor.c @@ -240,6 +247,7 @@ libextractor_sid_la_SOURCES = \ libextractor_sid_la_LDFLAGS = \ $(PLUGINFLAGS) + libextractor_s3m_la_SOURCES = \ s3m_extractor.c libextractor_s3m_la_LDFLAGS = \ diff --git a/src/plugins/test_xm.c b/src/plugins/test_xm.c @@ -0,0 +1,85 @@ +/* + This file is part of libextractor. + (C) 2012 Vidyut Samanta and Christian Grothoff + + 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 3, 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. +*/ +/** + * @file plugins/test_xm.c + * @brief testcase for xm plugin + * @author Christian Grothoff + */ +#include "platform.h" +#include "test_lib.h" + + + +/** + * Main function for the XM testcase. + * + * @param argc number of arguments (ignored) + * @param argv arguments (ignored) + * @return 0 on success + */ +int +main (int argc, char *argv[]) +{ + struct SolutionData xm_diesel_sol[] = + { + { + EXTRACTOR_METATYPE_MIMETYPE, + EXTRACTOR_METAFORMAT_UTF8, + "text/plain", + "audio/x-xm", + strlen ("audio/x-xm") + 1, + 0 + }, + { + EXTRACTOR_METATYPE_FORMAT_VERSION, + EXTRACTOR_METAFORMAT_UTF8, + "text/plain", + "1.4", + strlen ("1.4") + 1, + 0 + }, + { + EXTRACTOR_METATYPE_TITLE, + EXTRACTOR_METAFORMAT_UTF8, + "text/plain", + "diesel", + strlen ("diesel") + 1, + 0 + }, + { + EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE, + EXTRACTOR_METAFORMAT_UTF8, + "text/plain", + "FastTracker v2.00", + strlen ("FastTracker v2.00") + 1, + 0 + }, + { 0, 0, NULL, NULL, 0, -1 } + }; + struct ProblemSet ps[] = + { + { "testdata/xm_diesel.xm", + xm_diesel_sol }, + { NULL, NULL } + }; + return ET_main ("xm", ps); +} + +/* end of test_xm.c */ diff --git a/src/plugins/testdata/xm_diesel.xm b/src/plugins/testdata/xm_diesel.xm Binary files differ. diff --git a/src/plugins/xm_extractor.c b/src/plugins/xm_extractor.c @@ -68,6 +68,7 @@ EXTRACTOR_xm_extract_method (struct EXTRACTOR_ExtractContext *ec) char title[21]; char tracker[21]; char xmversion[8]; + size_t n; if (sizeof (struct Header) > ec->read (ec->cls, @@ -88,11 +89,17 @@ EXTRACTOR_xm_extract_method (struct EXTRACTOR_ExtractContext *ec) ADD (xmversion, EXTRACTOR_METATYPE_FORMAT_VERSION); /* Song title */ memcpy (&title, head->title, 20); - title[20] = '\0'; + n = 19; + while ( (n > 0) && isspace ((unsigned char) title[n])) + n--; + title[n + 1] = '\0'; ADD (title, EXTRACTOR_METATYPE_TITLE); /* software used for creating the data */ memcpy (&tracker, head->tracker, 20); - tracker[20] = '\0'; + n = 19; + while ( (n > 0) && isspace ((unsigned char) tracker[n])) + n--; + tracker[n + 1] = '\0'; ADD (tracker, EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE); return; }