"Fossies" - the Fresh Open Source Software Archive 
Member "libextractor-1.11/src/plugins/it_extractor.c" (30 Jan 2021, 3166 Bytes) of package /linux/privat/libextractor-1.11.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
For more information about "it_extractor.c" see the
Fossies "Dox" file reference documentation and the last
Fossies "Diffs" side-by-side code changes report:
1.6_vs_1.7.
1 /*
2 * This file is part of libextractor.
3 * Copyright (C) 2008 Toni Ruottu
4 *
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 3, or (at your
8 * option) any later version.
9 *
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.
14 *
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., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 *
20 */
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 */
27 #include "platform.h"
28 #include "extractor.h"
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 */
35 #define HEADER_SIZE 0xD0
36
37
38 /**
39 * Header of an IT file.
40 */
41 struct Header
42 {
43 char magicid[4];
44 char title[26];
45 char hilight[2];
46 char orders[2];
47 char instruments[2];
48 char samples[2];
49 char patterns[2];
50 char version[2];
51 char compatible[2];
52 char flags[2];
53 char special[2];
54 };
55
56
57 /**
58 * extract meta data from an Impulse Tracker module
59 *
60 * ITTECH.TXT as taken from IT 2.14p5 was used, while this piece of
61 * software was originally written.
62 *
63 * @param ec extraction context
64 */
65 void
66 EXTRACTOR_it_extract_method (struct EXTRACTOR_ExtractContext *ec)
67 {
68 void *data;
69 char title[27];
70 char itversion[8];
71 const struct Header *head;
72
73 if ((ssize_t) HEADER_SIZE >
74 ec->read (ec->cls,
75 &data,
76 HEADER_SIZE))
77 return;
78 head = (struct Header *) data;
79 /* Check "magic" id bytes */
80 if (memcmp (head->magicid, "IMPM", 4))
81 return;
82 /* Mime-type */
83 if (0 != ec->proc (ec->cls,
84 "it",
85 EXTRACTOR_METATYPE_MIMETYPE,
86 EXTRACTOR_METAFORMAT_UTF8,
87 "text/plain",
88 "audio/x-mod",
89 strlen ("audio/x-mod") + 1))
90 return;
91
92 /* Version of Tracker */
93 snprintf (itversion,
94 sizeof (itversion),
95 "%d.%d",
96 (head->version[0] & 0x01),
97 head->version[1]);
98 if (0 != ec->proc (ec->cls,
99 "it",
100 EXTRACTOR_METATYPE_FORMAT_VERSION,
101 EXTRACTOR_METAFORMAT_C_STRING,
102 "text/plain",
103 itversion,
104 strlen (itversion) + 1))
105 return;
106
107 /* Song title */
108 memcpy (&title, head->title, 26);
109 title[26] = '\0';
110 if (0 != ec->proc (ec->cls,
111 "it",
112 EXTRACTOR_METATYPE_TITLE,
113 EXTRACTOR_METAFORMAT_C_STRING,
114 "text/plain",
115 title,
116 strlen (title) + 1))
117 return;
118 }
119
120
121 /* end of it_extractor.c */