aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-08-09 21:07:33 +0000
committerChristian Grothoff <christian@grothoff.org>2012-08-09 21:07:33 +0000
commit6d48778edf53b53b13f7a1ae95d50e71887f67c7 (patch)
treed6c2ecc1ddd0c0a779ddde9dab1795262053bd6b
parent5071b3fb9309f0a213e6a0d0f70c0d1e5a8555aa (diff)
downloadlibextractor-6d48778edf53b53b13f7a1ae95d50e71887f67c7.tar.gz
libextractor-6d48778edf53b53b13f7a1ae95d50e71887f67c7.zip
-porting it extractor to new api
-rw-r--r--src/plugins/Makefile.am6
-rw-r--r--src/plugins/it_extractor.c105
-rw-r--r--src/plugins/xm_extractor.c8
3 files changed, 71 insertions, 48 deletions
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
index 16752af..4f3fb8c 100644
--- a/src/plugins/Makefile.am
+++ b/src/plugins/Makefile.am
@@ -67,6 +67,7 @@ endif
67 67
68 68
69plugin_LTLIBRARIES = \ 69plugin_LTLIBRARIES = \
70 libextractor_it.la \
70 libextractor_xm.la \ 71 libextractor_xm.la \
71 libextractor_wav.la \ 72 libextractor_wav.la \
72 $(PLUGIN_OGG) \ 73 $(PLUGIN_OGG) \
@@ -112,6 +113,11 @@ libextractor_xm_la_SOURCES = \
112libextractor_xm_la_LDFLAGS = \ 113libextractor_xm_la_LDFLAGS = \
113 $(PLUGINFLAGS) 114 $(PLUGINFLAGS)
114 115
116libextractor_it_la_SOURCES = \
117 it_extractor.c
118libextractor_it_la_LDFLAGS = \
119 $(PLUGINFLAGS)
120
115 121
116libextractor_wav_la_SOURCES = \ 122libextractor_wav_la_SOURCES = \
117 wav_extractor.c 123 wav_extractor.c
diff --git a/src/plugins/it_extractor.c b/src/plugins/it_extractor.c
index bde8d1c..852e50b 100644
--- a/src/plugins/it_extractor.c
+++ b/src/plugins/it_extractor.c
@@ -18,13 +18,27 @@
18 * Boston, MA 02111-1307, USA. 18 * Boston, MA 02111-1307, USA.
19 * 19 *
20 */ 20 */
21 21/**
22 * @file plugins/xm_extractor.c
23 * @brief plugin to support Impulse Tracker (IT) files
24 * @author Toni Ruottu
25 * @author Christian Grothoff
26 */
22#include "platform.h" 27#include "platform.h"
23#include "extractor.h" 28#include "extractor.h"
24 29
30
31/**
32 * Number of bytes in the full IT header and thus
33 * the minimum size we're going to accept for an IT file.
34 */
25#define HEADER_SIZE 0xD0 35#define HEADER_SIZE 0xD0
26 36
27struct header 37
38/**
39 * Header of an IT file.
40 */
41struct Header
28{ 42{
29 char magicid[4]; 43 char magicid[4];
30 char title[26]; 44 char title[26];
@@ -39,65 +53,68 @@ struct header
39 char special[2]; 53 char special[2];
40}; 54};
41 55
42/* "extract" keyword from an Impulse Tracker module 56
57/**
58 * extract meta data from an Impulse Tracker module
43 * 59 *
44 * ITTECH.TXT as taken from IT 2.14p5 was used, 60 * ITTECH.TXT as taken from IT 2.14p5 was used, while this piece of
45 * while this piece of software was originally 61 * software was originally written.
46 * written.
47 * 62 *
63 * @param ec extraction context
48 */ 64 */
49int 65void
50EXTRACTOR_it_extract (const char *data, 66EXTRACTOR_it_extract_method (struct EXTRACTOR_ExtractContext *ec)
51 size_t size,
52 EXTRACTOR_MetaDataProcessor proc,
53 void *proc_cls,
54 const char *options)
55{ 67{
68 void *data;
56 char title[27]; 69 char title[27];
57 char itversion[8]; 70 char itversion[8];
58 struct header *head; 71 const struct Header *head;
59 72
60 /* Check header size */ 73 if (HEADER_SIZE >
61 if (size < HEADER_SIZE) 74 ec->read (ec->cls,
62 return 0; 75 &data,
63 head = (struct header *) data; 76 HEADER_SIZE))
77 return;
78 head = (struct Header *) data;
64 /* Check "magic" id bytes */ 79 /* Check "magic" id bytes */
65 if (memcmp (head->magicid, "IMPM", 4)) 80 if (memcmp (head->magicid, "IMPM", 4))
66 return 0; 81 return;
67 /* Mime-type */ 82 /* Mime-type */
68 if (0 != proc (proc_cls, 83 if (0 != ec->proc (ec->cls,
69 "it", 84 "it",
70 EXTRACTOR_METATYPE_MIMETYPE, 85 EXTRACTOR_METATYPE_MIMETYPE,
71 EXTRACTOR_METAFORMAT_UTF8, 86 EXTRACTOR_METAFORMAT_UTF8,
72 "text/plain", 87 "text/plain",
73 "audio/x-it", 88 "audio/x-it",
74 strlen("audio/x-it")+1)) 89 strlen ("audio/x-it") + 1))
75 return 1; 90 return;
76 91
77 /* Version of Tracker */ 92 /* Version of Tracker */
78 snprintf (itversion, 93 snprintf (itversion,
79 sizeof (itversion), 94 sizeof (itversion),
80 "%d.%d", 95 "%d.%d",
81 (head->version[0]& 0x01),head->version[1]); 96 (head->version[0] & 0x01),
82 if (0 != proc (proc_cls, 97 head->version[1]);
83 "it", 98 if (0 != ec->proc (ec->cls,
84 EXTRACTOR_METATYPE_FORMAT_VERSION, 99 "it",
85 EXTRACTOR_METAFORMAT_C_STRING, 100 EXTRACTOR_METATYPE_FORMAT_VERSION,
86 "text/plain", 101 EXTRACTOR_METAFORMAT_C_STRING,
87 itversion, 102 "text/plain",
88 strlen(itversion)+1)) 103 itversion,
89 return 1; 104 strlen (itversion) + 1))
105 return;
90 106
91 /* Song title */ 107 /* Song title */
92 memcpy (&title, head->title, 26); 108 memcpy (&title, head->title, 26);
93 title[26] = '\0'; 109 title[26] = '\0';
94 if (0 != proc (proc_cls, 110 if (0 != ec->proc (ec->cls,
95 "it", 111 "it",
96 EXTRACTOR_METATYPE_TITLE, 112 EXTRACTOR_METATYPE_TITLE,
97 EXTRACTOR_METAFORMAT_C_STRING, 113 EXTRACTOR_METAFORMAT_C_STRING,
98 "text/plain", 114 "text/plain",
99 title, 115 title,
100 strlen(title)+1)) 116 strlen (title) + 1))
101 return 1; 117 return;
102 return 0;
103} 118}
119
120/* end of it_extractor.c */
diff --git a/src/plugins/xm_extractor.c b/src/plugins/xm_extractor.c
index 7ac94f4..13050b6 100644
--- a/src/plugins/xm_extractor.c
+++ b/src/plugins/xm_extractor.c
@@ -31,7 +31,7 @@
31/** 31/**
32 * Header of an XM file. 32 * Header of an XM file.
33 */ 33 */
34struct header 34struct Header
35{ 35{
36 char magicid[17]; 36 char magicid[17];
37 char title[20]; 37 char title[20];
@@ -64,15 +64,15 @@ void
64EXTRACTOR_xm_extract_method (struct EXTRACTOR_ExtractContext *ec) 64EXTRACTOR_xm_extract_method (struct EXTRACTOR_ExtractContext *ec)
65{ 65{
66 void *data; 66 void *data;
67 const struct header *head; 67 const struct Header *head;
68 char title[21]; 68 char title[21];
69 char tracker[21]; 69 char tracker[21];
70 char xmversion[8]; 70 char xmversion[8];
71 71
72 if (sizeof (struct header) > 72 if (sizeof (struct Header) >
73 ec->read (ec->cls, 73 ec->read (ec->cls,
74 &data, 74 &data,
75 sizeof (struct header))) 75 sizeof (struct Header)))
76 return; 76 return;
77 head = data; 77 head = data;
78 /* Check "magic" id bytes */ 78 /* Check "magic" id bytes */