aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2009-12-19 12:17:06 +0000
committerChristian Grothoff <christian@grothoff.org>2009-12-19 12:17:06 +0000
commitfe641c0d363f2bcb75cef8d7b67e44f4d972ba47 (patch)
tree3141e6b4ab4d7e83b8e0642f0062f1e4d945d773
parent8bb11f7c6a642203663e97b659371fcaaa3e7182 (diff)
downloadlibextractor-fe641c0d363f2bcb75cef8d7b67e44f4d972ba47.tar.gz
libextractor-fe641c0d363f2bcb75cef8d7b67e44f4d972ba47.zip
xm
-rw-r--r--doc/version.texi2
-rw-r--r--src/plugins/Makefile.am13
-rw-r--r--src/plugins/xm_extractor.c (renamed from src/plugins/xmextractor.c)68
3 files changed, 29 insertions, 54 deletions
diff --git a/doc/version.texi b/doc/version.texi
index dc2f7af..dfc5c5b 100644
--- a/doc/version.texi
+++ b/doc/version.texi
@@ -1,4 +1,4 @@
1@set UPDATED 22 October 2009 1@set UPDATED 1 October 2009
2@set UPDATED-MONTH October 2009 2@set UPDATED-MONTH October 2009
3@set EDITION 0.6.0 3@set EDITION 0.6.0
4@set VERSION 0.6.0 4@set VERSION 0.6.0
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
index 252a73d..05f77dd 100644
--- a/src/plugins/Makefile.am
+++ b/src/plugins/Makefile.am
@@ -97,6 +97,7 @@ plugin_LTLIBRARIES = \
97 $(thumbgtk) \ 97 $(thumbgtk) \
98 libextractor_tiff.la \ 98 libextractor_tiff.la \
99 libextractor_wav.la \ 99 libextractor_wav.la \
100 libextractor_xm.la \
100 libextractor_zip.la 101 libextractor_zip.la
101 102
102libextractor_applefile_la_SOURCES = \ 103libextractor_applefile_la_SOURCES = \
@@ -307,6 +308,11 @@ libextractor_wav_la_LDFLAGS = \
307libextractor_wav_la_LIBADD = \ 308libextractor_wav_la_LIBADD = \
308 $(LE_LIBINTL) 309 $(LE_LIBINTL)
309 310
311libextractor_xm_la_SOURCES = \
312 xm_extractor.c
313libextractor_xm_la_LDFLAGS = \
314 $(PLUGINFLAGS)
315
310libextractor_zip_la_SOURCES = \ 316libextractor_zip_la_SOURCES = \
311 zip_extractor.c 317 zip_extractor.c
312libextractor_zip_la_LDFLAGS = \ 318libextractor_zip_la_LDFLAGS = \
@@ -379,13 +385,6 @@ libextractor_nsfe_la_LDFLAGS = \
379libextractor_nsfe_la_LIBADD = \ 385libextractor_nsfe_la_LIBADD = \
380 $(top_builddir)/src/main/libextractor.la 386 $(top_builddir)/src/main/libextractor.la
381 387
382libextractor_xm_la_SOURCES = \
383 xmextractor.c
384libextractor_xm_la_LDFLAGS = \
385 $(PLUGINFLAGS)
386libextractor_xm_la_LIBADD = \
387 $(top_builddir)/src/main/libextractor.la
388
389libextractor_s3m_la_SOURCES = \ 388libextractor_s3m_la_SOURCES = \
390 s3mextractor.c 389 s3mextractor.c
391libextractor_s3m_la_LDFLAGS = \ 390libextractor_s3m_la_LDFLAGS = \
diff --git a/src/plugins/xmextractor.c b/src/plugins/xm_extractor.c
index c532b77..d8e0829 100644
--- a/src/plugins/xmextractor.c
+++ b/src/plugins/xm_extractor.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * This file is part of libextractor. 2 * This file is part of libextractor.
3 * (C) 2008 Toni Ruottu 3 * (C) 2008, 2009 Toni Ruottu
4 * 4 *
5 * libextractor is free software; you can redistribute it and/or modify 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 6 * it under the terms of the GNU General Public License as published
@@ -34,19 +34,7 @@ struct header
34 char version[2]; 34 char version[2];
35}; 35};
36 36
37 37#define ADD(s,t) do { if (0 != proc (proc_cls, "xm", t, EXTRACTOR_METAFORMAT_UTF8, "text/plain", s, strlen(s)+1)) return 1; } while (0)
38static struct EXTRACTOR_Keywords *addkword
39 (EXTRACTOR_KeywordList * oldhead,
40 const char *phrase, EXTRACTOR_KeywordType type)
41{
42 EXTRACTOR_KeywordList *keyword;
43
44 keyword = malloc (sizeof (EXTRACTOR_KeywordList));
45 keyword->next = oldhead;
46 keyword->keyword = strdup (phrase);
47 keyword->keywordType = type;
48 return (keyword);
49}
50 38
51 39
52/* "extract" keyword from an Extended Module 40/* "extract" keyword from an Extended Module
@@ -57,52 +45,40 @@ static struct EXTRACTOR_Keywords *addkword
57 * was originally written. 45 * was originally written.
58 * 46 *
59 */ 47 */
60struct EXTRACTOR_Keywords *libextractor_xm_extract 48int
61 (const char *filename, 49EXTRACTOR_xm_extract (const unsigned char *data,
62 char *data, size_t size, struct EXTRACTOR_Keywords *prev) 50 size_t size,
51 EXTRACTOR_MetaDataProcessor proc,
52 void *proc_cls,
53 const char *options)
63{ 54{
64 char title[21]; 55 char title[21];
65 char tracker[21]; 56 char tracker[21];
66 char xmversion[8]; 57 char xmversion[8];
67 struct header *head; 58 const struct header *head;
68 59
69 /* Check header size */ 60 /* Check header size */
70
71 if (size < HEADER_SIZE) 61 if (size < HEADER_SIZE)
72 { 62 return 0;
73 return (prev); 63 head = (const struct header *) data;
74 }
75
76 head = (struct header *) data;
77
78 /* Check "magic" id bytes */ 64 /* Check "magic" id bytes */
79
80 if (memcmp (head->magicid, "Extended Module: ", 17)) 65 if (memcmp (head->magicid, "Extended Module: ", 17))
81 { 66 return 0;
82 return (prev); 67 ADD("audio/x-xm", EXTRACTOR_METATYPE_MIMETYPE);
83 }
84
85 /* Mime-type */
86
87 prev = addkword (prev, "audio/x-xm", EXTRACTOR_MIMETYPE);
88
89 /* Version of Tracker */ 68 /* Version of Tracker */
90 69 snprintf (xmversion,
91 sprintf (xmversion, "%d.%d", head->version[1],head->version[0]); 70 sizeof(xmversion),
92 prev = addkword (prev, xmversion, EXTRACTOR_FORMAT_VERSION); 71 "%d.%d",
93 72 head->version[1],
73 head->version[0]);
74 ADD (xmversion, EXTRACTOR_METATYPE_FORMAT_VERSION);
94 /* Song title */ 75 /* Song title */
95
96 memcpy (&title, head->title, 20); 76 memcpy (&title, head->title, 20);
97 title[20] = '\0'; 77 title[20] = '\0';
98 prev = addkword (prev, title, EXTRACTOR_TITLE); 78 ADD (title, EXTRACTOR_METATYPE_TITLE);
99
100 /* software used for creating the data */ 79 /* software used for creating the data */
101
102 memcpy (&tracker, head->tracker, 20); 80 memcpy (&tracker, head->tracker, 20);
103 tracker[20] = '\0'; 81 tracker[20] = '\0';
104 prev = addkword (prev, tracker, EXTRACTOR_SOFTWARE); 82 ADD (tracker, EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE);
105 83 return 0;
106 return (prev);
107
108} 84}