2
* This file is part of libextractor.
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
7
* by the Free Software Foundation; either version 2, or (at your
8
* option) any later version.
10
* libextractor is distributed in the hope that it will be useful, but
11
* WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
* General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with libextractor; see the file COPYING. If not, write to the
17
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18
* Boston, MA 02111-1307, USA.
23
#include "extractor.h"
26
#define HEADER_SIZE 64
38
static struct EXTRACTOR_Keywords *addkword
39
(EXTRACTOR_KeywordList * oldhead,
40
const char *phrase, EXTRACTOR_KeywordType type)
42
EXTRACTOR_KeywordList *keyword;
44
keyword = malloc (sizeof (EXTRACTOR_KeywordList));
45
keyword->next = oldhead;
46
keyword->keyword = strdup (phrase);
47
keyword->keywordType = type;
52
/* "extract" keyword from an Extended Module
54
* The XM module format description for XM files
55
* version $0104 that was written by Mr.H of Triton
56
* in 1994 was used, while this piece of software
57
* was originally written.
60
struct EXTRACTOR_Keywords *libextractor_xm_extract
61
(const char *filename,
62
char *data, size_t size, struct EXTRACTOR_Keywords *prev)
69
/* Check header size */
71
if (size < HEADER_SIZE)
76
head = (struct header *) data;
78
/* Check "magic" id bytes */
80
if (memcmp (head->magicid, "Extended Module: ", 17))
87
prev = addkword (prev, "audio/x-xm", EXTRACTOR_MIMETYPE);
89
/* Version of Tracker */
91
sprintf (xmversion, "%d.%d", head->version[1],head->version[0]);
92
prev = addkword (prev, xmversion, EXTRACTOR_FORMAT_VERSION);
96
memcpy (&title, head->title, 20);
98
prev = addkword (prev, title, EXTRACTOR_TITLE);
100
/* software used for creating the data */
102
memcpy (&tracker, head->tracker, 20);
104
prev = addkword (prev, tracker, EXTRACTOR_SOFTWARE);