diff options
Diffstat (limited to 'src/plugins')
81 files changed, 10686 insertions, 10085 deletions
diff --git a/src/plugins/archive_extractor.c b/src/plugins/archive_extractor.c index 7a80ac5..6d413de 100644 --- a/src/plugins/archive_extractor.c +++ b/src/plugins/archive_extractor.c | |||
@@ -36,9 +36,9 @@ | |||
36 | * @return number of bytes read | 36 | * @return number of bytes read |
37 | */ | 37 | */ |
38 | static ssize_t | 38 | static ssize_t |
39 | read_cb (struct archive *a, | 39 | read_cb (struct archive *a, |
40 | void *client_data, | 40 | void *client_data, |
41 | const void **buff) | 41 | const void **buff) |
42 | { | 42 | { |
43 | struct EXTRACTOR_ExtractContext *ec = client_data; | 43 | struct EXTRACTOR_ExtractContext *ec = client_data; |
44 | ssize_t ret; | 44 | ssize_t ret; |
@@ -71,9 +71,9 @@ read_cb (struct archive *a, | |||
71 | * @return number of bytes skipped | 71 | * @return number of bytes skipped |
72 | */ | 72 | */ |
73 | static __LA_INT64_T | 73 | static __LA_INT64_T |
74 | skip_cb (struct archive *a, | 74 | skip_cb (struct archive *a, |
75 | void *client_data, | 75 | void *client_data, |
76 | __LA_INT64_T request) | 76 | __LA_INT64_T request) |
77 | { | 77 | { |
78 | struct EXTRACTOR_ExtractContext *ec = client_data; | 78 | struct EXTRACTOR_ExtractContext *ec = client_data; |
79 | 79 | ||
@@ -84,11 +84,11 @@ skip_cb (struct archive *a, | |||
84 | 84 | ||
85 | 85 | ||
86 | /** | 86 | /** |
87 | * Main entry method for the ARCHIVE extraction plugin. | 87 | * Main entry method for the ARCHIVE extraction plugin. |
88 | * | 88 | * |
89 | * @param ec extraction context provided to the plugin | 89 | * @param ec extraction context provided to the plugin |
90 | */ | 90 | */ |
91 | void | 91 | void |
92 | EXTRACTOR_archive_extract_method (struct EXTRACTOR_ExtractContext *ec) | 92 | EXTRACTOR_archive_extract_method (struct EXTRACTOR_ExtractContext *ec) |
93 | { | 93 | { |
94 | struct archive *a; | 94 | struct archive *a; |
@@ -105,41 +105,41 @@ EXTRACTOR_archive_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
105 | archive_read_support_compression_all (a); | 105 | archive_read_support_compression_all (a); |
106 | #endif | 106 | #endif |
107 | archive_read_support_format_all (a); | 107 | archive_read_support_format_all (a); |
108 | if(archive_read_open2 (a, ec, NULL, &read_cb, &skip_cb, NULL)!= ARCHIVE_OK) | 108 | if (archive_read_open2 (a, ec, NULL, &read_cb, &skip_cb, NULL)!= ARCHIVE_OK) |
109 | return; | 109 | return; |
110 | 110 | ||
111 | while (ARCHIVE_OK == archive_read_next_header(a, &entry)) | 111 | while (ARCHIVE_OK == archive_read_next_header (a, &entry)) |
112 | { | 112 | { |
113 | if ( (NULL == format) && | 113 | if ( (NULL == format) && |
114 | (NULL != (fname = archive_format_name (a))) ) | 114 | (NULL != (fname = archive_format_name (a))) ) |
115 | format = strdup (fname); | 115 | format = strdup (fname); |
116 | s = archive_entry_pathname (entry); | 116 | s = archive_entry_pathname (entry); |
117 | if (0 != ec->proc (ec->cls, | 117 | if (0 != ec->proc (ec->cls, |
118 | "tar", | 118 | "tar", |
119 | EXTRACTOR_METATYPE_FILENAME, | 119 | EXTRACTOR_METATYPE_FILENAME, |
120 | EXTRACTOR_METAFORMAT_UTF8, | 120 | EXTRACTOR_METAFORMAT_UTF8, |
121 | "text/plain", | 121 | "text/plain", |
122 | s, strlen (s) + 1)) | 122 | s, strlen (s) + 1)) |
123 | break; | 123 | break; |
124 | } | 124 | } |
125 | #if ARCHIVE_VERSION_NUMBER >= 3000000 | 125 | #if ARCHIVE_VERSION_NUMBER >= 3000000 |
126 | archive_read_free (a); | 126 | archive_read_free (a); |
127 | #else | 127 | #else |
128 | archive_read_finish (a); | 128 | archive_read_finish (a); |
129 | #endif | 129 | #endif |
130 | if (NULL != format) | 130 | if (NULL != format) |
131 | { | ||
132 | if (0 != ec->proc (ec->cls, | ||
133 | "tar", | ||
134 | EXTRACTOR_METATYPE_FORMAT, | ||
135 | EXTRACTOR_METAFORMAT_UTF8, | ||
136 | "text/plain", format, strlen (format) + 1)) | ||
131 | { | 137 | { |
132 | if (0 != ec->proc (ec->cls, | ||
133 | "tar", | ||
134 | EXTRACTOR_METATYPE_FORMAT, | ||
135 | EXTRACTOR_METAFORMAT_UTF8, | ||
136 | "text/plain", format, strlen (format) + 1)) | ||
137 | { | ||
138 | free (format); | ||
139 | return; | ||
140 | } | ||
141 | free (format); | 138 | free (format); |
139 | return; | ||
142 | } | 140 | } |
141 | free (format); | ||
142 | } | ||
143 | } | 143 | } |
144 | 144 | ||
145 | 145 | ||
diff --git a/src/plugins/deb_extractor.c b/src/plugins/deb_extractor.c index 2eb0028..16c6285 100644 --- a/src/plugins/deb_extractor.c +++ b/src/plugins/deb_extractor.c | |||
@@ -122,8 +122,8 @@ static struct Matches tmap[] = { | |||
122 | static int | 122 | static int |
123 | processControl (const char *data, | 123 | processControl (const char *data, |
124 | const size_t size, | 124 | const size_t size, |
125 | EXTRACTOR_MetaDataProcessor proc, | 125 | EXTRACTOR_MetaDataProcessor proc, |
126 | void *proc_cls) | 126 | void *proc_cls) |
127 | { | 127 | { |
128 | size_t pos; | 128 | size_t pos; |
129 | char *key; | 129 | char *key; |
@@ -134,49 +134,49 @@ processControl (const char *data, | |||
134 | 134 | ||
135 | pos = 0; | 135 | pos = 0; |
136 | while (pos < size) | 136 | while (pos < size) |
137 | { | 137 | { |
138 | for (colon = pos; ':' != data[colon]; colon++) | 138 | for (colon = pos; ':' != data[colon]; colon++) |
139 | if ((colon > size) || ('\n' == data[colon])) | 139 | if ((colon > size) || ('\n' == data[colon])) |
140 | return 0; | 140 | return 0; |
141 | colon++; | ||
142 | while ((colon < size) && (isspace ((unsigned char) data[colon]))) | ||
141 | colon++; | 143 | colon++; |
142 | while ((colon < size) && (isspace ((unsigned char) data[colon]))) | 144 | eol = colon; |
143 | colon++; | 145 | while ((eol < size) && |
144 | eol = colon; | 146 | (('\n' != data[eol]) || |
145 | while ((eol < size) && | 147 | ((eol + 1 < size) && (' ' == data[eol + 1])))) |
146 | (('\n' != data[eol]) || | 148 | eol++; |
147 | ((eol + 1 < size) && (' ' == data[eol + 1])))) | 149 | if ((eol == colon) || (eol > size)) |
148 | eol++; | 150 | return 0; |
149 | if ((eol == colon) || (eol > size)) | 151 | if (NULL == (key = stndup (&data[pos], colon - pos))) |
152 | return 0; | ||
153 | for (i = 0; NULL != tmap[i].text; i++) | ||
154 | { | ||
155 | if (0 != strcmp (key, tmap[i].text)) | ||
156 | continue; | ||
157 | if (NULL == (val = stndup (&data[colon], eol - colon))) | ||
158 | { | ||
159 | free (key); | ||
150 | return 0; | 160 | return 0; |
151 | if (NULL == (key = stndup (&data[pos], colon - pos))) | 161 | } |
152 | return 0; | 162 | if (0 != proc (proc_cls, |
153 | for (i = 0; NULL != tmap[i].text; i++) | 163 | "deb", |
154 | { | 164 | tmap[i].type, |
155 | if (0 != strcmp (key, tmap[i].text)) | 165 | EXTRACTOR_METAFORMAT_UTF8, |
156 | continue; | 166 | "text/plain", |
157 | if (NULL == (val = stndup (&data[colon], eol - colon))) | 167 | val, |
158 | { | 168 | strlen (val) + 1)) |
159 | free (key); | 169 | { |
160 | return 0; | 170 | free (val); |
161 | } | 171 | free (key); |
162 | if (0 != proc (proc_cls, | 172 | return 1; |
163 | "deb", | 173 | } |
164 | tmap[i].type, | 174 | free (val); |
165 | EXTRACTOR_METAFORMAT_UTF8, | 175 | break; |
166 | "text/plain", | ||
167 | val, | ||
168 | strlen(val) + 1)) | ||
169 | { | ||
170 | free (val); | ||
171 | free (key); | ||
172 | return 1; | ||
173 | } | ||
174 | free (val); | ||
175 | break; | ||
176 | } | ||
177 | free (key); | ||
178 | pos = eol + 1; | ||
179 | } | 176 | } |
177 | free (key); | ||
178 | pos = eol + 1; | ||
179 | } | ||
180 | return 0; | 180 | return 0; |
181 | } | 181 | } |
182 | 182 | ||
@@ -291,9 +291,9 @@ struct USTarHeader | |||
291 | */ | 291 | */ |
292 | static int | 292 | static int |
293 | processControlTar (const char *data, | 293 | processControlTar (const char *data, |
294 | size_t size, | 294 | size_t size, |
295 | EXTRACTOR_MetaDataProcessor proc, | 295 | EXTRACTOR_MetaDataProcessor proc, |
296 | void *proc_cls) | 296 | void *proc_cls) |
297 | { | 297 | { |
298 | struct TarHeader *tar; | 298 | struct TarHeader *tar; |
299 | struct USTarHeader *ustar; | 299 | struct USTarHeader *ustar; |
@@ -301,42 +301,42 @@ processControlTar (const char *data, | |||
301 | 301 | ||
302 | pos = 0; | 302 | pos = 0; |
303 | while (pos + sizeof (struct TarHeader) < size) | 303 | while (pos + sizeof (struct TarHeader) < size) |
304 | { | ||
305 | unsigned long long fsize; | ||
306 | char buf[13]; | ||
307 | |||
308 | tar = (struct TarHeader *) &data[pos]; | ||
309 | if (pos + sizeof (struct USTarHeader) < size) | ||
304 | { | 310 | { |
305 | unsigned long long fsize; | 311 | ustar = (struct USTarHeader *) &data[pos]; |
306 | char buf[13]; | 312 | if (0 == strncmp ("ustar", &ustar->magic[0], strlen ("ustar"))) |
307 | 313 | pos += 512; /* sizeof (struct USTarHeader); */ | |
308 | tar = (struct TarHeader *) & data[pos]; | ||
309 | if (pos + sizeof (struct USTarHeader) < size) | ||
310 | { | ||
311 | ustar = (struct USTarHeader *) & data[pos]; | ||
312 | if (0 == strncmp ("ustar", &ustar->magic[0], strlen ("ustar"))) | ||
313 | pos += 512; /* sizeof (struct USTarHeader); */ | ||
314 | else | ||
315 | pos += 257; /* sizeof (struct TarHeader); minus gcc alignment... */ | ||
316 | } | ||
317 | else | 314 | else |
318 | { | 315 | pos += 257; /* sizeof (struct TarHeader); minus gcc alignment... */ |
319 | pos += 257; /* sizeof (struct TarHeader); minus gcc alignment... */ | 316 | } |
320 | } | 317 | else |
318 | { | ||
319 | pos += 257; /* sizeof (struct TarHeader); minus gcc alignment... */ | ||
320 | } | ||
321 | 321 | ||
322 | memcpy (buf, &tar->filesize[0], 12); | 322 | memcpy (buf, &tar->filesize[0], 12); |
323 | buf[12] = '\0'; | 323 | buf[12] = '\0'; |
324 | if (1 != sscanf (buf, "%12llo", &fsize)) /* octal! Yuck yuck! */ | 324 | if (1 != sscanf (buf, "%12llo", &fsize)) /* octal! Yuck yuck! */ |
325 | return 0; | 325 | return 0; |
326 | if ((pos + fsize > size) || (fsize > size) || (pos + fsize < pos)) | 326 | if ((pos + fsize > size) || (fsize > size) || (pos + fsize < pos)) |
327 | return 0; | 327 | return 0; |
328 | 328 | ||
329 | if (0 == strncmp (&tar->name[0], "./control", strlen ("./control"))) | 329 | if (0 == strncmp (&tar->name[0], "./control", strlen ("./control"))) |
330 | { | 330 | { |
331 | /* found the 'control' file we were looking for */ | 331 | /* found the 'control' file we were looking for */ |
332 | return processControl (&data[pos], fsize, proc, proc_cls); | 332 | return processControl (&data[pos], fsize, proc, proc_cls); |
333 | } | ||
334 | if (0 != (fsize & 511)) | ||
335 | fsize = (fsize | 511) + 1; /* round up! */ | ||
336 | if (pos + fsize < pos) | ||
337 | return 0; | ||
338 | pos += fsize; | ||
339 | } | 333 | } |
334 | if (0 != (fsize & 511)) | ||
335 | fsize = (fsize | 511) + 1; /* round up! */ | ||
336 | if (pos + fsize < pos) | ||
337 | return 0; | ||
338 | pos += fsize; | ||
339 | } | ||
340 | return 0; | 340 | return 0; |
341 | } | 341 | } |
342 | 342 | ||
@@ -371,42 +371,43 @@ processControlTGZ (struct EXTRACTOR_ExtractContext *ec, | |||
371 | return 0; | 371 | return 0; |
372 | off = 0; | 372 | off = 0; |
373 | while (off < size) | 373 | while (off < size) |
374 | { | 374 | { |
375 | if (0 >= (sret = ec->read (ec->cls, &data, size - off))) | 375 | if (0 >= (sret = ec->read (ec->cls, &data, size - off))) |
376 | { | ||
377 | free (cdata); | ||
378 | return 0; | ||
379 | } | ||
380 | memcpy (&cdata[off], | ||
381 | data, | ||
382 | sret); | ||
383 | off += sret; | ||
384 | } | ||
385 | bufSize = cdata[size - 4] + (cdata[size - 3] << 8) + (cdata[size - 2] << 16) + (cdata[size - 1] << 24); | ||
386 | if (bufSize > MAX_CONTROL_SIZE) | ||
387 | { | 376 | { |
388 | free (cdata); | 377 | free (cdata); |
389 | return 0; | 378 | return 0; |
390 | } | 379 | } |
380 | memcpy (&cdata[off], | ||
381 | data, | ||
382 | sret); | ||
383 | off += sret; | ||
384 | } | ||
385 | bufSize = cdata[size - 4] + (cdata[size - 3] << 8) + (cdata[size - 2] << 16) | ||
386 | + (cdata[size - 1] << 24); | ||
387 | if (bufSize > MAX_CONTROL_SIZE) | ||
388 | { | ||
389 | free (cdata); | ||
390 | return 0; | ||
391 | } | ||
391 | if (NULL == (buf = malloc (bufSize))) | 392 | if (NULL == (buf = malloc (bufSize))) |
392 | { | 393 | { |
393 | free (cdata); | 394 | free (cdata); |
394 | return 0; | 395 | return 0; |
395 | } | 396 | } |
396 | ret = 0; | 397 | ret = 0; |
397 | memset (&strm, 0, sizeof (z_stream)); | 398 | memset (&strm, 0, sizeof (z_stream)); |
398 | strm.next_in = (Bytef *) data; | 399 | strm.next_in = (Bytef *) data; |
399 | strm.avail_in = size; | 400 | strm.avail_in = size; |
400 | if (Z_OK == inflateInit2 (&strm, 15 + 32)) | 401 | if (Z_OK == inflateInit2 (&strm, 15 + 32)) |
401 | { | 402 | { |
402 | strm.next_out = (Bytef *) buf; | 403 | strm.next_out = (Bytef *) buf; |
403 | strm.avail_out = bufSize; | 404 | strm.avail_out = bufSize; |
404 | inflate (&strm, Z_FINISH); | 405 | inflate (&strm, Z_FINISH); |
405 | if (strm.total_out > 0) | 406 | if (strm.total_out > 0) |
406 | ret = processControlTar (buf, strm.total_out, | 407 | ret = processControlTar (buf, strm.total_out, |
407 | ec->proc, ec->cls); | 408 | ec->proc, ec->cls); |
408 | inflateEnd (&strm); | 409 | inflateEnd (&strm); |
409 | } | 410 | } |
410 | free (buf); | 411 | free (buf); |
411 | free (cdata); | 412 | free (cdata); |
412 | return ret; | 413 | return ret; |
@@ -481,49 +482,50 @@ EXTRACTOR_deb_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
481 | return; | 482 | return; |
482 | pos = 8; | 483 | pos = 8; |
483 | while (pos + sizeof (struct ObjectHeader) < fsize) | 484 | while (pos + sizeof (struct ObjectHeader) < fsize) |
485 | { | ||
486 | if (pos != | ||
487 | ec->seek (ec->cls, pos, SEEK_SET)) | ||
488 | return; | ||
489 | if (sizeof (struct ObjectHeader) != | ||
490 | ec->read (ec->cls, &data, sizeof (struct ObjectHeader))) | ||
491 | return; | ||
492 | hdr = data; | ||
493 | if (0 != strncmp (&hdr->trailer[0], "`\n", 2)) | ||
494 | return; | ||
495 | memcpy (buf, &hdr->filesize[0], 10); | ||
496 | buf[10] = '\0'; | ||
497 | if (1 != sscanf (buf, "%10llu", &csize)) | ||
498 | return; | ||
499 | pos += sizeof (struct ObjectHeader); | ||
500 | if ((pos + csize > fsize) || (csize > fsize) || (pos + csize < pos)) | ||
501 | return; | ||
502 | if (0 == strncmp (&hdr->name[0], | ||
503 | "control.tar.gz", | ||
504 | strlen ("control.tar.gz"))) | ||
484 | { | 505 | { |
485 | if (pos != | 506 | if (0 != processControlTGZ (ec, |
486 | ec->seek (ec->cls, pos, SEEK_SET)) | 507 | csize)) |
487 | return; | ||
488 | if (sizeof (struct ObjectHeader) != | ||
489 | ec->read (ec->cls, &data, sizeof (struct ObjectHeader))) | ||
490 | return; | ||
491 | hdr = data; | ||
492 | if (0 != strncmp (&hdr->trailer[0], "`\n", 2)) | ||
493 | return; | 508 | return; |
494 | memcpy (buf, &hdr->filesize[0], 10); | 509 | done++; |
495 | buf[10] = '\0'; | 510 | } |
496 | if (1 != sscanf (buf, "%10llu", &csize)) | 511 | if (0 == strncmp (&hdr->name[0], |
497 | return; | 512 | "debian-binary", strlen ("debian-binary"))) |
498 | pos += sizeof (struct ObjectHeader); | 513 | { |
499 | if ((pos + csize > fsize) || (csize > fsize) || (pos + csize < pos)) | 514 | if (0 != ec->proc (ec->cls, |
515 | "deb", | ||
516 | EXTRACTOR_METATYPE_MIMETYPE, | ||
517 | EXTRACTOR_METAFORMAT_UTF8, | ||
518 | "text/plain", | ||
519 | "application/x-debian-package", | ||
520 | strlen ("application/x-debian-package") + 1)) | ||
500 | return; | 521 | return; |
501 | if (0 == strncmp (&hdr->name[0], | 522 | done++; |
502 | "control.tar.gz", | ||
503 | strlen ("control.tar.gz"))) | ||
504 | { | ||
505 | if (0 != processControlTGZ (ec, | ||
506 | csize)) | ||
507 | return; | ||
508 | done++; | ||
509 | } | ||
510 | if (0 == strncmp (&hdr->name[0], | ||
511 | "debian-binary", strlen ("debian-binary"))) | ||
512 | { | ||
513 | if (0 != ec->proc (ec->cls, | ||
514 | "deb", | ||
515 | EXTRACTOR_METATYPE_MIMETYPE, | ||
516 | EXTRACTOR_METAFORMAT_UTF8, | ||
517 | "text/plain", | ||
518 | "application/x-debian-package", | ||
519 | strlen ("application/x-debian-package")+1)) | ||
520 | return; | ||
521 | done++; | ||
522 | } | ||
523 | pos += csize; | ||
524 | if (2 == done) | ||
525 | break; /* no need to process the rest of the archive */ | ||
526 | } | 523 | } |
524 | pos += csize; | ||
525 | if (2 == done) | ||
526 | break; /* no need to process the rest of the archive */ | ||
527 | } | ||
527 | } | 528 | } |
528 | 529 | ||
530 | |||
529 | /* end of deb_extractor.c */ | 531 | /* end of deb_extractor.c */ |
diff --git a/src/plugins/dvi_extractor.c b/src/plugins/dvi_extractor.c index e3aa450..4e52150 100644 --- a/src/plugins/dvi_extractor.c +++ b/src/plugins/dvi_extractor.c | |||
@@ -53,12 +53,12 @@ static struct Matches tmap[] = { | |||
53 | { "/Keywords (", EXTRACTOR_METATYPE_KEYWORDS }, | 53 | { "/Keywords (", EXTRACTOR_METATYPE_KEYWORDS }, |
54 | { "/Creator (", EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE }, | 54 | { "/Creator (", EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE }, |
55 | { "/Producer (", EXTRACTOR_METATYPE_PRODUCED_BY_SOFTWARE }, | 55 | { "/Producer (", EXTRACTOR_METATYPE_PRODUCED_BY_SOFTWARE }, |
56 | { NULL, 0 } | 56 | { NULL, 0 } |
57 | }; | 57 | }; |
58 | 58 | ||
59 | 59 | ||
60 | /** | 60 | /** |
61 | * Parse a "ZZZ" tag. Specifically, the data may contain a | 61 | * Parse a "ZZZ" tag. Specifically, the data may contain a |
62 | * postscript dictionary with metadata. | 62 | * postscript dictionary with metadata. |
63 | * | 63 | * |
64 | * @param data overall input stream | 64 | * @param data overall input stream |
@@ -71,8 +71,8 @@ static struct Matches tmap[] = { | |||
71 | static int | 71 | static int |
72 | parseZZZ (const char *data, | 72 | parseZZZ (const char *data, |
73 | size_t pos, size_t len, | 73 | size_t pos, size_t len, |
74 | EXTRACTOR_MetaDataProcessor proc, | 74 | EXTRACTOR_MetaDataProcessor proc, |
75 | void *proc_cls) | 75 | void *proc_cls) |
76 | { | 76 | { |
77 | size_t slen; | 77 | size_t slen; |
78 | size_t end; | 78 | size_t end; |
@@ -85,37 +85,37 @@ parseZZZ (const char *data, | |||
85 | return 0; | 85 | return 0; |
86 | pos += slen; | 86 | pos += slen; |
87 | while (pos < end) | 87 | while (pos < end) |
88 | { | ||
89 | for (i = 0; NULL != tmap[i].text; i++) | ||
88 | { | 90 | { |
89 | for (i = 0; NULL != tmap[i].text; i++) | 91 | slen = strlen (tmap[i].text); |
90 | { | 92 | if ( (pos + slen > end) || |
91 | slen = strlen (tmap[i].text); | 93 | (0 != strncmp (&data[pos], tmap[i].text, slen)) ) |
92 | if ( (pos + slen > end) || | 94 | continue; |
93 | (0 != strncmp (&data[pos], tmap[i].text, slen)) ) | 95 | pos += slen; |
94 | continue; | 96 | slen = pos; |
95 | pos += slen; | 97 | while ((slen < end) && (data[slen] != ')')) |
96 | slen = pos; | 98 | slen++; |
97 | while ((slen < end) && (data[slen] != ')')) | 99 | slen = slen - pos; |
98 | slen++; | 100 | { |
99 | slen = slen - pos; | 101 | char value[slen + 1]; |
100 | { | 102 | |
101 | char value[slen + 1]; | 103 | value[slen] = '\0'; |
102 | 104 | memcpy (value, &data[pos], slen); | |
103 | value[slen] = '\0'; | 105 | if (0 != proc (proc_cls, |
104 | memcpy (value, &data[pos], slen); | 106 | "dvi", |
105 | if (0 != proc (proc_cls, | 107 | tmap[i].type, |
106 | "dvi", | 108 | EXTRACTOR_METAFORMAT_C_STRING, |
107 | tmap[i].type, | 109 | "text/plain", |
108 | EXTRACTOR_METAFORMAT_C_STRING, | 110 | value, |
109 | "text/plain", | 111 | slen + 1)) |
110 | value, | 112 | return 1; |
111 | slen + 1)) | 113 | } |
112 | return 1; | 114 | pos += slen + 1; |
113 | } | 115 | break; |
114 | pos += slen + 1; | ||
115 | break; | ||
116 | } | ||
117 | pos++; | ||
118 | } | 116 | } |
117 | pos++; | ||
118 | } | ||
119 | return 0; | 119 | return 0; |
120 | } | 120 | } |
121 | 121 | ||
@@ -153,7 +153,7 @@ getShortAt (const void *data) | |||
153 | 153 | ||
154 | 154 | ||
155 | /** | 155 | /** |
156 | * Main entry method for the 'application/x-dvi' extraction plugin. | 156 | * Main entry method for the 'application/x-dvi' extraction plugin. |
157 | * | 157 | * |
158 | * @param ec extraction context provided to the plugin | 158 | * @param ec extraction context provided to the plugin |
159 | */ | 159 | */ |
@@ -171,7 +171,7 @@ EXTRACTOR_dvi_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
171 | uint64_t size; | 171 | uint64_t size; |
172 | uint64_t off; | 172 | uint64_t off; |
173 | ssize_t iret; | 173 | ssize_t iret; |
174 | 174 | ||
175 | if (40 >= (iret = ec->read (ec->cls, &buf, 1024))) | 175 | if (40 >= (iret = ec->read (ec->cls, &buf, 1024))) |
176 | return; | 176 | return; |
177 | data = buf; | 177 | data = buf; |
@@ -189,15 +189,15 @@ EXTRACTOR_dvi_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
189 | memcpy (data, buf, iret); | 189 | memcpy (data, buf, iret); |
190 | off = iret; | 190 | off = iret; |
191 | while (off < size) | 191 | while (off < size) |
192 | { | ||
193 | if (0 >= (iret = ec->read (ec->cls, &buf, 16 * 1024))) | ||
192 | { | 194 | { |
193 | if (0 >= (iret = ec->read (ec->cls, &buf, 16 * 1024))) | 195 | free (data); |
194 | { | 196 | return; |
195 | free (data); | ||
196 | return; | ||
197 | } | ||
198 | memcpy (&data[off], buf, iret); | ||
199 | off += iret; | ||
200 | } | 197 | } |
198 | memcpy (&data[off], buf, iret); | ||
199 | off += iret; | ||
200 | } | ||
201 | pos = size - 1; | 201 | pos = size - 1; |
202 | while ( (223 == data[pos]) && | 202 | while ( (223 == data[pos]) && |
203 | (pos > 0) ) | 203 | (pos > 0) ) |
@@ -222,28 +222,28 @@ EXTRACTOR_dvi_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
222 | opos = pos; | 222 | opos = pos; |
223 | pos = getIntAt (&data[opos + 1]); | 223 | pos = getIntAt (&data[opos + 1]); |
224 | while (1) | 224 | while (1) |
225 | { | 225 | { |
226 | if (UINT32_MAX == pos) | 226 | if (UINT32_MAX == pos) |
227 | break; | 227 | break; |
228 | if ( (pos + 45 > size) || | 228 | if ( (pos + 45 > size) || |
229 | (pos + 45 < pos) ) | 229 | (pos + 45 < pos) ) |
230 | goto CLEANUP; | 230 | goto CLEANUP; |
231 | if (data[pos] != 139) /* expect 'bop' */ | 231 | if (data[pos] != 139) /* expect 'bop' */ |
232 | goto CLEANUP; | 232 | goto CLEANUP; |
233 | pageCount++; | 233 | pageCount++; |
234 | opos = pos; | 234 | opos = pos; |
235 | pos = getIntAt (&data[opos + 41]); | 235 | pos = getIntAt (&data[opos + 41]); |
236 | if (UINT32_MAX == pos) | 236 | if (UINT32_MAX == pos) |
237 | break; | 237 | break; |
238 | if (pos >= opos) | 238 | if (pos >= opos) |
239 | goto CLEANUP; /* invalid! */ | 239 | goto CLEANUP; /* invalid! */ |
240 | } | 240 | } |
241 | /* ok, now we believe it's a dvi... */ | 241 | /* ok, now we believe it's a dvi... */ |
242 | snprintf (pages, | 242 | snprintf (pages, |
243 | sizeof (pages), | 243 | sizeof (pages), |
244 | "%u", | 244 | "%u", |
245 | pageCount); | 245 | pageCount); |
246 | if (0 != ec->proc (ec->cls, | 246 | if (0 != ec->proc (ec->cls, |
247 | "dvi", | 247 | "dvi", |
248 | EXTRACTOR_METATYPE_PAGE_COUNT, | 248 | EXTRACTOR_METATYPE_PAGE_COUNT, |
249 | EXTRACTOR_METAFORMAT_UTF8, | 249 | EXTRACTOR_METAFORMAT_UTF8, |
@@ -251,7 +251,7 @@ EXTRACTOR_dvi_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
251 | pages, | 251 | pages, |
252 | strlen (pages) + 1)) | 252 | strlen (pages) + 1)) |
253 | goto CLEANUP; | 253 | goto CLEANUP; |
254 | if (0 != ec->proc (ec->cls, | 254 | if (0 != ec->proc (ec->cls, |
255 | "dvi", | 255 | "dvi", |
256 | EXTRACTOR_METATYPE_MIMETYPE, | 256 | EXTRACTOR_METATYPE_MIMETYPE, |
257 | EXTRACTOR_METAFORMAT_UTF8, | 257 | EXTRACTOR_METAFORMAT_UTF8, |
@@ -261,10 +261,10 @@ EXTRACTOR_dvi_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
261 | goto CLEANUP; | 261 | goto CLEANUP; |
262 | { | 262 | { |
263 | char comment[klen + 1]; | 263 | char comment[klen + 1]; |
264 | 264 | ||
265 | comment[klen] = '\0'; | 265 | comment[klen] = '\0'; |
266 | memcpy (comment, &data[15], klen); | 266 | memcpy (comment, &data[15], klen); |
267 | if (0 != ec->proc (ec->cls, | 267 | if (0 != ec->proc (ec->cls, |
268 | "dvi", | 268 | "dvi", |
269 | EXTRACTOR_METATYPE_COMMENT, | 269 | EXTRACTOR_METATYPE_COMMENT, |
270 | EXTRACTOR_METAFORMAT_C_STRING, | 270 | EXTRACTOR_METAFORMAT_C_STRING, |
@@ -277,47 +277,52 @@ EXTRACTOR_dvi_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
277 | pos = opos; | 277 | pos = opos; |
278 | while ( (size >= 100) && | 278 | while ( (size >= 100) && |
279 | (pos < size - 100) ) | 279 | (pos < size - 100) ) |
280 | { | ||
281 | switch (data[pos]) | ||
280 | { | 282 | { |
281 | switch (data[pos]) | 283 | case 139: /* begin page 'bop', we typically have to skip that one to |
282 | { | ||
283 | case 139: /* begin page 'bop', we typically have to skip that one to | ||
284 | find the zzz's */ | 284 | find the zzz's */ |
285 | pos += 45; /* skip bop */ | 285 | pos += 45; /* skip bop */ |
286 | break; | 286 | break; |
287 | case 239: /* zzz1 */ | 287 | case 239: /* zzz1 */ |
288 | len = data[pos + 1]; | 288 | len = data[pos + 1]; |
289 | if ( (pos + 2 + len < size) && | 289 | if ( (pos + 2 + len < size) && |
290 | (0 != parseZZZ ((const char *) data, pos + 2, len, ec->proc, ec->cls)) ) | 290 | (0 != parseZZZ ((const char *) data, pos + 2, len, ec->proc, |
291 | goto CLEANUP; | 291 | ec->cls)) ) |
292 | pos += len + 2; | 292 | goto CLEANUP; |
293 | break; | 293 | pos += len + 2; |
294 | case 240: /* zzz2 */ | 294 | break; |
295 | len = getShortAt (&data[pos + 1]); | 295 | case 240: /* zzz2 */ |
296 | if ( (pos + 3 + len < size) && | 296 | len = getShortAt (&data[pos + 1]); |
297 | (0 != parseZZZ ((const char *) data, pos + 3, len, ec->proc, ec->cls)) ) | 297 | if ( (pos + 3 + len < size) && |
298 | goto CLEANUP; | 298 | (0 != parseZZZ ((const char *) data, pos + 3, len, ec->proc, |
299 | pos += len + 3; | 299 | ec->cls)) ) |
300 | break; | 300 | goto CLEANUP; |
301 | case 241: /* zzz3, who uses that? */ | 301 | pos += len + 3; |
302 | len = (getShortAt (&data[pos + 1])) + 65536 * data[pos + 3]; | 302 | break; |
303 | if ( (pos + 4 + len < size) && | 303 | case 241: /* zzz3, who uses that? */ |
304 | (0 != parseZZZ ((const char *) data, pos + 4, len, ec->proc, ec->cls)) ) | 304 | len = (getShortAt (&data[pos + 1])) + 65536 * data[pos + 3]; |
305 | goto CLEANUP; | 305 | if ( (pos + 4 + len < size) && |
306 | pos += len + 4; | 306 | (0 != parseZZZ ((const char *) data, pos + 4, len, ec->proc, |
307 | break; | 307 | ec->cls)) ) |
308 | case 242: /* zzz4, hurray! */ | 308 | goto CLEANUP; |
309 | len = getIntAt (&data[pos + 1]); | 309 | pos += len + 4; |
310 | if ( (pos + 1 + len < size) && | 310 | break; |
311 | (0 != parseZZZ ((const char *) data, pos + 5, len, ec->proc, ec->cls)) ) | 311 | case 242: /* zzz4, hurray! */ |
312 | goto CLEANUP; | 312 | len = getIntAt (&data[pos + 1]); |
313 | pos += len + 5; | 313 | if ( (pos + 1 + len < size) && |
314 | break; | 314 | (0 != parseZZZ ((const char *) data, pos + 5, len, ec->proc, |
315 | default: /* unsupported opcode, abort scan */ | 315 | ec->cls)) ) |
316 | goto CLEANUP; | 316 | goto CLEANUP; |
317 | } | 317 | pos += len + 5; |
318 | break; | ||
319 | default: /* unsupported opcode, abort scan */ | ||
320 | goto CLEANUP; | ||
318 | } | 321 | } |
319 | CLEANUP: | 322 | } |
323 | CLEANUP: | ||
320 | free (data); | 324 | free (data); |
321 | } | 325 | } |
322 | 326 | ||
327 | |||
323 | /* end of dvi_extractor.c */ | 328 | /* end of dvi_extractor.c */ |
diff --git a/src/plugins/flac_extractor.c b/src/plugins/flac_extractor.c index 7f04df3..2d36c56 100644 --- a/src/plugins/flac_extractor.c +++ b/src/plugins/flac_extractor.c | |||
@@ -47,9 +47,9 @@ | |||
47 | */ | 47 | */ |
48 | static FLAC__StreamDecoderReadStatus | 48 | static FLAC__StreamDecoderReadStatus |
49 | flac_read (const FLAC__StreamDecoder *decoder, | 49 | flac_read (const FLAC__StreamDecoder *decoder, |
50 | FLAC__byte buffer[], | 50 | FLAC__byte buffer[], |
51 | size_t *bytes, | 51 | size_t *bytes, |
52 | void *client_data) | 52 | void *client_data) |
53 | { | 53 | { |
54 | struct EXTRACTOR_ExtractContext *ec = client_data; | 54 | struct EXTRACTOR_ExtractContext *ec = client_data; |
55 | void *data; | 55 | void *data; |
@@ -57,15 +57,15 @@ flac_read (const FLAC__StreamDecoder *decoder, | |||
57 | 57 | ||
58 | data = NULL; | 58 | data = NULL; |
59 | ret = ec->read (ec->cls, | 59 | ret = ec->read (ec->cls, |
60 | &data, | 60 | &data, |
61 | *bytes); | 61 | *bytes); |
62 | if (-1 == ret) | 62 | if (-1 == ret) |
63 | return FLAC__STREAM_DECODER_READ_STATUS_ABORT; | 63 | return FLAC__STREAM_DECODER_READ_STATUS_ABORT; |
64 | if (0 == ret) | 64 | if (0 == ret) |
65 | { | 65 | { |
66 | errno = 0; | 66 | errno = 0; |
67 | return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM; | 67 | return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM; |
68 | } | 68 | } |
69 | memcpy (buffer, data, ret); | 69 | memcpy (buffer, data, ret); |
70 | *bytes = ret; | 70 | *bytes = ret; |
71 | errno = 0; | 71 | errno = 0; |
@@ -83,8 +83,8 @@ flac_read (const FLAC__StreamDecoder *decoder, | |||
83 | */ | 83 | */ |
84 | static FLAC__StreamDecoderSeekStatus | 84 | static FLAC__StreamDecoderSeekStatus |
85 | flac_seek (const FLAC__StreamDecoder *decoder, | 85 | flac_seek (const FLAC__StreamDecoder *decoder, |
86 | FLAC__uint64 absolute_byte_offset, | 86 | FLAC__uint64 absolute_byte_offset, |
87 | void *client_data) | 87 | void *client_data) |
88 | { | 88 | { |
89 | struct EXTRACTOR_ExtractContext *ec = client_data; | 89 | struct EXTRACTOR_ExtractContext *ec = client_data; |
90 | 90 | ||
@@ -105,14 +105,14 @@ flac_seek (const FLAC__StreamDecoder *decoder, | |||
105 | */ | 105 | */ |
106 | static FLAC__StreamDecoderTellStatus | 106 | static FLAC__StreamDecoderTellStatus |
107 | flac_tell (const FLAC__StreamDecoder *decoder, | 107 | flac_tell (const FLAC__StreamDecoder *decoder, |
108 | FLAC__uint64 *absolute_byte_offset, | 108 | FLAC__uint64 *absolute_byte_offset, |
109 | void *client_data) | 109 | void *client_data) |
110 | { | 110 | { |
111 | struct EXTRACTOR_ExtractContext *ec = client_data; | 111 | struct EXTRACTOR_ExtractContext *ec = client_data; |
112 | 112 | ||
113 | *absolute_byte_offset = ec->seek (ec->cls, | 113 | *absolute_byte_offset = ec->seek (ec->cls, |
114 | 0, | 114 | 0, |
115 | SEEK_CUR); | 115 | SEEK_CUR); |
116 | return FLAC__STREAM_DECODER_TELL_STATUS_OK; | 116 | return FLAC__STREAM_DECODER_TELL_STATUS_OK; |
117 | } | 117 | } |
118 | 118 | ||
@@ -127,8 +127,8 @@ flac_tell (const FLAC__StreamDecoder *decoder, | |||
127 | */ | 127 | */ |
128 | static FLAC__StreamDecoderLengthStatus | 128 | static FLAC__StreamDecoderLengthStatus |
129 | flac_length (const FLAC__StreamDecoder *decoder, | 129 | flac_length (const FLAC__StreamDecoder *decoder, |
130 | FLAC__uint64 *stream_length, | 130 | FLAC__uint64 *stream_length, |
131 | void *client_data) | 131 | void *client_data) |
132 | { | 132 | { |
133 | struct EXTRACTOR_ExtractContext *ec = client_data; | 133 | struct EXTRACTOR_ExtractContext *ec = client_data; |
134 | 134 | ||
@@ -147,7 +147,7 @@ flac_length (const FLAC__StreamDecoder *decoder, | |||
147 | */ | 147 | */ |
148 | static FLAC__bool | 148 | static FLAC__bool |
149 | flac_eof (const FLAC__StreamDecoder *decoder, | 149 | flac_eof (const FLAC__StreamDecoder *decoder, |
150 | void *client_data) | 150 | void *client_data) |
151 | { | 151 | { |
152 | struct EXTRACTOR_ExtractContext *ec = client_data; | 152 | struct EXTRACTOR_ExtractContext *ec = client_data; |
153 | uint64_t size; | 153 | uint64_t size; |
@@ -175,9 +175,9 @@ flac_eof (const FLAC__StreamDecoder *decoder, | |||
175 | */ | 175 | */ |
176 | static FLAC__StreamDecoderWriteStatus | 176 | static FLAC__StreamDecoderWriteStatus |
177 | flac_write (const FLAC__StreamDecoder *decoder, | 177 | flac_write (const FLAC__StreamDecoder *decoder, |
178 | const FLAC__Frame *frame, | 178 | const FLAC__Frame *frame, |
179 | const FLAC__int32 *const buffer[], | 179 | const FLAC__int32 *const buffer[], |
180 | void *client_data) | 180 | void *client_data) |
181 | { | 181 | { |
182 | return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE; | 182 | return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE; |
183 | } | 183 | } |
@@ -230,7 +230,8 @@ static struct Matches tmap[] = { | |||
230 | * @param t type of the meta data | 230 | * @param t type of the meta data |
231 | * @param s meta data value in utf8 format | 231 | * @param s meta data value in utf8 format |
232 | */ | 232 | */ |
233 | #define ADD(t,s) do { ec->proc (ec->cls, "flac", t, EXTRACTOR_METAFORMAT_UTF8, "text/plain", s, strlen (s) + 1); } while (0) | 233 | #define ADD(t,s) do { ec->proc (ec->cls, "flac", t, EXTRACTOR_METAFORMAT_UTF8, \ |
234 | "text/plain", s, strlen (s) + 1); } while (0) | ||
234 | 235 | ||
235 | 236 | ||
236 | /** | 237 | /** |
@@ -242,9 +243,9 @@ static struct Matches tmap[] = { | |||
242 | */ | 243 | */ |
243 | static char * | 244 | static char * |
244 | xstrndup (const char *s, | 245 | xstrndup (const char *s, |
245 | size_t n) | 246 | size_t n) |
246 | { | 247 | { |
247 | char * d; | 248 | char *d; |
248 | 249 | ||
249 | if (NULL == (d = malloc (n + 1))) | 250 | if (NULL == (d = malloc (n + 1))) |
250 | return NULL; | 251 | return NULL; |
@@ -274,21 +275,21 @@ check (const char *type, | |||
274 | unsigned int i; | 275 | unsigned int i; |
275 | char *tmp; | 276 | char *tmp; |
276 | 277 | ||
277 | for (i=0; NULL != tmap[i].text; i++) | 278 | for (i = 0; NULL != tmap[i].text; i++) |
278 | { | 279 | { |
279 | if ( (type_length != strlen (tmap[i].text)) || | 280 | if ( (type_length != strlen (tmap[i].text)) || |
280 | (0 != strncasecmp (tmap[i].text, | 281 | (0 != strncasecmp (tmap[i].text, |
281 | type, | 282 | type, |
282 | type_length)) ) | 283 | type_length)) ) |
283 | continue; | 284 | continue; |
284 | if (NULL == | 285 | if (NULL == |
285 | (tmp = xstrndup (value, | 286 | (tmp = xstrndup (value, |
286 | value_length))) | 287 | value_length))) |
287 | continue; | 288 | continue; |
288 | ADD (tmap[i].type, tmp); | 289 | ADD (tmap[i].type, tmp); |
289 | free (tmp); | 290 | free (tmp); |
290 | break; | 291 | break; |
291 | } | 292 | } |
292 | } | 293 | } |
293 | 294 | ||
294 | 295 | ||
@@ -301,117 +302,117 @@ check (const char *type, | |||
301 | */ | 302 | */ |
302 | static void | 303 | static void |
303 | flac_metadata (const FLAC__StreamDecoder *decoder, | 304 | flac_metadata (const FLAC__StreamDecoder *decoder, |
304 | const FLAC__StreamMetadata *metadata, | 305 | const FLAC__StreamMetadata *metadata, |
305 | void *client_data) | 306 | void *client_data) |
306 | { | 307 | { |
307 | struct EXTRACTOR_ExtractContext *ec = client_data; | 308 | struct EXTRACTOR_ExtractContext *ec = client_data; |
308 | enum EXTRACTOR_MetaType type; | 309 | enum EXTRACTOR_MetaType type; |
309 | const FLAC__StreamMetadata_VorbisComment * vc; | 310 | const FLAC__StreamMetadata_VorbisComment *vc; |
310 | unsigned int count; | 311 | unsigned int count; |
311 | const FLAC__StreamMetadata_VorbisComment_Entry * entry; | 312 | const FLAC__StreamMetadata_VorbisComment_Entry *entry; |
312 | const char * eq; | 313 | const char *eq; |
313 | unsigned int len; | 314 | unsigned int len; |
314 | unsigned int ilen; | 315 | unsigned int ilen; |
315 | char buf[128]; | 316 | char buf[128]; |
316 | 317 | ||
317 | switch (metadata->type) | 318 | switch (metadata->type) |
319 | { | ||
320 | case FLAC__METADATA_TYPE_STREAMINFO: | ||
318 | { | 321 | { |
319 | case FLAC__METADATA_TYPE_STREAMINFO: | 322 | snprintf (buf, sizeof (buf), |
320 | { | 323 | _ ("%u Hz, %u channels"), |
321 | snprintf (buf, sizeof (buf), | 324 | metadata->data.stream_info.sample_rate, |
322 | _("%u Hz, %u channels"), | 325 | metadata->data.stream_info.channels); |
323 | metadata->data.stream_info.sample_rate, | 326 | ADD (EXTRACTOR_METATYPE_RESOURCE_TYPE, buf); |
324 | metadata->data.stream_info.channels); | ||
325 | ADD (EXTRACTOR_METATYPE_RESOURCE_TYPE, buf); | ||
326 | break; | ||
327 | } | ||
328 | case FLAC__METADATA_TYPE_APPLICATION: | ||
329 | /* FIXME: could find out generator application here: | ||
330 | http://flac.sourceforge.net/api/structFLAC____StreamMetadata__Application.html and | ||
331 | http://flac.sourceforge.net/id.html | ||
332 | */ | ||
333 | break; | 327 | break; |
334 | case FLAC__METADATA_TYPE_VORBIS_COMMENT: | 328 | } |
329 | case FLAC__METADATA_TYPE_APPLICATION: | ||
330 | /* FIXME: could find out generator application here: | ||
331 | http://flac.sourceforge.net/api/structFLAC____StreamMetadata__Application.html and | ||
332 | http://flac.sourceforge.net/id.html | ||
333 | */ | ||
334 | break; | ||
335 | case FLAC__METADATA_TYPE_VORBIS_COMMENT: | ||
336 | { | ||
337 | vc = &metadata->data.vorbis_comment; | ||
338 | count = vc->num_comments; | ||
339 | while (count-- > 0) | ||
335 | { | 340 | { |
336 | vc = &metadata->data.vorbis_comment; | 341 | entry = &vc->comments[count]; |
337 | count = vc->num_comments; | 342 | eq = (const char*) entry->entry; |
338 | while (count-- > 0) | 343 | if (NULL == eq) |
339 | { | 344 | break; |
340 | entry = &vc->comments[count]; | 345 | len = entry->length; |
341 | eq = (const char*) entry->entry; | 346 | ilen = 0; |
342 | if (NULL == eq) | 347 | while ( ('=' != *eq) && ('\0' != *eq) && |
343 | break; | 348 | (ilen < len) ) |
344 | len = entry->length; | 349 | { |
345 | ilen = 0; | 350 | eq++; |
346 | while ( ('=' != *eq) && ('\0' != *eq) && | 351 | ilen++; |
347 | (ilen < len) ) | 352 | } |
348 | { | 353 | if ( ('=' != *eq) || |
349 | eq++; | 354 | (ilen == len) ) |
350 | ilen++; | 355 | break; |
351 | } | 356 | eq++; |
352 | if ( ('=' != *eq) || | 357 | check ((const char*) entry->entry, |
353 | (ilen == len) ) | 358 | ilen, |
354 | break; | 359 | eq, |
355 | eq++; | 360 | len - ilen, |
356 | check ((const char*) entry->entry, | 361 | ec); |
357 | ilen, | ||
358 | eq, | ||
359 | len - ilen, | ||
360 | ec); | ||
361 | } | ||
362 | break; | ||
363 | } | 362 | } |
364 | case FLAC__METADATA_TYPE_PICTURE: | 363 | break; |
364 | } | ||
365 | case FLAC__METADATA_TYPE_PICTURE: | ||
366 | { | ||
367 | switch (metadata->data.picture.type) | ||
365 | { | 368 | { |
366 | switch (metadata->data.picture.type) | 369 | case FLAC__STREAM_METADATA_PICTURE_TYPE_OTHER: |
367 | { | 370 | case FLAC__STREAM_METADATA_PICTURE_TYPE_FILE_ICON_STANDARD: |
368 | case FLAC__STREAM_METADATA_PICTURE_TYPE_OTHER: | 371 | case FLAC__STREAM_METADATA_PICTURE_TYPE_FILE_ICON: |
369 | case FLAC__STREAM_METADATA_PICTURE_TYPE_FILE_ICON_STANDARD: | 372 | type = EXTRACTOR_METATYPE_THUMBNAIL; |
370 | case FLAC__STREAM_METADATA_PICTURE_TYPE_FILE_ICON: | 373 | break; |
371 | type = EXTRACTOR_METATYPE_THUMBNAIL; | 374 | case FLAC__STREAM_METADATA_PICTURE_TYPE_FRONT_COVER: |
372 | break; | 375 | case FLAC__STREAM_METADATA_PICTURE_TYPE_BACK_COVER: |
373 | case FLAC__STREAM_METADATA_PICTURE_TYPE_FRONT_COVER: | 376 | type = EXTRACTOR_METATYPE_COVER_PICTURE; |
374 | case FLAC__STREAM_METADATA_PICTURE_TYPE_BACK_COVER: | 377 | break; |
375 | type = EXTRACTOR_METATYPE_COVER_PICTURE; | 378 | case FLAC__STREAM_METADATA_PICTURE_TYPE_LEAD_ARTIST: |
376 | break; | 379 | case FLAC__STREAM_METADATA_PICTURE_TYPE_ARTIST: |
377 | case FLAC__STREAM_METADATA_PICTURE_TYPE_LEAD_ARTIST: | 380 | case FLAC__STREAM_METADATA_PICTURE_TYPE_CONDUCTOR: |
378 | case FLAC__STREAM_METADATA_PICTURE_TYPE_ARTIST: | 381 | case FLAC__STREAM_METADATA_PICTURE_TYPE_BAND: |
379 | case FLAC__STREAM_METADATA_PICTURE_TYPE_CONDUCTOR: | 382 | case FLAC__STREAM_METADATA_PICTURE_TYPE_COMPOSER: |
380 | case FLAC__STREAM_METADATA_PICTURE_TYPE_BAND: | 383 | case FLAC__STREAM_METADATA_PICTURE_TYPE_LYRICIST: |
381 | case FLAC__STREAM_METADATA_PICTURE_TYPE_COMPOSER: | 384 | type = EXTRACTOR_METATYPE_CONTRIBUTOR_PICTURE; |
382 | case FLAC__STREAM_METADATA_PICTURE_TYPE_LYRICIST: | 385 | break; |
383 | type = EXTRACTOR_METATYPE_CONTRIBUTOR_PICTURE; | 386 | case FLAC__STREAM_METADATA_PICTURE_TYPE_RECORDING_LOCATION: |
384 | break; | 387 | case FLAC__STREAM_METADATA_PICTURE_TYPE_DURING_RECORDING: |
385 | case FLAC__STREAM_METADATA_PICTURE_TYPE_RECORDING_LOCATION: | 388 | case FLAC__STREAM_METADATA_PICTURE_TYPE_DURING_PERFORMANCE: |
386 | case FLAC__STREAM_METADATA_PICTURE_TYPE_DURING_RECORDING: | 389 | case FLAC__STREAM_METADATA_PICTURE_TYPE_VIDEO_SCREEN_CAPTURE: |
387 | case FLAC__STREAM_METADATA_PICTURE_TYPE_DURING_PERFORMANCE: | 390 | type = EXTRACTOR_METATYPE_EVENT_PICTURE; |
388 | case FLAC__STREAM_METADATA_PICTURE_TYPE_VIDEO_SCREEN_CAPTURE: | 391 | break; |
389 | type = EXTRACTOR_METATYPE_EVENT_PICTURE; | 392 | case FLAC__STREAM_METADATA_PICTURE_TYPE_BAND_LOGOTYPE: |
390 | break; | 393 | case FLAC__STREAM_METADATA_PICTURE_TYPE_PUBLISHER_LOGOTYPE: |
391 | case FLAC__STREAM_METADATA_PICTURE_TYPE_BAND_LOGOTYPE: | 394 | type = EXTRACTOR_METATYPE_LOGO; |
392 | case FLAC__STREAM_METADATA_PICTURE_TYPE_PUBLISHER_LOGOTYPE: | 395 | break; |
393 | type = EXTRACTOR_METATYPE_LOGO; | 396 | case FLAC__STREAM_METADATA_PICTURE_TYPE_LEAFLET_PAGE: |
394 | break; | 397 | case FLAC__STREAM_METADATA_PICTURE_TYPE_MEDIA: |
395 | case FLAC__STREAM_METADATA_PICTURE_TYPE_LEAFLET_PAGE: | 398 | case FLAC__STREAM_METADATA_PICTURE_TYPE_FISH: |
396 | case FLAC__STREAM_METADATA_PICTURE_TYPE_MEDIA: | 399 | case FLAC__STREAM_METADATA_PICTURE_TYPE_ILLUSTRATION: |
397 | case FLAC__STREAM_METADATA_PICTURE_TYPE_FISH: | 400 | default: |
398 | case FLAC__STREAM_METADATA_PICTURE_TYPE_ILLUSTRATION: | 401 | type = EXTRACTOR_METATYPE_PICTURE; |
399 | default: | 402 | break; |
400 | type = EXTRACTOR_METATYPE_PICTURE; | ||
401 | break; | ||
402 | } | ||
403 | ec->proc (ec->cls, | ||
404 | "flac", | ||
405 | type, | ||
406 | EXTRACTOR_METAFORMAT_BINARY, | ||
407 | metadata->data.picture.mime_type, | ||
408 | (const char*) metadata->data.picture.data, | ||
409 | metadata->data.picture.data_length); | ||
410 | break; | ||
411 | } | 403 | } |
412 | default: | 404 | ec->proc (ec->cls, |
405 | "flac", | ||
406 | type, | ||
407 | EXTRACTOR_METAFORMAT_BINARY, | ||
408 | metadata->data.picture.mime_type, | ||
409 | (const char*) metadata->data.picture.data, | ||
410 | metadata->data.picture.data_length); | ||
413 | break; | 411 | break; |
414 | } | 412 | } |
413 | default: | ||
414 | break; | ||
415 | } | ||
415 | } | 416 | } |
416 | 417 | ||
417 | 418 | ||
@@ -424,8 +425,8 @@ flac_metadata (const FLAC__StreamDecoder *decoder, | |||
424 | */ | 425 | */ |
425 | static void | 426 | static void |
426 | flac_error (const FLAC__StreamDecoder *decoder, | 427 | flac_error (const FLAC__StreamDecoder *decoder, |
427 | FLAC__StreamDecoderErrorStatus status, | 428 | FLAC__StreamDecoderErrorStatus status, |
428 | void *client_data) | 429 | void *client_data) |
429 | { | 430 | { |
430 | /* ignore errors */ | 431 | /* ignore errors */ |
431 | } | 432 | } |
@@ -439,55 +440,57 @@ flac_error (const FLAC__StreamDecoder *decoder, | |||
439 | void | 440 | void |
440 | EXTRACTOR_flac_extract_method (struct EXTRACTOR_ExtractContext *ec) | 441 | EXTRACTOR_flac_extract_method (struct EXTRACTOR_ExtractContext *ec) |
441 | { | 442 | { |
442 | FLAC__StreamDecoder * decoder; | 443 | FLAC__StreamDecoder *decoder; |
443 | 444 | ||
444 | if (NULL == (decoder = FLAC__stream_decoder_new ())) | 445 | if (NULL == (decoder = FLAC__stream_decoder_new ())) |
445 | return; | 446 | return; |
446 | FLAC__stream_decoder_set_md5_checking (decoder, false); | 447 | FLAC__stream_decoder_set_md5_checking (decoder, false); |
447 | FLAC__stream_decoder_set_metadata_ignore_all (decoder); | 448 | FLAC__stream_decoder_set_metadata_ignore_all (decoder); |
448 | if (false == FLAC__stream_decoder_set_metadata_respond_all (decoder)) | 449 | if (false == FLAC__stream_decoder_set_metadata_respond_all (decoder)) |
449 | { | 450 | { |
450 | FLAC__stream_decoder_delete (decoder); | 451 | FLAC__stream_decoder_delete (decoder); |
451 | return; | 452 | return; |
452 | } | 453 | } |
453 | if (FLAC__STREAM_DECODER_INIT_STATUS_OK != | 454 | if (FLAC__STREAM_DECODER_INIT_STATUS_OK != |
454 | FLAC__stream_decoder_init_stream (decoder, | 455 | FLAC__stream_decoder_init_stream (decoder, |
455 | &flac_read, | 456 | &flac_read, |
456 | &flac_seek, | 457 | &flac_seek, |
457 | &flac_tell, | 458 | &flac_tell, |
458 | &flac_length, | 459 | &flac_length, |
459 | &flac_eof, | 460 | &flac_eof, |
460 | &flac_write, | 461 | &flac_write, |
461 | &flac_metadata, | 462 | &flac_metadata, |
462 | &flac_error, | 463 | &flac_error, |
463 | ec)) | 464 | ec)) |
464 | { | 465 | { |
465 | FLAC__stream_decoder_delete (decoder); | 466 | FLAC__stream_decoder_delete (decoder); |
466 | return; | 467 | return; |
467 | } | 468 | } |
468 | if (FLAC__STREAM_DECODER_SEARCH_FOR_METADATA != FLAC__stream_decoder_get_state(decoder)) | 469 | if (FLAC__STREAM_DECODER_SEARCH_FOR_METADATA != |
469 | { | 470 | FLAC__stream_decoder_get_state (decoder)) |
470 | FLAC__stream_decoder_delete (decoder); | 471 | { |
471 | return; | 472 | FLAC__stream_decoder_delete (decoder); |
472 | } | 473 | return; |
473 | if (! FLAC__stream_decoder_process_until_end_of_metadata(decoder)) | 474 | } |
474 | { | 475 | if (! FLAC__stream_decoder_process_until_end_of_metadata (decoder)) |
475 | FLAC__stream_decoder_delete (decoder); | 476 | { |
476 | return; | 477 | FLAC__stream_decoder_delete (decoder); |
477 | } | 478 | return; |
479 | } | ||
478 | switch (FLAC__stream_decoder_get_state (decoder)) | 480 | switch (FLAC__stream_decoder_get_state (decoder)) |
479 | { | 481 | { |
480 | case FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC: | 482 | case FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC: |
481 | case FLAC__STREAM_DECODER_READ_METADATA: | 483 | case FLAC__STREAM_DECODER_READ_METADATA: |
482 | case FLAC__STREAM_DECODER_END_OF_STREAM: | 484 | case FLAC__STREAM_DECODER_END_OF_STREAM: |
483 | case FLAC__STREAM_DECODER_READ_FRAME: | 485 | case FLAC__STREAM_DECODER_READ_FRAME: |
484 | break; | 486 | break; |
485 | default: | 487 | default: |
486 | /* not so sure... */ | 488 | /* not so sure... */ |
487 | break; | 489 | break; |
488 | } | 490 | } |
489 | FLAC__stream_decoder_finish (decoder); | 491 | FLAC__stream_decoder_finish (decoder); |
490 | FLAC__stream_decoder_delete (decoder); | 492 | FLAC__stream_decoder_delete (decoder); |
491 | } | 493 | } |
492 | 494 | ||
495 | |||
493 | /* end of flac_extractor.c */ | 496 | /* end of flac_extractor.c */ |
diff --git a/src/plugins/gif_extractor.c b/src/plugins/gif_extractor.c index 8ee5807..405eebe 100644 --- a/src/plugins/gif_extractor.c +++ b/src/plugins/gif_extractor.c | |||
@@ -37,16 +37,16 @@ | |||
37 | */ | 37 | */ |
38 | static int | 38 | static int |
39 | gif_read_func (GifFileType *ft, | 39 | gif_read_func (GifFileType *ft, |
40 | GifByteType *bt, | 40 | GifByteType *bt, |
41 | int arg) | 41 | int arg) |
42 | { | 42 | { |
43 | struct EXTRACTOR_ExtractContext *ec = ft->UserData; | 43 | struct EXTRACTOR_ExtractContext *ec = ft->UserData; |
44 | void *data; | 44 | void *data; |
45 | ssize_t ret; | 45 | ssize_t ret; |
46 | 46 | ||
47 | ret = ec->read (ec->cls, | 47 | ret = ec->read (ec->cls, |
48 | &data, | 48 | &data, |
49 | arg); | 49 | arg); |
50 | if (-1 == ret) | 50 | if (-1 == ret) |
51 | return -1; | 51 | return -1; |
52 | memcpy (bt, data, ret); | 52 | memcpy (bt, data, ret); |
@@ -75,7 +75,7 @@ EXTRACTOR_gif_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
75 | 75 | ||
76 | gif_error = 0; | 76 | gif_error = 0; |
77 | gif_file = DGifOpen (ec, &gif_read_func, &gif_error); | 77 | gif_file = DGifOpen (ec, &gif_read_func, &gif_error); |
78 | if (gif_file == NULL || gif_error != 0) | 78 | if ((gif_file == NULL) || (gif_error != 0)) |
79 | { | 79 | { |
80 | if (gif_file != NULL) | 80 | if (gif_file != NULL) |
81 | #if GIFLIB_MAJOR < 5 || GIFLIB_MINOR < 1 | 81 | #if GIFLIB_MAJOR < 5 || GIFLIB_MINOR < 1 |
@@ -88,57 +88,58 @@ EXTRACTOR_gif_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
88 | #endif | 88 | #endif |
89 | if (0 != | 89 | if (0 != |
90 | ec->proc (ec->cls, | 90 | ec->proc (ec->cls, |
91 | "gif", | 91 | "gif", |
92 | EXTRACTOR_METATYPE_MIMETYPE, | 92 | EXTRACTOR_METATYPE_MIMETYPE, |
93 | EXTRACTOR_METAFORMAT_UTF8, | 93 | EXTRACTOR_METAFORMAT_UTF8, |
94 | "text/plain", | 94 | "text/plain", |
95 | "image/gif", | 95 | "image/gif", |
96 | strlen ("image/gif") + 1)) | 96 | strlen ("image/gif") + 1)) |
97 | return; | 97 | return; |
98 | snprintf (dims, | 98 | snprintf (dims, |
99 | sizeof (dims), | 99 | sizeof (dims), |
100 | "%dx%d", | 100 | "%dx%d", |
101 | gif_file->SHeight, | 101 | gif_file->SHeight, |
102 | gif_file->SWidth); | 102 | gif_file->SWidth); |
103 | if (0 != | 103 | if (0 != |
104 | ec->proc (ec->cls, | 104 | ec->proc (ec->cls, |
105 | "gif", | 105 | "gif", |
106 | EXTRACTOR_METATYPE_IMAGE_DIMENSIONS, | 106 | EXTRACTOR_METATYPE_IMAGE_DIMENSIONS, |
107 | EXTRACTOR_METAFORMAT_UTF8, | 107 | EXTRACTOR_METAFORMAT_UTF8, |
108 | "text/plain", | 108 | "text/plain", |
109 | dims, | 109 | dims, |
110 | strlen (dims) + 1)) | 110 | strlen (dims) + 1)) |
111 | return; | 111 | return; |
112 | while (1) | 112 | while (1) |
113 | { | ||
114 | if (GIF_OK != | ||
115 | DGifGetRecordType (gif_file, | ||
116 | &gif_type)) | ||
117 | break; | ||
118 | if (UNDEFINED_RECORD_TYPE == gif_type) | ||
119 | break; | ||
120 | if (EXTENSION_RECORD_TYPE != gif_type) | ||
121 | continue; | ||
122 | if (GIF_OK != | ||
123 | DGifGetExtension (gif_file, &et, &ext)) | ||
124 | continue; | ||
125 | if (NULL == ext) | ||
126 | continue; | ||
127 | if (COMMENT_EXT_FUNC_CODE == et) | ||
113 | { | 128 | { |
114 | if (GIF_OK != | 129 | ec->proc (ec->cls, |
115 | DGifGetRecordType (gif_file, | 130 | "gif", |
116 | &gif_type)) | 131 | EXTRACTOR_METATYPE_COMMENT, |
117 | break; | 132 | EXTRACTOR_METAFORMAT_C_STRING, |
118 | if (UNDEFINED_RECORD_TYPE == gif_type) | 133 | "text/plain", |
119 | break; | 134 | (char*) &ext[1], |
120 | if (EXTENSION_RECORD_TYPE != gif_type) | 135 | (uint8_t) ext[0]); |
121 | continue; | 136 | break; |
122 | if (GIF_OK != | ||
123 | DGifGetExtension (gif_file, &et, &ext)) | ||
124 | continue; | ||
125 | if (NULL == ext) | ||
126 | continue; | ||
127 | if (COMMENT_EXT_FUNC_CODE == et) | ||
128 | { | ||
129 | ec->proc (ec->cls, | ||
130 | "gif", | ||
131 | EXTRACTOR_METATYPE_COMMENT, | ||
132 | EXTRACTOR_METAFORMAT_C_STRING, | ||
133 | "text/plain", | ||
134 | (char*) &ext[1], | ||
135 | (uint8_t) ext[0]); | ||
136 | break; | ||
137 | } | ||
138 | while ( (GIF_ERROR != | ||
139 | DGifGetExtensionNext(gif_file, &ext)) && | ||
140 | (NULL != ext) ) ; /* keep going */ | ||
141 | } | 137 | } |
138 | while ( (GIF_ERROR != | ||
139 | DGifGetExtensionNext (gif_file, &ext)) && | ||
140 | (NULL != ext) ) | ||
141 | ; /* keep going */ | ||
142 | } | ||
142 | #if defined (GIF_LIB_VERSION) || GIFLIB_MAJOR < 5 || GIFLIB_MINOR < 1 | 143 | #if defined (GIF_LIB_VERSION) || GIFLIB_MAJOR < 5 || GIFLIB_MINOR < 1 |
143 | DGifCloseFile (gif_file); | 144 | DGifCloseFile (gif_file); |
144 | #else | 145 | #else |
@@ -146,4 +147,5 @@ EXTRACTOR_gif_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
146 | #endif | 147 | #endif |
147 | } | 148 | } |
148 | 149 | ||
150 | |||
149 | /* end of gif_extractor.c */ | 151 | /* end of gif_extractor.c */ |
diff --git a/src/plugins/gstreamer_extractor.c b/src/plugins/gstreamer_extractor.c index 31568a7..87f0153 100644 --- a/src/plugins/gstreamer_extractor.c +++ b/src/plugins/gstreamer_extractor.c | |||
@@ -64,8 +64,7 @@ struct KnownTag | |||
64 | /** | 64 | /** |
65 | * Struct mapping known tags (that do occur in GST API) to LE tags. | 65 | * Struct mapping known tags (that do occur in GST API) to LE tags. |
66 | */ | 66 | */ |
67 | static struct KnownTag __known_tags[] = | 67 | static struct KnownTag __known_tags[] = { |
68 | { | ||
69 | /** | 68 | /** |
70 | * GST_TAG_TITLE: | 69 | * GST_TAG_TITLE: |
71 | * | 70 | * |
@@ -562,7 +561,8 @@ static struct KnownTag __known_tags[] = | |||
562 | * Represents the expected error on the horizontal positioning in | 561 | * Represents the expected error on the horizontal positioning in |
563 | * meters (double). | 562 | * meters (double). |
564 | */ | 563 | */ |
565 | {GST_TAG_GEO_LOCATION_HORIZONTAL_ERROR, EXTRACTOR_METATYPE_LOCATION_HORIZONTAL_ERROR}, | 564 | {GST_TAG_GEO_LOCATION_HORIZONTAL_ERROR, |
565 | EXTRACTOR_METATYPE_LOCATION_HORIZONTAL_ERROR}, | ||
566 | 566 | ||
567 | /** | 567 | /** |
568 | * GST_TAG_GEO_LOCATION_MOVEMENT_SPEED: | 568 | * GST_TAG_GEO_LOCATION_MOVEMENT_SPEED: |
@@ -572,7 +572,8 @@ static struct KnownTag __known_tags[] = | |||
572 | * | 572 | * |
573 | * See also #GST_TAG_GEO_LOCATION_MOVEMENT_DIRECTION | 573 | * See also #GST_TAG_GEO_LOCATION_MOVEMENT_DIRECTION |
574 | */ | 574 | */ |
575 | {GST_TAG_GEO_LOCATION_MOVEMENT_SPEED, EXTRACTOR_METATYPE_LOCATION_MOVEMENT_SPEED}, | 575 | {GST_TAG_GEO_LOCATION_MOVEMENT_SPEED, |
576 | EXTRACTOR_METATYPE_LOCATION_MOVEMENT_SPEED}, | ||
576 | 577 | ||
577 | /** | 578 | /** |
578 | * GST_TAG_GEO_LOCATION_MOVEMENT_DIRECTION: | 579 | * GST_TAG_GEO_LOCATION_MOVEMENT_DIRECTION: |
@@ -583,7 +584,8 @@ static struct KnownTag __known_tags[] = | |||
583 | * | 584 | * |
584 | * See also #GST_TAG_GEO_LOCATION_CAPTURE_DIRECTION | 585 | * See also #GST_TAG_GEO_LOCATION_CAPTURE_DIRECTION |
585 | */ | 586 | */ |
586 | {GST_TAG_GEO_LOCATION_MOVEMENT_DIRECTION, EXTRACTOR_METATYPE_LOCATION_MOVEMENT_DIRECTION}, | 587 | {GST_TAG_GEO_LOCATION_MOVEMENT_DIRECTION, |
588 | EXTRACTOR_METATYPE_LOCATION_MOVEMENT_DIRECTION}, | ||
587 | 589 | ||
588 | /** | 590 | /** |
589 | * GST_TAG_GEO_LOCATION_CAPTURE_DIRECTION: | 591 | * GST_TAG_GEO_LOCATION_CAPTURE_DIRECTION: |
@@ -594,7 +596,8 @@ static struct KnownTag __known_tags[] = | |||
594 | * | 596 | * |
595 | * See also #GST_TAG_GEO_LOCATION_MOVEMENT_DIRECTION | 597 | * See also #GST_TAG_GEO_LOCATION_MOVEMENT_DIRECTION |
596 | */ | 598 | */ |
597 | {GST_TAG_GEO_LOCATION_CAPTURE_DIRECTION, EXTRACTOR_METATYPE_LOCATION_CAPTURE_DIRECTION}, | 599 | {GST_TAG_GEO_LOCATION_CAPTURE_DIRECTION, |
600 | EXTRACTOR_METATYPE_LOCATION_CAPTURE_DIRECTION}, | ||
598 | 601 | ||
599 | /** | 602 | /** |
600 | * GST_TAG_SHOW_NAME: | 603 | * GST_TAG_SHOW_NAME: |
@@ -735,23 +738,22 @@ struct NamedTag | |||
735 | * Mapping from GST tag names to LE types for tags that are not in | 738 | * Mapping from GST tag names to LE types for tags that are not in |
736 | * the public GST API. | 739 | * the public GST API. |
737 | */ | 740 | */ |
738 | struct NamedTag named_tags[] = | 741 | struct NamedTag named_tags[] = { |
739 | { | 742 | { "FPS", EXTRACTOR_METATYPE_FRAME_RATE }, |
740 | { "FPS", EXTRACTOR_METATYPE_FRAME_RATE }, | 743 | { "PLAY_COUNTER", EXTRACTOR_METATYPE_PLAY_COUNTER }, |
741 | { "PLAY_COUNTER", EXTRACTOR_METATYPE_PLAY_COUNTER }, | 744 | { "RATING", EXTRACTOR_METATYPE_RATING }, |
742 | { "RATING", EXTRACTOR_METATYPE_RATING }, | 745 | { "SUMMARY", EXTRACTOR_METATYPE_SUMMARY }, |
743 | { "SUMMARY", EXTRACTOR_METATYPE_SUMMARY }, | 746 | { "SUBJECT", EXTRACTOR_METATYPE_SUBJECT }, |
744 | { "SUBJECT", EXTRACTOR_METATYPE_SUBJECT }, | 747 | { "MOOD", EXTRACTOR_METATYPE_MOOD }, |
745 | { "MOOD", EXTRACTOR_METATYPE_MOOD }, | 748 | { "LEAD_PERFORMER", EXTRACTOR_METATYPE_PERFORMER }, |
746 | { "LEAD_PERFORMER", EXTRACTOR_METATYPE_PERFORMER }, | 749 | { "DIRECTOR", EXTRACTOR_METATYPE_MOVIE_DIRECTOR }, |
747 | { "DIRECTOR", EXTRACTOR_METATYPE_MOVIE_DIRECTOR }, | 750 | { "WRITTEN_BY", EXTRACTOR_METATYPE_WRITER }, |
748 | { "WRITTEN_BY", EXTRACTOR_METATYPE_WRITER }, | 751 | { "PRODUCER", EXTRACTOR_METATYPE_PRODUCER }, |
749 | { "PRODUCER", EXTRACTOR_METATYPE_PRODUCER }, | 752 | { "PUBLISHER", EXTRACTOR_METATYPE_PUBLISHER }, |
750 | { "PUBLISHER", EXTRACTOR_METATYPE_PUBLISHER }, | 753 | { "ORIGINAL/ARTIST", EXTRACTOR_METATYPE_ORIGINAL_ARTIST }, |
751 | { "ORIGINAL/ARTIST", EXTRACTOR_METATYPE_ORIGINAL_ARTIST }, | 754 | { "ORIGINAL/TITLE", EXTRACTOR_METATYPE_ORIGINAL_TITLE }, |
752 | { "ORIGINAL/TITLE", EXTRACTOR_METATYPE_ORIGINAL_TITLE }, | 755 | { NULL, EXTRACTOR_METATYPE_UNKNOWN } |
753 | { NULL, EXTRACTOR_METATYPE_UNKNOWN } | 756 | }; |
754 | }; | ||
755 | 757 | ||
756 | 758 | ||
757 | /** | 759 | /** |
@@ -914,9 +916,9 @@ _data_timeout (struct PrivStruct *ps) | |||
914 | * @param ps our execution context | 916 | * @param ps our execution context |
915 | */ | 917 | */ |
916 | static void | 918 | static void |
917 | feed_data (GstElement * appsrc, | 919 | feed_data (GstElement *appsrc, |
918 | guint size, | 920 | guint size, |
919 | struct PrivStruct * ps) | 921 | struct PrivStruct *ps) |
920 | { | 922 | { |
921 | ssize_t data_len; | 923 | ssize_t data_len; |
922 | uint8_t *le_data; | 924 | uint8_t *le_data; |
@@ -929,7 +931,8 @@ feed_data (GstElement * appsrc, | |||
929 | 931 | ||
930 | if (ps->timeout_id > 0) | 932 | if (ps->timeout_id > 0) |
931 | g_source_remove (ps->timeout_id); | 933 | g_source_remove (ps->timeout_id); |
932 | ps->timeout_id = g_timeout_add (DATA_TIMEOUT, (GSourceFunc) _data_timeout, ps); | 934 | ps->timeout_id = g_timeout_add (DATA_TIMEOUT, (GSourceFunc) _data_timeout, |
935 | ps); | ||
933 | 936 | ||
934 | if ( (ps->length > 0) && (ps->offset >= ps->length) ) | 937 | if ( (ps->length > 0) && (ps->offset >= ps->length) ) |
935 | { | 938 | { |
@@ -938,11 +941,11 @@ feed_data (GstElement * appsrc, | |||
938 | return; | 941 | return; |
939 | } | 942 | } |
940 | 943 | ||
941 | if (ps->length > 0 && ps->offset + size > ps->length) | 944 | if ((ps->length > 0) && (ps->offset + size > ps->length)) |
942 | size = ps->length - ps->offset; | 945 | size = ps->length - ps->offset; |
943 | 946 | ||
944 | mem = gst_allocator_alloc (NULL, size, NULL); | 947 | mem = gst_allocator_alloc (NULL, size, NULL); |
945 | if (!gst_memory_map (mem, &mi, GST_MAP_WRITE)) | 948 | if (! gst_memory_map (mem, &mi, GST_MAP_WRITE)) |
946 | { | 949 | { |
947 | gst_memory_unref (mem); | 950 | gst_memory_unref (mem); |
948 | GST_DEBUG ("Failed to map the memory"); | 951 | GST_DEBUG ("Failed to map the memory"); |
@@ -955,7 +958,8 @@ feed_data (GstElement * appsrc, | |||
955 | pthread_mutex_lock (&pipe_mutex); | 958 | pthread_mutex_lock (&pipe_mutex); |
956 | while ( (accumulated < size) && (data_len > 0) ) | 959 | while ( (accumulated < size) && (data_len > 0) ) |
957 | { | 960 | { |
958 | data_len = ps->ec->read (ps->ec->cls, (void **) &le_data, size - accumulated); | 961 | data_len = ps->ec->read (ps->ec->cls, (void **) &le_data, size |
962 | - accumulated); | ||
959 | if (data_len > 0) | 963 | if (data_len > 0) |
960 | { | 964 | { |
961 | memcpy (&mi.data[accumulated], le_data, data_len); | 965 | memcpy (&mi.data[accumulated], le_data, data_len); |
@@ -974,7 +978,7 @@ feed_data (GstElement * appsrc, | |||
974 | GST_BUFFER_OFFSET_END (buffer) = ps->offset + size; | 978 | GST_BUFFER_OFFSET_END (buffer) = ps->offset + size; |
975 | 979 | ||
976 | GST_DEBUG ("feed buffer %p, offset %" G_GUINT64_FORMAT "-%u", | 980 | GST_DEBUG ("feed buffer %p, offset %" G_GUINT64_FORMAT "-%u", |
977 | buffer, ps->offset, size); | 981 | buffer, ps->offset, size); |
978 | gst_app_src_push_buffer (GST_APP_SRC (ps->source), buffer); | 982 | gst_app_src_push_buffer (GST_APP_SRC (ps->source), buffer); |
979 | ps->offset += size; | 983 | ps->offset += size; |
980 | } | 984 | } |
@@ -987,7 +991,8 @@ feed_data (GstElement * appsrc, | |||
987 | 991 | ||
988 | if (ps->timeout_id > 0) | 992 | if (ps->timeout_id > 0) |
989 | g_source_remove (ps->timeout_id); | 993 | g_source_remove (ps->timeout_id); |
990 | ps->timeout_id = g_timeout_add (DATA_TIMEOUT, (GSourceFunc) _data_timeout, ps); | 994 | ps->timeout_id = g_timeout_add (DATA_TIMEOUT, (GSourceFunc) _data_timeout, |
995 | ps); | ||
991 | } | 996 | } |
992 | 997 | ||
993 | 998 | ||
@@ -1001,9 +1006,9 @@ feed_data (GstElement * appsrc, | |||
1001 | * @return TRUE if seeking succeeded, FALSE if not | 1006 | * @return TRUE if seeking succeeded, FALSE if not |
1002 | */ | 1007 | */ |
1003 | static gboolean | 1008 | static gboolean |
1004 | seek_data (GstElement * appsrc, | 1009 | seek_data (GstElement *appsrc, |
1005 | guint64 position, | 1010 | guint64 position, |
1006 | struct PrivStruct * ps) | 1011 | struct PrivStruct *ps) |
1007 | { | 1012 | { |
1008 | GST_DEBUG ("seek to offset %" G_GUINT64_FORMAT, position); | 1013 | GST_DEBUG ("seek to offset %" G_GUINT64_FORMAT, position); |
1009 | pthread_mutex_lock (&pipe_mutex); | 1014 | pthread_mutex_lock (&pipe_mutex); |
@@ -1011,7 +1016,8 @@ seek_data (GstElement * appsrc, | |||
1011 | pthread_mutex_unlock (&pipe_mutex); | 1016 | pthread_mutex_unlock (&pipe_mutex); |
1012 | if (ps->timeout_id > 0) | 1017 | if (ps->timeout_id > 0) |
1013 | g_source_remove (ps->timeout_id); | 1018 | g_source_remove (ps->timeout_id); |
1014 | ps->timeout_id = g_timeout_add (DATA_TIMEOUT, (GSourceFunc) _data_timeout, ps); | 1019 | ps->timeout_id = g_timeout_add (DATA_TIMEOUT, (GSourceFunc) _data_timeout, |
1020 | ps); | ||
1015 | return ps->offset == position; | 1021 | return ps->offset == position; |
1016 | } | 1022 | } |
1017 | 1023 | ||
@@ -1026,8 +1032,8 @@ seek_data (GstElement * appsrc, | |||
1026 | */ | 1032 | */ |
1027 | static gboolean | 1033 | static gboolean |
1028 | send_structure_foreach (GQuark field_id, | 1034 | send_structure_foreach (GQuark field_id, |
1029 | const GValue *value, | 1035 | const GValue *value, |
1030 | gpointer user_data) | 1036 | gpointer user_data) |
1031 | { | 1037 | { |
1032 | struct PrivStruct *ps = user_data; | 1038 | struct PrivStruct *ps = user_data; |
1033 | gchar *str; | 1039 | gchar *str; |
@@ -1095,20 +1101,21 @@ send_structure_foreach (GQuark field_id, | |||
1095 | { | 1101 | { |
1096 | unsigned int i; | 1102 | unsigned int i; |
1097 | 1103 | ||
1098 | for (i=0; NULL != named_tags[i].tag; i++) | 1104 | for (i = 0; NULL != named_tags[i].tag; i++) |
1099 | if (0 == strcmp (named_tags[i].tag, field_name)) | 1105 | if (0 == strcmp (named_tags[i].tag, field_name)) |
1100 | { | 1106 | { |
1101 | ps->time_to_leave = ps->ec->proc (ps->ec->cls, "gstreamer", | 1107 | ps->time_to_leave = ps->ec->proc (ps->ec->cls, "gstreamer", |
1102 | named_tags[i].le_type, | 1108 | named_tags[i].le_type, |
1103 | EXTRACTOR_METAFORMAT_UTF8, "text/plain", | 1109 | EXTRACTOR_METAFORMAT_UTF8, |
1104 | (const char *) str, strlen (str) + 1); | 1110 | "text/plain", |
1105 | if (NULL != str) | 1111 | (const char *) str, strlen (str) + 1); |
1106 | { | 1112 | if (NULL != str) |
1107 | g_free (str); | 1113 | { |
1108 | str = NULL; | 1114 | g_free (str); |
1109 | } | 1115 | str = NULL; |
1110 | break; | 1116 | } |
1111 | } | 1117 | break; |
1118 | } | ||
1112 | } | 1119 | } |
1113 | if (NULL != str) | 1120 | if (NULL != str) |
1114 | { | 1121 | { |
@@ -1116,16 +1123,16 @@ send_structure_foreach (GQuark field_id, | |||
1116 | field_name, | 1123 | field_name, |
1117 | str); | 1124 | str); |
1118 | if (NULL != senddata) | 1125 | if (NULL != senddata) |
1119 | { | 1126 | { |
1120 | ps->time_to_leave = ps->ec->proc (ps->ec->cls, | 1127 | ps->time_to_leave = ps->ec->proc (ps->ec->cls, |
1121 | "gstreamer", | 1128 | "gstreamer", |
1122 | EXTRACTOR_METATYPE_UNKNOWN, | 1129 | EXTRACTOR_METATYPE_UNKNOWN, |
1123 | EXTRACTOR_METAFORMAT_UTF8, | 1130 | EXTRACTOR_METAFORMAT_UTF8, |
1124 | "text/plain", | 1131 | "text/plain", |
1125 | (const char *) senddata, | 1132 | (const char *) senddata, |
1126 | strlen (senddata) + 1); | 1133 | strlen (senddata) + 1); |
1127 | g_free (senddata); | 1134 | g_free (senddata); |
1128 | } | 1135 | } |
1129 | } | 1136 | } |
1130 | if (NULL != str) | 1137 | if (NULL != str) |
1131 | g_free (str); | 1138 | g_free (str); |
@@ -1143,7 +1150,7 @@ send_structure_foreach (GQuark field_id, | |||
1143 | */ | 1150 | */ |
1144 | static gboolean | 1151 | static gboolean |
1145 | send_audio_info (GstDiscovererAudioInfo *info, | 1152 | send_audio_info (GstDiscovererAudioInfo *info, |
1146 | struct PrivStruct *ps) | 1153 | struct PrivStruct *ps) |
1147 | { | 1154 | { |
1148 | gchar *tmp; | 1155 | gchar *tmp; |
1149 | const gchar *ctmp; | 1156 | const gchar *ctmp; |
@@ -1152,10 +1159,11 @@ send_audio_info (GstDiscovererAudioInfo *info, | |||
1152 | ctmp = gst_discoverer_audio_info_get_language (info); | 1159 | ctmp = gst_discoverer_audio_info_get_language (info); |
1153 | if (ctmp) | 1160 | if (ctmp) |
1154 | if ((ps->time_to_leave = ps->ec->proc (ps->ec->cls, "gstreamer", | 1161 | if ((ps->time_to_leave = ps->ec->proc (ps->ec->cls, "gstreamer", |
1155 | EXTRACTOR_METATYPE_AUDIO_LANGUAGE, | 1162 | EXTRACTOR_METATYPE_AUDIO_LANGUAGE, |
1156 | EXTRACTOR_METAFORMAT_UTF8, | 1163 | EXTRACTOR_METAFORMAT_UTF8, |
1157 | "text/plain", | 1164 | "text/plain", |
1158 | (const char *) ctmp, strlen (ctmp) + 1))) | 1165 | (const char *) ctmp, strlen (ctmp) |
1166 | + 1))) | ||
1159 | return TRUE; | 1167 | return TRUE; |
1160 | 1168 | ||
1161 | u = gst_discoverer_audio_info_get_channels (info); | 1169 | u = gst_discoverer_audio_info_get_channels (info); |
@@ -1163,16 +1171,16 @@ send_audio_info (GstDiscovererAudioInfo *info, | |||
1163 | { | 1171 | { |
1164 | tmp = g_strdup_printf ("%u", u); | 1172 | tmp = g_strdup_printf ("%u", u); |
1165 | if (NULL != tmp) | 1173 | if (NULL != tmp) |
1166 | { | 1174 | { |
1167 | ps->time_to_leave = ps->ec->proc (ps->ec->cls, | 1175 | ps->time_to_leave = ps->ec->proc (ps->ec->cls, |
1168 | "gstreamer", | 1176 | "gstreamer", |
1169 | EXTRACTOR_METATYPE_CHANNELS, | 1177 | EXTRACTOR_METATYPE_CHANNELS, |
1170 | EXTRACTOR_METAFORMAT_UTF8, | 1178 | EXTRACTOR_METAFORMAT_UTF8, |
1171 | "text/plain", | 1179 | "text/plain", |
1172 | (const char *) tmp, | 1180 | (const char *) tmp, |
1173 | strlen (tmp) + 1); | 1181 | strlen (tmp) + 1); |
1174 | g_free (tmp); | 1182 | g_free (tmp); |
1175 | } | 1183 | } |
1176 | if (ps->time_to_leave) | 1184 | if (ps->time_to_leave) |
1177 | return TRUE; | 1185 | return TRUE; |
1178 | } | 1186 | } |
@@ -1182,16 +1190,16 @@ send_audio_info (GstDiscovererAudioInfo *info, | |||
1182 | { | 1190 | { |
1183 | tmp = g_strdup_printf ("%u", u); | 1191 | tmp = g_strdup_printf ("%u", u); |
1184 | if (NULL != tmp) | 1192 | if (NULL != tmp) |
1185 | { | 1193 | { |
1186 | ps->time_to_leave = ps->ec->proc (ps->ec->cls, | 1194 | ps->time_to_leave = ps->ec->proc (ps->ec->cls, |
1187 | "gstreamer", | 1195 | "gstreamer", |
1188 | EXTRACTOR_METATYPE_SAMPLE_RATE, | 1196 | EXTRACTOR_METATYPE_SAMPLE_RATE, |
1189 | EXTRACTOR_METAFORMAT_UTF8, | 1197 | EXTRACTOR_METAFORMAT_UTF8, |
1190 | "text/plain", | 1198 | "text/plain", |
1191 | (const char *) tmp, | 1199 | (const char *) tmp, |
1192 | strlen (tmp) + 1); | 1200 | strlen (tmp) + 1); |
1193 | g_free (tmp); | 1201 | g_free (tmp); |
1194 | } | 1202 | } |
1195 | if (ps->time_to_leave) | 1203 | if (ps->time_to_leave) |
1196 | return TRUE; | 1204 | return TRUE; |
1197 | } | 1205 | } |
@@ -1201,16 +1209,16 @@ send_audio_info (GstDiscovererAudioInfo *info, | |||
1201 | { | 1209 | { |
1202 | tmp = g_strdup_printf ("%u", u); | 1210 | tmp = g_strdup_printf ("%u", u); |
1203 | if (NULL != tmp) | 1211 | if (NULL != tmp) |
1204 | { | 1212 | { |
1205 | ps->time_to_leave = ps->ec->proc (ps->ec->cls, | 1213 | ps->time_to_leave = ps->ec->proc (ps->ec->cls, |
1206 | "gstreamer", | 1214 | "gstreamer", |
1207 | EXTRACTOR_METATYPE_AUDIO_DEPTH, | 1215 | EXTRACTOR_METATYPE_AUDIO_DEPTH, |
1208 | EXTRACTOR_METAFORMAT_UTF8, | 1216 | EXTRACTOR_METAFORMAT_UTF8, |
1209 | "text/plain", | 1217 | "text/plain", |
1210 | (const char *) tmp, | 1218 | (const char *) tmp, |
1211 | strlen (tmp) + 1); | 1219 | strlen (tmp) + 1); |
1212 | g_free (tmp); | 1220 | g_free (tmp); |
1213 | } | 1221 | } |
1214 | if (ps->time_to_leave) | 1222 | if (ps->time_to_leave) |
1215 | return TRUE; | 1223 | return TRUE; |
1216 | } | 1224 | } |
@@ -1220,16 +1228,16 @@ send_audio_info (GstDiscovererAudioInfo *info, | |||
1220 | { | 1228 | { |
1221 | tmp = g_strdup_printf ("%u", u); | 1229 | tmp = g_strdup_printf ("%u", u); |
1222 | if (NULL != tmp) | 1230 | if (NULL != tmp) |
1223 | { | 1231 | { |
1224 | ps->time_to_leave = ps->ec->proc (ps->ec->cls, | 1232 | ps->time_to_leave = ps->ec->proc (ps->ec->cls, |
1225 | "gstreamer", | 1233 | "gstreamer", |
1226 | EXTRACTOR_METATYPE_AUDIO_BITRATE, | 1234 | EXTRACTOR_METATYPE_AUDIO_BITRATE, |
1227 | EXTRACTOR_METAFORMAT_UTF8, | 1235 | EXTRACTOR_METAFORMAT_UTF8, |
1228 | "text/plain", | 1236 | "text/plain", |
1229 | (const char *) tmp, | 1237 | (const char *) tmp, |
1230 | strlen (tmp) + 1); | 1238 | strlen (tmp) + 1); |
1231 | g_free (tmp); | 1239 | g_free (tmp); |
1232 | } | 1240 | } |
1233 | if (ps->time_to_leave) | 1241 | if (ps->time_to_leave) |
1234 | return TRUE; | 1242 | return TRUE; |
1235 | } | 1243 | } |
@@ -1239,16 +1247,16 @@ send_audio_info (GstDiscovererAudioInfo *info, | |||
1239 | { | 1247 | { |
1240 | tmp = g_strdup_printf ("%u", u); | 1248 | tmp = g_strdup_printf ("%u", u); |
1241 | if (NULL != tmp) | 1249 | if (NULL != tmp) |
1242 | { | 1250 | { |
1243 | ps->time_to_leave = ps->ec->proc (ps->ec->cls, | 1251 | ps->time_to_leave = ps->ec->proc (ps->ec->cls, |
1244 | "gstreamer", | 1252 | "gstreamer", |
1245 | EXTRACTOR_METATYPE_MAXIMUM_AUDIO_BITRATE, | 1253 | EXTRACTOR_METATYPE_MAXIMUM_AUDIO_BITRATE, |
1246 | EXTRACTOR_METAFORMAT_UTF8, | 1254 | EXTRACTOR_METAFORMAT_UTF8, |
1247 | "text/plain", | 1255 | "text/plain", |
1248 | (const char *) tmp, | 1256 | (const char *) tmp, |
1249 | strlen (tmp) + 1); | 1257 | strlen (tmp) + 1); |
1250 | g_free (tmp); | 1258 | g_free (tmp); |
1251 | } | 1259 | } |
1252 | if (ps->time_to_leave) | 1260 | if (ps->time_to_leave) |
1253 | return TRUE; | 1261 | return TRUE; |
1254 | } | 1262 | } |
@@ -1266,7 +1274,7 @@ send_audio_info (GstDiscovererAudioInfo *info, | |||
1266 | */ | 1274 | */ |
1267 | static int | 1275 | static int |
1268 | send_video_info (GstDiscovererVideoInfo *info, | 1276 | send_video_info (GstDiscovererVideoInfo *info, |
1269 | struct PrivStruct *ps) | 1277 | struct PrivStruct *ps) |
1270 | { | 1278 | { |
1271 | gchar *tmp; | 1279 | gchar *tmp; |
1272 | guint u; | 1280 | guint u; |
@@ -1278,16 +1286,16 @@ send_video_info (GstDiscovererVideoInfo *info, | |||
1278 | { | 1286 | { |
1279 | tmp = g_strdup_printf ("%ux%u", u, u2); | 1287 | tmp = g_strdup_printf ("%ux%u", u, u2); |
1280 | if (NULL != tmp) | 1288 | if (NULL != tmp) |
1281 | { | 1289 | { |
1282 | ps->time_to_leave = ps->ec->proc (ps->ec->cls, | 1290 | ps->time_to_leave = ps->ec->proc (ps->ec->cls, |
1283 | "gstreamer", | 1291 | "gstreamer", |
1284 | EXTRACTOR_METATYPE_VIDEO_DIMENSIONS, | 1292 | EXTRACTOR_METATYPE_VIDEO_DIMENSIONS, |
1285 | EXTRACTOR_METAFORMAT_UTF8, | 1293 | EXTRACTOR_METAFORMAT_UTF8, |
1286 | "text/plain", | 1294 | "text/plain", |
1287 | (const char *) tmp, | 1295 | (const char *) tmp, |
1288 | strlen (tmp) + 1); | 1296 | strlen (tmp) + 1); |
1289 | g_free (tmp); | 1297 | g_free (tmp); |
1290 | } | 1298 | } |
1291 | if (ps->time_to_leave) | 1299 | if (ps->time_to_leave) |
1292 | return TRUE; | 1300 | return TRUE; |
1293 | } | 1301 | } |
@@ -1297,16 +1305,16 @@ send_video_info (GstDiscovererVideoInfo *info, | |||
1297 | { | 1305 | { |
1298 | tmp = g_strdup_printf ("%u", u); | 1306 | tmp = g_strdup_printf ("%u", u); |
1299 | if (NULL != tmp) | 1307 | if (NULL != tmp) |
1300 | { | 1308 | { |
1301 | ps->time_to_leave = ps->ec->proc (ps->ec->cls, | 1309 | ps->time_to_leave = ps->ec->proc (ps->ec->cls, |
1302 | "gstreamer", | 1310 | "gstreamer", |
1303 | EXTRACTOR_METATYPE_VIDEO_DEPTH, | 1311 | EXTRACTOR_METATYPE_VIDEO_DEPTH, |
1304 | EXTRACTOR_METAFORMAT_UTF8, | 1312 | EXTRACTOR_METAFORMAT_UTF8, |
1305 | "text/plain", | 1313 | "text/plain", |
1306 | (const char *) tmp, | 1314 | (const char *) tmp, |
1307 | strlen (tmp) + 1); | 1315 | strlen (tmp) + 1); |
1308 | g_free (tmp); | 1316 | g_free (tmp); |
1309 | } | 1317 | } |
1310 | if (ps->time_to_leave) | 1318 | if (ps->time_to_leave) |
1311 | return TRUE; | 1319 | return TRUE; |
1312 | } | 1320 | } |
@@ -1317,16 +1325,16 @@ send_video_info (GstDiscovererVideoInfo *info, | |||
1317 | { | 1325 | { |
1318 | tmp = g_strdup_printf ("%u/%u", u, u2); | 1326 | tmp = g_strdup_printf ("%u/%u", u, u2); |
1319 | if (NULL != tmp) | 1327 | if (NULL != tmp) |
1320 | { | 1328 | { |
1321 | ps->time_to_leave = ps->ec->proc (ps->ec->cls, | 1329 | ps->time_to_leave = ps->ec->proc (ps->ec->cls, |
1322 | "gstreamer", | 1330 | "gstreamer", |
1323 | EXTRACTOR_METATYPE_FRAME_RATE, | 1331 | EXTRACTOR_METATYPE_FRAME_RATE, |
1324 | EXTRACTOR_METAFORMAT_UTF8, | 1332 | EXTRACTOR_METAFORMAT_UTF8, |
1325 | "text/plain", | 1333 | "text/plain", |
1326 | (const char *) tmp, | 1334 | (const char *) tmp, |
1327 | strlen (tmp) + 1); | 1335 | strlen (tmp) + 1); |
1328 | g_free (tmp); | 1336 | g_free (tmp); |
1329 | } | 1337 | } |
1330 | if (ps->time_to_leave) | 1338 | if (ps->time_to_leave) |
1331 | return TRUE; | 1339 | return TRUE; |
1332 | } | 1340 | } |
@@ -1337,16 +1345,16 @@ send_video_info (GstDiscovererVideoInfo *info, | |||
1337 | { | 1345 | { |
1338 | tmp = g_strdup_printf ("%u/%u", u, u2); | 1346 | tmp = g_strdup_printf ("%u/%u", u, u2); |
1339 | if (NULL != tmp) | 1347 | if (NULL != tmp) |
1340 | { | 1348 | { |
1341 | ps->time_to_leave = ps->ec->proc (ps->ec->cls, | 1349 | ps->time_to_leave = ps->ec->proc (ps->ec->cls, |
1342 | "gstreamer", | 1350 | "gstreamer", |
1343 | EXTRACTOR_METATYPE_PIXEL_ASPECT_RATIO, | 1351 | EXTRACTOR_METATYPE_PIXEL_ASPECT_RATIO, |
1344 | EXTRACTOR_METAFORMAT_UTF8, | 1352 | EXTRACTOR_METAFORMAT_UTF8, |
1345 | "text/plain", | 1353 | "text/plain", |
1346 | (const char *) tmp, | 1354 | (const char *) tmp, |
1347 | strlen (tmp) + 1); | 1355 | strlen (tmp) + 1); |
1348 | g_free (tmp); | 1356 | g_free (tmp); |
1349 | } | 1357 | } |
1350 | if (ps->time_to_leave) | 1358 | if (ps->time_to_leave) |
1351 | return TRUE; | 1359 | return TRUE; |
1352 | } | 1360 | } |
@@ -1358,16 +1366,16 @@ send_video_info (GstDiscovererVideoInfo *info, | |||
1358 | { | 1366 | { |
1359 | tmp = g_strdup_printf ("%u", u); | 1367 | tmp = g_strdup_printf ("%u", u); |
1360 | if (NULL != tmp) | 1368 | if (NULL != tmp) |
1361 | { | 1369 | { |
1362 | ps->time_to_leave = ps->ec->proc (ps->ec->cls, | 1370 | ps->time_to_leave = ps->ec->proc (ps->ec->cls, |
1363 | "gstreamer", | 1371 | "gstreamer", |
1364 | EXTRACTOR_METATYPE_VIDEO_BITRATE, | 1372 | EXTRACTOR_METATYPE_VIDEO_BITRATE, |
1365 | EXTRACTOR_METAFORMAT_UTF8, | 1373 | EXTRACTOR_METAFORMAT_UTF8, |
1366 | "text/plain", | 1374 | "text/plain", |
1367 | (const char *) tmp, | 1375 | (const char *) tmp, |
1368 | strlen (tmp) + 1); | 1376 | strlen (tmp) + 1); |
1369 | g_free (tmp); | 1377 | g_free (tmp); |
1370 | } | 1378 | } |
1371 | if (ps->time_to_leave) | 1379 | if (ps->time_to_leave) |
1372 | return TRUE; | 1380 | return TRUE; |
1373 | } | 1381 | } |
@@ -1377,16 +1385,16 @@ send_video_info (GstDiscovererVideoInfo *info, | |||
1377 | { | 1385 | { |
1378 | tmp = g_strdup_printf ("%u", u); | 1386 | tmp = g_strdup_printf ("%u", u); |
1379 | if (NULL != tmp) | 1387 | if (NULL != tmp) |
1380 | { | 1388 | { |
1381 | ps->time_to_leave = ps->ec->proc (ps->ec->cls, | 1389 | ps->time_to_leave = ps->ec->proc (ps->ec->cls, |
1382 | "gstreamer", | 1390 | "gstreamer", |
1383 | EXTRACTOR_METATYPE_MAXIMUM_VIDEO_BITRATE, | 1391 | EXTRACTOR_METATYPE_MAXIMUM_VIDEO_BITRATE, |
1384 | EXTRACTOR_METAFORMAT_UTF8, | 1392 | EXTRACTOR_METAFORMAT_UTF8, |
1385 | "text/plain", | 1393 | "text/plain", |
1386 | (const char *) tmp, | 1394 | (const char *) tmp, |
1387 | strlen (tmp) + 1); | 1395 | strlen (tmp) + 1); |
1388 | g_free (tmp); | 1396 | g_free (tmp); |
1389 | } | 1397 | } |
1390 | if (ps->time_to_leave) | 1398 | if (ps->time_to_leave) |
1391 | return TRUE; | 1399 | return TRUE; |
1392 | } | 1400 | } |
@@ -1404,26 +1412,27 @@ send_video_info (GstDiscovererVideoInfo *info, | |||
1404 | */ | 1412 | */ |
1405 | static int | 1413 | static int |
1406 | send_subtitle_info (GstDiscovererSubtitleInfo *info, | 1414 | send_subtitle_info (GstDiscovererSubtitleInfo *info, |
1407 | struct PrivStruct *ps) | 1415 | struct PrivStruct *ps) |
1408 | { | 1416 | { |
1409 | const gchar *ctmp; | 1417 | const gchar *ctmp; |
1410 | 1418 | ||
1411 | ctmp = gst_discoverer_subtitle_info_get_language (info); | 1419 | ctmp = gst_discoverer_subtitle_info_get_language (info); |
1412 | if ( (NULL != ctmp) && | 1420 | if ( (NULL != ctmp) && |
1413 | (0 != (ps->time_to_leave = ps->ec->proc (ps->ec->cls, "gstreamer", | 1421 | (0 != (ps->time_to_leave = ps->ec->proc (ps->ec->cls, "gstreamer", |
1414 | EXTRACTOR_METATYPE_SUBTITLE_LANGUAGE, | 1422 | EXTRACTOR_METATYPE_SUBTITLE_LANGUAGE, |
1415 | EXTRACTOR_METAFORMAT_UTF8, | 1423 | EXTRACTOR_METAFORMAT_UTF8, |
1416 | "text/plain", | 1424 | "text/plain", |
1417 | (const char *) ctmp, strlen (ctmp) + 1))) ) | 1425 | (const char *) ctmp, strlen ( |
1426 | ctmp) + 1))) ) | ||
1418 | return TRUE; | 1427 | return TRUE; |
1419 | return FALSE; | 1428 | return FALSE; |
1420 | } | 1429 | } |
1421 | 1430 | ||
1422 | 1431 | ||
1423 | static void | 1432 | static void |
1424 | send_tag_foreach (const GstTagList * tags, | 1433 | send_tag_foreach (const GstTagList *tags, |
1425 | const gchar * tag, | 1434 | const gchar *tag, |
1426 | gpointer user_data) | 1435 | gpointer user_data) |
1427 | { | 1436 | { |
1428 | static struct KnownTag unknown_tag = {NULL, EXTRACTOR_METATYPE_UNKNOWN}; | 1437 | static struct KnownTag unknown_tag = {NULL, EXTRACTOR_METATYPE_UNKNOWN}; |
1429 | struct PrivStruct *ps = user_data; | 1438 | struct PrivStruct *ps = user_data; |
@@ -1480,7 +1489,9 @@ send_tag_foreach (const GstTagList * tags, | |||
1480 | str = gst_value_serialize (&val); | 1489 | str = gst_value_serialize (&val); |
1481 | break; | 1490 | break; |
1482 | default: | 1491 | default: |
1483 | if (G_VALUE_TYPE (&val) == GST_TYPE_SAMPLE && (sample = gst_value_get_sample (&val))) | 1492 | if ((G_VALUE_TYPE (&val) == GST_TYPE_SAMPLE) && (sample = |
1493 | gst_value_get_sample ( | ||
1494 | &val))) | ||
1484 | { | 1495 | { |
1485 | GstMapInfo mi; | 1496 | GstMapInfo mi; |
1486 | GstCaps *caps; | 1497 | GstCaps *caps; |
@@ -1498,7 +1509,9 @@ send_tag_foreach (const GstTagList * tags, | |||
1498 | info = gst_sample_get_info (sample); | 1509 | info = gst_sample_get_info (sample); |
1499 | 1510 | ||
1500 | if ( (NULL == info) || | 1511 | if ( (NULL == info) || |
1501 | (!gst_structure_get (info, "image-type", GST_TYPE_TAG_IMAGE_TYPE, &imagetype, NULL)) ) | 1512 | (! gst_structure_get (info, "image-type", |
1513 | GST_TYPE_TAG_IMAGE_TYPE, &imagetype, | ||
1514 | NULL)) ) | ||
1502 | le_type = EXTRACTOR_METATYPE_PICTURE; | 1515 | le_type = EXTRACTOR_METATYPE_PICTURE; |
1503 | else | 1516 | else |
1504 | { | 1517 | { |
@@ -1545,12 +1558,12 @@ send_tag_foreach (const GstTagList * tags, | |||
1545 | le_type, | 1558 | le_type, |
1546 | EXTRACTOR_METAFORMAT_BINARY, | 1559 | EXTRACTOR_METAFORMAT_BINARY, |
1547 | mime_type, | 1560 | mime_type, |
1548 | (const char *) mi.data, mi.size); | 1561 | (const char *) mi.data, mi.size); |
1549 | gst_buffer_unmap (buf, &mi); | 1562 | gst_buffer_unmap (buf, &mi); |
1550 | } | 1563 | } |
1551 | } | 1564 | } |
1552 | else if ((G_VALUE_TYPE (&val) == G_TYPE_UINT64) && | 1565 | else if ((G_VALUE_TYPE (&val) == G_TYPE_UINT64) && |
1553 | (tag_quark == duration_quark)) | 1566 | (tag_quark == duration_quark)) |
1554 | { | 1567 | { |
1555 | GstClockTime duration = (GstClockTime) g_value_get_uint64 (&val); | 1568 | GstClockTime duration = (GstClockTime) g_value_get_uint64 (&val); |
1556 | if ((GST_CLOCK_TIME_IS_VALID (duration)) && (duration > 0)) | 1569 | if ((GST_CLOCK_TIME_IS_VALID (duration)) && (duration > 0)) |
@@ -1566,14 +1579,12 @@ send_tag_foreach (const GstTagList * tags, | |||
1566 | * ignore these tags to avoid duplicates. | 1579 | * ignore these tags to avoid duplicates. |
1567 | * This MIGHT be fixed in new GStreamer versions, but won't affect | 1580 | * This MIGHT be fixed in new GStreamer versions, but won't affect |
1568 | * this code (we simply won't get the tags that we think we should skip). | 1581 | * this code (we simply won't get the tags that we think we should skip). |
1569 | */ | 1582 | */gboolean skip = FALSE; |
1570 | gboolean skip = FALSE; | ||
1571 | /* We have one tag-processing routine and use it for different | 1583 | /* We have one tag-processing routine and use it for different |
1572 | * stream types. However, tags themselves don't know the type of the | 1584 | * stream types. However, tags themselves don't know the type of the |
1573 | * stream they are attached to. We remember that before listing the | 1585 | * stream they are attached to. We remember that before listing the |
1574 | * tags, and adjust LE type accordingly. | 1586 | * tags, and adjust LE type accordingly. |
1575 | */ | 1587 | */enum EXTRACTOR_MetaType le_type = kt->le_type; |
1576 | enum EXTRACTOR_MetaType le_type = kt->le_type; | ||
1577 | switch (kt->le_type) | 1588 | switch (kt->le_type) |
1578 | { | 1589 | { |
1579 | case EXTRACTOR_METATYPE_LANGUAGE: | 1590 | case EXTRACTOR_METATYPE_LANGUAGE: |
@@ -1662,7 +1673,7 @@ send_tag_foreach (const GstTagList * tags, | |||
1662 | { | 1673 | { |
1663 | gchar *new_str; | 1674 | gchar *new_str; |
1664 | /* GST_TAG_EXTENDED_COMMENT is already in key=value form */ | 1675 | /* GST_TAG_EXTENDED_COMMENT is already in key=value form */ |
1665 | if ((0 != strcmp (tag, "extended-comment")) || !strchr (str, '=')) | 1676 | if ((0 != strcmp (tag, "extended-comment")) || ! strchr (str, '=')) |
1666 | { | 1677 | { |
1667 | new_str = g_strdup_printf ("%s=%s", tag, str); | 1678 | new_str = g_strdup_printf ("%s=%s", tag, str); |
1668 | if (NULL != str) | 1679 | if (NULL != str) |
@@ -1693,12 +1704,12 @@ send_tag_foreach (const GstTagList * tags, | |||
1693 | 1704 | ||
1694 | static void | 1705 | static void |
1695 | send_streams (GstDiscovererStreamInfo *info, | 1706 | send_streams (GstDiscovererStreamInfo *info, |
1696 | struct PrivStruct *ps); | 1707 | struct PrivStruct *ps); |
1697 | 1708 | ||
1698 | 1709 | ||
1699 | static void | 1710 | static void |
1700 | send_stream_info (GstDiscovererStreamInfo * info, | 1711 | send_stream_info (GstDiscovererStreamInfo *info, |
1701 | struct PrivStruct *ps) | 1712 | struct PrivStruct *ps) |
1702 | { | 1713 | { |
1703 | const GstStructure *misc; | 1714 | const GstStructure *misc; |
1704 | GstCaps *caps; | 1715 | GstCaps *caps; |
@@ -1722,9 +1733,11 @@ send_stream_info (GstDiscovererStreamInfo * info, | |||
1722 | if (g_str_has_prefix (structname, "image/")) | 1733 | if (g_str_has_prefix (structname, "image/")) |
1723 | ps->st = STREAM_TYPE_IMAGE; | 1734 | ps->st = STREAM_TYPE_IMAGE; |
1724 | ps->time_to_leave = ps->ec->proc (ps->ec->cls, "gstreamer", | 1735 | ps->time_to_leave = ps->ec->proc (ps->ec->cls, "gstreamer", |
1725 | EXTRACTOR_METATYPE_MIMETYPE, EXTRACTOR_METAFORMAT_UTF8, "text/plain", | 1736 | EXTRACTOR_METATYPE_MIMETYPE, |
1726 | (const char *) structname, strlen (structname) + 1); | 1737 | EXTRACTOR_METAFORMAT_UTF8, "text/plain", |
1727 | if (!ps->time_to_leave) | 1738 | (const char *) structname, strlen ( |
1739 | structname) + 1); | ||
1740 | if (! ps->time_to_leave) | ||
1728 | { | 1741 | { |
1729 | gst_structure_foreach (structure, send_structure_foreach, ps); | 1742 | gst_structure_foreach (structure, send_structure_foreach, ps); |
1730 | } | 1743 | } |
@@ -1770,8 +1783,8 @@ send_stream_info (GstDiscovererStreamInfo * info, | |||
1770 | GList *child; | 1783 | GList *child; |
1771 | GstDiscovererContainerInfo *c = GST_DISCOVERER_CONTAINER_INFO (info); | 1784 | GstDiscovererContainerInfo *c = GST_DISCOVERER_CONTAINER_INFO (info); |
1772 | GList *children = gst_discoverer_container_info_get_streams (c); | 1785 | GList *children = gst_discoverer_container_info_get_streams (c); |
1773 | for (child = children; (NULL != child) && (!ps->time_to_leave); | 1786 | for (child = children; (NULL != child) && (! ps->time_to_leave); |
1774 | child = child->next) | 1787 | child = child->next) |
1775 | { | 1788 | { |
1776 | GstDiscovererStreamInfo *sinfo = child->data; | 1789 | GstDiscovererStreamInfo *sinfo = child->data; |
1777 | /* send_streams () will unref it */ | 1790 | /* send_streams () will unref it */ |
@@ -1786,7 +1799,7 @@ send_stream_info (GstDiscovererStreamInfo * info, | |||
1786 | 1799 | ||
1787 | static void | 1800 | static void |
1788 | send_streams (GstDiscovererStreamInfo *info, | 1801 | send_streams (GstDiscovererStreamInfo *info, |
1789 | struct PrivStruct *ps) | 1802 | struct PrivStruct *ps) |
1790 | { | 1803 | { |
1791 | GstDiscovererStreamInfo *next; | 1804 | GstDiscovererStreamInfo *next; |
1792 | 1805 | ||
@@ -1808,9 +1821,9 @@ send_streams (GstDiscovererStreamInfo *info, | |||
1808 | * @param user_data the 'struct PrivStruct' with the 'toc' string we are assembling | 1821 | * @param user_data the 'struct PrivStruct' with the 'toc' string we are assembling |
1809 | */ | 1822 | */ |
1810 | static void | 1823 | static void |
1811 | send_toc_tags_foreach (const GstTagList * tags, | 1824 | send_toc_tags_foreach (const GstTagList *tags, |
1812 | const gchar * tag, | 1825 | const gchar *tag, |
1813 | gpointer user_data) | 1826 | gpointer user_data) |
1814 | { | 1827 | { |
1815 | struct PrivStruct *ps = user_data; | 1828 | struct PrivStruct *ps = user_data; |
1816 | GValue val = { 0 }; | 1829 | GValue val = { 0 }; |
@@ -1899,9 +1912,11 @@ send_toc_foreach (gpointer data, gpointer user_data) | |||
1899 | return; | 1912 | return; |
1900 | gst_toc_entry_get_start_stop_times (entry, &start, &stop); | 1913 | gst_toc_entry_get_start_stop_times (entry, &start, &stop); |
1901 | s = g_strdup_printf ("%*.*s<%s start=\"%" GST_TIME_FORMAT "\" stop=\"%" | 1914 | s = g_strdup_printf ("%*.*s<%s start=\"%" GST_TIME_FORMAT "\" stop=\"%" |
1902 | GST_TIME_FORMAT"\">\n", ps->toc_depth * 2, ps->toc_depth * 2, " ", | 1915 | GST_TIME_FORMAT "\">\n", ps->toc_depth * 2, |
1903 | gst_toc_entry_type_get_nick (entype), GST_TIME_ARGS (start), | 1916 | ps->toc_depth * 2, " ", |
1904 | GST_TIME_ARGS (stop)); | 1917 | gst_toc_entry_type_get_nick (entype), GST_TIME_ARGS ( |
1918 | start), | ||
1919 | GST_TIME_ARGS (stop)); | ||
1905 | if (NULL != s) | 1920 | if (NULL != s) |
1906 | { | 1921 | { |
1907 | if (ps->toc_print_phase) | 1922 | if (ps->toc_print_phase) |
@@ -1916,21 +1931,25 @@ send_toc_foreach (gpointer data, gpointer user_data) | |||
1916 | ps->toc_depth++; | 1931 | ps->toc_depth++; |
1917 | tags = gst_toc_entry_get_tags (entry); | 1932 | tags = gst_toc_entry_get_tags (entry); |
1918 | if (tags) | 1933 | if (tags) |
1919 | { | 1934 | { |
1920 | if (ps->toc_print_phase) | 1935 | if (ps->toc_print_phase) |
1921 | ps->toc_pos += g_snprintf (&ps->toc[ps->toc_pos], ps->toc_length - ps->toc_pos, | 1936 | ps->toc_pos += g_snprintf (&ps->toc[ps->toc_pos], ps->toc_length |
1922 | "%*.*s<tags>\n", ps->toc_depth * 2, ps->toc_depth * 2, " "); | 1937 | - ps->toc_pos, |
1923 | else | 1938 | "%*.*s<tags>\n", ps->toc_depth * 2, |
1924 | ps->toc_length += strlen ("<tags>\n") + ps->toc_depth * 2; | 1939 | ps->toc_depth * 2, " "); |
1925 | ps->toc_depth++; | 1940 | else |
1926 | gst_tag_list_foreach (tags, &send_toc_tags_foreach, ps); | 1941 | ps->toc_length += strlen ("<tags>\n") + ps->toc_depth * 2; |
1927 | ps->toc_depth--; | 1942 | ps->toc_depth++; |
1928 | if (ps->toc_print_phase) | 1943 | gst_tag_list_foreach (tags, &send_toc_tags_foreach, ps); |
1929 | ps->toc_pos += g_snprintf (&ps->toc[ps->toc_pos], ps->toc_length - ps->toc_pos, | 1944 | ps->toc_depth--; |
1930 | "%*.*s</tags>\n", ps->toc_depth * 2, ps->toc_depth * 2, " "); | 1945 | if (ps->toc_print_phase) |
1931 | else | 1946 | ps->toc_pos += g_snprintf (&ps->toc[ps->toc_pos], ps->toc_length |
1932 | ps->toc_length += strlen ("</tags>\n") + ps->toc_depth * 2; | 1947 | - ps->toc_pos, |
1933 | } | 1948 | "%*.*s</tags>\n", ps->toc_depth * 2, |
1949 | ps->toc_depth * 2, " "); | ||
1950 | else | ||
1951 | ps->toc_length += strlen ("</tags>\n") + ps->toc_depth * 2; | ||
1952 | } | ||
1934 | 1953 | ||
1935 | subentries = gst_toc_entry_get_sub_entries (entry); | 1954 | subentries = gst_toc_entry_get_sub_entries (entry); |
1936 | g_list_foreach (subentries, send_toc_foreach, ps); | 1955 | g_list_foreach (subentries, send_toc_foreach, ps); |
@@ -1939,11 +1958,12 @@ send_toc_foreach (gpointer data, gpointer user_data) | |||
1939 | s = g_strdup_printf ("%*.*s</%s>\n", | 1958 | s = g_strdup_printf ("%*.*s</%s>\n", |
1940 | ps->toc_depth * 2, | 1959 | ps->toc_depth * 2, |
1941 | ps->toc_depth * 2, " ", | 1960 | ps->toc_depth * 2, " ", |
1942 | gst_toc_entry_type_get_nick (entype)); | 1961 | gst_toc_entry_type_get_nick (entype)); |
1943 | if (NULL != s) | 1962 | if (NULL != s) |
1944 | { | 1963 | { |
1945 | if (ps->toc_print_phase) | 1964 | if (ps->toc_print_phase) |
1946 | ps->toc_pos += g_snprintf (&ps->toc[ps->toc_pos], ps->toc_length - ps->toc_pos, "%s", s); | 1965 | ps->toc_pos += g_snprintf (&ps->toc[ps->toc_pos], ps->toc_length |
1966 | - ps->toc_pos, "%s", s); | ||
1947 | else | 1967 | else |
1948 | ps->toc_length += strlen (s); | 1968 | ps->toc_length += strlen (s); |
1949 | g_free (s); | 1969 | g_free (s); |
@@ -1958,8 +1978,8 @@ send_toc_foreach (gpointer data, gpointer user_data) | |||
1958 | 1978 | ||
1959 | 1979 | ||
1960 | static void | 1980 | static void |
1961 | send_info (GstDiscovererInfo * info, | 1981 | send_info (GstDiscovererInfo *info, |
1962 | struct PrivStruct *ps) | 1982 | struct PrivStruct *ps) |
1963 | { | 1983 | { |
1964 | const GstToc *toc; | 1984 | const GstToc *toc; |
1965 | gchar *s; | 1985 | gchar *s; |
@@ -1992,9 +2012,7 @@ send_info (GstDiscovererInfo * info, | |||
1992 | { | 2012 | { |
1993 | gst_tag_list_foreach (tags, send_tag_foreach, ps); | 2013 | gst_tag_list_foreach (tags, send_tag_foreach, ps); |
1994 | } | 2014 | } |
1995 | */ | 2015 | */if (ps->time_to_leave) |
1996 | |||
1997 | if (ps->time_to_leave) | ||
1998 | return; | 2016 | return; |
1999 | 2017 | ||
2000 | if ((toc = gst_discoverer_info_get_toc (info))) | 2018 | if ((toc = gst_discoverer_info_get_toc (info))) |
@@ -2040,8 +2058,8 @@ send_info (GstDiscovererInfo * info, | |||
2040 | 2058 | ||
2041 | 2059 | ||
2042 | static void | 2060 | static void |
2043 | send_discovered_info (GstDiscovererInfo * info, | 2061 | send_discovered_info (GstDiscovererInfo *info, |
2044 | struct PrivStruct * ps) | 2062 | struct PrivStruct *ps) |
2045 | { | 2063 | { |
2046 | GstDiscovererResult result; | 2064 | GstDiscovererResult result; |
2047 | 2065 | ||
@@ -2051,20 +2069,20 @@ send_discovered_info (GstDiscovererInfo * info, | |||
2051 | result = gst_discoverer_info_get_result (info); | 2069 | result = gst_discoverer_info_get_result (info); |
2052 | 2070 | ||
2053 | switch (result) | 2071 | switch (result) |
2054 | { | 2072 | { |
2055 | case GST_DISCOVERER_OK: | 2073 | case GST_DISCOVERER_OK: |
2056 | break; | 2074 | break; |
2057 | case GST_DISCOVERER_URI_INVALID: | 2075 | case GST_DISCOVERER_URI_INVALID: |
2058 | break; | 2076 | break; |
2059 | case GST_DISCOVERER_ERROR: | 2077 | case GST_DISCOVERER_ERROR: |
2060 | break; | 2078 | break; |
2061 | case GST_DISCOVERER_TIMEOUT: | 2079 | case GST_DISCOVERER_TIMEOUT: |
2062 | break; | 2080 | break; |
2063 | case GST_DISCOVERER_BUSY: | 2081 | case GST_DISCOVERER_BUSY: |
2064 | break; | 2082 | break; |
2065 | case GST_DISCOVERER_MISSING_PLUGINS: | 2083 | case GST_DISCOVERER_MISSING_PLUGINS: |
2066 | break; | 2084 | break; |
2067 | } | 2085 | } |
2068 | pthread_mutex_lock (&pipe_mutex); | 2086 | pthread_mutex_lock (&pipe_mutex); |
2069 | send_info (info, ps); | 2087 | send_info (info, ps); |
2070 | pthread_mutex_unlock (&pipe_mutex); | 2088 | pthread_mutex_unlock (&pipe_mutex); |
@@ -2072,20 +2090,21 @@ send_discovered_info (GstDiscovererInfo * info, | |||
2072 | 2090 | ||
2073 | 2091 | ||
2074 | static void | 2092 | static void |
2075 | _new_discovered_uri (GstDiscoverer * dc, | 2093 | _new_discovered_uri (GstDiscoverer *dc, |
2076 | GstDiscovererInfo * info, | 2094 | GstDiscovererInfo *info, |
2077 | GError * err, | 2095 | GError *err, |
2078 | struct PrivStruct *ps) | 2096 | struct PrivStruct *ps) |
2079 | { | 2097 | { |
2080 | send_discovered_info (info, ps); | 2098 | send_discovered_info (info, ps); |
2081 | if (ps->timeout_id > 0) | 2099 | if (ps->timeout_id > 0) |
2082 | g_source_remove (ps->timeout_id); | 2100 | g_source_remove (ps->timeout_id); |
2083 | ps->timeout_id = g_timeout_add (DATA_TIMEOUT, (GSourceFunc) _data_timeout, ps); | 2101 | ps->timeout_id = g_timeout_add (DATA_TIMEOUT, (GSourceFunc) _data_timeout, |
2102 | ps); | ||
2084 | } | 2103 | } |
2085 | 2104 | ||
2086 | 2105 | ||
2087 | static void | 2106 | static void |
2088 | _discoverer_finished (GstDiscoverer * dc, struct PrivStruct *ps) | 2107 | _discoverer_finished (GstDiscoverer *dc, struct PrivStruct *ps) |
2089 | { | 2108 | { |
2090 | if (ps->timeout_id > 0) | 2109 | if (ps->timeout_id > 0) |
2091 | g_source_remove (ps->timeout_id); | 2110 | g_source_remove (ps->timeout_id); |
@@ -2105,9 +2124,9 @@ _discoverer_finished (GstDiscoverer * dc, struct PrivStruct *ps) | |||
2105 | * @param ps | 2124 | * @param ps |
2106 | */ | 2125 | */ |
2107 | static void | 2126 | static void |
2108 | _source_setup (GstDiscoverer * dc, | 2127 | _source_setup (GstDiscoverer *dc, |
2109 | GstElement * source, | 2128 | GstElement *source, |
2110 | struct PrivStruct *ps) | 2129 | struct PrivStruct *ps) |
2111 | { | 2130 | { |
2112 | if (ps->source) | 2131 | if (ps->source) |
2113 | gst_object_unref (GST_OBJECT (ps->source)); | 2132 | gst_object_unref (GST_OBJECT (ps->source)); |
@@ -2120,7 +2139,8 @@ _source_setup (GstDiscoverer * dc, | |||
2120 | if (ps->length > 0) | 2139 | if (ps->length > 0) |
2121 | { | 2140 | { |
2122 | g_object_set (ps->source, "size", (gint64) ps->length, NULL); | 2141 | g_object_set (ps->source, "size", (gint64) ps->length, NULL); |
2123 | gst_util_set_object_arg (G_OBJECT (ps->source), "stream-type", "random-access"); | 2142 | gst_util_set_object_arg (G_OBJECT (ps->source), "stream-type", |
2143 | "random-access"); | ||
2124 | } | 2144 | } |
2125 | else | 2145 | else |
2126 | gst_util_set_object_arg (G_OBJECT (ps->source), "stream-type", "seekable"); | 2146 | gst_util_set_object_arg (G_OBJECT (ps->source), "stream-type", "seekable"); |
@@ -2129,16 +2149,16 @@ _source_setup (GstDiscoverer * dc, | |||
2129 | * data */ | 2149 | * data */ |
2130 | g_signal_connect (ps->source, "need-data", G_CALLBACK (feed_data), ps); | 2150 | g_signal_connect (ps->source, "need-data", G_CALLBACK (feed_data), ps); |
2131 | g_signal_connect (ps->source, "seek-data", G_CALLBACK (seek_data), ps); | 2151 | g_signal_connect (ps->source, "seek-data", G_CALLBACK (seek_data), ps); |
2132 | ps->timeout_id = g_timeout_add (DATA_TIMEOUT, (GSourceFunc) _data_timeout, ps); | 2152 | ps->timeout_id = g_timeout_add (DATA_TIMEOUT, (GSourceFunc) _data_timeout, |
2153 | ps); | ||
2133 | } | 2154 | } |
2134 | 2155 | ||
2135 | 2156 | ||
2136 | |||
2137 | static void | 2157 | static void |
2138 | log_handler (const gchar *log_domain, | 2158 | log_handler (const gchar *log_domain, |
2139 | GLogLevelFlags log_level, | 2159 | GLogLevelFlags log_level, |
2140 | const gchar *message, | 2160 | const gchar *message, |
2141 | gpointer unused_data) | 2161 | gpointer unused_data) |
2142 | { | 2162 | { |
2143 | /* do nothing */ | 2163 | /* do nothing */ |
2144 | } | 2164 | } |
@@ -2151,11 +2171,12 @@ log_handler (const gchar *log_domain, | |||
2151 | * @return FALSE (always) | 2171 | * @return FALSE (always) |
2152 | */ | 2172 | */ |
2153 | static gboolean | 2173 | static gboolean |
2154 | _run_async (struct PrivStruct * ps) | 2174 | _run_async (struct PrivStruct *ps) |
2155 | { | 2175 | { |
2156 | g_log_set_default_handler (&log_handler, NULL); | 2176 | g_log_set_default_handler (&log_handler, NULL); |
2157 | g_log_set_handler (NULL, G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION, | 2177 | g_log_set_handler (NULL, G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL |
2158 | &log_handler, NULL); | 2178 | | G_LOG_FLAG_RECURSION, |
2179 | &log_handler, NULL); | ||
2159 | gst_discoverer_discover_uri_async (ps->dc, "appsrc://"); | 2180 | gst_discoverer_discover_uri_async (ps->dc, "appsrc://"); |
2160 | return FALSE; | 2181 | return FALSE; |
2161 | } | 2182 | } |
@@ -2178,11 +2199,11 @@ EXTRACTOR_gstreamer_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
2178 | memset (&ps, 0, sizeof (ps)); | 2199 | memset (&ps, 0, sizeof (ps)); |
2179 | ps.dc = gst_discoverer_new (8 * GST_SECOND, &err); | 2200 | ps.dc = gst_discoverer_new (8 * GST_SECOND, &err); |
2180 | if (NULL == ps.dc) | 2201 | if (NULL == ps.dc) |
2181 | { | 2202 | { |
2182 | if (NULL != err) | 2203 | if (NULL != err) |
2183 | g_error_free (err); | 2204 | g_error_free (err); |
2184 | return; | 2205 | return; |
2185 | } | 2206 | } |
2186 | if (NULL != err) | 2207 | if (NULL != err) |
2187 | g_error_free (err); | 2208 | g_error_free (err); |
2188 | /* connect signals */ | 2209 | /* connect signals */ |
@@ -2195,10 +2216,11 @@ EXTRACTOR_gstreamer_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
2195 | if (ps.length == UINT_MAX) | 2216 | if (ps.length == UINT_MAX) |
2196 | ps.length = 0; | 2217 | ps.length = 0; |
2197 | g_log_set_default_handler (&log_handler, NULL); | 2218 | g_log_set_default_handler (&log_handler, NULL); |
2198 | g_log_set_handler (NULL, G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION, | 2219 | g_log_set_handler (NULL, G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL |
2199 | &log_handler, NULL); | 2220 | | G_LOG_FLAG_RECURSION, |
2221 | &log_handler, NULL); | ||
2200 | gst_discoverer_start (ps.dc); | 2222 | gst_discoverer_start (ps.dc); |
2201 | g_idle_add ((GSourceFunc) &_run_async, &ps); | 2223 | g_idle_add ((GSourceFunc) & _run_async, &ps); |
2202 | g_main_loop_run (ps.loop); | 2224 | g_main_loop_run (ps.loop); |
2203 | if (ps.timeout_id > 0) | 2225 | if (ps.timeout_id > 0) |
2204 | g_source_remove (ps.timeout_id); | 2226 | g_source_remove (ps.timeout_id); |
@@ -2216,35 +2238,36 @@ gstreamer_init () | |||
2216 | { | 2238 | { |
2217 | gst_init (NULL, NULL); | 2239 | gst_init (NULL, NULL); |
2218 | g_log_set_default_handler (&log_handler, NULL); | 2240 | g_log_set_default_handler (&log_handler, NULL); |
2219 | g_log_set_handler (NULL, G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION, | 2241 | g_log_set_handler (NULL, G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL |
2220 | &log_handler, NULL); | 2242 | | G_LOG_FLAG_RECURSION, |
2243 | &log_handler, NULL); | ||
2221 | GST_DEBUG_CATEGORY_INIT (gstreamer_extractor, "GstExtractor", | 2244 | GST_DEBUG_CATEGORY_INIT (gstreamer_extractor, "GstExtractor", |
2222 | 0, "GStreamer-based libextractor plugin"); | 2245 | 0, "GStreamer-based libextractor plugin"); |
2223 | 2246 | ||
2224 | audio_quarks = g_new0 (GQuark, 4); | 2247 | audio_quarks = g_new0 (GQuark, 4); |
2225 | if (NULL != audio_quarks) | 2248 | if (NULL != audio_quarks) |
2226 | { | 2249 | { |
2227 | audio_quarks[0] = g_quark_from_string ("rate"); | 2250 | audio_quarks[0] = g_quark_from_string ("rate"); |
2228 | audio_quarks[1] = g_quark_from_string ("channels"); | 2251 | audio_quarks[1] = g_quark_from_string ("channels"); |
2229 | audio_quarks[2] = g_quark_from_string ("depth"); | 2252 | audio_quarks[2] = g_quark_from_string ("depth"); |
2230 | audio_quarks[3] = g_quark_from_string (NULL); | 2253 | audio_quarks[3] = g_quark_from_string (NULL); |
2231 | } | 2254 | } |
2232 | video_quarks = g_new0 (GQuark, 6); | 2255 | video_quarks = g_new0 (GQuark, 6); |
2233 | if (NULL != video_quarks) | 2256 | if (NULL != video_quarks) |
2234 | { | 2257 | { |
2235 | video_quarks[0] = g_quark_from_string ("width"); | 2258 | video_quarks[0] = g_quark_from_string ("width"); |
2236 | video_quarks[1] = g_quark_from_string ("height"); | 2259 | video_quarks[1] = g_quark_from_string ("height"); |
2237 | video_quarks[2] = g_quark_from_string ("framerate"); | 2260 | video_quarks[2] = g_quark_from_string ("framerate"); |
2238 | video_quarks[3] = g_quark_from_string ("max-framerate"); | 2261 | video_quarks[3] = g_quark_from_string ("max-framerate"); |
2239 | video_quarks[4] = g_quark_from_string ("pixel-aspect-ratio"); | 2262 | video_quarks[4] = g_quark_from_string ("pixel-aspect-ratio"); |
2240 | video_quarks[5] = g_quark_from_string (NULL); | 2263 | video_quarks[5] = g_quark_from_string (NULL); |
2241 | } | 2264 | } |
2242 | subtitle_quarks = g_new0 (GQuark, 2); | 2265 | subtitle_quarks = g_new0 (GQuark, 2); |
2243 | if (NULL != subtitle_quarks) | 2266 | if (NULL != subtitle_quarks) |
2244 | { | 2267 | { |
2245 | subtitle_quarks[0] = g_quark_from_string ("language-code"); | 2268 | subtitle_quarks[0] = g_quark_from_string ("language-code"); |
2246 | subtitle_quarks[1] = g_quark_from_string (NULL); | 2269 | subtitle_quarks[1] = g_quark_from_string (NULL); |
2247 | } | 2270 | } |
2248 | 2271 | ||
2249 | duration_quark = g_quark_from_string ("duration"); | 2272 | duration_quark = g_quark_from_string ("duration"); |
2250 | 2273 | ||
diff --git a/src/plugins/html_extractor.c b/src/plugins/html_extractor.c index 8cd4aba..5ebf97b 100644 --- a/src/plugins/html_extractor.c +++ b/src/plugins/html_extractor.c | |||
@@ -87,9 +87,9 @@ tag_to_type (const char *tag) | |||
87 | { | 87 | { |
88 | unsigned int i; | 88 | unsigned int i; |
89 | 89 | ||
90 | for (i=0; NULL != tagmap[i].name; i++) | 90 | for (i = 0; NULL != tagmap[i].name; i++) |
91 | if (0 == strcasecmp (tag, | 91 | if (0 == strcasecmp (tag, |
92 | tagmap[i].name)) | 92 | tagmap[i].name)) |
93 | return tagmap[i].type; | 93 | return tagmap[i].type; |
94 | return EXTRACTOR_METATYPE_RESERVED; | 94 | return EXTRACTOR_METATYPE_RESERVED; |
95 | } | 95 | } |
@@ -107,10 +107,10 @@ tag_to_type (const char *tag) | |||
107 | */ | 107 | */ |
108 | static Bool TIDY_CALL | 108 | static Bool TIDY_CALL |
109 | report_cb (TidyDoc doc, | 109 | report_cb (TidyDoc doc, |
110 | TidyReportLevel lvl, | 110 | TidyReportLevel lvl, |
111 | uint line, | 111 | uint line, |
112 | uint col, | 112 | uint col, |
113 | ctmbstr mssg) | 113 | ctmbstr mssg) |
114 | { | 114 | { |
115 | return 0; | 115 | return 0; |
116 | } | 116 | } |
@@ -130,7 +130,7 @@ get_byte_cb (void *sourceData) | |||
130 | 130 | ||
131 | if (1 != | 131 | if (1 != |
132 | ec->read (ec->cls, | 132 | ec->read (ec->cls, |
133 | &data, 1)) | 133 | &data, 1)) |
134 | return EndOfStream; | 134 | return EndOfStream; |
135 | return *(unsigned char*) data; | 135 | return *(unsigned char*) data; |
136 | } | 136 | } |
@@ -188,130 +188,129 @@ EXTRACTOR_html_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
188 | const char *mime; | 188 | const char *mime; |
189 | 189 | ||
190 | if (-1 == (iret = ec->read (ec->cls, | 190 | if (-1 == (iret = ec->read (ec->cls, |
191 | &data, | 191 | &data, |
192 | 16 * 1024))) | 192 | 16 * 1024))) |
193 | return; | 193 | return; |
194 | if (NULL == (mime = magic_buffer (magic, data, iret))) | 194 | if (NULL == (mime = magic_buffer (magic, data, iret))) |
195 | return; | 195 | return; |
196 | if (0 != strncmp (mime, | 196 | if (0 != strncmp (mime, |
197 | "text/html", | 197 | "text/html", |
198 | strlen ("text/html"))) | 198 | strlen ("text/html"))) |
199 | return; /* not HTML */ | 199 | return; /* not HTML */ |
200 | 200 | ||
201 | if (0 != ec->seek (ec->cls, 0, SEEK_SET)) | 201 | if (0 != ec->seek (ec->cls, 0, SEEK_SET)) |
202 | return; /* seek failed !? */ | 202 | return; /* seek failed !? */ |
203 | 203 | ||
204 | tidyInitSource (&src, ec, | 204 | tidyInitSource (&src, ec, |
205 | &get_byte_cb, | 205 | &get_byte_cb, |
206 | &unget_byte_cb, | 206 | &unget_byte_cb, |
207 | &eof_cb); | 207 | &eof_cb); |
208 | if (NULL == (doc = tidyCreate ())) | 208 | if (NULL == (doc = tidyCreate ())) |
209 | return; | 209 | return; |
210 | tidySetReportFilter (doc, &report_cb); | 210 | tidySetReportFilter (doc, &report_cb); |
211 | tidySetAppData (doc, ec); | 211 | tidySetAppData (doc, ec); |
212 | if (0 > tidyParseSource (doc, &src)) | 212 | if (0 > tidyParseSource (doc, &src)) |
213 | { | 213 | { |
214 | tidyRelease (doc); | 214 | tidyRelease (doc); |
215 | return; | 215 | return; |
216 | } | 216 | } |
217 | if (1 != tidyStatus (doc)) | 217 | if (1 != tidyStatus (doc)) |
218 | { | 218 | { |
219 | tidyRelease (doc); | 219 | tidyRelease (doc); |
220 | return; | 220 | return; |
221 | } | 221 | } |
222 | if (NULL == (head = tidyGetHead (doc))) | 222 | if (NULL == (head = tidyGetHead (doc))) |
223 | { | 223 | { |
224 | fprintf (stderr, "no head\n"); | 224 | fprintf (stderr, "no head\n"); |
225 | tidyRelease (doc); | 225 | tidyRelease (doc); |
226 | return; | 226 | return; |
227 | } | 227 | } |
228 | for (child = tidyGetChild (head); NULL != child; child = tidyGetNext (child)) | 228 | for (child = tidyGetChild (head); NULL != child; child = tidyGetNext (child)) |
229 | { | ||
230 | switch (tidyNodeGetType (child)) | ||
229 | { | 231 | { |
230 | switch (tidyNodeGetType(child)) | 232 | case TidyNode_Root: |
231 | { | 233 | break; |
232 | case TidyNode_Root: | 234 | case TidyNode_DocType: |
233 | break; | 235 | break; |
234 | case TidyNode_DocType: | 236 | case TidyNode_Comment: |
235 | break; | 237 | break; |
236 | case TidyNode_Comment: | 238 | case TidyNode_ProcIns: |
237 | break; | 239 | break; |
238 | case TidyNode_ProcIns: | 240 | case TidyNode_Text: |
239 | break; | 241 | break; |
240 | case TidyNode_Text: | 242 | case TidyNode_CDATA: |
241 | break; | 243 | break; |
242 | case TidyNode_CDATA: | 244 | case TidyNode_Section: |
243 | break; | 245 | break; |
244 | case TidyNode_Section: | 246 | case TidyNode_Asp: |
245 | break; | 247 | break; |
246 | case TidyNode_Asp: | 248 | case TidyNode_Jste: |
247 | break; | 249 | break; |
248 | case TidyNode_Jste: | 250 | case TidyNode_Php: |
249 | break; | 251 | break; |
250 | case TidyNode_Php: | 252 | case TidyNode_XmlDecl: |
251 | break; | 253 | break; |
252 | case TidyNode_XmlDecl: | 254 | case TidyNode_Start: |
253 | break; | 255 | case TidyNode_StartEnd: |
254 | case TidyNode_Start: | 256 | name = tidyNodeGetName (child); |
255 | case TidyNode_StartEnd: | 257 | if ( (0 == strcasecmp (name, "title")) && |
256 | name = tidyNodeGetName (child); | 258 | (NULL != (title = tidyGetChild (child))) ) |
257 | if ( (0 == strcasecmp (name, "title")) && | 259 | { |
258 | (NULL != (title = tidyGetChild (child))) ) | 260 | tidyBufInit (&tbuf); |
259 | { | 261 | tidyNodeGetValue (doc, title, &tbuf); |
260 | tidyBufInit (&tbuf); | 262 | /* add 0-termination */ |
261 | tidyNodeGetValue (doc, title, &tbuf); | 263 | tidyBufPutByte (&tbuf, 0); |
262 | /* add 0-termination */ | 264 | if (0 != |
263 | tidyBufPutByte (&tbuf, 0); | 265 | ec->proc (ec->cls, |
264 | if (0 != | 266 | "html", |
265 | ec->proc (ec->cls, | 267 | EXTRACTOR_METATYPE_TITLE, |
266 | "html", | 268 | EXTRACTOR_METAFORMAT_UTF8, |
267 | EXTRACTOR_METATYPE_TITLE, | 269 | "text/plain", |
268 | EXTRACTOR_METAFORMAT_UTF8, | 270 | (const char *) tbuf.bp, |
269 | "text/plain", | 271 | tbuf.size)) |
270 | (const char *) tbuf.bp, | 272 | { |
271 | tbuf.size)) | 273 | tidyBufFree (&tbuf); |
272 | { | 274 | goto CLEANUP; |
273 | tidyBufFree (&tbuf); | 275 | } |
274 | goto CLEANUP; | 276 | tidyBufFree (&tbuf); |
275 | } | 277 | break; |
276 | tidyBufFree (&tbuf); | 278 | } |
277 | break; | 279 | if (0 == strcasecmp (name, "meta")) |
278 | } | 280 | { |
279 | if (0 == strcasecmp (name, "meta")) | 281 | if (NULL == (attr = tidyAttrGetById (child, |
280 | { | 282 | TidyAttr_NAME))) |
281 | if (NULL == (attr = tidyAttrGetById (child, | 283 | break; |
282 | TidyAttr_NAME))) | 284 | if (EXTRACTOR_METATYPE_RESERVED == |
283 | break; | 285 | (type = tag_to_type (tidyAttrValue (attr)))) |
284 | if (EXTRACTOR_METATYPE_RESERVED == | 286 | break; |
285 | (type = tag_to_type (tidyAttrValue (attr)))) | 287 | if (NULL == (attr = tidyAttrGetById (child, |
286 | break; | 288 | TidyAttr_CONTENT))) |
287 | if (NULL == (attr = tidyAttrGetById (child, | 289 | break; |
288 | TidyAttr_CONTENT))) | 290 | name = tidyAttrValue (attr); |
289 | break; | 291 | if (0 != |
290 | name = tidyAttrValue (attr); | 292 | ec->proc (ec->cls, |
291 | if (0 != | 293 | "html", |
292 | ec->proc (ec->cls, | 294 | type, |
293 | "html", | 295 | EXTRACTOR_METAFORMAT_UTF8, |
294 | type, | 296 | "text/plain", |
295 | EXTRACTOR_METAFORMAT_UTF8, | 297 | name, |
296 | "text/plain", | 298 | strlen (name) + 1)) |
297 | name, | 299 | goto CLEANUP; |
298 | strlen (name) + 1)) | 300 | break; |
299 | goto CLEANUP; | 301 | } |
300 | break; | 302 | break; |
301 | } | 303 | case TidyNode_End: |
302 | break; | 304 | break; |
303 | case TidyNode_End: | 305 | default: |
304 | break; | 306 | break; |
305 | default: | ||
306 | break; | ||
307 | } | ||
308 | } | 307 | } |
309 | CLEANUP: | 308 | } |
309 | CLEANUP: | ||
310 | tidyRelease (doc); | 310 | tidyRelease (doc); |
311 | } | 311 | } |
312 | 312 | ||
313 | 313 | ||
314 | |||
315 | #if OLD | 314 | #if OLD |
316 | 315 | ||
317 | 316 | ||
@@ -323,66 +322,71 @@ tagMatch (const char *tag, const char *s, const char *e) | |||
323 | return (((e - s) == strlen (tag)) && (0 == strncasecmp (tag, s, e - s))); | 322 | return (((e - s) == strlen (tag)) && (0 == strncasecmp (tag, s, e - s))); |
324 | } | 323 | } |
325 | 324 | ||
325 | |||
326 | static int | 326 | static int |
327 | lookFor (char c, size_t * pos, const char *data, size_t size) | 327 | lookFor (char c, size_t *pos, const char *data, size_t size) |
328 | { | 328 | { |
329 | size_t p = *pos; | 329 | size_t p = *pos; |
330 | 330 | ||
331 | while ((p < size) && (data[p] != c)) | 331 | while ((p < size) && (data[p] != c)) |
332 | { | 332 | { |
333 | if (data[p] == '\0') | 333 | if (data[p] == '\0') |
334 | return 0; | 334 | return 0; |
335 | p++; | 335 | p++; |
336 | } | 336 | } |
337 | *pos = p; | 337 | *pos = p; |
338 | return p < size; | 338 | return p < size; |
339 | } | 339 | } |
340 | 340 | ||
341 | |||
341 | static int | 342 | static int |
342 | skipWhitespace (size_t * pos, const char *data, size_t size) | 343 | skipWhitespace (size_t *pos, const char *data, size_t size) |
343 | { | 344 | { |
344 | size_t p = *pos; | 345 | size_t p = *pos; |
345 | 346 | ||
346 | while ((p < size) && (isspace ( (unsigned char) data[p]))) | 347 | while ((p < size) && (isspace ( (unsigned char) data[p]))) |
347 | { | 348 | { |
348 | if (data[p] == '\0') | 349 | if (data[p] == '\0') |
349 | return 0; | 350 | return 0; |
350 | p++; | 351 | p++; |
351 | } | 352 | } |
352 | *pos = p; | 353 | *pos = p; |
353 | return p < size; | 354 | return p < size; |
354 | } | 355 | } |
355 | 356 | ||
357 | |||
356 | static int | 358 | static int |
357 | skipLetters (size_t * pos, const char *data, size_t size) | 359 | skipLetters (size_t *pos, const char *data, size_t size) |
358 | { | 360 | { |
359 | size_t p = *pos; | 361 | size_t p = *pos; |
360 | 362 | ||
361 | while ((p < size) && (isalpha ( (unsigned char) data[p]))) | 363 | while ((p < size) && (isalpha ( (unsigned char) data[p]))) |
362 | { | 364 | { |
363 | if (data[p] == '\0') | 365 | if (data[p] == '\0') |
364 | return 0; | 366 | return 0; |
365 | p++; | 367 | p++; |
366 | } | 368 | } |
367 | *pos = p; | 369 | *pos = p; |
368 | return p < size; | 370 | return p < size; |
369 | } | 371 | } |
370 | 372 | ||
373 | |||
371 | static int | 374 | static int |
372 | lookForMultiple (const char *c, size_t * pos, const char *data, size_t size) | 375 | lookForMultiple (const char *c, size_t *pos, const char *data, size_t size) |
373 | { | 376 | { |
374 | size_t p = *pos; | 377 | size_t p = *pos; |
375 | 378 | ||
376 | while ((p < size) && (strchr (c, data[p]) == NULL)) | 379 | while ((p < size) && (strchr (c, data[p]) == NULL)) |
377 | { | 380 | { |
378 | if (data[p] == '\0') | 381 | if (data[p] == '\0') |
379 | return 0; | 382 | return 0; |
380 | p++; | 383 | p++; |
381 | } | 384 | } |
382 | *pos = p; | 385 | *pos = p; |
383 | return p < size; | 386 | return p < size; |
384 | } | 387 | } |
385 | 388 | ||
389 | |||
386 | static void | 390 | static void |
387 | findEntry (const char *key, | 391 | findEntry (const char *key, |
388 | const char *start, | 392 | const char *start, |
@@ -394,32 +398,33 @@ findEntry (const char *key, | |||
394 | *mend = NULL; | 398 | *mend = NULL; |
395 | len = strlen (key); | 399 | len = strlen (key); |
396 | while (start < end - len - 1) | 400 | while (start < end - len - 1) |
401 | { | ||
402 | start++; | ||
403 | if (start[len] != '=') | ||
404 | continue; | ||
405 | if (0 == strncasecmp (start, key, len)) | ||
397 | { | 406 | { |
398 | start++; | 407 | start += len + 1; |
399 | if (start[len] != '=') | 408 | *mstart = start; |
400 | continue; | 409 | if ((*start == '\"') || (*start == '\'')) |
401 | if (0 == strncasecmp (start, key, len)) | 410 | { |
402 | { | 411 | start++; |
403 | start += len + 1; | 412 | while ((start < end) && (*start != **mstart)) |
404 | *mstart = start; | 413 | start++; |
405 | if ((*start == '\"') || (*start == '\'')) | 414 | (*mstart)++; /* skip quote */ |
406 | { | 415 | } |
407 | start++; | 416 | else |
408 | while ((start < end) && (*start != **mstart)) | 417 | { |
409 | start++; | 418 | while ((start < end) && (! isspace ( (unsigned char) *start))) |
410 | (*mstart)++; /* skip quote */ | 419 | start++; |
411 | } | 420 | } |
412 | else | 421 | *mend = start; |
413 | { | 422 | return; |
414 | while ((start < end) && (!isspace ( (unsigned char) *start))) | ||
415 | start++; | ||
416 | } | ||
417 | *mend = start; | ||
418 | return; | ||
419 | } | ||
420 | } | 423 | } |
424 | } | ||
421 | } | 425 | } |
422 | 426 | ||
427 | |||
423 | /** | 428 | /** |
424 | * Search all tags that correspond to "tagname". Example: | 429 | * Search all tags that correspond to "tagname". Example: |
425 | * If the tag is <meta name="foo" desc="bar">, and | 430 | * If the tag is <meta name="foo" desc="bar">, and |
@@ -430,7 +435,7 @@ findEntry (const char *key, | |||
430 | * @return NULL if nothing is found | 435 | * @return NULL if nothing is found |
431 | */ | 436 | */ |
432 | static char * | 437 | static char * |
433 | findInTags (struct TagInfo * t, | 438 | findInTags (struct TagInfo *t, |
434 | const char *tagname, | 439 | const char *tagname, |
435 | const char *keyname, const char *keyvalue, const char *searchname) | 440 | const char *keyname, const char *keyvalue, const char *searchname) |
436 | { | 441 | { |
@@ -438,26 +443,26 @@ findInTags (struct TagInfo * t, | |||
438 | const char *pend; | 443 | const char *pend; |
439 | 444 | ||
440 | while (t != NULL) | 445 | while (t != NULL) |
446 | { | ||
447 | if (tagMatch (tagname, t->tagStart, t->tagEnd)) | ||
441 | { | 448 | { |
442 | if (tagMatch (tagname, t->tagStart, t->tagEnd)) | 449 | findEntry (keyname, t->tagEnd, t->dataStart, &pstart, &pend); |
450 | if ((pstart != NULL) && (tagMatch (keyvalue, pstart, pend))) | ||
451 | { | ||
452 | findEntry (searchname, t->tagEnd, t->dataStart, &pstart, &pend); | ||
453 | if (pstart != NULL) | ||
443 | { | 454 | { |
444 | findEntry (keyname, t->tagEnd, t->dataStart, &pstart, &pend); | 455 | char *ret = malloc (pend - pstart + 1); |
445 | if ((pstart != NULL) && (tagMatch (keyvalue, pstart, pend))) | 456 | if (ret == NULL) |
446 | { | 457 | return NULL; |
447 | findEntry (searchname, t->tagEnd, t->dataStart, &pstart, &pend); | 458 | memcpy (ret, pstart, pend - pstart); |
448 | if (pstart != NULL) | 459 | ret[pend - pstart] = '\0'; |
449 | { | 460 | return ret; |
450 | char *ret = malloc (pend - pstart + 1); | ||
451 | if (ret == NULL) | ||
452 | return NULL; | ||
453 | memcpy (ret, pstart, pend - pstart); | ||
454 | ret[pend - pstart] = '\0'; | ||
455 | return ret; | ||
456 | } | ||
457 | } | ||
458 | } | 461 | } |
459 | t = t->next; | 462 | } |
460 | } | 463 | } |
464 | t = t->next; | ||
465 | } | ||
461 | return NULL; | 466 | return NULL; |
462 | } | 467 | } |
463 | 468 | ||
@@ -465,10 +470,10 @@ findInTags (struct TagInfo * t, | |||
465 | /* mimetype = text/html */ | 470 | /* mimetype = text/html */ |
466 | int | 471 | int |
467 | EXTRACTOR_html_extract (const char *data, | 472 | EXTRACTOR_html_extract (const char *data, |
468 | size_t size, | 473 | size_t size, |
469 | EXTRACTOR_MetaDataProcessor proc, | 474 | EXTRACTOR_MetaDataProcessor proc, |
470 | void *proc_cls, | 475 | void *proc_cls, |
471 | const char *options) | 476 | const char *options) |
472 | { | 477 | { |
473 | size_t xsize; | 478 | size_t xsize; |
474 | struct TagInfo *tags; | 479 | struct TagInfo *tags; |
@@ -494,60 +499,60 @@ EXTRACTOR_html_extract (const char *data, | |||
494 | tag.next = NULL; | 499 | tag.next = NULL; |
495 | pos = 0; | 500 | pos = 0; |
496 | while (pos < xsize) | 501 | while (pos < xsize) |
502 | { | ||
503 | if (! lookFor ('<', &pos, data, size)) | ||
504 | break; | ||
505 | tag.tagStart = &data[++pos]; | ||
506 | if (! skipLetters (&pos, data, size)) | ||
507 | break; | ||
508 | tag.tagEnd = &data[pos]; | ||
509 | if (! skipWhitespace (&pos, data, size)) | ||
510 | break; | ||
511 | STEP3: | ||
512 | if (! lookForMultiple (">\"\'", &pos, data, size)) | ||
513 | break; | ||
514 | if (data[pos] != '>') | ||
497 | { | 515 | { |
498 | if (!lookFor ('<', &pos, data, size)) | 516 | /* find end-quote, ignore escaped quotes (\') */ |
499 | break; | 517 | do |
500 | tag.tagStart = &data[++pos]; | 518 | { |
501 | if (!skipLetters (&pos, data, size)) | 519 | tpos = pos; |
502 | break; | 520 | pos++; |
503 | tag.tagEnd = &data[pos]; | 521 | if (! lookFor (data[tpos], &pos, data, size)) |
504 | if (!skipWhitespace (&pos, data, size)) | 522 | break; |
505 | break; | 523 | } |
506 | STEP3: | 524 | while (data[pos - 1] == '\\'); |
507 | if (!lookForMultiple (">\"\'", &pos, data, size)) | ||
508 | break; | ||
509 | if (data[pos] != '>') | ||
510 | { | ||
511 | /* find end-quote, ignore escaped quotes (\') */ | ||
512 | do | ||
513 | { | ||
514 | tpos = pos; | ||
515 | pos++; | ||
516 | if (!lookFor (data[tpos], &pos, data, size)) | ||
517 | break; | ||
518 | } | ||
519 | while (data[pos - 1] == '\\'); | ||
520 | pos++; | ||
521 | goto STEP3; | ||
522 | } | ||
523 | pos++; | 525 | pos++; |
524 | if (!skipWhitespace (&pos, data, size)) | 526 | goto STEP3; |
525 | break; | 527 | } |
526 | tag.dataStart = &data[pos]; | 528 | pos++; |
527 | if (!lookFor ('<', &pos, data, size)) | 529 | if (! skipWhitespace (&pos, data, size)) |
528 | break; | 530 | break; |
529 | tag.dataEnd = &data[pos]; | 531 | tag.dataStart = &data[pos]; |
530 | i = 0; | 532 | if (! lookFor ('<', &pos, data, size)) |
531 | while (relevantTags[i] != NULL) | 533 | break; |
532 | { | 534 | tag.dataEnd = &data[pos]; |
533 | if ((strlen (relevantTags[i]) == tag.tagEnd - tag.tagStart) && | 535 | i = 0; |
534 | (0 == strncasecmp (relevantTags[i], | 536 | while (relevantTags[i] != NULL) |
535 | tag.tagStart, tag.tagEnd - tag.tagStart))) | 537 | { |
536 | { | 538 | if ((strlen (relevantTags[i]) == tag.tagEnd - tag.tagStart) && |
537 | t = malloc (sizeof (struct TagInfo)); | 539 | (0 == strncasecmp (relevantTags[i], |
538 | if (t == NULL) | 540 | tag.tagStart, tag.tagEnd - tag.tagStart))) |
539 | return 0; | 541 | { |
540 | *t = tag; | 542 | t = malloc (sizeof (struct TagInfo)); |
541 | t->next = tags; | 543 | if (t == NULL) |
542 | tags = t; | 544 | return 0; |
543 | break; | 545 | *t = tag; |
544 | } | 546 | t->next = tags; |
545 | i++; | 547 | tags = t; |
546 | } | ||
547 | /* abort early if we hit the body tag */ | ||
548 | if (tagMatch ("body", tag.tagStart, tag.tagEnd)) | ||
549 | break; | 548 | break; |
549 | } | ||
550 | i++; | ||
550 | } | 551 | } |
552 | /* abort early if we hit the body tag */ | ||
553 | if (tagMatch ("body", tag.tagStart, tag.tagEnd)) | ||
554 | break; | ||
555 | } | ||
551 | 556 | ||
552 | /* fast exit */ | 557 | /* fast exit */ |
553 | if (tags == NULL) | 558 | if (tags == NULL) |
@@ -557,110 +562,112 @@ EXTRACTOR_html_extract (const char *data, | |||
557 | /* first, try to determine mime type and/or character set */ | 562 | /* first, try to determine mime type and/or character set */ |
558 | tmp = findInTags (tags, "meta", "http-equiv", "content-type", "content"); | 563 | tmp = findInTags (tags, "meta", "http-equiv", "content-type", "content"); |
559 | if (tmp != NULL) | 564 | if (tmp != NULL) |
560 | { | 565 | { |
561 | /* ideally, tmp == "test/html; charset=ISO-XXXX-Y" or something like that; | 566 | /* ideally, tmp == "test/html; charset=ISO-XXXX-Y" or something like that; |
562 | if text/html is present, we take that as the mime-type; if charset= | 567 | if text/html is present, we take that as the mime-type; if charset= |
563 | is present, we try to use that for character set conversion. */ | 568 | is present, we try to use that for character set conversion. */ |
564 | if (0 == strncasecmp (tmp, "text/html", strlen ("text/html"))) | 569 | if (0 == strncasecmp (tmp, "text/html", strlen ("text/html"))) |
565 | ret = proc (proc_cls, | 570 | ret = proc (proc_cls, |
566 | "html", | 571 | "html", |
567 | EXTRACTOR_METATYPE_MIMETYPE, | 572 | EXTRACTOR_METATYPE_MIMETYPE, |
568 | EXTRACTOR_METAFORMAT_UTF8, | 573 | EXTRACTOR_METAFORMAT_UTF8, |
569 | "text/plain", | 574 | "text/plain", |
570 | "text/html", | 575 | "text/html", |
571 | strlen ("text/html")+1); | 576 | strlen ("text/html") + 1); |
572 | charset = strcasestr (tmp, "charset="); | 577 | charset = strcasestr (tmp, "charset="); |
573 | if (charset != NULL) | 578 | if (charset != NULL) |
574 | charset = strdup (&charset[strlen ("charset=")]); | 579 | charset = strdup (&charset[strlen ("charset=")]); |
575 | free (tmp); | 580 | free (tmp); |
576 | } | 581 | } |
577 | i = 0; | 582 | i = 0; |
578 | while (tagmap[i].name != NULL) | 583 | while (tagmap[i].name != NULL) |
584 | { | ||
585 | tmp = findInTags (tags, "meta", "name", tagmap[i].name, "content"); | ||
586 | if ( (tmp != NULL) && | ||
587 | (ret == 0) ) | ||
579 | { | 588 | { |
580 | tmp = findInTags (tags, "meta", "name", tagmap[i].name, "content"); | 589 | if (charset == NULL) |
581 | if ( (tmp != NULL) && | 590 | { |
582 | (ret == 0) ) | 591 | ret = proc (proc_cls, |
592 | "html", | ||
593 | tagmap[i].type, | ||
594 | EXTRACTOR_METAFORMAT_C_STRING, | ||
595 | "text/plain", | ||
596 | tmp, | ||
597 | strlen (tmp) + 1); | ||
598 | } | ||
599 | else | ||
600 | { | ||
601 | xtmp = EXTRACTOR_common_convert_to_utf8 (tmp, | ||
602 | strlen (tmp), | ||
603 | charset); | ||
604 | if (xtmp != NULL) | ||
583 | { | 605 | { |
584 | if (charset == NULL) | 606 | ret = proc (proc_cls, |
585 | { | 607 | "html", |
586 | ret = proc (proc_cls, | 608 | tagmap[i].type, |
587 | "html", | 609 | EXTRACTOR_METAFORMAT_UTF8, |
588 | tagmap[i].type, | 610 | "text/plain", |
589 | EXTRACTOR_METAFORMAT_C_STRING, | 611 | xtmp, |
590 | "text/plain", | 612 | strlen (xtmp) + 1); |
591 | tmp, | 613 | free (xtmp); |
592 | strlen (tmp) + 1); | ||
593 | } | ||
594 | else | ||
595 | { | ||
596 | xtmp = EXTRACTOR_common_convert_to_utf8 (tmp, | ||
597 | strlen (tmp), | ||
598 | charset); | ||
599 | if (xtmp != NULL) | ||
600 | { | ||
601 | ret = proc (proc_cls, | ||
602 | "html", | ||
603 | tagmap[i].type, | ||
604 | EXTRACTOR_METAFORMAT_UTF8, | ||
605 | "text/plain", | ||
606 | xtmp, | ||
607 | strlen (xtmp) + 1); | ||
608 | free (xtmp); | ||
609 | } | ||
610 | } | ||
611 | } | 614 | } |
612 | if (tmp != NULL) | 615 | } |
613 | free (tmp); | ||
614 | i++; | ||
615 | } | 616 | } |
617 | if (tmp != NULL) | ||
618 | free (tmp); | ||
619 | i++; | ||
620 | } | ||
616 | while (tags != NULL) | 621 | while (tags != NULL) |
622 | { | ||
623 | t = tags; | ||
624 | if ( (tagMatch ("title", t->tagStart, t->tagEnd)) && | ||
625 | (ret == 0) ) | ||
617 | { | 626 | { |
618 | t = tags; | 627 | if (charset == NULL) |
619 | if ( (tagMatch ("title", t->tagStart, t->tagEnd)) && | 628 | { |
620 | (ret == 0) ) | 629 | xtmp = malloc (t->dataEnd - t->dataStart + 1); |
621 | { | 630 | if (xtmp != NULL) |
622 | if (charset == NULL) | 631 | { |
623 | { | 632 | memcpy (xtmp, t->dataStart, t->dataEnd - t->dataStart); |
624 | xtmp = malloc (t->dataEnd - t->dataStart + 1); | 633 | xtmp[t->dataEnd - t->dataStart] = '\0'; |
625 | if (xtmp != NULL) | 634 | ret = proc (proc_cls, |
626 | { | 635 | "html", |
627 | memcpy (xtmp, t->dataStart, t->dataEnd - t->dataStart); | 636 | EXTRACTOR_METATYPE_TITLE, |
628 | xtmp[t->dataEnd - t->dataStart] = '\0'; | 637 | EXTRACTOR_METAFORMAT_C_STRING, |
629 | ret = proc (proc_cls, | 638 | "text/plain", |
630 | "html", | 639 | xtmp, |
631 | EXTRACTOR_METATYPE_TITLE, | 640 | strlen (xtmp) + 1); |
632 | EXTRACTOR_METAFORMAT_C_STRING, | 641 | free (xtmp); |
633 | "text/plain", | 642 | } |
634 | xtmp, | 643 | } |
635 | strlen (xtmp) + 1); | 644 | else |
636 | free (xtmp); | 645 | { |
637 | } | 646 | xtmp = EXTRACTOR_common_convert_to_utf8 (t->dataStart, |
638 | } | 647 | t->dataEnd - t->dataStart, |
639 | else | 648 | charset); |
640 | { | 649 | if (xtmp != NULL) |
641 | xtmp = EXTRACTOR_common_convert_to_utf8 (t->dataStart, | 650 | { |
642 | t->dataEnd - t->dataStart, | 651 | ret = proc (proc_cls, |
643 | charset); | 652 | "html", |
644 | if (xtmp != NULL) | 653 | EXTRACTOR_METATYPE_TITLE, |
645 | { | 654 | EXTRACTOR_METAFORMAT_UTF8, |
646 | ret = proc (proc_cls, | 655 | "text/plain", |
647 | "html", | 656 | xtmp, |
648 | EXTRACTOR_METATYPE_TITLE, | 657 | strlen (xtmp) + 1); |
649 | EXTRACTOR_METAFORMAT_UTF8, | 658 | free (xtmp); |
650 | "text/plain", | 659 | } |
651 | xtmp, | 660 | } |
652 | strlen (xtmp) + 1); | ||
653 | free (xtmp); | ||
654 | } | ||
655 | } | ||
656 | } | ||
657 | tags = t->next; | ||
658 | free (t); | ||
659 | } | 661 | } |
662 | tags = t->next; | ||
663 | free (t); | ||
664 | } | ||
660 | if (charset != NULL) | 665 | if (charset != NULL) |
661 | free (charset); | 666 | free (charset); |
662 | return ret; | 667 | return ret; |
663 | } | 668 | } |
669 | |||
670 | |||
664 | #endif | 671 | #endif |
665 | 672 | ||
666 | 673 | ||
@@ -672,9 +679,9 @@ html_gobject_init () | |||
672 | { | 679 | { |
673 | magic = magic_open (MAGIC_MIME_TYPE); | 680 | magic = magic_open (MAGIC_MIME_TYPE); |
674 | if (0 != magic_load (magic, NULL)) | 681 | if (0 != magic_load (magic, NULL)) |
675 | { | 682 | { |
676 | /* FIXME: how to deal with errors? */ | 683 | /* FIXME: how to deal with errors? */ |
677 | } | 684 | } |
678 | } | 685 | } |
679 | 686 | ||
680 | 687 | ||
@@ -685,10 +692,11 @@ void __attribute__ ((destructor)) | |||
685 | html_ltdl_fini () | 692 | html_ltdl_fini () |
686 | { | 693 | { |
687 | if (NULL != magic) | 694 | if (NULL != magic) |
688 | { | 695 | { |
689 | magic_close (magic); | 696 | magic_close (magic); |
690 | magic = NULL; | 697 | magic = NULL; |
691 | } | 698 | } |
692 | } | 699 | } |
693 | 700 | ||
701 | |||
694 | /* end of html_extractor.c */ | 702 | /* end of html_extractor.c */ |
diff --git a/src/plugins/it_extractor.c b/src/plugins/it_extractor.c index 3d8803f..336392f 100644 --- a/src/plugins/it_extractor.c +++ b/src/plugins/it_extractor.c | |||
@@ -72,8 +72,8 @@ EXTRACTOR_it_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
72 | 72 | ||
73 | if ((ssize_t) HEADER_SIZE > | 73 | if ((ssize_t) HEADER_SIZE > |
74 | ec->read (ec->cls, | 74 | ec->read (ec->cls, |
75 | &data, | 75 | &data, |
76 | HEADER_SIZE)) | 76 | HEADER_SIZE)) |
77 | return; | 77 | return; |
78 | head = (struct Header *) data; | 78 | head = (struct Header *) data; |
79 | /* Check "magic" id bytes */ | 79 | /* Check "magic" id bytes */ |
@@ -81,40 +81,41 @@ EXTRACTOR_it_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
81 | return; | 81 | return; |
82 | /* Mime-type */ | 82 | /* Mime-type */ |
83 | if (0 != ec->proc (ec->cls, | 83 | if (0 != ec->proc (ec->cls, |
84 | "it", | 84 | "it", |
85 | EXTRACTOR_METATYPE_MIMETYPE, | 85 | EXTRACTOR_METATYPE_MIMETYPE, |
86 | EXTRACTOR_METAFORMAT_UTF8, | 86 | EXTRACTOR_METAFORMAT_UTF8, |
87 | "text/plain", | 87 | "text/plain", |
88 | "audio/x-mod", | 88 | "audio/x-mod", |
89 | strlen ("audio/x-mod") + 1)) | 89 | strlen ("audio/x-mod") + 1)) |
90 | return; | 90 | return; |
91 | 91 | ||
92 | /* Version of Tracker */ | 92 | /* Version of Tracker */ |
93 | snprintf (itversion, | 93 | snprintf (itversion, |
94 | sizeof (itversion), | 94 | sizeof (itversion), |
95 | "%d.%d", | 95 | "%d.%d", |
96 | (head->version[0] & 0x01), | 96 | (head->version[0] & 0x01), |
97 | head->version[1]); | 97 | head->version[1]); |
98 | if (0 != ec->proc (ec->cls, | 98 | if (0 != ec->proc (ec->cls, |
99 | "it", | 99 | "it", |
100 | EXTRACTOR_METATYPE_FORMAT_VERSION, | 100 | EXTRACTOR_METATYPE_FORMAT_VERSION, |
101 | EXTRACTOR_METAFORMAT_C_STRING, | 101 | EXTRACTOR_METAFORMAT_C_STRING, |
102 | "text/plain", | 102 | "text/plain", |
103 | itversion, | 103 | itversion, |
104 | strlen (itversion) + 1)) | 104 | strlen (itversion) + 1)) |
105 | return; | 105 | return; |
106 | 106 | ||
107 | /* Song title */ | 107 | /* Song title */ |
108 | memcpy (&title, head->title, 26); | 108 | memcpy (&title, head->title, 26); |
109 | title[26] = '\0'; | 109 | title[26] = '\0'; |
110 | if (0 != ec->proc (ec->cls, | 110 | if (0 != ec->proc (ec->cls, |
111 | "it", | 111 | "it", |
112 | EXTRACTOR_METATYPE_TITLE, | 112 | EXTRACTOR_METATYPE_TITLE, |
113 | EXTRACTOR_METAFORMAT_C_STRING, | 113 | EXTRACTOR_METAFORMAT_C_STRING, |
114 | "text/plain", | 114 | "text/plain", |
115 | title, | 115 | title, |
116 | strlen (title) + 1)) | 116 | strlen (title) + 1)) |
117 | return; | 117 | return; |
118 | } | 118 | } |
119 | 119 | ||
120 | |||
120 | /* end of it_extractor.c */ | 121 | /* end of it_extractor.c */ |
diff --git a/src/plugins/jpeg_extractor.c b/src/plugins/jpeg_extractor.c index d6c1f6f..24812bd 100644 --- a/src/plugins/jpeg_extractor.c +++ b/src/plugins/jpeg_extractor.c | |||
@@ -112,71 +112,73 @@ EXTRACTOR_jpeg_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
112 | jpeg_create_decompress (&jds); | 112 | jpeg_create_decompress (&jds); |
113 | jpeg_save_markers (&jds, JPEG_COM, 1024 * 8); | 113 | jpeg_save_markers (&jds, JPEG_COM, 1024 * 8); |
114 | while ( (1 == is_jpeg) || (rounds++ < 8) ) | 114 | while ( (1 == is_jpeg) || (rounds++ < 8) ) |
115 | { | ||
116 | if (-1 == (size = ec->read (ec->cls, | ||
117 | &buf, | ||
118 | 16 * 1024))) | ||
119 | break; | ||
120 | if (0 == size) | ||
121 | break; | ||
122 | jpeg_mem_src (&jds, buf, size); | ||
123 | if (0 == is_jpeg) | ||
115 | { | 124 | { |
116 | if (-1 == (size = ec->read (ec->cls, | 125 | if (JPEG_HEADER_OK == jpeg_read_header (&jds, 1)) |
117 | &buf, | 126 | is_jpeg = 1; /* ok, really a jpeg, keep going until the end */ |
118 | 16 * 1024))) | 127 | continue; |
119 | break; | ||
120 | if (0 == size) | ||
121 | break; | ||
122 | jpeg_mem_src (&jds, buf, size); | ||
123 | if (0 == is_jpeg) | ||
124 | { | ||
125 | if (JPEG_HEADER_OK == jpeg_read_header (&jds, 1)) | ||
126 | is_jpeg = 1; /* ok, really a jpeg, keep going until the end */ | ||
127 | continue; | ||
128 | } | ||
129 | jpeg_consume_input (&jds); | ||
130 | } | 128 | } |
129 | jpeg_consume_input (&jds); | ||
130 | } | ||
131 | 131 | ||
132 | if (1 != is_jpeg) | 132 | if (1 != is_jpeg) |
133 | goto EXIT; | 133 | goto EXIT; |
134 | if (0 != | 134 | if (0 != |
135 | ec->proc (ec->cls, | 135 | ec->proc (ec->cls, |
136 | "jpeg", | 136 | "jpeg", |
137 | EXTRACTOR_METATYPE_MIMETYPE, | 137 | EXTRACTOR_METATYPE_MIMETYPE, |
138 | EXTRACTOR_METAFORMAT_UTF8, | 138 | EXTRACTOR_METAFORMAT_UTF8, |
139 | "text/plain", | 139 | "text/plain", |
140 | "image/jpeg", | 140 | "image/jpeg", |
141 | strlen ("image/jpeg") + 1)) | 141 | strlen ("image/jpeg") + 1)) |
142 | goto EXIT; | 142 | goto EXIT; |
143 | snprintf (format, | 143 | snprintf (format, |
144 | sizeof (format), | 144 | sizeof (format), |
145 | "%ux%u", | 145 | "%ux%u", |
146 | (unsigned int) jds.image_width, | 146 | (unsigned int) jds.image_width, |
147 | (unsigned int) jds.image_height); | 147 | (unsigned int) jds.image_height); |
148 | if (0 != | 148 | if (0 != |
149 | ec->proc (ec->cls, | 149 | ec->proc (ec->cls, |
150 | "jpeg", | 150 | "jpeg", |
151 | EXTRACTOR_METATYPE_IMAGE_DIMENSIONS, | 151 | EXTRACTOR_METATYPE_IMAGE_DIMENSIONS, |
152 | EXTRACTOR_METAFORMAT_UTF8, | 152 | EXTRACTOR_METAFORMAT_UTF8, |
153 | "text/plain", | 153 | "text/plain", |
154 | format, | 154 | format, |
155 | strlen (format) + 1)) | 155 | strlen (format) + 1)) |
156 | goto EXIT; | 156 | goto EXIT; |
157 | for (mptr = jds.marker_list; NULL != mptr; mptr = mptr->next) | 157 | for (mptr = jds.marker_list; NULL != mptr; mptr = mptr->next) |
158 | { | 158 | { |
159 | size_t off; | 159 | size_t off; |
160 | 160 | ||
161 | if (JPEG_COM != mptr->marker) | 161 | if (JPEG_COM != mptr->marker) |
162 | continue; | 162 | continue; |
163 | off = 0; | 163 | off = 0; |
164 | while ( (off < mptr->data_length) && | 164 | while ( (off < mptr->data_length) && |
165 | (isspace (((const unsigned char *)mptr->data)[mptr->data_length - 1 - off])) ) | 165 | (isspace (((const unsigned char *) mptr->data)[mptr->data_length |
166 | off++; | 166 | - 1 - off])) ) |
167 | if (0 != | 167 | off++; |
168 | ec->proc (ec->cls, | 168 | if (0 != |
169 | "jpeg", | 169 | ec->proc (ec->cls, |
170 | EXTRACTOR_METATYPE_COMMENT, | 170 | "jpeg", |
171 | EXTRACTOR_METAFORMAT_C_STRING, | 171 | EXTRACTOR_METATYPE_COMMENT, |
172 | "text/plain", | 172 | EXTRACTOR_METAFORMAT_C_STRING, |
173 | (const char *) mptr->data, | 173 | "text/plain", |
174 | mptr->data_length - off)) | 174 | (const char *) mptr->data, |
175 | goto EXIT; | 175 | mptr->data_length - off)) |
176 | } | 176 | goto EXIT; |
177 | 177 | } | |
178 | EXIT: | 178 | |
179 | EXIT: | ||
179 | jpeg_destroy_decompress (&jds); | 180 | jpeg_destroy_decompress (&jds); |
180 | } | 181 | } |
181 | 182 | ||
183 | |||
182 | /* end of jpeg_extractor.c */ | 184 | /* end of jpeg_extractor.c */ |
diff --git a/src/plugins/man_extractor.c b/src/plugins/man_extractor.c index b92fc9e..86ba68d 100644 --- a/src/plugins/man_extractor.c +++ b/src/plugins/man_extractor.c | |||
@@ -59,35 +59,35 @@ stndup (const char *str, size_t n) | |||
59 | */ | 59 | */ |
60 | static int | 60 | static int |
61 | add_keyword (enum EXTRACTOR_MetaType type, | 61 | add_keyword (enum EXTRACTOR_MetaType type, |
62 | char *keyword, | 62 | char *keyword, |
63 | EXTRACTOR_MetaDataProcessor proc, | 63 | EXTRACTOR_MetaDataProcessor proc, |
64 | void *proc_cls) | 64 | void *proc_cls) |
65 | { | 65 | { |
66 | int ret; | 66 | int ret; |
67 | char *value; | 67 | char *value; |
68 | 68 | ||
69 | if (NULL == keyword) | 69 | if (NULL == keyword) |
70 | return 0; | 70 | return 0; |
71 | if ( (keyword[0] == '\"') && | 71 | if ( (keyword[0] == '\"') && |
72 | (keyword[strlen (keyword) - 1] == '\"') ) | 72 | (keyword[strlen (keyword) - 1] == '\"') ) |
73 | { | 73 | { |
74 | keyword[strlen (keyword) - 1] = '\0'; | 74 | keyword[strlen (keyword) - 1] = '\0'; |
75 | value = &keyword[1]; | 75 | value = &keyword[1]; |
76 | } | 76 | } |
77 | else | 77 | else |
78 | value = keyword; | 78 | value = keyword; |
79 | if (0 == strlen (value)) | 79 | if (0 == strlen (value)) |
80 | { | 80 | { |
81 | free (keyword); | 81 | free (keyword); |
82 | return 0; | 82 | return 0; |
83 | } | 83 | } |
84 | ret = proc (proc_cls, | 84 | ret = proc (proc_cls, |
85 | "man", | 85 | "man", |
86 | type, | 86 | type, |
87 | EXTRACTOR_METAFORMAT_UTF8, | 87 | EXTRACTOR_METAFORMAT_UTF8, |
88 | "text/plain", | 88 | "text/plain", |
89 | value, | 89 | value, |
90 | strlen (value)+1); | 90 | strlen (value) + 1); |
91 | free (keyword); | 91 | free (keyword); |
92 | return ret; | 92 | return ret; |
93 | } | 93 | } |
@@ -102,20 +102,20 @@ add_keyword (enum EXTRACTOR_MetaType type, | |||
102 | */ | 102 | */ |
103 | static void | 103 | static void |
104 | find_end_of_token (size_t *end, | 104 | find_end_of_token (size_t *end, |
105 | const char *buf, | 105 | const char *buf, |
106 | const size_t size) | 106 | const size_t size) |
107 | { | 107 | { |
108 | int quot; | 108 | int quot; |
109 | 109 | ||
110 | quot = 0; | 110 | quot = 0; |
111 | while ( (*end < size) && | 111 | while ( (*end < size) && |
112 | ( (0 != (quot & 1)) || | 112 | ( (0 != (quot & 1)) || |
113 | ((' ' != buf[*end])) ) ) | 113 | ((' ' != buf[*end])) ) ) |
114 | { | 114 | { |
115 | if ('\"' == buf[*end]) | 115 | if ('\"' == buf[*end]) |
116 | quot++; | 116 | quot++; |
117 | (*end)++; | 117 | (*end)++; |
118 | } | 118 | } |
119 | if (1 == (quot & 1)) | 119 | if (1 == (quot & 1)) |
120 | (*end) = size + 1; | 120 | (*end) = size + 1; |
121 | } | 121 | } |
@@ -130,15 +130,16 @@ find_end_of_token (size_t *end, | |||
130 | 130 | ||
131 | /** | 131 | /** |
132 | * Add a keyword to LE. | 132 | * Add a keyword to LE. |
133 | * | 133 | * |
134 | * @param t type to use | 134 | * @param t type to use |
135 | * @param s keyword to give to LE | 135 | * @param s keyword to give to LE |
136 | */ | 136 | */ |
137 | #define ADD(t,s) do { if (0 != add_keyword (t, s, ec->proc, ec->cls)) return; } while (0) | 137 | #define ADD(t,s) do { if (0 != add_keyword (t, s, ec->proc, ec->cls)) return; \ |
138 | } while (0) | ||
138 | 139 | ||
139 | 140 | ||
140 | /** | 141 | /** |
141 | * Main entry method for the man page extraction plugin. | 142 | * Main entry method for the man page extraction plugin. |
142 | * | 143 | * |
143 | * @param ec extraction context provided to the plugin | 144 | * @param ec extraction context provided to the plugin |
144 | */ | 145 | */ |
@@ -152,7 +153,7 @@ EXTRACTOR_man_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
152 | void *data; | 153 | void *data; |
153 | ssize_t size; | 154 | ssize_t size; |
154 | char *buf; | 155 | char *buf; |
155 | 156 | ||
156 | if (0 >= (size = ec->read (ec->cls, &data, MAX_READ))) | 157 | if (0 >= (size = ec->read (ec->cls, &data, MAX_READ))) |
157 | return; | 158 | return; |
158 | buf = data; | 159 | buf = data; |
@@ -162,17 +163,17 @@ EXTRACTOR_man_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
162 | /* find actual beginning of the man page (.TH); | 163 | /* find actual beginning of the man page (.TH); |
163 | abort if we find non-printable characters */ | 164 | abort if we find non-printable characters */ |
164 | while ( (pos < size - xlen) && | 165 | while ( (pos < size - xlen) && |
165 | ( (0 != strncmp (".TH ", | 166 | ( (0 != strncmp (".TH ", |
166 | &buf[pos], | 167 | &buf[pos], |
167 | xlen)) || | 168 | xlen)) || |
168 | ( (0 != pos) && | 169 | ( (0 != pos) && |
169 | (buf[pos - 1] != '\n') ) ) ) | 170 | (buf[pos - 1] != '\n') ) ) ) |
170 | { | 171 | { |
171 | if ( (! isgraph ((unsigned char) buf[pos])) && | 172 | if ( (! isgraph ((unsigned char) buf[pos])) && |
172 | (! isspace ((unsigned char) buf[pos])) ) | 173 | (! isspace ((unsigned char) buf[pos])) ) |
173 | return; | 174 | return; |
174 | pos++; | 175 | pos++; |
175 | } | 176 | } |
176 | if (0 != strncmp (".TH ", &buf[pos], xlen)) | 177 | if (0 != strncmp (".TH ", &buf[pos], xlen)) |
177 | return; | 178 | return; |
178 | 179 | ||
@@ -192,13 +193,13 @@ EXTRACTOR_man_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
192 | if (end > size) | 193 | if (end > size) |
193 | return; | 194 | return; |
194 | if (end > pos) | 195 | if (end > pos) |
195 | { | 196 | { |
196 | ADD (EXTRACTOR_METATYPE_TITLE, stndup (&buf[pos], end - pos)); | 197 | ADD (EXTRACTOR_METATYPE_TITLE, stndup (&buf[pos], end - pos)); |
197 | pos = end + 1; | 198 | pos = end + 1; |
198 | } | 199 | } |
199 | if (pos >= size) | 200 | if (pos >= size) |
200 | return; | 201 | return; |
201 | 202 | ||
202 | /* next token is the section */ | 203 | /* next token is the section */ |
203 | end = pos; | 204 | end = pos; |
204 | find_end_of_token (&end, buf, size); | 205 | find_end_of_token (&end, buf, size); |
@@ -207,62 +208,62 @@ EXTRACTOR_man_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
207 | if ('\"' == buf[pos]) | 208 | if ('\"' == buf[pos]) |
208 | pos++; | 209 | pos++; |
209 | if ((end - pos >= 1) && (end - pos <= 4)) | 210 | if ((end - pos >= 1) && (end - pos <= 4)) |
211 | { | ||
212 | switch (buf[pos]) | ||
210 | { | 213 | { |
211 | switch (buf[pos]) | 214 | case '1': |
212 | { | 215 | ADD (EXTRACTOR_METATYPE_SECTION, |
213 | case '1': | 216 | strdup (_ ("Commands"))); |
214 | ADD (EXTRACTOR_METATYPE_SECTION, | 217 | break; |
215 | strdup (_("Commands"))); | 218 | case '2': |
216 | break; | 219 | ADD (EXTRACTOR_METATYPE_SECTION, |
217 | case '2': | 220 | strdup (_ ("System calls"))); |
218 | ADD (EXTRACTOR_METATYPE_SECTION, | 221 | break; |
219 | strdup (_("System calls"))); | 222 | case '3': |
220 | break; | 223 | ADD (EXTRACTOR_METATYPE_SECTION, |
221 | case '3': | 224 | strdup (_ ("Library calls"))); |
222 | ADD (EXTRACTOR_METATYPE_SECTION, | 225 | break; |
223 | strdup (_("Library calls"))); | 226 | case '4': |
224 | break; | 227 | ADD (EXTRACTOR_METATYPE_SECTION, |
225 | case '4': | 228 | strdup (_ ("Special files"))); |
226 | ADD (EXTRACTOR_METATYPE_SECTION, | 229 | break; |
227 | strdup (_("Special files"))); | 230 | case '5': |
228 | break; | 231 | ADD (EXTRACTOR_METATYPE_SECTION, |
229 | case '5': | 232 | strdup (_ ("File formats and conventions"))); |
230 | ADD (EXTRACTOR_METATYPE_SECTION, | 233 | break; |
231 | strdup (_("File formats and conventions"))); | 234 | case '6': |
232 | break; | 235 | ADD (EXTRACTOR_METATYPE_SECTION, |
233 | case '6': | 236 | strdup (_ ("Games"))); |
234 | ADD (EXTRACTOR_METATYPE_SECTION, | 237 | break; |
235 | strdup (_("Games"))); | 238 | case '7': |
236 | break; | 239 | ADD (EXTRACTOR_METATYPE_SECTION, |
237 | case '7': | 240 | strdup (_ ("Conventions and miscellaneous"))); |
238 | ADD (EXTRACTOR_METATYPE_SECTION, | 241 | break; |
239 | strdup (_("Conventions and miscellaneous"))); | 242 | case '8': |
240 | break; | 243 | ADD (EXTRACTOR_METATYPE_SECTION, |
241 | case '8': | 244 | strdup (_ ("System management commands"))); |
242 | ADD (EXTRACTOR_METATYPE_SECTION, | 245 | break; |
243 | strdup (_("System management commands"))); | 246 | case '9': |
244 | break; | 247 | ADD (EXTRACTOR_METATYPE_SECTION, |
245 | case '9': | 248 | strdup (_ ("Kernel routines"))); |
246 | ADD (EXTRACTOR_METATYPE_SECTION, | 249 | break; |
247 | strdup (_("Kernel routines"))); | 250 | default: |
248 | break; | 251 | ADD (EXTRACTOR_METATYPE_SECTION, |
249 | default: | 252 | stndup (&buf[pos], 1)); |
250 | ADD (EXTRACTOR_METATYPE_SECTION, | ||
251 | stndup (&buf[pos], 1)); | ||
252 | } | ||
253 | pos = end + 1; | ||
254 | } | 253 | } |
254 | pos = end + 1; | ||
255 | } | ||
255 | end = pos; | 256 | end = pos; |
256 | 257 | ||
257 | /* next token is the modification date */ | 258 | /* next token is the modification date */ |
258 | find_end_of_token (&end, buf, size); | 259 | find_end_of_token (&end, buf, size); |
259 | if (end > size) | 260 | if (end > size) |
260 | return; | 261 | return; |
261 | if (end > pos) | 262 | if (end > pos) |
262 | { | 263 | { |
263 | ADD (EXTRACTOR_METATYPE_MODIFICATION_DATE, stndup (&buf[pos], end - pos)); | 264 | ADD (EXTRACTOR_METATYPE_MODIFICATION_DATE, stndup (&buf[pos], end - pos)); |
264 | pos = end + 1; | 265 | pos = end + 1; |
265 | } | 266 | } |
266 | 267 | ||
267 | /* next token is the source of the man page */ | 268 | /* next token is the source of the man page */ |
268 | end = pos; | 269 | end = pos; |
@@ -270,11 +271,11 @@ EXTRACTOR_man_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
270 | if (end > size) | 271 | if (end > size) |
271 | return; | 272 | return; |
272 | if (end > pos) | 273 | if (end > pos) |
273 | { | 274 | { |
274 | ADD (EXTRACTOR_METATYPE_SOURCE, | 275 | ADD (EXTRACTOR_METATYPE_SOURCE, |
275 | stndup (&buf[pos], end - pos)); | 276 | stndup (&buf[pos], end - pos)); |
276 | pos = end + 1; | 277 | pos = end + 1; |
277 | } | 278 | } |
278 | 279 | ||
279 | /* last token is the title of the book the man page belongs to */ | 280 | /* last token is the title of the book the man page belongs to */ |
280 | end = pos; | 281 | end = pos; |
@@ -282,11 +283,12 @@ EXTRACTOR_man_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
282 | if (end > size) | 283 | if (end > size) |
283 | return; | 284 | return; |
284 | if (end > pos) | 285 | if (end > pos) |
285 | { | 286 | { |
286 | ADD (EXTRACTOR_METATYPE_BOOK_TITLE, | 287 | ADD (EXTRACTOR_METATYPE_BOOK_TITLE, |
287 | stndup (&buf[pos], end - pos)); | 288 | stndup (&buf[pos], end - pos)); |
288 | pos = end + 1; | 289 | pos = end + 1; |
289 | } | 290 | } |
290 | } | 291 | } |
291 | 292 | ||
293 | |||
292 | /* end of man_extractor.c */ | 294 | /* end of man_extractor.c */ |
diff --git a/src/plugins/midi_extractor.c b/src/plugins/midi_extractor.c index 4ceff6a..66ea71d 100644 --- a/src/plugins/midi_extractor.c +++ b/src/plugins/midi_extractor.c | |||
@@ -31,27 +31,27 @@ | |||
31 | * Types of events in MIDI. | 31 | * Types of events in MIDI. |
32 | */ | 32 | */ |
33 | enum EventType | 33 | enum EventType |
34 | { | 34 | { |
35 | ET_SEQUENCE_NUMBER = 0, | 35 | ET_SEQUENCE_NUMBER = 0, |
36 | ET_TEXT_EVENT = 1, | 36 | ET_TEXT_EVENT = 1, |
37 | ET_COPYRIGHT_NOTICE = 2, | 37 | ET_COPYRIGHT_NOTICE = 2, |
38 | ET_TRACK_NAME = 3, | 38 | ET_TRACK_NAME = 3, |
39 | ET_INSTRUMENT_NAME = 4, | 39 | ET_INSTRUMENT_NAME = 4, |
40 | ET_LYRIC_TEXT = 5, | 40 | ET_LYRIC_TEXT = 5, |
41 | ET_MARKER_TEXT = 6, | 41 | ET_MARKER_TEXT = 6, |
42 | ET_CUE_POINT = 7, | 42 | ET_CUE_POINT = 7, |
43 | ET_CHANNEL_PREFIX_ASSIGNMENT = 0x20, | 43 | ET_CHANNEL_PREFIX_ASSIGNMENT = 0x20, |
44 | ET_END_OF_TRACK = 0x2F, | 44 | ET_END_OF_TRACK = 0x2F, |
45 | ET_TEMPO_SETTING = 0x51, | 45 | ET_TEMPO_SETTING = 0x51, |
46 | ET_SMPTE_OFFSET = 0x54, | 46 | ET_SMPTE_OFFSET = 0x54, |
47 | ET_TIME_SIGNATURE = 0x58, | 47 | ET_TIME_SIGNATURE = 0x58, |
48 | ET_KEY_SIGNATURE = 0x59, | 48 | ET_KEY_SIGNATURE = 0x59, |
49 | ET_SEQUENCE_SPECIRFIC_EVENT = 0x7F | 49 | ET_SEQUENCE_SPECIRFIC_EVENT = 0x7F |
50 | }; | 50 | }; |
51 | 51 | ||
52 | 52 | ||
53 | /** | 53 | /** |
54 | * Main entry method for the 'audio/midi' extraction plugin. | 54 | * Main entry method for the 'audio/midi' extraction plugin. |
55 | * | 55 | * |
56 | * @param ec extraction context provided to the plugin | 56 | * @param ec extraction context provided to the plugin |
57 | */ | 57 | */ |
@@ -66,7 +66,7 @@ EXTRACTOR_midi_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
66 | smf_t *m = NULL; | 66 | smf_t *m = NULL; |
67 | smf_event_t *event; | 67 | smf_event_t *event; |
68 | uint8_t len; | 68 | uint8_t len; |
69 | 69 | ||
70 | if (4 >= (iret = ec->read (ec->cls, &buf, 1024))) | 70 | if (4 >= (iret = ec->read (ec->cls, &buf, 1024))) |
71 | return; | 71 | return; |
72 | data = buf; | 72 | data = buf; |
@@ -81,103 +81,103 @@ EXTRACTOR_midi_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
81 | memcpy (data, buf, iret); | 81 | memcpy (data, buf, iret); |
82 | off = iret; | 82 | off = iret; |
83 | while (off < size) | 83 | while (off < size) |
84 | { | ||
85 | if (0 >= (iret = ec->read (ec->cls, &buf, 16 * 1024))) | ||
84 | { | 86 | { |
85 | if (0 >= (iret = ec->read (ec->cls, &buf, 16 * 1024))) | 87 | free (data); |
86 | { | 88 | return; |
87 | free (data); | 89 | } |
88 | return; | 90 | memcpy (&data[off], buf, iret); |
89 | } | 91 | off += iret; |
90 | memcpy (&data[off], buf, iret); | 92 | } |
91 | off += iret; | 93 | if (0 != ec->proc (ec->cls, |
92 | } | 94 | "midi", |
93 | if (0 != ec->proc (ec->cls, | 95 | EXTRACTOR_METATYPE_MIMETYPE, |
94 | "midi", | 96 | EXTRACTOR_METAFORMAT_UTF8, |
95 | EXTRACTOR_METATYPE_MIMETYPE, | 97 | "text/plain", |
96 | EXTRACTOR_METAFORMAT_UTF8, | 98 | "audio/midi", |
97 | "text/plain", | 99 | strlen ("audio/midi") + 1)) |
98 | "audio/midi", | ||
99 | strlen ("audio/midi") + 1)) | ||
100 | goto CLEANUP; | 100 | goto CLEANUP; |
101 | if (NULL == (m = smf_load_from_memory (data, size))) | 101 | if (NULL == (m = smf_load_from_memory (data, size))) |
102 | goto CLEANUP; | 102 | goto CLEANUP; |
103 | while (NULL != (event = smf_get_next_event (m))) | 103 | while (NULL != (event = smf_get_next_event (m))) |
104 | { | 104 | { |
105 | if (! smf_event_is_metadata (event)) | 105 | if (! smf_event_is_metadata (event)) |
106 | break; | 106 | break; |
107 | len = event->midi_buffer[2]; | 107 | len = event->midi_buffer[2]; |
108 | if ( (len > 0) && | 108 | if ( (len > 0) && |
109 | isspace (event->midi_buffer[2 + len])) | 109 | isspace (event->midi_buffer[2 + len])) |
110 | len--; | 110 | len--; |
111 | #if 0 | 111 | #if 0 |
112 | fprintf (stderr, | 112 | fprintf (stderr, |
113 | "type: %d, len: %d value: %.*s\n", | 113 | "type: %d, len: %d value: %.*s\n", |
114 | event->midi_buffer[1], | 114 | event->midi_buffer[1], |
115 | event->midi_buffer[2], | 115 | event->midi_buffer[2], |
116 | (int) event->midi_buffer_length - 3, | 116 | (int) event->midi_buffer_length - 3, |
117 | (char *) &event->midi_buffer[3]); | 117 | (char *) &event->midi_buffer[3]); |
118 | #endif | 118 | #endif |
119 | if (1 != event->track_number) | 119 | if (1 != event->track_number) |
120 | continue; /* heuristic to not get instruments */ | 120 | continue; /* heuristic to not get instruments */ |
121 | if (0 == len) | 121 | if (0 == len) |
122 | continue; | 122 | continue; |
123 | switch (event->midi_buffer[1]) | 123 | switch (event->midi_buffer[1]) |
124 | { | 124 | { |
125 | case ET_TEXT_EVENT: | 125 | case ET_TEXT_EVENT: |
126 | if (0 != ec->proc (ec->cls, | 126 | if (0 != ec->proc (ec->cls, |
127 | "midi", | 127 | "midi", |
128 | EXTRACTOR_METATYPE_COMMENT, | 128 | EXTRACTOR_METATYPE_COMMENT, |
129 | EXTRACTOR_METAFORMAT_UTF8, | 129 | EXTRACTOR_METAFORMAT_UTF8, |
130 | "text/plain", | 130 | "text/plain", |
131 | (void*) &event->midi_buffer[3], | 131 | (void*) &event->midi_buffer[3], |
132 | len)) | 132 | len)) |
133 | goto CLEANUP; | 133 | goto CLEANUP; |
134 | break; | 134 | break; |
135 | case ET_COPYRIGHT_NOTICE: | 135 | case ET_COPYRIGHT_NOTICE: |
136 | if (0 != ec->proc (ec->cls, | 136 | if (0 != ec->proc (ec->cls, |
137 | "midi", | 137 | "midi", |
138 | EXTRACTOR_METATYPE_COPYRIGHT, | 138 | EXTRACTOR_METATYPE_COPYRIGHT, |
139 | EXTRACTOR_METAFORMAT_UTF8, | 139 | EXTRACTOR_METAFORMAT_UTF8, |
140 | "text/plain", | 140 | "text/plain", |
141 | (void*) &event->midi_buffer[3], | 141 | (void*) &event->midi_buffer[3], |
142 | len)) | 142 | len)) |
143 | goto CLEANUP; | 143 | goto CLEANUP; |
144 | break; | 144 | break; |
145 | case ET_TRACK_NAME: | 145 | case ET_TRACK_NAME: |
146 | if (0 != ec->proc (ec->cls, | 146 | if (0 != ec->proc (ec->cls, |
147 | "midi", | 147 | "midi", |
148 | EXTRACTOR_METATYPE_TITLE, | 148 | EXTRACTOR_METATYPE_TITLE, |
149 | EXTRACTOR_METAFORMAT_UTF8, | 149 | EXTRACTOR_METAFORMAT_UTF8, |
150 | "text/plain", | 150 | "text/plain", |
151 | (void*) &event->midi_buffer[3], | 151 | (void*) &event->midi_buffer[3], |
152 | len)) | 152 | len)) |
153 | goto CLEANUP; | 153 | goto CLEANUP; |
154 | break; | 154 | break; |
155 | case ET_INSTRUMENT_NAME: | 155 | case ET_INSTRUMENT_NAME: |
156 | if (0 != ec->proc (ec->cls, | 156 | if (0 != ec->proc (ec->cls, |
157 | "midi", | 157 | "midi", |
158 | EXTRACTOR_METATYPE_SOURCE_DEVICE, | 158 | EXTRACTOR_METATYPE_SOURCE_DEVICE, |
159 | EXTRACTOR_METAFORMAT_UTF8, | 159 | EXTRACTOR_METAFORMAT_UTF8, |
160 | "text/plain", | 160 | "text/plain", |
161 | (void*) &event->midi_buffer[3], | 161 | (void*) &event->midi_buffer[3], |
162 | len)) | 162 | len)) |
163 | goto CLEANUP; | 163 | goto CLEANUP; |
164 | break; | 164 | break; |
165 | case ET_LYRIC_TEXT: | 165 | case ET_LYRIC_TEXT: |
166 | if (0 != ec->proc (ec->cls, | 166 | if (0 != ec->proc (ec->cls, |
167 | "midi", | 167 | "midi", |
168 | EXTRACTOR_METATYPE_LYRICS, | 168 | EXTRACTOR_METATYPE_LYRICS, |
169 | EXTRACTOR_METAFORMAT_UTF8, | 169 | EXTRACTOR_METAFORMAT_UTF8, |
170 | "text/plain", | 170 | "text/plain", |
171 | (void*) &event->midi_buffer[3], | 171 | (void*) &event->midi_buffer[3], |
172 | len)) | 172 | len)) |
173 | goto CLEANUP; | 173 | goto CLEANUP; |
174 | break; | 174 | break; |
175 | default: | 175 | default: |
176 | break; | 176 | break; |
177 | } | ||
178 | } | 177 | } |
179 | 178 | } | |
180 | CLEANUP: | 179 | |
180 | CLEANUP: | ||
181 | if (NULL != m) | 181 | if (NULL != m) |
182 | smf_delete (m); | 182 | smf_delete (m); |
183 | free (data); | 183 | free (data); |
diff --git a/src/plugins/mime_extractor.c b/src/plugins/mime_extractor.c index b9fb3cf..cfcfab9 100644 --- a/src/plugins/mime_extractor.c +++ b/src/plugins/mime_extractor.c | |||
@@ -36,7 +36,7 @@ static magic_t magic; | |||
36 | * Path we used for loading magic data, NULL is used for 'default'. | 36 | * Path we used for loading magic data, NULL is used for 'default'. |
37 | */ | 37 | */ |
38 | static char *magic_path; | 38 | static char *magic_path; |
39 | 39 | ||
40 | 40 | ||
41 | /** | 41 | /** |
42 | * Main entry method for the 'application/ogg' extraction plugin. The | 42 | * Main entry method for the 'application/ogg' extraction plugin. The |
@@ -54,74 +54,75 @@ EXTRACTOR_mime_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
54 | const char *mime; | 54 | const char *mime; |
55 | 55 | ||
56 | ret = ec->read (ec->cls, | 56 | ret = ec->read (ec->cls, |
57 | &buf, | 57 | &buf, |
58 | 16 * 1024); | 58 | 16 * 1024); |
59 | if (-1 == ret) | 59 | if (-1 == ret) |
60 | return; | 60 | return; |
61 | if ( ( (NULL == magic_path) && | 61 | if ( ( (NULL == magic_path) && |
62 | (NULL != ec->config) ) || | 62 | (NULL != ec->config) ) || |
63 | ( (NULL != magic_path) && | 63 | ( (NULL != magic_path) && |
64 | (NULL == ec->config) ) || | 64 | (NULL == ec->config) ) || |
65 | ( (NULL != magic_path) && | 65 | ( (NULL != magic_path) && |
66 | (NULL != ec->config) && | 66 | (NULL != ec->config) && |
67 | (0 != strcmp (magic_path, | 67 | (0 != strcmp (magic_path, |
68 | ec->config) )) ) | 68 | ec->config) )) ) |
69 | { | ||
70 | if (NULL != magic_path) | ||
71 | free (magic_path); | ||
72 | magic_close (magic); | ||
73 | magic = magic_open (MAGIC_MIME_TYPE); | ||
74 | if (0 != magic_load (magic, ec->config)) | ||
69 | { | 75 | { |
70 | if (NULL != magic_path) | 76 | /* FIXME: report errors? */ |
71 | free (magic_path); | ||
72 | magic_close (magic); | ||
73 | magic = magic_open (MAGIC_MIME_TYPE); | ||
74 | if (0 != magic_load (magic, ec->config)) | ||
75 | { | ||
76 | /* FIXME: report errors? */ | ||
77 | } | ||
78 | if (NULL != ec->config) | ||
79 | magic_path = strdup (ec->config); | ||
80 | else | ||
81 | magic_path = NULL; | ||
82 | } | 77 | } |
78 | if (NULL != ec->config) | ||
79 | magic_path = strdup (ec->config); | ||
80 | else | ||
81 | magic_path = NULL; | ||
82 | } | ||
83 | if (NULL == (mime = magic_buffer (magic, buf, ret))) | 83 | if (NULL == (mime = magic_buffer (magic, buf, ret))) |
84 | return; | 84 | return; |
85 | ec->proc (ec->cls, | 85 | ec->proc (ec->cls, |
86 | "mime", | 86 | "mime", |
87 | EXTRACTOR_METATYPE_MIMETYPE, | 87 | EXTRACTOR_METATYPE_MIMETYPE, |
88 | EXTRACTOR_METAFORMAT_UTF8, | 88 | EXTRACTOR_METAFORMAT_UTF8, |
89 | "text/plain", | 89 | "text/plain", |
90 | mime, | 90 | mime, |
91 | strlen (mime) + 1); | 91 | strlen (mime) + 1); |
92 | } | 92 | } |
93 | 93 | ||
94 | 94 | ||
95 | /** | 95 | /** |
96 | * Constructor for the library. Loads the magic file. | 96 | * Constructor for the library. Loads the magic file. |
97 | */ | 97 | */ |
98 | void __attribute__ ((constructor)) | 98 | void __attribute__ ((constructor)) |
99 | mime_ltdl_init () | 99 | mime_ltdl_init () |
100 | { | 100 | { |
101 | magic = magic_open (MAGIC_MIME_TYPE); | 101 | magic = magic_open (MAGIC_MIME_TYPE); |
102 | if (0 != magic_load (magic, magic_path)) | 102 | if (0 != magic_load (magic, magic_path)) |
103 | { | 103 | { |
104 | /* FIXME: how to deal with errors? */ | 104 | /* FIXME: how to deal with errors? */ |
105 | } | 105 | } |
106 | } | 106 | } |
107 | 107 | ||
108 | 108 | ||
109 | /** | 109 | /** |
110 | * Destructor for the library, cleans up. | 110 | * Destructor for the library, cleans up. |
111 | */ | 111 | */ |
112 | void __attribute__ ((destructor)) | 112 | void __attribute__ ((destructor)) |
113 | mime_ltdl_fini () | 113 | mime_ltdl_fini () |
114 | { | 114 | { |
115 | if (NULL != magic) | 115 | if (NULL != magic) |
116 | { | 116 | { |
117 | magic_close (magic); | 117 | magic_close (magic); |
118 | magic = NULL; | 118 | magic = NULL; |
119 | } | 119 | } |
120 | if (NULL != magic_path) | 120 | if (NULL != magic_path) |
121 | { | 121 | { |
122 | free (magic_path); | 122 | free (magic_path); |
123 | magic_path = NULL; | 123 | magic_path = NULL; |
124 | } | 124 | } |
125 | } | 125 | } |
126 | 126 | ||
127 | |||
127 | /* end of mime_extractor.c */ | 128 | /* end of mime_extractor.c */ |
diff --git a/src/plugins/mp4_extractor.c b/src/plugins/mp4_extractor.c index 89be634..b8ad84c 100644 --- a/src/plugins/mp4_extractor.c +++ b/src/plugins/mp4_extractor.c | |||
@@ -29,7 +29,7 @@ | |||
29 | 29 | ||
30 | 30 | ||
31 | /** | 31 | /** |
32 | * Callback invoked by libmp4v2 to open the file. | 32 | * Callback invoked by libmp4v2 to open the file. |
33 | * We cheated and passed our extractor context as | 33 | * We cheated and passed our extractor context as |
34 | * the filename (fingers crossed) and will simply | 34 | * the filename (fingers crossed) and will simply |
35 | * return it again to make it the handle. | 35 | * return it again to make it the handle. |
@@ -40,7 +40,7 @@ | |||
40 | */ | 40 | */ |
41 | static void* | 41 | static void* |
42 | open_cb (const char *name, | 42 | open_cb (const char *name, |
43 | MP4FileMode mode) | 43 | MP4FileMode mode) |
44 | { | 44 | { |
45 | void *ecp; | 45 | void *ecp; |
46 | 46 | ||
@@ -61,15 +61,15 @@ open_cb (const char *name, | |||
61 | */ | 61 | */ |
62 | static int | 62 | static int |
63 | seek_cb (void *handle, | 63 | seek_cb (void *handle, |
64 | int64_t pos) | 64 | int64_t pos) |
65 | { | 65 | { |
66 | struct EXTRACTOR_ExtractContext *ec = handle; | 66 | struct EXTRACTOR_ExtractContext *ec = handle; |
67 | 67 | ||
68 | fprintf (stderr, "Seek: %lld!\n", (long long) pos); | 68 | fprintf (stderr, "Seek: %lld!\n", (long long) pos); |
69 | if (-1 == | 69 | if (-1 == |
70 | ec->seek (ec->cls, | 70 | ec->seek (ec->cls, |
71 | pos, | 71 | pos, |
72 | SEEK_CUR)) | 72 | SEEK_CUR)) |
73 | return true; /* failure */ | 73 | return true; /* failure */ |
74 | return false; | 74 | return false; |
75 | } | 75 | } |
@@ -85,23 +85,23 @@ seek_cb (void *handle, | |||
85 | * @param maxChunkSize some chunk size (ignored) | 85 | * @param maxChunkSize some chunk size (ignored) |
86 | * @return true on failure, false on success | 86 | * @return true on failure, false on success |
87 | */ | 87 | */ |
88 | static int | 88 | static int |
89 | read_cb (void *handle, | 89 | read_cb (void *handle, |
90 | void *buffer, | 90 | void *buffer, |
91 | int64_t size, | 91 | int64_t size, |
92 | int64_t *nin, | 92 | int64_t *nin, |
93 | int64_t maxChunkSize) | 93 | int64_t maxChunkSize) |
94 | { | 94 | { |
95 | struct EXTRACTOR_ExtractContext *ec = handle; | 95 | struct EXTRACTOR_ExtractContext *ec = handle; |
96 | void *buf; | 96 | void *buf; |
97 | ssize_t ret; | 97 | ssize_t ret; |
98 | 98 | ||
99 | fprintf (stderr, "read!\n"); | 99 | fprintf (stderr, "read!\n"); |
100 | *nin = 0; | 100 | *nin = 0; |
101 | if (-1 == | 101 | if (-1 == |
102 | (ret = ec->read (ec->cls, | 102 | (ret = ec->read (ec->cls, |
103 | &buf, | 103 | &buf, |
104 | size))) | 104 | size))) |
105 | return true; /* failure */ | 105 | return true; /* failure */ |
106 | memcpy (buffer, buf, ret); | 106 | memcpy (buffer, buf, ret); |
107 | *nin = ret; | 107 | *nin = ret; |
@@ -121,10 +121,10 @@ read_cb (void *handle, | |||
121 | */ | 121 | */ |
122 | static int | 122 | static int |
123 | write_cb (void *handle, | 123 | write_cb (void *handle, |
124 | const void *buffer, | 124 | const void *buffer, |
125 | int64_t size, | 125 | int64_t size, |
126 | int64_t *nout, | 126 | int64_t *nout, |
127 | int64_t maxChunkSize) | 127 | int64_t maxChunkSize) |
128 | { | 128 | { |
129 | fprintf (stderr, "Write!?\n"); | 129 | fprintf (stderr, "Write!?\n"); |
130 | return true; /* failure */ | 130 | return true; /* failure */ |
@@ -149,24 +149,26 @@ close_cb (void *handle) | |||
149 | /** | 149 | /** |
150 | * Wrapper to replace 'stat64' call by libmp4v2. | 150 | * Wrapper to replace 'stat64' call by libmp4v2. |
151 | */ | 151 | */ |
152 | int | 152 | int |
153 | stat_cb (const char * path, | 153 | stat_cb (const char *path, |
154 | struct stat64 * buf) | 154 | struct stat64 *buf) |
155 | { | 155 | { |
156 | void *ecp; | 156 | void *ecp; |
157 | struct EXTRACTOR_ExtractContext *ec; | 157 | struct EXTRACTOR_ExtractContext *ec; |
158 | 158 | ||
159 | fprintf (stderr, "stat!\n"); | 159 | fprintf (stderr, "stat!\n"); |
160 | if (1 != sscanf (path, "%p", &ecp)) | 160 | if (1 != sscanf (path, "%p", &ecp)) |
161 | { | 161 | { |
162 | errno = EINVAL; | 162 | errno = EINVAL; |
163 | return -1; | 163 | return -1; |
164 | } | 164 | } |
165 | ec = ecp; | 165 | ec = ecp; |
166 | memset (buf, 0, sizeof (struct stat)); | 166 | memset (buf, 0, sizeof (struct stat)); |
167 | buf->st_size = ec->get_size (ec->cls); | 167 | buf->st_size = ec->get_size (ec->cls); |
168 | return 0; | 168 | return 0; |
169 | } | 169 | } |
170 | |||
171 | |||
170 | #endif | 172 | #endif |
171 | 173 | ||
172 | 174 | ||
@@ -175,7 +177,7 @@ stat_cb (const char * path, | |||
175 | * | 177 | * |
176 | * @param ec extraction context provided to the plugin | 178 | * @param ec extraction context provided to the plugin |
177 | */ | 179 | */ |
178 | void | 180 | void |
179 | EXTRACTOR_mp4_extract_method (struct EXTRACTOR_ExtractContext *ec) | 181 | EXTRACTOR_mp4_extract_method (struct EXTRACTOR_ExtractContext *ec) |
180 | { | 182 | { |
181 | MP4FileProvider fp; | 183 | MP4FileProvider fp; |
@@ -185,7 +187,7 @@ EXTRACTOR_mp4_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
185 | 187 | ||
186 | if (1) | 188 | if (1) |
187 | return; /* plugin is known not to work yet; | 189 | return; /* plugin is known not to work yet; |
188 | see issue 138 filed against MP4v2 lib */ | 190 | see issue 138 filed against MP4v2 lib */ |
189 | snprintf (ecp, sizeof (ecp), "%p", ec); | 191 | snprintf (ecp, sizeof (ecp), "%p", ec); |
190 | fp.open = &open_cb; | 192 | fp.open = &open_cb; |
191 | fp.seek = &seek_cb; | 193 | fp.seek = &seek_cb; |
@@ -193,14 +195,15 @@ EXTRACTOR_mp4_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
193 | fp.write = &write_cb; | 195 | fp.write = &write_cb; |
194 | fp.close = &close_cb; | 196 | fp.close = &close_cb; |
195 | if (NULL == (mp4 = MP4ReadProvider (ecp, | 197 | if (NULL == (mp4 = MP4ReadProvider (ecp, |
196 | &fp))) | 198 | &fp))) |
197 | return; | 199 | return; |
198 | tags = MP4TagsAlloc (); | 200 | tags = MP4TagsAlloc (); |
199 | if (MP4TagsFetch (tags, mp4)) | 201 | if (MP4TagsFetch (tags, mp4)) |
200 | { | 202 | { |
201 | fprintf (stderr, "got tags!\n"); | 203 | fprintf (stderr, "got tags!\n"); |
202 | } | 204 | } |
203 | MP4Close (mp4, 0); | 205 | MP4Close (mp4, 0); |
204 | } | 206 | } |
205 | 207 | ||
208 | |||
206 | /* end of mp4_extractor.c */ | 209 | /* end of mp4_extractor.c */ |
diff --git a/src/plugins/mpeg_extractor.c b/src/plugins/mpeg_extractor.c index 627cae0..9c5f0b8 100644 --- a/src/plugins/mpeg_extractor.c +++ b/src/plugins/mpeg_extractor.c | |||
@@ -34,7 +34,11 @@ | |||
34 | * @param t type of the meta data | 34 | * @param t type of the meta data |
35 | * @param s meta data value in utf8 format | 35 | * @param s meta data value in utf8 format |
36 | */ | 36 | */ |
37 | #define ADD(s,t) do { if (0 != ec->proc (ec->cls, "mpeg", t, EXTRACTOR_METAFORMAT_UTF8, "text/plain", s, strlen (s) + 1)) goto EXIT; } while (0) | 37 | #define ADD(s,t) do { if (0 != ec->proc (ec->cls, "mpeg", t, \ |
38 | EXTRACTOR_METAFORMAT_UTF8, \ | ||
39 | "text/plain", s, strlen (s) \ | ||
40 | + 1)) goto EXIT; \ | ||
41 | } while (0) | ||
38 | 42 | ||
39 | 43 | ||
40 | /** | 44 | /** |
@@ -68,10 +72,10 @@ EXTRACTOR_mpeg_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
68 | if (NULL == (handle = mpeg2_init ())) | 72 | if (NULL == (handle = mpeg2_init ())) |
69 | return; | 73 | return; |
70 | if (NULL == (info = mpeg2_info (handle))) | 74 | if (NULL == (info = mpeg2_info (handle))) |
71 | { | 75 | { |
72 | mpeg2_close (handle); | 76 | mpeg2_close (handle); |
73 | return; | 77 | return; |
74 | } | 78 | } |
75 | fsize = ec->get_size (ec->cls); | 79 | fsize = ec->get_size (ec->cls); |
76 | buf = NULL; | 80 | buf = NULL; |
77 | have_gop = 0; | 81 | have_gop = 0; |
@@ -86,130 +90,131 @@ EXTRACTOR_mpeg_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
86 | fmac = 0; | 90 | fmac = 0; |
87 | lformat[0] = '\0'; | 91 | lformat[0] = '\0'; |
88 | while (1) | 92 | while (1) |
93 | { | ||
94 | state = mpeg2_parse (handle); | ||
95 | switch (state) | ||
89 | { | 96 | { |
90 | state = mpeg2_parse (handle); | 97 | case STATE_BUFFER: |
91 | switch (state) | 98 | if (fail_count > 16) |
92 | { | 99 | goto EXIT; /* do not read large non-mpeg files */ |
93 | case STATE_BUFFER: | 100 | fail_count++; |
94 | if (fail_count > 16) | 101 | if (0 >= (avail = ec->read (ec->cls, |
95 | goto EXIT; /* do not read large non-mpeg files */ | 102 | &buf, |
96 | fail_count++; | 103 | 16 * 1024))) |
97 | if (0 >= (avail = ec->read (ec->cls, | 104 | goto EXIT; |
98 | &buf, | 105 | mpeg2_buffer (handle, buf, buf + avail); |
99 | 16 * 1024))) | 106 | break; |
100 | goto EXIT; | 107 | case STATE_SEQUENCE: |
101 | mpeg2_buffer (handle, buf, buf + avail); | 108 | fail_count = 0; |
102 | break; | 109 | format[0] = fsize; |
103 | case STATE_SEQUENCE: | 110 | format[0]++; |
104 | fail_count = 0; | 111 | if (0 == mime) |
105 | format[0] = fsize; | 112 | { |
106 | format[0]++; | 113 | mime = 1; |
107 | if (0 == mime) | 114 | ADD ("video/mpeg", EXTRACTOR_METATYPE_MIMETYPE); |
108 | { | 115 | } |
109 | mime = 1; | 116 | snprintf (format, |
110 | ADD ("video/mpeg", EXTRACTOR_METATYPE_MIMETYPE); | 117 | sizeof(format), "%ux%u", |
111 | } | 118 | info->sequence->width, info->sequence->height); |
112 | snprintf (format, | 119 | if (0 != strcmp (lformat, |
113 | sizeof(format), "%ux%u", | 120 | format)) |
114 | info->sequence->width, info->sequence->height); | 121 | { |
115 | if (0 != strcmp (lformat, | 122 | strcpy (lformat, |
116 | format)) | 123 | format); |
117 | { | 124 | ADD (format, EXTRACTOR_METATYPE_IMAGE_DIMENSIONS); |
118 | strcpy (lformat, | 125 | } |
119 | format); | 126 | switch (info->sequence->flags & SEQ_VIDEO_FORMAT_UNSPECIFIED) |
120 | ADD (format, EXTRACTOR_METATYPE_IMAGE_DIMENSIONS); | 127 | { |
121 | } | 128 | case SEQ_VIDEO_FORMAT_PAL: |
122 | switch (info->sequence->flags & SEQ_VIDEO_FORMAT_UNSPECIFIED) | 129 | if (0 == fpal) |
123 | { | 130 | { |
124 | case SEQ_VIDEO_FORMAT_PAL: | 131 | fpal = 1; |
125 | if (0 == fpal) | 132 | ADD ("PAL", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM); |
126 | { | 133 | } |
127 | fpal = 1; | 134 | break; |
128 | ADD ("PAL", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM); | 135 | case SEQ_VIDEO_FORMAT_NTSC: |
129 | } | 136 | if (0 == fntsc) |
130 | break; | 137 | { |
131 | case SEQ_VIDEO_FORMAT_NTSC: | 138 | fntsc = 1; |
132 | if (0 == fntsc) | 139 | ADD ("NTSC", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM); |
133 | { | 140 | } |
134 | fntsc = 1; | 141 | break; |
135 | ADD ("NTSC", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM); | 142 | case SEQ_VIDEO_FORMAT_SECAM: |
136 | } | 143 | if (0 == fsecam) |
137 | break; | 144 | { |
138 | case SEQ_VIDEO_FORMAT_SECAM: | 145 | fsecam = 1; |
139 | if (0 == fsecam) | 146 | ADD ("SECAM", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM); |
140 | { | 147 | } |
141 | fsecam = 1; | 148 | break; |
142 | ADD ("SECAM", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM); | 149 | case SEQ_VIDEO_FORMAT_MAC: |
143 | } | 150 | if (0 == fmac) |
144 | break; | 151 | { |
145 | case SEQ_VIDEO_FORMAT_MAC: | 152 | fmac = 1; |
146 | if (0 == fmac) | 153 | ADD ("MAC", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM); |
147 | { | 154 | } |
148 | fmac = 1; | 155 | break; |
149 | ADD ("MAC", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM); | 156 | default: |
150 | } | 157 | break; |
151 | break; | 158 | } |
152 | default: | 159 | if ((info->sequence->flags & SEQ_FLAG_MPEG2) > 0) |
153 | break; | 160 | { |
154 | } | 161 | if (0 == fmt1) |
155 | if ((info->sequence->flags & SEQ_FLAG_MPEG2) > 0) | 162 | { |
156 | { | 163 | fmt1 = 1; |
157 | if (0 == fmt1) | 164 | ADD ("MPEG2", EXTRACTOR_METATYPE_FORMAT_VERSION); |
158 | { | 165 | } |
159 | fmt1 = 1; | 166 | } |
160 | ADD ("MPEG2", EXTRACTOR_METATYPE_FORMAT_VERSION); | 167 | else |
161 | } | 168 | { |
162 | } | 169 | if (0 == fmt2) |
163 | else | 170 | { |
164 | { | 171 | fmt2 = 1; |
165 | if (0 == fmt2) | 172 | ADD ("MPEG1", EXTRACTOR_METATYPE_FORMAT_VERSION); |
166 | { | 173 | } |
167 | fmt2 = 1; | 174 | } |
168 | ADD ("MPEG1", EXTRACTOR_METATYPE_FORMAT_VERSION); | 175 | if ( (0 == did_seek) && |
169 | } | 176 | (fsize != -1) && |
170 | } | 177 | (fsize > 1024 * 256 * 2) ) |
171 | if ( (0 == did_seek) && | 178 | { |
172 | (fsize != -1) && | 179 | /* skip to the end of the mpeg for speed */ |
173 | (fsize > 1024 * 256 * 2) ) | 180 | did_seek = 1; |
174 | { | 181 | ec->seek (ec->cls, |
175 | /* skip to the end of the mpeg for speed */ | 182 | fsize - 256 * 1024, |
176 | did_seek = 1; | 183 | SEEK_SET); |
177 | ec->seek (ec->cls, | 184 | } |
178 | fsize - 256 * 1024, | 185 | break; |
179 | SEEK_SET); | 186 | case STATE_GOP: |
180 | } | 187 | fail_count = 0; |
181 | break; | 188 | if ( (NULL != info->gop) && |
182 | case STATE_GOP: | 189 | (0 != info->gop->pictures) ) |
183 | fail_count = 0; | 190 | { |
184 | if ( (NULL != info->gop) && | 191 | snprintf (gop_format, |
185 | (0 != info->gop->pictures) ) | 192 | sizeof (gop_format), |
186 | { | 193 | "%02u:%02u:%02u (%u frames)", |
187 | snprintf (gop_format, | 194 | info->gop->hours, |
188 | sizeof (gop_format), | 195 | info->gop->minutes, |
189 | "%02u:%02u:%02u (%u frames)", | 196 | info->gop->seconds, |
190 | info->gop->hours, | 197 | info->gop->pictures); |
191 | info->gop->minutes, | 198 | have_gop = 1; |
192 | info->gop->seconds, | 199 | } |
193 | info->gop->pictures); | 200 | break; |
194 | have_gop = 1; | 201 | case STATE_SLICE: |
195 | } | 202 | fail_count = 0; |
196 | break; | 203 | break; |
197 | case STATE_SLICE: | 204 | case STATE_END: |
198 | fail_count = 0; | 205 | fail_count = 0; |
199 | break; | 206 | break; |
200 | case STATE_END: | 207 | case STATE_INVALID: |
201 | fail_count = 0; | 208 | goto EXIT; |
202 | break; | 209 | default: |
203 | case STATE_INVALID: | 210 | break; |
204 | goto EXIT; | ||
205 | default: | ||
206 | break; | ||
207 | } | ||
208 | } | 211 | } |
209 | EXIT: | 212 | } |
213 | EXIT: | ||
210 | if (1 == have_gop) | 214 | if (1 == have_gop) |
211 | ADD (gop_format, EXTRACTOR_METATYPE_DURATION); | 215 | ADD (gop_format, EXTRACTOR_METATYPE_DURATION); |
212 | mpeg2_close (handle); | 216 | mpeg2_close (handle); |
213 | } | 217 | } |
214 | 218 | ||
219 | |||
215 | /* end of mpeg_extractor.c */ | 220 | /* end of mpeg_extractor.c */ |
diff --git a/src/plugins/nsf_extractor.c b/src/plugins/nsf_extractor.c index a02aaee..8028e92 100644 --- a/src/plugins/nsf_extractor.c +++ b/src/plugins/nsf_extractor.c | |||
@@ -28,7 +28,6 @@ | |||
28 | #include "extractor.h" | 28 | #include "extractor.h" |
29 | 29 | ||
30 | 30 | ||
31 | |||
32 | /* television system flags */ | 31 | /* television system flags */ |
33 | #define PAL_FLAG 0x01 | 32 | #define PAL_FLAG 0x01 |
34 | #define DUAL_FLAG 0x02 | 33 | #define DUAL_FLAG 0x02 |
@@ -130,7 +129,11 @@ struct header | |||
130 | * @param s metadata value as UTF8 | 129 | * @param s metadata value as UTF8 |
131 | * @param t metadata type to use | 130 | * @param t metadata type to use |
132 | */ | 131 | */ |
133 | #define ADD(s,t) do { if (0 != ec->proc (ec->cls, "nsf", t, EXTRACTOR_METAFORMAT_UTF8, "text/plain", s, strlen (s) + 1)) return; } while (0) | 132 | #define ADD(s,t) do { if (0 != ec->proc (ec->cls, "nsf", t, \ |
133 | EXTRACTOR_METAFORMAT_UTF8, \ | ||
134 | "text/plain", s, strlen (s) \ | ||
135 | + 1)) return; \ | ||
136 | } while (0) | ||
134 | 137 | ||
135 | 138 | ||
136 | /** | 139 | /** |
@@ -167,19 +170,19 @@ EXTRACTOR_nsf_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
167 | return; | 170 | return; |
168 | ADD ("audio/x-nsf", EXTRACTOR_METATYPE_MIMETYPE); | 171 | ADD ("audio/x-nsf", EXTRACTOR_METATYPE_MIMETYPE); |
169 | snprintf (nsfversion, | 172 | snprintf (nsfversion, |
170 | sizeof(nsfversion), | 173 | sizeof(nsfversion), |
171 | "%d", | 174 | "%d", |
172 | head->nsfversion); | 175 | head->nsfversion); |
173 | ADD (nsfversion, EXTRACTOR_METATYPE_FORMAT_VERSION); | 176 | ADD (nsfversion, EXTRACTOR_METATYPE_FORMAT_VERSION); |
174 | snprintf (songs, | 177 | snprintf (songs, |
175 | sizeof(songs), | 178 | sizeof(songs), |
176 | "%d", | 179 | "%d", |
177 | (int) head->songs); | 180 | (int) head->songs); |
178 | ADD (songs, EXTRACTOR_METATYPE_SONG_COUNT); | 181 | ADD (songs, EXTRACTOR_METATYPE_SONG_COUNT); |
179 | snprintf (startingsong, | 182 | snprintf (startingsong, |
180 | sizeof(startingsong), | 183 | sizeof(startingsong), |
181 | "%d", | 184 | "%d", |
182 | (int) head->firstsong); | 185 | (int) head->firstsong); |
183 | ADD (startingsong, EXTRACTOR_METATYPE_STARTING_SONG); | 186 | ADD (startingsong, EXTRACTOR_METATYPE_STARTING_SONG); |
184 | memcpy (&album, head->title, 32); | 187 | memcpy (&album, head->title, 32); |
185 | album[32] = '\0'; | 188 | album[32] = '\0'; |
@@ -192,16 +195,16 @@ EXTRACTOR_nsf_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
192 | ADD (copyright, EXTRACTOR_METATYPE_COPYRIGHT); | 195 | ADD (copyright, EXTRACTOR_METATYPE_COPYRIGHT); |
193 | 196 | ||
194 | if (0 != (head->tvflags & DUAL_FLAG)) | 197 | if (0 != (head->tvflags & DUAL_FLAG)) |
195 | { | 198 | { |
196 | ADD ("PAL/NTSC", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM); | 199 | ADD ("PAL/NTSC", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM); |
197 | } | 200 | } |
198 | else | 201 | else |
199 | { | 202 | { |
200 | if (0 != (head->tvflags & PAL_FLAG)) | 203 | if (0 != (head->tvflags & PAL_FLAG)) |
201 | ADD ("PAL", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM); | 204 | ADD ("PAL", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM); |
202 | else | 205 | else |
203 | ADD ("NTSC", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM); | 206 | ADD ("NTSC", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM); |
204 | } | 207 | } |
205 | 208 | ||
206 | /* Detect Extra Sound Chips needed to play the files */ | 209 | /* Detect Extra Sound Chips needed to play the files */ |
207 | if (0 != (head->chipflags & VRCVI_FLAG)) | 210 | if (0 != (head->chipflags & VRCVI_FLAG)) |
@@ -218,4 +221,5 @@ EXTRACTOR_nsf_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
218 | ADD ("Sunsoft FME-07", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE); | 221 | ADD ("Sunsoft FME-07", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE); |
219 | } | 222 | } |
220 | 223 | ||
224 | |||
221 | /* end of nsf_extractor.c */ | 225 | /* end of nsf_extractor.c */ |
diff --git a/src/plugins/nsfe_extractor.c b/src/plugins/nsfe_extractor.c index 36ba115..c7f44b9 100644 --- a/src/plugins/nsfe_extractor.c +++ b/src/plugins/nsfe_extractor.c | |||
@@ -396,4 +396,5 @@ EXTRACTOR_nsfe_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
396 | } | 396 | } |
397 | } | 397 | } |
398 | 398 | ||
399 | |||
399 | /* end of nsfe_extractor.c */ | 400 | /* end of nsfe_extractor.c */ |
diff --git a/src/plugins/odf_extractor.c b/src/plugins/odf_extractor.c index 6a68f7c..ff8f9b2 100644 --- a/src/plugins/odf_extractor.c +++ b/src/plugins/odf_extractor.c | |||
@@ -41,12 +41,12 @@ | |||
41 | /** | 41 | /** |
42 | * Mapping from ODF meta data strings to LE types. | 42 | * Mapping from ODF meta data strings to LE types. |
43 | */ | 43 | */ |
44 | struct Matches | 44 | struct Matches |
45 | { | 45 | { |
46 | /** | 46 | /** |
47 | * ODF description. | 47 | * ODF description. |
48 | */ | 48 | */ |
49 | const char * text; | 49 | const char *text; |
50 | 50 | ||
51 | /** | 51 | /** |
52 | * Corresponding LE type. | 52 | * Corresponding LE type. |
@@ -85,7 +85,7 @@ static struct Matches tmap[] = { | |||
85 | * @return NULL if no mimetype could be found, otherwise the mime type | 85 | * @return NULL if no mimetype could be found, otherwise the mime type |
86 | */ | 86 | */ |
87 | static char * | 87 | static char * |
88 | libextractor_oo_getmimetype (struct EXTRACTOR_UnzipFile * uf) | 88 | libextractor_oo_getmimetype (struct EXTRACTOR_UnzipFile *uf) |
89 | { | 89 | { |
90 | char filename_inzip[MAXFILENAME]; | 90 | char filename_inzip[MAXFILENAME]; |
91 | struct EXTRACTOR_UnzipFileInfo file_info; | 91 | struct EXTRACTOR_UnzipFileInfo file_info; |
@@ -94,61 +94,61 @@ libextractor_oo_getmimetype (struct EXTRACTOR_UnzipFile * uf) | |||
94 | 94 | ||
95 | if (EXTRACTOR_UNZIP_OK != | 95 | if (EXTRACTOR_UNZIP_OK != |
96 | EXTRACTOR_common_unzip_go_find_local_file (uf, | 96 | EXTRACTOR_common_unzip_go_find_local_file (uf, |
97 | "mimetype", | 97 | "mimetype", |
98 | 2)) | 98 | 2)) |
99 | return NULL; | 99 | return NULL; |
100 | if (EXTRACTOR_UNZIP_OK != | 100 | if (EXTRACTOR_UNZIP_OK != |
101 | EXTRACTOR_common_unzip_get_current_file_info (uf, | 101 | EXTRACTOR_common_unzip_get_current_file_info (uf, |
102 | &file_info, | 102 | &file_info, |
103 | filename_inzip, | 103 | filename_inzip, |
104 | sizeof (filename_inzip), | 104 | sizeof (filename_inzip), |
105 | NULL, | 105 | NULL, |
106 | 0, | 106 | 0, |
107 | NULL, | 107 | NULL, |
108 | 0)) | 108 | 0)) |
109 | return NULL; | 109 | return NULL; |
110 | if (EXTRACTOR_UNZIP_OK != | 110 | if (EXTRACTOR_UNZIP_OK != |
111 | EXTRACTOR_common_unzip_open_current_file (uf)) | 111 | EXTRACTOR_common_unzip_open_current_file (uf)) |
112 | return NULL; | 112 | return NULL; |
113 | buf_size = file_info.uncompressed_size; | 113 | buf_size = file_info.uncompressed_size; |
114 | if (buf_size > 1024) | 114 | if (buf_size > 1024) |
115 | { | 115 | { |
116 | /* way too large! */ | 116 | /* way too large! */ |
117 | EXTRACTOR_common_unzip_close_current_file (uf); | 117 | EXTRACTOR_common_unzip_close_current_file (uf); |
118 | return NULL; | 118 | return NULL; |
119 | } | 119 | } |
120 | if (NULL == (buf = malloc (1 + buf_size))) | 120 | if (NULL == (buf = malloc (1 + buf_size))) |
121 | { | 121 | { |
122 | /* memory exhausted! */ | 122 | /* memory exhausted! */ |
123 | EXTRACTOR_common_unzip_close_current_file (uf); | 123 | EXTRACTOR_common_unzip_close_current_file (uf); |
124 | return NULL; | 124 | return NULL; |
125 | } | 125 | } |
126 | if (buf_size != | 126 | if (buf_size != |
127 | (size_t) EXTRACTOR_common_unzip_read_current_file (uf, | 127 | (size_t) EXTRACTOR_common_unzip_read_current_file (uf, |
128 | buf, | 128 | buf, |
129 | buf_size)) | 129 | buf_size)) |
130 | { | 130 | { |
131 | free(buf); | 131 | free (buf); |
132 | EXTRACTOR_common_unzip_close_current_file(uf); | 132 | EXTRACTOR_common_unzip_close_current_file (uf); |
133 | return NULL; | 133 | return NULL; |
134 | } | 134 | } |
135 | /* found something */ | 135 | /* found something */ |
136 | buf[buf_size] = '\0'; | 136 | buf[buf_size] = '\0'; |
137 | while ( (0 < buf_size) && | 137 | while ( (0 < buf_size) && |
138 | isspace( (unsigned char) buf[buf_size - 1])) | 138 | isspace ( (unsigned char) buf[buf_size - 1])) |
139 | buf[--buf_size] = '\0'; | 139 | buf[--buf_size] = '\0'; |
140 | if ('\0' == buf[0]) | 140 | if ('\0' == buf[0]) |
141 | { | 141 | { |
142 | free (buf); | 142 | free (buf); |
143 | buf = NULL; | 143 | buf = NULL; |
144 | } | 144 | } |
145 | EXTRACTOR_common_unzip_close_current_file (uf); | 145 | EXTRACTOR_common_unzip_close_current_file (uf); |
146 | return buf; | 146 | return buf; |
147 | } | 147 | } |
148 | 148 | ||
149 | 149 | ||
150 | /** | 150 | /** |
151 | * Main entry method for the ODF extraction plugin. | 151 | * Main entry method for the ODF extraction plugin. |
152 | * | 152 | * |
153 | * @param ec extraction context provided to the plugin | 153 | * @param ec extraction context provided to the plugin |
154 | */ | 154 | */ |
@@ -167,154 +167,157 @@ EXTRACTOR_odf_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
167 | if (NULL == (uf = EXTRACTOR_common_unzip_open (ec))) | 167 | if (NULL == (uf = EXTRACTOR_common_unzip_open (ec))) |
168 | return; | 168 | return; |
169 | if (NULL != (mimetype = libextractor_oo_getmimetype (uf))) | 169 | if (NULL != (mimetype = libextractor_oo_getmimetype (uf))) |
170 | { | ||
171 | if (0 != ec->proc (ec->cls, | ||
172 | "odf", | ||
173 | EXTRACTOR_METATYPE_MIMETYPE, | ||
174 | EXTRACTOR_METAFORMAT_UTF8, | ||
175 | "text/plain", | ||
176 | mimetype, | ||
177 | strlen (mimetype) + 1)) | ||
170 | { | 178 | { |
171 | if (0 != ec->proc (ec->cls, | 179 | EXTRACTOR_common_unzip_close (uf); |
172 | "odf", | ||
173 | EXTRACTOR_METATYPE_MIMETYPE, | ||
174 | EXTRACTOR_METAFORMAT_UTF8, | ||
175 | "text/plain", | ||
176 | mimetype, | ||
177 | strlen (mimetype) + 1)) | ||
178 | { | ||
179 | EXTRACTOR_common_unzip_close (uf); | ||
180 | free (mimetype); | ||
181 | return; | ||
182 | } | ||
183 | free (mimetype); | 180 | free (mimetype); |
181 | return; | ||
184 | } | 182 | } |
183 | free (mimetype); | ||
184 | } | ||
185 | if (EXTRACTOR_UNZIP_OK != | 185 | if (EXTRACTOR_UNZIP_OK != |
186 | EXTRACTOR_common_unzip_go_find_local_file (uf, | 186 | EXTRACTOR_common_unzip_go_find_local_file (uf, |
187 | METAFILE, | 187 | METAFILE, |
188 | 2)) | 188 | 2)) |
189 | { | 189 | { |
190 | /* metafile not found */ | 190 | /* metafile not found */ |
191 | EXTRACTOR_common_unzip_close (uf); | 191 | EXTRACTOR_common_unzip_close (uf); |
192 | return; | 192 | return; |
193 | } | 193 | } |
194 | if (EXTRACTOR_UNZIP_OK != | 194 | if (EXTRACTOR_UNZIP_OK != |
195 | EXTRACTOR_common_unzip_get_current_file_info (uf, | 195 | EXTRACTOR_common_unzip_get_current_file_info (uf, |
196 | &file_info, | 196 | &file_info, |
197 | filename_inzip, | 197 | filename_inzip, |
198 | sizeof (filename_inzip), | 198 | sizeof (filename_inzip), |
199 | NULL, 0, NULL, 0)) | 199 | NULL, 0, NULL, 0)) |
200 | { | 200 | { |
201 | /* problems accessing metafile */ | 201 | /* problems accessing metafile */ |
202 | EXTRACTOR_common_unzip_close (uf); | 202 | EXTRACTOR_common_unzip_close (uf); |
203 | return; | 203 | return; |
204 | } | 204 | } |
205 | if (EXTRACTOR_UNZIP_OK != | 205 | if (EXTRACTOR_UNZIP_OK != |
206 | EXTRACTOR_common_unzip_open_current_file (uf)) | 206 | EXTRACTOR_common_unzip_open_current_file (uf)) |
207 | { | 207 | { |
208 | /* problems with unzip */ | 208 | /* problems with unzip */ |
209 | EXTRACTOR_common_unzip_close (uf); | 209 | EXTRACTOR_common_unzip_close (uf); |
210 | return; | 210 | return; |
211 | } | 211 | } |
212 | 212 | ||
213 | buf_size = file_info.uncompressed_size; | 213 | buf_size = file_info.uncompressed_size; |
214 | if (buf_size > 128 * 1024) | 214 | if (buf_size > 128 * 1024) |
215 | { | 215 | { |
216 | /* too big to be meta-data! */ | 216 | /* too big to be meta-data! */ |
217 | EXTRACTOR_common_unzip_close_current_file (uf); | 217 | EXTRACTOR_common_unzip_close_current_file (uf); |
218 | EXTRACTOR_common_unzip_close (uf); | 218 | EXTRACTOR_common_unzip_close (uf); |
219 | return; | 219 | return; |
220 | } | 220 | } |
221 | if (NULL == (buf = malloc (buf_size+1))) | 221 | if (NULL == (buf = malloc (buf_size + 1))) |
222 | { | 222 | { |
223 | /* out of memory */ | 223 | /* out of memory */ |
224 | EXTRACTOR_common_unzip_close_current_file (uf); | 224 | EXTRACTOR_common_unzip_close_current_file (uf); |
225 | EXTRACTOR_common_unzip_close (uf); | 225 | EXTRACTOR_common_unzip_close (uf); |
226 | return; | 226 | return; |
227 | } | 227 | } |
228 | if (buf_size != EXTRACTOR_common_unzip_read_current_file (uf, buf, buf_size)) | 228 | if (buf_size != EXTRACTOR_common_unzip_read_current_file (uf, buf, buf_size)) |
229 | { | 229 | { |
230 | EXTRACTOR_common_unzip_close_current_file (uf); | 230 | EXTRACTOR_common_unzip_close_current_file (uf); |
231 | goto CLEANUP; | 231 | goto CLEANUP; |
232 | } | 232 | } |
233 | EXTRACTOR_common_unzip_close_current_file (uf); | 233 | EXTRACTOR_common_unzip_close_current_file (uf); |
234 | /* we don't do "proper" parsing of the meta-data but rather use some heuristics | 234 | /* we don't do "proper" parsing of the meta-data but rather use some heuristics |
235 | to get values out that we understand */ | 235 | to get values out that we understand */ |
236 | buf[buf_size] = '\0'; | 236 | buf[buf_size] = '\0'; |
237 | /* printf("%s\n", buf); */ | 237 | /* printf("%s\n", buf); */ |
238 | /* try to find some of the typical OO xml headers */ | 238 | /* try to find some of the typical OO xml headers */ |
239 | if ( (strstr (buf, "xmlns:meta=\"http://openoffice.org/2000/meta\"") != NULL) || | 239 | if ( (strstr (buf, "xmlns:meta=\"http://openoffice.org/2000/meta\"") != |
240 | (strstr (buf, "xmlns:dc=\"http://purl.org/dc/elements/1.1/\"") != NULL) || | 240 | NULL) || |
241 | (strstr (buf, "xmlns:xlink=\"http://www.w3.org/1999/xlink\"") != NULL) ) | 241 | (strstr (buf, "xmlns:dc=\"http://purl.org/dc/elements/1.1/\"") != |
242 | NULL) || | ||
243 | (strstr (buf, "xmlns:xlink=\"http://www.w3.org/1999/xlink\"") != NULL) ) | ||
244 | { | ||
245 | /* accept as meta-data */ | ||
246 | for (i = 0; NULL != tmap[i].text; i++) | ||
242 | { | 247 | { |
243 | /* accept as meta-data */ | 248 | char *spos; |
244 | for (i = 0; NULL != tmap[i].text; i++) | 249 | char *epos; |
245 | { | 250 | char needle[256]; |
246 | char * spos; | 251 | int oc; |
247 | char * epos; | 252 | |
248 | char needle[256]; | 253 | pbuf = buf; |
249 | int oc; | 254 | |
250 | 255 | while (1) | |
251 | pbuf = buf; | 256 | { |
252 | 257 | strcpy (needle, "<"); | |
253 | while (1) | 258 | strcat (needle, tmap[i].text); |
254 | { | 259 | strcat (needle, ">"); |
255 | strcpy(needle, "<"); | 260 | spos = strstr (pbuf, needle); |
256 | strcat(needle, tmap[i].text); | 261 | if (NULL == spos) |
257 | strcat(needle, ">"); | 262 | { |
258 | spos = strstr(pbuf, needle); | 263 | strcpy (needle, tmap[i].text); |
259 | if (NULL == spos) | 264 | strcat (needle, "=\""); |
260 | { | 265 | spos = strstr (pbuf, needle); |
261 | strcpy(needle, tmap[i].text); | 266 | if (spos == NULL) |
262 | strcat(needle, "=\""); | 267 | break; |
263 | spos = strstr(pbuf, needle); | 268 | spos += strlen (needle); |
264 | if (spos == NULL) | 269 | epos = spos; |
265 | break; | 270 | while ( (epos[0] != '\0') && |
266 | spos += strlen(needle); | 271 | (epos[0] != '"') ) |
267 | epos = spos; | 272 | epos++; |
268 | while ( (epos[0] != '\0') && | 273 | } |
269 | (epos[0] != '"') ) | 274 | else |
270 | epos++; | 275 | { |
271 | } | 276 | oc = 0; |
272 | else | 277 | spos += strlen (needle); |
273 | { | 278 | while ( (spos[0] != '\0') && |
274 | oc = 0; | 279 | ( (spos[0] == '<') || |
275 | spos += strlen(needle); | 280 | (oc > 0) ) ) |
276 | while ( (spos[0] != '\0') && | 281 | { |
277 | ( (spos[0] == '<') || | 282 | if (spos[0] == '<') |
278 | (oc > 0) ) ) | 283 | oc++; |
279 | { | 284 | if (spos[0] == '>') |
280 | if (spos[0] == '<') | 285 | oc--; |
281 | oc++; | 286 | spos++; |
282 | if (spos[0] == '>') | 287 | } |
283 | oc--; | 288 | epos = spos; |
284 | spos++; | 289 | while ( (epos[0] != '\0') && |
285 | } | 290 | (epos[0] != '<') && |
286 | epos = spos; | 291 | (epos[0] != '>') ) |
287 | while ( (epos[0] != '\0') && | 292 | { |
288 | (epos[0] != '<') && | 293 | epos++; |
289 | (epos[0] != '>') ) | 294 | } |
290 | { | 295 | } |
291 | epos++; | 296 | if (spos != epos) |
292 | } | 297 | { |
293 | } | 298 | char key[epos - spos + 1]; |
294 | if (spos != epos) | 299 | |
295 | { | 300 | memcpy (key, spos, epos - spos); |
296 | char key[epos - spos + 1]; | 301 | key[epos - spos] = '\0'; |
297 | 302 | if (0 != ec->proc (ec->cls, | |
298 | memcpy(key, spos, epos-spos); | 303 | "odf", |
299 | key[epos-spos] = '\0'; | 304 | tmap[i].type, |
300 | if (0 != ec->proc (ec->cls, | 305 | EXTRACTOR_METAFORMAT_UTF8, |
301 | "odf", | 306 | "text/plain", |
302 | tmap[i].type, | 307 | key, |
303 | EXTRACTOR_METAFORMAT_UTF8, | 308 | epos - spos + 1)) |
304 | "text/plain", | 309 | goto CLEANUP; |
305 | key, | 310 | pbuf = epos; |
306 | epos - spos + 1)) | 311 | } |
307 | goto CLEANUP; | 312 | else |
308 | pbuf = epos; | 313 | break; |
309 | } | 314 | } |
310 | else | ||
311 | break; | ||
312 | } | ||
313 | } | ||
314 | } | 315 | } |
315 | CLEANUP: | 316 | } |
317 | CLEANUP: | ||
316 | free (buf); | 318 | free (buf); |
317 | EXTRACTOR_common_unzip_close (uf); | 319 | EXTRACTOR_common_unzip_close (uf); |
318 | } | 320 | } |
319 | 321 | ||
322 | |||
320 | /* end of odf_extractor.c */ | 323 | /* end of odf_extractor.c */ |
diff --git a/src/plugins/ogg_extractor.c b/src/plugins/ogg_extractor.c index d7005ef..4c773aa 100644 --- a/src/plugins/ogg_extractor.c +++ b/src/plugins/ogg_extractor.c | |||
@@ -52,15 +52,15 @@ read_ogg (void *ptr, size_t size, size_t nmemb, void *datasource) | |||
52 | 52 | ||
53 | data = NULL; | 53 | data = NULL; |
54 | ret = ec->read (ec->cls, | 54 | ret = ec->read (ec->cls, |
55 | &data, | 55 | &data, |
56 | size * nmemb); | 56 | size * nmemb); |
57 | if (-1 == ret) | 57 | if (-1 == ret) |
58 | return 0; | 58 | return 0; |
59 | if (0 == ret) | 59 | if (0 == ret) |
60 | { | 60 | { |
61 | errno = 0; | 61 | errno = 0; |
62 | return 0; | 62 | return 0; |
63 | } | 63 | } |
64 | memcpy (ptr, data, ret); | 64 | memcpy (ptr, data, ret); |
65 | errno = 0; | 65 | errno = 0; |
66 | return ret; | 66 | return ret; |
@@ -77,8 +77,8 @@ read_ogg (void *ptr, size_t size, size_t nmemb, void *datasource) | |||
77 | */ | 77 | */ |
78 | static int | 78 | static int |
79 | seek_ogg (void *datasource, | 79 | seek_ogg (void *datasource, |
80 | ogg_int64_t offset, | 80 | ogg_int64_t offset, |
81 | int whence) | 81 | int whence) |
82 | { | 82 | { |
83 | struct EXTRACTOR_ExtractContext *ec = datasource; | 83 | struct EXTRACTOR_ExtractContext *ec = datasource; |
84 | int64_t new_position; | 84 | int64_t new_position; |
@@ -100,12 +100,11 @@ tell_ogg (void *datasource) | |||
100 | struct EXTRACTOR_ExtractContext *ec = datasource; | 100 | struct EXTRACTOR_ExtractContext *ec = datasource; |
101 | 101 | ||
102 | return (long) ec->seek (ec->cls, | 102 | return (long) ec->seek (ec->cls, |
103 | 0, | 103 | 0, |
104 | SEEK_CUR); | 104 | SEEK_CUR); |
105 | } | 105 | } |
106 | 106 | ||
107 | 107 | ||
108 | |||
109 | /** | 108 | /** |
110 | * Extract the associated meta data for a given label from vorbis. | 109 | * Extract the associated meta data for a given label from vorbis. |
111 | * | 110 | * |
@@ -115,7 +114,7 @@ tell_ogg (void *datasource) | |||
115 | */ | 114 | */ |
116 | static char * | 115 | static char * |
117 | get_comment (vorbis_comment *vc, | 116 | get_comment (vorbis_comment *vc, |
118 | const char *label) | 117 | const char *label) |
119 | { | 118 | { |
120 | if (NULL == vc) | 119 | if (NULL == vc) |
121 | return NULL; | 120 | return NULL; |
@@ -129,7 +128,11 @@ get_comment (vorbis_comment *vc, | |||
129 | * @param t LE meta data type | 128 | * @param t LE meta data type |
130 | * @param s meta data to add | 129 | * @param s meta data to add |
131 | */ | 130 | */ |
132 | #define ADD(t,s) do { if (0 != (ret = ec->proc (ec->cls, "ogg", t, EXTRACTOR_METAFORMAT_UTF8, "text/plain", s, strlen(s)+1))) goto FINISH; } while (0) | 131 | #define ADD(t,s) do { if (0 != (ret = ec->proc (ec->cls, "ogg", t, \ |
132 | EXTRACTOR_METAFORMAT_UTF8, \ | ||
133 | "text/plain", s, strlen (s) \ | ||
134 | + 1))) goto FINISH; \ | ||
135 | } while (0) | ||
133 | 136 | ||
134 | 137 | ||
135 | /** | 138 | /** |
@@ -138,7 +141,8 @@ get_comment (vorbis_comment *vc, | |||
138 | * @param t LE meta data type | 141 | * @param t LE meta data type |
139 | * @param d vorbis meta data label | 142 | * @param d vorbis meta data label |
140 | */ | 143 | */ |
141 | #define ADDG(t,d) do { m = get_comment (comments, d); if (NULL != m) ADD(t,m); } while (0) | 144 | #define ADDG(t,d) do { m = get_comment (comments, d); if (NULL != m) ADD (t,m); \ |
145 | } while (0) | ||
142 | 146 | ||
143 | 147 | ||
144 | /** | 148 | /** |
@@ -200,4 +204,5 @@ FINISH: | |||
200 | ov_clear (&vf); | 204 | ov_clear (&vf); |
201 | } | 205 | } |
202 | 206 | ||
207 | |||
203 | /* end of ogg_extractor.c */ | 208 | /* end of ogg_extractor.c */ |
diff --git a/src/plugins/old/applefile_extractor.c b/src/plugins/old/applefile_extractor.c index cc82dc8..dcaf7d0 100644 --- a/src/plugins/old/applefile_extractor.c +++ b/src/plugins/old/applefile_extractor.c | |||
@@ -42,10 +42,10 @@ typedef struct | |||
42 | #define APPLEFILE_HEADER_SIZE 26 | 42 | #define APPLEFILE_HEADER_SIZE 26 |
43 | #define APPLEFILE_HEADER_SPEC "4bW16bH" | 43 | #define APPLEFILE_HEADER_SPEC "4bW16bH" |
44 | #define APPLEFILE_HEADER_FIELDS(p) \ | 44 | #define APPLEFILE_HEADER_FIELDS(p) \ |
45 | &(p)->magic, \ | 45 | & (p)->magic, \ |
46 | &(p)->version, \ | 46 | &(p)->version, \ |
47 | &(p)->homeFileSystem, \ | 47 | &(p)->homeFileSystem, \ |
48 | &(p)->entries | 48 | &(p)->entries |
49 | 49 | ||
50 | typedef struct | 50 | typedef struct |
51 | { | 51 | { |
@@ -57,9 +57,9 @@ typedef struct | |||
57 | #define APPLEFILE_ENTRY_DESCRIPTOR_SIZE 12 | 57 | #define APPLEFILE_ENTRY_DESCRIPTOR_SIZE 12 |
58 | #define APPLEFILE_ENTRY_DESCRIPTOR_SPEC "WWW" | 58 | #define APPLEFILE_ENTRY_DESCRIPTOR_SPEC "WWW" |
59 | #define APPLEFILE_ENTRY_DESCRIPTOR_FIELDS(p) \ | 59 | #define APPLEFILE_ENTRY_DESCRIPTOR_FIELDS(p) \ |
60 | &(p)->id, \ | 60 | & (p)->id, \ |
61 | &(p)->offset, \ | 61 | &(p)->offset, \ |
62 | &(p)->length | 62 | &(p)->length |
63 | 63 | ||
64 | #define AED_ID_DATA_FORK 1 | 64 | #define AED_ID_DATA_FORK 1 |
65 | #define AED_ID_RESOURCE_FORK 2 | 65 | #define AED_ID_RESOURCE_FORK 2 |
@@ -76,43 +76,47 @@ typedef struct | |||
76 | #define AED_ID_AFP_FILE_INFO 14 | 76 | #define AED_ID_AFP_FILE_INFO 14 |
77 | #define AED_ID_DIRECTORY_ID 15 | 77 | #define AED_ID_DIRECTORY_ID 15 |
78 | 78 | ||
79 | static int readApplefileHeader(const unsigned char *data, | 79 | static int |
80 | size_t *offset, | 80 | readApplefileHeader (const unsigned char *data, |
81 | size_t size, | 81 | size_t *offset, |
82 | ApplefileHeader *hdr) | 82 | size_t size, |
83 | ApplefileHeader *hdr) | ||
83 | { | 84 | { |
84 | if ((*offset + APPLEFILE_HEADER_SIZE) > size) | 85 | if ((*offset + APPLEFILE_HEADER_SIZE) > size) |
85 | return -1; | 86 | return -1; |
86 | 87 | ||
87 | EXTRACTOR_common_cat_unpack(data + *offset, | 88 | EXTRACTOR_common_cat_unpack (data + *offset, |
88 | APPLEFILE_HEADER_SPEC, | 89 | APPLEFILE_HEADER_SPEC, |
89 | APPLEFILE_HEADER_FIELDS(hdr)); | 90 | APPLEFILE_HEADER_FIELDS (hdr)); |
90 | *offset += APPLEFILE_HEADER_SIZE; | 91 | *offset += APPLEFILE_HEADER_SIZE; |
91 | return 0; | 92 | return 0; |
92 | } | 93 | } |
93 | 94 | ||
94 | static int readEntryDescriptor(const unsigned char *data, | 95 | |
95 | size_t *offset, | 96 | static int |
96 | size_t size, | 97 | readEntryDescriptor (const unsigned char *data, |
97 | ApplefileEntryDescriptor *dsc) | 98 | size_t *offset, |
99 | size_t size, | ||
100 | ApplefileEntryDescriptor *dsc) | ||
98 | { | 101 | { |
99 | if ((*offset + APPLEFILE_ENTRY_DESCRIPTOR_SIZE) > size) | 102 | if ((*offset + APPLEFILE_ENTRY_DESCRIPTOR_SIZE) > size) |
100 | return -1; | 103 | return -1; |
101 | 104 | ||
102 | EXTRACTOR_common_cat_unpack(data + *offset, | 105 | EXTRACTOR_common_cat_unpack (data + *offset, |
103 | APPLEFILE_ENTRY_DESCRIPTOR_SPEC, | 106 | APPLEFILE_ENTRY_DESCRIPTOR_SPEC, |
104 | APPLEFILE_ENTRY_DESCRIPTOR_FIELDS(dsc)); | 107 | APPLEFILE_ENTRY_DESCRIPTOR_FIELDS (dsc)); |
105 | *offset += APPLEFILE_ENTRY_DESCRIPTOR_SIZE; | 108 | *offset += APPLEFILE_ENTRY_DESCRIPTOR_SIZE; |
106 | return 0; | 109 | return 0; |
107 | } | 110 | } |
108 | 111 | ||
112 | |||
109 | /* mimetype = application/applefile */ | 113 | /* mimetype = application/applefile */ |
110 | int | 114 | int |
111 | EXTRACTOR_applefile_extract (const char *sdata, | 115 | EXTRACTOR_applefile_extract (const char *sdata, |
112 | size_t size, | 116 | size_t size, |
113 | EXTRACTOR_MetaDataProcessor proc, | 117 | EXTRACTOR_MetaDataProcessor proc, |
114 | void *proc_cls, | 118 | void *proc_cls, |
115 | const char *options) | 119 | const char *options) |
116 | { | 120 | { |
117 | const unsigned char *data = (const unsigned char*) sdata; | 121 | const unsigned char *data = (const unsigned char*) sdata; |
118 | size_t offset; | 122 | size_t offset; |
@@ -121,129 +125,134 @@ EXTRACTOR_applefile_extract (const char *sdata, | |||
121 | int i; | 125 | int i; |
122 | 126 | ||
123 | offset = 0; | 127 | offset = 0; |
124 | if (readApplefileHeader(data, &offset, size, &header) == -1) | 128 | if (readApplefileHeader (data, &offset, size, &header) == -1) |
125 | return 0; | 129 | return 0; |
126 | if ( (memcmp(header.magic, APPLESINGLE_SIGNATURE, 4) != 0) && | 130 | if ( (memcmp (header.magic, APPLESINGLE_SIGNATURE, 4) != 0) && |
127 | (memcmp(header.magic, APPLEDOUBLE_SIGNATURE, 4) != 0) ) | 131 | (memcmp (header.magic, APPLEDOUBLE_SIGNATURE, 4) != 0) ) |
128 | return 0; | 132 | return 0; |
129 | if (0 != proc (proc_cls, | 133 | if (0 != proc (proc_cls, |
130 | "applefile", | 134 | "applefile", |
131 | EXTRACTOR_METATYPE_MIMETYPE, | 135 | EXTRACTOR_METATYPE_MIMETYPE, |
132 | EXTRACTOR_METAFORMAT_UTF8, | 136 | EXTRACTOR_METAFORMAT_UTF8, |
133 | "text/plain", | 137 | "text/plain", |
134 | "application/applefile", | 138 | "application/applefile", |
135 | strlen ("application/applefile")+1)) | 139 | strlen ("application/applefile") + 1)) |
136 | return 1; | 140 | return 1; |
137 | #if DEBUG | 141 | #if DEBUG |
138 | fprintf(stderr, | 142 | fprintf (stderr, |
139 | "applefile header: %08x %d\n", header.version, header.entries); | 143 | "applefile header: %08x %d\n", header.version, header.entries); |
140 | #endif | 144 | #endif |
141 | if ( (header.version != 0x00010000) && | 145 | if ( (header.version != 0x00010000) && |
142 | (header.version != 0x00020000) ) | 146 | (header.version != 0x00020000) ) |
143 | return 0; | 147 | return 0; |
144 | 148 | ||
145 | for (i = 0; i < header.entries; i++) { | 149 | for (i = 0; i < header.entries; i++) |
146 | if (readEntryDescriptor(data, &offset, size, &dsc) == -1) | 150 | { |
151 | if (readEntryDescriptor (data, &offset, size, &dsc) == -1) | ||
147 | break; | 152 | break; |
148 | 153 | ||
149 | #if DEBUG | 154 | #if DEBUG |
150 | fprintf(stderr, | 155 | fprintf (stderr, |
151 | "applefile entry: %u %u %u\n", dsc.id, dsc.offset, dsc.length); | 156 | "applefile entry: %u %u %u\n", dsc.id, dsc.offset, dsc.length); |
152 | #endif | 157 | #endif |
153 | switch (dsc.id) | 158 | switch (dsc.id) |
159 | { | ||
160 | case AED_ID_DATA_FORK: | ||
154 | { | 161 | { |
155 | case AED_ID_DATA_FORK: | 162 | /* same as in filenameextractor.c */ |
156 | { | 163 | char s[14]; |
157 | /* same as in filenameextractor.c */ | ||
158 | char s[14]; | ||
159 | 164 | ||
160 | if (dsc.length >= 1000000000) | 165 | if (dsc.length >= 1000000000) |
161 | snprintf (s, 13, "%.2f %s", dsc.length / 1000000000.0, | 166 | snprintf (s, 13, "%.2f %s", dsc.length / 1000000000.0, |
162 | _("GB")); | 167 | _ ("GB")); |
163 | else if (dsc.length >= 1000000) | 168 | else if (dsc.length >= 1000000) |
164 | snprintf (s, 13, "%.2f %s", dsc.length / 1000000.0, _("MB")); | 169 | snprintf (s, 13, "%.2f %s", dsc.length / 1000000.0, _ ("MB")); |
165 | else if (dsc.length >= 1000) | 170 | else if (dsc.length >= 1000) |
166 | snprintf (s, 13, "%.2f %s", dsc.length / 1000.0, _("KB")); | 171 | snprintf (s, 13, "%.2f %s", dsc.length / 1000.0, _ ("KB")); |
167 | else | 172 | else |
168 | snprintf (s, 13, "%.2f %s", (double) dsc.length, _("Bytes")); | 173 | snprintf (s, 13, "%.2f %s", (double) dsc.length, _ ("Bytes")); |
169 | 174 | ||
170 | if (0 != proc (proc_cls, | 175 | if (0 != proc (proc_cls, |
171 | "applefile", | 176 | "applefile", |
172 | EXTRACTOR_METATYPE_EMBEDDED_FILE_SIZE, | 177 | EXTRACTOR_METATYPE_EMBEDDED_FILE_SIZE, |
173 | EXTRACTOR_METAFORMAT_UTF8, | 178 | EXTRACTOR_METAFORMAT_UTF8, |
174 | "text/plain", | 179 | "text/plain", |
175 | s, | 180 | s, |
176 | strlen (s) + 1)) | 181 | strlen (s) + 1)) |
177 | return 1; | 182 | return 1; |
178 | } | 183 | } |
179 | break; | 184 | break; |
180 | case AED_ID_REAL_NAME: | 185 | case AED_ID_REAL_NAME: |
181 | { | 186 | { |
182 | char s[2048]; | 187 | char s[2048]; |
183 | if ( (dsc.length < sizeof(s)) && | 188 | if ( (dsc.length < sizeof(s)) && |
184 | ((dsc.offset + dsc.length) < size) ) { | 189 | ((dsc.offset + dsc.length) < size) ) |
185 | memcpy(s, data + dsc.offset, dsc.length); | 190 | { |
186 | s[dsc.length] = '\0'; | 191 | memcpy (s, data + dsc.offset, dsc.length); |
187 | if (0 != proc (proc_cls, | 192 | s[dsc.length] = '\0'; |
188 | "applefile", | 193 | if (0 != proc (proc_cls, |
189 | EXTRACTOR_METATYPE_FILENAME, | 194 | "applefile", |
190 | EXTRACTOR_METAFORMAT_UTF8, | 195 | EXTRACTOR_METATYPE_FILENAME, |
191 | "text/plain", | 196 | EXTRACTOR_METAFORMAT_UTF8, |
192 | s, | 197 | "text/plain", |
193 | dsc.length + 1)) | 198 | s, |
194 | return 1; | 199 | dsc.length + 1)) |
195 | } | 200 | return 1; |
196 | } | 201 | } |
197 | break; | 202 | } |
198 | case AED_ID_COMMENT: | 203 | break; |
199 | if ( (dsc.length < 65536) && ((dsc.offset + dsc.length) < size) ) { | 204 | case AED_ID_COMMENT: |
200 | char *s = malloc(dsc.length + 1); | 205 | if ( (dsc.length < 65536) && ((dsc.offset + dsc.length) < size) ) |
201 | if (s != NULL) { | 206 | { |
202 | memcpy(s, data + dsc.offset, dsc.length); | 207 | char *s = malloc (dsc.length + 1); |
203 | s[dsc.length] = '\0'; | 208 | if (s != NULL) |
204 | if (0 != proc (proc_cls, | 209 | { |
205 | "applefile", | 210 | memcpy (s, data + dsc.offset, dsc.length); |
206 | EXTRACTOR_METATYPE_COMMENT, | 211 | s[dsc.length] = '\0'; |
207 | EXTRACTOR_METAFORMAT_UTF8, | 212 | if (0 != proc (proc_cls, |
208 | "text/plain", | 213 | "applefile", |
209 | s, | 214 | EXTRACTOR_METATYPE_COMMENT, |
210 | dsc.length + 1)) | 215 | EXTRACTOR_METAFORMAT_UTF8, |
211 | { | 216 | "text/plain", |
212 | free (s); | 217 | s, |
213 | return 1; | 218 | dsc.length + 1)) |
214 | } | 219 | { |
215 | free (s); | 220 | free (s); |
216 | } | 221 | return 1; |
217 | } | 222 | } |
218 | break; | 223 | free (s); |
219 | case AED_ID_FINDER_INFO: | ||
220 | if (dsc.length >= 16 && (dsc.offset + dsc.length) < size) { | ||
221 | char s[5]; | ||
222 | memcpy(s, data + dsc.offset, 4); | ||
223 | s[4] = '\0'; | ||
224 | if (0 != proc (proc_cls, | ||
225 | "applefile", | ||
226 | EXTRACTOR_METATYPE_FINDER_FILE_TYPE, | ||
227 | EXTRACTOR_METAFORMAT_C_STRING, | ||
228 | "text/plain", | ||
229 | s, | ||
230 | strlen(s) + 1)) | ||
231 | return 1; | ||
232 | |||
233 | memcpy(s, data + dsc.offset + 4, 4); | ||
234 | s[4] = '\0'; | ||
235 | if (0 != proc (proc_cls, | ||
236 | "applefile", | ||
237 | EXTRACTOR_METATYPE_FINDER_FILE_CREATOR, | ||
238 | EXTRACTOR_METAFORMAT_C_STRING, | ||
239 | "text/plain", | ||
240 | s, | ||
241 | strlen(s) + 1)) | ||
242 | return 1; | ||
243 | } | 224 | } |
244 | break; | 225 | } |
245 | default: | 226 | break; |
246 | break; | 227 | case AED_ID_FINDER_INFO: |
228 | if ((dsc.length >= 16) && ( (dsc.offset + dsc.length) < size) ) | ||
229 | { | ||
230 | char s[5]; | ||
231 | memcpy (s, data + dsc.offset, 4); | ||
232 | s[4] = '\0'; | ||
233 | if (0 != proc (proc_cls, | ||
234 | "applefile", | ||
235 | EXTRACTOR_METATYPE_FINDER_FILE_TYPE, | ||
236 | EXTRACTOR_METAFORMAT_C_STRING, | ||
237 | "text/plain", | ||
238 | s, | ||
239 | strlen (s) + 1)) | ||
240 | return 1; | ||
241 | |||
242 | memcpy (s, data + dsc.offset + 4, 4); | ||
243 | s[4] = '\0'; | ||
244 | if (0 != proc (proc_cls, | ||
245 | "applefile", | ||
246 | EXTRACTOR_METATYPE_FINDER_FILE_CREATOR, | ||
247 | EXTRACTOR_METAFORMAT_C_STRING, | ||
248 | "text/plain", | ||
249 | s, | ||
250 | strlen (s) + 1)) | ||
251 | return 1; | ||
252 | } | ||
253 | break; | ||
254 | default: | ||
255 | break; | ||
247 | } | 256 | } |
248 | } | 257 | } |
249 | return 0; | 258 | return 0; |
diff --git a/src/plugins/old/asf_extractor.c b/src/plugins/old/asf_extractor.c index 0581ded..6be0a16 100644 --- a/src/plugins/old/asf_extractor.c +++ b/src/plugins/old/asf_extractor.c | |||
@@ -110,199 +110,288 @@ static const struct | |||
110 | { | 110 | { |
111 | const char *name; | 111 | const char *name; |
112 | const LE_GUID guid; | 112 | const LE_GUID guid; |
113 | } guids[] = | 113 | } guids[] = { |
114 | { | ||
115 | { | 114 | { |
116 | "error", | 115 | "error", |
117 | { | 116 | { |
118 | 0x0,}}, | 117 | 0x0, |
119 | /* base ASF objects */ | 118 | } |
119 | }, | ||
120 | /* base ASF objects */ | ||
120 | { | 121 | { |
121 | "header", | 122 | "header", |
122 | { | 123 | { |
123 | 0x75b22630, 0x668e, 0x11cf, | 124 | 0x75b22630, 0x668e, 0x11cf, |
124 | { | 125 | { |
125 | 0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c}}}, | 126 | 0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c |
127 | } | ||
128 | } | ||
129 | }, | ||
126 | { | 130 | { |
127 | "data", | 131 | "data", |
128 | { | 132 | { |
129 | 0x75b22636, 0x668e, 0x11cf, | 133 | 0x75b22636, 0x668e, 0x11cf, |
130 | { | 134 | { |
131 | 0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c}}}, | 135 | 0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c |
136 | } | ||
137 | } | ||
138 | }, | ||
132 | { | 139 | { |
133 | "simple index", | 140 | "simple index", |
134 | { | 141 | { |
135 | 0x33000890, 0xe5b1, 0x11cf, | 142 | 0x33000890, 0xe5b1, 0x11cf, |
136 | { | 143 | { |
137 | 0x89, 0xf4, 0x00, 0xa0, 0xc9, 0x03, 0x49, 0xcb}}}, | 144 | 0x89, 0xf4, 0x00, 0xa0, 0xc9, 0x03, 0x49, 0xcb |
138 | /* header ASF objects */ | 145 | } |
146 | } | ||
147 | }, | ||
148 | /* header ASF objects */ | ||
139 | { | 149 | { |
140 | "file properties", | 150 | "file properties", |
141 | { | 151 | { |
142 | 0x8cabdca1, 0xa947, 0x11cf, | 152 | 0x8cabdca1, 0xa947, 0x11cf, |
143 | { | 153 | { |
144 | 0x8e, 0xe4, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65}}}, | 154 | 0x8e, 0xe4, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65 |
155 | } | ||
156 | } | ||
157 | }, | ||
145 | { | 158 | { |
146 | "stream header", | 159 | "stream header", |
147 | { | 160 | { |
148 | 0xb7dc0791, 0xa9b7, 0x11cf, | 161 | 0xb7dc0791, 0xa9b7, 0x11cf, |
149 | { | 162 | { |
150 | 0x8e, 0xe6, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65}}}, | 163 | 0x8e, 0xe6, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65 |
164 | } | ||
165 | } | ||
166 | }, | ||
151 | { | 167 | { |
152 | "stream bitrate properties", /* (http://get.to/sdp) */ | 168 | "stream bitrate properties", /* (http://get.to/sdp) */ |
153 | { | 169 | { |
154 | 0x7bf875ce, 0x468d, 0x11d1, | 170 | 0x7bf875ce, 0x468d, 0x11d1, |
155 | { | 171 | { |
156 | 0x8d, 0x82, 0x00, 0x60, 0x97, 0xc9, 0xa2, 0xb2}}}, | 172 | 0x8d, 0x82, 0x00, 0x60, 0x97, 0xc9, 0xa2, 0xb2 |
173 | } | ||
174 | } | ||
175 | }, | ||
157 | { | 176 | { |
158 | "content description", | 177 | "content description", |
159 | { | 178 | { |
160 | 0x75b22633, 0x668e, 0x11cf, | 179 | 0x75b22633, 0x668e, 0x11cf, |
161 | { | 180 | { |
162 | 0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c}}}, | 181 | 0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c |
182 | } | ||
183 | } | ||
184 | }, | ||
163 | { | 185 | { |
164 | "extended content encryption", | 186 | "extended content encryption", |
165 | { | 187 | { |
166 | 0x298ae614, 0x2622, 0x4c17, | 188 | 0x298ae614, 0x2622, 0x4c17, |
167 | { | 189 | { |
168 | 0xb9, 0x35, 0xda, 0xe0, 0x7e, 0xe9, 0x28, 0x9c}}}, | 190 | 0xb9, 0x35, 0xda, 0xe0, 0x7e, 0xe9, 0x28, 0x9c |
191 | } | ||
192 | } | ||
193 | }, | ||
169 | { | 194 | { |
170 | "script command", | 195 | "script command", |
171 | { | 196 | { |
172 | 0x1efb1a30, 0x0b62, 0x11d0, | 197 | 0x1efb1a30, 0x0b62, 0x11d0, |
173 | { | 198 | { |
174 | 0xa3, 0x9b, 0x00, 0xa0, 0xc9, 0x03, 0x48, 0xf6}}}, | 199 | 0xa3, 0x9b, 0x00, 0xa0, 0xc9, 0x03, 0x48, 0xf6 |
200 | } | ||
201 | } | ||
202 | }, | ||
175 | { | 203 | { |
176 | "marker", | 204 | "marker", |
177 | { | 205 | { |
178 | 0xf487cd01, 0xa951, 0x11cf, | 206 | 0xf487cd01, 0xa951, 0x11cf, |
179 | { | 207 | { |
180 | 0x8e, 0xe6, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65}}}, | 208 | 0x8e, 0xe6, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65 |
209 | } | ||
210 | } | ||
211 | }, | ||
181 | { | 212 | { |
182 | "header extension", | 213 | "header extension", |
183 | { | 214 | { |
184 | 0x5fbf03b5, 0xa92e, 0x11cf, | 215 | 0x5fbf03b5, 0xa92e, 0x11cf, |
185 | { | 216 | { |
186 | 0x8e, 0xe3, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65}}}, | 217 | 0x8e, 0xe3, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65 |
218 | } | ||
219 | } | ||
220 | }, | ||
187 | { | 221 | { |
188 | "bitrate mutual exclusion", | 222 | "bitrate mutual exclusion", |
189 | { | 223 | { |
190 | 0xd6e229dc, 0x35da, 0x11d1, | 224 | 0xd6e229dc, 0x35da, 0x11d1, |
191 | { | 225 | { |
192 | 0x90, 0x34, 0x00, 0xa0, 0xc9, 0x03, 0x49, 0xbe}}}, | 226 | 0x90, 0x34, 0x00, 0xa0, 0xc9, 0x03, 0x49, 0xbe |
227 | } | ||
228 | } | ||
229 | }, | ||
193 | { | 230 | { |
194 | "codec list", | 231 | "codec list", |
195 | { | 232 | { |
196 | 0x86d15240, 0x311d, 0x11d0, | 233 | 0x86d15240, 0x311d, 0x11d0, |
197 | { | 234 | { |
198 | 0xa3, 0xa4, 0x00, 0xa0, 0xc9, 0x03, 0x48, 0xf6}}}, | 235 | 0xa3, 0xa4, 0x00, 0xa0, 0xc9, 0x03, 0x48, 0xf6 |
236 | } | ||
237 | } | ||
238 | }, | ||
199 | { | 239 | { |
200 | "extended content description", | 240 | "extended content description", |
201 | { | 241 | { |
202 | 0xd2d0a440, 0xe307, 0x11d2, | 242 | 0xd2d0a440, 0xe307, 0x11d2, |
203 | { | 243 | { |
204 | 0x97, 0xf0, 0x00, 0xa0, 0xc9, 0x5e, 0xa8, 0x50}}}, | 244 | 0x97, 0xf0, 0x00, 0xa0, 0xc9, 0x5e, 0xa8, 0x50 |
245 | } | ||
246 | } | ||
247 | }, | ||
205 | { | 248 | { |
206 | "error correction", | 249 | "error correction", |
207 | { | 250 | { |
208 | 0x75b22635, 0x668e, 0x11cf, | 251 | 0x75b22635, 0x668e, 0x11cf, |
209 | { | 252 | { |
210 | 0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c}}}, | 253 | 0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c |
254 | } | ||
255 | } | ||
256 | }, | ||
211 | { | 257 | { |
212 | "padding", | 258 | "padding", |
213 | { | 259 | { |
214 | 0x1806d474, 0xcadf, 0x4509, | 260 | 0x1806d474, 0xcadf, 0x4509, |
215 | { | 261 | { |
216 | 0xa4, 0xba, 0x9a, 0xab, 0xcb, 0x96, 0xaa, 0xe8}}}, | 262 | 0xa4, 0xba, 0x9a, 0xab, 0xcb, 0x96, 0xaa, 0xe8 |
217 | /* stream properties object stream type */ | 263 | } |
264 | } | ||
265 | }, | ||
266 | /* stream properties object stream type */ | ||
218 | { | 267 | { |
219 | "audio media", | 268 | "audio media", |
220 | { | 269 | { |
221 | 0xf8699e40, 0x5b4d, 0x11cf, | 270 | 0xf8699e40, 0x5b4d, 0x11cf, |
222 | { | 271 | { |
223 | 0xa8, 0xfd, 0x00, 0x80, 0x5f, 0x5c, 0x44, 0x2b}}}, | 272 | 0xa8, 0xfd, 0x00, 0x80, 0x5f, 0x5c, 0x44, 0x2b |
273 | } | ||
274 | } | ||
275 | }, | ||
224 | { | 276 | { |
225 | "video media", | 277 | "video media", |
226 | { | 278 | { |
227 | 0xbc19efc0, 0x5b4d, 0x11cf, | 279 | 0xbc19efc0, 0x5b4d, 0x11cf, |
228 | { | 280 | { |
229 | 0xa8, 0xfd, 0x00, 0x80, 0x5f, 0x5c, 0x44, 0x2b}}}, | 281 | 0xa8, 0xfd, 0x00, 0x80, 0x5f, 0x5c, 0x44, 0x2b |
282 | } | ||
283 | } | ||
284 | }, | ||
230 | { | 285 | { |
231 | "command media", | 286 | "command media", |
232 | { | 287 | { |
233 | 0x59dacfc0, 0x59e6, 0x11d0, | 288 | 0x59dacfc0, 0x59e6, 0x11d0, |
234 | { | 289 | { |
235 | 0xa3, 0xac, 0x00, 0xa0, 0xc9, 0x03, 0x48, 0xf6}}}, | 290 | 0xa3, 0xac, 0x00, 0xa0, 0xc9, 0x03, 0x48, 0xf6 |
236 | /* stream properties object error correction */ | 291 | } |
292 | } | ||
293 | }, | ||
294 | /* stream properties object error correction */ | ||
237 | { | 295 | { |
238 | "no error correction", | 296 | "no error correction", |
239 | { | 297 | { |
240 | 0x20fb5700, 0x5b55, 0x11cf, | 298 | 0x20fb5700, 0x5b55, 0x11cf, |
241 | { | 299 | { |
242 | 0xa8, 0xfd, 0x00, 0x80, 0x5f, 0x5c, 0x44, 0x2b}}}, | 300 | 0xa8, 0xfd, 0x00, 0x80, 0x5f, 0x5c, 0x44, 0x2b |
301 | } | ||
302 | } | ||
303 | }, | ||
243 | { | 304 | { |
244 | "audio spread", | 305 | "audio spread", |
245 | { | 306 | { |
246 | 0xbfc3cd50, 0x618f, 0x11cf, | 307 | 0xbfc3cd50, 0x618f, 0x11cf, |
247 | { | 308 | { |
248 | 0x8b, 0xb2, 0x00, 0xaa, 0x00, 0xb4, 0xe2, 0x20}}}, | 309 | 0x8b, 0xb2, 0x00, 0xaa, 0x00, 0xb4, 0xe2, 0x20 |
249 | /* mutual exclusion object exlusion type */ | 310 | } |
311 | } | ||
312 | }, | ||
313 | /* mutual exclusion object exlusion type */ | ||
250 | { | 314 | { |
251 | "mutex bitrate", | 315 | "mutex bitrate", |
252 | { | 316 | { |
253 | 0xd6e22a01, 0x35da, 0x11d1, | 317 | 0xd6e22a01, 0x35da, 0x11d1, |
254 | { | 318 | { |
255 | 0x90, 0x34, 0x00, 0xa0, 0xc9, 0x03, 0x49, 0xbe}}}, | 319 | 0x90, 0x34, 0x00, 0xa0, 0xc9, 0x03, 0x49, 0xbe |
320 | } | ||
321 | } | ||
322 | }, | ||
256 | { | 323 | { |
257 | "mutex unknown", | 324 | "mutex unknown", |
258 | { | 325 | { |
259 | 0xd6e22a02, 0x35da, 0x11d1, | 326 | 0xd6e22a02, 0x35da, 0x11d1, |
260 | { | 327 | { |
261 | 0x90, 0x34, 0x00, 0xa0, 0xc9, 0x03, 0x49, 0xbe}}}, | 328 | 0x90, 0x34, 0x00, 0xa0, 0xc9, 0x03, 0x49, 0xbe |
262 | /* header extension */ | 329 | } |
330 | } | ||
331 | }, | ||
332 | /* header extension */ | ||
263 | { | 333 | { |
264 | "reserved_1", | 334 | "reserved_1", |
265 | { | 335 | { |
266 | 0xabd3d211, 0xa9ba, 0x11cf, | 336 | 0xabd3d211, 0xa9ba, 0x11cf, |
267 | { | 337 | { |
268 | 0x8e, 0xe6, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65}}}, | 338 | 0x8e, 0xe6, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65 |
269 | /* script command */ | 339 | } |
340 | } | ||
341 | }, | ||
342 | /* script command */ | ||
270 | { | 343 | { |
271 | "reserved script command", | 344 | "reserved script command", |
272 | { | 345 | { |
273 | 0x4B1ACBE3, 0x100B, 0x11D0, | 346 | 0x4B1ACBE3, 0x100B, 0x11D0, |
274 | { | 347 | { |
275 | 0xA3, 0x9B, 0x00, 0xA0, 0xC9, 0x03, 0x48, 0xF6}}}, | 348 | 0xA3, 0x9B, 0x00, 0xA0, 0xC9, 0x03, 0x48, 0xF6 |
276 | /* marker object */ | 349 | } |
350 | } | ||
351 | }, | ||
352 | /* marker object */ | ||
277 | { | 353 | { |
278 | "reserved marker", | 354 | "reserved marker", |
279 | { | 355 | { |
280 | 0x4CFEDB20, 0x75F6, 0x11CF, | 356 | 0x4CFEDB20, 0x75F6, 0x11CF, |
281 | { | 357 | { |
282 | 0x9C, 0x0F, 0x00, 0xA0, 0xC9, 0x03, 0x49, 0xCB}}}, | 358 | 0x9C, 0x0F, 0x00, 0xA0, 0xC9, 0x03, 0x49, 0xCB |
283 | /* various */ | 359 | } |
284 | /* Already defined (reserved_1) | 360 | } |
285 | { "head2", | 361 | }, |
286 | { 0xabd3d211, 0xa9ba, 0x11cf, { 0x8e, 0xe6, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65 }} }, | 362 | /* various */ |
287 | */ | 363 | /* Already defined (reserved_1) |
364 | { "head2", | ||
365 | { 0xabd3d211, 0xa9ba, 0x11cf, { 0x8e, 0xe6, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65 }} }, | ||
366 | */ | ||
288 | { | 367 | { |
289 | "audio conceal none", | 368 | "audio conceal none", |
290 | { | 369 | { |
291 | 0x49f1a440, 0x4ece, 0x11d0, | 370 | 0x49f1a440, 0x4ece, 0x11d0, |
292 | { | 371 | { |
293 | 0xa3, 0xac, 0x00, 0xa0, 0xc9, 0x03, 0x48, 0xf6}}}, | 372 | 0xa3, 0xac, 0x00, 0xa0, 0xc9, 0x03, 0x48, 0xf6 |
373 | } | ||
374 | } | ||
375 | }, | ||
294 | { | 376 | { |
295 | "codec comment1 header", | 377 | "codec comment1 header", |
296 | { | 378 | { |
297 | 0x86d15241, 0x311d, 0x11d0, | 379 | 0x86d15241, 0x311d, 0x11d0, |
298 | { | 380 | { |
299 | 0xa3, 0xa4, 0x00, 0xa0, 0xc9, 0x03, 0x48, 0xf6}}}, | 381 | 0xa3, 0xa4, 0x00, 0xa0, 0xc9, 0x03, 0x48, 0xf6 |
382 | } | ||
383 | } | ||
384 | }, | ||
300 | { | 385 | { |
301 | "asf 2.0 header", | 386 | "asf 2.0 header", |
302 | { | 387 | { |
303 | 0xd6e229d1, 0x35da, 0x11d1, | 388 | 0xd6e229d1, 0x35da, 0x11d1, |
304 | { | 389 | { |
305 | 0x90, 0x34, 0x00, 0xa0, 0xc9, 0x03, 0x49, 0xbe}}},}; | 390 | 0x90, 0x34, 0x00, 0xa0, 0xc9, 0x03, 0x49, 0xbe |
391 | } | ||
392 | } | ||
393 | }, | ||
394 | }; | ||
306 | 395 | ||
307 | 396 | ||
308 | struct demux_asf_s | 397 | struct demux_asf_s |
@@ -326,7 +415,7 @@ struct demux_asf_s | |||
326 | }; | 415 | }; |
327 | 416 | ||
328 | static int | 417 | static int |
329 | readBuf (struct demux_asf_s * this, void *buf, int len) | 418 | readBuf (struct demux_asf_s *this, void *buf, int len) |
330 | { | 419 | { |
331 | int min; | 420 | int min; |
332 | 421 | ||
@@ -338,8 +427,9 @@ readBuf (struct demux_asf_s * this, void *buf, int len) | |||
338 | return min; | 427 | return min; |
339 | } | 428 | } |
340 | 429 | ||
430 | |||
341 | static uint8_t | 431 | static uint8_t |
342 | get_byte (struct demux_asf_s * this) | 432 | get_byte (struct demux_asf_s *this) |
343 | { | 433 | { |
344 | uint8_t buf; | 434 | uint8_t buf; |
345 | int i; | 435 | int i; |
@@ -350,8 +440,9 @@ get_byte (struct demux_asf_s * this) | |||
350 | return buf; | 440 | return buf; |
351 | } | 441 | } |
352 | 442 | ||
443 | |||
353 | static uint16_t | 444 | static uint16_t |
354 | get_le16 (struct demux_asf_s * this) | 445 | get_le16 (struct demux_asf_s *this) |
355 | { | 446 | { |
356 | uint8_t buf[2]; | 447 | uint8_t buf[2]; |
357 | int i; | 448 | int i; |
@@ -362,8 +453,9 @@ get_le16 (struct demux_asf_s * this) | |||
362 | return buf[0] | (buf[1] << 8); | 453 | return buf[0] | (buf[1] << 8); |
363 | } | 454 | } |
364 | 455 | ||
456 | |||
365 | static uint32_t | 457 | static uint32_t |
366 | get_le32 (struct demux_asf_s * this) | 458 | get_le32 (struct demux_asf_s *this) |
367 | { | 459 | { |
368 | uint8_t buf[4]; | 460 | uint8_t buf[4]; |
369 | int i; | 461 | int i; |
@@ -374,8 +466,9 @@ get_le32 (struct demux_asf_s * this) | |||
374 | return buf[0] | (buf[1] << 8) | (buf[2] << 16) | (buf[3] << 24); | 466 | return buf[0] | (buf[1] << 8) | (buf[2] << 16) | (buf[3] << 24); |
375 | } | 467 | } |
376 | 468 | ||
469 | |||
377 | static uint64_t | 470 | static uint64_t |
378 | get_le64 (struct demux_asf_s * this) | 471 | get_le64 (struct demux_asf_s *this) |
379 | { | 472 | { |
380 | uint8_t buf[8]; | 473 | uint8_t buf[8]; |
381 | int i; | 474 | int i; |
@@ -384,16 +477,17 @@ get_le64 (struct demux_asf_s * this) | |||
384 | if (i != 8) | 477 | if (i != 8) |
385 | this->status = DEMUX_FINISHED; | 478 | this->status = DEMUX_FINISHED; |
386 | return (uint64_t) buf[0] | 479 | return (uint64_t) buf[0] |
387 | | ((uint64_t) buf[1] << 8) | 480 | | ((uint64_t) buf[1] << 8) |
388 | | ((uint64_t) buf[2] << 16) | 481 | | ((uint64_t) buf[2] << 16) |
389 | | ((uint64_t) buf[3] << 24) | 482 | | ((uint64_t) buf[3] << 24) |
390 | | ((uint64_t) buf[4] << 32) | 483 | | ((uint64_t) buf[4] << 32) |
391 | | ((uint64_t) buf[5] << 40) | 484 | | ((uint64_t) buf[5] << 40) |
392 | | ((uint64_t) buf[6] << 48) | ((uint64_t) buf[7] << 54); | 485 | | ((uint64_t) buf[6] << 48) | ((uint64_t) buf[7] << 54); |
393 | } | 486 | } |
394 | 487 | ||
488 | |||
395 | static int | 489 | static int |
396 | get_guid (struct demux_asf_s * this) | 490 | get_guid (struct demux_asf_s *this) |
397 | { | 491 | { |
398 | int i; | 492 | int i; |
399 | LE_GUID g; | 493 | LE_GUID g; |
@@ -406,7 +500,7 @@ get_guid (struct demux_asf_s * this) | |||
406 | if (this->status == DEMUX_FINISHED) | 500 | if (this->status == DEMUX_FINISHED) |
407 | return GUID_ERROR; | 501 | return GUID_ERROR; |
408 | for (i = 1; i < GUID_END; i++) | 502 | for (i = 1; i < GUID_END; i++) |
409 | if (!memcmp (&g, &guids[i].guid, sizeof (LE_GUID))) | 503 | if (! memcmp (&g, &guids[i].guid, sizeof (LE_GUID))) |
410 | return i; | 504 | return i; |
411 | 505 | ||
412 | return GUID_ERROR; | 506 | return GUID_ERROR; |
@@ -414,7 +508,7 @@ get_guid (struct demux_asf_s * this) | |||
414 | 508 | ||
415 | 509 | ||
416 | static int | 510 | static int |
417 | asf_read_header (struct demux_asf_s * this) | 511 | asf_read_header (struct demux_asf_s *this) |
418 | { | 512 | { |
419 | int guid; | 513 | int guid; |
420 | uint64_t gsize; | 514 | uint64_t gsize; |
@@ -426,62 +520,67 @@ asf_read_header (struct demux_asf_s * this) | |||
426 | get_le64 (this); /* object size */ | 520 | get_le64 (this); /* object size */ |
427 | get_le32 (this); /* number of header objects */ | 521 | get_le32 (this); /* number of header objects */ |
428 | get_byte (this); /* reserved 1 */ | 522 | get_byte (this); /* reserved 1 */ |
429 | get_byte (this); /* reserved 2 */ | 523 | get_byte (this); /* reserved 2 */ |
430 | while (this->status != DEMUX_FINISHED) | 524 | while (this->status != DEMUX_FINISHED) |
525 | { | ||
526 | guid = get_guid (this); /* object ID */ | ||
527 | gsize = get_le64 (this); /* object size */ | ||
528 | if (gsize < 24) | ||
529 | goto fail; | ||
530 | switch (guid) | ||
431 | { | 531 | { |
432 | guid = get_guid (this); /* object ID */ | 532 | case GUID_ASF_FILE_PROPERTIES: |
433 | gsize = get_le64 (this); /* object size */ | 533 | guid = get_guid (this); /* file ID */ |
434 | if (gsize < 24) | 534 | get_le64 (this); /* file size */ |
435 | goto fail; | 535 | get_le64 (this); /* creation date */ |
436 | switch (guid) | 536 | get_le64 (this); /* nb_packets */ |
437 | { | 537 | this->length = get_le64 (this); /* play duration in 100 ns units */ |
438 | case GUID_ASF_FILE_PROPERTIES: | 538 | get_le64 (this); /* send duration */ |
439 | guid = get_guid (this); /* file ID */ | 539 | get_le64 (this); /* preroll */ |
440 | get_le64 (this); /* file size */ | 540 | get_le32 (this); /* flags */ |
441 | get_le64 (this); /* creation date */ | 541 | get_le32 (this); /* min size */ |
442 | get_le64 (this); /* nb_packets */ | 542 | get_le32 (this); /* max size */ |
443 | this->length = get_le64 (this); /* play duration in 100 ns units */ | 543 | get_le32 (this); /* max bitrate */ |
444 | get_le64 (this); /* send duration */ | 544 | break; |
445 | get_le64 (this); /* preroll */ | 545 | case GUID_ASF_DATA: |
446 | get_le32 (this); /* flags */ | 546 | goto headers_ok; |
447 | get_le32 (this); /* min size */ | 547 | break; |
448 | get_le32 (this); /* max size */ | 548 | case GUID_ASF_CONTENT_DESCRIPTION: |
449 | get_le32 (this); /* max bitrate */ | 549 | len1 = get_le16 (this); |
450 | break; | 550 | len2 = get_le16 (this); |
451 | case GUID_ASF_DATA: | 551 | len3 = get_le16 (this); |
452 | goto headers_ok; | 552 | len4 = get_le16 (this); |
453 | break; | 553 | len5 = get_le16 (this); |
454 | case GUID_ASF_CONTENT_DESCRIPTION: | 554 | this->title = EXTRACTOR_common_convert_to_utf8 ( |
455 | len1 = get_le16 (this); | 555 | &this->input[this->inputPos], |
456 | len2 = get_le16 (this); | 556 | len1, |
457 | len3 = get_le16 (this); | 557 | "UTF-16"); |
458 | len4 = get_le16 (this); | 558 | this->inputPos += len1; |
459 | len5 = get_le16 (this); | 559 | this->author = EXTRACTOR_common_convert_to_utf8 ( |
460 | this->title = EXTRACTOR_common_convert_to_utf8 (&this->input[this->inputPos], | 560 | &this->input[this->inputPos], |
461 | len1, | 561 | len2, |
462 | "UTF-16"); | 562 | "UTF-16"); |
463 | this->inputPos += len1; | 563 | this->inputPos += len2; |
464 | this->author = EXTRACTOR_common_convert_to_utf8 (&this->input[this->inputPos], | 564 | this->copyright = EXTRACTOR_common_convert_to_utf8 ( |
465 | len2, | 565 | &this->input[this->inputPos], |
466 | "UTF-16"); | 566 | len3, |
467 | this->inputPos += len2; | 567 | "UTF-16"); |
468 | this->copyright = EXTRACTOR_common_convert_to_utf8 (&this->input[this->inputPos], | 568 | this->inputPos += len3; |
469 | len3, | 569 | this->comment = EXTRACTOR_common_convert_to_utf8 ( |
470 | "UTF-16"); | 570 | &this->input[this->inputPos], |
471 | this->inputPos += len3; | 571 | len4, |
472 | this->comment = EXTRACTOR_common_convert_to_utf8 (&this->input[this->inputPos], | 572 | "UTF-16"); |
473 | len4, | 573 | this->inputPos += len4; |
474 | "UTF-16"); | 574 | this->rating = EXTRACTOR_common_convert_to_utf8 ( |
475 | this->inputPos += len4; | 575 | &this->input[this->inputPos], |
476 | this->rating = EXTRACTOR_common_convert_to_utf8 (&this->input[this->inputPos], | 576 | len5, |
477 | len5, | 577 | "UTF-16"); |
478 | "UTF-16"); | 578 | this->inputPos += len5; |
479 | this->inputPos += len5; | 579 | break; |
480 | break; | 580 | default: |
481 | default: | 581 | this->inputPos += gsize - 24; |
482 | this->inputPos += gsize - 24; | ||
483 | } | ||
484 | } | 582 | } |
583 | } | ||
485 | 584 | ||
486 | headers_ok: | 585 | headers_ok: |
487 | this->inputPos += sizeof (LE_GUID) + 10; | 586 | this->inputPos += sizeof (LE_GUID) + 10; |
@@ -502,12 +601,12 @@ fail: | |||
502 | video/x-ms-wax: wva: wma metafile; */ | 601 | video/x-ms-wax: wva: wma metafile; */ |
503 | 602 | ||
504 | /* mimetype = application/applefile */ | 603 | /* mimetype = application/applefile */ |
505 | int | 604 | int |
506 | EXTRACTOR_asf_extract (const char *data, | 605 | EXTRACTOR_asf_extract (const char *data, |
507 | size_t size, | 606 | size_t size, |
508 | EXTRACTOR_MetaDataProcessor proc, | 607 | EXTRACTOR_MetaDataProcessor proc, |
509 | void *proc_cls, | 608 | void *proc_cls, |
510 | const char *options) | 609 | const char *options) |
511 | { | 610 | { |
512 | struct demux_asf_s this; | 611 | struct demux_asf_s this; |
513 | size_t slen; | 612 | size_t slen; |
@@ -521,60 +620,60 @@ EXTRACTOR_asf_extract (const char *data, | |||
521 | ret = 0; | 620 | ret = 0; |
522 | if (1 == asf_read_header (&this)) | 621 | if (1 == asf_read_header (&this)) |
523 | { | 622 | { |
524 | snprintf (duration_str, | 623 | snprintf (duration_str, |
525 | sizeof (duration_str), | 624 | sizeof (duration_str), |
526 | "%llu ms", (unsigned long long) (this.length / 10000LL)); | 625 | "%llu ms", (unsigned long long) (this.length / 10000LL)); |
527 | if ( ( (this.title != NULL) && | 626 | if ( ( (this.title != NULL) && |
528 | (0 < (slen = strlen(this.title))) && | 627 | (0 < (slen = strlen (this.title))) && |
529 | (0 != proc (proc_cls, | 628 | (0 != proc (proc_cls, |
530 | "asf", | 629 | "asf", |
531 | EXTRACTOR_METATYPE_TITLE, | 630 | EXTRACTOR_METATYPE_TITLE, |
532 | EXTRACTOR_METAFORMAT_C_STRING, | 631 | EXTRACTOR_METAFORMAT_C_STRING, |
533 | "text/plain", | 632 | "text/plain", |
534 | this.title, | 633 | this.title, |
535 | slen + 1)) ) || | 634 | slen + 1)) ) || |
536 | ( (this.author != NULL) && | 635 | ( (this.author != NULL) && |
537 | (0 < (slen = strlen(this.author))) && | 636 | (0 < (slen = strlen (this.author))) && |
538 | (0 != proc (proc_cls, | 637 | (0 != proc (proc_cls, |
539 | "asf", | 638 | "asf", |
540 | EXTRACTOR_METATYPE_AUTHOR_NAME, | 639 | EXTRACTOR_METATYPE_AUTHOR_NAME, |
541 | EXTRACTOR_METAFORMAT_C_STRING, | 640 | EXTRACTOR_METAFORMAT_C_STRING, |
542 | "text/plain", | 641 | "text/plain", |
543 | this.author, | 642 | this.author, |
544 | slen + 1)) ) || | 643 | slen + 1)) ) || |
545 | ( (this.comment != NULL) && | 644 | ( (this.comment != NULL) && |
546 | (0 < (slen = strlen(this.comment))) && | 645 | (0 < (slen = strlen (this.comment))) && |
547 | (0 != proc (proc_cls, | 646 | (0 != proc (proc_cls, |
548 | "asf", | 647 | "asf", |
549 | EXTRACTOR_METATYPE_COMMENT, | 648 | EXTRACTOR_METATYPE_COMMENT, |
550 | EXTRACTOR_METAFORMAT_C_STRING, | 649 | EXTRACTOR_METAFORMAT_C_STRING, |
551 | "text/plain", | 650 | "text/plain", |
552 | this.comment, | 651 | this.comment, |
553 | slen + 1)) ) || | 652 | slen + 1)) ) || |
554 | ( (this.copyright != NULL) && | 653 | ( (this.copyright != NULL) && |
555 | (0 < (slen = strlen(this.copyright))) && | 654 | (0 < (slen = strlen (this.copyright))) && |
556 | (0 != proc (proc_cls, | 655 | (0 != proc (proc_cls, |
557 | "asf", | 656 | "asf", |
558 | EXTRACTOR_METATYPE_COPYRIGHT, | 657 | EXTRACTOR_METATYPE_COPYRIGHT, |
559 | EXTRACTOR_METAFORMAT_C_STRING, | 658 | EXTRACTOR_METAFORMAT_C_STRING, |
560 | "text/plain", | 659 | "text/plain", |
561 | this.copyright, | 660 | this.copyright, |
562 | slen + 1)) ) || | 661 | slen + 1)) ) || |
563 | (0 != proc (proc_cls, | 662 | (0 != proc (proc_cls, |
564 | "asf", | 663 | "asf", |
565 | EXTRACTOR_METATYPE_MIMETYPE, | 664 | EXTRACTOR_METATYPE_MIMETYPE, |
566 | EXTRACTOR_METAFORMAT_C_STRING, | 665 | EXTRACTOR_METAFORMAT_C_STRING, |
567 | "text/plain", | 666 | "text/plain", |
568 | "video/x-ms-asf", | 667 | "video/x-ms-asf", |
569 | strlen("video/x-ms-asf") + 1)) || | 668 | strlen ("video/x-ms-asf") + 1)) || |
570 | (0 != proc (proc_cls, | 669 | (0 != proc (proc_cls, |
571 | "asf", | 670 | "asf", |
572 | EXTRACTOR_METATYPE_DURATION, | 671 | EXTRACTOR_METATYPE_DURATION, |
573 | EXTRACTOR_METAFORMAT_C_STRING, | 672 | EXTRACTOR_METAFORMAT_C_STRING, |
574 | "text/plain", | 673 | "text/plain", |
575 | duration_str, | 674 | duration_str, |
576 | strlen(duration_str) + 1)) ) | 675 | strlen (duration_str) + 1)) ) |
577 | ret = 1; | 676 | ret = 1; |
578 | } | 677 | } |
579 | free (this.title); | 678 | free (this.title); |
580 | free (this.author); | 679 | free (this.author); |
@@ -584,4 +683,5 @@ EXTRACTOR_asf_extract (const char *data, | |||
584 | return ret; | 683 | return ret; |
585 | } | 684 | } |
586 | 685 | ||
686 | |||
587 | /* end of asf_extractor.c */ | 687 | /* end of asf_extractor.c */ |
diff --git a/src/plugins/old/convert_numeric.c b/src/plugins/old/convert_numeric.c index b345014..35bd65a 100644 --- a/src/plugins/old/convert_numeric.c +++ b/src/plugins/old/convert_numeric.c | |||
@@ -61,45 +61,44 @@ static unsigned long get_field (const unsigned char *, | |||
61 | unsigned int, | 61 | unsigned int, |
62 | unsigned int, | 62 | unsigned int, |
63 | unsigned int); | 63 | unsigned int); |
64 | |||
64 | static int floatformat_always_valid (const struct EXTRACTOR_floatformat *fmt, | 65 | static int floatformat_always_valid (const struct EXTRACTOR_floatformat *fmt, |
65 | const void *from); | 66 | const void *from); |
66 | 67 | ||
67 | static int | 68 | static int |
68 | floatformat_always_valid (const struct EXTRACTOR_floatformat *fmt /*ATTRIBUTE_UNUSED*/, | 69 | floatformat_always_valid (const struct |
70 | EXTRACTOR_floatformat *fmt /*ATTRIBUTE_UNUSED*/, | ||
69 | const void *from /*ATTRIBUTE_UNUSED*/) | 71 | const void *from /*ATTRIBUTE_UNUSED*/) |
70 | { | 72 | { |
71 | return 1; | 73 | return 1; |
72 | } | 74 | } |
73 | 75 | ||
76 | |||
74 | /* The odds that CHAR_BIT will be anything but 8 are low enough that I'm not | 77 | /* The odds that CHAR_BIT will be anything but 8 are low enough that I'm not |
75 | going to bother with trying to muck around with whether it is defined in | 78 | going to bother with trying to muck around with whether it is defined in |
76 | a system header, what we do if not, etc. */ | 79 | a system header, what we do if not, etc. */ |
77 | #define FLOATFORMAT_CHAR_BIT 8 | 80 | #define FLOATFORMAT_CHAR_BIT 8 |
78 | 81 | ||
79 | /* floatformats for IEEE single and double, big and little endian. */ | 82 | /* floatformats for IEEE single and double, big and little endian. */ |
80 | const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ieee_single_big = | 83 | const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ieee_single_big = { |
81 | { | ||
82 | floatformat_big, 32, 0, 1, 8, 127, 255, 9, 23, | 84 | floatformat_big, 32, 0, 1, 8, 127, 255, 9, 23, |
83 | floatformat_intbit_no, | 85 | floatformat_intbit_no, |
84 | "floatformat_ieee_single_big", | 86 | "floatformat_ieee_single_big", |
85 | floatformat_always_valid | 87 | floatformat_always_valid |
86 | }; | 88 | }; |
87 | const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ieee_single_little = | 89 | const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ieee_single_little = { |
88 | { | ||
89 | floatformat_little, 32, 0, 1, 8, 127, 255, 9, 23, | 90 | floatformat_little, 32, 0, 1, 8, 127, 255, 9, 23, |
90 | floatformat_intbit_no, | 91 | floatformat_intbit_no, |
91 | "floatformat_ieee_single_little", | 92 | "floatformat_ieee_single_little", |
92 | floatformat_always_valid | 93 | floatformat_always_valid |
93 | }; | 94 | }; |
94 | const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ieee_double_big = | 95 | const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ieee_double_big = { |
95 | { | ||
96 | floatformat_big, 64, 0, 1, 11, 1023, 2047, 12, 52, | 96 | floatformat_big, 64, 0, 1, 11, 1023, 2047, 12, 52, |
97 | floatformat_intbit_no, | 97 | floatformat_intbit_no, |
98 | "floatformat_ieee_double_big", | 98 | "floatformat_ieee_double_big", |
99 | floatformat_always_valid | 99 | floatformat_always_valid |
100 | }; | 100 | }; |
101 | const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ieee_double_little = | 101 | const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ieee_double_little = { |
102 | { | ||
103 | floatformat_little, 64, 0, 1, 11, 1023, 2047, 12, 52, | 102 | floatformat_little, 64, 0, 1, 11, 1023, 2047, 12, 52, |
104 | floatformat_intbit_no, | 103 | floatformat_intbit_no, |
105 | "floatformat_ieee_double_little", | 104 | "floatformat_ieee_double_little", |
@@ -109,8 +108,8 @@ const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ieee_double_little = | |||
109 | /* floatformat for IEEE double, little endian byte order, with big endian word | 108 | /* floatformat for IEEE double, little endian byte order, with big endian word |
110 | ordering, as on the ARM. */ | 109 | ordering, as on the ARM. */ |
111 | 110 | ||
112 | const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ieee_double_littlebyte_bigword = | 111 | const struct EXTRACTOR_floatformat |
113 | { | 112 | EXTRACTOR_floatformat_ieee_double_littlebyte_bigword = { |
114 | floatformat_littlebyte_bigword, 64, 0, 1, 11, 1023, 2047, 12, 52, | 113 | floatformat_littlebyte_bigword, 64, 0, 1, 11, 1023, 2047, 12, 52, |
115 | floatformat_intbit_no, | 114 | floatformat_intbit_no, |
116 | "floatformat_ieee_double_littlebyte_bigword", | 115 | "floatformat_ieee_double_littlebyte_bigword", |
@@ -119,33 +118,32 @@ const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ieee_double_littlebyte_ | |||
119 | 118 | ||
120 | /* floatformat for VAX. Not quite IEEE, but close enough. */ | 119 | /* floatformat for VAX. Not quite IEEE, but close enough. */ |
121 | 120 | ||
122 | const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_vax_f = | 121 | const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_vax_f = { |
123 | { | ||
124 | floatformat_vax, 32, 0, 1, 8, 129, 0, 9, 23, | 122 | floatformat_vax, 32, 0, 1, 8, 129, 0, 9, 23, |
125 | floatformat_intbit_no, | 123 | floatformat_intbit_no, |
126 | "floatformat_vax_f", | 124 | "floatformat_vax_f", |
127 | floatformat_always_valid | 125 | floatformat_always_valid |
128 | }; | 126 | }; |
129 | const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_vax_d = | 127 | const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_vax_d = { |
130 | { | ||
131 | floatformat_vax, 64, 0, 1, 8, 129, 0, 9, 55, | 128 | floatformat_vax, 64, 0, 1, 8, 129, 0, 9, 55, |
132 | floatformat_intbit_no, | 129 | floatformat_intbit_no, |
133 | "floatformat_vax_d", | 130 | "floatformat_vax_d", |
134 | floatformat_always_valid | 131 | floatformat_always_valid |
135 | }; | 132 | }; |
136 | const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_vax_g = | 133 | const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_vax_g = { |
137 | { | ||
138 | floatformat_vax, 64, 0, 1, 11, 1025, 0, 12, 52, | 134 | floatformat_vax, 64, 0, 1, 11, 1025, 0, 12, 52, |
139 | floatformat_intbit_no, | 135 | floatformat_intbit_no, |
140 | "floatformat_vax_g", | 136 | "floatformat_vax_g", |
141 | floatformat_always_valid | 137 | floatformat_always_valid |
142 | }; | 138 | }; |
143 | 139 | ||
144 | static int floatformat_i387_ext_is_valid (const struct EXTRACTOR_floatformat *fmt, | 140 | static int floatformat_i387_ext_is_valid (const struct |
145 | const void *from); | 141 | EXTRACTOR_floatformat *fmt, |
142 | const void *from); | ||
146 | 143 | ||
147 | static int | 144 | static int |
148 | floatformat_i387_ext_is_valid (const struct EXTRACTOR_floatformat *fmt, const void *from) | 145 | floatformat_i387_ext_is_valid (const struct EXTRACTOR_floatformat *fmt, const |
146 | void *from) | ||
149 | { | 147 | { |
150 | /* In the i387 double-extended format, if the exponent is all ones, | 148 | /* In the i387 double-extended format, if the exponent is all ones, |
151 | then the integer bit must be set. If the exponent is neither 0 | 149 | then the integer bit must be set. If the exponent is neither 0 |
@@ -155,9 +153,9 @@ floatformat_i387_ext_is_valid (const struct EXTRACTOR_floatformat *fmt, const vo | |||
155 | const unsigned char *ufrom = (const unsigned char *) from; | 153 | const unsigned char *ufrom = (const unsigned char *) from; |
156 | 154 | ||
157 | exponent = get_field (ufrom, fmt->byteorder, fmt->totalsize, | 155 | exponent = get_field (ufrom, fmt->byteorder, fmt->totalsize, |
158 | fmt->exp_start, fmt->exp_len); | 156 | fmt->exp_start, fmt->exp_len); |
159 | int_bit = get_field (ufrom, fmt->byteorder, fmt->totalsize, | 157 | int_bit = get_field (ufrom, fmt->byteorder, fmt->totalsize, |
160 | fmt->man_start, 1); | 158 | fmt->man_start, 1); |
161 | 159 | ||
162 | if ((exponent == 0) != (int_bit == 0)) | 160 | if ((exponent == 0) != (int_bit == 0)) |
163 | return 0; | 161 | return 0; |
@@ -165,38 +163,34 @@ floatformat_i387_ext_is_valid (const struct EXTRACTOR_floatformat *fmt, const vo | |||
165 | return 1; | 163 | return 1; |
166 | } | 164 | } |
167 | 165 | ||
168 | const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_i387_ext = | 166 | |
169 | { | 167 | const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_i387_ext = { |
170 | floatformat_little, 80, 0, 1, 15, 0x3fff, 0x7fff, 16, 64, | 168 | floatformat_little, 80, 0, 1, 15, 0x3fff, 0x7fff, 16, 64, |
171 | floatformat_intbit_yes, | 169 | floatformat_intbit_yes, |
172 | "floatformat_i387_ext", | 170 | "floatformat_i387_ext", |
173 | floatformat_i387_ext_is_valid | 171 | floatformat_i387_ext_is_valid |
174 | }; | 172 | }; |
175 | const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_m68881_ext = | 173 | const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_m68881_ext = { |
176 | { | ||
177 | /* Note that the bits from 16 to 31 are unused. */ | 174 | /* Note that the bits from 16 to 31 are unused. */ |
178 | floatformat_big, 96, 0, 1, 15, 0x3fff, 0x7fff, 32, 64, | 175 | floatformat_big, 96, 0, 1, 15, 0x3fff, 0x7fff, 32, 64, |
179 | floatformat_intbit_yes, | 176 | floatformat_intbit_yes, |
180 | "floatformat_m68881_ext", | 177 | "floatformat_m68881_ext", |
181 | floatformat_always_valid | 178 | floatformat_always_valid |
182 | }; | 179 | }; |
183 | const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_i960_ext = | 180 | const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_i960_ext = { |
184 | { | ||
185 | /* Note that the bits from 0 to 15 are unused. */ | 181 | /* Note that the bits from 0 to 15 are unused. */ |
186 | floatformat_little, 96, 16, 17, 15, 0x3fff, 0x7fff, 32, 64, | 182 | floatformat_little, 96, 16, 17, 15, 0x3fff, 0x7fff, 32, 64, |
187 | floatformat_intbit_yes, | 183 | floatformat_intbit_yes, |
188 | "floatformat_i960_ext", | 184 | "floatformat_i960_ext", |
189 | floatformat_always_valid | 185 | floatformat_always_valid |
190 | }; | 186 | }; |
191 | const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_m88110_ext = | 187 | const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_m88110_ext = { |
192 | { | ||
193 | floatformat_big, 80, 0, 1, 15, 0x3fff, 0x7fff, 16, 64, | 188 | floatformat_big, 80, 0, 1, 15, 0x3fff, 0x7fff, 16, 64, |
194 | floatformat_intbit_yes, | 189 | floatformat_intbit_yes, |
195 | "floatformat_m88110_ext", | 190 | "floatformat_m88110_ext", |
196 | floatformat_always_valid | 191 | floatformat_always_valid |
197 | }; | 192 | }; |
198 | const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_m88110_harris_ext = | 193 | const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_m88110_harris_ext = { |
199 | { | ||
200 | /* Harris uses raw format 128 bytes long, but the number is just an ieee | 194 | /* Harris uses raw format 128 bytes long, but the number is just an ieee |
201 | double, and the last 64 bits are wasted. */ | 195 | double, and the last 64 bits are wasted. */ |
202 | floatformat_big,128, 0, 1, 11, 0x3ff, 0x7ff, 12, 52, | 196 | floatformat_big,128, 0, 1, 11, 0x3ff, 0x7ff, 12, 52, |
@@ -204,45 +198,40 @@ const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_m88110_harris_ext = | |||
204 | "floatformat_m88110_ext_harris", | 198 | "floatformat_m88110_ext_harris", |
205 | floatformat_always_valid | 199 | floatformat_always_valid |
206 | }; | 200 | }; |
207 | const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_arm_ext_big = | 201 | const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_arm_ext_big = { |
208 | { | ||
209 | /* Bits 1 to 16 are unused. */ | 202 | /* Bits 1 to 16 are unused. */ |
210 | floatformat_big, 96, 0, 17, 15, 0x3fff, 0x7fff, 32, 64, | 203 | floatformat_big, 96, 0, 17, 15, 0x3fff, 0x7fff, 32, 64, |
211 | floatformat_intbit_yes, | 204 | floatformat_intbit_yes, |
212 | "floatformat_arm_ext_big", | 205 | "floatformat_arm_ext_big", |
213 | floatformat_always_valid | 206 | floatformat_always_valid |
214 | }; | 207 | }; |
215 | const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_arm_ext_littlebyte_bigword = | 208 | const struct EXTRACTOR_floatformat |
216 | { | 209 | EXTRACTOR_floatformat_arm_ext_littlebyte_bigword = { |
217 | /* Bits 1 to 16 are unused. */ | 210 | /* Bits 1 to 16 are unused. */ |
218 | floatformat_littlebyte_bigword, 96, 0, 17, 15, 0x3fff, 0x7fff, 32, 64, | 211 | floatformat_littlebyte_bigword, 96, 0, 17, 15, 0x3fff, 0x7fff, 32, 64, |
219 | floatformat_intbit_yes, | 212 | floatformat_intbit_yes, |
220 | "floatformat_arm_ext_littlebyte_bigword", | 213 | "floatformat_arm_ext_littlebyte_bigword", |
221 | floatformat_always_valid | 214 | floatformat_always_valid |
222 | }; | 215 | }; |
223 | const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ia64_spill_big = | 216 | const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ia64_spill_big = { |
224 | { | ||
225 | floatformat_big, 128, 0, 1, 17, 65535, 0x1ffff, 18, 64, | 217 | floatformat_big, 128, 0, 1, 17, 65535, 0x1ffff, 18, 64, |
226 | floatformat_intbit_yes, | 218 | floatformat_intbit_yes, |
227 | "floatformat_ia64_spill_big", | 219 | "floatformat_ia64_spill_big", |
228 | floatformat_always_valid | 220 | floatformat_always_valid |
229 | }; | 221 | }; |
230 | const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ia64_spill_little = | 222 | const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ia64_spill_little = { |
231 | { | ||
232 | floatformat_little, 128, 0, 1, 17, 65535, 0x1ffff, 18, 64, | 223 | floatformat_little, 128, 0, 1, 17, 65535, 0x1ffff, 18, 64, |
233 | floatformat_intbit_yes, | 224 | floatformat_intbit_yes, |
234 | "floatformat_ia64_spill_little", | 225 | "floatformat_ia64_spill_little", |
235 | floatformat_always_valid | 226 | floatformat_always_valid |
236 | }; | 227 | }; |
237 | const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ia64_quad_big = | 228 | const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ia64_quad_big = { |
238 | { | ||
239 | floatformat_big, 128, 0, 1, 15, 16383, 0x7fff, 16, 112, | 229 | floatformat_big, 128, 0, 1, 15, 16383, 0x7fff, 16, 112, |
240 | floatformat_intbit_no, | 230 | floatformat_intbit_no, |
241 | "floatformat_ia64_quad_big", | 231 | "floatformat_ia64_quad_big", |
242 | floatformat_always_valid | 232 | floatformat_always_valid |
243 | }; | 233 | }; |
244 | const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ia64_quad_little = | 234 | const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ia64_quad_little = { |
245 | { | ||
246 | floatformat_little, 128, 0, 1, 15, 16383, 0x7fff, 16, 112, | 235 | floatformat_little, 128, 0, 1, 15, 16383, 0x7fff, 16, 112, |
247 | floatformat_intbit_no, | 236 | floatformat_intbit_no, |
248 | "floatformat_ia64_quad_little", | 237 | "floatformat_ia64_quad_little", |
@@ -257,7 +246,8 @@ const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ia64_quad_little = | |||
257 | /* Extract a field which starts at START and is LEN bits long. DATA and | 246 | /* Extract a field which starts at START and is LEN bits long. DATA and |
258 | TOTAL_LEN are the thing we are extracting it from, in byteorder ORDER. */ | 247 | TOTAL_LEN are the thing we are extracting it from, in byteorder ORDER. */ |
259 | static unsigned long | 248 | static unsigned long |
260 | get_field (const unsigned char *data, enum EXTRACTOR_floatformat_byteorders order, | 249 | get_field (const unsigned char *data, enum EXTRACTOR_floatformat_byteorders |
250 | order, | ||
261 | unsigned int total_len, unsigned int start, unsigned int len) | 251 | unsigned int total_len, unsigned int start, unsigned int len) |
262 | { | 252 | { |
263 | unsigned long result = 0; | 253 | unsigned long result = 0; |
@@ -278,29 +268,30 @@ get_field (const unsigned char *data, enum EXTRACTOR_floatformat_byteorders orde | |||
278 | hi_bit = min (lo_bit + len, FLOATFORMAT_CHAR_BIT); | 268 | hi_bit = min (lo_bit + len, FLOATFORMAT_CHAR_BIT); |
279 | 269 | ||
280 | do | 270 | do |
281 | { | 271 | { |
282 | unsigned int shifted = *(data + cur_byte) >> lo_bit; | 272 | unsigned int shifted = *(data + cur_byte) >> lo_bit; |
283 | unsigned int bits = hi_bit - lo_bit; | 273 | unsigned int bits = hi_bit - lo_bit; |
284 | unsigned int mask = (1 << bits) - 1; | 274 | unsigned int mask = (1 << bits) - 1; |
285 | result |= (shifted & mask) << cur_bitshift; | 275 | result |= (shifted & mask) << cur_bitshift; |
286 | len -= bits; | 276 | len -= bits; |
287 | cur_bitshift += bits; | 277 | cur_bitshift += bits; |
288 | cur_byte += nextbyte; | 278 | cur_byte += nextbyte; |
289 | lo_bit = 0; | 279 | lo_bit = 0; |
290 | hi_bit = min (len, FLOATFORMAT_CHAR_BIT); | 280 | hi_bit = min (len, FLOATFORMAT_CHAR_BIT); |
291 | } | 281 | } |
292 | while (len != 0); | 282 | while (len != 0); |
293 | 283 | ||
294 | return result; | 284 | return result; |
295 | } | 285 | } |
296 | 286 | ||
287 | |||
297 | /* Convert from FMT to a double. | 288 | /* Convert from FMT to a double. |
298 | FROM is the address of the extended float. | 289 | FROM is the address of the extended float. |
299 | Store the double in *TO. */ | 290 | Store the double in *TO. */ |
300 | 291 | ||
301 | void | 292 | void |
302 | EXTRACTOR_common_floatformat_to_double (const struct EXTRACTOR_floatformat *fmt, | 293 | EXTRACTOR_common_floatformat_to_double (const struct EXTRACTOR_floatformat *fmt, |
303 | const void *from, double *to) | 294 | const void *from, double *to) |
304 | { | 295 | { |
305 | const unsigned char *ufrom = (const unsigned char *) from; | 296 | const unsigned char *ufrom = (const unsigned char *) from; |
306 | double dto; | 297 | double dto; |
@@ -308,65 +299,65 @@ EXTRACTOR_common_floatformat_to_double (const struct EXTRACTOR_floatformat *fmt, | |||
308 | unsigned long mant; | 299 | unsigned long mant; |
309 | unsigned int mant_bits, mant_off; | 300 | unsigned int mant_bits, mant_off; |
310 | int mant_bits_left; | 301 | int mant_bits_left; |
311 | int special_exponent; /* It's a NaN, denorm or zero */ | 302 | int special_exponent; /* It's a NaN, denorm or zero */ |
312 | 303 | ||
313 | exponent = get_field (ufrom, fmt->byteorder, fmt->totalsize, | 304 | exponent = get_field (ufrom, fmt->byteorder, fmt->totalsize, |
314 | fmt->exp_start, fmt->exp_len); | 305 | fmt->exp_start, fmt->exp_len); |
315 | 306 | ||
316 | /* If the exponent indicates a NaN, we don't have information to | 307 | /* If the exponent indicates a NaN, we don't have information to |
317 | decide what to do. So we handle it like IEEE, except that we | 308 | decide what to do. So we handle it like IEEE, except that we |
318 | don't try to preserve the type of NaN. FIXME. */ | 309 | don't try to preserve the type of NaN. FIXME. */ |
319 | if ((unsigned long) exponent == fmt->exp_nan) | 310 | if ((unsigned long) exponent == fmt->exp_nan) |
311 | { | ||
312 | int nan; | ||
313 | |||
314 | mant_off = fmt->man_start; | ||
315 | mant_bits_left = fmt->man_len; | ||
316 | nan = 0; | ||
317 | while (mant_bits_left > 0) | ||
320 | { | 318 | { |
321 | int nan; | 319 | mant_bits = min (mant_bits_left, 32); |
322 | 320 | ||
323 | mant_off = fmt->man_start; | 321 | if (get_field (ufrom, fmt->byteorder, fmt->totalsize, |
324 | mant_bits_left = fmt->man_len; | 322 | mant_off, mant_bits) != 0) |
325 | nan = 0; | 323 | { |
326 | while (mant_bits_left > 0) | 324 | /* This is a NaN. */ |
327 | { | 325 | nan = 1; |
328 | mant_bits = min (mant_bits_left, 32); | 326 | break; |
329 | 327 | } | |
330 | if (get_field (ufrom, fmt->byteorder, fmt->totalsize, | 328 | |
331 | mant_off, mant_bits) != 0) | 329 | mant_off += mant_bits; |
332 | { | 330 | mant_bits_left -= mant_bits; |
333 | /* This is a NaN. */ | ||
334 | nan = 1; | ||
335 | break; | ||
336 | } | ||
337 | |||
338 | mant_off += mant_bits; | ||
339 | mant_bits_left -= mant_bits; | ||
340 | } | ||
341 | |||
342 | /* On certain systems (such as GNU/Linux), the use of the | ||
343 | INFINITY macro below may generate a warning that can not be | ||
344 | silenced due to a bug in GCC (PR preprocessor/11931). The | ||
345 | preprocessor fails to recognise the __extension__ keyword in | ||
346 | conjunction with the GNU/C99 extension for hexadecimal | ||
347 | floating point constants and will issue a warning when | ||
348 | compiling with -pedantic. */ | ||
349 | if (nan) | ||
350 | dto = NAN; | ||
351 | else | ||
352 | dto = INFINITY; | ||
353 | |||
354 | if (get_field (ufrom, fmt->byteorder, fmt->totalsize, fmt->sign_start, 1)) | ||
355 | dto = -dto; | ||
356 | |||
357 | *to = dto; | ||
358 | |||
359 | return; | ||
360 | } | 331 | } |
361 | 332 | ||
333 | /* On certain systems (such as GNU/Linux), the use of the | ||
334 | INFINITY macro below may generate a warning that can not be | ||
335 | silenced due to a bug in GCC (PR preprocessor/11931). The | ||
336 | preprocessor fails to recognise the __extension__ keyword in | ||
337 | conjunction with the GNU/C99 extension for hexadecimal | ||
338 | floating point constants and will issue a warning when | ||
339 | compiling with -pedantic. */if (nan) | ||
340 | dto = NAN; | ||
341 | else | ||
342 | dto = INFINITY; | ||
343 | |||
344 | if (get_field (ufrom, fmt->byteorder, fmt->totalsize, fmt->sign_start, 1)) | ||
345 | dto = -dto; | ||
346 | |||
347 | *to = dto; | ||
348 | |||
349 | return; | ||
350 | } | ||
351 | |||
362 | mant_bits_left = fmt->man_len; | 352 | mant_bits_left = fmt->man_len; |
363 | mant_off = fmt->man_start; | 353 | mant_off = fmt->man_start; |
364 | dto = 0.0; | 354 | dto = 0.0; |
365 | 355 | ||
366 | special_exponent = (exponent == 0) || ((unsigned long) exponent == fmt->exp_nan); | 356 | special_exponent = (exponent == 0) || ((unsigned long) exponent == |
357 | fmt->exp_nan); | ||
367 | 358 | ||
368 | /* Don't bias zero's, denorms or NaNs. */ | 359 | /* Don't bias zero's, denorms or NaNs. */ |
369 | if (!special_exponent) | 360 | if (! special_exponent) |
370 | exponent -= fmt->exp_bias; | 361 | exponent -= fmt->exp_bias; |
371 | 362 | ||
372 | /* Build the result algebraically. Might go infinite, underflow, etc; | 363 | /* Build the result algebraically. Might go infinite, underflow, etc; |
@@ -375,36 +366,36 @@ EXTRACTOR_common_floatformat_to_double (const struct EXTRACTOR_floatformat *fmt, | |||
375 | /* If this format uses a hidden bit, explicitly add it in now. Otherwise, | 366 | /* If this format uses a hidden bit, explicitly add it in now. Otherwise, |
376 | increment the exponent by one to account for the integer bit. */ | 367 | increment the exponent by one to account for the integer bit. */ |
377 | 368 | ||
378 | if (!special_exponent) | 369 | if (! special_exponent) |
379 | { | 370 | { |
380 | if (fmt->intbit == floatformat_intbit_no) | 371 | if (fmt->intbit == floatformat_intbit_no) |
381 | dto = ldexp (1.0, exponent); | 372 | dto = ldexp (1.0, exponent); |
382 | else | 373 | else |
383 | exponent++; | 374 | exponent++; |
384 | } | 375 | } |
385 | 376 | ||
386 | while (mant_bits_left > 0) | 377 | while (mant_bits_left > 0) |
387 | { | 378 | { |
388 | mant_bits = min (mant_bits_left, 32); | 379 | mant_bits = min (mant_bits_left, 32); |
389 | 380 | ||
390 | mant = get_field (ufrom, fmt->byteorder, fmt->totalsize, | 381 | mant = get_field (ufrom, fmt->byteorder, fmt->totalsize, |
391 | mant_off, mant_bits); | 382 | mant_off, mant_bits); |
392 | 383 | ||
393 | /* Handle denormalized numbers. FIXME: What should we do for | 384 | /* Handle denormalized numbers. FIXME: What should we do for |
394 | non-IEEE formats? */ | 385 | non-IEEE formats? */ |
395 | if (special_exponent && exponent == 0 && mant != 0) | 386 | if (special_exponent && (exponent == 0) && (mant != 0) ) |
396 | dto += ldexp ((double)mant, | 387 | dto += ldexp ((double) mant, |
397 | (- fmt->exp_bias | 388 | (-fmt->exp_bias |
398 | - mant_bits | 389 | - mant_bits |
399 | - (mant_off - fmt->man_start) | 390 | - (mant_off - fmt->man_start) |
400 | + 1)); | 391 | + 1)); |
401 | else | 392 | else |
402 | dto += ldexp ((double)mant, exponent - mant_bits); | 393 | dto += ldexp ((double) mant, exponent - mant_bits); |
403 | if (exponent != 0) | 394 | if (exponent != 0) |
404 | exponent -= mant_bits; | 395 | exponent -= mant_bits; |
405 | mant_off += mant_bits; | 396 | mant_off += mant_bits; |
406 | mant_bits_left -= mant_bits; | 397 | mant_bits_left -= mant_bits; |
407 | } | 398 | } |
408 | 399 | ||
409 | /* Negate it if negative. */ | 400 | /* Negate it if negative. */ |
410 | if (get_field (ufrom, fmt->byteorder, fmt->totalsize, fmt->sign_start, 1)) | 401 | if (get_field (ufrom, fmt->byteorder, fmt->totalsize, fmt->sign_start, 1)) |
@@ -412,6 +403,7 @@ EXTRACTOR_common_floatformat_to_double (const struct EXTRACTOR_floatformat *fmt, | |||
412 | *to = dto; | 403 | *to = dto; |
413 | } | 404 | } |
414 | 405 | ||
406 | |||
415 | static void put_field (unsigned char *, enum EXTRACTOR_floatformat_byteorders, | 407 | static void put_field (unsigned char *, enum EXTRACTOR_floatformat_byteorders, |
416 | unsigned int, | 408 | unsigned int, |
417 | unsigned int, | 409 | unsigned int, |
@@ -442,27 +434,29 @@ put_field (unsigned char *data, enum EXTRACTOR_floatformat_byteorders order, | |||
442 | hi_bit = min (lo_bit + len, FLOATFORMAT_CHAR_BIT); | 434 | hi_bit = min (lo_bit + len, FLOATFORMAT_CHAR_BIT); |
443 | 435 | ||
444 | do | 436 | do |
445 | { | 437 | { |
446 | unsigned char *byte_ptr = data + cur_byte; | 438 | unsigned char *byte_ptr = data + cur_byte; |
447 | unsigned int bits = hi_bit - lo_bit; | 439 | unsigned int bits = hi_bit - lo_bit; |
448 | unsigned int mask = ((1 << bits) - 1) << lo_bit; | 440 | unsigned int mask = ((1 << bits) - 1) << lo_bit; |
449 | *byte_ptr = (*byte_ptr & ~mask) | ((stuff_to_put << lo_bit) & mask); | 441 | *byte_ptr = (*byte_ptr & ~mask) | ((stuff_to_put << lo_bit) & mask); |
450 | stuff_to_put >>= bits; | 442 | stuff_to_put >>= bits; |
451 | len -= bits; | 443 | len -= bits; |
452 | cur_byte += nextbyte; | 444 | cur_byte += nextbyte; |
453 | lo_bit = 0; | 445 | lo_bit = 0; |
454 | hi_bit = min (len, FLOATFORMAT_CHAR_BIT); | 446 | hi_bit = min (len, FLOATFORMAT_CHAR_BIT); |
455 | } | 447 | } |
456 | while (len != 0); | 448 | while (len != 0); |
457 | } | 449 | } |
458 | 450 | ||
451 | |||
459 | /* The converse: convert the double *FROM to an extended float | 452 | /* The converse: convert the double *FROM to an extended float |
460 | and store where TO points. Neither FROM nor TO have any alignment | 453 | and store where TO points. Neither FROM nor TO have any alignment |
461 | restrictions. */ | 454 | restrictions. */ |
462 | 455 | ||
463 | void | 456 | void |
464 | EXTRACTOR_common_floatformat_from_double (const struct EXTRACTOR_floatformat *fmt, | 457 | EXTRACTOR_common_floatformat_from_double (const struct |
465 | const double *from, void *to) | 458 | EXTRACTOR_floatformat *fmt, |
459 | const double *from, void *to) | ||
466 | { | 460 | { |
467 | double dfrom; | 461 | double dfrom; |
468 | int exponent; | 462 | int exponent; |
@@ -476,88 +470,90 @@ EXTRACTOR_common_floatformat_from_double (const struct EXTRACTOR_floatformat *fm | |||
476 | 470 | ||
477 | /* If negative, set the sign bit. */ | 471 | /* If negative, set the sign bit. */ |
478 | if (dfrom < 0) | 472 | if (dfrom < 0) |
479 | { | 473 | { |
480 | put_field (uto, fmt->byteorder, fmt->totalsize, fmt->sign_start, 1, 1); | 474 | put_field (uto, fmt->byteorder, fmt->totalsize, fmt->sign_start, 1, 1); |
481 | dfrom = -dfrom; | 475 | dfrom = -dfrom; |
482 | } | 476 | } |
483 | 477 | ||
484 | if (dfrom == 0) | 478 | if (dfrom == 0) |
485 | { | 479 | { |
486 | /* 0.0. */ | 480 | /* 0.0. */ |
487 | return; | 481 | return; |
488 | } | 482 | } |
489 | 483 | ||
490 | if (dfrom != dfrom) | 484 | if (dfrom != dfrom) |
491 | { | 485 | { |
492 | /* NaN. */ | 486 | /* NaN. */ |
493 | put_field (uto, fmt->byteorder, fmt->totalsize, fmt->exp_start, | 487 | put_field (uto, fmt->byteorder, fmt->totalsize, fmt->exp_start, |
494 | fmt->exp_len, fmt->exp_nan); | 488 | fmt->exp_len, fmt->exp_nan); |
495 | /* Be sure it's not infinity, but NaN value is irrelevant. */ | 489 | /* Be sure it's not infinity, but NaN value is irrelevant. */ |
496 | put_field (uto, fmt->byteorder, fmt->totalsize, fmt->man_start, | 490 | put_field (uto, fmt->byteorder, fmt->totalsize, fmt->man_start, |
497 | 32, 1); | 491 | 32, 1); |
498 | return; | 492 | return; |
499 | } | 493 | } |
500 | 494 | ||
501 | if (dfrom + dfrom == dfrom) | 495 | if (dfrom + dfrom == dfrom) |
502 | { | 496 | { |
503 | /* This can only happen for an infinite value (or zero, which we | 497 | /* This can only happen for an infinite value (or zero, which we |
504 | already handled above). */ | 498 | already handled above). */ |
505 | put_field (uto, fmt->byteorder, fmt->totalsize, fmt->exp_start, | 499 | put_field (uto, fmt->byteorder, fmt->totalsize, fmt->exp_start, |
506 | fmt->exp_len, fmt->exp_nan); | 500 | fmt->exp_len, fmt->exp_nan); |
507 | return; | 501 | return; |
508 | } | 502 | } |
509 | 503 | ||
510 | mant = frexp (dfrom, &exponent); | 504 | mant = frexp (dfrom, &exponent); |
511 | if (exponent + fmt->exp_bias - 1 > 0) | 505 | if (exponent + fmt->exp_bias - 1 > 0) |
512 | put_field (uto, fmt->byteorder, fmt->totalsize, fmt->exp_start, | 506 | put_field (uto, fmt->byteorder, fmt->totalsize, fmt->exp_start, |
513 | fmt->exp_len, exponent + fmt->exp_bias - 1); | 507 | fmt->exp_len, exponent + fmt->exp_bias - 1); |
514 | else | 508 | else |
515 | { | 509 | { |
516 | /* Handle a denormalized number. FIXME: What should we do for | 510 | /* Handle a denormalized number. FIXME: What should we do for |
517 | non-IEEE formats? */ | 511 | non-IEEE formats? */ |
518 | put_field (uto, fmt->byteorder, fmt->totalsize, fmt->exp_start, | 512 | put_field (uto, fmt->byteorder, fmt->totalsize, fmt->exp_start, |
519 | fmt->exp_len, 0); | 513 | fmt->exp_len, 0); |
520 | mant = ldexp (mant, exponent + fmt->exp_bias - 1); | 514 | mant = ldexp (mant, exponent + fmt->exp_bias - 1); |
521 | } | 515 | } |
522 | 516 | ||
523 | mant_bits_left = fmt->man_len; | 517 | mant_bits_left = fmt->man_len; |
524 | mant_off = fmt->man_start; | 518 | mant_off = fmt->man_start; |
525 | while (mant_bits_left > 0) | 519 | while (mant_bits_left > 0) |
520 | { | ||
521 | unsigned long mant_long; | ||
522 | mant_bits = mant_bits_left < 32 ? mant_bits_left : 32; | ||
523 | |||
524 | mant *= 4294967296.0; | ||
525 | mant_long = (unsigned long) mant; | ||
526 | mant -= mant_long; | ||
527 | |||
528 | /* If the integer bit is implicit, and we are not creating a | ||
529 | denormalized number, then we need to discard it. */ | ||
530 | if (( (unsigned int) mant_bits_left == fmt->man_len) | ||
531 | && (fmt->intbit == floatformat_intbit_no) | ||
532 | && (exponent + fmt->exp_bias - 1 > 0) ) | ||
526 | { | 533 | { |
527 | unsigned long mant_long; | 534 | mant_long &= 0x7fffffff; |
528 | mant_bits = mant_bits_left < 32 ? mant_bits_left : 32; | 535 | mant_bits -= 1; |
529 | |||
530 | mant *= 4294967296.0; | ||
531 | mant_long = (unsigned long)mant; | ||
532 | mant -= mant_long; | ||
533 | |||
534 | /* If the integer bit is implicit, and we are not creating a | ||
535 | denormalized number, then we need to discard it. */ | ||
536 | if ((unsigned int) mant_bits_left == fmt->man_len | ||
537 | && fmt->intbit == floatformat_intbit_no | ||
538 | && exponent + fmt->exp_bias - 1 > 0) | ||
539 | { | ||
540 | mant_long &= 0x7fffffff; | ||
541 | mant_bits -= 1; | ||
542 | } | ||
543 | else if (mant_bits < 32) | ||
544 | { | ||
545 | /* The bits we want are in the most significant MANT_BITS bits of | ||
546 | mant_long. Move them to the least significant. */ | ||
547 | mant_long >>= 32 - mant_bits; | ||
548 | } | ||
549 | |||
550 | put_field (uto, fmt->byteorder, fmt->totalsize, | ||
551 | mant_off, mant_bits, mant_long); | ||
552 | mant_off += mant_bits; | ||
553 | mant_bits_left -= mant_bits; | ||
554 | } | 536 | } |
537 | else if (mant_bits < 32) | ||
538 | { | ||
539 | /* The bits we want are in the most significant MANT_BITS bits of | ||
540 | mant_long. Move them to the least significant. */ | ||
541 | mant_long >>= 32 - mant_bits; | ||
542 | } | ||
543 | |||
544 | put_field (uto, fmt->byteorder, fmt->totalsize, | ||
545 | mant_off, mant_bits, mant_long); | ||
546 | mant_off += mant_bits; | ||
547 | mant_bits_left -= mant_bits; | ||
548 | } | ||
555 | } | 549 | } |
556 | 550 | ||
551 | |||
557 | /* Return non-zero iff the data at FROM is a valid number in format FMT. */ | 552 | /* Return non-zero iff the data at FROM is a valid number in format FMT. */ |
558 | 553 | ||
559 | int | 554 | int |
560 | EXTRACTOR_common_floatformat_is_valid (const struct EXTRACTOR_floatformat *fmt, const void *from) | 555 | EXTRACTOR_common_floatformat_is_valid (const struct EXTRACTOR_floatformat *fmt, |
556 | const void *from) | ||
561 | { | 557 | { |
562 | return fmt->is_valid (fmt, from); | 558 | return fmt->is_valid (fmt, from); |
563 | } | 559 | } |
@@ -575,15 +571,15 @@ ieee_test (double n) | |||
575 | double result; | 571 | double result; |
576 | 572 | ||
577 | floatformat_to_double (&floatformat_ieee_double_little, &n, &result); | 573 | floatformat_to_double (&floatformat_ieee_double_little, &n, &result); |
578 | if ((n != result && (! isnan (n) || ! isnan (result))) | 574 | if (((n != result) && (! isnan (n) || ! isnan (result))) |
579 | || (n < 0 && result >= 0) | 575 | || ((n < 0) && (result >= 0)) |
580 | || (n >= 0 && result < 0)) | 576 | || ((n >= 0) && (result < 0))) |
581 | printf ("Differ(to): %.20g -> %.20g\n", n, result); | 577 | printf ("Differ(to): %.20g -> %.20g\n", n, result); |
582 | 578 | ||
583 | floatformat_from_double (&floatformat_ieee_double_little, &n, &result); | 579 | floatformat_from_double (&floatformat_ieee_double_little, &n, &result); |
584 | if ((n != result && (! isnan (n) || ! isnan (result))) | 580 | if (((n != result) && (! isnan (n) || ! isnan (result))) |
585 | || (n < 0 && result >= 0) | 581 | || ((n < 0) && (result >= 0)) |
586 | || (n >= 0 && result < 0)) | 582 | || ((n >= 0) && (result < 0))) |
587 | printf ("Differ(from): %.20g -> %.20g\n", n, result); | 583 | printf ("Differ(from): %.20g -> %.20g\n", n, result); |
588 | 584 | ||
589 | #if 0 | 585 | #if 0 |
@@ -600,13 +596,14 @@ ieee_test (double n) | |||
600 | #if IEEE_DEBUG > 1 | 596 | #if IEEE_DEBUG > 1 |
601 | /* This is to be run on a host which uses 68881 format. */ | 597 | /* This is to be run on a host which uses 68881 format. */ |
602 | { | 598 | { |
603 | long double ex = *(long double *)exten; | 599 | long double ex = *(long double *) exten; |
604 | if (ex != n) | 600 | if (ex != n) |
605 | printf ("Differ(from vs. extended): %.20g\n", n); | 601 | printf ("Differ(from vs. extended): %.20g\n", n); |
606 | } | 602 | } |
607 | #endif | 603 | #endif |
608 | } | 604 | } |
609 | 605 | ||
606 | |||
610 | int | 607 | int |
611 | main (void) | 608 | main (void) |
612 | { | 609 | { |
@@ -620,12 +617,14 @@ main (void) | |||
620 | ieee_test (1.2E-70); | 617 | ieee_test (1.2E-70); |
621 | ieee_test (1.2E-316); | 618 | ieee_test (1.2E-316); |
622 | ieee_test (4.9406564584124654E-324); | 619 | ieee_test (4.9406564584124654E-324); |
623 | ieee_test (- 4.9406564584124654E-324); | 620 | ieee_test (-4.9406564584124654E-324); |
624 | ieee_test (- 0.0); | 621 | ieee_test (-0.0); |
625 | ieee_test (- INFINITY); | 622 | ieee_test (-INFINITY); |
626 | ieee_test (- NAN); | 623 | ieee_test (-NAN); |
627 | ieee_test (INFINITY); | 624 | ieee_test (INFINITY); |
628 | ieee_test (NAN); | 625 | ieee_test (NAN); |
629 | return 0; | 626 | return 0; |
630 | } | 627 | } |
628 | |||
629 | |||
631 | #endif | 630 | #endif |
diff --git a/src/plugins/old/convert_numeric.h b/src/plugins/old/convert_numeric.h index cc425f5..f3adead 100644 --- a/src/plugins/old/convert_numeric.h +++ b/src/plugins/old/convert_numeric.h | |||
@@ -18,7 +18,7 @@ You should have received a copy of the GNU General Public License | |||
18 | along with this program; if not, write to the Free Software | 18 | along with this program; if not, write to the Free Software |
19 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ | 19 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ |
20 | 20 | ||
21 | #if !defined (FLOATFORMAT_H) | 21 | #if ! defined (FLOATFORMAT_H) |
22 | #define FLOATFORMAT_H 1 | 22 | #define FLOATFORMAT_H 1 |
23 | 23 | ||
24 | /*#include "ansidecl.h"*/ | 24 | /*#include "ansidecl.h"*/ |
@@ -31,7 +31,8 @@ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. | |||
31 | 31 | ||
32 | /* What is the order of the bytes? */ | 32 | /* What is the order of the bytes? */ |
33 | 33 | ||
34 | enum EXTRACTOR_floatformat_byteorders { | 34 | enum EXTRACTOR_floatformat_byteorders |
35 | { | ||
35 | /* Standard little endian byte order. | 36 | /* Standard little endian byte order. |
36 | EX: 1.2345678e10 => 00 00 80 c5 e0 fe 06 42 */ | 37 | EX: 1.2345678e10 => 00 00 80 c5 e0 fe 06 42 */ |
37 | floatformat_little, | 38 | floatformat_little, |
@@ -51,12 +52,13 @@ enum EXTRACTOR_floatformat_byteorders { | |||
51 | floatformat_vax | 52 | floatformat_vax |
52 | }; | 53 | }; |
53 | 54 | ||
54 | enum EXTRACTOR_floatformat_intbit { floatformat_intbit_yes, floatformat_intbit_no }; | 55 | enum EXTRACTOR_floatformat_intbit { floatformat_intbit_yes, |
56 | floatformat_intbit_no }; | ||
55 | 57 | ||
56 | struct EXTRACTOR_floatformat | 58 | struct EXTRACTOR_floatformat |
57 | { | 59 | { |
58 | enum EXTRACTOR_floatformat_byteorders byteorder; | 60 | enum EXTRACTOR_floatformat_byteorders byteorder; |
59 | unsigned int totalsize; /* Total size of number in bits */ | 61 | unsigned int totalsize; /* Total size of number in bits */ |
60 | 62 | ||
61 | /* Sign bit is always one bit long. 1 means negative, 0 means positive. */ | 63 | /* Sign bit is always one bit long. 1 means negative, 0 means positive. */ |
62 | unsigned int sign_start; | 64 | unsigned int sign_start; |
@@ -90,13 +92,16 @@ struct EXTRACTOR_floatformat | |||
90 | /* floatformats for IEEE single and double, big and little endian. */ | 92 | /* floatformats for IEEE single and double, big and little endian. */ |
91 | 93 | ||
92 | extern const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ieee_single_big; | 94 | extern const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ieee_single_big; |
93 | extern const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ieee_single_little; | 95 | extern const struct EXTRACTOR_floatformat |
96 | EXTRACTOR_floatformat_ieee_single_little; | ||
94 | extern const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ieee_double_big; | 97 | extern const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ieee_double_big; |
95 | extern const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ieee_double_little; | 98 | extern const struct EXTRACTOR_floatformat |
99 | EXTRACTOR_floatformat_ieee_double_little; | ||
96 | 100 | ||
97 | /* floatformat for ARM IEEE double, little endian bytes and big endian words */ | 101 | /* floatformat for ARM IEEE double, little endian bytes and big endian words */ |
98 | 102 | ||
99 | extern const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ieee_double_littlebyte_bigword; | 103 | extern const struct EXTRACTOR_floatformat |
104 | EXTRACTOR_floatformat_ieee_double_littlebyte_bigword; | ||
100 | 105 | ||
101 | /* floatformats for VAX. */ | 106 | /* floatformats for VAX. */ |
102 | 107 | ||
@@ -110,31 +115,38 @@ extern const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_i387_ext; | |||
110 | extern const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_m68881_ext; | 115 | extern const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_m68881_ext; |
111 | extern const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_i960_ext; | 116 | extern const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_i960_ext; |
112 | extern const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_m88110_ext; | 117 | extern const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_m88110_ext; |
113 | extern const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_m88110_harris_ext; | 118 | extern const struct EXTRACTOR_floatformat |
119 | EXTRACTOR_floatformat_m88110_harris_ext; | ||
114 | extern const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_arm_ext_big; | 120 | extern const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_arm_ext_big; |
115 | extern const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_arm_ext_littlebyte_bigword; | 121 | extern const struct EXTRACTOR_floatformat |
122 | EXTRACTOR_floatformat_arm_ext_littlebyte_bigword; | ||
116 | /* IA-64 Floating Point register spilt into memory. */ | 123 | /* IA-64 Floating Point register spilt into memory. */ |
117 | extern const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ia64_spill_big; | 124 | extern const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ia64_spill_big; |
118 | extern const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ia64_spill_little; | 125 | extern const struct EXTRACTOR_floatformat |
126 | EXTRACTOR_floatformat_ia64_spill_little; | ||
119 | extern const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ia64_quad_big; | 127 | extern const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ia64_quad_big; |
120 | extern const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ia64_quad_little; | 128 | extern const struct EXTRACTOR_floatformat |
129 | EXTRACTOR_floatformat_ia64_quad_little; | ||
121 | 130 | ||
122 | /* Convert from FMT to a double. | 131 | /* Convert from FMT to a double. |
123 | FROM is the address of the extended float. | 132 | FROM is the address of the extended float. |
124 | Store the double in *TO. */ | 133 | Store the double in *TO. */ |
125 | 134 | ||
126 | extern void | 135 | extern void |
127 | EXTRACTOR_common_floatformat_to_double (const struct EXTRACTOR_floatformat *, const void *, double *); | 136 | EXTRACTOR_common_floatformat_to_double (const struct EXTRACTOR_floatformat *, |
137 | const void *, double *); | ||
128 | 138 | ||
129 | /* The converse: convert the double *FROM to FMT | 139 | /* The converse: convert the double *FROM to FMT |
130 | and store where TO points. */ | 140 | and store where TO points. */ |
131 | 141 | ||
132 | extern void | 142 | extern void |
133 | EXTRACTOR_common_floatformat_from_double (const struct EXTRACTOR_floatformat *, const double *, void *); | 143 | EXTRACTOR_common_floatformat_from_double (const struct EXTRACTOR_floatformat *, |
144 | const double *, void *); | ||
134 | 145 | ||
135 | /* Return non-zero iff the data at FROM is a valid number in format FMT. */ | 146 | /* Return non-zero iff the data at FROM is a valid number in format FMT. */ |
136 | 147 | ||
137 | extern int | 148 | extern int |
138 | EXTRACTOR_common_floatformat_is_valid (const struct EXTRACTOR_floatformat *fmt, const void *from); | 149 | EXTRACTOR_common_floatformat_is_valid (const struct EXTRACTOR_floatformat *fmt, |
150 | const void *from); | ||
139 | 151 | ||
140 | #endif /* defined (FLOATFORMAT_H) */ | 152 | #endif /* defined (FLOATFORMAT_H) */ |
diff --git a/src/plugins/old/ebml_extractor.c b/src/plugins/old/ebml_extractor.c index 2d52d90..f7daa9a 100644 --- a/src/plugins/old/ebml_extractor.c +++ b/src/plugins/old/ebml_extractor.c | |||
@@ -18,11 +18,11 @@ | |||
18 | Boston, MA 02110-1301, USA. | 18 | Boston, MA 02110-1301, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /* | 21 | /* |
22 | * Made by Gabriel Peixoto | 22 | * Made by Gabriel Peixoto |
23 | * Using AVInfo 1.x code. Copyright (c) 2004 George Shuklin. | 23 | * Using AVInfo 1.x code. Copyright (c) 2004 George Shuklin. |
24 | * Nearly complete rewrite by LRN, Copyright (c) 2012 | 24 | * Nearly complete rewrite by LRN, Copyright (c) 2012 |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include "platform.h" | 27 | #include "platform.h" |
28 | #include "extractor.h" | 28 | #include "extractor.h" |
@@ -44,20 +44,25 @@ | |||
44 | struct tm * | 44 | struct tm * |
45 | gmtime_undocumented_64_r (const __time64_t *timer, struct tm *result) | 45 | gmtime_undocumented_64_r (const __time64_t *timer, struct tm *result) |
46 | { | 46 | { |
47 | struct tm *local_result = NULL;//_gmtime64 (timer); | 47 | struct tm *local_result = NULL; // _gmtime64 (timer); |
48 | 48 | ||
49 | if (local_result == NULL || result == NULL) | 49 | if ((local_result == NULL) || (result == NULL) ) |
50 | return NULL; | 50 | return NULL; |
51 | 51 | ||
52 | memcpy (result, local_result, sizeof (*result)); | 52 | memcpy (result, local_result, sizeof (*result)); |
53 | return result; | 53 | return result; |
54 | } | 54 | } |
55 | |||
56 | |||
55 | #endif | 57 | #endif |
56 | 58 | ||
57 | #include "extractor_plugins.h" | 59 | #include "extractor_plugins.h" |
58 | 60 | ||
59 | #define ADD_EBML(s,t) do { proc (proc_cls, "ebml", t, EXTRACTOR_METAFORMAT_UTF8, "text/plain", s, strlen(s)+1); } while (0) | 61 | #define ADD_EBML(s,t) do { proc (proc_cls, "ebml", t, EXTRACTOR_METAFORMAT_UTF8, \ |
60 | #define ADD_MATROSKA(s,t) do { proc (proc_cls, "matroska", t, EXTRACTOR_METAFORMAT_UTF8, "text/plain", s, strlen(s)+1); } while (0) | 62 | "text/plain", s, strlen (s) + 1); } while (0) |
63 | #define ADD_MATROSKA(s,t) do { proc (proc_cls, "matroska", t, \ | ||
64 | EXTRACTOR_METAFORMAT_UTF8, "text/plain", s, \ | ||
65 | strlen (s) + 1); } while (0) | ||
61 | 66 | ||
62 | /** | 67 | /** |
63 | * String length limit. The spec does not limit the strings, | 68 | * String length limit. The spec does not limit the strings, |
@@ -162,9 +167,9 @@ struct MatroskaTagMap tag_map[] = { | |||
162 | {"KEYWORDS", EXTRACTOR_METATYPE_KEYWORDS}, | 167 | {"KEYWORDS", EXTRACTOR_METATYPE_KEYWORDS}, |
163 | {"SUMMARY", EXTRACTOR_METATYPE_SUMMARY}, | 168 | {"SUMMARY", EXTRACTOR_METATYPE_SUMMARY}, |
164 | /* | 169 | /* |
165 | SYNOPSIS UTF-8 A description of the story line of the item. | 170 | SYNOPSIS UTF-8 A description of the story line of the item. |
166 | INITIAL_KEY UTF-8 The initial key that a musical track starts in. The format is identical to ID3. | 171 | INITIAL_KEY UTF-8 The initial key that a musical track starts in. The format is identical to ID3. |
167 | PERIOD UTF-8 Describes the period that the piece is from or about. For example, "Renaissance". | 172 | PERIOD UTF-8 Describes the period that the piece is from or about. For example, "Renaissance". |
168 | LAW_RATING UTF-8 Depending on the country it's the format of the rating of a movie (P, R, X in the USA, an age in other countries or a URI defining a logo). | 173 | LAW_RATING UTF-8 Depending on the country it's the format of the rating of a movie (P, R, X in the USA, an age in other countries or a URI defining a logo). |
169 | ICRA binary The ICRA content rating for parental control. (Previously RSACi) | 174 | ICRA binary The ICRA content rating for parental control. (Previously RSACi) |
170 | */ | 175 | */ |
@@ -176,7 +181,7 @@ struct MatroskaTagMap tag_map[] = { | |||
176 | {"DATE_WRITTEN", EXTRACTOR_METATYPE_UNKNOWN_DATE}, | 181 | {"DATE_WRITTEN", EXTRACTOR_METATYPE_UNKNOWN_DATE}, |
177 | {"DATE_PURCHASED", EXTRACTOR_METATYPE_UNKNOWN_DATE}, | 182 | {"DATE_PURCHASED", EXTRACTOR_METATYPE_UNKNOWN_DATE}, |
178 | /* | 183 | /* |
179 | RECORDING_LOCATION UTF-8 The location where the item was recorded. The countries corresponding to the string, same 2 octets as in Internet domains, or possibly ISO-3166. This code is followed by a comma, then more detailed information such as state/province, another comma, and then city. For example, "US, Texas, Austin". This will allow for easy sorting. It is okay to only store the country, or the country and the state/province. More detailed information can be added after the city through the use of additional commas. In cases where the province/state is unknown, but you want to store the city, simply leave a space between the two commas. For example, "US, , Austin". | 184 | RECORDING_LOCATION UTF-8 The location where the item was recorded. The countries corresponding to the string, same 2 octets as in Internet domains, or possibly ISO-3166. This code is followed by a comma, then more detailed information such as state/province, another comma, and then city. For example, "US, Texas, Austin". This will allow for easy sorting. It is okay to only store the country, or the country and the state/province. More detailed information can be added after the city through the use of additional commas. In cases where the province/state is unknown, but you want to store the city, simply leave a space between the two commas. For example, "US, , Austin". |
180 | COMPOSITION_LOCATION UTF-8 Location that the item was originaly designed/written. The countries corresponding to the string, same 2 octets as in Internet domains, or possibly ISO-3166. This code is followed by a comma, then more detailed information such as state/province, another comma, and then city. For example, "US, Texas, Austin". This will allow for easy sorting. It is okay to only store the country, or the country and the state/province. More detailed information can be added after the city through the use of additional commas. In cases where the province/state is unknown, but you want to store the city, simply leave a space between the two commas. For example, "US, , Austin". | 185 | COMPOSITION_LOCATION UTF-8 Location that the item was originaly designed/written. The countries corresponding to the string, same 2 octets as in Internet domains, or possibly ISO-3166. This code is followed by a comma, then more detailed information such as state/province, another comma, and then city. For example, "US, Texas, Austin". This will allow for easy sorting. It is okay to only store the country, or the country and the state/province. More detailed information can be added after the city through the use of additional commas. In cases where the province/state is unknown, but you want to store the city, simply leave a space between the two commas. For example, "US, , Austin". |
181 | COMPOSER_NATIONALITY UTF-8 Nationality of the main composer of the item, mostly for classical music. The countries corresponding to the string, same 2 octets as in Internet domains, or possibly ISO-3166. | 186 | COMPOSER_NATIONALITY UTF-8 Nationality of the main composer of the item, mostly for classical music. The countries corresponding to the string, same 2 octets as in Internet domains, or possibly ISO-3166. |
182 | */ | 187 | */ |
@@ -188,7 +193,7 @@ struct MatroskaTagMap tag_map[] = { | |||
188 | ENCODER UTF-8 The software or hardware used to encode this item. ("LAME" or "XviD") | 193 | ENCODER UTF-8 The software or hardware used to encode this item. ("LAME" or "XviD") |
189 | ENCODER_SETTINGS UTF-8 A list of the settings used for encoding this item. No specific format. | 194 | ENCODER_SETTINGS UTF-8 A list of the settings used for encoding this item. No specific format. |
190 | BPS UTF-8 The average bits per second of the specified item. This is only the data in the Blocks, and excludes headers and any container overhead. | 195 | BPS UTF-8 The average bits per second of the specified item. This is only the data in the Blocks, and excludes headers and any container overhead. |
191 | FPS UTF-8 The average frames per second of the specified item. This is typically the average number of Blocks per second. In the event that lacing is used, each laced chunk is to be counted as a seperate frame. | 196 | FPS UTF-8 The average frames per second of the specified item. This is typically the average number of Blocks per second. In the event that lacing is used, each laced chunk is to be counted as a seperate frame. |
192 | */ | 197 | */ |
193 | {"BPM", EXTRACTOR_METATYPE_BEATS_PER_MINUTE}, | 198 | {"BPM", EXTRACTOR_METATYPE_BEATS_PER_MINUTE}, |
194 | /* | 199 | /* |
@@ -201,7 +206,7 @@ struct MatroskaTagMap tag_map[] = { | |||
201 | /* | 206 | /* |
202 | MCDI binary This is a binary dump of the TOC of the CDROM that this item was taken from. This holds the same information as the MCDI in ID3. | 207 | MCDI binary This is a binary dump of the TOC of the CDROM that this item was taken from. This holds the same information as the MCDI in ID3. |
203 | ISBN UTF-8 International Standard Book Number | 208 | ISBN UTF-8 International Standard Book Number |
204 | BARCODE UTF-8 EAN-13 (European Article Numbering) or UPC-A (Universal Product Code) bar code identifier | 209 | BARCODE UTF-8 EAN-13 (European Article Numbering) or UPC-A (Universal Product Code) bar code identifier |
205 | CATALOG_NUMBER UTF-8 A label-specific string used to identify the release (TIC 01 for example). | 210 | CATALOG_NUMBER UTF-8 A label-specific string used to identify the release (TIC 01 for example). |
206 | LABEL_CODE UTF-8 A 4-digit or 5-digit number to identify the record label, typically printed as (LC) xxxx or (LC) 0xxxx on CDs medias or covers (only the number is stored). | 211 | LABEL_CODE UTF-8 A 4-digit or 5-digit number to identify the record label, typically printed as (LC) xxxx or (LC) 0xxxx on CDs medias or covers (only the number is stored). |
207 | LCCN UTF-8 Library of Congress Control Number | 212 | LCCN UTF-8 Library of Congress Control Number |
@@ -281,7 +286,6 @@ enum | |||
281 | MatroskaID_Tracks_Audio_BitDepth = 0x6264, /* not 0, UINT. Bits per sample, mostly used for PCM. */ | 286 | MatroskaID_Tracks_Audio_BitDepth = 0x6264, /* not 0, UINT. Bits per sample, mostly used for PCM. */ |
282 | 287 | ||
283 | 288 | ||
284 | |||
285 | MatroskaID_Tags = 0x1254C367, /* can appear more than once. Element containing elements specific to Tracks/Chapters. A list of valid tags can be found here. */ | 289 | MatroskaID_Tags = 0x1254C367, /* can appear more than once. Element containing elements specific to Tracks/Chapters. A list of valid tags can be found here. */ |
286 | MatroskaID_Tags_Tag = 0x7373, /* mandatory, can appear more than once. Element containing elements specific to Tracks/Chapters. */ | 290 | MatroskaID_Tags_Tag = 0x7373, /* mandatory, can appear more than once. Element containing elements specific to Tracks/Chapters. */ |
287 | MatroskaID_Tags_Tag_SimpleTag = 0x67C8, /* mandatory, can appear more than once, recursive. Contains general information about the target. */ | 291 | MatroskaID_Tags_Tag_SimpleTag = 0x67C8, /* mandatory, can appear more than once, recursive. Contains general information about the target. */ |
@@ -315,12 +319,14 @@ enum VINTParseMode | |||
315 | */ | 319 | */ |
316 | static ssize_t | 320 | static ssize_t |
317 | VINTparse (struct EXTRACTOR_PluginList *plugin, | 321 | VINTparse (struct EXTRACTOR_PluginList *plugin, |
318 | int64_t * result, enum VINTParseMode mode) | 322 | int64_t *result, enum VINTParseMode mode) |
319 | { | 323 | { |
320 | /* 10000000 01000000 00100000 00010000 00001000 00000100 00000010 00000001 */ | 324 | /* 10000000 01000000 00100000 00010000 00001000 00000100 00000010 00000001 */ |
321 | static const unsigned char mask[8] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 }; | 325 | static const unsigned char mask[8] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, |
326 | 0x02, 0x01 }; | ||
322 | /* 01111111 00111111 00011111 00001111 00000111 00000011 00000001 00000000 */ | 327 | /* 01111111 00111111 00011111 00001111 00000111 00000011 00000001 00000000 */ |
323 | static const unsigned char imask[8] = { 0x7F, 0x3F, 0x1F, 0x0F, 0x07, 0x03, 0x01, 0x00 }; | 328 | static const unsigned char imask[8] = { 0x7F, 0x3F, 0x1F, 0x0F, 0x07, 0x03, |
329 | 0x01, 0x00 }; | ||
324 | static const int64_t int_negative_limits[8] = { | 330 | static const int64_t int_negative_limits[8] = { |
325 | -0x00000000000040LL, /* 7-bit integer */ | 331 | -0x00000000000040LL, /* 7-bit integer */ |
326 | -0x00000000002000LL, /* 14-bit integer */ | 332 | -0x00000000002000LL, /* 14-bit integer */ |
@@ -374,13 +380,11 @@ VINTparse (struct EXTRACTOR_PluginList *plugin, | |||
374 | * 1-byte integer has 2^7 different values, | 380 | * 1-byte integer has 2^7 different values, |
375 | * 2-byte integer has 2^14 different values, | 381 | * 2-byte integer has 2^14 different values, |
376 | * etc | 382 | * etc |
377 | */ | 383 | *//* |
378 | /* | ||
379 | * Examine the first byte and see how many 0-bytes are at its beginning. | 384 | * Examine the first byte and see how many 0-bytes are at its beginning. |
380 | */ | 385 | */vint_width = 0; |
381 | vint_width = 0; | ||
382 | for (c = 0; c < 8; c++) | 386 | for (c = 0; c < 8; c++) |
383 | if (!(first_byte & mask[c])) | 387 | if (! (first_byte & mask[c])) |
384 | vint_width++; | 388 | vint_width++; |
385 | else | 389 | else |
386 | break; | 390 | break; |
@@ -403,7 +407,7 @@ VINTparse (struct EXTRACTOR_PluginList *plugin, | |||
403 | * 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | 407 | * 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
404 | * 4-bit signed integer: | 408 | * 4-bit signed integer: |
405 | * 0 1 2 3 4 5 6 7 -8 -7 -6 -5 -4 -3 -2 -1 | 409 | * 0 1 2 3 4 5 6 7 -8 -7 -6 -5 -4 -3 -2 -1 |
406 | * | 410 | * |
407 | * 3 here is 0011b, and -3 is 1101b | 411 | * 3 here is 0011b, and -3 is 1101b |
408 | * However, writing 1101b into int8_t memory location will NOT make | 412 | * However, writing 1101b into int8_t memory location will NOT make |
409 | * the machine interpret it as -3, it will be interpreted as 00001101b, | 413 | * the machine interpret it as -3, it will be interpreted as 00001101b, |
@@ -427,9 +431,7 @@ VINTparse (struct EXTRACTOR_PluginList *plugin, | |||
427 | * which is outside of the signed integer range (remember, we're in 4-bit space here). | 431 | * which is outside of the signed integer range (remember, we're in 4-bit space here). |
428 | * on the other hand, 5 and -3 both are within the range. | 432 | * on the other hand, 5 and -3 both are within the range. |
429 | * 4) if the number does not exceed the signed integer maximum (7), store it as-is | 433 | * 4) if the number does not exceed the signed integer maximum (7), store it as-is |
430 | */ | 434 | */result_u = 0; |
431 | |||
432 | result_u = 0; | ||
433 | /* Copy the extra bytes into a temporary buffer, in the right order */ | 435 | /* Copy the extra bytes into a temporary buffer, in the right order */ |
434 | for (c = 0; c < vint_width; c++) | 436 | for (c = 0; c < vint_width; c++) |
435 | result_u += ((uint64_t) int_bytes[vint_width - c]) << (c * 8); | 437 | result_u += ((uint64_t) int_bytes[vint_width - c]) << (c * 8); |
@@ -439,7 +441,8 @@ VINTparse (struct EXTRACTOR_PluginList *plugin, | |||
439 | { | 441 | { |
440 | case VINT_READ_UINT: | 442 | case VINT_READ_UINT: |
441 | /* Unset the 1-bit marker */ | 443 | /* Unset the 1-bit marker */ |
442 | result_u += ((uint64_t) int_bytes[0] & imask[vint_width]) << (vint_width * 8); | 444 | result_u += ((uint64_t) int_bytes[0] & imask[vint_width]) << (vint_width |
445 | * 8); | ||
443 | memcpy (result, &result_u, sizeof (uint64_t)); | 446 | memcpy (result, &result_u, sizeof (uint64_t)); |
444 | break; | 447 | break; |
445 | case VINT_READ_ID: | 448 | case VINT_READ_ID: |
@@ -449,7 +452,8 @@ VINTparse (struct EXTRACTOR_PluginList *plugin, | |||
449 | break; | 452 | break; |
450 | case VINT_READ_SIZE: | 453 | case VINT_READ_SIZE: |
451 | /* Unset the 1-bit marker */ | 454 | /* Unset the 1-bit marker */ |
452 | result_u += ((uint64_t) int_bytes[0] & imask[vint_width]) << (vint_width * 8); | 455 | result_u += ((uint64_t) int_bytes[0] & imask[vint_width]) << (vint_width |
456 | * 8); | ||
453 | /* Special case: all-1 size means "size is unknown". We indicate this | 457 | /* Special case: all-1 size means "size is unknown". We indicate this |
454 | * in the return value by setting it to UINT64_MAX. | 458 | * in the return value by setting it to UINT64_MAX. |
455 | */ | 459 | */ |
@@ -459,7 +463,8 @@ VINTparse (struct EXTRACTOR_PluginList *plugin, | |||
459 | break; | 463 | break; |
460 | case VINT_READ_SINT: | 464 | case VINT_READ_SINT: |
461 | /* Unset the 1-bit marker */ | 465 | /* Unset the 1-bit marker */ |
462 | result_u += ((uint64_t) int_bytes[0] & imask[vint_width]) << (vint_width * 8); | 466 | result_u += ((uint64_t) int_bytes[0] & imask[vint_width]) << (vint_width |
467 | * 8); | ||
463 | /* Interpret large values as negative signed values */ | 468 | /* Interpret large values as negative signed values */ |
464 | if (result_u > int_positive_limits[vint_width]) | 469 | if (result_u > int_positive_limits[vint_width]) |
465 | { | 470 | { |
@@ -492,7 +497,7 @@ VINTparse (struct EXTRACTOR_PluginList *plugin, | |||
492 | */ | 497 | */ |
493 | static ssize_t | 498 | static ssize_t |
494 | elementRead (struct EXTRACTOR_PluginList *plugin, | 499 | elementRead (struct EXTRACTOR_PluginList *plugin, |
495 | uint32_t *id, int64_t * size) | 500 | uint32_t *id, int64_t *size) |
496 | { | 501 | { |
497 | int64_t tempID; | 502 | int64_t tempID; |
498 | int64_t tempsize; | 503 | int64_t tempsize; |
@@ -519,6 +524,7 @@ elementRead (struct EXTRACTOR_PluginList *plugin, | |||
519 | return id_offset + size_offset; | 524 | return id_offset + size_offset; |
520 | } | 525 | } |
521 | 526 | ||
527 | |||
522 | static ssize_t | 528 | static ssize_t |
523 | idRead (struct EXTRACTOR_PluginList *plugin, | 529 | idRead (struct EXTRACTOR_PluginList *plugin, |
524 | uint64_t length, uint32_t *id) | 530 | uint64_t length, uint32_t *id) |
@@ -537,8 +543,10 @@ idRead (struct EXTRACTOR_PluginList *plugin, | |||
537 | return id_offset; | 543 | return id_offset; |
538 | } | 544 | } |
539 | 545 | ||
546 | |||
540 | static ssize_t | 547 | static ssize_t |
541 | uintRead (struct EXTRACTOR_PluginList *plugin, uint64_t length, uint64_t *result) | 548 | uintRead (struct EXTRACTOR_PluginList *plugin, uint64_t length, |
549 | uint64_t *result) | ||
542 | { | 550 | { |
543 | size_t c; | 551 | size_t c; |
544 | unsigned char *data; | 552 | unsigned char *data; |
@@ -552,6 +560,7 @@ uintRead (struct EXTRACTOR_PluginList *plugin, uint64_t length, uint64_t *result | |||
552 | return (ssize_t) length; | 560 | return (ssize_t) length; |
553 | } | 561 | } |
554 | 562 | ||
563 | |||
555 | static ssize_t | 564 | static ssize_t |
556 | sintRead (struct EXTRACTOR_PluginList *plugin, uint64_t length, int64_t *result) | 565 | sintRead (struct EXTRACTOR_PluginList *plugin, uint64_t length, int64_t *result) |
557 | { | 566 | { |
@@ -579,6 +588,7 @@ sintRead (struct EXTRACTOR_PluginList *plugin, uint64_t length, int64_t *result) | |||
579 | return (ssize_t) length; | 588 | return (ssize_t) length; |
580 | } | 589 | } |
581 | 590 | ||
591 | |||
582 | static ssize_t | 592 | static ssize_t |
583 | stringRead (struct EXTRACTOR_PluginList *plugin, uint64_t length, char *result) | 593 | stringRead (struct EXTRACTOR_PluginList *plugin, uint64_t length, char *result) |
584 | { | 594 | { |
@@ -601,8 +611,10 @@ stringRead (struct EXTRACTOR_PluginList *plugin, uint64_t length, char *result) | |||
601 | return 1; | 611 | return 1; |
602 | } | 612 | } |
603 | 613 | ||
614 | |||
604 | static ssize_t | 615 | static ssize_t |
605 | floatRead (struct EXTRACTOR_PluginList *plugin, uint64_t length, long double *result) | 616 | floatRead (struct EXTRACTOR_PluginList *plugin, uint64_t length, long |
617 | double *result) | ||
606 | { | 618 | { |
607 | size_t c; | 619 | size_t c; |
608 | unsigned char t[8]; | 620 | unsigned char t[8]; |
@@ -612,7 +624,7 @@ floatRead (struct EXTRACTOR_PluginList *plugin, uint64_t length, long double *re | |||
612 | return -1; | 624 | return -1; |
613 | 625 | ||
614 | /* we don't support 10-byte floats, because not all C compilers will guarantee that long double is stored in 10 bytes in a IEEE-conformant format */ | 626 | /* we don't support 10-byte floats, because not all C compilers will guarantee that long double is stored in 10 bytes in a IEEE-conformant format */ |
615 | if (length != 4 && length != 8 /* && length != 10 */) | 627 | if ((length != 4) && (length != 8) /* && length != 10 */) |
616 | return 0; | 628 | return 0; |
617 | 629 | ||
618 | for (c = 0; c < length; c++) | 630 | for (c = 0; c < length; c++) |
@@ -624,14 +636,15 @@ floatRead (struct EXTRACTOR_PluginList *plugin, uint64_t length, long double *re | |||
624 | #endif | 636 | #endif |
625 | } | 637 | } |
626 | if (length == 4) | 638 | if (length == 4) |
627 | *result = * ((float *) t); | 639 | *result = *((float *) t); |
628 | else if (length == 8) | 640 | else if (length == 8) |
629 | *result = * ((double *) t); | 641 | *result = *((double *) t); |
630 | else | 642 | else |
631 | *result = * ((long double *) t); | 643 | *result = *((long double *) t); |
632 | return (ssize_t) length; | 644 | return (ssize_t) length; |
633 | } | 645 | } |
634 | 646 | ||
647 | |||
635 | static const char stream_type_letters[] = "?vat"; /*[0]-no, [1]-video,[2]-audio,[3]-text */ | 648 | static const char stream_type_letters[] = "?vat"; /*[0]-no, [1]-video,[2]-audio,[3]-text */ |
636 | 649 | ||
637 | enum EBMLState | 650 | enum EBMLState |
@@ -791,6 +804,7 @@ clean_ebml_state_ebml (struct ebml_state *state) | |||
791 | state->doctype_read_version = 0; | 804 | state->doctype_read_version = 0; |
792 | } | 805 | } |
793 | 806 | ||
807 | |||
794 | static void | 808 | static void |
795 | clean_ebml_state_matroska_simpletags (struct ebml_state *state) | 809 | clean_ebml_state_matroska_simpletags (struct ebml_state *state) |
796 | { | 810 | { |
@@ -809,7 +823,7 @@ clean_ebml_state_matroska_simpletags (struct ebml_state *state) | |||
809 | if (el->string != NULL) | 823 | if (el->string != NULL) |
810 | free (el->string); | 824 | free (el->string); |
811 | free (el); | 825 | free (el); |
812 | if (parent != NULL && parent->child == el) | 826 | if ((parent != NULL) && (parent->child == el)) |
813 | parent->child = next; | 827 | parent->child = next; |
814 | el = next; | 828 | el = next; |
815 | if (next == NULL) | 829 | if (next == NULL) |
@@ -820,8 +834,10 @@ clean_ebml_state_matroska_simpletags (struct ebml_state *state) | |||
820 | state->tag_current = NULL; | 834 | state->tag_current = NULL; |
821 | } | 835 | } |
822 | 836 | ||
837 | |||
823 | void | 838 | void |
824 | matroska_add_tag (struct ebml_state *state, struct matroska_simpletag *parent, char *name, char *string) | 839 | matroska_add_tag (struct ebml_state *state, struct matroska_simpletag *parent, |
840 | char *name, char *string) | ||
825 | { | 841 | { |
826 | struct matroska_simpletag *el = malloc (sizeof (struct matroska_simpletag)); | 842 | struct matroska_simpletag *el = malloc (sizeof (struct matroska_simpletag)); |
827 | el->parent = parent; | 843 | el->parent = parent; |
@@ -839,6 +855,7 @@ matroska_add_tag (struct ebml_state *state, struct matroska_simpletag *parent, c | |||
839 | state->tag_last = el; | 855 | state->tag_last = el; |
840 | } | 856 | } |
841 | 857 | ||
858 | |||
842 | static void | 859 | static void |
843 | clean_ebml_state_matroska_seeks (struct ebml_state *state) | 860 | clean_ebml_state_matroska_seeks (struct ebml_state *state) |
844 | { | 861 | { |
@@ -852,6 +869,7 @@ clean_ebml_state_matroska_seeks (struct ebml_state *state) | |||
852 | state->matroska_seeks_tail = NULL; | 869 | state->matroska_seeks_tail = NULL; |
853 | } | 870 | } |
854 | 871 | ||
872 | |||
855 | static void | 873 | static void |
856 | clean_ebml_state_matroska_segment (struct ebml_state *state) | 874 | clean_ebml_state_matroska_segment (struct ebml_state *state) |
857 | { | 875 | { |
@@ -862,6 +880,7 @@ clean_ebml_state_matroska_segment (struct ebml_state *state) | |||
862 | clean_ebml_state_matroska_simpletags (state); | 880 | clean_ebml_state_matroska_simpletags (state); |
863 | } | 881 | } |
864 | 882 | ||
883 | |||
865 | static void | 884 | static void |
866 | clean_ebml_state_matroska_seek (struct ebml_state *state) | 885 | clean_ebml_state_matroska_seek (struct ebml_state *state) |
867 | { | 886 | { |
@@ -869,6 +888,7 @@ clean_ebml_state_matroska_seek (struct ebml_state *state) | |||
869 | state->matroska_seek_position = 0; | 888 | state->matroska_seek_position = 0; |
870 | } | 889 | } |
871 | 890 | ||
891 | |||
872 | static void | 892 | static void |
873 | clean_ebml_state_matroska_info (struct ebml_state *state) | 893 | clean_ebml_state_matroska_info (struct ebml_state *state) |
874 | { | 894 | { |
@@ -889,6 +909,7 @@ clean_ebml_state_matroska_info (struct ebml_state *state) | |||
889 | state->matroska_info_writing_app = NULL; | 909 | state->matroska_info_writing_app = NULL; |
890 | } | 910 | } |
891 | 911 | ||
912 | |||
892 | static void | 913 | static void |
893 | clean_ebml_state_matroska_track_video (struct ebml_state *state) | 914 | clean_ebml_state_matroska_track_video (struct ebml_state *state) |
894 | { | 915 | { |
@@ -902,6 +923,7 @@ clean_ebml_state_matroska_track_video (struct ebml_state *state) | |||
902 | state->matroska_track_video_display_unit = 0; | 923 | state->matroska_track_video_display_unit = 0; |
903 | } | 924 | } |
904 | 925 | ||
926 | |||
905 | static void | 927 | static void |
906 | clean_ebml_state_matroska_track_audio (struct ebml_state *state) | 928 | clean_ebml_state_matroska_track_audio (struct ebml_state *state) |
907 | { | 929 | { |
@@ -912,6 +934,7 @@ clean_ebml_state_matroska_track_audio (struct ebml_state *state) | |||
912 | state->matroska_track_audio_bit_depth = 0; | 934 | state->matroska_track_audio_bit_depth = 0; |
913 | } | 935 | } |
914 | 936 | ||
937 | |||
915 | static void | 938 | static void |
916 | clean_ebml_state_matroska_track (struct ebml_state *state) | 939 | clean_ebml_state_matroska_track (struct ebml_state *state) |
917 | { | 940 | { |
@@ -935,6 +958,7 @@ clean_ebml_state_matroska_track (struct ebml_state *state) | |||
935 | clean_ebml_state_matroska_track_audio (state); | 958 | clean_ebml_state_matroska_track_audio (state); |
936 | } | 959 | } |
937 | 960 | ||
961 | |||
938 | static struct ebml_state * | 962 | static struct ebml_state * |
939 | EXTRACTOR_ebml_init_state_method () | 963 | EXTRACTOR_ebml_init_state_method () |
940 | { | 964 | { |
@@ -952,14 +976,17 @@ EXTRACTOR_ebml_init_state_method () | |||
952 | return state; | 976 | return state; |
953 | } | 977 | } |
954 | 978 | ||
979 | |||
955 | static void | 980 | static void |
956 | report_simpletag (struct ebml_state *state, EXTRACTOR_MetaDataProcessor proc, void *proc_cls) | 981 | report_simpletag (struct ebml_state *state, EXTRACTOR_MetaDataProcessor proc, |
982 | void *proc_cls) | ||
957 | { | 983 | { |
958 | struct matroska_simpletag *el, *next; | 984 | struct matroska_simpletag *el, *next; |
959 | char format[MAX_STRING_SIZE + 1]; | 985 | char format[MAX_STRING_SIZE + 1]; |
960 | for (el = state->tag_tree; el != NULL; el = next) | 986 | for (el = state->tag_tree; el != NULL; el = next) |
961 | { | 987 | { |
962 | if (el->name != NULL && el->name[0] != '\0' && el->string != NULL && el->string[0] != '\0') | 988 | if ((el->name != NULL) && (el->name[0] != '\0') && (el->string != NULL) && |
989 | (el->string[0] != '\0') ) | ||
963 | { | 990 | { |
964 | enum EXTRACTOR_MetaType metatype = EXTRACTOR_METATYPE_RESERVED; | 991 | enum EXTRACTOR_MetaType metatype = EXTRACTOR_METATYPE_RESERVED; |
965 | struct MatroskaTagMap *map_item; | 992 | struct MatroskaTagMap *map_item; |
@@ -975,10 +1002,10 @@ report_simpletag (struct ebml_state *state, EXTRACTOR_MetaDataProcessor proc, vo | |||
975 | { | 1002 | { |
976 | snprintf (format, MAX_STRING_SIZE, "%s=%s", el->name, el->string); | 1003 | snprintf (format, MAX_STRING_SIZE, "%s=%s", el->name, el->string); |
977 | format[MAX_STRING_SIZE] = '\0'; | 1004 | format[MAX_STRING_SIZE] = '\0'; |
978 | ADD_MATROSKA(format, EXTRACTOR_METATYPE_UNKNOWN); | 1005 | ADD_MATROSKA (format, EXTRACTOR_METATYPE_UNKNOWN); |
979 | } | 1006 | } |
980 | else | 1007 | else |
981 | ADD_MATROSKA(el->string, metatype); | 1008 | ADD_MATROSKA (el->string, metatype); |
982 | } | 1009 | } |
983 | next = el->child; | 1010 | next = el->child; |
984 | while (next == NULL && el != NULL) | 1011 | while (next == NULL && el != NULL) |
@@ -991,18 +1018,21 @@ report_simpletag (struct ebml_state *state, EXTRACTOR_MetaDataProcessor proc, vo | |||
991 | clean_ebml_state_matroska_simpletags (state); | 1018 | clean_ebml_state_matroska_simpletags (state); |
992 | } | 1019 | } |
993 | 1020 | ||
1021 | |||
994 | static void | 1022 | static void |
995 | report_state (struct ebml_state *state, EXTRACTOR_MetaDataProcessor proc, void *proc_cls) | 1023 | report_state (struct ebml_state *state, EXTRACTOR_MetaDataProcessor proc, |
1024 | void *proc_cls) | ||
996 | { | 1025 | { |
997 | char format[MAX_STRING_SIZE + 1]; | 1026 | char format[MAX_STRING_SIZE + 1]; |
998 | report_simpletag (state, proc, proc_cls); | 1027 | report_simpletag (state, proc, proc_cls); |
999 | if (state->valid_ebml && !state->reported_ebml) | 1028 | if (state->valid_ebml && ! state->reported_ebml) |
1000 | { | 1029 | { |
1001 | state->reported_ebml = 1; | 1030 | state->reported_ebml = 1; |
1002 | snprintf (format, MAX_STRING_SIZE, "%llu", (unsigned long long) state->ebml_version); | 1031 | snprintf (format, MAX_STRING_SIZE, "%llu", (unsigned long |
1032 | long) state->ebml_version); | ||
1003 | format[MAX_STRING_SIZE] = '\0'; | 1033 | format[MAX_STRING_SIZE] = '\0'; |
1004 | ADD_EBML(format, EXTRACTOR_METATYPE_FORMAT_VERSION); | 1034 | ADD_EBML (format, EXTRACTOR_METATYPE_FORMAT_VERSION); |
1005 | snprintf (format, MAX_STRING_SIZE, "%s %llu (EBML %llu)", state->doctype, | 1035 | snprintf (format, MAX_STRING_SIZE, "%s %llu (EBML %llu)", state->doctype, |
1006 | (unsigned long long) state->doctype_version, | 1036 | (unsigned long long) state->doctype_version, |
1007 | (unsigned long long) state->ebml_version); | 1037 | (unsigned long long) state->ebml_version); |
1008 | format[MAX_STRING_SIZE] = '\0'; | 1038 | format[MAX_STRING_SIZE] = '\0'; |
@@ -1012,21 +1042,25 @@ report_state (struct ebml_state *state, EXTRACTOR_MetaDataProcessor proc, void * | |||
1012 | clean_ebml_state_ebml (state); | 1042 | clean_ebml_state_ebml (state); |
1013 | if (state->valid_matroska_info == -1) | 1043 | if (state->valid_matroska_info == -1) |
1014 | { | 1044 | { |
1015 | if ((state->matroska_info_duration > 0 || state->matroska_info_duration == -1.0) && | 1045 | if (((state->matroska_info_duration > 0) || |
1016 | state->matroska_info_muxing_app != NULL && state->matroska_info_writing_app != NULL) | 1046 | (state->matroska_info_duration == -1.0) ) && |
1047 | (state->matroska_info_muxing_app != NULL) && | ||
1048 | (state->matroska_info_writing_app != NULL) ) | ||
1017 | state->valid_matroska_info = 1; | 1049 | state->valid_matroska_info = 1; |
1018 | else | 1050 | else |
1019 | state->valid_matroska_info = 0; | 1051 | state->valid_matroska_info = 0; |
1020 | } | 1052 | } |
1021 | if (state->valid_matroska_info == 1 && !state->reported_matroska_info) | 1053 | if ((state->valid_matroska_info == 1) && ! state->reported_matroska_info) |
1022 | { | 1054 | { |
1023 | state->reported_matroska_info = 1; | 1055 | state->reported_matroska_info = 1; |
1024 | if (state->matroska_info_duration != -1.0) | 1056 | if (state->matroska_info_duration != -1.0) |
1025 | { | 1057 | { |
1026 | uint64_t seconds = (uint64_t) ((state->matroska_info_duration * (float) state->matroska_info_timecode_scale) / 1e+9); | 1058 | uint64_t seconds = (uint64_t) ((state->matroska_info_duration |
1059 | * (float) state-> | ||
1060 | matroska_info_timecode_scale) / 1e+9); | ||
1027 | snprintf (format, MAX_STRING_SIZE, "%llus", (unsigned long long) seconds); | 1061 | snprintf (format, MAX_STRING_SIZE, "%llus", (unsigned long long) seconds); |
1028 | format[MAX_STRING_SIZE] = '\0'; | 1062 | format[MAX_STRING_SIZE] = '\0'; |
1029 | ADD_MATROSKA(format, EXTRACTOR_METATYPE_DURATION); | 1063 | ADD_MATROSKA (format, EXTRACTOR_METATYPE_DURATION); |
1030 | } | 1064 | } |
1031 | if (state->matroska_info_date_utc_is_set) | 1065 | if (state->matroska_info_date_utc_is_set) |
1032 | { | 1066 | { |
@@ -1052,8 +1086,7 @@ report_state (struct ebml_state *state, EXTRACTOR_MetaDataProcessor proc, void * | |||
1052 | * millenium is known and never changes), but we want to use 64-bit integer to | 1086 | * millenium is known and never changes), but we want to use 64-bit integer to |
1053 | * manipulate time. If it gets trimmed later, when assigning back to a TIME_TYPE | 1087 | * manipulate time. If it gets trimmed later, when assigning back to a TIME_TYPE |
1054 | * that happens to be 32-bit long - well, tough luck. | 1088 | * that happens to be 32-bit long - well, tough luck. |
1055 | */ | 1089 | */errno = 0; |
1056 | errno = 0; | ||
1057 | #if WINDOWS | 1090 | #if WINDOWS |
1058 | millenium_start_stamp = _mktime64 (&millenium_start); | 1091 | millenium_start_stamp = _mktime64 (&millenium_start); |
1059 | #else | 1092 | #else |
@@ -1061,58 +1094,69 @@ report_state (struct ebml_state *state, EXTRACTOR_MetaDataProcessor proc, void * | |||
1061 | #endif | 1094 | #endif |
1062 | if (millenium_start_stamp == -1) | 1095 | if (millenium_start_stamp == -1) |
1063 | printf ("Failed to convert time: %d\n", errno); | 1096 | printf ("Failed to convert time: %d\n", errno); |
1064 | matroska_date_stamp = millenium_start_stamp * 1000000000 + state->matroska_info_date_utc; | 1097 | matroska_date_stamp = millenium_start_stamp * 1000000000 |
1098 | + state->matroska_info_date_utc; | ||
1065 | /* Now matroska_date_stamp is the number of nanoseconds since UNIX Epoch */ | 1099 | /* Now matroska_date_stamp is the number of nanoseconds since UNIX Epoch */ |
1066 | matroska_date_stamp_time_t = matroska_date_stamp / 1000000000; | 1100 | matroska_date_stamp_time_t = matroska_date_stamp / 1000000000; |
1067 | /* Now matroska_date_stamp_time_t is the number of seconds since UNIX Epoch */ | 1101 | /* Now matroska_date_stamp_time_t is the number of seconds since UNIX Epoch */ |
1068 | #if WINDOWS | 1102 | #if WINDOWS |
1069 | if (NULL != gmtime_undocumented_64_r (&matroska_date_stamp_time_t, &matroska_date)) | 1103 | if (NULL != gmtime_undocumented_64_r (&matroska_date_stamp_time_t, |
1104 | &matroska_date)) | ||
1070 | #else | 1105 | #else |
1071 | /* We want to be thread-safe. If you have no gmtime_r(), think of something! */ | 1106 | /* We want to be thread-safe. If you have no gmtime_r(), think of something! */ |
1072 | if (NULL != gmtime_r (&matroska_date_stamp_time_t, &matroska_date)) | 1107 | if (NULL != gmtime_r (&matroska_date_stamp_time_t, &matroska_date)) |
1073 | #endif | 1108 | #endif |
1074 | { | 1109 | { |
1075 | if (0 != strftime (format, MAX_STRING_SIZE, "%Y.%m.%d %H:%M:%S UTC", &matroska_date)) | 1110 | if (0 != strftime (format, MAX_STRING_SIZE, "%Y.%m.%d %H:%M:%S UTC", |
1076 | ADD_MATROSKA(format, EXTRACTOR_METATYPE_CREATION_DATE); | 1111 | &matroska_date)) |
1112 | ADD_MATROSKA (format, EXTRACTOR_METATYPE_CREATION_DATE); | ||
1077 | } | 1113 | } |
1078 | } | 1114 | } |
1079 | if (state->matroska_info_title != NULL) | 1115 | if (state->matroska_info_title != NULL) |
1080 | ADD_MATROSKA(state->matroska_info_title, EXTRACTOR_METATYPE_TITLE); | 1116 | ADD_MATROSKA (state->matroska_info_title, EXTRACTOR_METATYPE_TITLE); |
1081 | if (strcmp (state->matroska_info_writing_app, state->matroska_info_muxing_app) == 0) | 1117 | if (strcmp (state->matroska_info_writing_app, |
1082 | snprintf (format, MAX_STRING_SIZE, "Written and muxed with %s", state->matroska_info_writing_app); | 1118 | state->matroska_info_muxing_app) == 0) |
1119 | snprintf (format, MAX_STRING_SIZE, "Written and muxed with %s", | ||
1120 | state->matroska_info_writing_app); | ||
1083 | else | 1121 | else |
1084 | snprintf (format, MAX_STRING_SIZE, "Written with %s, muxed with %s", state->matroska_info_writing_app, state->matroska_info_muxing_app); | 1122 | snprintf (format, MAX_STRING_SIZE, "Written with %s, muxed with %s", |
1123 | state->matroska_info_writing_app, | ||
1124 | state->matroska_info_muxing_app); | ||
1085 | format[MAX_STRING_SIZE] = '\0'; | 1125 | format[MAX_STRING_SIZE] = '\0'; |
1086 | ADD_MATROSKA(format, EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE); | 1126 | ADD_MATROSKA (format, EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE); |
1087 | } | 1127 | } |
1088 | if (state->valid_matroska_info == 1) | 1128 | if (state->valid_matroska_info == 1) |
1089 | clean_ebml_state_matroska_info (state); | 1129 | clean_ebml_state_matroska_info (state); |
1090 | if (state->valid_matroska_track == -1) | 1130 | if (state->valid_matroska_track == -1) |
1091 | { | 1131 | { |
1092 | if ((state->matroska_track_type > 0 && state->matroska_track_type < 255) && | 1132 | if (((state->matroska_track_type > 0) && (state->matroska_track_type < |
1093 | state->matroska_track_codec_id != NULL) | 1133 | 255) ) && |
1134 | (state->matroska_track_codec_id != NULL) ) | ||
1094 | state->valid_matroska_track = 1; | 1135 | state->valid_matroska_track = 1; |
1095 | else | 1136 | else |
1096 | state->valid_matroska_track = 0; | 1137 | state->valid_matroska_track = 0; |
1097 | } | 1138 | } |
1098 | if (state->valid_matroska_track_video == -1) | 1139 | if (state->valid_matroska_track_video == -1) |
1099 | { | 1140 | { |
1100 | if ((state->matroska_track_video_flag_interlaced == 0 || state->matroska_track_video_flag_interlaced == 1) && | 1141 | if (((state->matroska_track_video_flag_interlaced == 0) || |
1101 | (state->matroska_track_video_stereo_mode >= 0 && state->matroska_track_video_stereo_mode <= 14) && | 1142 | (state->matroska_track_video_flag_interlaced == 1) ) && |
1102 | state->matroska_track_video_pixel_width > 0 && state->matroska_track_video_pixel_height > 0) | 1143 | ((state->matroska_track_video_stereo_mode >= 0) && |
1144 | (state->matroska_track_video_stereo_mode <= 14) ) && | ||
1145 | (state->matroska_track_video_pixel_width > 0) && | ||
1146 | (state->matroska_track_video_pixel_height > 0) ) | ||
1103 | state->valid_matroska_track_video = 1; | 1147 | state->valid_matroska_track_video = 1; |
1104 | else | 1148 | else |
1105 | state->valid_matroska_track_video = 0; | 1149 | state->valid_matroska_track_video = 0; |
1106 | } | 1150 | } |
1107 | if (state->valid_matroska_track_audio == -1) | 1151 | if (state->valid_matroska_track_audio == -1) |
1108 | { | 1152 | { |
1109 | if (state->matroska_track_audio_sampling_frequency > 0 && | 1153 | if ((state->matroska_track_audio_sampling_frequency > 0) && |
1110 | state->matroska_track_audio_channels > 0) | 1154 | (state->matroska_track_audio_channels > 0) ) |
1111 | state->valid_matroska_track_audio = 1; | 1155 | state->valid_matroska_track_audio = 1; |
1112 | else | 1156 | else |
1113 | state->valid_matroska_track_audio = 0; | 1157 | state->valid_matroska_track_audio = 0; |
1114 | } | 1158 | } |
1115 | if (state->valid_matroska_track == 1 && !state->reported_matroska_track) | 1159 | if ((state->valid_matroska_track == 1) && ! state->reported_matroska_track) |
1116 | { | 1160 | { |
1117 | char name_part[MAX_STRING_SIZE + 1]; | 1161 | char name_part[MAX_STRING_SIZE + 1]; |
1118 | char codec_part[MAX_STRING_SIZE + 1]; | 1162 | char codec_part[MAX_STRING_SIZE + 1]; |
@@ -1142,28 +1186,32 @@ report_state (struct ebml_state *state, EXTRACTOR_MetaDataProcessor proc, void * | |||
1142 | if (state->matroska_track_name == NULL) | 1186 | if (state->matroska_track_name == NULL) |
1143 | snprintf (name_part, MAX_STRING_SIZE, "%s", ""); | 1187 | snprintf (name_part, MAX_STRING_SIZE, "%s", ""); |
1144 | else | 1188 | else |
1145 | snprintf (name_part, MAX_STRING_SIZE, "`%s' ", state->matroska_track_name); | 1189 | snprintf (name_part, MAX_STRING_SIZE, "`%s' ", |
1190 | state->matroska_track_name); | ||
1146 | name_part[MAX_STRING_SIZE] = '\0'; | 1191 | name_part[MAX_STRING_SIZE] = '\0'; |
1147 | 1192 | ||
1148 | if (state->matroska_track_codec_name == NULL) | 1193 | if (state->matroska_track_codec_name == NULL) |
1149 | snprintf (codec_part, MAX_STRING_SIZE, "%s", state->matroska_track_codec_id); | 1194 | snprintf (codec_part, MAX_STRING_SIZE, "%s", |
1195 | state->matroska_track_codec_id); | ||
1150 | else | 1196 | else |
1151 | snprintf (codec_part, MAX_STRING_SIZE, "%s [%s]", state->matroska_track_codec_id, state->matroska_track_codec_name); | 1197 | snprintf (codec_part, MAX_STRING_SIZE, "%s [%s]", |
1198 | state->matroska_track_codec_id, | ||
1199 | state->matroska_track_codec_name); | ||
1152 | codec_part[MAX_STRING_SIZE] = '\0'; | 1200 | codec_part[MAX_STRING_SIZE] = '\0'; |
1153 | 1201 | ||
1154 | if (use_video && state->valid_matroska_track_video == 1) | 1202 | if (use_video && (state->valid_matroska_track_video == 1)) |
1155 | { | 1203 | { |
1156 | /* Ignore Display* for now. Aspect ratio correction could be | 1204 | /* Ignore Display* for now. Aspect ratio correction could be |
1157 | * done either way (stretching horizontally or squishing vertically), | 1205 | * done either way (stretching horizontally or squishing vertically), |
1158 | * so let's stick to hard cold pixel counts. | 1206 | * so let's stick to hard cold pixel counts. |
1159 | */ | 1207 | */ |
1160 | snprintf (format, MAX_STRING_SIZE, "%llux%llu", | 1208 | snprintf (format, MAX_STRING_SIZE, "%llux%llu", |
1161 | (unsigned long long) state->matroska_track_video_pixel_width, | 1209 | (unsigned long long) state->matroska_track_video_pixel_width, |
1162 | (unsigned long long) state->matroska_track_video_pixel_height); | 1210 | (unsigned long long) state->matroska_track_video_pixel_height); |
1163 | format[MAX_STRING_SIZE] = '\0'; | 1211 | format[MAX_STRING_SIZE] = '\0'; |
1164 | ADD_MATROSKA (format, EXTRACTOR_METATYPE_IMAGE_DIMENSIONS); | 1212 | ADD_MATROSKA (format, EXTRACTOR_METATYPE_IMAGE_DIMENSIONS); |
1165 | } | 1213 | } |
1166 | if (use_audio && state->valid_matroska_track_audio == 1) | 1214 | if (use_audio && (state->valid_matroska_track_audio == 1)) |
1167 | { | 1215 | { |
1168 | double freq = state->matroska_track_audio_sampling_frequency; | 1216 | double freq = state->matroska_track_audio_sampling_frequency; |
1169 | double rfreq = freq; | 1217 | double rfreq = freq; |
@@ -1176,20 +1224,24 @@ report_state (struct ebml_state *state, EXTRACTOR_MetaDataProcessor proc, void * | |||
1176 | hz_part[MAX_STRING_SIZE] = '\0'; | 1224 | hz_part[MAX_STRING_SIZE] = '\0'; |
1177 | 1225 | ||
1178 | if (state->matroska_track_audio_bit_depth > 0) | 1226 | if (state->matroska_track_audio_bit_depth > 0) |
1179 | snprintf (bit_part, MAX_STRING_SIZE, "%llu-bit ", (unsigned long long) state->matroska_track_audio_bit_depth); | 1227 | snprintf (bit_part, MAX_STRING_SIZE, "%llu-bit ", (unsigned long |
1228 | long) state-> | ||
1229 | matroska_track_audio_bit_depth); | ||
1180 | else | 1230 | else |
1181 | bit_part[0] = '\0'; | 1231 | bit_part[0] = '\0'; |
1182 | bit_part[MAX_STRING_SIZE] = '\0'; | 1232 | bit_part[MAX_STRING_SIZE] = '\0'; |
1183 | 1233 | ||
1184 | snprintf (format, MAX_STRING_SIZE, "%s track %s(%s, %llu-channel %sat %s) [%s]", | 1234 | snprintf (format, MAX_STRING_SIZE, |
1185 | track_type_string, name_part, codec_part, | 1235 | "%s track %s(%s, %llu-channel %sat %s) [%s]", |
1186 | (unsigned long long) state->matroska_track_audio_channels, | 1236 | track_type_string, name_part, codec_part, |
1187 | bit_part, hz_part, state->matroska_track_language); | 1237 | (unsigned long long) state->matroska_track_audio_channels, |
1238 | bit_part, hz_part, state->matroska_track_language); | ||
1188 | } | 1239 | } |
1189 | else | 1240 | else |
1190 | { | 1241 | { |
1191 | snprintf (format, MAX_STRING_SIZE, "%s track %s(%s) [%s]", | 1242 | snprintf (format, MAX_STRING_SIZE, "%s track %s(%s) [%s]", |
1192 | track_type_string, name_part, codec_part, state->matroska_track_language); | 1243 | track_type_string, name_part, codec_part, |
1244 | state->matroska_track_language); | ||
1193 | } | 1245 | } |
1194 | format[MAX_STRING_SIZE] = '\0'; | 1246 | format[MAX_STRING_SIZE] = '\0'; |
1195 | ADD_EBML (format, EXTRACTOR_METATYPE_RESOURCE_TYPE); | 1247 | ADD_EBML (format, EXTRACTOR_METATYPE_RESOURCE_TYPE); |
@@ -1199,7 +1251,7 @@ report_state (struct ebml_state *state, EXTRACTOR_MetaDataProcessor proc, void * | |||
1199 | } | 1251 | } |
1200 | 1252 | ||
1201 | 1253 | ||
1202 | static int | 1254 | static int |
1203 | EXTRACTOR_ebml_discard_state_method (struct ebml_state *state) | 1255 | EXTRACTOR_ebml_discard_state_method (struct ebml_state *state) |
1204 | { | 1256 | { |
1205 | if (state != NULL) | 1257 | if (state != NULL) |
@@ -1214,6 +1266,7 @@ EXTRACTOR_ebml_discard_state_method (struct ebml_state *state) | |||
1214 | return 1; | 1266 | return 1; |
1215 | } | 1267 | } |
1216 | 1268 | ||
1269 | |||
1217 | static struct ebml_element * | 1270 | static struct ebml_element * |
1218 | ebml_stack_pop (struct ebml_state *state) | 1271 | ebml_stack_pop (struct ebml_state *state) |
1219 | { | 1272 | { |
@@ -1227,7 +1280,10 @@ ebml_stack_pop (struct ebml_state *state) | |||
1227 | 1280 | ||
1228 | 1281 | ||
1229 | static void | 1282 | static void |
1230 | ebml_stack_push_new (struct ebml_state *state, uint64_t position, uint32_t id, uint64_t size, uint64_t header_size, int finish_state, int prev_state, int bail_state, int bail_next_state) | 1283 | ebml_stack_push_new (struct ebml_state *state, uint64_t position, uint32_t id, |
1284 | uint64_t size, uint64_t header_size, int finish_state, int | ||
1285 | prev_state, int | ||
1286 | bail_state, int bail_next_state) | ||
1231 | { | 1287 | { |
1232 | struct ebml_element *element = malloc (sizeof (struct ebml_element)); | 1288 | struct ebml_element *element = malloc (sizeof (struct ebml_element)); |
1233 | element->parent = state->stack_top; | 1289 | element->parent = state->stack_top; |
@@ -1242,8 +1298,10 @@ ebml_stack_push_new (struct ebml_state *state, uint64_t position, uint32_t id, u | |||
1242 | element->bail_next_state = bail_next_state; | 1298 | element->bail_next_state = bail_next_state; |
1243 | } | 1299 | } |
1244 | 1300 | ||
1301 | |||
1245 | static int | 1302 | static int |
1246 | check_result (struct EXTRACTOR_PluginList *plugin, ssize_t read_result, struct ebml_state *state) | 1303 | check_result (struct EXTRACTOR_PluginList *plugin, ssize_t read_result, struct |
1304 | ebml_state *state) | ||
1247 | { | 1305 | { |
1248 | if (read_result == 0) | 1306 | if (read_result == 0) |
1249 | { | 1307 | { |
@@ -1256,7 +1314,7 @@ check_result (struct EXTRACTOR_PluginList *plugin, ssize_t read_result, struct e | |||
1256 | return 0; | 1314 | return 0; |
1257 | } | 1315 | } |
1258 | offset = parent->position + parent->header_size + parent->size; | 1316 | offset = parent->position + parent->header_size + parent->size; |
1259 | if (offset < 0 || offset != pl_seek (plugin, offset, SEEK_SET)) | 1317 | if ((offset < 0) || (offset != pl_seek (plugin, offset, SEEK_SET))) |
1260 | { | 1318 | { |
1261 | state->state = EBML_BAD_STATE; | 1319 | state->state = EBML_BAD_STATE; |
1262 | return 0; | 1320 | return 0; |
@@ -1269,12 +1327,16 @@ check_result (struct EXTRACTOR_PluginList *plugin, ssize_t read_result, struct e | |||
1269 | return 1; | 1327 | return 1; |
1270 | } | 1328 | } |
1271 | 1329 | ||
1330 | |||
1272 | static int | 1331 | static int |
1273 | maybe_rise_up (struct EXTRACTOR_PluginList *plugin, struct ebml_state *state, int *do_break, int64_t read_result) | 1332 | maybe_rise_up (struct EXTRACTOR_PluginList *plugin, struct ebml_state *state, |
1333 | int *do_break, int64_t read_result) | ||
1274 | { | 1334 | { |
1275 | int64_t offset; | 1335 | int64_t offset; |
1276 | offset = pl_get_pos (plugin) - read_result; | 1336 | offset = pl_get_pos (plugin) - read_result; |
1277 | if (state->stack_top != NULL && offset >= state->stack_top->position + state->stack_top->header_size + state->stack_top->size) | 1337 | if ((state->stack_top != NULL) && (offset >= state->stack_top->position |
1338 | + state->stack_top->header_size | ||
1339 | + state->stack_top->size) ) | ||
1278 | { | 1340 | { |
1279 | state->state = state->stack_top->finish_state; | 1341 | state->state = state->stack_top->finish_state; |
1280 | pl_seek (plugin, -read_result, SEEK_CUR); | 1342 | pl_seek (plugin, -read_result, SEEK_CUR); |
@@ -1284,24 +1346,29 @@ maybe_rise_up (struct EXTRACTOR_PluginList *plugin, struct ebml_state *state, in | |||
1284 | return 0; | 1346 | return 0; |
1285 | } | 1347 | } |
1286 | 1348 | ||
1349 | |||
1287 | static void | 1350 | static void |
1288 | rise_up_after_value (struct EXTRACTOR_PluginList *plugin, struct ebml_state *state, int next_state) | 1351 | rise_up_after_value (struct EXTRACTOR_PluginList *plugin, struct |
1352 | ebml_state *state, int next_state) | ||
1289 | { | 1353 | { |
1290 | int64_t offset; | 1354 | int64_t offset; |
1291 | state->state = EBML_READ_ELEMENT; | 1355 | state->state = EBML_READ_ELEMENT; |
1292 | offset = state->stack_top->position + state->stack_top->header_size + state->stack_top->size; | 1356 | offset = state->stack_top->position + state->stack_top->header_size |
1357 | + state->stack_top->size; | ||
1293 | free (ebml_stack_pop (state)); | 1358 | free (ebml_stack_pop (state)); |
1294 | state->next_state = next_state; | 1359 | state->next_state = next_state; |
1295 | pl_seek (plugin, offset, SEEK_SET); | 1360 | pl_seek (plugin, offset, SEEK_SET); |
1296 | } | 1361 | } |
1297 | 1362 | ||
1363 | |||
1298 | static void | 1364 | static void |
1299 | try_to_find_pos (struct EXTRACTOR_PluginList *plugin, struct ebml_state *state) | 1365 | try_to_find_pos (struct EXTRACTOR_PluginList *plugin, struct ebml_state *state) |
1300 | { | 1366 | { |
1301 | if (state->matroska_seeks != NULL) | 1367 | if (state->matroska_seeks != NULL) |
1302 | { | 1368 | { |
1303 | struct matroska_seek_list *el, *pos = NULL; | 1369 | struct matroska_seek_list *el, *pos = NULL; |
1304 | int64_t segment_position = pl_get_pos (plugin) - state->segment_contents_start; | 1370 | int64_t segment_position = pl_get_pos (plugin) |
1371 | - state->segment_contents_start; | ||
1305 | for (el = state->matroska_seeks; el != NULL; el = el->next) | 1372 | for (el = state->matroska_seeks; el != NULL; el = el->next) |
1306 | { | 1373 | { |
1307 | if (el->position <= segment_position) | 1374 | if (el->position <= segment_position) |
@@ -1314,8 +1381,10 @@ try_to_find_pos (struct EXTRACTOR_PluginList *plugin, struct ebml_state *state) | |||
1314 | } | 1381 | } |
1315 | } | 1382 | } |
1316 | 1383 | ||
1384 | |||
1317 | static void | 1385 | static void |
1318 | maybe_seek_to_something_interesting (struct EXTRACTOR_PluginList *plugin, struct ebml_state *state) | 1386 | maybe_seek_to_something_interesting (struct EXTRACTOR_PluginList *plugin, struct |
1387 | ebml_state *state) | ||
1319 | { | 1388 | { |
1320 | int64_t offset; | 1389 | int64_t offset; |
1321 | struct matroska_seek_list *el; | 1390 | struct matroska_seek_list *el; |
@@ -1350,12 +1419,14 @@ maybe_seek_to_something_interesting (struct EXTRACTOR_PluginList *plugin, struct | |||
1350 | * the one we've got from seek table. If it doesn't match - stop parsing the file. | 1419 | * the one we've got from seek table. If it doesn't match - stop parsing the file. |
1351 | */ | 1420 | */ |
1352 | #if DEBUG_EBML | 1421 | #if DEBUG_EBML |
1353 | printf ("Seeking from %llu to %llu\n", offset, el->position + state->segment_contents_start); | 1422 | printf ("Seeking from %llu to %llu\n", offset, el->position |
1423 | + state->segment_contents_start); | ||
1354 | #endif | 1424 | #endif |
1355 | pl_seek (plugin, el->position + state->segment_contents_start, SEEK_SET); | 1425 | pl_seek (plugin, el->position + state->segment_contents_start, SEEK_SET); |
1356 | } | 1426 | } |
1357 | } | 1427 | } |
1358 | 1428 | ||
1429 | |||
1359 | static void | 1430 | static void |
1360 | sort_seeks (struct ebml_state *state) | 1431 | sort_seeks (struct ebml_state *state) |
1361 | { | 1432 | { |
@@ -1363,7 +1434,7 @@ sort_seeks (struct ebml_state *state) | |||
1363 | int64_t position; | 1434 | int64_t position; |
1364 | struct matroska_seek_list *el; | 1435 | struct matroska_seek_list *el; |
1365 | char sorted = 0; | 1436 | char sorted = 0; |
1366 | while (!sorted) | 1437 | while (! sorted) |
1367 | { | 1438 | { |
1368 | sorted = 1; | 1439 | sorted = 1; |
1369 | for (el = state->matroska_seeks; el != NULL; el = el->next) | 1440 | for (el = state->matroska_seeks; el != NULL; el = el->next) |
@@ -1386,7 +1457,8 @@ sort_seeks (struct ebml_state *state) | |||
1386 | 1457 | ||
1387 | 1458 | ||
1388 | int | 1459 | int |
1389 | EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_MetaDataProcessor proc, void *proc_cls) | 1460 | EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, |
1461 | EXTRACTOR_MetaDataProcessor proc, void *proc_cls) | ||
1390 | { | 1462 | { |
1391 | uint64_t offset = 0; | 1463 | uint64_t offset = 0; |
1392 | ssize_t read_result; | 1464 | ssize_t read_result; |
@@ -1406,7 +1478,7 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1406 | 1478 | ||
1407 | if (plugin == NULL) | 1479 | if (plugin == NULL) |
1408 | return 1; | 1480 | return 1; |
1409 | 1481 | ||
1410 | state = EXTRACTOR_ebml_init_state_method (); | 1482 | state = EXTRACTOR_ebml_init_state_method (); |
1411 | if (state == NULL) | 1483 | if (state == NULL) |
1412 | return 1; | 1484 | return 1; |
@@ -1421,7 +1493,7 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1421 | return EXTRACTOR_ebml_discard_state_method (state); | 1493 | return EXTRACTOR_ebml_discard_state_method (state); |
1422 | case EBML_LOOKING_FOR_HEADER: | 1494 | case EBML_LOOKING_FOR_HEADER: |
1423 | offset = pl_get_pos (plugin); | 1495 | offset = pl_get_pos (plugin); |
1424 | sint_value = pl_read (plugin, &data, 1024*1024); | 1496 | sint_value = pl_read (plugin, &data, 1024 * 1024); |
1425 | if (sint_value < 4) | 1497 | if (sint_value < 4) |
1426 | return EXTRACTOR_ebml_discard_state_method (state); | 1498 | return EXTRACTOR_ebml_discard_state_method (state); |
1427 | start = NULL; | 1499 | start = NULL; |
@@ -1433,12 +1505,13 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1433 | offset = pl_get_pos (plugin) - 3; | 1505 | offset = pl_get_pos (plugin) - 3; |
1434 | if (offset != pl_seek (plugin, offset, SEEK_SET)) | 1506 | if (offset != pl_seek (plugin, offset, SEEK_SET)) |
1435 | return EXTRACTOR_ebml_discard_state_method (state); | 1507 | return EXTRACTOR_ebml_discard_state_method (state); |
1436 | sint_value = pl_read (plugin, &data, 1024*1024); | 1508 | sint_value = pl_read (plugin, &data, 1024 * 1024); |
1437 | if (sint_value < 4) | 1509 | if (sint_value < 4) |
1438 | return EXTRACTOR_ebml_discard_state_method (state); | 1510 | return EXTRACTOR_ebml_discard_state_method (state); |
1439 | } | 1511 | } |
1440 | } | 1512 | } |
1441 | if (offset + start - data != pl_seek (plugin, offset + start - data, SEEK_SET)) | 1513 | if (offset + start - data != pl_seek (plugin, offset + start - data, |
1514 | SEEK_SET)) | ||
1442 | return EXTRACTOR_ebml_discard_state_method (state); | 1515 | return EXTRACTOR_ebml_discard_state_method (state); |
1443 | state->state = EBML_READING_HEADER; | 1516 | state->state = EBML_READING_HEADER; |
1444 | break; | 1517 | break; |
@@ -1458,7 +1531,9 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1458 | } | 1531 | } |
1459 | state->state = EBML_READ_ELEMENT; | 1532 | state->state = EBML_READ_ELEMENT; |
1460 | state->next_state = EBML_READING_HEADER_ELEMENTS; | 1533 | state->next_state = EBML_READING_HEADER_ELEMENTS; |
1461 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, EBML_FINISHED_READING_HEADER, EBML_BAD_STATE, EBML_FINISHED_READING_HEADER, EBML_BAD_STATE); | 1534 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, |
1535 | EBML_FINISHED_READING_HEADER, EBML_BAD_STATE, | ||
1536 | EBML_FINISHED_READING_HEADER, EBML_BAD_STATE); | ||
1462 | break; | 1537 | break; |
1463 | case EBML_READ_ELEMENT: | 1538 | case EBML_READ_ELEMENT: |
1464 | #if DEBUG_EBML | 1539 | #if DEBUG_EBML |
@@ -1475,19 +1550,14 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1475 | } | 1550 | } |
1476 | state->state = state->next_state; | 1551 | state->state = state->next_state; |
1477 | break; | 1552 | break; |
1478 | */ | 1553 | *//* while the following code crashes with SIGILL. |
1479 | /* while the following code crashes with SIGILL. | 1554 | *//* |
1480 | */ | ||
1481 | /* | ||
1482 | read_result = elementRead (plugin, &eID, &eSize); | 1555 | read_result = elementRead (plugin, &eID, &eSize); |
1483 | state->state = state->next_state; | 1556 | state->state = state->next_state; |
1484 | if (read_result < 0) | 1557 | if (read_result < 0) |
1485 | state->state = EBML_BAD_STATE; | 1558 | state->state = EBML_BAD_STATE; |
1486 | break; | 1559 | break; |
1487 | */ | 1560 | *//* but the following code works as intended *//* All three code snippets were compiled with -O0 */{ |
1488 | /* but the following code works as intended */ | ||
1489 | /* All three code snippets were compiled with -O0 */ | ||
1490 | { | ||
1491 | enum EBMLState next_state = state->next_state; | 1561 | enum EBMLState next_state = state->next_state; |
1492 | state->state = EBML_BAD_STATE; | 1562 | state->state = EBML_BAD_STATE; |
1493 | read_result = elementRead (plugin, &eID, (int64_t*) &eSize); | 1563 | read_result = elementRead (plugin, &eID, (int64_t*) &eSize); |
@@ -1506,7 +1576,8 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1506 | read_result = 0; | 1576 | read_result = 0; |
1507 | else | 1577 | else |
1508 | { | 1578 | { |
1509 | if (0 > (read_result = uintRead (plugin, state->stack_top->size, &uint_value))) | 1579 | if (0 > (read_result = uintRead (plugin, state->stack_top->size, |
1580 | &uint_value))) | ||
1510 | { | 1581 | { |
1511 | state->state = EBML_BAD_STATE; | 1582 | state->state = EBML_BAD_STATE; |
1512 | break; | 1583 | break; |
@@ -1516,7 +1587,8 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1516 | state->state = state->next_state; | 1587 | state->state = state->next_state; |
1517 | break; | 1588 | break; |
1518 | case EBML_READ_ID: | 1589 | case EBML_READ_ID: |
1519 | if (0 > (read_result = idRead (plugin, state->stack_top->size, &id_value))) | 1590 | if (0 > (read_result = idRead (plugin, state->stack_top->size, |
1591 | &id_value))) | ||
1520 | { | 1592 | { |
1521 | state->state = EBML_BAD_STATE; | 1593 | state->state = EBML_BAD_STATE; |
1522 | break; | 1594 | break; |
@@ -1534,7 +1606,8 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1534 | read_result = 0; | 1606 | read_result = 0; |
1535 | else | 1607 | else |
1536 | { | 1608 | { |
1537 | if (0 > (read_result = sintRead (plugin, state->stack_top->size, &sint_value))) | 1609 | if (0 > (read_result = sintRead (plugin, state->stack_top->size, |
1610 | &sint_value))) | ||
1538 | { | 1611 | { |
1539 | state->state = EBML_BAD_STATE; | 1612 | state->state = EBML_BAD_STATE; |
1540 | break; | 1613 | break; |
@@ -1554,7 +1627,8 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1554 | read_result = 0; | 1627 | read_result = 0; |
1555 | else | 1628 | else |
1556 | { | 1629 | { |
1557 | if (0 > (read_result = floatRead (plugin, state->stack_top->size, &float_value))) | 1630 | if (0 > (read_result = floatRead (plugin, state->stack_top->size, |
1631 | &float_value))) | ||
1558 | { | 1632 | { |
1559 | state->state = EBML_BAD_STATE; | 1633 | state->state = EBML_BAD_STATE; |
1560 | break; | 1634 | break; |
@@ -1571,7 +1645,8 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1571 | } | 1645 | } |
1572 | else | 1646 | else |
1573 | { | 1647 | { |
1574 | if (0 > (read_result = stringRead (plugin, state->stack_top->size, (char *) &string_value))) | 1648 | if (0 > (read_result = stringRead (plugin, state->stack_top->size, |
1649 | (char *) &string_value))) | ||
1575 | { | 1650 | { |
1576 | state->state = EBML_BAD_STATE; | 1651 | state->state = EBML_BAD_STATE; |
1577 | break; | 1652 | break; |
@@ -1581,7 +1656,7 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1581 | state->state = state->next_state; | 1656 | state->state = state->next_state; |
1582 | break; | 1657 | break; |
1583 | case EBML_READING_HEADER_ELEMENTS: | 1658 | case EBML_READING_HEADER_ELEMENTS: |
1584 | if (!check_result (plugin, read_result, state)) | 1659 | if (! check_result (plugin, read_result, state)) |
1585 | break; | 1660 | break; |
1586 | do_break = 0; | 1661 | do_break = 0; |
1587 | switch (eID) | 1662 | switch (eID) |
@@ -1609,10 +1684,13 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1609 | if (do_break) | 1684 | if (do_break) |
1610 | break; | 1685 | break; |
1611 | state->next_state = EBML_READING_HEADER_ELEMENT_VALUE; | 1686 | state->next_state = EBML_READING_HEADER_ELEMENT_VALUE; |
1612 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, EBML_BAD_STATE, EBML_READING_HEADER_ELEMENTS, EBML_READ_ELEMENT, EBML_READING_HEADER_ELEMENTS); | 1687 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, |
1688 | EBML_BAD_STATE, EBML_READING_HEADER_ELEMENTS, | ||
1689 | EBML_READ_ELEMENT, | ||
1690 | EBML_READING_HEADER_ELEMENTS); | ||
1613 | break; | 1691 | break; |
1614 | case EBML_READING_HEADER_ELEMENT_VALUE: | 1692 | case EBML_READING_HEADER_ELEMENT_VALUE: |
1615 | if (!check_result (plugin, read_result, state)) | 1693 | if (! check_result (plugin, read_result, state)) |
1616 | break; | 1694 | break; |
1617 | 1695 | ||
1618 | switch (state->stack_top->id) | 1696 | switch (state->stack_top->id) |
@@ -1632,8 +1710,7 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1632 | * We also stop right here and do not assume that somewhere further | 1710 | * We also stop right here and do not assume that somewhere further |
1633 | * in the file there's another EBML header that is, maybe, readable | 1711 | * in the file there's another EBML header that is, maybe, readable |
1634 | * by us. If you think this is worth correcting - patches are welcome. | 1712 | * by us. If you think this is worth correcting - patches are welcome. |
1635 | */ | 1713 | */continue; |
1636 | continue; | ||
1637 | } | 1714 | } |
1638 | break; | 1715 | break; |
1639 | case EBMLID_MAX_ID_LENGTH: | 1716 | case EBMLID_MAX_ID_LENGTH: |
@@ -1658,7 +1735,7 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1658 | rise_up_after_value (plugin, state, EBML_READING_HEADER_ELEMENTS); | 1735 | rise_up_after_value (plugin, state, EBML_READING_HEADER_ELEMENTS); |
1659 | break; | 1736 | break; |
1660 | case EBML_FINISHED_READING_HEADER: | 1737 | case EBML_FINISHED_READING_HEADER: |
1661 | if (!state->valid_ebml) | 1738 | if (! state->valid_ebml) |
1662 | { | 1739 | { |
1663 | /* Header was invalid (lacking doctype). */ | 1740 | /* Header was invalid (lacking doctype). */ |
1664 | state->next_state = EBML_SKIP_UNTIL_NEXT_HEADER; | 1741 | state->next_state = EBML_SKIP_UNTIL_NEXT_HEADER; |
@@ -1680,8 +1757,7 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1680 | * metadata from it!), we do not care about these differences | 1757 | * metadata from it!), we do not care about these differences |
1681 | * (which means that this code will happily read webm files that do | 1758 | * (which means that this code will happily read webm files that do |
1682 | * not conform to Webm spec, but conform to Matroska spec). | 1759 | * not conform to Webm spec, but conform to Matroska spec). |
1683 | */ | 1760 | */state->next_state = EBML_READING_MATROSKA_SEGMENT; |
1684 | state->next_state = EBML_READING_MATROSKA_SEGMENT; | ||
1685 | } | 1761 | } |
1686 | else | 1762 | else |
1687 | { | 1763 | { |
@@ -1727,11 +1803,14 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1727 | state->state = EBML_READ_ELEMENT; | 1803 | state->state = EBML_READ_ELEMENT; |
1728 | state->next_state = EBML_READING_MATROSKA_SEGMENT_CONTENTS; | 1804 | state->next_state = EBML_READING_MATROSKA_SEGMENT_CONTENTS; |
1729 | clean_ebml_state_matroska_segment (state); | 1805 | clean_ebml_state_matroska_segment (state); |
1730 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, EBML_FINISHED_READING_MATROSKA_SEGMENT_CONTENTS, EBML_READING_MATROSKA_SEGMENT, EBML_READ_ELEMENT, EBML_READING_MATROSKA_SEGMENT); | 1806 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, |
1807 | EBML_FINISHED_READING_MATROSKA_SEGMENT_CONTENTS, | ||
1808 | EBML_READING_MATROSKA_SEGMENT, EBML_READ_ELEMENT, | ||
1809 | EBML_READING_MATROSKA_SEGMENT); | ||
1731 | state->segment_contents_start = pl_get_pos (plugin); | 1810 | state->segment_contents_start = pl_get_pos (plugin); |
1732 | break; | 1811 | break; |
1733 | case EBML_READING_MATROSKA_SEGMENT_CONTENTS: | 1812 | case EBML_READING_MATROSKA_SEGMENT_CONTENTS: |
1734 | if (!check_result (plugin, read_result, state)) | 1813 | if (! check_result (plugin, read_result, state)) |
1735 | break; | 1814 | break; |
1736 | 1815 | ||
1737 | state->state = EBML_READ_ELEMENT; | 1816 | state->state = EBML_READ_ELEMENT; |
@@ -1739,20 +1818,40 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1739 | { | 1818 | { |
1740 | case MatroskaID_SeekHead: | 1819 | case MatroskaID_SeekHead: |
1741 | state->next_state = EBML_READING_MATROSKA_SEEK_HEAD_CONTENTS; | 1820 | state->next_state = EBML_READING_MATROSKA_SEEK_HEAD_CONTENTS; |
1742 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, EBML_FINISHED_READING_MATROSKA_SEEK_HEAD_CONTENTS, EBML_READING_MATROSKA_SEGMENT_CONTENTS, EBML_READ_ELEMENT, EBML_READING_MATROSKA_SEGMENT_CONTENTS); | 1821 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, |
1822 | read_result, | ||
1823 | EBML_FINISHED_READING_MATROSKA_SEEK_HEAD_CONTENTS, | ||
1824 | EBML_READING_MATROSKA_SEGMENT_CONTENTS, | ||
1825 | EBML_READ_ELEMENT, | ||
1826 | EBML_READING_MATROSKA_SEGMENT_CONTENTS); | ||
1743 | break; | 1827 | break; |
1744 | case MatroskaID_Info: | 1828 | case MatroskaID_Info: |
1745 | state->next_state = EBML_READING_MATROSKA_INFO_CONTENTS; | 1829 | state->next_state = EBML_READING_MATROSKA_INFO_CONTENTS; |
1746 | clean_ebml_state_matroska_info (state); | 1830 | clean_ebml_state_matroska_info (state); |
1747 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, EBML_FINISHED_READING_MATROSKA_INFO_CONTENTS, EBML_READING_MATROSKA_SEGMENT_CONTENTS, EBML_READ_ELEMENT, EBML_READING_MATROSKA_SEGMENT_CONTENTS); | 1831 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, |
1832 | read_result, | ||
1833 | EBML_FINISHED_READING_MATROSKA_INFO_CONTENTS, | ||
1834 | EBML_READING_MATROSKA_SEGMENT_CONTENTS, | ||
1835 | EBML_READ_ELEMENT, | ||
1836 | EBML_READING_MATROSKA_SEGMENT_CONTENTS); | ||
1748 | break; | 1837 | break; |
1749 | case MatroskaID_Tracks: | 1838 | case MatroskaID_Tracks: |
1750 | state->next_state = EBML_READING_MATROSKA_TRACKS_CONTENTS; | 1839 | state->next_state = EBML_READING_MATROSKA_TRACKS_CONTENTS; |
1751 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, EBML_FINISHED_READING_MATROSKA_TRACKS_CONTENTS, EBML_READING_MATROSKA_SEGMENT_CONTENTS, EBML_READ_ELEMENT, EBML_READING_MATROSKA_SEGMENT_CONTENTS); | 1840 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, |
1841 | read_result, | ||
1842 | EBML_FINISHED_READING_MATROSKA_TRACKS_CONTENTS, | ||
1843 | EBML_READING_MATROSKA_SEGMENT_CONTENTS, | ||
1844 | EBML_READ_ELEMENT, | ||
1845 | EBML_READING_MATROSKA_SEGMENT_CONTENTS); | ||
1752 | break; | 1846 | break; |
1753 | case MatroskaID_Tags: | 1847 | case MatroskaID_Tags: |
1754 | state->next_state = EBML_READING_MATROSKA_TAGS_CONTENTS; | 1848 | state->next_state = EBML_READING_MATROSKA_TAGS_CONTENTS; |
1755 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, EBML_FINISHED_READING_MATROSKA_TAGS_CONTENTS, EBML_READING_MATROSKA_SEGMENT_CONTENTS, EBML_READ_ELEMENT, EBML_READING_MATROSKA_SEGMENT_CONTENTS); | 1849 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, |
1850 | read_result, | ||
1851 | EBML_FINISHED_READING_MATROSKA_TAGS_CONTENTS, | ||
1852 | EBML_READING_MATROSKA_SEGMENT_CONTENTS, | ||
1853 | EBML_READ_ELEMENT, | ||
1854 | EBML_READING_MATROSKA_SEGMENT_CONTENTS); | ||
1756 | break; | 1855 | break; |
1757 | default: | 1856 | default: |
1758 | if (maybe_rise_up (plugin, state, &do_break, read_result)) | 1857 | if (maybe_rise_up (plugin, state, &do_break, read_result)) |
@@ -1763,7 +1862,7 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1763 | } | 1862 | } |
1764 | break; | 1863 | break; |
1765 | case EBML_READING_MATROSKA_TAGS_CONTENTS: | 1864 | case EBML_READING_MATROSKA_TAGS_CONTENTS: |
1766 | if (!check_result (plugin, read_result, state)) | 1865 | if (! check_result (plugin, read_result, state)) |
1767 | break; | 1866 | break; |
1768 | state->state = EBML_READ_ELEMENT; | 1867 | state->state = EBML_READ_ELEMENT; |
1769 | switch (eID) | 1868 | switch (eID) |
@@ -1771,7 +1870,12 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1771 | case MatroskaID_Tags_Tag: | 1870 | case MatroskaID_Tags_Tag: |
1772 | state->next_state = EBML_READING_MATROSKA_TAG_CONTENTS; | 1871 | state->next_state = EBML_READING_MATROSKA_TAG_CONTENTS; |
1773 | clean_ebml_state_matroska_seek (state); | 1872 | clean_ebml_state_matroska_seek (state); |
1774 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, EBML_FINISHED_READING_MATROSKA_TAG_CONTENTS, EBML_READING_MATROSKA_TAGS_CONTENTS, EBML_READ_ELEMENT, EBML_READING_MATROSKA_TAGS_CONTENTS); | 1873 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, |
1874 | read_result, | ||
1875 | EBML_FINISHED_READING_MATROSKA_TAG_CONTENTS, | ||
1876 | EBML_READING_MATROSKA_TAGS_CONTENTS, | ||
1877 | EBML_READ_ELEMENT, | ||
1878 | EBML_READING_MATROSKA_TAGS_CONTENTS); | ||
1775 | break; | 1879 | break; |
1776 | default: | 1880 | default: |
1777 | if (maybe_rise_up (plugin, state, &do_break, read_result)) | 1881 | if (maybe_rise_up (plugin, state, &do_break, read_result)) |
@@ -1781,7 +1885,7 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1781 | } | 1885 | } |
1782 | break; | 1886 | break; |
1783 | case EBML_READING_MATROSKA_TAG_CONTENTS: | 1887 | case EBML_READING_MATROSKA_TAG_CONTENTS: |
1784 | if (!check_result (plugin, read_result, state)) | 1888 | if (! check_result (plugin, read_result, state)) |
1785 | break; | 1889 | break; |
1786 | 1890 | ||
1787 | state->state = EBML_READ_ELEMENT; | 1891 | state->state = EBML_READ_ELEMENT; |
@@ -1793,7 +1897,12 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1793 | matroska_add_tag (state, NULL, NULL, NULL); | 1897 | matroska_add_tag (state, NULL, NULL, NULL); |
1794 | state->tag_current = state->tag_last; | 1898 | state->tag_current = state->tag_last; |
1795 | state->tag_tree = state->tag_current; | 1899 | state->tag_tree = state->tag_current; |
1796 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, EBML_FINISHED_READING_MATROSKA_SIMPLETAG_CONTENTS, EBML_READING_MATROSKA_TAG_CONTENTS, EBML_READ_ELEMENT, EBML_READING_MATROSKA_TAG_CONTENTS); | 1900 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, |
1901 | read_result, | ||
1902 | EBML_FINISHED_READING_MATROSKA_SIMPLETAG_CONTENTS, | ||
1903 | EBML_READING_MATROSKA_TAG_CONTENTS, | ||
1904 | EBML_READ_ELEMENT, | ||
1905 | EBML_READING_MATROSKA_TAG_CONTENTS); | ||
1797 | break; | 1906 | break; |
1798 | default: | 1907 | default: |
1799 | if (maybe_rise_up (plugin, state, &do_break, read_result)) | 1908 | if (maybe_rise_up (plugin, state, &do_break, read_result)) |
@@ -1803,7 +1912,7 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1803 | } | 1912 | } |
1804 | break; | 1913 | break; |
1805 | case EBML_READING_MATROSKA_SIMPLETAG_CONTENTS: | 1914 | case EBML_READING_MATROSKA_SIMPLETAG_CONTENTS: |
1806 | if (!check_result (plugin, read_result, state)) | 1915 | if (! check_result (plugin, read_result, state)) |
1807 | break; | 1916 | break; |
1808 | 1917 | ||
1809 | do_break = 0; | 1918 | do_break = 0; |
@@ -1823,7 +1932,12 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1823 | state->next_state = EBML_READING_MATROSKA_SIMPLETAG_CONTENTS; | 1932 | state->next_state = EBML_READING_MATROSKA_SIMPLETAG_CONTENTS; |
1824 | matroska_add_tag (state, state->tag_current, NULL, NULL); | 1933 | matroska_add_tag (state, state->tag_current, NULL, NULL); |
1825 | state->tag_current = state->tag_last; | 1934 | state->tag_current = state->tag_last; |
1826 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, EBML_FINISHED_READING_MATROSKA_SIMPLETAG_CONTENTS, EBML_READING_MATROSKA_SIMPLETAG_CONTENTS, EBML_READ_ELEMENT, EBML_FINISHED_READING_MATROSKA_SIMPLETAG_CONTENTS); | 1935 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, |
1936 | read_result, | ||
1937 | EBML_FINISHED_READING_MATROSKA_SIMPLETAG_CONTENTS, | ||
1938 | EBML_READING_MATROSKA_SIMPLETAG_CONTENTS, | ||
1939 | EBML_READ_ELEMENT, | ||
1940 | EBML_FINISHED_READING_MATROSKA_SIMPLETAG_CONTENTS); | ||
1827 | do_break = 1; | 1941 | do_break = 1; |
1828 | break; | 1942 | break; |
1829 | default: | 1943 | default: |
@@ -1838,10 +1952,14 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1838 | if (do_break) | 1952 | if (do_break) |
1839 | break; | 1953 | break; |
1840 | state->next_state = EBML_READING_MATROSKA_SIMPLETAG_CONTENTS_VALUE; | 1954 | state->next_state = EBML_READING_MATROSKA_SIMPLETAG_CONTENTS_VALUE; |
1841 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, EBML_BAD_STATE, EBML_READING_MATROSKA_SIMPLETAG_CONTENTS, EBML_READ_ELEMENT, EBML_READING_MATROSKA_SIMPLETAG_CONTENTS); | 1955 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, |
1956 | EBML_BAD_STATE, | ||
1957 | EBML_READING_MATROSKA_SIMPLETAG_CONTENTS, | ||
1958 | EBML_READ_ELEMENT, | ||
1959 | EBML_READING_MATROSKA_SIMPLETAG_CONTENTS); | ||
1842 | break; | 1960 | break; |
1843 | case EBML_READING_MATROSKA_SIMPLETAG_CONTENTS_VALUE: | 1961 | case EBML_READING_MATROSKA_SIMPLETAG_CONTENTS_VALUE: |
1844 | if (!check_result (plugin, read_result, state)) | 1962 | if (! check_result (plugin, read_result, state)) |
1845 | break; | 1963 | break; |
1846 | 1964 | ||
1847 | /* This breaks the specs, as there should be only one instance of each | 1965 | /* This breaks the specs, as there should be only one instance of each |
@@ -1861,10 +1979,11 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1861 | state->tag_current->string = strdup (string_value); | 1979 | state->tag_current->string = strdup (string_value); |
1862 | break; | 1980 | break; |
1863 | } | 1981 | } |
1864 | rise_up_after_value (plugin, state, EBML_READING_MATROSKA_SIMPLETAG_CONTENTS); | 1982 | rise_up_after_value (plugin, state, |
1983 | EBML_READING_MATROSKA_SIMPLETAG_CONTENTS); | ||
1865 | break; | 1984 | break; |
1866 | case EBML_READING_MATROSKA_SEEK_HEAD_CONTENTS: | 1985 | case EBML_READING_MATROSKA_SEEK_HEAD_CONTENTS: |
1867 | if (!check_result (plugin, read_result, state)) | 1986 | if (! check_result (plugin, read_result, state)) |
1868 | break; | 1987 | break; |
1869 | 1988 | ||
1870 | state->state = EBML_READ_ELEMENT; | 1989 | state->state = EBML_READ_ELEMENT; |
@@ -1873,7 +1992,12 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1873 | case MatroskaID_Seek: | 1992 | case MatroskaID_Seek: |
1874 | state->next_state = EBML_READING_MATROSKA_SEEK_CONTENTS; | 1993 | state->next_state = EBML_READING_MATROSKA_SEEK_CONTENTS; |
1875 | clean_ebml_state_matroska_seek (state); | 1994 | clean_ebml_state_matroska_seek (state); |
1876 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, EBML_FINISHED_READING_MATROSKA_SEEK_CONTENTS, EBML_READING_MATROSKA_SEEK_HEAD_CONTENTS, EBML_READ_ELEMENT, EBML_READING_MATROSKA_SEEK_HEAD_CONTENTS); | 1995 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, |
1996 | read_result, | ||
1997 | EBML_FINISHED_READING_MATROSKA_SEEK_CONTENTS, | ||
1998 | EBML_READING_MATROSKA_SEEK_HEAD_CONTENTS, | ||
1999 | EBML_READ_ELEMENT, | ||
2000 | EBML_READING_MATROSKA_SEEK_HEAD_CONTENTS); | ||
1877 | break; | 2001 | break; |
1878 | default: | 2002 | default: |
1879 | if (maybe_rise_up (plugin, state, &do_break, read_result)) | 2003 | if (maybe_rise_up (plugin, state, &do_break, read_result)) |
@@ -1883,7 +2007,7 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1883 | } | 2007 | } |
1884 | break; | 2008 | break; |
1885 | case EBML_READING_MATROSKA_SEEK_CONTENTS: | 2009 | case EBML_READING_MATROSKA_SEEK_CONTENTS: |
1886 | if (!check_result (plugin, read_result, state)) | 2010 | if (! check_result (plugin, read_result, state)) |
1887 | break; | 2011 | break; |
1888 | 2012 | ||
1889 | do_break = 0; | 2013 | do_break = 0; |
@@ -1907,10 +2031,13 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1907 | if (do_break) | 2031 | if (do_break) |
1908 | break; | 2032 | break; |
1909 | state->next_state = EBML_READING_MATROSKA_SEEK_CONTENTS_VALUE; | 2033 | state->next_state = EBML_READING_MATROSKA_SEEK_CONTENTS_VALUE; |
1910 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, EBML_BAD_STATE, EBML_READING_MATROSKA_SEEK_CONTENTS, EBML_READ_ELEMENT, EBML_READING_MATROSKA_SEEK_CONTENTS); | 2034 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, |
2035 | EBML_BAD_STATE, EBML_READING_MATROSKA_SEEK_CONTENTS, | ||
2036 | EBML_READ_ELEMENT, | ||
2037 | EBML_READING_MATROSKA_SEEK_CONTENTS); | ||
1911 | break; | 2038 | break; |
1912 | case EBML_READING_MATROSKA_SEEK_CONTENTS_VALUE: | 2039 | case EBML_READING_MATROSKA_SEEK_CONTENTS_VALUE: |
1913 | if (!check_result (plugin, read_result, state)) | 2040 | if (! check_result (plugin, read_result, state)) |
1914 | break; | 2041 | break; |
1915 | 2042 | ||
1916 | /* This breaks the specs, as there should be only one instance of each | 2043 | /* This breaks the specs, as there should be only one instance of each |
@@ -1929,7 +2056,7 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1929 | rise_up_after_value (plugin, state, EBML_READING_MATROSKA_SEEK_CONTENTS); | 2056 | rise_up_after_value (plugin, state, EBML_READING_MATROSKA_SEEK_CONTENTS); |
1930 | break; | 2057 | break; |
1931 | case EBML_READING_MATROSKA_TRACKS_CONTENTS: | 2058 | case EBML_READING_MATROSKA_TRACKS_CONTENTS: |
1932 | if (!check_result (plugin, read_result, state)) | 2059 | if (! check_result (plugin, read_result, state)) |
1933 | break; | 2060 | break; |
1934 | 2061 | ||
1935 | state->state = EBML_READ_ELEMENT; | 2062 | state->state = EBML_READ_ELEMENT; |
@@ -1938,7 +2065,12 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1938 | case MatroskaID_Tracks_TrackEntry: | 2065 | case MatroskaID_Tracks_TrackEntry: |
1939 | state->next_state = EBML_READING_MATROSKA_TRACK_ENTRY_CONTENTS; | 2066 | state->next_state = EBML_READING_MATROSKA_TRACK_ENTRY_CONTENTS; |
1940 | clean_ebml_state_matroska_track (state); | 2067 | clean_ebml_state_matroska_track (state); |
1941 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, EBML_FINISHED_READING_MATROSKA_TRACK_ENTRY_CONTENTS, EBML_READING_MATROSKA_TRACKS_CONTENTS, EBML_READ_ELEMENT, EBML_READING_MATROSKA_TRACKS_CONTENTS); | 2068 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, |
2069 | read_result, | ||
2070 | EBML_FINISHED_READING_MATROSKA_TRACK_ENTRY_CONTENTS, | ||
2071 | EBML_READING_MATROSKA_TRACKS_CONTENTS, | ||
2072 | EBML_READ_ELEMENT, | ||
2073 | EBML_READING_MATROSKA_TRACKS_CONTENTS); | ||
1942 | break; | 2074 | break; |
1943 | default: | 2075 | default: |
1944 | if (maybe_rise_up (plugin, state, &do_break, read_result)) | 2076 | if (maybe_rise_up (plugin, state, &do_break, read_result)) |
@@ -1948,7 +2080,7 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1948 | } | 2080 | } |
1949 | break; | 2081 | break; |
1950 | case EBML_READING_MATROSKA_TRACK_ENTRY_CONTENTS: | 2082 | case EBML_READING_MATROSKA_TRACK_ENTRY_CONTENTS: |
1951 | if (!check_result (plugin, read_result, state)) | 2083 | if (! check_result (plugin, read_result, state)) |
1952 | break; | 2084 | break; |
1953 | 2085 | ||
1954 | do_break = 0; | 2086 | do_break = 0; |
@@ -1967,14 +2099,24 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1967 | state->state = EBML_READ_ELEMENT; | 2099 | state->state = EBML_READ_ELEMENT; |
1968 | state->next_state = EBML_READING_MATROSKA_TRACK_ENTRY_VIDEO_CONTENTS; | 2100 | state->next_state = EBML_READING_MATROSKA_TRACK_ENTRY_VIDEO_CONTENTS; |
1969 | clean_ebml_state_matroska_track_video (state); | 2101 | clean_ebml_state_matroska_track_video (state); |
1970 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, EBML_FINISHED_READING_MATROSKA_TRACK_ENTRY_VIDEO_CONTENTS, EBML_READING_MATROSKA_TRACK_ENTRY_CONTENTS, EBML_READ_ELEMENT, EBML_READING_MATROSKA_TRACK_ENTRY_CONTENTS); | 2102 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, |
2103 | read_result, | ||
2104 | EBML_FINISHED_READING_MATROSKA_TRACK_ENTRY_VIDEO_CONTENTS, | ||
2105 | EBML_READING_MATROSKA_TRACK_ENTRY_CONTENTS, | ||
2106 | EBML_READ_ELEMENT, | ||
2107 | EBML_READING_MATROSKA_TRACK_ENTRY_CONTENTS); | ||
1971 | do_break = 1; | 2108 | do_break = 1; |
1972 | break; | 2109 | break; |
1973 | case MatroskaID_Tracks_Audio: | 2110 | case MatroskaID_Tracks_Audio: |
1974 | state->state = EBML_READ_ELEMENT; | 2111 | state->state = EBML_READ_ELEMENT; |
1975 | state->next_state = EBML_READING_MATROSKA_TRACK_ENTRY_AUDIO_CONTENTS; | 2112 | state->next_state = EBML_READING_MATROSKA_TRACK_ENTRY_AUDIO_CONTENTS; |
1976 | clean_ebml_state_matroska_track_audio (state); | 2113 | clean_ebml_state_matroska_track_audio (state); |
1977 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, EBML_FINISHED_READING_MATROSKA_TRACK_ENTRY_AUDIO_CONTENTS, EBML_READING_MATROSKA_TRACK_ENTRY_CONTENTS, EBML_READ_ELEMENT, EBML_READING_MATROSKA_TRACK_ENTRY_CONTENTS); | 2114 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, |
2115 | read_result, | ||
2116 | EBML_FINISHED_READING_MATROSKA_TRACK_ENTRY_AUDIO_CONTENTS, | ||
2117 | EBML_READING_MATROSKA_TRACK_ENTRY_CONTENTS, | ||
2118 | EBML_READ_ELEMENT, | ||
2119 | EBML_READING_MATROSKA_TRACK_ENTRY_CONTENTS); | ||
1978 | do_break = 1; | 2120 | do_break = 1; |
1979 | break; | 2121 | break; |
1980 | default: | 2122 | default: |
@@ -1989,10 +2131,14 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1989 | if (do_break) | 2131 | if (do_break) |
1990 | break; | 2132 | break; |
1991 | state->next_state = EBML_READING_MATROSKA_TRACK_ENTRY_CONTENTS_VALUE; | 2133 | state->next_state = EBML_READING_MATROSKA_TRACK_ENTRY_CONTENTS_VALUE; |
1992 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, EBML_BAD_STATE, EBML_READING_MATROSKA_TRACK_ENTRY_CONTENTS, EBML_READ_ELEMENT, EBML_READING_MATROSKA_TRACK_ENTRY_CONTENTS); | 2134 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, |
2135 | EBML_BAD_STATE, | ||
2136 | EBML_READING_MATROSKA_TRACK_ENTRY_CONTENTS, | ||
2137 | EBML_READ_ELEMENT, | ||
2138 | EBML_READING_MATROSKA_TRACK_ENTRY_CONTENTS); | ||
1993 | break; | 2139 | break; |
1994 | case EBML_READING_MATROSKA_TRACK_ENTRY_AUDIO_CONTENTS: | 2140 | case EBML_READING_MATROSKA_TRACK_ENTRY_AUDIO_CONTENTS: |
1995 | if (!check_result (plugin, read_result, state)) | 2141 | if (! check_result (plugin, read_result, state)) |
1996 | break; | 2142 | break; |
1997 | 2143 | ||
1998 | do_break = 0; | 2144 | do_break = 0; |
@@ -2017,11 +2163,16 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
2017 | } | 2163 | } |
2018 | if (do_break) | 2164 | if (do_break) |
2019 | break; | 2165 | break; |
2020 | state->next_state = EBML_READING_MATROSKA_TRACK_ENTRY_AUDIO_CONTENTS_VALUE; | 2166 | state->next_state = |
2021 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, EBML_BAD_STATE, EBML_READING_MATROSKA_TRACK_ENTRY_AUDIO_CONTENTS, EBML_READ_ELEMENT, EBML_READING_MATROSKA_TRACK_ENTRY_AUDIO_CONTENTS); | 2167 | EBML_READING_MATROSKA_TRACK_ENTRY_AUDIO_CONTENTS_VALUE; |
2168 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, | ||
2169 | EBML_BAD_STATE, | ||
2170 | EBML_READING_MATROSKA_TRACK_ENTRY_AUDIO_CONTENTS, | ||
2171 | EBML_READ_ELEMENT, | ||
2172 | EBML_READING_MATROSKA_TRACK_ENTRY_AUDIO_CONTENTS); | ||
2022 | break; | 2173 | break; |
2023 | case EBML_READING_MATROSKA_TRACK_ENTRY_AUDIO_CONTENTS_VALUE: | 2174 | case EBML_READING_MATROSKA_TRACK_ENTRY_AUDIO_CONTENTS_VALUE: |
2024 | if (!check_result (plugin, read_result, state)) | 2175 | if (! check_result (plugin, read_result, state)) |
2025 | break; | 2176 | break; |
2026 | 2177 | ||
2027 | /* This breaks the specs, as there should be only one instance of each | 2178 | /* This breaks the specs, as there should be only one instance of each |
@@ -2043,10 +2194,11 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
2043 | state->matroska_track_audio_bit_depth = uint_value; | 2194 | state->matroska_track_audio_bit_depth = uint_value; |
2044 | break; | 2195 | break; |
2045 | } | 2196 | } |
2046 | rise_up_after_value (plugin, state, EBML_READING_MATROSKA_TRACK_ENTRY_AUDIO_CONTENTS); | 2197 | rise_up_after_value (plugin, state, |
2198 | EBML_READING_MATROSKA_TRACK_ENTRY_AUDIO_CONTENTS); | ||
2047 | break; | 2199 | break; |
2048 | case EBML_READING_MATROSKA_TRACK_ENTRY_VIDEO_CONTENTS: | 2200 | case EBML_READING_MATROSKA_TRACK_ENTRY_VIDEO_CONTENTS: |
2049 | if (!check_result (plugin, read_result, state)) | 2201 | if (! check_result (plugin, read_result, state)) |
2050 | break; | 2202 | break; |
2051 | 2203 | ||
2052 | do_break = 0; | 2204 | do_break = 0; |
@@ -2072,11 +2224,16 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
2072 | } | 2224 | } |
2073 | if (do_break) | 2225 | if (do_break) |
2074 | break; | 2226 | break; |
2075 | state->next_state = EBML_READING_MATROSKA_TRACK_ENTRY_VIDEO_CONTENTS_VALUE; | 2227 | state->next_state = |
2076 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, EBML_BAD_STATE, EBML_READING_MATROSKA_TRACK_ENTRY_VIDEO_CONTENTS, EBML_READ_ELEMENT, EBML_READING_MATROSKA_TRACK_ENTRY_VIDEO_CONTENTS); | 2228 | EBML_READING_MATROSKA_TRACK_ENTRY_VIDEO_CONTENTS_VALUE; |
2229 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, | ||
2230 | EBML_BAD_STATE, | ||
2231 | EBML_READING_MATROSKA_TRACK_ENTRY_VIDEO_CONTENTS, | ||
2232 | EBML_READ_ELEMENT, | ||
2233 | EBML_READING_MATROSKA_TRACK_ENTRY_VIDEO_CONTENTS); | ||
2077 | break; | 2234 | break; |
2078 | case EBML_READING_MATROSKA_TRACK_ENTRY_VIDEO_CONTENTS_VALUE: | 2235 | case EBML_READING_MATROSKA_TRACK_ENTRY_VIDEO_CONTENTS_VALUE: |
2079 | if (!check_result (plugin, read_result, state)) | 2236 | if (! check_result (plugin, read_result, state)) |
2080 | break; | 2237 | break; |
2081 | 2238 | ||
2082 | /* This breaks the specs, as there should be only one instance of each | 2239 | /* This breaks the specs, as there should be only one instance of each |
@@ -2107,10 +2264,11 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
2107 | state->matroska_track_video_display_unit = uint_value; | 2264 | state->matroska_track_video_display_unit = uint_value; |
2108 | break; | 2265 | break; |
2109 | } | 2266 | } |
2110 | rise_up_after_value (plugin, state, EBML_READING_MATROSKA_TRACK_ENTRY_VIDEO_CONTENTS); | 2267 | rise_up_after_value (plugin, state, |
2268 | EBML_READING_MATROSKA_TRACK_ENTRY_VIDEO_CONTENTS); | ||
2111 | break; | 2269 | break; |
2112 | case EBML_READING_MATROSKA_TRACK_ENTRY_CONTENTS_VALUE: | 2270 | case EBML_READING_MATROSKA_TRACK_ENTRY_CONTENTS_VALUE: |
2113 | if (!check_result (plugin, read_result, state)) | 2271 | if (! check_result (plugin, read_result, state)) |
2114 | break; | 2272 | break; |
2115 | 2273 | ||
2116 | /* This breaks the specs, as there should be only one instance of each | 2274 | /* This breaks the specs, as there should be only one instance of each |
@@ -2143,10 +2301,11 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
2143 | state->matroska_track_codec_name = strdup (string_value); | 2301 | state->matroska_track_codec_name = strdup (string_value); |
2144 | break; /* UTF-8-encoded. A human-readable string specifying the codec. */ | 2302 | break; /* UTF-8-encoded. A human-readable string specifying the codec. */ |
2145 | } | 2303 | } |
2146 | rise_up_after_value (plugin, state, EBML_READING_MATROSKA_TRACK_ENTRY_CONTENTS); | 2304 | rise_up_after_value (plugin, state, |
2305 | EBML_READING_MATROSKA_TRACK_ENTRY_CONTENTS); | ||
2147 | break; | 2306 | break; |
2148 | case EBML_READING_MATROSKA_INFO_CONTENTS: | 2307 | case EBML_READING_MATROSKA_INFO_CONTENTS: |
2149 | if (!check_result (plugin, read_result, state)) | 2308 | if (! check_result (plugin, read_result, state)) |
2150 | break; | 2309 | break; |
2151 | 2310 | ||
2152 | do_break = 0; | 2311 | do_break = 0; |
@@ -2178,10 +2337,13 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
2178 | if (do_break) | 2337 | if (do_break) |
2179 | break; | 2338 | break; |
2180 | state->next_state = EBML_READING_MATROSKA_INFO_CONTENTS_VALUE; | 2339 | state->next_state = EBML_READING_MATROSKA_INFO_CONTENTS_VALUE; |
2181 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, EBML_BAD_STATE, EBML_READING_MATROSKA_INFO_CONTENTS, EBML_READ_ELEMENT, EBML_READING_MATROSKA_INFO_CONTENTS); | 2340 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, |
2341 | EBML_BAD_STATE, EBML_READING_MATROSKA_INFO_CONTENTS, | ||
2342 | EBML_READ_ELEMENT, | ||
2343 | EBML_READING_MATROSKA_INFO_CONTENTS); | ||
2182 | break; | 2344 | break; |
2183 | case EBML_READING_MATROSKA_INFO_CONTENTS_VALUE: | 2345 | case EBML_READING_MATROSKA_INFO_CONTENTS_VALUE: |
2184 | if (!check_result (plugin, read_result, state)) | 2346 | if (! check_result (plugin, read_result, state)) |
2185 | break; | 2347 | break; |
2186 | 2348 | ||
2187 | /* This breaks the specs, as there should be only one instance of each | 2349 | /* This breaks the specs, as there should be only one instance of each |
@@ -2219,7 +2381,10 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
2219 | rise_up_after_value (plugin, state, EBML_READING_MATROSKA_INFO_CONTENTS); | 2381 | rise_up_after_value (plugin, state, EBML_READING_MATROSKA_INFO_CONTENTS); |
2220 | break; | 2382 | break; |
2221 | case EBML_FINISHED_READING_MATROSKA_INFO_CONTENTS: | 2383 | case EBML_FINISHED_READING_MATROSKA_INFO_CONTENTS: |
2222 | if (state->stack_top != NULL && pl_get_pos (plugin) >= state->stack_top->position + state->stack_top->header_size + state->stack_top->size) | 2384 | if ((state->stack_top != NULL) && (pl_get_pos (plugin) >= |
2385 | state->stack_top->position | ||
2386 | + state->stack_top->header_size | ||
2387 | + state->stack_top->size) ) | ||
2223 | report_state (state, proc, proc_cls); | 2388 | report_state (state, proc, proc_cls); |
2224 | maybe_seek_to_something_interesting (plugin, state); | 2389 | maybe_seek_to_something_interesting (plugin, state); |
2225 | state->state = EBML_READ_ELEMENT; | 2390 | state->state = EBML_READ_ELEMENT; |
@@ -2227,7 +2392,10 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
2227 | free (ebml_stack_pop (state)); | 2392 | free (ebml_stack_pop (state)); |
2228 | break; | 2393 | break; |
2229 | case EBML_FINISHED_READING_MATROSKA_TRACK_ENTRY_CONTENTS: | 2394 | case EBML_FINISHED_READING_MATROSKA_TRACK_ENTRY_CONTENTS: |
2230 | if (state->stack_top != NULL && pl_get_pos (plugin) >= state->stack_top->position + state->stack_top->header_size + state->stack_top->size) | 2395 | if ((state->stack_top != NULL) && (pl_get_pos (plugin) >= |
2396 | state->stack_top->position | ||
2397 | + state->stack_top->header_size | ||
2398 | + state->stack_top->size) ) | ||
2231 | report_state (state, proc, proc_cls); | 2399 | report_state (state, proc, proc_cls); |
2232 | state->state = EBML_READ_ELEMENT; | 2400 | state->state = EBML_READ_ELEMENT; |
2233 | state->next_state = state->stack_top->prev_state; | 2401 | state->next_state = state->stack_top->prev_state; |
@@ -2235,7 +2403,8 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
2235 | break; | 2403 | break; |
2236 | case EBML_FINISHED_READING_MATROSKA_SEEK_CONTENTS: | 2404 | case EBML_FINISHED_READING_MATROSKA_SEEK_CONTENTS: |
2237 | if ((state->matroska_seek_id != 0) && | 2405 | if ((state->matroska_seek_id != 0) && |
2238 | ((state->matroska_seek_position > 0) || state->matroska_seeks_tail == NULL)) | 2406 | ((state->matroska_seek_position > 0) || (state->matroska_seeks_tail == |
2407 | NULL) )) | ||
2239 | { | 2408 | { |
2240 | struct matroska_seek_list *el; | 2409 | struct matroska_seek_list *el; |
2241 | el = malloc (sizeof (struct matroska_seek_list)); | 2410 | el = malloc (sizeof (struct matroska_seek_list)); |
diff --git a/src/plugins/old/elf_extractor.c b/src/plugins/old/elf_extractor.c index 0a14736..9c35e7c 100644 --- a/src/plugins/old/elf_extractor.c +++ b/src/plugins/old/elf_extractor.c | |||
@@ -26,7 +26,7 @@ | |||
26 | typedef uint32_t Elf32_Addr; | 26 | typedef uint32_t Elf32_Addr; |
27 | typedef uint16_t Elf32_Half; | 27 | typedef uint16_t Elf32_Half; |
28 | typedef uint32_t Elf32_Off; | 28 | typedef uint32_t Elf32_Off; |
29 | typedef int32_t Elf32_Sword; | 29 | typedef int32_t Elf32_Sword; |
30 | typedef uint32_t Elf32_Word; | 30 | typedef uint32_t Elf32_Word; |
31 | 31 | ||
32 | typedef uint16_t Elf64_Half; | 32 | typedef uint16_t Elf64_Half; |
@@ -64,57 +64,58 @@ typedef struct | |||
64 | #define ELF_HEADER_SIZE sizeof (Elf32_Ehdr) | 64 | #define ELF_HEADER_SIZE sizeof (Elf32_Ehdr) |
65 | 65 | ||
66 | #define ELF_HEADER_FIELDS(p) \ | 66 | #define ELF_HEADER_FIELDS(p) \ |
67 | &(p)->e_type, \ | 67 | & (p)->e_type, \ |
68 | &(p)->e_machine, \ | 68 | &(p)->e_machine, \ |
69 | &(p)->e_version, \ | 69 | &(p)->e_version, \ |
70 | &(p)->e_entry, \ | 70 | &(p)->e_entry, \ |
71 | &(p)->e_phoff, \ | 71 | &(p)->e_phoff, \ |
72 | &(p)->e_shoff, \ | 72 | &(p)->e_shoff, \ |
73 | &(p)->e_flags, \ | 73 | &(p)->e_flags, \ |
74 | &(p)->e_ehsize, \ | 74 | &(p)->e_ehsize, \ |
75 | &(p)->e_phensize, \ | 75 | &(p)->e_phensize, \ |
76 | &(p)->e_phnum, \ | 76 | &(p)->e_phnum, \ |
77 | &(p)->e_shentsize, \ | 77 | &(p)->e_shentsize, \ |
78 | &(p)->e_shnum, \ | 78 | &(p)->e_shnum, \ |
79 | &(p)->e_shstrndx | 79 | &(p)->e_shstrndx |
80 | static char *ELF_HEADER_SPECS[] = { | 80 | static char *ELF_HEADER_SPECS[] = { |
81 | "hhwwwwwhhhhhh", | 81 | "hhwwwwwhhhhhh", |
82 | "HHWWWWWHHHHHH", | 82 | "HHWWWWWHHHHHH", |
83 | }; | 83 | }; |
84 | 84 | ||
85 | typedef struct { | 85 | typedef struct |
86 | Elf64_Half e_type; | 86 | { |
87 | Elf64_Half e_machine; | 87 | Elf64_Half e_type; |
88 | Elf64_Word e_version; | 88 | Elf64_Half e_machine; |
89 | Elf64_Addr e_entry; | 89 | Elf64_Word e_version; |
90 | Elf64_Off e_phoff; | 90 | Elf64_Addr e_entry; |
91 | Elf64_Off e_shoff; | 91 | Elf64_Off e_phoff; |
92 | Elf64_Word e_flags; | 92 | Elf64_Off e_shoff; |
93 | Elf64_Half e_ehsize; | 93 | Elf64_Word e_flags; |
94 | Elf64_Half e_phensize; | 94 | Elf64_Half e_ehsize; |
95 | Elf64_Half e_phnum; | 95 | Elf64_Half e_phensize; |
96 | Elf64_Half e_shentsize; | 96 | Elf64_Half e_phnum; |
97 | Elf64_Half e_shnum; | 97 | Elf64_Half e_shentsize; |
98 | Elf64_Half e_shstrndx; | 98 | Elf64_Half e_shnum; |
99 | Elf64_Half e_shstrndx; | ||
99 | } Elf64_Ehdr; | 100 | } Elf64_Ehdr; |
100 | 101 | ||
101 | /* elf-header minus e_ident */ | 102 | /* elf-header minus e_ident */ |
102 | #define ELF64_HEADER_SIZE sizeof (Elf64_Ehdr) | 103 | #define ELF64_HEADER_SIZE sizeof (Elf64_Ehdr) |
103 | 104 | ||
104 | #define ELF64_HEADER_FIELDS(p) \ | 105 | #define ELF64_HEADER_FIELDS(p) \ |
105 | &(p)->e_type, \ | 106 | & (p)->e_type, \ |
106 | &(p)->e_machine, \ | 107 | &(p)->e_machine, \ |
107 | &(p)->e_version, \ | 108 | &(p)->e_version, \ |
108 | &(p)->e_entry, \ | 109 | &(p)->e_entry, \ |
109 | &(p)->e_phoff, \ | 110 | &(p)->e_phoff, \ |
110 | &(p)->e_shoff, \ | 111 | &(p)->e_shoff, \ |
111 | &(p)->e_flags, \ | 112 | &(p)->e_flags, \ |
112 | &(p)->e_ehsize, \ | 113 | &(p)->e_ehsize, \ |
113 | &(p)->e_phensize, \ | 114 | &(p)->e_phensize, \ |
114 | &(p)->e_phnum, \ | 115 | &(p)->e_phnum, \ |
115 | &(p)->e_shentsize, \ | 116 | &(p)->e_shentsize, \ |
116 | &(p)->e_shnum, \ | 117 | &(p)->e_shnum, \ |
117 | &(p)->e_shstrndx | 118 | &(p)->e_shstrndx |
118 | static char *ELF64_HEADER_SPECS[] = { | 119 | static char *ELF64_HEADER_SPECS[] = { |
119 | "hhwxxxwhhhhhh", | 120 | "hhwxxxwhhhhhh", |
120 | "HHWXXXWHHHHHH", | 121 | "HHWXXXWHHHHHH", |
@@ -137,16 +138,16 @@ typedef struct | |||
137 | #define ELF_SECTION_SIZE 40 | 138 | #define ELF_SECTION_SIZE 40 |
138 | 139 | ||
139 | #define ELF_SECTION_FIELDS(p) \ | 140 | #define ELF_SECTION_FIELDS(p) \ |
140 | &(p)->sh_name, \ | 141 | & (p)->sh_name, \ |
141 | &(p)->sh_type, \ | 142 | &(p)->sh_type, \ |
142 | &(p)->sh_flags, \ | 143 | &(p)->sh_flags, \ |
143 | &(p)->sh_addr, \ | 144 | &(p)->sh_addr, \ |
144 | &(p)->sh_offset, \ | 145 | &(p)->sh_offset, \ |
145 | &(p)->sh_size, \ | 146 | &(p)->sh_size, \ |
146 | &(p)->sh_link, \ | 147 | &(p)->sh_link, \ |
147 | &(p)->sh_info, \ | 148 | &(p)->sh_info, \ |
148 | &(p)->sh_addralign, \ | 149 | &(p)->sh_addralign, \ |
149 | &(p)->sh_entsize | 150 | &(p)->sh_entsize |
150 | static char *ELF_SECTION_SPECS[] = { | 151 | static char *ELF_SECTION_SPECS[] = { |
151 | "wwwwwwwwww", | 152 | "wwwwwwwwww", |
152 | "WWWWWWWWWW", | 153 | "WWWWWWWWWW", |
@@ -164,15 +165,15 @@ typedef struct | |||
164 | Elf32_Word p_align; | 165 | Elf32_Word p_align; |
165 | } Elf32_Phdr; | 166 | } Elf32_Phdr; |
166 | #define ELF_PDHR_SIZE 32 | 167 | #define ELF_PDHR_SIZE 32 |
167 | #define ELF_PHDR_FIELDS(p) \ | 168 | #define ELF_PHDR_FIELDS(p) \ |
168 | &(p)->p_type, \ | 169 | & (p)->p_type, \ |
169 | &(p)->p_offset, \ | 170 | &(p)->p_offset, \ |
170 | &(p)->p_vaddr, \ | 171 | &(p)->p_vaddr, \ |
171 | &(p)->p_paddr, \ | 172 | &(p)->p_paddr, \ |
172 | &(p)->p_filesz, \ | 173 | &(p)->p_filesz, \ |
173 | &(p)->p_memsz, \ | 174 | &(p)->p_memsz, \ |
174 | &(p)->p_flags, \ | 175 | &(p)->p_flags, \ |
175 | &(p)->p_align | 176 | &(p)->p_align |
176 | static char *ELF_PHDR_SPECS[] = { | 177 | static char *ELF_PHDR_SPECS[] = { |
177 | "wwwwwwww", | 178 | "wwwwwwww", |
178 | "WWWWWWWW", | 179 | "WWWWWWWW", |
@@ -188,9 +189,9 @@ typedef struct | |||
188 | } d_un; | 189 | } d_un; |
189 | } Elf32_Dyn; | 190 | } Elf32_Dyn; |
190 | #define ELF_DYN_SIZE 8 | 191 | #define ELF_DYN_SIZE 8 |
191 | #define ELF_DYN_FIELDS(p) \ | 192 | #define ELF_DYN_FIELDS(p) \ |
192 | &(p)->d_tag, \ | 193 | & (p)->d_tag, \ |
193 | &(p)->d_un | 194 | &(p)->d_un |
194 | static char *ELF_DYN_SPECS[] = { | 195 | static char *ELF_DYN_SPECS[] = { |
195 | "ww", | 196 | "ww", |
196 | "WW", | 197 | "WW", |
@@ -292,8 +293,6 @@ static char *ELF_DYN_SPECS[] = { | |||
292 | #define PT_HIPROC 0x7fffffff | 293 | #define PT_HIPROC 0x7fffffff |
293 | 294 | ||
294 | 295 | ||
295 | |||
296 | |||
297 | #define ELFCLASSNONE 0 | 296 | #define ELFCLASSNONE 0 |
298 | #define ELFCLASS32 1 | 297 | #define ELFCLASS32 1 |
299 | #define ELFCLASS64 2 | 298 | #define ELFCLASS64 2 |
@@ -312,23 +311,24 @@ static int | |||
312 | getByteorder (char ei_data) | 311 | getByteorder (char ei_data) |
313 | { | 312 | { |
314 | if (ei_data == ELFDATA2LSB) | 313 | if (ei_data == ELFDATA2LSB) |
315 | { | 314 | { |
316 | #if __BYTE_ORDER == __BIG_ENDIAN | 315 | #if __BYTE_ORDER == __BIG_ENDIAN |
317 | return 1; | 316 | return 1; |
318 | #else | 317 | #else |
319 | return 0; | 318 | return 0; |
320 | #endif | 319 | #endif |
321 | } | 320 | } |
322 | else | 321 | else |
323 | { | 322 | { |
324 | #if __BYTE_ORDER == __BIG_ENDIAN | 323 | #if __BYTE_ORDER == __BIG_ENDIAN |
325 | return 0; | 324 | return 0; |
326 | #else | 325 | #else |
327 | return 1; | 326 | return 1; |
328 | #endif | 327 | #endif |
329 | } | 328 | } |
330 | } | 329 | } |
331 | 330 | ||
331 | |||
332 | /** | 332 | /** |
333 | * | 333 | * |
334 | * @return 0 on success, -1 on error | 334 | * @return 0 on success, -1 on error |
@@ -336,17 +336,18 @@ getByteorder (char ei_data) | |||
336 | static int | 336 | static int |
337 | getSectionHdr (const char *data, | 337 | getSectionHdr (const char *data, |
338 | size_t size, | 338 | size_t size, |
339 | Elf32_Ehdr * ehdr, Elf32_Half idx, Elf32_Shdr * ret) | 339 | Elf32_Ehdr *ehdr, Elf32_Half idx, Elf32_Shdr *ret) |
340 | { | 340 | { |
341 | if (ehdr->e_shnum <= idx) | 341 | if (ehdr->e_shnum <= idx) |
342 | return -1; | 342 | return -1; |
343 | 343 | ||
344 | EXTRACTOR_common_cat_unpack (&data[ehdr->e_shoff + ehdr->e_shentsize * idx], | 344 | EXTRACTOR_common_cat_unpack (&data[ehdr->e_shoff + ehdr->e_shentsize * idx], |
345 | ELF_SECTION_SPECS[getByteorder (data[EI_CLASS])], | 345 | ELF_SECTION_SPECS[getByteorder (data[EI_CLASS])], |
346 | ELF_SECTION_FIELDS (ret)); | 346 | ELF_SECTION_FIELDS (ret)); |
347 | return 0; | 347 | return 0; |
348 | } | 348 | } |
349 | 349 | ||
350 | |||
350 | /** | 351 | /** |
351 | * | 352 | * |
352 | * @return 0 on success, -1 on error | 353 | * @return 0 on success, -1 on error |
@@ -354,17 +355,18 @@ getSectionHdr (const char *data, | |||
354 | static int | 355 | static int |
355 | getDynTag (const char *data, | 356 | getDynTag (const char *data, |
356 | size_t size, | 357 | size_t size, |
357 | Elf32_Ehdr * ehdr, | 358 | Elf32_Ehdr *ehdr, |
358 | Elf32_Off off, Elf32_Word osize, unsigned int idx, Elf32_Dyn * ret) | 359 | Elf32_Off off, Elf32_Word osize, unsigned int idx, Elf32_Dyn *ret) |
359 | { | 360 | { |
360 | if ((off + osize > size) || ((idx + 1) * ELF_DYN_SIZE > osize)) | 361 | if ((off + osize > size) || ((idx + 1) * ELF_DYN_SIZE > osize)) |
361 | return -1; | 362 | return -1; |
362 | EXTRACTOR_common_cat_unpack (&data[off + idx * ELF_DYN_SIZE], | 363 | EXTRACTOR_common_cat_unpack (&data[off + idx * ELF_DYN_SIZE], |
363 | ELF_DYN_SPECS[getByteorder (data[EI_CLASS])], | 364 | ELF_DYN_SPECS[getByteorder (data[EI_CLASS])], |
364 | ELF_DYN_FIELDS (ret)); | 365 | ELF_DYN_FIELDS (ret)); |
365 | return 0; | 366 | return 0; |
366 | } | 367 | } |
367 | 368 | ||
369 | |||
368 | /** | 370 | /** |
369 | * | 371 | * |
370 | * @return 0 on success, -1 on error | 372 | * @return 0 on success, -1 on error |
@@ -372,26 +374,27 @@ getDynTag (const char *data, | |||
372 | static int | 374 | static int |
373 | getProgramHdr (const char *data, | 375 | getProgramHdr (const char *data, |
374 | size_t size, | 376 | size_t size, |
375 | Elf32_Ehdr * ehdr, Elf32_Half idx, Elf32_Phdr * ret) | 377 | Elf32_Ehdr *ehdr, Elf32_Half idx, Elf32_Phdr *ret) |
376 | { | 378 | { |
377 | if (ehdr->e_phnum <= idx) | 379 | if (ehdr->e_phnum <= idx) |
378 | return -1; | 380 | return -1; |
379 | 381 | ||
380 | EXTRACTOR_common_cat_unpack (&data[ehdr->e_phoff + ehdr->e_phensize * idx], | 382 | EXTRACTOR_common_cat_unpack (&data[ehdr->e_phoff + ehdr->e_phensize * idx], |
381 | ELF_PHDR_SPECS[getByteorder (data[EI_CLASS])], | 383 | ELF_PHDR_SPECS[getByteorder (data[EI_CLASS])], |
382 | ELF_PHDR_FIELDS (ret)); | 384 | ELF_PHDR_FIELDS (ret)); |
383 | return 0; | 385 | return 0; |
384 | } | 386 | } |
385 | 387 | ||
388 | |||
386 | /** | 389 | /** |
387 | * Parse ELF header. | 390 | * Parse ELF header. |
388 | * @return 0 on success for 32 bit, 1 on success for 64 bit, -1 on error | 391 | * @return 0 on success for 32 bit, 1 on success for 64 bit, -1 on error |
389 | */ | 392 | */ |
390 | static int | 393 | static int |
391 | getELFHdr (const char *data, | 394 | getELFHdr (const char *data, |
392 | size_t size, | 395 | size_t size, |
393 | Elf32_Ehdr * ehdr, | 396 | Elf32_Ehdr *ehdr, |
394 | Elf64_Ehdr * ehdr64) | 397 | Elf64_Ehdr *ehdr64) |
395 | { | 398 | { |
396 | /* catlib */ | 399 | /* catlib */ |
397 | if (size < EI_NIDENT) | 400 | if (size < EI_NIDENT) |
@@ -400,43 +403,47 @@ getELFHdr (const char *data, | |||
400 | return -1; /* not an elf */ | 403 | return -1; /* not an elf */ |
401 | 404 | ||
402 | switch (data[EI_CLASS]) | 405 | switch (data[EI_CLASS]) |
403 | { | 406 | { |
404 | case ELFCLASS32: | 407 | case ELFCLASS32: |
405 | if (size < sizeof (Elf32_Ehdr) + EI_NIDENT) | 408 | if (size < sizeof (Elf32_Ehdr) + EI_NIDENT) |
406 | return -1; | ||
407 | EXTRACTOR_common_cat_unpack (&data[EI_NIDENT], | ||
408 | ELF_HEADER_SPECS[getByteorder (data[EI_DATA])], | ||
409 | ELF_HEADER_FIELDS (ehdr)); | ||
410 | if (ehdr->e_shoff + ehdr->e_shentsize * ehdr->e_shnum > size) | ||
411 | return -1; /* invalid offsets... */ | ||
412 | if (ehdr->e_shentsize < ELF_SECTION_SIZE) | ||
413 | return -1; /* huh? */ | ||
414 | if (ehdr->e_phoff + ehdr->e_phensize * ehdr->e_phnum > size) | ||
415 | return -1; | ||
416 | return 0; | ||
417 | case ELFCLASS64: | ||
418 | if (size < sizeof (Elf64_Ehdr) + EI_NIDENT) | ||
419 | return -1; | ||
420 | EXTRACTOR_common_cat_unpack (&data[EI_NIDENT], | ||
421 | ELF64_HEADER_SPECS[getByteorder (data[EI_DATA])], | ||
422 | ELF64_HEADER_FIELDS (ehdr64)); | ||
423 | if (ehdr64->e_shoff + ((uint32_t) ehdr64->e_shentsize * ehdr64->e_shnum) > size) | ||
424 | return -1; /* invalid offsets... */ | ||
425 | if (ehdr64->e_phoff + ((uint32_t) ehdr64->e_phensize * ehdr64->e_phnum) > size) | ||
426 | return -1; | ||
427 | return 1; | ||
428 | default: | ||
429 | return -1; | 409 | return -1; |
430 | } | 410 | EXTRACTOR_common_cat_unpack (&data[EI_NIDENT], |
411 | ELF_HEADER_SPECS[getByteorder (data[EI_DATA])], | ||
412 | ELF_HEADER_FIELDS (ehdr)); | ||
413 | if (ehdr->e_shoff + ehdr->e_shentsize * ehdr->e_shnum > size) | ||
414 | return -1; /* invalid offsets... */ | ||
415 | if (ehdr->e_shentsize < ELF_SECTION_SIZE) | ||
416 | return -1; /* huh? */ | ||
417 | if (ehdr->e_phoff + ehdr->e_phensize * ehdr->e_phnum > size) | ||
418 | return -1; | ||
419 | return 0; | ||
420 | case ELFCLASS64: | ||
421 | if (size < sizeof (Elf64_Ehdr) + EI_NIDENT) | ||
422 | return -1; | ||
423 | EXTRACTOR_common_cat_unpack (&data[EI_NIDENT], | ||
424 | ELF64_HEADER_SPECS[getByteorder ( | ||
425 | data[EI_DATA])], | ||
426 | ELF64_HEADER_FIELDS (ehdr64)); | ||
427 | if (ehdr64->e_shoff + ((uint32_t) ehdr64->e_shentsize * ehdr64->e_shnum) > | ||
428 | size) | ||
429 | return -1; /* invalid offsets... */ | ||
430 | if (ehdr64->e_phoff + ((uint32_t) ehdr64->e_phensize * ehdr64->e_phnum) > | ||
431 | size) | ||
432 | return -1; | ||
433 | return 1; | ||
434 | default: | ||
435 | return -1; | ||
436 | } | ||
431 | } | 437 | } |
432 | 438 | ||
439 | |||
433 | /** | 440 | /** |
434 | * @return the string (offset into data, do NOT free), NULL on error | 441 | * @return the string (offset into data, do NOT free), NULL on error |
435 | */ | 442 | */ |
436 | static const char * | 443 | static const char * |
437 | readStringTable (const char *data, | 444 | readStringTable (const char *data, |
438 | size_t size, | 445 | size_t size, |
439 | Elf32_Ehdr * ehdr, | 446 | Elf32_Ehdr *ehdr, |
440 | Elf32_Half strTableOffset, Elf32_Word sh_name) | 447 | Elf32_Half strTableOffset, Elf32_Word sh_name) |
441 | { | 448 | { |
442 | Elf32_Shdr shrd; | 449 | Elf32_Shdr shrd; |
@@ -450,15 +457,19 @@ readStringTable (const char *data, | |||
450 | return &data[shrd.sh_offset + sh_name]; | 457 | return &data[shrd.sh_offset + sh_name]; |
451 | } | 458 | } |
452 | 459 | ||
453 | #define ADD(s, type) do { if (0!=proc(proc_cls, "elf", type, EXTRACTOR_METAFORMAT_UTF8, "text/plain", s, strlen(s)+1)) return 1; } while (0) | 460 | |
461 | #define ADD(s, type) do { if (0!=proc (proc_cls, "elf", type, \ | ||
462 | EXTRACTOR_METAFORMAT_UTF8, "text/plain", \ | ||
463 | s, strlen (s) + 1)) return 1; \ | ||
464 | } while (0) | ||
454 | 465 | ||
455 | /* application/x-executable, ELF */ | 466 | /* application/x-executable, ELF */ |
456 | int | 467 | int |
457 | EXTRACTOR_elf_extract (const char *data, | 468 | EXTRACTOR_elf_extract (const char *data, |
458 | size_t size, | 469 | size_t size, |
459 | EXTRACTOR_MetaDataProcessor proc, | 470 | EXTRACTOR_MetaDataProcessor proc, |
460 | void *proc_cls, | 471 | void *proc_cls, |
461 | const char *options) | 472 | const char *options) |
462 | { | 473 | { |
463 | Elf32_Ehdr ehdr; | 474 | Elf32_Ehdr ehdr; |
464 | Elf32_Half idx; | 475 | Elf32_Half idx; |
@@ -470,186 +481,186 @@ EXTRACTOR_elf_extract (const char *data, | |||
470 | return 0; | 481 | return 0; |
471 | ADD ("application/x-executable", EXTRACTOR_METATYPE_MIMETYPE); | 482 | ADD ("application/x-executable", EXTRACTOR_METATYPE_MIMETYPE); |
472 | switch ( ((unsigned char*) data)[EI_OSABI]) | 483 | switch ( ((unsigned char*) data)[EI_OSABI]) |
473 | { | 484 | { |
474 | case ELFOSABI_LINUX: | 485 | case ELFOSABI_LINUX: |
475 | ADD ("Linux", EXTRACTOR_METATYPE_TARGET_OS); | 486 | ADD ("Linux", EXTRACTOR_METATYPE_TARGET_OS); |
476 | break; | 487 | break; |
477 | case ELFOSABI_FREEBSD: | 488 | case ELFOSABI_FREEBSD: |
478 | ADD ("FreeBSD", EXTRACTOR_METATYPE_TARGET_OS); | 489 | ADD ("FreeBSD", EXTRACTOR_METATYPE_TARGET_OS); |
479 | break; | 490 | break; |
480 | case ELFOSABI_NETBSD: | 491 | case ELFOSABI_NETBSD: |
481 | ADD ("NetBSD", EXTRACTOR_METATYPE_TARGET_OS); | 492 | ADD ("NetBSD", EXTRACTOR_METATYPE_TARGET_OS); |
482 | break; | 493 | break; |
483 | case ELFOSABI_OPENBSD: | 494 | case ELFOSABI_OPENBSD: |
484 | ADD ("OpenBSD", EXTRACTOR_METATYPE_TARGET_OS); | 495 | ADD ("OpenBSD", EXTRACTOR_METATYPE_TARGET_OS); |
485 | break; | 496 | break; |
486 | case ELFOSABI_IRIX: | 497 | case ELFOSABI_IRIX: |
487 | ADD ("IRIX", EXTRACTOR_METATYPE_TARGET_OS); | 498 | ADD ("IRIX", EXTRACTOR_METATYPE_TARGET_OS); |
488 | break; | 499 | break; |
489 | default: | 500 | default: |
490 | break; | 501 | break; |
491 | } | 502 | } |
492 | switch ( (ret == 0) ? ehdr.e_type : ehdr64.e_type) | 503 | switch ( (ret == 0) ? ehdr.e_type : ehdr64.e_type) |
493 | { | 504 | { |
494 | case ET_REL: | 505 | case ET_REL: |
495 | ADD ("Relocatable file", EXTRACTOR_METATYPE_RESOURCE_TYPE); | 506 | ADD ("Relocatable file", EXTRACTOR_METATYPE_RESOURCE_TYPE); |
496 | break; | 507 | break; |
497 | case ET_EXEC: | 508 | case ET_EXEC: |
498 | ADD ("Executable file", EXTRACTOR_METATYPE_RESOURCE_TYPE); | 509 | ADD ("Executable file", EXTRACTOR_METATYPE_RESOURCE_TYPE); |
499 | break; | 510 | break; |
500 | case ET_DYN: | 511 | case ET_DYN: |
501 | ADD ("Shared object file", EXTRACTOR_METATYPE_RESOURCE_TYPE); | 512 | ADD ("Shared object file", EXTRACTOR_METATYPE_RESOURCE_TYPE); |
502 | break; | 513 | break; |
503 | case ET_CORE: | 514 | case ET_CORE: |
504 | ADD ("Core file", EXTRACTOR_METATYPE_RESOURCE_TYPE); | 515 | ADD ("Core file", EXTRACTOR_METATYPE_RESOURCE_TYPE); |
505 | break; | 516 | break; |
506 | default: | 517 | default: |
507 | break; /* unknown */ | 518 | break; /* unknown */ |
508 | } | 519 | } |
509 | switch ( (ret == 0) ? ehdr.e_machine : ehdr64.e_machine) | 520 | switch ( (ret == 0) ? ehdr.e_machine : ehdr64.e_machine) |
510 | { | 521 | { |
511 | case EM_M32: | 522 | case EM_M32: |
512 | ADD ("M32", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE); | 523 | ADD ("M32", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE); |
513 | break; | 524 | break; |
514 | case EM_386: | 525 | case EM_386: |
515 | ADD ("i386", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE); | 526 | ADD ("i386", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE); |
516 | break; | 527 | break; |
517 | case EM_68K: | 528 | case EM_68K: |
518 | ADD ("68K", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE); | 529 | ADD ("68K", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE); |
519 | break; | 530 | break; |
520 | case EM_88K: | 531 | case EM_88K: |
521 | ADD ("88K", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE); | 532 | ADD ("88K", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE); |
522 | break; | 533 | break; |
523 | case EM_SPARC: | 534 | case EM_SPARC: |
524 | ADD ("Sparc", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE); | 535 | ADD ("Sparc", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE); |
525 | break; | 536 | break; |
526 | case EM_860: | 537 | case EM_860: |
527 | ADD ("960", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE); | 538 | ADD ("960", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE); |
528 | break; | 539 | break; |
529 | case EM_MIPS: | 540 | case EM_MIPS: |
530 | ADD ("MIPS", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE); | 541 | ADD ("MIPS", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE); |
531 | break; | 542 | break; |
532 | case EM_PPC: | 543 | case EM_PPC: |
533 | ADD ("PPC", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE); | 544 | ADD ("PPC", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE); |
534 | break; | 545 | break; |
535 | case EM_PPC64: | 546 | case EM_PPC64: |
536 | ADD ("PPC64", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE); | 547 | ADD ("PPC64", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE); |
537 | break; | 548 | break; |
538 | case EM_S390: | 549 | case EM_S390: |
539 | ADD ("S390", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE); | 550 | ADD ("S390", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE); |
540 | break; | 551 | break; |
541 | case EM_ARM: | 552 | case EM_ARM: |
542 | ADD ("ARM", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE); | 553 | ADD ("ARM", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE); |
543 | break; | 554 | break; |
544 | case EM_ALPHA: | 555 | case EM_ALPHA: |
545 | ADD ("ALPHA", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE); | 556 | ADD ("ALPHA", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE); |
546 | break; | 557 | break; |
547 | case EM_IA_64: | 558 | case EM_IA_64: |
548 | ADD ("IA-64", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE); | 559 | ADD ("IA-64", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE); |
549 | break; | 560 | break; |
550 | case EM_X86_64: | 561 | case EM_X86_64: |
551 | ADD ("x86_64", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE); | 562 | ADD ("x86_64", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE); |
552 | break; | 563 | break; |
553 | case EM_CUDA: | 564 | case EM_CUDA: |
554 | ADD ("NVIDIA CUDA", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE); | 565 | ADD ("NVIDIA CUDA", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE); |
555 | break; | 566 | break; |
556 | default: | 567 | default: |
557 | break; /* oops */ | 568 | break; /* oops */ |
558 | } | 569 | } |
559 | 570 | ||
560 | if (ret != 0) | 571 | if (ret != 0) |
561 | return 0; /* FIXME: full support for 64-bit ELF... */ | 572 | return 0; /* FIXME: full support for 64-bit ELF... */ |
562 | for (idx = 0; idx < ehdr.e_phnum; idx++) | 573 | for (idx = 0; idx < ehdr.e_phnum; idx++) |
563 | { | 574 | { |
564 | Elf32_Phdr phdr; | 575 | Elf32_Phdr phdr; |
565 | 576 | ||
566 | if (0 != getProgramHdr (data, size, &ehdr, idx, &phdr)) | 577 | if (0 != getProgramHdr (data, size, &ehdr, idx, &phdr)) |
578 | return 0; | ||
579 | if (phdr.p_type == PT_DYNAMIC) | ||
580 | { | ||
581 | unsigned int dc = phdr.p_filesz / ELF_DYN_SIZE; | ||
582 | unsigned int id; | ||
583 | Elf32_Addr stringPtr; | ||
584 | Elf32_Half stringIdx; | ||
585 | Elf32_Half six; | ||
586 | |||
587 | stringPtr = 0; | ||
588 | |||
589 | for (id = 0; id < dc; id++) | ||
590 | { | ||
591 | Elf32_Dyn dyn; | ||
592 | if (0 != getDynTag (data, | ||
593 | size, | ||
594 | &ehdr, | ||
595 | phdr.p_offset, phdr.p_filesz, id, &dyn)) | ||
596 | return 0; | ||
597 | if (DT_STRTAB == dyn.d_tag) | ||
598 | { | ||
599 | stringPtr = dyn.d_un.d_ptr; | ||
600 | break; | ||
601 | } | ||
602 | } | ||
603 | if (stringPtr == 0) | ||
567 | return 0; | 604 | return 0; |
568 | if (phdr.p_type == PT_DYNAMIC) | 605 | for (six = 0; six < ehdr.e_shnum; six++) |
606 | { | ||
607 | Elf32_Shdr sec; | ||
608 | if (-1 == getSectionHdr (data, size, &ehdr, six, &sec)) | ||
609 | return 0; | ||
610 | if ((sec.sh_addr == stringPtr) && (sec.sh_type == SHT_STRTAB)) | ||
569 | { | 611 | { |
570 | unsigned int dc = phdr.p_filesz / ELF_DYN_SIZE; | 612 | stringIdx = six; |
571 | unsigned int id; | 613 | break; |
572 | Elf32_Addr stringPtr; | 614 | } |
573 | Elf32_Half stringIdx; | 615 | } |
574 | Elf32_Half six; | 616 | if (six == ehdr.e_shnum) |
575 | 617 | return 0; /* stringIdx not found */ | |
576 | stringPtr = 0; | 618 | |
577 | 619 | for (id = 0; id < dc; id++) | |
578 | for (id = 0; id < dc; id++) | 620 | { |
579 | { | 621 | Elf32_Dyn dyn; |
580 | Elf32_Dyn dyn; | 622 | if (0 != getDynTag (data, |
581 | if (0 != getDynTag (data, | 623 | size, |
582 | size, | 624 | &ehdr, |
583 | &ehdr, | 625 | phdr.p_offset, phdr.p_filesz, id, &dyn)) |
584 | phdr.p_offset, phdr.p_filesz, id, &dyn)) | 626 | return 0; |
585 | return 0; | 627 | switch (dyn.d_tag) |
586 | if (DT_STRTAB == dyn.d_tag) | 628 | { |
587 | { | 629 | case DT_RPATH: |
588 | stringPtr = dyn.d_un.d_ptr; | 630 | { |
589 | break; | 631 | const char *rpath; |
590 | } | 632 | |
591 | } | 633 | rpath = readStringTable (data, |
592 | if (stringPtr == 0) | 634 | size, |
593 | return 0; | 635 | &ehdr, |
594 | for (six = 0; six < ehdr.e_shnum; six++) | 636 | stringIdx, dyn.d_un.d_val); |
637 | /* "source" of the dependencies: path | ||
638 | to dynamic libraries */ | ||
639 | if (rpath != NULL) | ||
595 | { | 640 | { |
596 | Elf32_Shdr sec; | 641 | ADD (rpath, EXTRACTOR_METATYPE_LIBRARY_SEARCH_PATH); |
597 | if (-1 == getSectionHdr (data, size, &ehdr, six, &sec)) | ||
598 | return 0; | ||
599 | if ((sec.sh_addr == stringPtr) && (sec.sh_type == SHT_STRTAB)) | ||
600 | { | ||
601 | stringIdx = six; | ||
602 | break; | ||
603 | } | ||
604 | } | 642 | } |
605 | if (six == ehdr.e_shnum) | 643 | break; |
606 | return 0; /* stringIdx not found */ | 644 | } |
607 | 645 | case DT_NEEDED: | |
608 | for (id = 0; id < dc; id++) | 646 | { |
647 | const char *needed; | ||
648 | |||
649 | needed = readStringTable (data, | ||
650 | size, | ||
651 | &ehdr, | ||
652 | stringIdx, dyn.d_un.d_val); | ||
653 | if (needed != NULL) | ||
609 | { | 654 | { |
610 | Elf32_Dyn dyn; | 655 | ADD (needed, EXTRACTOR_METATYPE_LIBRARY_DEPENDENCY); |
611 | if (0 != getDynTag (data, | ||
612 | size, | ||
613 | &ehdr, | ||
614 | phdr.p_offset, phdr.p_filesz, id, &dyn)) | ||
615 | return 0; | ||
616 | switch (dyn.d_tag) | ||
617 | { | ||
618 | case DT_RPATH: | ||
619 | { | ||
620 | const char *rpath; | ||
621 | |||
622 | rpath = readStringTable (data, | ||
623 | size, | ||
624 | &ehdr, | ||
625 | stringIdx, dyn.d_un.d_val); | ||
626 | /* "source" of the dependencies: path | ||
627 | to dynamic libraries */ | ||
628 | if (rpath != NULL) | ||
629 | { | ||
630 | ADD (rpath, EXTRACTOR_METATYPE_LIBRARY_SEARCH_PATH); | ||
631 | } | ||
632 | break; | ||
633 | } | ||
634 | case DT_NEEDED: | ||
635 | { | ||
636 | const char *needed; | ||
637 | |||
638 | needed = readStringTable (data, | ||
639 | size, | ||
640 | &ehdr, | ||
641 | stringIdx, dyn.d_un.d_val); | ||
642 | if (needed != NULL) | ||
643 | { | ||
644 | ADD (needed, EXTRACTOR_METATYPE_LIBRARY_DEPENDENCY); | ||
645 | } | ||
646 | break; | ||
647 | } | ||
648 | } | ||
649 | } | 656 | } |
650 | 657 | break; | |
658 | } | ||
651 | } | 659 | } |
660 | } | ||
661 | |||
652 | } | 662 | } |
663 | } | ||
653 | 664 | ||
654 | return 0; | 665 | return 0; |
655 | } | 666 | } |
diff --git a/src/plugins/old/flv_extractor.c b/src/plugins/old/flv_extractor.c index f7d762d..2104d79 100644 --- a/src/plugins/old/flv_extractor.c +++ b/src/plugins/old/flv_extractor.c | |||
@@ -55,16 +55,18 @@ | |||
55 | #define ASTYPE_TYPEDOBJECT 0x10 | 55 | #define ASTYPE_TYPEDOBJECT 0x10 |
56 | #define ASTYPE_AMF3DATA 0x11 | 56 | #define ASTYPE_AMF3DATA 0x11 |
57 | 57 | ||
58 | typedef struct { | 58 | typedef struct |
59 | void * userdata; | 59 | { |
60 | void (*as_begin_callback)(unsigned char type, void * userdata); | 60 | void *userdata; |
61 | void (*as_key_callback)(char * key, void * userdata); | 61 | void (*as_begin_callback)(unsigned char type, void *userdata); |
62 | void (*as_end_callback)(unsigned char type, void * value, void * userdata); | 62 | void (*as_key_callback)(char *key, void *userdata); |
63 | void (*as_end_callback)(unsigned char type, void *value, void *userdata); | ||
63 | } AMFParserHandler; | 64 | } AMFParserHandler; |
64 | 65 | ||
65 | /* core datatypes */ | 66 | /* core datatypes */ |
66 | 67 | ||
67 | static uint32_t readInt32(const unsigned char **data) | 68 | static uint32_t |
69 | readInt32 (const unsigned char **data) | ||
68 | { | 70 | { |
69 | const unsigned char *ptr = *data; | 71 | const unsigned char *ptr = *data; |
70 | uint32_t val; | 72 | uint32_t val; |
@@ -75,7 +77,9 @@ static uint32_t readInt32(const unsigned char **data) | |||
75 | return val; | 77 | return val; |
76 | } | 78 | } |
77 | 79 | ||
78 | static uint32_t readInt24(const unsigned char **data) | 80 | |
81 | static uint32_t | ||
82 | readInt24 (const unsigned char **data) | ||
79 | { | 83 | { |
80 | const unsigned char *ptr = *data; | 84 | const unsigned char *ptr = *data; |
81 | uint32_t val; | 85 | uint32_t val; |
@@ -86,7 +90,9 @@ static uint32_t readInt24(const unsigned char **data) | |||
86 | return val; | 90 | return val; |
87 | } | 91 | } |
88 | 92 | ||
89 | static uint16_t readInt16(const unsigned char **data) | 93 | |
94 | static uint16_t | ||
95 | readInt16 (const unsigned char **data) | ||
90 | { | 96 | { |
91 | const unsigned char *ptr = *data; | 97 | const unsigned char *ptr = *data; |
92 | uint16_t val; | 98 | uint16_t val; |
@@ -97,14 +103,17 @@ static uint16_t readInt16(const unsigned char **data) | |||
97 | return val; | 103 | return val; |
98 | } | 104 | } |
99 | 105 | ||
100 | static double readDouble(const unsigned char **data) | 106 | |
107 | static double | ||
108 | readDouble (const unsigned char **data) | ||
101 | { | 109 | { |
102 | const unsigned char *ptr = *data; | 110 | const unsigned char *ptr = *data; |
103 | double val; | 111 | double val; |
104 | 112 | ||
105 | EXTRACTOR_common_floatformat_to_double(&EXTRACTOR_floatformat_ieee_double_big, | 113 | EXTRACTOR_common_floatformat_to_double ( |
106 | (const void *)ptr, | 114 | &EXTRACTOR_floatformat_ieee_double_big, |
107 | &val); | 115 | (const void *) ptr, |
116 | &val); | ||
108 | ptr += 8; | 117 | ptr += 8; |
109 | *data = ptr; | 118 | *data = ptr; |
110 | return val; | 119 | return val; |
@@ -113,9 +122,10 @@ static double readDouble(const unsigned char **data) | |||
113 | 122 | ||
114 | /* actionscript types */ | 123 | /* actionscript types */ |
115 | 124 | ||
116 | static int readASNumber(const unsigned char **data, | 125 | static int |
117 | size_t *len, | 126 | readASNumber (const unsigned char **data, |
118 | double *retval) | 127 | size_t *len, |
128 | double *retval) | ||
119 | { | 129 | { |
120 | const unsigned char *ptr = *data; | 130 | const unsigned char *ptr = *data; |
121 | double val; | 131 | double val; |
@@ -123,7 +133,7 @@ static int readASNumber(const unsigned char **data, | |||
123 | if (*len < 8) | 133 | if (*len < 8) |
124 | return -1; | 134 | return -1; |
125 | 135 | ||
126 | val = readDouble(&ptr); | 136 | val = readDouble (&ptr); |
127 | *len -= 8; | 137 | *len -= 8; |
128 | 138 | ||
129 | *retval = val; | 139 | *retval = val; |
@@ -131,9 +141,11 @@ static int readASNumber(const unsigned char **data, | |||
131 | return 0; | 141 | return 0; |
132 | } | 142 | } |
133 | 143 | ||
134 | static int readASBoolean(const unsigned char **data, | 144 | |
135 | size_t *len, | 145 | static int |
136 | int *retval) | 146 | readASBoolean (const unsigned char **data, |
147 | size_t *len, | ||
148 | int *retval) | ||
137 | { | 149 | { |
138 | const unsigned char *ptr = *data; | 150 | const unsigned char *ptr = *data; |
139 | int val; | 151 | int val; |
@@ -150,29 +162,33 @@ static int readASBoolean(const unsigned char **data, | |||
150 | return 0; | 162 | return 0; |
151 | } | 163 | } |
152 | 164 | ||
153 | static int readASDate(const unsigned char **data, | 165 | |
154 | size_t *len, | 166 | static int |
155 | double *millis, | 167 | readASDate (const unsigned char **data, |
156 | short *zone) | 168 | size_t *len, |
169 | double *millis, | ||
170 | short *zone) | ||
157 | { | 171 | { |
158 | const unsigned char *ptr = *data; | 172 | const unsigned char *ptr = *data; |
159 | 173 | ||
160 | if (*len < 10) | 174 | if (*len < 10) |
161 | return -1; | 175 | return -1; |
162 | 176 | ||
163 | *millis = readDouble(&ptr); | 177 | *millis = readDouble (&ptr); |
164 | *len -= 8; | 178 | *len -= 8; |
165 | 179 | ||
166 | *zone = readInt16(&ptr); | 180 | *zone = readInt16 (&ptr); |
167 | *len -= 2; | 181 | *len -= 2; |
168 | 182 | ||
169 | *data = ptr; | 183 | *data = ptr; |
170 | return 0; | 184 | return 0; |
171 | } | 185 | } |
172 | 186 | ||
173 | static int readASString(const unsigned char **data, | 187 | |
174 | size_t *len, | 188 | static int |
175 | char **retval) | 189 | readASString (const unsigned char **data, |
190 | size_t *len, | ||
191 | char **retval) | ||
176 | { | 192 | { |
177 | const unsigned char *ptr = *data; | 193 | const unsigned char *ptr = *data; |
178 | char *ret; | 194 | char *ret; |
@@ -181,15 +197,15 @@ static int readASString(const unsigned char **data, | |||
181 | if (*len < 2) | 197 | if (*len < 2) |
182 | return -1; | 198 | return -1; |
183 | 199 | ||
184 | slen = readInt16(&ptr); | 200 | slen = readInt16 (&ptr); |
185 | 201 | ||
186 | if (*len < (2 + slen)) | 202 | if (*len < (2 + slen)) |
187 | return -1; | 203 | return -1; |
188 | 204 | ||
189 | ret = malloc(slen+1); | 205 | ret = malloc (slen + 1); |
190 | if (ret == NULL) | 206 | if (ret == NULL) |
191 | return -1; | 207 | return -1; |
192 | memcpy(ret, ptr, slen); | 208 | memcpy (ret, ptr, slen); |
193 | ret[slen] = '\0'; | 209 | ret[slen] = '\0'; |
194 | ptr += slen; | 210 | ptr += slen; |
195 | *len -= (2 + slen); | 211 | *len -= (2 + slen); |
@@ -199,9 +215,11 @@ static int readASString(const unsigned char **data, | |||
199 | return 0; | 215 | return 0; |
200 | } | 216 | } |
201 | 217 | ||
202 | static int parse_amf(const unsigned char **data, | 218 | |
203 | size_t *len, | 219 | static int |
204 | AMFParserHandler *handler) | 220 | parse_amf (const unsigned char **data, |
221 | size_t *len, | ||
222 | AMFParserHandler *handler) | ||
205 | { | 223 | { |
206 | const unsigned char *ptr = *data; | 224 | const unsigned char *ptr = *data; |
207 | unsigned char astype; | 225 | unsigned char astype; |
@@ -210,45 +228,47 @@ static int parse_amf(const unsigned char **data, | |||
210 | ret = 0; | 228 | ret = 0; |
211 | astype = *ptr++; | 229 | astype = *ptr++; |
212 | (*(handler->as_begin_callback))(astype, handler->userdata); | 230 | (*(handler->as_begin_callback))(astype, handler->userdata); |
213 | switch (astype) { | 231 | switch (astype) |
214 | case ASTYPE_NUMBER: | 232 | { |
233 | case ASTYPE_NUMBER: | ||
215 | { | 234 | { |
216 | double val; | 235 | double val; |
217 | ret = readASNumber(&ptr, len, &val); | 236 | ret = readASNumber (&ptr, len, &val); |
218 | if (ret == 0) | 237 | if (ret == 0) |
219 | (*(handler->as_end_callback))(astype, | 238 | (*(handler->as_end_callback))(astype, |
220 | &val, | 239 | &val, |
221 | handler->userdata); | 240 | handler->userdata); |
222 | break; | 241 | break; |
223 | } | 242 | } |
224 | case ASTYPE_BOOLEAN: | 243 | case ASTYPE_BOOLEAN: |
225 | { | 244 | { |
226 | int val; | 245 | int val; |
227 | ret = readASBoolean(&ptr, len, &val); | 246 | ret = readASBoolean (&ptr, len, &val); |
228 | if (ret == 0) | 247 | if (ret == 0) |
229 | (*(handler->as_end_callback))(astype, | 248 | (*(handler->as_end_callback))(astype, |
230 | &val, | 249 | &val, |
231 | handler->userdata); | 250 | handler->userdata); |
232 | break; | 251 | break; |
233 | } | 252 | } |
234 | case ASTYPE_STRING: | 253 | case ASTYPE_STRING: |
235 | { | 254 | { |
236 | char *val; | 255 | char *val; |
237 | ret = readASString(&ptr, len, &val); | 256 | ret = readASString (&ptr, len, &val); |
238 | if (ret == 0) { | 257 | if (ret == 0) |
258 | { | ||
239 | (*(handler->as_end_callback))(astype, | 259 | (*(handler->as_end_callback))(astype, |
240 | val, | 260 | val, |
241 | handler->userdata); | 261 | handler->userdata); |
242 | free(val); | 262 | free (val); |
243 | } | 263 | } |
244 | break; | 264 | break; |
245 | } | 265 | } |
246 | case ASTYPE_DATE: | 266 | case ASTYPE_DATE: |
247 | { | 267 | { |
248 | void *tmp[2]; | 268 | void *tmp[2]; |
249 | double millis; | 269 | double millis; |
250 | short tz; | 270 | short tz; |
251 | ret = readASDate(&ptr, len, &millis, &tz); | 271 | ret = readASDate (&ptr, len, &millis, &tz); |
252 | tmp[0] = &millis; | 272 | tmp[0] = &millis; |
253 | tmp[1] = &tz; | 273 | tmp[1] = &tz; |
254 | if (ret == 0) | 274 | if (ret == 0) |
@@ -257,53 +277,56 @@ static int parse_amf(const unsigned char **data, | |||
257 | handler->userdata); | 277 | handler->userdata); |
258 | break; | 278 | break; |
259 | } | 279 | } |
260 | case ASTYPE_NULL: | 280 | case ASTYPE_NULL: |
261 | case ASTYPE_UNDEFINED: | 281 | case ASTYPE_UNDEFINED: |
262 | case ASTYPE_UNSUPPORTED: | 282 | case ASTYPE_UNSUPPORTED: |
263 | case ASTYPE_ENDOFOBJECT: | 283 | case ASTYPE_ENDOFOBJECT: |
264 | (*(handler->as_end_callback))(astype, NULL, handler->userdata); | 284 | (*(handler->as_end_callback))(astype, NULL, handler->userdata); |
265 | break; | 285 | break; |
266 | case ASTYPE_ARRAY: | 286 | case ASTYPE_ARRAY: |
267 | { | 287 | { |
268 | long i, alen; | 288 | long i, alen; |
269 | if (*len < 4) { | 289 | if (*len < 4) |
290 | { | ||
270 | ret = -1; | 291 | ret = -1; |
271 | break; | 292 | break; |
272 | } | 293 | } |
273 | alen = readInt32(&ptr); | 294 | alen = readInt32 (&ptr); |
274 | *len -= 4; | 295 | *len -= 4; |
275 | for (i = 0; i < alen; i++) { | 296 | for (i = 0; i < alen; i++) |
276 | ret = parse_amf(&ptr, len, handler); | 297 | { |
298 | ret = parse_amf (&ptr, len, handler); | ||
277 | if (ret == -1) | 299 | if (ret == -1) |
278 | break; | 300 | break; |
279 | } | 301 | } |
280 | (*(handler->as_end_callback))(ASTYPE_ARRAY, | 302 | (*(handler->as_end_callback))(ASTYPE_ARRAY, |
281 | NULL, | 303 | NULL, |
282 | handler->userdata); | 304 | handler->userdata); |
283 | break; | 305 | break; |
284 | } | 306 | } |
285 | case ASTYPE_OBJECT: | 307 | case ASTYPE_OBJECT: |
286 | { | 308 | { |
287 | char *key; | 309 | char *key; |
288 | unsigned char type; | 310 | unsigned char type; |
289 | 311 | ||
290 | ret = readASString(&ptr, len, &key); | 312 | ret = readASString (&ptr, len, &key); |
291 | if (ret == -1) | 313 | if (ret == -1) |
292 | break; | 314 | break; |
293 | (*(handler->as_key_callback))(key, | 315 | (*(handler->as_key_callback))(key, |
294 | handler->userdata); | 316 | handler->userdata); |
295 | free(key); | 317 | free (key); |
296 | type = *ptr; | 318 | type = *ptr; |
297 | while (type != ASTYPE_ENDOFOBJECT) { | 319 | while (type != ASTYPE_ENDOFOBJECT) |
298 | ret = parse_amf(&ptr, len, handler); | 320 | { |
321 | ret = parse_amf (&ptr, len, handler); | ||
299 | if (ret == -1) | 322 | if (ret == -1) |
300 | break; | 323 | break; |
301 | ret = readASString(&ptr, len, &key); | 324 | ret = readASString (&ptr, len, &key); |
302 | if (ret == -1) | 325 | if (ret == -1) |
303 | break; | 326 | break; |
304 | (*(handler->as_key_callback))(key, | 327 | (*(handler->as_key_callback))(key, |
305 | handler->userdata); | 328 | handler->userdata); |
306 | free(key); | 329 | free (key); |
307 | type = *ptr; | 330 | type = *ptr; |
308 | } | 331 | } |
309 | if (ret == 0) | 332 | if (ret == 0) |
@@ -312,34 +335,36 @@ static int parse_amf(const unsigned char **data, | |||
312 | handler->userdata); | 335 | handler->userdata); |
313 | break; | 336 | break; |
314 | } | 337 | } |
315 | case ASTYPE_MIXEDARRAY: | 338 | case ASTYPE_MIXEDARRAY: |
316 | { | 339 | { |
317 | char *key; | 340 | char *key; |
318 | unsigned char type; | 341 | unsigned char type; |
319 | 342 | ||
320 | if (*len < 4) { | 343 | if (*len < 4) |
344 | { | ||
321 | ret = -1; | 345 | ret = -1; |
322 | break; | 346 | break; |
323 | } | 347 | } |
324 | /* max_index */ readInt32(&ptr); | 348 | /* max_index */ readInt32 (&ptr); |
325 | *len -= 4; | 349 | *len -= 4; |
326 | ret = readASString(&ptr, len, &key); | 350 | ret = readASString (&ptr, len, &key); |
327 | if (ret == -1) | 351 | if (ret == -1) |
328 | break; | 352 | break; |
329 | (*(handler->as_key_callback))(key, | 353 | (*(handler->as_key_callback))(key, |
330 | handler->userdata); | 354 | handler->userdata); |
331 | free(key); | 355 | free (key); |
332 | type = *ptr; | 356 | type = *ptr; |
333 | while (type != ASTYPE_ENDOFOBJECT) { | 357 | while (type != ASTYPE_ENDOFOBJECT) |
334 | ret = parse_amf(&ptr, len, handler); | 358 | { |
359 | ret = parse_amf (&ptr, len, handler); | ||
335 | if (ret == -1) | 360 | if (ret == -1) |
336 | break; | 361 | break; |
337 | ret = readASString(&ptr, len, &key); | 362 | ret = readASString (&ptr, len, &key); |
338 | if (ret == -1) | 363 | if (ret == -1) |
339 | break; | 364 | break; |
340 | (*(handler->as_key_callback))(key, | 365 | (*(handler->as_key_callback))(key, |
341 | handler->userdata); | 366 | handler->userdata); |
342 | free(key); | 367 | free (key); |
343 | type = *ptr; | 368 | type = *ptr; |
344 | } | 369 | } |
345 | if (ret == 0) | 370 | if (ret == 0) |
@@ -348,21 +373,22 @@ static int parse_amf(const unsigned char **data, | |||
348 | handler->userdata); | 373 | handler->userdata); |
349 | break; | 374 | break; |
350 | } | 375 | } |
351 | default: | 376 | default: |
352 | ret = -1; | 377 | ret = -1; |
353 | (*(handler->as_end_callback))(astype, | 378 | (*(handler->as_end_callback))(astype, |
354 | NULL, | 379 | NULL, |
355 | handler->userdata); | 380 | handler->userdata); |
356 | #if DEBUG | 381 | #if DEBUG |
357 | printf("parse_amf: Unknown type %02x", astype); | 382 | printf ("parse_amf: Unknown type %02x", astype); |
358 | #endif | 383 | #endif |
359 | break; | 384 | break; |
360 | } | 385 | } |
361 | 386 | ||
362 | *data = ptr; | 387 | *data = ptr; |
363 | return ret; | 388 | return ret; |
364 | } | 389 | } |
365 | 390 | ||
391 | |||
366 | /* | 392 | /* |
367 | * FLV parser | 393 | * FLV parser |
368 | */ | 394 | */ |
@@ -379,8 +405,9 @@ flv_to_iso_date (double timeval, short timezone, | |||
379 | * shift epoch to proleptic times | 405 | * shift epoch to proleptic times |
380 | * to make subsequent modulo operations safer. | 406 | * to make subsequent modulo operations safer. |
381 | */ | 407 | */ |
382 | long long my_timeval = (timeval/1000) | 408 | long long my_timeval = (timeval / 1000) |
383 | + ((long long) ((1970 * 365) + 478) * (long long) 86400); | 409 | + ((long long) ((1970 * 365) + 478) * (long |
410 | long) 86400); | ||
384 | 411 | ||
385 | unsigned int seconds = (unsigned int) (my_timeval % 60); | 412 | unsigned int seconds = (unsigned int) (my_timeval % 60); |
386 | unsigned int minutes = (unsigned int) ((my_timeval / 60) % 60); | 413 | unsigned int minutes = (unsigned int) ((my_timeval / 60) % 60); |
@@ -396,7 +423,7 @@ flv_to_iso_date (double timeval, short timezone, | |||
396 | unsigned int days = (unsigned int) (my_timeval / (24 * 3600)); | 423 | unsigned int days = (unsigned int) (my_timeval / (24 * 3600)); |
397 | 424 | ||
398 | unsigned int days_in_month[] = | 425 | unsigned int days_in_month[] = |
399 | { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; | 426 | { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; |
400 | unsigned int diff = 0; | 427 | unsigned int diff = 0; |
401 | 428 | ||
402 | if ((long long) 0 > my_timeval) | 429 | if ((long long) 0 > my_timeval) |
@@ -413,15 +440,15 @@ flv_to_iso_date (double timeval, short timezone, | |||
413 | */ | 440 | */ |
414 | diff = (days / ((365 * 100) + 24)); | 441 | diff = (days / ((365 * 100) + 24)); |
415 | if (4 <= diff) | 442 | if (4 <= diff) |
416 | { | 443 | { |
417 | year += 399; | 444 | year += 399; |
418 | days = 364; | 445 | days = 364; |
419 | } | 446 | } |
420 | else | 447 | else |
421 | { | 448 | { |
422 | year += (100 * diff); | 449 | year += (100 * diff); |
423 | days %= ((365 * 100) + 24); | 450 | days %= ((365 * 100) + 24); |
424 | } | 451 | } |
425 | 452 | ||
426 | /* | 453 | /* |
427 | * remaining leap years | 454 | * remaining leap years |
@@ -430,32 +457,32 @@ flv_to_iso_date (double timeval, short timezone, | |||
430 | days %= ((365 * 4) + 1); | 457 | days %= ((365 * 4) + 1); |
431 | 458 | ||
432 | while (1) | 459 | while (1) |
460 | { | ||
461 | if ((0 == (year % 400)) || ((0 == (year % 4)) && (0 != (year % 100)))) | ||
433 | { | 462 | { |
434 | if ((0 == (year % 400)) || ((0 == (year % 4)) && (0 != (year % 100)))) | 463 | if (366 > days) |
435 | { | 464 | { |
436 | if (366 > days) | 465 | break; |
437 | { | 466 | } |
438 | break; | ||
439 | } | ||
440 | else | ||
441 | { | ||
442 | days -= 366; | ||
443 | year++; | ||
444 | } | ||
445 | } | ||
446 | else | 467 | else |
447 | { | 468 | { |
448 | if (365 > days) | 469 | days -= 366; |
449 | { | 470 | year++; |
450 | break; | 471 | } |
451 | } | 472 | } |
452 | else | 473 | else |
453 | { | 474 | { |
454 | days -= 365; | 475 | if (365 > days) |
455 | year++; | 476 | { |
456 | } | 477 | break; |
457 | } | 478 | } |
479 | else | ||
480 | { | ||
481 | days -= 365; | ||
482 | year++; | ||
483 | } | ||
458 | } | 484 | } |
485 | } | ||
459 | 486 | ||
460 | if ((0 == (year % 400)) || ((0 == (year % 4)) && (0 != (year % 100)))) | 487 | if ((0 == (year % 400)) || ((0 == (year % 4)) && (0 != (year % 100)))) |
461 | days_in_month[1] = 29; | 488 | days_in_month[1] = 29; |
@@ -465,12 +492,12 @@ flv_to_iso_date (double timeval, short timezone, | |||
465 | 492 | ||
466 | zone_sign = 0; | 493 | zone_sign = 0; |
467 | if (timezone < 0) | 494 | if (timezone < 0) |
468 | { | 495 | { |
469 | zone_sign = -1; | 496 | zone_sign = -1; |
470 | timezone = -timezone; | 497 | timezone = -timezone; |
471 | } | 498 | } |
472 | zone_hours = timezone/60; | 499 | zone_hours = timezone / 60; |
473 | zone_minutes = timezone - zone_hours*60; | 500 | zone_minutes = timezone - zone_hours * 60; |
474 | 501 | ||
475 | retval = snprintf (rtime, rsize, "%04u-%02u-%02uT%02u:%02u:%02u%c%02d:%02u", | 502 | retval = snprintf (rtime, rsize, "%04u-%02u-%02uT%02u:%02u:%02u%c%02d:%02u", |
476 | year, month + 1, days + 1, hours, minutes, seconds, | 503 | year, month + 1, days + 1, hours, minutes, seconds, |
@@ -479,6 +506,7 @@ flv_to_iso_date (double timeval, short timezone, | |||
479 | return (retval < rsize) ? 0 : EOVERFLOW; | 506 | return (retval < rsize) ? 0 : EOVERFLOW; |
480 | } | 507 | } |
481 | 508 | ||
509 | |||
482 | typedef struct | 510 | typedef struct |
483 | { | 511 | { |
484 | char signature[3]; | 512 | char signature[3]; |
@@ -503,20 +531,21 @@ typedef struct | |||
503 | 531 | ||
504 | #define FLV_TAG_HEADER_SIZE 11 | 532 | #define FLV_TAG_HEADER_SIZE 11 |
505 | 533 | ||
506 | static int readFLVHeader(const unsigned char **data, | 534 | static int |
507 | const unsigned char *end, | 535 | readFLVHeader (const unsigned char **data, |
508 | FLVHeader *hdr) | 536 | const unsigned char *end, |
537 | FLVHeader *hdr) | ||
509 | { | 538 | { |
510 | const unsigned char *ptr = *data; | 539 | const unsigned char *ptr = *data; |
511 | 540 | ||
512 | if ((ptr + FLV_HEADER_SIZE) > end) | 541 | if ((ptr + FLV_HEADER_SIZE) > end) |
513 | return -1; | 542 | return -1; |
514 | 543 | ||
515 | memcpy(hdr->signature, ptr, 3); | 544 | memcpy (hdr->signature, ptr, 3); |
516 | ptr += 3; | 545 | ptr += 3; |
517 | hdr->version = *ptr++; | 546 | hdr->version = *ptr++; |
518 | hdr->flags = *ptr++; | 547 | hdr->flags = *ptr++; |
519 | hdr->offset = readInt32(&ptr); | 548 | hdr->offset = readInt32 (&ptr); |
520 | if (hdr->offset != FLV_HEADER_SIZE) | 549 | if (hdr->offset != FLV_HEADER_SIZE) |
521 | return -1; | 550 | return -1; |
522 | 551 | ||
@@ -524,24 +553,28 @@ static int readFLVHeader(const unsigned char **data, | |||
524 | return 0; | 553 | return 0; |
525 | } | 554 | } |
526 | 555 | ||
527 | static int readPreviousTagSize(const unsigned char **data, | 556 | |
528 | const unsigned char *end, | 557 | static int |
529 | unsigned long *prev_size) | 558 | readPreviousTagSize (const unsigned char **data, |
559 | const unsigned char *end, | ||
560 | unsigned long *prev_size) | ||
530 | { | 561 | { |
531 | const unsigned char *ptr = *data; | 562 | const unsigned char *ptr = *data; |
532 | 563 | ||
533 | if ((ptr + 4) > end) | 564 | if ((ptr + 4) > end) |
534 | return -1; | 565 | return -1; |
535 | 566 | ||
536 | *prev_size = readInt32(&ptr); | 567 | *prev_size = readInt32 (&ptr); |
537 | 568 | ||
538 | *data = ptr; | 569 | *data = ptr; |
539 | return 0; | 570 | return 0; |
540 | } | 571 | } |
541 | 572 | ||
542 | static int readFLVTagHeader(const unsigned char **data, | 573 | |
543 | const unsigned char *end, | 574 | static int |
544 | FLVTagHeader *hdr) | 575 | readFLVTagHeader (const unsigned char **data, |
576 | const unsigned char *end, | ||
577 | FLVTagHeader *hdr) | ||
545 | { | 578 | { |
546 | const unsigned char *ptr = *data; | 579 | const unsigned char *ptr = *data; |
547 | 580 | ||
@@ -549,15 +582,17 @@ static int readFLVTagHeader(const unsigned char **data, | |||
549 | return -1; | 582 | return -1; |
550 | 583 | ||
551 | hdr->type = *ptr++; | 584 | hdr->type = *ptr++; |
552 | hdr->bodyLength = readInt24(&ptr); | 585 | hdr->bodyLength = readInt24 (&ptr); |
553 | hdr->timestamp = readInt32(&ptr); | 586 | hdr->timestamp = readInt32 (&ptr); |
554 | hdr->streamId = readInt24(&ptr); | 587 | hdr->streamId = readInt24 (&ptr); |
555 | 588 | ||
556 | *data = ptr; | 589 | *data = ptr; |
557 | return 0; | 590 | return 0; |
558 | } | 591 | } |
559 | 592 | ||
560 | typedef struct { | 593 | |
594 | typedef struct | ||
595 | { | ||
561 | int videoCodec; | 596 | int videoCodec; |
562 | char *videoCodecStr; | 597 | char *videoCodecStr; |
563 | int videoWidth; | 598 | int videoWidth; |
@@ -573,7 +608,8 @@ typedef struct { | |||
573 | int audioRate; | 608 | int audioRate; |
574 | } FLVStreamInfo; | 609 | } FLVStreamInfo; |
575 | 610 | ||
576 | typedef enum { | 611 | typedef enum |
612 | { | ||
577 | FLV_NONE = 0, | 613 | FLV_NONE = 0, |
578 | FLV_WIDTH, | 614 | FLV_WIDTH, |
579 | FLV_HEIGHT, | 615 | FLV_HEIGHT, |
@@ -586,7 +622,8 @@ typedef enum { | |||
586 | FLV_ACODECID | 622 | FLV_ACODECID |
587 | } FLVStreamAttribute; | 623 | } FLVStreamAttribute; |
588 | 624 | ||
589 | typedef struct { | 625 | typedef struct |
626 | { | ||
590 | const char *key; | 627 | const char *key; |
591 | FLVStreamAttribute attribute; | 628 | FLVStreamAttribute attribute; |
592 | } MetaKeyToStreamAttribute; | 629 | } MetaKeyToStreamAttribute; |
@@ -605,7 +642,8 @@ static MetaKeyToStreamAttribute key_to_attribute_map[] = { | |||
605 | { NULL, FLV_NONE } | 642 | { NULL, FLV_NONE } |
606 | }; | 643 | }; |
607 | 644 | ||
608 | typedef struct { | 645 | typedef struct |
646 | { | ||
609 | const char *key; | 647 | const char *key; |
610 | enum EXTRACTOR_MetaType type; | 648 | enum EXTRACTOR_MetaType type; |
611 | } MetaKeyToExtractorItem; | 649 | } MetaKeyToExtractorItem; |
@@ -619,7 +657,8 @@ static MetaKeyToExtractorItem key_to_extractor_map[] = { | |||
619 | { NULL, EXTRACTOR_METATYPE_RESERVED } | 657 | { NULL, EXTRACTOR_METATYPE_RESERVED } |
620 | }; | 658 | }; |
621 | 659 | ||
622 | typedef struct { | 660 | typedef struct |
661 | { | ||
623 | int onMetaData; | 662 | int onMetaData; |
624 | int parsingDepth; | 663 | int parsingDepth; |
625 | int ret; | 664 | int ret; |
@@ -632,22 +671,25 @@ typedef struct { | |||
632 | FLVStreamInfo *streamInfo; | 671 | FLVStreamInfo *streamInfo; |
633 | } FLVMetaParserState; | 672 | } FLVMetaParserState; |
634 | 673 | ||
635 | static void handleASBegin(unsigned char type, void * userdata) | 674 | static void |
675 | handleASBegin (unsigned char type, void *userdata) | ||
636 | { | 676 | { |
637 | FLVMetaParserState *state = (FLVMetaParserState *)userdata; | 677 | FLVMetaParserState *state = (FLVMetaParserState *) userdata; |
638 | 678 | ||
639 | if (state->onMetaData && state->parsingDepth == 0 && | 679 | if (state->onMetaData && (state->parsingDepth == 0) && |
640 | type != ASTYPE_MIXEDARRAY) | 680 | (type != ASTYPE_MIXEDARRAY) ) |
641 | state->onMetaData = 0; | 681 | state->onMetaData = 0; |
642 | 682 | ||
643 | if (type == ASTYPE_ARRAY || type == ASTYPE_MIXEDARRAY || | 683 | if ((type == ASTYPE_ARRAY) || (type == ASTYPE_MIXEDARRAY) || |
644 | type == ASTYPE_OBJECT) | 684 | (type == ASTYPE_OBJECT) ) |
645 | state->parsingDepth++; | 685 | state->parsingDepth++; |
646 | } | 686 | } |
647 | 687 | ||
648 | static void handleASKey(char * key, void * userdata) | 688 | |
689 | static void | ||
690 | handleASKey (char *key, void *userdata) | ||
649 | { | 691 | { |
650 | FLVMetaParserState *state = (FLVMetaParserState *)userdata; | 692 | FLVMetaParserState *state = (FLVMetaParserState *) userdata; |
651 | int i; | 693 | int i; |
652 | 694 | ||
653 | if (key == NULL) | 695 | if (key == NULL) |
@@ -655,26 +697,29 @@ static void handleASKey(char * key, void * userdata) | |||
655 | 697 | ||
656 | i = 0; | 698 | i = 0; |
657 | while ((key_to_extractor_map[i].key != NULL) && | 699 | while ((key_to_extractor_map[i].key != NULL) && |
658 | (strcasecmp(key, key_to_extractor_map[i].key) != 0)) | 700 | (strcasecmp (key, key_to_extractor_map[i].key) != 0)) |
659 | i++; | 701 | i++; |
660 | state->currentKeyType = key_to_extractor_map[i].type; | 702 | state->currentKeyType = key_to_extractor_map[i].type; |
661 | 703 | ||
662 | i = 0; | 704 | i = 0; |
663 | while ((key_to_attribute_map[i].key != NULL) && | 705 | while ((key_to_attribute_map[i].key != NULL) && |
664 | (strcasecmp(key, key_to_attribute_map[i].key) != 0)) | 706 | (strcasecmp (key, key_to_attribute_map[i].key) != 0)) |
665 | i++; | 707 | i++; |
666 | state->currentAttribute = key_to_attribute_map[i].attribute; | 708 | state->currentAttribute = key_to_attribute_map[i].attribute; |
667 | } | 709 | } |
668 | 710 | ||
669 | static void handleASEnd(unsigned char type, void * value, void * userdata) | 711 | |
712 | static void | ||
713 | handleASEnd (unsigned char type, void *value, void *userdata) | ||
670 | { | 714 | { |
671 | FLVMetaParserState *state = (FLVMetaParserState *)userdata; | 715 | FLVMetaParserState *state = (FLVMetaParserState *) userdata; |
672 | const char *s; | 716 | const char *s; |
673 | char tmpstr[30]; | 717 | char tmpstr[30]; |
674 | 718 | ||
675 | if ((state->parsingDepth == 0) && (type == ASTYPE_STRING)) { | 719 | if ((state->parsingDepth == 0) && (type == ASTYPE_STRING)) |
676 | s = (const char *)value; | 720 | { |
677 | if (!strcmp(s, "onMetaData")) | 721 | s = (const char *) value; |
722 | if (! strcmp (s, "onMetaData")) | ||
678 | state->onMetaData = 1; | 723 | state->onMetaData = 1; |
679 | } | 724 | } |
680 | 725 | ||
@@ -686,50 +731,53 @@ static void handleASEnd(unsigned char type, void * value, void * userdata) | |||
686 | (state->currentAttribute != FLV_NONE) && | 731 | (state->currentAttribute != FLV_NONE) && |
687 | (type == ASTYPE_NUMBER)) | 732 | (type == ASTYPE_NUMBER)) |
688 | { | 733 | { |
689 | double n = *((double *)value); | 734 | double n = *((double *) value); |
690 | switch (state->currentAttribute) { | 735 | switch (state->currentAttribute) |
691 | case FLV_NONE: /* make gcc happy */ | 736 | { |
692 | break; | 737 | case FLV_NONE: /* make gcc happy */ |
693 | case FLV_STEREO: | 738 | break; |
694 | break; | 739 | case FLV_STEREO: |
695 | case FLV_ACHANNELS: | 740 | break; |
696 | state->streamInfo->audioChannels = n; | 741 | case FLV_ACHANNELS: |
697 | break; | 742 | state->streamInfo->audioChannels = n; |
698 | case FLV_WIDTH: | 743 | break; |
699 | if (state->streamInfo->videoWidth == -1) | 744 | case FLV_WIDTH: |
700 | state->streamInfo->videoWidth = n; | 745 | if (state->streamInfo->videoWidth == -1) |
701 | break; | 746 | state->streamInfo->videoWidth = n; |
702 | case FLV_HEIGHT: | 747 | break; |
703 | if (state->streamInfo->videoHeight == -1) | 748 | case FLV_HEIGHT: |
704 | state->streamInfo->videoHeight = n; | 749 | if (state->streamInfo->videoHeight == -1) |
705 | break; | 750 | state->streamInfo->videoHeight = n; |
706 | case FLV_FRAMERATE: | 751 | break; |
707 | state->streamInfo->videoFrameRate = n; | 752 | case FLV_FRAMERATE: |
708 | break; | 753 | state->streamInfo->videoFrameRate = n; |
709 | case FLV_VDATARATE: | 754 | break; |
710 | state->streamInfo->videoDataRate = n; | 755 | case FLV_VDATARATE: |
711 | break; | 756 | state->streamInfo->videoDataRate = n; |
712 | case FLV_ADATARATE: | 757 | break; |
713 | state->streamInfo->audioDataRate = n; | 758 | case FLV_ADATARATE: |
714 | break; | 759 | state->streamInfo->audioDataRate = n; |
715 | case FLV_VCODECID: | 760 | break; |
716 | if (state->streamInfo->videoCodec == -1) | 761 | case FLV_VCODECID: |
717 | state->streamInfo->videoCodec = n; | 762 | if (state->streamInfo->videoCodec == -1) |
718 | /* prefer codec ids to fourcc codes */ | 763 | state->streamInfo->videoCodec = n; |
719 | if (state->streamInfo->videoCodecStr != NULL) { | 764 | /* prefer codec ids to fourcc codes */ |
720 | free(state->streamInfo->videoCodecStr); | 765 | if (state->streamInfo->videoCodecStr != NULL) |
721 | state->streamInfo->videoCodecStr = NULL; | 766 | { |
722 | } | 767 | free (state->streamInfo->videoCodecStr); |
723 | break; | 768 | state->streamInfo->videoCodecStr = NULL; |
724 | case FLV_ACODECID: | 769 | } |
725 | if (state->streamInfo->audioCodec == -1) | 770 | break; |
726 | state->streamInfo->audioCodec = n; | 771 | case FLV_ACODECID: |
727 | /* prefer codec ids to fourcc codes */ | 772 | if (state->streamInfo->audioCodec == -1) |
728 | if (state->streamInfo->audioCodecStr != NULL) { | 773 | state->streamInfo->audioCodec = n; |
729 | free(state->streamInfo->audioCodecStr); | 774 | /* prefer codec ids to fourcc codes */ |
730 | state->streamInfo->audioCodecStr = NULL; | 775 | if (state->streamInfo->audioCodecStr != NULL) |
731 | } | 776 | { |
732 | break; | 777 | free (state->streamInfo->audioCodecStr); |
778 | state->streamInfo->audioCodecStr = NULL; | ||
779 | } | ||
780 | break; | ||
733 | } | 781 | } |
734 | } | 782 | } |
735 | 783 | ||
@@ -738,20 +786,21 @@ static void handleASEnd(unsigned char type, void * value, void * userdata) | |||
738 | (state->currentAttribute != FLV_NONE) && | 786 | (state->currentAttribute != FLV_NONE) && |
739 | (type == ASTYPE_STRING)) | 787 | (type == ASTYPE_STRING)) |
740 | { | 788 | { |
741 | s = (const char *)value; | 789 | s = (const char *) value; |
742 | switch (state->currentAttribute) { | 790 | switch (state->currentAttribute) |
743 | case FLV_VCODECID: | 791 | { |
744 | if (s != NULL && state->streamInfo->videoCodecStr == NULL && | 792 | case FLV_VCODECID: |
745 | state->streamInfo->videoCodec == -1) | 793 | if ((s != NULL) && (state->streamInfo->videoCodecStr == NULL) && |
746 | state->streamInfo->videoCodecStr = strdup(s); | 794 | (state->streamInfo->videoCodec == -1) ) |
747 | break; | 795 | state->streamInfo->videoCodecStr = strdup (s); |
748 | case FLV_ACODECID: | 796 | break; |
749 | if (s != NULL && state->streamInfo->audioCodecStr == NULL && | 797 | case FLV_ACODECID: |
750 | state->streamInfo->audioCodec == -1) | 798 | if ((s != NULL) && (state->streamInfo->audioCodecStr == NULL) && |
751 | state->streamInfo->audioCodecStr = strdup(s); | 799 | (state->streamInfo->audioCodec == -1) ) |
752 | break; | 800 | state->streamInfo->audioCodecStr = strdup (s); |
753 | default: | 801 | break; |
754 | break; | 802 | default: |
803 | break; | ||
755 | } | 804 | } |
756 | } | 805 | } |
757 | 806 | ||
@@ -759,7 +808,7 @@ static void handleASEnd(unsigned char type, void * value, void * userdata) | |||
759 | (state->currentAttribute == FLV_STEREO) && | 808 | (state->currentAttribute == FLV_STEREO) && |
760 | (type == ASTYPE_BOOLEAN)) | 809 | (type == ASTYPE_BOOLEAN)) |
761 | { | 810 | { |
762 | int n = *((int *)value); | 811 | int n = *((int *) value); |
763 | if (state->streamInfo->audioChannels == -1) | 812 | if (state->streamInfo->audioChannels == -1) |
764 | state->streamInfo->audioChannels = (n == 0) ? 1 : 2; | 813 | state->streamInfo->audioChannels = (n == 0) ? 1 : 2; |
765 | } | 814 | } |
@@ -769,57 +818,59 @@ static void handleASEnd(unsigned char type, void * value, void * userdata) | |||
769 | (state->currentKeyType != EXTRACTOR_METATYPE_RESERVED)) | 818 | (state->currentKeyType != EXTRACTOR_METATYPE_RESERVED)) |
770 | { | 819 | { |
771 | s = NULL; | 820 | s = NULL; |
772 | switch (type) { | 821 | switch (type) |
773 | case ASTYPE_NUMBER: | 822 | { |
823 | case ASTYPE_NUMBER: | ||
774 | { | 824 | { |
775 | double n = *((double *)value); | 825 | double n = *((double *) value); |
776 | s = tmpstr; | 826 | s = tmpstr; |
777 | if (state->currentKeyType == EXTRACTOR_METATYPE_DURATION) | 827 | if (state->currentKeyType == EXTRACTOR_METATYPE_DURATION) |
778 | snprintf(tmpstr, sizeof(tmpstr), "%.2f s", n); | 828 | snprintf (tmpstr, sizeof(tmpstr), "%.2f s", n); |
779 | else | 829 | else |
780 | snprintf(tmpstr, sizeof(tmpstr), "%f", n); | 830 | snprintf (tmpstr, sizeof(tmpstr), "%f", n); |
781 | break; | 831 | break; |
782 | } | 832 | } |
783 | case ASTYPE_STRING: | 833 | case ASTYPE_STRING: |
784 | { | 834 | { |
785 | s = (char *)value; | 835 | s = (char *) value; |
786 | break; | 836 | break; |
787 | } | 837 | } |
788 | case ASTYPE_DATE: | 838 | case ASTYPE_DATE: |
789 | { | 839 | { |
790 | void **tmp = (void **)value; | 840 | void **tmp = (void **) value; |
791 | double *millis; | 841 | double *millis; |
792 | short *tz; | 842 | short *tz; |
793 | millis = (double *)tmp[0]; | 843 | millis = (double *) tmp[0]; |
794 | tz = (short *)tmp[1]; | 844 | tz = (short *) tmp[1]; |
795 | if (0 == flv_to_iso_date(*millis, *tz, tmpstr, sizeof(tmpstr))) | 845 | if (0 == flv_to_iso_date (*millis, *tz, tmpstr, sizeof(tmpstr))) |
796 | s = tmpstr; | 846 | s = tmpstr; |
797 | break; | 847 | break; |
798 | } | 848 | } |
799 | } | 849 | } |
800 | if ( (s != NULL) && | 850 | if ( (s != NULL) && |
801 | (state->ret == 0) ) | 851 | (state->ret == 0) ) |
802 | state->ret = state->proc (state->proc_cls, | 852 | state->ret = state->proc (state->proc_cls, |
803 | "flv", | 853 | "flv", |
804 | state->currentKeyType, | 854 | state->currentKeyType, |
805 | EXTRACTOR_METAFORMAT_UTF8, | 855 | EXTRACTOR_METAFORMAT_UTF8, |
806 | "text/plain", | 856 | "text/plain", |
807 | s, | 857 | s, |
808 | strlen (s) + 1); | 858 | strlen (s) + 1); |
809 | } | 859 | } |
810 | state->currentKeyType = EXTRACTOR_METATYPE_RESERVED; | 860 | state->currentKeyType = EXTRACTOR_METATYPE_RESERVED; |
811 | state->currentAttribute = FLV_NONE; | 861 | state->currentAttribute = FLV_NONE; |
812 | 862 | ||
813 | if (type == ASTYPE_ARRAY || type == ASTYPE_MIXEDARRAY || | 863 | if ((type == ASTYPE_ARRAY) || (type == ASTYPE_MIXEDARRAY) || |
814 | type == ASTYPE_OBJECT) | 864 | (type == ASTYPE_OBJECT) ) |
815 | state->parsingDepth--; | 865 | state->parsingDepth--; |
816 | } | 866 | } |
817 | 867 | ||
868 | |||
818 | static int | 869 | static int |
819 | handleMetaBody(const unsigned char *data, size_t len, | 870 | handleMetaBody (const unsigned char *data, size_t len, |
820 | FLVStreamInfo *stinfo, | 871 | FLVStreamInfo *stinfo, |
821 | EXTRACTOR_MetaDataProcessor proc, | 872 | EXTRACTOR_MetaDataProcessor proc, |
822 | void *proc_cls) | 873 | void *proc_cls) |
823 | { | 874 | { |
824 | AMFParserHandler handler; | 875 | AMFParserHandler handler; |
825 | FLVMetaParserState pstate; | 876 | FLVMetaParserState pstate; |
@@ -836,12 +887,14 @@ handleMetaBody(const unsigned char *data, size_t len, | |||
836 | handler.as_key_callback = &handleASKey; | 887 | handler.as_key_callback = &handleASKey; |
837 | handler.as_end_callback = &handleASEnd; | 888 | handler.as_end_callback = &handleASEnd; |
838 | 889 | ||
839 | while (len > 0 && parse_amf(&data, &len, &handler) == 0); | 890 | while (len > 0 && parse_amf (&data, &len, &handler) == 0) |
891 | ; | ||
840 | if (pstate.ret != 0) | 892 | if (pstate.ret != 0) |
841 | return 1; | 893 | return 1; |
842 | return 0; | 894 | return 0; |
843 | } | 895 | } |
844 | 896 | ||
897 | |||
845 | static char *FLVAudioCodecs[] = { | 898 | static char *FLVAudioCodecs[] = { |
846 | "Uncompressed", | 899 | "Uncompressed", |
847 | "ADPCM", | 900 | "ADPCM", |
@@ -875,19 +928,21 @@ static char *FLVAudioSampleRates[] = { | |||
875 | }; | 928 | }; |
876 | 929 | ||
877 | static void | 930 | static void |
878 | handleAudioBody(const unsigned char *data, size_t len, | 931 | handleAudioBody (const unsigned char *data, size_t len, |
879 | FLVStreamInfo *stinfo) | 932 | FLVStreamInfo *stinfo) |
880 | { | 933 | { |
881 | stinfo->audioChannels = (*data & 0x01) + 1; | 934 | stinfo->audioChannels = (*data & 0x01) + 1; |
882 | stinfo->audioSampleBits = (*data & 0x02) >> 1; | 935 | stinfo->audioSampleBits = (*data & 0x02) >> 1; |
883 | stinfo->audioRate = (*data & 0x0C) >> 2; | 936 | stinfo->audioRate = (*data & 0x0C) >> 2; |
884 | stinfo->audioCodec = (*data & 0xF0) >> 4; | 937 | stinfo->audioCodec = (*data & 0xF0) >> 4; |
885 | if (stinfo->audioCodecStr != NULL) { | 938 | if (stinfo->audioCodecStr != NULL) |
886 | free(stinfo->audioCodecStr); | 939 | { |
940 | free (stinfo->audioCodecStr); | ||
887 | stinfo->audioCodecStr = NULL; | 941 | stinfo->audioCodecStr = NULL; |
888 | } | 942 | } |
889 | } | 943 | } |
890 | 944 | ||
945 | |||
891 | static char *FLVVideoCodecs[] = { | 946 | static char *FLVVideoCodecs[] = { |
892 | NULL, | 947 | NULL, |
893 | NULL, | 948 | NULL, |
@@ -911,8 +966,8 @@ static int sorenson_predefined_res[][2] = { | |||
911 | }; | 966 | }; |
912 | 967 | ||
913 | static void | 968 | static void |
914 | handleVideoBody(const unsigned char *data, size_t len, | 969 | handleVideoBody (const unsigned char *data, size_t len, |
915 | FLVStreamInfo *stinfo) | 970 | FLVStreamInfo *stinfo) |
916 | { | 971 | { |
917 | int codecId, frameType; | 972 | int codecId, frameType; |
918 | 973 | ||
@@ -921,84 +976,94 @@ handleVideoBody(const unsigned char *data, size_t len, | |||
921 | data++; | 976 | data++; |
922 | 977 | ||
923 | /* try to get video dimensions */ | 978 | /* try to get video dimensions */ |
924 | switch (codecId) { | 979 | switch (codecId) |
925 | case 0x02: /* Sorenson */ | 980 | { |
926 | if (len < 9) | 981 | case 0x02: /* Sorenson */ |
927 | break; | 982 | if (len < 9) |
928 | if (frameType == 1) { | ||
929 | int start_code = (data[0] << 9) | (data[1] << 1) | ((data[2] >> 7)&0x1); | ||
930 | int version = (data[2] & 0x7C) >> 2; | ||
931 | int frame_size = ((data[3] & 0x03) << 1) | (data[4] >> 7); | ||
932 | if (start_code != 0x00000001) | ||
933 | break; | ||
934 | if (!(version == 0 || version == 1)) | ||
935 | break; | ||
936 | if (frame_size == 0) { | ||
937 | stinfo->videoWidth = ((data[4] & 0x7F) >> 1) | (data[5] >> 7); | ||
938 | stinfo->videoHeight = ((data[5] & 0x7F) >> 1) | (data[6] >> 7); | ||
939 | } | ||
940 | else if (frame_size == 1) { | ||
941 | stinfo->videoWidth = ((data[4] & 0x7F) << 9) | (data[5] << 1) | | ||
942 | (data[6] >> 7); | ||
943 | stinfo->videoHeight = ((data[6] & 0x7F) << 9) | (data[7] << 1) | | ||
944 | (data[8] >> 7); | ||
945 | } | ||
946 | else { | ||
947 | stinfo->videoWidth = sorenson_predefined_res[frame_size][0]; | ||
948 | stinfo->videoHeight = sorenson_predefined_res[frame_size][1]; | ||
949 | } | ||
950 | } | ||
951 | break; | 983 | break; |
952 | case 0x03: /* ScreenVideo */ | 984 | if (frameType == 1) |
953 | if (len < 5) | 985 | { |
986 | int start_code = (data[0] << 9) | (data[1] << 1) | ((data[2] >> 7) & 0x1); | ||
987 | int version = (data[2] & 0x7C) >> 2; | ||
988 | int frame_size = ((data[3] & 0x03) << 1) | (data[4] >> 7); | ||
989 | if (start_code != 0x00000001) | ||
954 | break; | 990 | break; |
955 | stinfo->videoWidth = readInt16(&data) & 0x0FFF; | 991 | if (! ((version == 0) || (version == 1) )) |
956 | stinfo->videoHeight = readInt16(&data) & 0x0FFF; | 992 | break; |
993 | if (frame_size == 0) | ||
994 | { | ||
995 | stinfo->videoWidth = ((data[4] & 0x7F) >> 1) | (data[5] >> 7); | ||
996 | stinfo->videoHeight = ((data[5] & 0x7F) >> 1) | (data[6] >> 7); | ||
997 | } | ||
998 | else if (frame_size == 1) | ||
999 | { | ||
1000 | stinfo->videoWidth = ((data[4] & 0x7F) << 9) | (data[5] << 1) | ||
1001 | | (data[6] >> 7); | ||
1002 | stinfo->videoHeight = ((data[6] & 0x7F) << 9) | (data[7] << 1) | ||
1003 | | (data[8] >> 7); | ||
1004 | } | ||
1005 | else | ||
1006 | { | ||
1007 | stinfo->videoWidth = sorenson_predefined_res[frame_size][0]; | ||
1008 | stinfo->videoHeight = sorenson_predefined_res[frame_size][1]; | ||
1009 | } | ||
1010 | } | ||
1011 | break; | ||
1012 | case 0x03: /* ScreenVideo */ | ||
1013 | if (len < 5) | ||
957 | break; | 1014 | break; |
958 | case 0x04: /* On2 VP6 */ | 1015 | stinfo->videoWidth = readInt16 (&data) & 0x0FFF; |
959 | case 0x05: | 1016 | stinfo->videoHeight = readInt16 (&data) & 0x0FFF; |
1017 | break; | ||
1018 | case 0x04: /* On2 VP6 */ | ||
1019 | case 0x05: | ||
960 | { | 1020 | { |
961 | unsigned char dim_adj; | 1021 | unsigned char dim_adj; |
962 | if (len < 10) | 1022 | if (len < 10) |
963 | break; | 1023 | break; |
964 | dim_adj = *data++; | 1024 | dim_adj = *data++; |
965 | if ((frameType == 1) && ((data[0] & 0x80) == 0)) { | 1025 | if ((frameType == 1) && ((data[0] & 0x80) == 0)) |
1026 | { | ||
966 | /* see ffmpeg vp6 decoder */ | 1027 | /* see ffmpeg vp6 decoder */ |
967 | int separated_coeff = data[0] & 0x01; | 1028 | int separated_coeff = data[0] & 0x01; |
968 | int filter_header = data[1] & 0x06; | 1029 | int filter_header = data[1] & 0x06; |
969 | /*int interlaced = data[1] & 0x01; TODO: used in flv ever? */ | 1030 | /*int interlaced = data[1] & 0x01; TODO: used in flv ever? */ |
970 | if (separated_coeff || !filter_header) { | 1031 | if (separated_coeff || ! filter_header) |
1032 | { | ||
971 | data += 2; | 1033 | data += 2; |
972 | } | 1034 | } |
973 | /* XXX encoded/displayed dimensions might vary, but which are the | 1035 | /* XXX encoded/displayed dimensions might vary, but which are the |
974 | * right ones? */ | 1036 | * right ones? */ |
975 | stinfo->videoWidth = (data[3]*16) - (dim_adj>>4); | 1037 | stinfo->videoWidth = (data[3] * 16) - (dim_adj >> 4); |
976 | stinfo->videoHeight = (data[2]*16) - (dim_adj&0x0F); | 1038 | stinfo->videoHeight = (data[2] * 16) - (dim_adj & 0x0F); |
977 | } | 1039 | } |
978 | break; | 1040 | break; |
979 | } | 1041 | } |
980 | default: | 1042 | default: |
981 | break; | 1043 | break; |
982 | } | 1044 | } |
983 | 1045 | ||
984 | stinfo->videoCodec = codecId; | 1046 | stinfo->videoCodec = codecId; |
985 | if (stinfo->videoCodecStr != NULL) { | 1047 | if (stinfo->videoCodecStr != NULL) |
986 | free(stinfo->videoCodecStr); | 1048 | { |
1049 | free (stinfo->videoCodecStr); | ||
987 | stinfo->videoCodecStr = NULL; | 1050 | stinfo->videoCodecStr = NULL; |
988 | } | 1051 | } |
989 | } | 1052 | } |
990 | 1053 | ||
991 | static int readFLVTag(const unsigned char **data, | 1054 | |
992 | const unsigned char *end, | 1055 | static int |
993 | FLVStreamInfo *stinfo, | 1056 | readFLVTag (const unsigned char **data, |
994 | EXTRACTOR_MetaDataProcessor proc, | 1057 | const unsigned char *end, |
995 | void *proc_cls) | 1058 | FLVStreamInfo *stinfo, |
1059 | EXTRACTOR_MetaDataProcessor proc, | ||
1060 | void *proc_cls) | ||
996 | { | 1061 | { |
997 | const unsigned char *ptr = *data; | 1062 | const unsigned char *ptr = *data; |
998 | FLVTagHeader header; | 1063 | FLVTagHeader header; |
999 | int ret = 0; | 1064 | int ret = 0; |
1000 | 1065 | ||
1001 | if (readFLVTagHeader(&ptr, end, &header) == -1) | 1066 | if (readFLVTagHeader (&ptr, end, &header) == -1) |
1002 | return -1; | 1067 | return -1; |
1003 | 1068 | ||
1004 | if ((ptr + header.bodyLength) > end) | 1069 | if ((ptr + header.bodyLength) > end) |
@@ -1006,17 +1071,17 @@ static int readFLVTag(const unsigned char **data, | |||
1006 | 1071 | ||
1007 | switch (header.type) | 1072 | switch (header.type) |
1008 | { | 1073 | { |
1009 | case FLV_TAG_TYPE_AUDIO: | 1074 | case FLV_TAG_TYPE_AUDIO: |
1010 | handleAudioBody(ptr, header.bodyLength, stinfo); | 1075 | handleAudioBody (ptr, header.bodyLength, stinfo); |
1011 | break; | 1076 | break; |
1012 | case FLV_TAG_TYPE_VIDEO: | 1077 | case FLV_TAG_TYPE_VIDEO: |
1013 | handleVideoBody(ptr, header.bodyLength, stinfo); | 1078 | handleVideoBody (ptr, header.bodyLength, stinfo); |
1014 | break; | 1079 | break; |
1015 | case FLV_TAG_TYPE_META: | 1080 | case FLV_TAG_TYPE_META: |
1016 | ret = handleMetaBody(ptr, header.bodyLength, stinfo, proc, proc_cls); | 1081 | ret = handleMetaBody (ptr, header.bodyLength, stinfo, proc, proc_cls); |
1017 | break; | 1082 | break; |
1018 | default: | 1083 | default: |
1019 | break; | 1084 | break; |
1020 | } | 1085 | } |
1021 | 1086 | ||
1022 | ptr += header.bodyLength; | 1087 | ptr += header.bodyLength; |
@@ -1024,129 +1089,149 @@ static int readFLVTag(const unsigned char **data, | |||
1024 | return ret; | 1089 | return ret; |
1025 | } | 1090 | } |
1026 | 1091 | ||
1092 | |||
1027 | #define MAX_FLV_FORMAT_LINE 80 | 1093 | #define MAX_FLV_FORMAT_LINE 80 |
1028 | static char * printVideoFormat(FLVStreamInfo *stinfo) | 1094 | static char * |
1095 | printVideoFormat (FLVStreamInfo *stinfo) | ||
1029 | { | 1096 | { |
1030 | char s[MAX_FLV_FORMAT_LINE+1]; | 1097 | char s[MAX_FLV_FORMAT_LINE + 1]; |
1031 | int n; | 1098 | int n; |
1032 | size_t len = MAX_FLV_FORMAT_LINE; | 1099 | size_t len = MAX_FLV_FORMAT_LINE; |
1033 | 1100 | ||
1034 | n = 0; | 1101 | n = 0; |
1035 | /* some files seem to specify only the width or the height, print '?' for | 1102 | /* some files seem to specify only the width or the height, print '?' for |
1036 | * the unknown dimension */ | 1103 | * the unknown dimension */ |
1037 | if (stinfo->videoWidth != -1 || stinfo->videoHeight != -1) { | 1104 | if ((stinfo->videoWidth != -1) || (stinfo->videoHeight != -1)) |
1038 | if (n < len) { | 1105 | { |
1106 | if (n < len) | ||
1107 | { | ||
1039 | if (stinfo->videoWidth != -1) | 1108 | if (stinfo->videoWidth != -1) |
1040 | n += snprintf(s+n, len-n, "%d", stinfo->videoWidth); | 1109 | n += snprintf (s + n, len - n, "%d", stinfo->videoWidth); |
1041 | else | 1110 | else |
1042 | n += snprintf(s+n, len-n, "?"); | 1111 | n += snprintf (s + n, len - n, "?"); |
1043 | } | 1112 | } |
1044 | 1113 | ||
1045 | if (n < len) { | 1114 | if (n < len) |
1115 | { | ||
1046 | if (stinfo->videoHeight != -1) | 1116 | if (stinfo->videoHeight != -1) |
1047 | n += snprintf(s+n, len-n, "x%d", stinfo->videoHeight); | 1117 | n += snprintf (s + n, len - n, "x%d", stinfo->videoHeight); |
1048 | else | 1118 | else |
1049 | n += snprintf(s+n, len-n, "x?"); | 1119 | n += snprintf (s + n, len - n, "x?"); |
1050 | } | 1120 | } |
1051 | } | 1121 | } |
1052 | 1122 | ||
1053 | if (stinfo->videoFrameRate != 0.0 && n < len) { | 1123 | if ((stinfo->videoFrameRate != 0.0) && (n < len)) |
1124 | { | ||
1054 | if (n > 0) | 1125 | if (n > 0) |
1055 | n += snprintf(s+n, len-n, ", "); | 1126 | n += snprintf (s + n, len - n, ", "); |
1056 | if (n < len) | 1127 | if (n < len) |
1057 | n += snprintf(s+n, len-n, "%0.2f fps", stinfo->videoFrameRate); | 1128 | n += snprintf (s + n, len - n, "%0.2f fps", stinfo->videoFrameRate); |
1058 | } | 1129 | } |
1059 | 1130 | ||
1060 | if (stinfo->videoCodec > -1 && stinfo->videoCodec < 8 && | 1131 | if ((stinfo->videoCodec > -1) && (stinfo->videoCodec < 8) && |
1061 | FLVVideoCodecs[stinfo->videoCodec] != NULL && n < len) { | 1132 | (FLVVideoCodecs[stinfo->videoCodec] != NULL) && (n < len) ) |
1133 | { | ||
1062 | if (n > 0) | 1134 | if (n > 0) |
1063 | n += snprintf(s+n, len-n, ", "); | 1135 | n += snprintf (s + n, len - n, ", "); |
1064 | if (n < len) | 1136 | if (n < len) |
1065 | n += snprintf(s+n, len-n, "%s", FLVVideoCodecs[stinfo->videoCodec]); | 1137 | n += snprintf (s + n, len - n, "%s", FLVVideoCodecs[stinfo->videoCodec]); |
1066 | } | 1138 | } |
1067 | else if (stinfo->videoCodecStr != NULL && n < len) { | 1139 | else if ((stinfo->videoCodecStr != NULL) && (n < len)) |
1140 | { | ||
1068 | if (n > 0) | 1141 | if (n > 0) |
1069 | n += snprintf(s+n, len-n, ", "); | 1142 | n += snprintf (s + n, len - n, ", "); |
1070 | if (n < len) | 1143 | if (n < len) |
1071 | n += snprintf(s+n, len-n, "%s", stinfo->videoCodecStr); | 1144 | n += snprintf (s + n, len - n, "%s", stinfo->videoCodecStr); |
1072 | } | 1145 | } |
1073 | 1146 | ||
1074 | if (stinfo->videoDataRate != 0.0 && n < len) { | 1147 | if ((stinfo->videoDataRate != 0.0) && (n < len)) |
1148 | { | ||
1075 | if (n > 0) | 1149 | if (n > 0) |
1076 | n += snprintf(s+n, len-n, ", "); | 1150 | n += snprintf (s + n, len - n, ", "); |
1077 | if (n < len) | 1151 | if (n < len) |
1078 | n += snprintf(s+n, len-n, "%.4f kbps", stinfo->videoDataRate); | 1152 | n += snprintf (s + n, len - n, "%.4f kbps", stinfo->videoDataRate); |
1079 | } | 1153 | } |
1080 | 1154 | ||
1081 | if (n == 0) | 1155 | if (n == 0) |
1082 | return NULL; | 1156 | return NULL; |
1083 | return strdup(s); | 1157 | return strdup (s); |
1084 | } | 1158 | } |
1085 | 1159 | ||
1086 | static char * printAudioFormat(FLVStreamInfo *stinfo) | 1160 | |
1161 | static char * | ||
1162 | printAudioFormat (FLVStreamInfo *stinfo) | ||
1087 | { | 1163 | { |
1088 | char s[MAX_FLV_FORMAT_LINE+1]; | 1164 | char s[MAX_FLV_FORMAT_LINE + 1]; |
1089 | int n; | 1165 | int n; |
1090 | size_t len = MAX_FLV_FORMAT_LINE; | 1166 | size_t len = MAX_FLV_FORMAT_LINE; |
1091 | 1167 | ||
1092 | n = 0; | 1168 | n = 0; |
1093 | if ( (stinfo->audioRate != -1) && (n < len)) { | 1169 | if ( (stinfo->audioRate != -1) && (n < len)) |
1094 | n += snprintf(s+n, len-n, "%s Hz", FLVAudioSampleRates[stinfo->audioRate]); | 1170 | { |
1171 | n += snprintf (s + n, len - n, "%s Hz", | ||
1172 | FLVAudioSampleRates[stinfo->audioRate]); | ||
1095 | } | 1173 | } |
1096 | 1174 | ||
1097 | if ((stinfo->audioSampleBits != -1) && (n < len)) { | 1175 | if ((stinfo->audioSampleBits != -1) && (n < len)) |
1176 | { | ||
1098 | if (n > 0) | 1177 | if (n > 0) |
1099 | n += snprintf(s+n, len-n, ", "); | 1178 | n += snprintf (s + n, len - n, ", "); |
1100 | if (n < len) | 1179 | if (n < len) |
1101 | n += snprintf(s+n, len-n, "%s", | 1180 | n += snprintf (s + n, len - n, "%s", |
1102 | FLVAudioSampleSizes[stinfo->audioSampleBits]); | 1181 | FLVAudioSampleSizes[stinfo->audioSampleBits]); |
1103 | } | 1182 | } |
1104 | 1183 | ||
1105 | if ((stinfo->audioChannels != -1) && (n < len)) { | 1184 | if ((stinfo->audioChannels != -1) && (n < len)) |
1185 | { | ||
1106 | if (n > 0) | 1186 | if (n > 0) |
1107 | n += snprintf(s+n, len-n, ", "); | 1187 | n += snprintf (s + n, len - n, ", "); |
1108 | if (n < len) { | 1188 | if (n < len) |
1109 | if (stinfo->audioChannels >= 1 && stinfo->audioChannels <= 2) | 1189 | { |
1110 | n += snprintf(s+n, len-n, "%s", | 1190 | if ((stinfo->audioChannels >= 1) && (stinfo->audioChannels <= 2)) |
1111 | FLVAudioChannels[stinfo->audioChannels-1]); | 1191 | n += snprintf (s + n, len - n, "%s", |
1192 | FLVAudioChannels[stinfo->audioChannels - 1]); | ||
1112 | else | 1193 | else |
1113 | n += snprintf(s+n, len-n, "%d", | 1194 | n += snprintf (s + n, len - n, "%d", |
1114 | stinfo->audioChannels); | 1195 | stinfo->audioChannels); |
1115 | } | 1196 | } |
1116 | } | 1197 | } |
1117 | 1198 | ||
1118 | if ((stinfo->audioCodec > -1) && (stinfo->audioCodec < 12) && | 1199 | if ((stinfo->audioCodec > -1) && (stinfo->audioCodec < 12) && |
1119 | (FLVAudioCodecs[stinfo->audioCodec] != NULL) && (n < len)) { | 1200 | (FLVAudioCodecs[stinfo->audioCodec] != NULL) && (n < len)) |
1201 | { | ||
1120 | if (n > 0) | 1202 | if (n > 0) |
1121 | n += snprintf(s+n, len-n, ", "); | 1203 | n += snprintf (s + n, len - n, ", "); |
1122 | if (n < len) | 1204 | if (n < len) |
1123 | n += snprintf(s+n, len-n, "%s", FLVAudioCodecs[stinfo->audioCodec]); | 1205 | n += snprintf (s + n, len - n, "%s", FLVAudioCodecs[stinfo->audioCodec]); |
1124 | } | 1206 | } |
1125 | else if ((stinfo->audioCodecStr != NULL) && (n < len)) { | 1207 | else if ((stinfo->audioCodecStr != NULL) && (n < len)) |
1208 | { | ||
1126 | if (n > 0) | 1209 | if (n > 0) |
1127 | n += snprintf(s+n, len-n, ", "); | 1210 | n += snprintf (s + n, len - n, ", "); |
1128 | if (n < len) | 1211 | if (n < len) |
1129 | n += snprintf(s+n, len-n, "%s", stinfo->audioCodecStr); | 1212 | n += snprintf (s + n, len - n, "%s", stinfo->audioCodecStr); |
1130 | } | 1213 | } |
1131 | 1214 | ||
1132 | if ((stinfo->audioDataRate != 0.0) && (n < len)) { | 1215 | if ((stinfo->audioDataRate != 0.0) && (n < len)) |
1216 | { | ||
1133 | if (n > 0) | 1217 | if (n > 0) |
1134 | n += snprintf(s+n, len-n, ", "); | 1218 | n += snprintf (s + n, len - n, ", "); |
1135 | if (n < len) | 1219 | if (n < len) |
1136 | n += snprintf(s+n, len-n, "%.4f kbps", stinfo->audioDataRate); | 1220 | n += snprintf (s + n, len - n, "%.4f kbps", stinfo->audioDataRate); |
1137 | } | 1221 | } |
1138 | 1222 | ||
1139 | if (n == 0) | 1223 | if (n == 0) |
1140 | return NULL; | 1224 | return NULL; |
1141 | return strdup(s); | 1225 | return strdup (s); |
1142 | } | 1226 | } |
1143 | 1227 | ||
1144 | int | 1228 | |
1229 | int | ||
1145 | EXTRACTOR_flv_extract (const unsigned char *data, | 1230 | EXTRACTOR_flv_extract (const unsigned char *data, |
1146 | size_t size, | 1231 | size_t size, |
1147 | EXTRACTOR_MetaDataProcessor proc, | 1232 | EXTRACTOR_MetaDataProcessor proc, |
1148 | void *proc_cls, | 1233 | void *proc_cls, |
1149 | const char *options) | 1234 | const char *options) |
1150 | { | 1235 | { |
1151 | const unsigned char *ptr; | 1236 | const unsigned char *ptr; |
1152 | const unsigned char *end; | 1237 | const unsigned char *end; |
@@ -1159,19 +1244,19 @@ EXTRACTOR_flv_extract (const unsigned char *data, | |||
1159 | ptr = data; | 1244 | ptr = data; |
1160 | end = ptr + size; | 1245 | end = ptr + size; |
1161 | 1246 | ||
1162 | if (readFLVHeader(&ptr, end, &header) == -1) | 1247 | if (readFLVHeader (&ptr, end, &header) == -1) |
1163 | return 0; | 1248 | return 0; |
1164 | 1249 | ||
1165 | if (memcmp(header.signature, FLV_SIGNATURE, 3) != 0) | 1250 | if (memcmp (header.signature, FLV_SIGNATURE, 3) != 0) |
1166 | return 0; | 1251 | return 0; |
1167 | 1252 | ||
1168 | if (0 != proc (proc_cls, | 1253 | if (0 != proc (proc_cls, |
1169 | "flv", | 1254 | "flv", |
1170 | EXTRACTOR_METATYPE_MIMETYPE, | 1255 | EXTRACTOR_METATYPE_MIMETYPE, |
1171 | EXTRACTOR_METAFORMAT_UTF8, | 1256 | EXTRACTOR_METAFORMAT_UTF8, |
1172 | "text/plain", | 1257 | "text/plain", |
1173 | "video/x-flv", | 1258 | "video/x-flv", |
1174 | strlen ("video/x-flv") + 1)) | 1259 | strlen ("video/x-flv") + 1)) |
1175 | return 0; | 1260 | return 0; |
1176 | if (header.version != 1) | 1261 | if (header.version != 1) |
1177 | return 0; | 1262 | return 0; |
@@ -1191,7 +1276,8 @@ EXTRACTOR_flv_extract (const unsigned char *data, | |||
1191 | stinfo.audioChannels = -1; | 1276 | stinfo.audioChannels = -1; |
1192 | stinfo.audioDataRate = 0.0; | 1277 | stinfo.audioDataRate = 0.0; |
1193 | ret = 0; | 1278 | ret = 0; |
1194 | while (ptr < end) { | 1279 | while (ptr < end) |
1280 | { | ||
1195 | if (-1 == (ret = readFLVTag (&ptr, end, &stinfo, proc, proc_cls))) | 1281 | if (-1 == (ret = readFLVTag (&ptr, end, &stinfo, proc, proc_cls))) |
1196 | break; | 1282 | break; |
1197 | if (readPreviousTagSize (&ptr, end, &prev_tag_size) == -1) | 1283 | if (readPreviousTagSize (&ptr, end, &prev_tag_size) == -1) |
@@ -1201,35 +1287,35 @@ EXTRACTOR_flv_extract (const unsigned char *data, | |||
1201 | return 1; | 1287 | return 1; |
1202 | s = printVideoFormat (&stinfo); | 1288 | s = printVideoFormat (&stinfo); |
1203 | if (s != NULL) | 1289 | if (s != NULL) |
1290 | { | ||
1291 | if (0 != proc (proc_cls, | ||
1292 | "flv", | ||
1293 | EXTRACTOR_METATYPE_RESOURCE_TYPE, | ||
1294 | EXTRACTOR_METAFORMAT_UTF8, | ||
1295 | "text/plain", | ||
1296 | s, | ||
1297 | strlen (s) + 1)) | ||
1204 | { | 1298 | { |
1205 | if (0 != proc (proc_cls, | ||
1206 | "flv", | ||
1207 | EXTRACTOR_METATYPE_RESOURCE_TYPE, | ||
1208 | EXTRACTOR_METAFORMAT_UTF8, | ||
1209 | "text/plain", | ||
1210 | s, | ||
1211 | strlen (s)+1)) | ||
1212 | { | ||
1213 | free (s); | ||
1214 | return 1; | ||
1215 | } | ||
1216 | free (s); | 1299 | free (s); |
1300 | return 1; | ||
1217 | } | 1301 | } |
1302 | free (s); | ||
1303 | } | ||
1218 | s = printAudioFormat (&stinfo); | 1304 | s = printAudioFormat (&stinfo); |
1219 | if (s != NULL) | 1305 | if (s != NULL) |
1306 | { | ||
1307 | if (0 != proc (proc_cls, | ||
1308 | "flv", | ||
1309 | EXTRACTOR_METATYPE_RESOURCE_TYPE, | ||
1310 | EXTRACTOR_METAFORMAT_UTF8, | ||
1311 | "text/plain", | ||
1312 | s, | ||
1313 | strlen (s) + 1)) | ||
1220 | { | 1314 | { |
1221 | if (0 != proc (proc_cls, | ||
1222 | "flv", | ||
1223 | EXTRACTOR_METATYPE_RESOURCE_TYPE, | ||
1224 | EXTRACTOR_METAFORMAT_UTF8, | ||
1225 | "text/plain", | ||
1226 | s, | ||
1227 | strlen (s)+1)) | ||
1228 | { | ||
1229 | free (s); | ||
1230 | return 1; | ||
1231 | } | ||
1232 | free (s); | 1315 | free (s); |
1316 | return 1; | ||
1233 | } | 1317 | } |
1318 | free (s); | ||
1319 | } | ||
1234 | return 0; | 1320 | return 0; |
1235 | } | 1321 | } |
diff --git a/src/plugins/old/mkv_extractor.c b/src/plugins/old/mkv_extractor.c index 9e2f1f9..ff052dc 100644 --- a/src/plugins/old/mkv_extractor.c +++ b/src/plugins/old/mkv_extractor.c | |||
@@ -18,17 +18,21 @@ | |||
18 | Boston, MA 02110-1301, USA. | 18 | Boston, MA 02110-1301, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /* | 21 | /* |
22 | * Made by Gabriel Peixoto | 22 | * Made by Gabriel Peixoto |
23 | * Using AVInfo 1.x code. Copyright (c) 2004 George Shuklin. | 23 | * Using AVInfo 1.x code. Copyright (c) 2004 George Shuklin. |
24 | * | 24 | * |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include "platform.h" | 27 | #include "platform.h" |
28 | #include "extractor.h" | 28 | #include "extractor.h" |
29 | #include <stdint.h> | 29 | #include <stdint.h> |
30 | 30 | ||
31 | #define ADD(s,t) do { if (0 != (ret = proc (proc_cls, "mkv", t, EXTRACTOR_METAFORMAT_UTF8, "text/plain", s, strlen(s)+1))) goto EXIT; } while (0) | 31 | #define ADD(s,t) do { if (0 != (ret = proc (proc_cls, "mkv", t, \ |
32 | EXTRACTOR_METAFORMAT_UTF8, \ | ||
33 | "text/plain", s, strlen (s) \ | ||
34 | + 1))) goto EXIT; \ | ||
35 | } while (0) | ||
32 | 36 | ||
33 | /** | 37 | /** |
34 | * FIXME: document | 38 | * FIXME: document |
@@ -98,27 +102,29 @@ enum | |||
98 | */ | 102 | */ |
99 | static size_t | 103 | static size_t |
100 | VINTparse (const unsigned char *buffer, size_t start, size_t end, | 104 | VINTparse (const unsigned char *buffer, size_t start, size_t end, |
101 | int64_t * result, int flag) | 105 | int64_t *result, int flag) |
102 | { | 106 | { |
103 | static const unsigned char mask[8] = { 0x80, 0x40, 0x20, 0x10, 0x8, 0x4, 0x2, 0x1 }; | 107 | static const unsigned char mask[8] = { 0x80, 0x40, 0x20, 0x10, 0x8, 0x4, 0x2, |
104 | static const unsigned char imask[8] = { 0x7F, 0x3F, 0x1F, 0xF, 0x7, 0x3, 0x1, 00 }; | 108 | 0x1 }; |
109 | static const unsigned char imask[8] = { 0x7F, 0x3F, 0x1F, 0xF, 0x7, 0x3, 0x1, | ||
110 | 00 }; | ||
105 | int vint_width; | 111 | int vint_width; |
106 | unsigned int c; | 112 | unsigned int c; |
107 | int64_t temp; | 113 | int64_t temp; |
108 | unsigned char tempc; | 114 | unsigned char tempc; |
109 | 115 | ||
110 | if (end - start < 2) | 116 | if (end - start < 2) |
111 | return 0; /*ops */ | 117 | return 0; /*ops */ |
112 | 118 | ||
113 | vint_width = 0; | 119 | vint_width = 0; |
114 | for (c = 0; c < 8; c++) | 120 | for (c = 0; c < 8; c++) |
115 | if (!(buffer[start] & mask[c])) | 121 | if (! (buffer[start] & mask[c])) |
116 | vint_width++; | 122 | vint_width++; |
117 | else | 123 | else |
118 | break; | 124 | break; |
119 | if ( (vint_width >= 8) || (vint_width + start + 1 >= end) ) | 125 | if ( (vint_width >= 8) || (vint_width + start + 1 >= end) ) |
120 | return 0; | 126 | return 0; |
121 | 127 | ||
122 | *result = 0; | 128 | *result = 0; |
123 | for (c = 0; c < vint_width; c++) | 129 | for (c = 0; c < vint_width; c++) |
124 | { | 130 | { |
@@ -139,7 +145,7 @@ VINTparse (const unsigned char *buffer, size_t start, size_t end, | |||
139 | */ | 145 | */ |
140 | static unsigned int | 146 | static unsigned int |
141 | elementRead (const unsigned char *buffer, size_t start, size_t end, | 147 | elementRead (const unsigned char *buffer, size_t start, size_t end, |
142 | uint32_t *id, int64_t * size) | 148 | uint32_t *id, int64_t *size) |
143 | { | 149 | { |
144 | int64_t tempID; | 150 | int64_t tempID; |
145 | int64_t tempsize; | 151 | int64_t tempsize; |
@@ -147,12 +153,12 @@ elementRead (const unsigned char *buffer, size_t start, size_t end, | |||
147 | size_t size_offset; | 153 | size_t size_offset; |
148 | 154 | ||
149 | tempID = 0; | 155 | tempID = 0; |
150 | 156 | ||
151 | id_offset = VINTparse (buffer, start, end, &tempID, 0); | 157 | id_offset = VINTparse (buffer, start, end, &tempID, 0); |
152 | if (!id_offset) | 158 | if (! id_offset) |
153 | return 0; | 159 | return 0; |
154 | size_offset = VINTparse (buffer, start + id_offset, end, &tempsize, 1); | 160 | size_offset = VINTparse (buffer, start + id_offset, end, &tempsize, 1); |
155 | if (!size_offset) | 161 | if (! size_offset) |
156 | return 0; | 162 | return 0; |
157 | *id = (uint32_t) tempID; | 163 | *id = (uint32_t) tempID; |
158 | *size = tempsize; | 164 | *size = tempsize; |
@@ -172,10 +178,11 @@ getInt (const unsigned char *buffer, size_t start, size_t size) | |||
172 | 178 | ||
173 | result = 0; | 179 | result = 0; |
174 | for (c = 1; c <= size; c++) | 180 | for (c = 1; c <= size; c++) |
175 | result += ((uint64_t)buffer[start + c - 1]) << (8 * (size - c)); | 181 | result += ((uint64_t) buffer[start + c - 1]) << (8 * (size - c)); |
176 | return result; | 182 | return result; |
177 | } | 183 | } |
178 | 184 | ||
185 | |||
179 | static float | 186 | static float |
180 | getFloat (const unsigned char *buffer, size_t start, size_t size) | 187 | getFloat (const unsigned char *buffer, size_t start, size_t size) |
181 | { | 188 | { |
@@ -194,7 +201,8 @@ getFloat (const unsigned char *buffer, size_t start, size_t size) | |||
194 | return 0.0; | 201 | return 0.0; |
195 | } | 202 | } |
196 | 203 | ||
197 | static const unsigned int MKV_Parse_list[] = { | 204 | |
205 | static const unsigned int MKV_Parse_list[] = { | ||
198 | /*Elements, containing requed information (sub-elements), see enum in mkv.h for values */ | 206 | /*Elements, containing requed information (sub-elements), see enum in mkv.h for values */ |
199 | MKVID_Segment, | 207 | MKVID_Segment, |
200 | MKVID_Info, | 208 | MKVID_Info, |
@@ -244,14 +252,14 @@ EXTRACTOR_mkv_extract (const unsigned char *data, size_t size, | |||
244 | if (NULL == start) | 252 | if (NULL == start) |
245 | return 0; | 253 | return 0; |
246 | p = start - data; | 254 | p = start - data; |
247 | 255 | ||
248 | /*main loop*/ | 256 | /*main loop*/ |
249 | ret = 0; | 257 | ret = 0; |
250 | do | 258 | do |
251 | { | 259 | { |
252 | offs = elementRead (data, p, size, &eID, &eSize); | 260 | offs = elementRead (data, p, size, &eID, &eSize); |
253 | p += offs; | 261 | p += offs; |
254 | if (!offs || p >= size) | 262 | if (! offs || (p >= size)) |
255 | break; | 263 | break; |
256 | if (MKVID_EBML == eID) | 264 | if (MKVID_EBML == eID) |
257 | { | 265 | { |
@@ -262,8 +270,8 @@ EXTRACTOR_mkv_extract (const unsigned char *data, size_t size, | |||
262 | if (! is_mkv) | 270 | if (! is_mkv) |
263 | return 0; | 271 | return 0; |
264 | for (c = 0; c < sizeof (MKV_Parse_list) / sizeof (*MKV_Parse_list); c++) | 272 | for (c = 0; c < sizeof (MKV_Parse_list) / sizeof (*MKV_Parse_list); c++) |
265 | if (MKV_Parse_list[c] == eID) | 273 | if (MKV_Parse_list[c] == eID) |
266 | break; | 274 | break; |
267 | if (c < sizeof (MKV_Parse_list) / sizeof (*MKV_Parse_list)) | 275 | if (c < sizeof (MKV_Parse_list) / sizeof (*MKV_Parse_list)) |
268 | continue; | 276 | continue; |
269 | 277 | ||
@@ -272,7 +280,7 @@ EXTRACTOR_mkv_extract (const unsigned char *data, size_t size, | |||
272 | 280 | ||
273 | if ( (eSize == 4) || (eSize == 8) || (eSize == 1) || (eSize == 2)) | 281 | if ( (eSize == 4) || (eSize == 8) || (eSize == 1) || (eSize == 2)) |
274 | value = getInt (data, p, eSize); | 282 | value = getInt (data, p, eSize); |
275 | 283 | ||
276 | switch (eID) | 284 | switch (eID) |
277 | { | 285 | { |
278 | case MKVID_TrackType: /*detect a stream type (video/audio/text) */ | 286 | case MKVID_TrackType: /*detect a stream type (video/audio/text) */ |
@@ -286,9 +294,9 @@ EXTRACTOR_mkv_extract (const unsigned char *data, size_t size, | |||
286 | have_audio = 1; | 294 | have_audio = 1; |
287 | break; | 295 | break; |
288 | case MKV_Track_subtitle: | 296 | case MKV_Track_subtitle: |
289 | break; | 297 | break; |
290 | case MKV_Track_subtitle_orig: | 298 | case MKV_Track_subtitle_orig: |
291 | break; | 299 | break; |
292 | } | 300 | } |
293 | break; | 301 | break; |
294 | case MKVID_DefaultDuration: | 302 | case MKVID_DefaultDuration: |
@@ -298,11 +306,11 @@ EXTRACTOR_mkv_extract (const unsigned char *data, size_t size, | |||
298 | fps = 0; | 306 | fps = 0; |
299 | break; | 307 | break; |
300 | case MKVID_Language: | 308 | case MKVID_Language: |
301 | snprintf (buffer, | 309 | snprintf (buffer, |
302 | sizeof (buffer), | 310 | sizeof (buffer), |
303 | "%.*s", | 311 | "%.*s", |
304 | (int) eSize, | 312 | (int) eSize, |
305 | data + p); | 313 | data + p); |
306 | ADD (buffer, EXTRACTOR_METATYPE_LANGUAGE); | 314 | ADD (buffer, EXTRACTOR_METATYPE_LANGUAGE); |
307 | break; | 315 | break; |
308 | case MKVID_CodecName: | 316 | case MKVID_CodecName: |
@@ -340,10 +348,10 @@ EXTRACTOR_mkv_extract (const unsigned char *data, size_t size, | |||
340 | if (eSize > MAX_STRING_SIZE) | 348 | if (eSize > MAX_STRING_SIZE) |
341 | break; | 349 | break; |
342 | snprintf (buffer, | 350 | snprintf (buffer, |
343 | sizeof (buffer), | 351 | sizeof (buffer), |
344 | "%.*s", | 352 | "%.*s", |
345 | (int) eSize, | 353 | (int) eSize, |
346 | (const char*) data + p); | 354 | (const char*) data + p); |
347 | ADD (buffer, EXTRACTOR_METATYPE_TITLE); | 355 | ADD (buffer, EXTRACTOR_METATYPE_TITLE); |
348 | break; | 356 | break; |
349 | default: | 357 | default: |
@@ -354,20 +362,20 @@ EXTRACTOR_mkv_extract (const unsigned char *data, size_t size, | |||
354 | while (1); | 362 | while (1); |
355 | 363 | ||
356 | snprintf (buffer, | 364 | snprintf (buffer, |
357 | sizeof (buffer), | 365 | sizeof (buffer), |
358 | "%u s (%s%s%s)", | 366 | "%u s (%s%s%s)", |
359 | (unsigned int) (duration / 1e+9 * (float) timescale), | 367 | (unsigned int) (duration / 1e+9 * (float) timescale), |
360 | (have_audio ? "audio" : ""), | 368 | (have_audio ? "audio" : ""), |
361 | ((have_audio && have_video) ? "/" : ""), | 369 | ((have_audio && have_video) ? "/" : ""), |
362 | (have_video ? "video" : "")); | 370 | (have_video ? "video" : "")); |
363 | if ( (have_audio || have_video) && (duration >= 0.0) ) | 371 | if ( (have_audio || have_video) && (duration >= 0.0) ) |
364 | ADD (buffer, EXTRACTOR_METATYPE_DURATION); | 372 | ADD (buffer, EXTRACTOR_METATYPE_DURATION); |
365 | if ( (value_width != 0) && (value_height != 0) ) | 373 | if ( (value_width != 0) && (value_height != 0) ) |
366 | { | 374 | { |
367 | snprintf (buffer, | 375 | snprintf (buffer, |
368 | sizeof(buffer), | 376 | sizeof(buffer), |
369 | "%ux%u", | 377 | "%ux%u", |
370 | value_width, value_height); | 378 | value_width, value_height); |
371 | ADD (buffer, EXTRACTOR_METATYPE_IMAGE_DIMENSIONS); | 379 | ADD (buffer, EXTRACTOR_METATYPE_IMAGE_DIMENSIONS); |
372 | } | 380 | } |
373 | 381 | ||
@@ -375,34 +383,34 @@ EXTRACTOR_mkv_extract (const unsigned char *data, size_t size, | |||
375 | { | 383 | { |
376 | if ( (fps != 0) && (bit_depth != 0) ) | 384 | if ( (fps != 0) && (bit_depth != 0) ) |
377 | snprintf (buffer, | 385 | snprintf (buffer, |
378 | sizeof (buffer), | 386 | sizeof (buffer), |
379 | "%.*s (%u fps, %u bit)", | 387 | "%.*s (%u fps, %u bit)", |
380 | codec_strlen, | 388 | codec_strlen, |
381 | codec, | 389 | codec, |
382 | fps, | 390 | fps, |
383 | bit_depth); | 391 | bit_depth); |
384 | else if (fps != 0) | 392 | else if (fps != 0) |
385 | snprintf (buffer, | 393 | snprintf (buffer, |
386 | sizeof (buffer), | 394 | sizeof (buffer), |
387 | "%.*s (%u fps)", | 395 | "%.*s (%u fps)", |
388 | codec_strlen, | 396 | codec_strlen, |
389 | codec, | 397 | codec, |
390 | fps); | 398 | fps); |
391 | else if (bit_depth != 0) | 399 | else if (bit_depth != 0) |
392 | snprintf (buffer, | 400 | snprintf (buffer, |
393 | sizeof (buffer), | 401 | sizeof (buffer), |
394 | "%.*s (%u bit)", | 402 | "%.*s (%u bit)", |
395 | codec_strlen, | 403 | codec_strlen, |
396 | codec, | 404 | codec, |
397 | bit_depth); | 405 | bit_depth); |
398 | else | 406 | else |
399 | snprintf (buffer, | 407 | snprintf (buffer, |
400 | sizeof (buffer), | 408 | sizeof (buffer), |
401 | "%.*s", | 409 | "%.*s", |
402 | codec_strlen, | 410 | codec_strlen, |
403 | codec); | 411 | codec); |
404 | ADD (buffer, | 412 | ADD (buffer, |
405 | EXTRACTOR_METATYPE_FORMAT); | 413 | EXTRACTOR_METATYPE_FORMAT); |
406 | } | 414 | } |
407 | EXIT: | 415 | EXIT: |
408 | return ret; | 416 | return ret; |
diff --git a/src/plugins/old/mp3_extractor.c b/src/plugins/old/mp3_extractor.c index 99afd15..076b427 100644 --- a/src/plugins/old/mp3_extractor.c +++ b/src/plugins/old/mp3_extractor.c | |||
@@ -91,21 +91,21 @@ static const int freq_table[4][3] = { | |||
91 | {48000, 24000, 12000}, | 91 | {48000, 24000, 12000}, |
92 | {32000, 16000, 8000} | 92 | {32000, 16000, 8000} |
93 | }; | 93 | }; |
94 | static const char * const channel_modes[4] = { | 94 | static const char *const channel_modes[4] = { |
95 | gettext_noop("stereo"), | 95 | gettext_noop ("stereo"), |
96 | gettext_noop("joint stereo"), | 96 | gettext_noop ("joint stereo"), |
97 | gettext_noop("dual channel"), | 97 | gettext_noop ("dual channel"), |
98 | gettext_noop("mono") | 98 | gettext_noop ("mono") |
99 | }; | 99 | }; |
100 | static const char * const mpeg_versions[3] = { | 100 | static const char *const mpeg_versions[3] = { |
101 | gettext_noop("MPEG-1"), | 101 | gettext_noop ("MPEG-1"), |
102 | gettext_noop("MPEG-2"), | 102 | gettext_noop ("MPEG-2"), |
103 | gettext_noop("MPEG-2.5") | 103 | gettext_noop ("MPEG-2.5") |
104 | }; | 104 | }; |
105 | static const char * const layer_names[3] = { | 105 | static const char *const layer_names[3] = { |
106 | gettext_noop("Layer I"), | 106 | gettext_noop ("Layer I"), |
107 | gettext_noop("Layer II"), | 107 | gettext_noop ("Layer II"), |
108 | gettext_noop("Layer III") | 108 | gettext_noop ("Layer III") |
109 | }; | 109 | }; |
110 | 110 | ||
111 | 111 | ||
@@ -113,7 +113,10 @@ static const char * const layer_names[3] = { | |||
113 | #define SYSERR 1 | 113 | #define SYSERR 1 |
114 | #define INVALID_ID3 2 | 114 | #define INVALID_ID3 2 |
115 | 115 | ||
116 | #define ADDR(s,t) do { if (0 != proc (proc_cls, "mp3", t, EXTRACTOR_METAFORMAT_UTF8, "text/plain", s, strlen(s)+1)) return 1; } while (0) | 116 | #define ADDR(s,t) do { if (0 != proc (proc_cls, "mp3", t, \ |
117 | EXTRACTOR_METAFORMAT_UTF8, "text/plain", \ | ||
118 | s, strlen (s) + 1)) return 1; \ | ||
119 | } while (0) | ||
117 | 120 | ||
118 | struct mp3_state | 121 | struct mp3_state |
119 | { | 122 | { |
@@ -163,6 +166,7 @@ EXTRACTOR_mp3_init_state_method () | |||
163 | return state; | 166 | return state; |
164 | } | 167 | } |
165 | 168 | ||
169 | |||
166 | static int | 170 | static int |
167 | EXTRACTOR_mp3_discard_state_method (struct mp3_state *state) | 171 | EXTRACTOR_mp3_discard_state_method (struct mp3_state *state) |
168 | { | 172 | { |
@@ -173,51 +177,58 @@ EXTRACTOR_mp3_discard_state_method (struct mp3_state *state) | |||
173 | return 1; | 177 | return 1; |
174 | } | 178 | } |
175 | 179 | ||
180 | |||
176 | static int | 181 | static int |
177 | calculate_frame_statistics_and_maybe_report_it (struct EXTRACTOR_PluginList *plugin, | 182 | calculate_frame_statistics_and_maybe_report_it (struct |
178 | struct mp3_state *state, EXTRACTOR_MetaDataProcessor proc, void *proc_cls) | 183 | EXTRACTOR_PluginList *plugin, |
184 | struct mp3_state *state, | ||
185 | EXTRACTOR_MetaDataProcessor proc, | ||
186 | void *proc_cls) | ||
179 | { | 187 | { |
180 | int length; | 188 | int length; |
181 | char format[512]; | 189 | char format[512]; |
182 | 190 | ||
183 | if (((double) state->number_of_valid_frames / (double) state->number_of_frames) < 0.8 || | 191 | if ((((double) state->number_of_valid_frames |
184 | state->number_of_valid_frames <= 2) | 192 | / (double) state->number_of_frames) < 0.8) || |
193 | (state->number_of_valid_frames <= 2) ) | ||
185 | /* Unlikely to be an mp3 file */ | 194 | /* Unlikely to be an mp3 file */ |
186 | return 0; | 195 | return 0; |
187 | ADDR ("audio/mpeg", EXTRACTOR_METATYPE_MIMETYPE); | 196 | ADDR ("audio/mpeg", EXTRACTOR_METATYPE_MIMETYPE); |
188 | state->avg_bps = state->avg_bps / state->number_of_valid_frames; | 197 | state->avg_bps = state->avg_bps / state->number_of_valid_frames; |
189 | if (state->sample_rate > 0) | 198 | if (state->sample_rate > 0) |
190 | length = 1152 * state->number_of_valid_frames / state->sample_rate; | 199 | length = 1152 * state->number_of_valid_frames / state->sample_rate; |
191 | else if (state->avg_bps > 0 || state->bitrate > 0) | 200 | else if ((state->avg_bps > 0) || (state->bitrate > 0)) |
192 | length = plugin->fsize / (state->avg_bps ? state->avg_bps : state->bitrate ? state->bitrate : 1) / 125; | 201 | length = plugin->fsize / (state->avg_bps ? state->avg_bps : state->bitrate ? |
202 | state->bitrate : 1) / 125; | ||
193 | else | 203 | else |
194 | length = 0; | 204 | length = 0; |
195 | 205 | ||
196 | ADDR (mpeg_versions[state->mpeg_ver - 1], EXTRACTOR_METATYPE_FORMAT_VERSION); | 206 | ADDR (mpeg_versions[state->mpeg_ver - 1], EXTRACTOR_METATYPE_FORMAT_VERSION); |
197 | snprintf (format, | 207 | snprintf (format, |
198 | sizeof (format), | 208 | sizeof (format), |
199 | "%s %s audio, %d kbps (%s), %d Hz, %s, %s, %s", | 209 | "%s %s audio, %d kbps (%s), %d Hz, %s, %s, %s", |
200 | mpeg_versions[state->mpeg_ver - 1], | 210 | mpeg_versions[state->mpeg_ver - 1], |
201 | layer_names[state->layer - 1], | 211 | layer_names[state->layer - 1], |
202 | state->avg_bps, | 212 | state->avg_bps, |
203 | state->vbr_flag ? _("VBR") : _("CBR"), | 213 | state->vbr_flag ? _ ("VBR") : _ ("CBR"), |
204 | state->sample_rate, | 214 | state->sample_rate, |
205 | channel_modes[state->ch], | 215 | channel_modes[state->ch], |
206 | state->copyright_flag ? _("copyright") : _("no copyright"), | 216 | state->copyright_flag ? _ ("copyright") : _ ("no copyright"), |
207 | state->original_flag ? _("original") : _("copy") ); | 217 | state->original_flag ? _ ("original") : _ ("copy") ); |
208 | 218 | ||
209 | ADDR (format, EXTRACTOR_METATYPE_RESOURCE_TYPE); | 219 | ADDR (format, EXTRACTOR_METATYPE_RESOURCE_TYPE); |
210 | snprintf (format, | 220 | snprintf (format, |
211 | sizeof (format), "%dm%02d", | 221 | sizeof (format), "%dm%02d", |
212 | length / 60, length % 60); | 222 | length / 60, length % 60); |
213 | ADDR (format, EXTRACTOR_METATYPE_DURATION); | 223 | ADDR (format, EXTRACTOR_METATYPE_DURATION); |
214 | return 0; | 224 | return 0; |
215 | } | 225 | } |
216 | 226 | ||
227 | |||
217 | int | 228 | int |
218 | EXTRACTOR_mp3_extract_method (struct EXTRACTOR_PluginList *plugin, | 229 | EXTRACTOR_mp3_extract_method (struct EXTRACTOR_PluginList *plugin, |
219 | EXTRACTOR_MetaDataProcessor proc, | 230 | EXTRACTOR_MetaDataProcessor proc, |
220 | void *proc_cls) | 231 | void *proc_cls) |
221 | { | 232 | { |
222 | int64_t offset = 0; | 233 | int64_t offset = 0; |
223 | int64_t round_offset; | 234 | int64_t round_offset; |
@@ -255,24 +266,29 @@ EXTRACTOR_mp3_extract_method (struct EXTRACTOR_PluginList *plugin, | |||
255 | while (1) | 266 | while (1) |
256 | { | 267 | { |
257 | pl_seek (plugin, offset, SEEK_SET); | 268 | pl_seek (plugin, offset, SEEK_SET); |
258 | read_result = pl_read (plugin, &data, 1024*1024); | 269 | read_result = pl_read (plugin, &data, 1024 * 1024); |
259 | if (read_result < 4) | 270 | if (read_result < 4) |
260 | { | 271 | { |
261 | calculate_frame_statistics_and_maybe_report_it (plugin, state, proc, proc_cls); | 272 | calculate_frame_statistics_and_maybe_report_it (plugin, state, proc, |
273 | proc_cls); | ||
262 | return EXTRACTOR_mp3_discard_state_method (state); | 274 | return EXTRACTOR_mp3_discard_state_method (state); |
263 | } | 275 | } |
264 | for (i = 0; i + 3 < read_result; i++) | 276 | for (i = 0; i + 3 < read_result; i++) |
265 | if (((*((uint32_t *) &data[i])) & MPA_SYNC_MASK_MEM) == MPA_SYNC_MASK_MEM) | 277 | if (((*((uint32_t *) &data[i])) & MPA_SYNC_MASK_MEM) == |
278 | MPA_SYNC_MASK_MEM) | ||
266 | break; | 279 | break; |
267 | if (i + 3 >= 1024*1024) | 280 | if (i + 3 >= 1024 * 1024) |
268 | offset += read_result - 3; | 281 | offset += read_result - 3; |
269 | else | 282 | else |
270 | break; | 283 | break; |
271 | if (offset > round_offset + 31*1024*1024) | 284 | if (offset > round_offset + 31 * 1024 * 1024) |
272 | { | 285 | { |
273 | if (((state->number_of_valid_frames > 2) && ((double) state->number_of_valid_frames / (double) state->number_of_frames) < 0.8)) | 286 | if (((state->number_of_valid_frames > 2) && |
287 | ( ((double) state->number_of_valid_frames | ||
288 | / (double) state->number_of_frames) < 0.8) )) | ||
274 | { | 289 | { |
275 | calculate_frame_statistics_and_maybe_report_it (plugin, state, proc, proc_cls); | 290 | calculate_frame_statistics_and_maybe_report_it (plugin, state, proc, |
291 | proc_cls); | ||
276 | } | 292 | } |
277 | return EXTRACTOR_mp3_discard_state_method (state); | 293 | return EXTRACTOR_mp3_discard_state_method (state); |
278 | } | 294 | } |
@@ -280,11 +296,12 @@ EXTRACTOR_mp3_extract_method (struct EXTRACTOR_PluginList *plugin, | |||
280 | pl_seek (plugin, offset + i, SEEK_SET); | 296 | pl_seek (plugin, offset + i, SEEK_SET); |
281 | if (4 != pl_read (plugin, &data, 4)) | 297 | if (4 != pl_read (plugin, &data, 4)) |
282 | { | 298 | { |
283 | calculate_frame_statistics_and_maybe_report_it (plugin, state, proc, proc_cls); | 299 | calculate_frame_statistics_and_maybe_report_it (plugin, state, proc, |
300 | proc_cls); | ||
284 | return EXTRACTOR_mp3_discard_state_method (state); | 301 | return EXTRACTOR_mp3_discard_state_method (state); |
285 | } | 302 | } |
286 | state->header = (data[0] << 24) | (data[1] << 16) | | 303 | state->header = (data[0] << 24) | (data[1] << 16) |
287 | (data[2] << 8) | data[3]; | 304 | | (data[2] << 8) | data[3]; |
288 | if ((state->header & MPA_SYNC_MASK) == MPA_SYNC_MASK) | 305 | if ((state->header & MPA_SYNC_MASK) == MPA_SYNC_MASK) |
289 | { | 306 | { |
290 | state->state = MP3_READING_FRAME; | 307 | state->state = MP3_READING_FRAME; |
@@ -336,8 +353,8 @@ EXTRACTOR_mp3_extract_method (struct EXTRACTOR_PluginList *plugin, | |||
336 | idx_num = (mpeg_ver - 1) * 3 + layer - 1; | 353 | idx_num = (mpeg_ver - 1) * 3 + layer - 1; |
337 | else | 354 | else |
338 | idx_num = 2 + layer; | 355 | idx_num = 2 + layer; |
339 | bitrate = 1000 * bitrate_table[(state->header >> MPA_BITRATE_SHIFT) & | 356 | bitrate = 1000 * bitrate_table[(state->header >> MPA_BITRATE_SHIFT) |
340 | MPA_BITRATE_MASK][idx_num]; | 357 | & MPA_BITRATE_MASK][idx_num]; |
341 | if (bitrate < 0) | 358 | if (bitrate < 0) |
342 | { | 359 | { |
343 | /*error in header */ | 360 | /*error in header */ |
@@ -345,8 +362,8 @@ EXTRACTOR_mp3_extract_method (struct EXTRACTOR_PluginList *plugin, | |||
345 | offset += 1; | 362 | offset += 1; |
346 | break; | 363 | break; |
347 | } | 364 | } |
348 | sample_rate = freq_table[(state->header >> MPA_FREQ_SHIFT) & | 365 | sample_rate = freq_table[(state->header >> MPA_FREQ_SHIFT) |
349 | MPA_FREQ_MASK][mpeg_ver - 1]; | 366 | & MPA_FREQ_MASK][mpeg_ver - 1]; |
350 | if (sample_rate <= 0) | 367 | if (sample_rate <= 0) |
351 | { | 368 | { |
352 | /*error in header */ | 369 | /*error in header */ |
@@ -358,9 +375,13 @@ EXTRACTOR_mp3_extract_method (struct EXTRACTOR_PluginList *plugin, | |||
358 | copyright_flag = (state->header >> MPA_COPYRIGHT_SHIFT) & 0x1; | 375 | copyright_flag = (state->header >> MPA_COPYRIGHT_SHIFT) & 0x1; |
359 | original_flag = (state->header >> MPA_ORIGINAL_SHIFT) & 0x1; | 376 | original_flag = (state->header >> MPA_ORIGINAL_SHIFT) & 0x1; |
360 | if (layer == LAYER_1) | 377 | if (layer == LAYER_1) |
361 | frame_size = (12 * bitrate / sample_rate + ((state->header >> MPA_PADDING_SHIFT) & 0x1)) * 4; | 378 | frame_size = (12 * bitrate / sample_rate + ((state->header |
379 | >> MPA_PADDING_SHIFT) | ||
380 | & 0x1)) * 4; | ||
362 | else | 381 | else |
363 | frame_size = 144 * bitrate / sample_rate + ((state->header >> MPA_PADDING_SHIFT) & 0x1); | 382 | frame_size = 144 * bitrate / sample_rate + ((state->header |
383 | >> MPA_PADDING_SHIFT) | ||
384 | & 0x1); | ||
364 | if (frame_size < 8) | 385 | if (frame_size < 8) |
365 | { | 386 | { |
366 | /*error in header */ | 387 | /*error in header */ |
@@ -390,4 +411,5 @@ EXTRACTOR_mp3_extract_method (struct EXTRACTOR_PluginList *plugin, | |||
390 | return 1; | 411 | return 1; |
391 | } | 412 | } |
392 | 413 | ||
414 | |||
393 | /* end of mp3_extractor.c */ | 415 | /* end of mp3_extractor.c */ |
diff --git a/src/plugins/old/pack.c b/src/plugins/old/pack.c index 968cf67..4f9e19d 100644 --- a/src/plugins/old/pack.c +++ b/src/plugins/old/pack.c | |||
@@ -27,7 +27,7 @@ MODIFICATIONS. | |||
27 | #include "platform.h" | 27 | #include "platform.h" |
28 | #include "pack.h" | 28 | #include "pack.h" |
29 | 29 | ||
30 | #if !(defined(_WIN32) && defined(cbNDRContext)) | 30 | #if ! (defined(_WIN32) && defined(cbNDRContext)) |
31 | typedef unsigned char byte; | 31 | typedef unsigned char byte; |
32 | #endif | 32 | #endif |
33 | typedef unsigned short half; | 33 | typedef unsigned short half; |
@@ -37,11 +37,10 @@ typedef signed short shalf; | |||
37 | typedef signed int sword; | 37 | typedef signed int sword; |
38 | 38 | ||
39 | 39 | ||
40 | |||
41 | int | 40 | int |
42 | EXTRACTOR_common_cat_unpack (const void *buf, | 41 | EXTRACTOR_common_cat_unpack (const void *buf, |
43 | const char *fmt, | 42 | const char *fmt, |
44 | ...) | 43 | ...) |
45 | { | 44 | { |
46 | va_list ap; | 45 | va_list ap; |
47 | word maxlen, len, *wordp; | 46 | word maxlen, len, *wordp; |
@@ -63,283 +62,282 @@ EXTRACTOR_common_cat_unpack (const void *buf, | |||
63 | va_start (ap, fmt); | 62 | va_start (ap, fmt); |
64 | 63 | ||
65 | while (*fmt) | 64 | while (*fmt) |
65 | { | ||
66 | nreps = 1; | ||
67 | |||
68 | if (isdigit ( (unsigned char) *fmt)) | ||
66 | { | 69 | { |
67 | nreps = 1; | 70 | /* We use cp instead of format to keep the 'const' qualifier of fmt */ |
71 | nreps = strtoul (fmt, &cp, 0); | ||
72 | fmt = cp; | ||
73 | if (*fmt == 'a') | ||
74 | isnonprefixed = 0; | ||
75 | } | ||
68 | 76 | ||
69 | if (isdigit ( (unsigned char) *fmt)) | 77 | switch (*fmt) |
78 | { | ||
79 | case 'B': | ||
80 | case 'b': | ||
81 | bytep = va_arg (ap, byte *); | ||
82 | for (i = 0; i < nreps; ++i) | ||
83 | { | ||
84 | *bytep = *bp++; | ||
85 | ++bytep; | ||
86 | npacked += 1; | ||
87 | } | ||
88 | break; | ||
89 | |||
90 | |||
91 | case 'h': | ||
92 | halfp = va_arg (ap, half *); | ||
93 | for (i = 0; i < nreps; ++i) | ||
94 | { | ||
95 | *halfp = *bp++; | ||
96 | *halfp |= *bp++ << 8; | ||
97 | ++halfp; | ||
98 | npacked += 2; | ||
99 | } | ||
100 | break; | ||
101 | |||
102 | case 'H': | ||
103 | halfp = va_arg (ap, half *); | ||
104 | for (i = 0; i < nreps; ++i) | ||
105 | { | ||
106 | *halfp = *bp++ << 8; | ||
107 | *halfp |= *bp++; | ||
108 | ++halfp; | ||
109 | npacked += 2; | ||
110 | } | ||
111 | break; | ||
112 | |||
113 | |||
114 | case 'w': | ||
115 | wordp = va_arg (ap, word *); | ||
116 | for (i = 0; i < nreps; ++i) | ||
117 | { | ||
118 | *wordp = *bp++; | ||
119 | *wordp |= *bp++ << 8; | ||
120 | *wordp |= *bp++ << 16; | ||
121 | *wordp |= *bp++ << 24; | ||
122 | ++wordp; | ||
123 | npacked += 4; | ||
124 | } | ||
125 | break; | ||
126 | |||
127 | case 'x': | ||
128 | ll = va_arg (ap, long long *); | ||
129 | for (i = 0; i < nreps; ++i) | ||
130 | { | ||
131 | *ll = ((long long) *bp++); | ||
132 | *ll |= ((long long) *bp++) << 8; | ||
133 | *ll |= ((long long) *bp++) << 16; | ||
134 | *ll |= ((long long) *bp++) << 24; | ||
135 | *ll |= ((long long) *bp++) << 32; | ||
136 | *ll |= ((long long) *bp++) << 40; | ||
137 | *ll |= ((long long) *bp++) << 48; | ||
138 | *ll |= ((long long) *bp++) << 56; | ||
139 | ++ll; | ||
140 | npacked += 8; | ||
141 | } | ||
142 | break; | ||
143 | |||
144 | case 'W': | ||
145 | wordp = va_arg (ap, word *); | ||
146 | for (i = 0; i < nreps; ++i) | ||
147 | { | ||
148 | *wordp = *bp++ << 24; | ||
149 | *wordp |= *bp++ << 16; | ||
150 | *wordp |= *bp++ << 8; | ||
151 | *wordp |= *bp++; | ||
152 | ++wordp; | ||
153 | npacked += 4; | ||
154 | } | ||
155 | break; | ||
156 | |||
157 | case 'X': | ||
158 | ll = va_arg (ap, long long *); | ||
159 | for (i = 0; i < nreps; ++i) | ||
160 | { | ||
161 | *ll = ((long long) *bp++) << 56; | ||
162 | *ll |= ((long long) *bp++) << 48; | ||
163 | *ll |= ((long long) *bp++) << 40; | ||
164 | *ll |= ((long long) *bp++) << 32; | ||
165 | *ll |= ((long long) *bp++) << 24; | ||
166 | *ll |= ((long long) *bp++) << 18; | ||
167 | *ll |= ((long long) *bp++) << 8; | ||
168 | *ll |= ((long long) *bp++); | ||
169 | ++ll; | ||
170 | npacked += 8; | ||
171 | } | ||
172 | break; | ||
173 | |||
174 | |||
175 | case 'A': | ||
176 | if (isnonprefixed) | ||
177 | { | ||
178 | maxlen = va_arg (ap, word); | ||
179 | arr = va_arg (ap, void *); | ||
180 | |||
181 | len = *bp++ << 24; | ||
182 | len |= *bp++ << 16; | ||
183 | len |= *bp++ << 8; | ||
184 | len |= *bp++; | ||
185 | |||
186 | if (len > maxlen) | ||
70 | { | 187 | { |
71 | /* We use cp instead of format to keep the 'const' qualifier of fmt */ | 188 | va_end (ap); |
72 | nreps = strtoul (fmt, &cp, 0); | 189 | return -1; |
73 | fmt = cp; | ||
74 | if (*fmt == 'a') | ||
75 | isnonprefixed = 0; | ||
76 | } | 190 | } |
77 | 191 | ||
78 | switch (*fmt) | 192 | memmove (arr, bp, len); |
193 | bp += len; | ||
194 | |||
195 | npacked += len; | ||
196 | } | ||
197 | else | ||
198 | { | ||
199 | cbvp = va_arg (ap, struct cat_bvec *); | ||
200 | for (i = 0; i < nreps; ++i) | ||
201 | { | ||
202 | maxlen = cbvp->len; | ||
203 | arr = cbvp->data; | ||
204 | |||
205 | len = *bp++ << 24; | ||
206 | len |= *bp++ << 16; | ||
207 | len |= *bp++ << 8; | ||
208 | len |= *bp++; | ||
209 | |||
210 | if (len > maxlen) | ||
211 | return -1; | ||
212 | |||
213 | memmove (arr, bp, len); | ||
214 | cbvp->len = len; | ||
215 | bp += len; | ||
216 | |||
217 | ++cbvp; | ||
218 | npacked += len; | ||
219 | } | ||
220 | isnonprefixed = 1; | ||
221 | } | ||
222 | break; | ||
223 | |||
224 | case 'C': | ||
225 | case 'c': | ||
226 | sbytep = va_arg (ap, sbyte *); | ||
227 | for (i = 0; i < nreps; ++i) | ||
228 | { | ||
229 | *sbytep = *bp++; | ||
230 | |||
231 | if ((sizeof (sbyte) > 1) && (*sbytep & 0x80)) | ||
232 | *sbytep |= (~0) << ((sizeof (sbyte) - 1) * 8); | ||
233 | |||
234 | ++sbytep; | ||
235 | npacked += 1; | ||
236 | } | ||
237 | break; | ||
238 | |||
239 | |||
240 | case 's': | ||
241 | shalfp = va_arg (ap, shalf *); | ||
242 | for (i = 0; i < nreps; ++i) | ||
243 | { | ||
244 | *shalfp = *bp++; | ||
245 | *shalfp |= *bp++ << 8; | ||
246 | |||
247 | if ((sizeof (shalf) > 2) && (*shalfp & 0x8000)) | ||
248 | *shalfp |= (~0) << ((sizeof (shalf) - 2) * 8); | ||
249 | |||
250 | ++shalfp; | ||
251 | npacked += 2; | ||
252 | } | ||
253 | break; | ||
254 | |||
255 | case 'S': | ||
256 | shalfp = va_arg (ap, shalf *); | ||
257 | for (i = 0; i < nreps; ++i) | ||
258 | { | ||
259 | *shalfp = *bp++ << 8; | ||
260 | *shalfp |= *bp++; | ||
261 | |||
262 | if ((sizeof (shalf) > 2) && (*shalfp & 0x8000)) | ||
263 | *shalfp |= (~0) << ((sizeof (shalf) - 2) * 8); | ||
264 | |||
265 | ++shalfp; | ||
266 | npacked += 2; | ||
267 | } | ||
268 | break; | ||
269 | |||
270 | case 'l': | ||
271 | swordp = va_arg (ap, sword *); | ||
272 | for (i = 0; i < nreps; ++i) | ||
273 | { | ||
274 | *swordp = *bp++; | ||
275 | *swordp |= *bp++ << 8; | ||
276 | *swordp |= *bp++ << 16; | ||
277 | *swordp |= *bp++ << 24; | ||
278 | |||
279 | if ((sizeof (swordp) > 4) && (*swordp & 0x80000000)) | ||
280 | *swordp |= (~0) << ((sizeof (sword) - 4) * 8); | ||
281 | |||
282 | ++swordp; | ||
283 | npacked += 4; | ||
284 | } | ||
285 | break; | ||
286 | |||
287 | case 'L': | ||
288 | swordp = va_arg (ap, sword *); | ||
289 | for (i = 0; i < nreps; ++i) | ||
290 | { | ||
291 | *swordp = *bp++ << 24; | ||
292 | *swordp |= *bp++ << 16; | ||
293 | *swordp |= *bp++ << 8; | ||
294 | *swordp |= *bp++; | ||
295 | |||
296 | if ((sizeof (swordp) > 4) && (*swordp & 0x80000000)) | ||
297 | *swordp |= (~0) << ((sizeof (sword) - 4) * 8); | ||
298 | |||
299 | ++swordp; | ||
300 | npacked += 4; | ||
301 | } | ||
302 | break; | ||
303 | |||
304 | case 'P': | ||
305 | cbvp = va_arg (ap, struct cat_bvec *); | ||
306 | for (i = 0; i < nreps; ++i) | ||
307 | { | ||
308 | len = *bp++ << 24; | ||
309 | len |= *bp++ << 16; | ||
310 | len |= *bp++ << 8; | ||
311 | len |= *bp++; | ||
312 | |||
313 | newbuf = (byte *) malloc (len); | ||
314 | |||
315 | if (! newbuf) | ||
79 | { | 316 | { |
80 | case 'B': | 317 | int j; |
81 | case 'b': | 318 | for (j = 0; j < i; j++) |
82 | bytep = va_arg (ap, byte *); | 319 | free (cbvp[i].data); |
83 | for (i = 0; i < nreps; ++i) | ||
84 | { | ||
85 | *bytep = *bp++; | ||
86 | ++bytep; | ||
87 | npacked += 1; | ||
88 | } | ||
89 | break; | ||
90 | |||
91 | |||
92 | |||
93 | case 'h': | ||
94 | halfp = va_arg (ap, half *); | ||
95 | for (i = 0; i < nreps; ++i) | ||
96 | { | ||
97 | *halfp = *bp++; | ||
98 | *halfp |= *bp++ << 8; | ||
99 | ++halfp; | ||
100 | npacked += 2; | ||
101 | } | ||
102 | break; | ||
103 | |||
104 | case 'H': | ||
105 | halfp = va_arg (ap, half *); | ||
106 | for (i = 0; i < nreps; ++i) | ||
107 | { | ||
108 | *halfp = *bp++ << 8; | ||
109 | *halfp |= *bp++; | ||
110 | ++halfp; | ||
111 | npacked += 2; | ||
112 | } | ||
113 | break; | ||
114 | |||
115 | |||
116 | case 'w': | ||
117 | wordp = va_arg (ap, word *); | ||
118 | for (i = 0; i < nreps; ++i) | ||
119 | { | ||
120 | *wordp = *bp++; | ||
121 | *wordp |= *bp++ << 8; | ||
122 | *wordp |= *bp++ << 16; | ||
123 | *wordp |= *bp++ << 24; | ||
124 | ++wordp; | ||
125 | npacked += 4; | ||
126 | } | ||
127 | break; | ||
128 | |||
129 | case 'x': | ||
130 | ll = va_arg (ap, long long *); | ||
131 | for (i = 0; i < nreps; ++i) | ||
132 | { | ||
133 | *ll = ((long long) *bp++); | ||
134 | *ll |= ((long long) *bp++) << 8; | ||
135 | *ll |= ((long long) *bp++) << 16; | ||
136 | *ll |= ((long long) *bp++) << 24; | ||
137 | *ll |= ((long long) *bp++) << 32; | ||
138 | *ll |= ((long long) *bp++) << 40; | ||
139 | *ll |= ((long long) *bp++) << 48; | ||
140 | *ll |= ((long long) *bp++) << 56; | ||
141 | ++ll; | ||
142 | npacked += 8; | ||
143 | } | ||
144 | break; | ||
145 | |||
146 | case 'W': | ||
147 | wordp = va_arg (ap, word *); | ||
148 | for (i = 0; i < nreps; ++i) | ||
149 | { | ||
150 | *wordp = *bp++ << 24; | ||
151 | *wordp |= *bp++ << 16; | ||
152 | *wordp |= *bp++ << 8; | ||
153 | *wordp |= *bp++; | ||
154 | ++wordp; | ||
155 | npacked += 4; | ||
156 | } | ||
157 | break; | ||
158 | |||
159 | case 'X': | ||
160 | ll = va_arg (ap, long long *); | ||
161 | for (i = 0; i < nreps; ++i) | ||
162 | { | ||
163 | *ll = ((long long) *bp++) << 56; | ||
164 | *ll |= ((long long) *bp++) << 48; | ||
165 | *ll |= ((long long) *bp++) << 40; | ||
166 | *ll |= ((long long) *bp++) << 32; | ||
167 | *ll |= ((long long) *bp++) << 24; | ||
168 | *ll |= ((long long) *bp++) << 18; | ||
169 | *ll |= ((long long) *bp++) << 8; | ||
170 | *ll |= ((long long) *bp++); | ||
171 | ++ll; | ||
172 | npacked += 8; | ||
173 | } | ||
174 | break; | ||
175 | |||
176 | |||
177 | case 'A': | ||
178 | if (isnonprefixed) | ||
179 | { | ||
180 | maxlen = va_arg (ap, word); | ||
181 | arr = va_arg (ap, void *); | ||
182 | |||
183 | len = *bp++ << 24; | ||
184 | len |= *bp++ << 16; | ||
185 | len |= *bp++ << 8; | ||
186 | len |= *bp++; | ||
187 | |||
188 | if (len > maxlen) | ||
189 | { | ||
190 | va_end (ap); | ||
191 | return -1; | ||
192 | } | ||
193 | |||
194 | memmove (arr, bp, len); | ||
195 | bp += len; | ||
196 | |||
197 | npacked += len; | ||
198 | } | ||
199 | else | ||
200 | { | ||
201 | cbvp = va_arg (ap, struct cat_bvec *); | ||
202 | for (i = 0; i < nreps; ++i) | ||
203 | { | ||
204 | maxlen = cbvp->len; | ||
205 | arr = cbvp->data; | ||
206 | |||
207 | len = *bp++ << 24; | ||
208 | len |= *bp++ << 16; | ||
209 | len |= *bp++ << 8; | ||
210 | len |= *bp++; | ||
211 | |||
212 | if (len > maxlen) | ||
213 | return -1; | ||
214 | |||
215 | memmove (arr, bp, len); | ||
216 | cbvp->len = len; | ||
217 | bp += len; | ||
218 | |||
219 | ++cbvp; | ||
220 | npacked += len; | ||
221 | } | ||
222 | isnonprefixed = 1; | ||
223 | } | ||
224 | break; | ||
225 | |||
226 | case 'C': | ||
227 | case 'c': | ||
228 | sbytep = va_arg (ap, sbyte *); | ||
229 | for (i = 0; i < nreps; ++i) | ||
230 | { | ||
231 | *sbytep = *bp++; | ||
232 | |||
233 | if ((sizeof (sbyte) > 1) && (*sbytep & 0x80)) | ||
234 | *sbytep |= (~0) << ((sizeof (sbyte) - 1) * 8); | ||
235 | |||
236 | ++sbytep; | ||
237 | npacked += 1; | ||
238 | } | ||
239 | break; | ||
240 | |||
241 | |||
242 | case 's': | ||
243 | shalfp = va_arg (ap, shalf *); | ||
244 | for (i = 0; i < nreps; ++i) | ||
245 | { | ||
246 | *shalfp = *bp++; | ||
247 | *shalfp |= *bp++ << 8; | ||
248 | |||
249 | if ((sizeof (shalf) > 2) && (*shalfp & 0x8000)) | ||
250 | *shalfp |= (~0) << ((sizeof (shalf) - 2) * 8); | ||
251 | |||
252 | ++shalfp; | ||
253 | npacked += 2; | ||
254 | } | ||
255 | break; | ||
256 | |||
257 | case 'S': | ||
258 | shalfp = va_arg (ap, shalf *); | ||
259 | for (i = 0; i < nreps; ++i) | ||
260 | { | ||
261 | *shalfp = *bp++ << 8; | ||
262 | *shalfp |= *bp++; | ||
263 | |||
264 | if ((sizeof (shalf) > 2) && (*shalfp & 0x8000)) | ||
265 | *shalfp |= (~0) << ((sizeof (shalf) - 2) * 8); | ||
266 | |||
267 | ++shalfp; | ||
268 | npacked += 2; | ||
269 | } | ||
270 | break; | ||
271 | |||
272 | case 'l': | ||
273 | swordp = va_arg (ap, sword *); | ||
274 | for (i = 0; i < nreps; ++i) | ||
275 | { | ||
276 | *swordp = *bp++; | ||
277 | *swordp |= *bp++ << 8; | ||
278 | *swordp |= *bp++ << 16; | ||
279 | *swordp |= *bp++ << 24; | ||
280 | |||
281 | if ((sizeof (swordp) > 4) && (*swordp & 0x80000000)) | ||
282 | *swordp |= (~0) << ((sizeof (sword) - 4) * 8); | ||
283 | |||
284 | ++swordp; | ||
285 | npacked += 4; | ||
286 | } | ||
287 | break; | ||
288 | |||
289 | case 'L': | ||
290 | swordp = va_arg (ap, sword *); | ||
291 | for (i = 0; i < nreps; ++i) | ||
292 | { | ||
293 | *swordp = *bp++ << 24; | ||
294 | *swordp |= *bp++ << 16; | ||
295 | *swordp |= *bp++ << 8; | ||
296 | *swordp |= *bp++; | ||
297 | |||
298 | if ((sizeof (swordp) > 4) && (*swordp & 0x80000000)) | ||
299 | *swordp |= (~0) << ((sizeof (sword) - 4) * 8); | ||
300 | |||
301 | ++swordp; | ||
302 | npacked += 4; | ||
303 | } | ||
304 | break; | ||
305 | |||
306 | case 'P': | ||
307 | cbvp = va_arg (ap, struct cat_bvec *); | ||
308 | for (i = 0; i < nreps; ++i) | ||
309 | { | ||
310 | len = *bp++ << 24; | ||
311 | len |= *bp++ << 16; | ||
312 | len |= *bp++ << 8; | ||
313 | len |= *bp++; | ||
314 | |||
315 | newbuf = (byte *) malloc (len); | ||
316 | |||
317 | if (!newbuf) | ||
318 | { | ||
319 | int j; | ||
320 | for (j = 0; j < i; j++) | ||
321 | free (cbvp[i].data); | ||
322 | va_end (ap); | ||
323 | return -1; | ||
324 | } | ||
325 | |||
326 | memmove (newbuf, bp, len); | ||
327 | cbvp[i].data = newbuf; | ||
328 | cbvp[i].len = len; | ||
329 | |||
330 | bp += len; | ||
331 | npacked += len; | ||
332 | } | ||
333 | break; | ||
334 | |||
335 | default: | ||
336 | va_end (ap); | 320 | va_end (ap); |
337 | return -1; | 321 | return -1; |
338 | } | 322 | } |
339 | 323 | ||
340 | ++fmt; | 324 | memmove (newbuf, bp, len); |
325 | cbvp[i].data = newbuf; | ||
326 | cbvp[i].len = len; | ||
327 | |||
328 | bp += len; | ||
329 | npacked += len; | ||
330 | } | ||
331 | break; | ||
332 | |||
333 | default: | ||
334 | va_end (ap); | ||
335 | return -1; | ||
341 | } | 336 | } |
342 | 337 | ||
338 | ++fmt; | ||
339 | } | ||
340 | |||
343 | va_end (ap); | 341 | va_end (ap); |
344 | return 0; | 342 | return 0; |
345 | } | 343 | } |
diff --git a/src/plugins/old/pack.h b/src/plugins/old/pack.h index fe4e168..74bc172 100644 --- a/src/plugins/old/pack.h +++ b/src/plugins/old/pack.h | |||
@@ -45,18 +45,16 @@ MODIFICATIONS. | |||
45 | p - (unpack only) value is a pointer to a pointer. Generate the buffer | 45 | p - (unpack only) value is a pointer to a pointer. Generate the buffer |
46 | to hold the data. | 46 | to hold the data. |
47 | */ | 47 | */ |
48 | int | 48 | int |
49 | EXTRACTOR_common_cat_unpack(const void * buf, | 49 | EXTRACTOR_common_cat_unpack (const void *buf, |
50 | const char *fmt, | 50 | const char *fmt, |
51 | ...); | 51 | ...); |
52 | 52 | ||
53 | struct cat_bvec | 53 | struct cat_bvec |
54 | { | 54 | { |
55 | unsigned long len; | 55 | unsigned long len; |
56 | void * data; | 56 | void *data; |
57 | }; | 57 | }; |
58 | 58 | ||
59 | 59 | ||
60 | #endif /* __CAT_PACK_H */ | 60 | #endif /* __CAT_PACK_H */ |
61 | |||
62 | |||
diff --git a/src/plugins/old/qt_extractor.c b/src/plugins/old/qt_extractor.c index f3420bb..2db3306 100644 --- a/src/plugins/old/qt_extractor.c +++ b/src/plugins/old/qt_extractor.c | |||
@@ -178,7 +178,7 @@ static const char *const genre_names[] = { | |||
178 | }; | 178 | }; |
179 | 179 | ||
180 | #define GENRE_NAME_COUNT \ | 180 | #define GENRE_NAME_COUNT \ |
181 | ((unsigned int)(sizeof genre_names / sizeof (const char *const))) | 181 | ((unsigned int) (sizeof genre_names / sizeof (const char *const))) |
182 | 182 | ||
183 | 183 | ||
184 | static const char *languages[] = { | 184 | static const char *languages[] = { |
@@ -299,7 +299,7 @@ typedef struct | |||
299 | const char *mime; | 299 | const char *mime; |
300 | } C2M; | 300 | } C2M; |
301 | 301 | ||
302 | /* see http://www.mp4ra.org/filetype.html | 302 | /* see http://www.mp4ra.org/filetype.html |
303 | * http://www.ftyps.com/ */ | 303 | * http://www.ftyps.com/ */ |
304 | static C2M ftMap[] = { | 304 | static C2M ftMap[] = { |
305 | {"qt ", "video/quicktime"}, | 305 | {"qt ", "video/quicktime"}, |
@@ -356,7 +356,7 @@ static CHE cHm[] = { | |||
356 | {"src", EXTRACTOR_METATYPE_CONTRIBUTOR_NAME}, | 356 | {"src", EXTRACTOR_METATYPE_CONTRIBUTOR_NAME}, |
357 | {"prf", EXTRACTOR_METATYPE_PERFORMER }, | 357 | {"prf", EXTRACTOR_METATYPE_PERFORMER }, |
358 | {"prd", EXTRACTOR_METATYPE_PRODUCER}, | 358 | {"prd", EXTRACTOR_METATYPE_PRODUCER}, |
359 | {"PRD", EXTRACTOR_METATYPE_PRODUCT_VERSION}, | 359 | {"PRD", EXTRACTOR_METATYPE_PRODUCT_VERSION}, |
360 | {"swr", EXTRACTOR_METATYPE_PRODUCED_BY_SOFTWARE}, | 360 | {"swr", EXTRACTOR_METATYPE_PRODUCED_BY_SOFTWARE}, |
361 | {"isr", EXTRACTOR_METATYPE_ISRC}, | 361 | {"isr", EXTRACTOR_METATYPE_ISRC}, |
362 | {"wrt", EXTRACTOR_METATYPE_WRITER}, | 362 | {"wrt", EXTRACTOR_METATYPE_WRITER}, |
@@ -396,7 +396,7 @@ static ITTagConversionEntry it_to_extr_table[] = { | |||
396 | {"keyw", EXTRACTOR_METATYPE_KEYWORDS}, | 396 | {"keyw", EXTRACTOR_METATYPE_KEYWORDS}, |
397 | {"desc", EXTRACTOR_METATYPE_DESCRIPTION}, | 397 | {"desc", EXTRACTOR_METATYPE_DESCRIPTION}, |
398 | {"tvnn", EXTRACTOR_METATYPE_NETWORK_NAME}, | 398 | {"tvnn", EXTRACTOR_METATYPE_NETWORK_NAME}, |
399 | {"tvsh", EXTRACTOR_METATYPE_SHOW_NAME}, | 399 | {"tvsh", EXTRACTOR_METATYPE_SHOW_NAME}, |
400 | {"tven", EXTRACTOR_METATYPE_NETWORK_NAME}, | 400 | {"tven", EXTRACTOR_METATYPE_NETWORK_NAME}, |
401 | {NULL, EXTRACTOR_METATYPE_RESERVED} | 401 | {NULL, EXTRACTOR_METATYPE_RESERVED} |
402 | }; | 402 | }; |
@@ -441,25 +441,26 @@ checkAtomValid (const char *buffer, size_t size, size_t pos) | |||
441 | return 0; | 441 | return 0; |
442 | atom = (const Atom *) &buffer[pos]; | 442 | atom = (const Atom *) &buffer[pos]; |
443 | if (ntohl (atom->size) == 1) | 443 | if (ntohl (atom->size) == 1) |
444 | { | 444 | { |
445 | if ((pos + sizeof (LongAtom) > size) || (pos + sizeof (LongAtom) < pos)) | 445 | if ((pos + sizeof (LongAtom) > size) || (pos + sizeof (LongAtom) < pos)) |
446 | return 0; | 446 | return 0; |
447 | latom = (const LongAtom *) &buffer[pos]; | 447 | latom = (const LongAtom *) &buffer[pos]; |
448 | atomSize = ntohll (latom->size); | 448 | atomSize = ntohll (latom->size); |
449 | if ((atomSize < sizeof (LongAtom)) || | 449 | if ((atomSize < sizeof (LongAtom)) || |
450 | (atomSize + pos > size) || (atomSize + pos < atomSize)) | 450 | (atomSize + pos > size) || (atomSize + pos < atomSize)) |
451 | return 0; | 451 | return 0; |
452 | } | 452 | } |
453 | else | 453 | else |
454 | { | 454 | { |
455 | atomSize = ntohl (atom->size); | 455 | atomSize = ntohl (atom->size); |
456 | if ((atomSize < sizeof (Atom)) || | 456 | if ((atomSize < sizeof (Atom)) || |
457 | (atomSize + pos > size) || (atomSize + pos < atomSize)) | 457 | (atomSize + pos > size) || (atomSize + pos < atomSize)) |
458 | return 0; | 458 | return 0; |
459 | } | 459 | } |
460 | return 1; | 460 | return 1; |
461 | } | 461 | } |
462 | 462 | ||
463 | |||
463 | /** | 464 | /** |
464 | * Assumes that checkAtomValid has already been called. | 465 | * Assumes that checkAtomValid has already been called. |
465 | */ | 466 | */ |
@@ -470,13 +471,14 @@ getAtomSize (const char *buf) | |||
470 | const LongAtom *latom; | 471 | const LongAtom *latom; |
471 | atom = (const Atom *) buf; | 472 | atom = (const Atom *) buf; |
472 | if (ntohl (atom->size) == 1) | 473 | if (ntohl (atom->size) == 1) |
473 | { | 474 | { |
474 | latom = (const LongAtom *) buf; | 475 | latom = (const LongAtom *) buf; |
475 | return ntohll (latom->size); | 476 | return ntohll (latom->size); |
476 | } | 477 | } |
477 | return ntohl (atom->size); | 478 | return ntohl (atom->size); |
478 | } | 479 | } |
479 | 480 | ||
481 | |||
480 | /** | 482 | /** |
481 | * Assumes that checkAtomValid has already been called. | 483 | * Assumes that checkAtomValid has already been called. |
482 | */ | 484 | */ |
@@ -491,6 +493,7 @@ getAtomHeaderSize (const char *buf) | |||
491 | return sizeof (Atom); | 493 | return sizeof (Atom); |
492 | } | 494 | } |
493 | 495 | ||
496 | |||
494 | struct ExtractContext | 497 | struct ExtractContext |
495 | { | 498 | { |
496 | EXTRACTOR_MetaDataProcessor proc; | 499 | EXTRACTOR_MetaDataProcessor proc; |
@@ -500,22 +503,21 @@ struct ExtractContext | |||
500 | 503 | ||
501 | static void | 504 | static void |
502 | addKeyword (enum EXTRACTOR_MetaType type, | 505 | addKeyword (enum EXTRACTOR_MetaType type, |
503 | const char *str, | 506 | const char *str, |
504 | struct ExtractContext *ec) | 507 | struct ExtractContext *ec) |
505 | { | 508 | { |
506 | if (ec->ret != 0) | 509 | if (ec->ret != 0) |
507 | return; | 510 | return; |
508 | ec->ret = ec->proc (ec->proc_cls, | 511 | ec->ret = ec->proc (ec->proc_cls, |
509 | "qt", | 512 | "qt", |
510 | type, | 513 | type, |
511 | EXTRACTOR_METAFORMAT_UTF8, | 514 | EXTRACTOR_METAFORMAT_UTF8, |
512 | "text/plain", | 515 | "text/plain", |
513 | str, | 516 | str, |
514 | strlen(str)+1); | 517 | strlen (str) + 1); |
515 | } | 518 | } |
516 | 519 | ||
517 | 520 | ||
518 | |||
519 | /** | 521 | /** |
520 | * Assumes that checkAtomValid has already been called. | 522 | * Assumes that checkAtomValid has already been called. |
521 | */ | 523 | */ |
@@ -538,8 +540,8 @@ typedef struct | |||
538 | static int handleAtom (HandlerEntry *handlers, | 540 | static int handleAtom (HandlerEntry *handlers, |
539 | const char *input, | 541 | const char *input, |
540 | size_t size, | 542 | size_t size, |
541 | size_t pos, | 543 | size_t pos, |
542 | struct ExtractContext *ec); | 544 | struct ExtractContext *ec); |
543 | 545 | ||
544 | static HandlerEntry all_handlers[]; | 546 | static HandlerEntry all_handlers[]; |
545 | static HandlerEntry ilst_handlers[]; | 547 | static HandlerEntry ilst_handlers[]; |
@@ -550,7 +552,7 @@ static HandlerEntry ilst_handlers[]; | |||
550 | */ | 552 | */ |
551 | static int | 553 | static int |
552 | processAtoms (HandlerEntry *handlers, const char *input, | 554 | processAtoms (HandlerEntry *handlers, const char *input, |
553 | size_t size, struct ExtractContext *ec) | 555 | size_t size, struct ExtractContext *ec) |
554 | { | 556 | { |
555 | size_t pos; | 557 | size_t pos; |
556 | 558 | ||
@@ -558,14 +560,15 @@ processAtoms (HandlerEntry *handlers, const char *input, | |||
558 | return 1; | 560 | return 1; |
559 | pos = 0; | 561 | pos = 0; |
560 | while (pos < size - sizeof (Atom)) | 562 | while (pos < size - sizeof (Atom)) |
561 | { | 563 | { |
562 | if (0 == handleAtom (handlers, input, size, pos, ec)) | 564 | if (0 == handleAtom (handlers, input, size, pos, ec)) |
563 | return 0; | 565 | return 0; |
564 | pos += getAtomSize (&input[pos]); | 566 | pos += getAtomSize (&input[pos]); |
565 | } | 567 | } |
566 | return 1; | 568 | return 1; |
567 | } | 569 | } |
568 | 570 | ||
571 | |||
569 | /** | 572 | /** |
570 | * Process all atoms. | 573 | * Process all atoms. |
571 | * @return 0 on error, 1 for success, -1 for unknown atom type | 574 | * @return 0 on error, 1 for success, -1 for unknown atom type |
@@ -574,9 +577,10 @@ static int | |||
574 | processAllAtoms (const char *input, | 577 | processAllAtoms (const char *input, |
575 | size_t size, struct ExtractContext *ec) | 578 | size_t size, struct ExtractContext *ec) |
576 | { | 579 | { |
577 | return processAtoms(all_handlers, input, size, ec); | 580 | return processAtoms (all_handlers, input, size, ec); |
578 | } | 581 | } |
579 | 582 | ||
583 | |||
580 | /** | 584 | /** |
581 | * Handle the moov atom. | 585 | * Handle the moov atom. |
582 | * @return 0 on error, 1 for success, -1 for unknown atom type | 586 | * @return 0 on error, 1 for success, -1 for unknown atom type |
@@ -590,6 +594,7 @@ moovHandler (const char *input, | |||
590 | getAtomSize (&input[pos]) - hdr, ec); | 594 | getAtomSize (&input[pos]) - hdr, ec); |
591 | } | 595 | } |
592 | 596 | ||
597 | |||
593 | /* see http://developer.apple.com/documentation/QuickTime/QTFF/QTFFChap1/chapter_2_section_5.html */ | 598 | /* see http://developer.apple.com/documentation/QuickTime/QTFF/QTFFChap1/chapter_2_section_5.html */ |
594 | typedef struct | 599 | typedef struct |
595 | { | 600 | { |
@@ -609,7 +614,8 @@ ftypHandler (const char *input, | |||
609 | const FileType *ft; | 614 | const FileType *ft; |
610 | int i; | 615 | int i; |
611 | 616 | ||
612 | if (getAtomSize (&input[pos]) < sizeof (FileType)) { | 617 | if (getAtomSize (&input[pos]) < sizeof (FileType)) |
618 | { | ||
613 | return 0; | 619 | return 0; |
614 | } | 620 | } |
615 | ft = (const FileType *) &input[pos]; | 621 | ft = (const FileType *) &input[pos]; |
@@ -622,6 +628,7 @@ ftypHandler (const char *input, | |||
622 | return 1; | 628 | return 1; |
623 | } | 629 | } |
624 | 630 | ||
631 | |||
625 | typedef struct | 632 | typedef struct |
626 | { | 633 | { |
627 | Atom hdr; | 634 | Atom hdr; |
@@ -662,13 +669,14 @@ mvhdHandler (const char *input, | |||
662 | return 0; | 669 | return 0; |
663 | m = (const MovieHeaderAtom *) &input[pos]; | 670 | m = (const MovieHeaderAtom *) &input[pos]; |
664 | snprintf (duration, | 671 | snprintf (duration, |
665 | sizeof(duration), | 672 | sizeof(duration), |
666 | "%us", | 673 | "%us", |
667 | ntohl (m->duration) / ntohl (m->timeScale)); | 674 | ntohl (m->duration) / ntohl (m->timeScale)); |
668 | addKeyword (EXTRACTOR_METATYPE_DURATION, duration, ec); | 675 | addKeyword (EXTRACTOR_METATYPE_DURATION, duration, ec); |
669 | return 1; | 676 | return 1; |
670 | } | 677 | } |
671 | 678 | ||
679 | |||
672 | typedef struct | 680 | typedef struct |
673 | { | 681 | { |
674 | Atom cmovAtom; | 682 | Atom cmovAtom; |
@@ -699,9 +707,9 @@ cmovHandler (const char *input, | |||
699 | (0 != memcmp (&c->cmvdAtom.type, "cmvd", 4)) || | 707 | (0 != memcmp (&c->cmvdAtom.type, "cmvd", 4)) || |
700 | (ntohl (c->cmvdAtom.size) != | 708 | (ntohl (c->cmvdAtom.size) != |
701 | getAtomSize (&input[pos]) - sizeof (Atom) * 2 - 4)) | 709 | getAtomSize (&input[pos]) - sizeof (Atom) * 2 - 4)) |
702 | { | 710 | { |
703 | return 0; /* dcom must be 12 bytes */ | 711 | return 0; /* dcom must be 12 bytes */ |
704 | } | 712 | } |
705 | s = ntohl (c->decompressedSize); | 713 | s = ntohl (c->decompressedSize); |
706 | if (s > 16 * 1024 * 1024) | 714 | if (s > 16 * 1024 * 1024) |
707 | return 1; /* ignore, too big! */ | 715 | return 1; /* ignore, too big! */ |
@@ -718,27 +726,28 @@ cmovHandler (const char *input, | |||
718 | z_state.opaque = (voidpf) 0; | 726 | z_state.opaque = (voidpf) 0; |
719 | z_ret_code = inflateInit (&z_state); | 727 | z_ret_code = inflateInit (&z_state); |
720 | if (Z_OK != z_ret_code) | 728 | if (Z_OK != z_ret_code) |
721 | { | 729 | { |
722 | free (buf); | 730 | free (buf); |
723 | return 0; /* crc error? */ | 731 | return 0; /* crc error? */ |
724 | } | 732 | } |
725 | z_ret_code = inflate (&z_state, Z_NO_FLUSH); | 733 | z_ret_code = inflate (&z_state, Z_NO_FLUSH); |
726 | if ((z_ret_code != Z_OK) && (z_ret_code != Z_STREAM_END)) | 734 | if ((z_ret_code != Z_OK) && (z_ret_code != Z_STREAM_END)) |
727 | { | 735 | { |
728 | free (buf); | 736 | free (buf); |
729 | return 0; /* decode error? */ | 737 | return 0; /* decode error? */ |
730 | } | 738 | } |
731 | z_ret_code = inflateEnd (&z_state); | 739 | z_ret_code = inflateEnd (&z_state); |
732 | if (Z_OK != z_ret_code) | 740 | if (Z_OK != z_ret_code) |
733 | { | 741 | { |
734 | free (buf); | 742 | free (buf); |
735 | return 0; /* decode error? */ | 743 | return 0; /* decode error? */ |
736 | } | 744 | } |
737 | ret = handleAtom (all_handlers, buf, s, 0, ec); | 745 | ret = handleAtom (all_handlers, buf, s, 0, ec); |
738 | free (buf); | 746 | free (buf); |
739 | return ret; | 747 | return ret; |
740 | } | 748 | } |
741 | 749 | ||
750 | |||
742 | typedef struct | 751 | typedef struct |
743 | { | 752 | { |
744 | short integer; | 753 | short integer; |
@@ -780,18 +789,19 @@ tkhdHandler (const char *input, | |||
780 | return 0; | 789 | return 0; |
781 | m = (const TrackAtom *) &input[pos]; | 790 | m = (const TrackAtom *) &input[pos]; |
782 | if (ntohs (m->track_width.integer) != 0) | 791 | if (ntohs (m->track_width.integer) != 0) |
783 | { | 792 | { |
784 | /* if actually a/the video track */ | 793 | /* if actually a/the video track */ |
785 | snprintf (dimensions, | 794 | snprintf (dimensions, |
786 | sizeof(dimensions), | 795 | sizeof(dimensions), |
787 | "%dx%d", | 796 | "%dx%d", |
788 | ntohs (m->track_width.integer), | 797 | ntohs (m->track_width.integer), |
789 | ntohs (m->track_height.integer)); | 798 | ntohs (m->track_height.integer)); |
790 | addKeyword (EXTRACTOR_METATYPE_IMAGE_DIMENSIONS, dimensions, ec); | 799 | addKeyword (EXTRACTOR_METATYPE_IMAGE_DIMENSIONS, dimensions, ec); |
791 | } | 800 | } |
792 | return 1; | 801 | return 1; |
793 | } | 802 | } |
794 | 803 | ||
804 | |||
795 | static int | 805 | static int |
796 | trakHandler (const char *input, | 806 | trakHandler (const char *input, |
797 | size_t size, size_t pos, struct ExtractContext *ec) | 807 | size_t size, size_t pos, struct ExtractContext *ec) |
@@ -801,6 +811,7 @@ trakHandler (const char *input, | |||
801 | getAtomSize (&input[pos]) - hdr, ec); | 811 | getAtomSize (&input[pos]) - hdr, ec); |
802 | } | 812 | } |
803 | 813 | ||
814 | |||
804 | static int | 815 | static int |
805 | metaHandler (const char *input, | 816 | metaHandler (const char *input, |
806 | size_t size, size_t pos, struct ExtractContext *ec) | 817 | size_t size, size_t pos, struct ExtractContext *ec) |
@@ -812,6 +823,7 @@ metaHandler (const char *input, | |||
812 | getAtomSize (&input[pos]) - hdr - 4, ec); | 823 | getAtomSize (&input[pos]) - hdr - 4, ec); |
813 | } | 824 | } |
814 | 825 | ||
826 | |||
815 | typedef struct | 827 | typedef struct |
816 | { | 828 | { |
817 | Atom header; | 829 | Atom header; |
@@ -873,13 +885,14 @@ c_Handler (const char *input, | |||
873 | int i; | 885 | int i; |
874 | 886 | ||
875 | i = 0; | 887 | i = 0; |
876 | while ((cHm[i].pfx != NULL) && (0 != memcmp (&input[pos+5], cHm[i].pfx, 3))) | 888 | while ((cHm[i].pfx != NULL) && (0 != memcmp (&input[pos + 5], cHm[i].pfx, 3))) |
877 | i++; | 889 | i++; |
878 | if (cHm[i].pfx != NULL) | 890 | if (cHm[i].pfx != NULL) |
879 | return processTextTag (input, size, pos, cHm[i].type, ec); | 891 | return processTextTag (input, size, pos, cHm[i].type, ec); |
880 | return -1; /* not found */ | 892 | return -1; /* not found */ |
881 | } | 893 | } |
882 | 894 | ||
895 | |||
883 | static int | 896 | static int |
884 | udtaHandler (const char *input, | 897 | udtaHandler (const char *input, |
885 | size_t size, size_t pos, struct ExtractContext *ec) | 898 | size_t size, size_t pos, struct ExtractContext *ec) |
@@ -889,13 +902,14 @@ udtaHandler (const char *input, | |||
889 | getAtomSize (&input[pos]) - hdr, ec); | 902 | getAtomSize (&input[pos]) - hdr, ec); |
890 | } | 903 | } |
891 | 904 | ||
905 | |||
892 | static int | 906 | static int |
893 | processDataAtom (const char *input, | 907 | processDataAtom (const char *input, |
894 | size_t size, /* parent atom size */ | 908 | size_t size, /* parent atom size */ |
895 | size_t pos, | 909 | size_t pos, |
896 | const char *patom, | 910 | const char *patom, |
897 | enum EXTRACTOR_MetaType type, | 911 | enum EXTRACTOR_MetaType type, |
898 | struct ExtractContext *ec) | 912 | struct ExtractContext *ec) |
899 | { | 913 | { |
900 | char *meta; | 914 | char *meta; |
901 | unsigned char version; | 915 | unsigned char version; |
@@ -907,55 +921,62 @@ processDataAtom (const char *input, | |||
907 | 921 | ||
908 | hdr = getAtomHeaderSize (&input[pos]); | 922 | hdr = getAtomHeaderSize (&input[pos]); |
909 | asize = getAtomSize (&input[pos]); | 923 | asize = getAtomSize (&input[pos]); |
910 | if (memcmp(&input[pos+4], "data", 4) != 0) | 924 | if (memcmp (&input[pos + 4], "data", 4) != 0) |
911 | return -1; | 925 | return -1; |
912 | 926 | ||
913 | if (asize < hdr + 8 || /* header + u32 flags + u32 reserved */ | 927 | if ((asize < hdr + 8) || /* header + u32 flags + u32 reserved */ |
914 | asize > (getAtomSize(&patom[0]) - 8)) | 928 | (asize > (getAtomSize (&patom[0]) - 8)) ) |
915 | return 0; | 929 | return 0; |
916 | 930 | ||
917 | len = (unsigned int)(asize - (hdr + 8)); | 931 | len = (unsigned int) (asize - (hdr + 8)); |
918 | 932 | ||
919 | version = input[pos+8]; | 933 | version = input[pos + 8]; |
920 | flags = ((unsigned char)input[pos+9]<<16) | | 934 | flags = ((unsigned char) input[pos + 9] << 16) |
921 | ((unsigned char)input[pos+10]<<8) | | 935 | | ((unsigned char) input[pos + 10] << 8) |
922 | (unsigned char)input[pos+11]; | 936 | | (unsigned char) input[pos + 11]; |
923 | #if DEBUG | 937 | #if DEBUG |
924 | printf("[data] version:%02x flags:%08x txtlen:%d\n", version, flags, len); | 938 | printf ("[data] version:%02x flags:%08x txtlen:%d\n", version, flags, len); |
925 | #endif | 939 | #endif |
926 | 940 | ||
927 | if (version != 0) | 941 | if (version != 0) |
928 | return -1; | 942 | return -1; |
929 | 943 | ||
930 | if (flags == 0x0) { /* binary data */ | 944 | if (flags == 0x0) /* binary data */ |
931 | if (memcmp(&patom[4], "gnre", 4) == 0) { | 945 | { |
932 | if (len >= 2) { | 946 | if (memcmp (&patom[4], "gnre", 4) == 0) |
933 | unsigned short genre = ((unsigned char)input[pos+16] << 8) | | 947 | { |
934 | (unsigned char)input[pos+17]; | 948 | if (len >= 2) |
935 | if (genre > 0 && genre < GENRE_NAME_COUNT) | 949 | { |
936 | addKeyword(type, genre_names[genre-1], ec); | 950 | unsigned short genre = ((unsigned char) input[pos + 16] << 8) |
951 | | (unsigned char) input[pos + 17]; | ||
952 | if ((genre > 0) && (genre < GENRE_NAME_COUNT)) | ||
953 | addKeyword (type, genre_names[genre - 1], ec); | ||
937 | } | 954 | } |
938 | return 1; | 955 | return 1; |
939 | } | 956 | } |
940 | else if ((memcmp(&patom[4], "trkn", 4) == 0) || | 957 | else if ((memcmp (&patom[4], "trkn", 4) == 0) || |
941 | (memcmp(&patom[4], "disk", 4) == 0)) { | 958 | (memcmp (&patom[4], "disk", 4) == 0)) |
942 | if (len >= 4) { | 959 | { |
943 | unsigned short n = ((unsigned char)input[pos+18] << 8) | | 960 | if (len >= 4) |
944 | (unsigned char)input[pos+19]; | 961 | { |
962 | unsigned short n = ((unsigned char) input[pos + 18] << 8) | ||
963 | | (unsigned char) input[pos + 19]; | ||
945 | char s[8]; | 964 | char s[8]; |
946 | snprintf(s, 8, "%d", n); | 965 | snprintf (s, 8, "%d", n); |
947 | addKeyword(type, s, ec); | 966 | addKeyword (type, s, ec); |
948 | } | 967 | } |
949 | } | 968 | } |
950 | else { | 969 | else |
970 | { | ||
951 | return -1; | 971 | return -1; |
952 | } | 972 | } |
953 | } | 973 | } |
954 | else if (flags == 0x1) { /* text data */ | 974 | else if (flags == 0x1) /* text data */ |
975 | { | ||
955 | meta = malloc (len + 1); | 976 | meta = malloc (len + 1); |
956 | if (meta == NULL) | 977 | if (meta == NULL) |
957 | return 0; | 978 | return 0; |
958 | memcpy (meta, &input[pos+16], len); | 979 | memcpy (meta, &input[pos + 16], len); |
959 | meta[len] = '\0'; | 980 | meta[len] = '\0'; |
960 | for (i = 0; i < len; i++) | 981 | for (i = 0; i < len; i++) |
961 | if (meta[i] == '\r') | 982 | if (meta[i] == '\r') |
@@ -968,12 +989,13 @@ processDataAtom (const char *input, | |||
968 | return -1; | 989 | return -1; |
969 | } | 990 | } |
970 | 991 | ||
992 | |||
971 | /* NOTE: iTunes tag processing should, in theory, be limited to iTunes | 993 | /* NOTE: iTunes tag processing should, in theory, be limited to iTunes |
972 | * file types (from ftyp), but, in reality, it seems that there are other | 994 | * file types (from ftyp), but, in reality, it seems that there are other |
973 | * files, like 3gpp, out in the wild with iTunes tags. */ | 995 | * files, like 3gpp, out in the wild with iTunes tags. */ |
974 | static int | 996 | static int |
975 | iTunesTagHandler (const char *input, | 997 | iTunesTagHandler (const char *input, |
976 | size_t size, size_t pos, struct ExtractContext *ec) | 998 | size_t size, size_t pos, struct ExtractContext *ec) |
977 | { | 999 | { |
978 | unsigned long long asize; | 1000 | unsigned long long asize; |
979 | unsigned int hdr; | 1001 | unsigned int hdr; |
@@ -986,24 +1008,24 @@ iTunesTagHandler (const char *input, | |||
986 | return 0; | 1008 | return 0; |
987 | 1009 | ||
988 | i = 0; | 1010 | i = 0; |
989 | while ((it_to_extr_table[i].atom_type != NULL) && | 1011 | while ((it_to_extr_table[i].atom_type != NULL) && |
990 | (0 != memcmp (&input[pos+4], it_to_extr_table[i].atom_type, 4))) | 1012 | (0 != memcmp (&input[pos + 4], it_to_extr_table[i].atom_type, 4))) |
991 | i++; | 1013 | i++; |
992 | if (it_to_extr_table[i].atom_type != NULL) | 1014 | if (it_to_extr_table[i].atom_type != NULL) |
993 | return processDataAtom(input, asize, pos+hdr, &input[pos], | 1015 | return processDataAtom (input, asize, pos + hdr, &input[pos], |
994 | it_to_extr_table[i].type, ec); | 1016 | it_to_extr_table[i].type, ec); |
995 | 1017 | ||
996 | return -1; | 1018 | return -1; |
997 | } | 1019 | } |
998 | 1020 | ||
999 | 1021 | ||
1000 | static int | 1022 | static int |
1001 | ilstHandler (const char *input, | 1023 | ilstHandler (const char *input, |
1002 | size_t size, size_t pos, struct ExtractContext *ec) | 1024 | size_t size, size_t pos, struct ExtractContext *ec) |
1003 | { | 1025 | { |
1004 | unsigned int hdr = getAtomHeaderSize (&input[pos]); | 1026 | unsigned int hdr = getAtomHeaderSize (&input[pos]); |
1005 | return processAtoms(ilst_handlers, &input[pos + hdr], | 1027 | return processAtoms (ilst_handlers, &input[pos + hdr], |
1006 | getAtomSize(&input[pos]) - hdr, ec); | 1028 | getAtomSize (&input[pos]) - hdr, ec); |
1007 | } | 1029 | } |
1008 | 1030 | ||
1009 | 1031 | ||
@@ -1099,23 +1121,23 @@ handleAtom (HandlerEntry *handlers, const char *input, | |||
1099 | { | 1121 | { |
1100 | int i; | 1122 | int i; |
1101 | if (0 == checkAtomValid (input, size, pos)) | 1123 | if (0 == checkAtomValid (input, size, pos)) |
1102 | { | 1124 | { |
1103 | return 0; | 1125 | return 0; |
1104 | } | 1126 | } |
1105 | i = 0; | 1127 | i = 0; |
1106 | while ((handlers[i].name != NULL) && | 1128 | while ((handlers[i].name != NULL) && |
1107 | (0 != memcmp (&input[pos + 4], handlers[i].name, 4))) | 1129 | (0 != memcmp (&input[pos + 4], handlers[i].name, 4))) |
1108 | i++; | 1130 | i++; |
1109 | if (handlers[i].name == NULL) | 1131 | if (handlers[i].name == NULL) |
1110 | { | 1132 | { |
1111 | #if DEBUG | 1133 | #if DEBUG |
1112 | char b[5]; | 1134 | char b[5]; |
1113 | memcpy (b, &input[pos + 4], 4); | 1135 | memcpy (b, &input[pos + 4], 4); |
1114 | b[4] = '\0'; | 1136 | b[4] = '\0'; |
1115 | printf ("No handler for `%s'\n", b); | 1137 | printf ("No handler for `%s'\n", b); |
1116 | #endif | 1138 | #endif |
1117 | return -1; | 1139 | return -1; |
1118 | } | 1140 | } |
1119 | i = handlers[i].handler (input, size, pos, ec); | 1141 | i = handlers[i].handler (input, size, pos, ec); |
1120 | #if DEBUG | 1142 | #if DEBUG |
1121 | printf ("Running handler for `%4s' at %u completed with result %d\n", | 1143 | printf ("Running handler for `%4s' at %u completed with result %d\n", |
@@ -1124,18 +1146,19 @@ handleAtom (HandlerEntry *handlers, const char *input, | |||
1124 | return i; | 1146 | return i; |
1125 | } | 1147 | } |
1126 | 1148 | ||
1149 | |||
1127 | /* mimetypes: | 1150 | /* mimetypes: |
1128 | video/quicktime: mov,qt: Quicktime animation; | 1151 | video/quicktime: mov,qt: Quicktime animation; |
1129 | video/x-quicktime: mov,qt: Quicktime animation; | 1152 | video/x-quicktime: mov,qt: Quicktime animation; |
1130 | application/x-quicktimeplayer: qtl: Quicktime list; | 1153 | application/x-quicktimeplayer: qtl: Quicktime list; |
1131 | */ | 1154 | */ |
1132 | 1155 | ||
1133 | int | 1156 | int |
1134 | EXTRACTOR_qt_extract (const char *data, | 1157 | EXTRACTOR_qt_extract (const char *data, |
1135 | size_t size, | 1158 | size_t size, |
1136 | EXTRACTOR_MetaDataProcessor proc, | 1159 | EXTRACTOR_MetaDataProcessor proc, |
1137 | void *proc_cls, | 1160 | void *proc_cls, |
1138 | const char *options) | 1161 | const char *options) |
1139 | { | 1162 | { |
1140 | struct ExtractContext ec; | 1163 | struct ExtractContext ec; |
1141 | ec.proc = proc; | 1164 | ec.proc = proc; |
@@ -1145,4 +1168,5 @@ EXTRACTOR_qt_extract (const char *data, | |||
1145 | return ec.ret; | 1168 | return ec.ret; |
1146 | } | 1169 | } |
1147 | 1170 | ||
1171 | |||
1148 | /* end of qt_extractor.c */ | 1172 | /* end of qt_extractor.c */ |
diff --git a/src/plugins/old/real_extractor.c b/src/plugins/old/real_extractor.c index 0ca343c..cfac031 100644 --- a/src/plugins/old/real_extractor.c +++ b/src/plugins/old/real_extractor.c | |||
@@ -77,9 +77,9 @@ typedef struct | |||
77 | 77 | ||
78 | 78 | ||
79 | static int | 79 | static int |
80 | processMediaProperties (const Media_Properties * prop, | 80 | processMediaProperties (const Media_Properties *prop, |
81 | EXTRACTOR_MetaDataProcessor proc, | 81 | EXTRACTOR_MetaDataProcessor proc, |
82 | void *proc_cls) | 82 | void *proc_cls) |
83 | { | 83 | { |
84 | 84 | ||
85 | UINT8 mime_type_size; | 85 | UINT8 mime_type_size; |
@@ -95,28 +95,29 @@ processMediaProperties (const Media_Properties * prop, | |||
95 | return 0; | 95 | return 0; |
96 | 96 | ||
97 | mime_type_size = prop->data[prop->stream_name_size]; | 97 | mime_type_size = prop->data[prop->stream_name_size]; |
98 | if (prop_size > prop->stream_name_size + sizeof (UINT8) + | 98 | if (prop_size > prop->stream_name_size + sizeof (UINT8) |
99 | +mime_type_size + sizeof (Media_Properties)) | 99 | + +mime_type_size + sizeof (Media_Properties)) |
100 | { | 100 | { |
101 | char data[mime_type_size + 1]; | 101 | char data[mime_type_size + 1]; |
102 | memcpy (data, &prop->data[prop->stream_name_size + 1], mime_type_size); | 102 | memcpy (data, &prop->data[prop->stream_name_size + 1], mime_type_size); |
103 | data[mime_type_size] = '\0'; | 103 | data[mime_type_size] = '\0'; |
104 | 104 | ||
105 | return proc (proc_cls, | 105 | return proc (proc_cls, |
106 | "real", | 106 | "real", |
107 | EXTRACTOR_METATYPE_MIMETYPE, | 107 | EXTRACTOR_METATYPE_MIMETYPE, |
108 | EXTRACTOR_METAFORMAT_UTF8, | 108 | EXTRACTOR_METAFORMAT_UTF8, |
109 | "text/plain", | 109 | "text/plain", |
110 | data, | 110 | data, |
111 | strlen (data)); | 111 | strlen (data)); |
112 | } | 112 | } |
113 | return 0; | 113 | return 0; |
114 | } | 114 | } |
115 | 115 | ||
116 | |||
116 | static int | 117 | static int |
117 | processContentDescription (const Content_Description * prop, | 118 | processContentDescription (const Content_Description *prop, |
118 | EXTRACTOR_MetaDataProcessor proc, | 119 | EXTRACTOR_MetaDataProcessor proc, |
119 | void *proc_cls) | 120 | void *proc_cls) |
120 | { | 121 | { |
121 | UINT16 author_len; | 122 | UINT16 author_len; |
122 | UINT16 copyright_len; | 123 | UINT16 copyright_len; |
@@ -137,23 +138,23 @@ processContentDescription (const Content_Description * prop, | |||
137 | title_len = ntohs (prop->title_len); | 138 | title_len = ntohs (prop->title_len); |
138 | if (prop_size <= title_len + sizeof (UINT16) + sizeof (Content_Description)) | 139 | if (prop_size <= title_len + sizeof (UINT16) + sizeof (Content_Description)) |
139 | return 0; | 140 | return 0; |
140 | author_len = ntohs (*(UINT16 *) & prop->data[title_len]); | 141 | author_len = ntohs (*(UINT16 *) &prop->data[title_len]); |
141 | if (prop_size <= title_len + sizeof (UINT16) | 142 | if (prop_size <= title_len + sizeof (UINT16) |
142 | + author_len + sizeof (Content_Description)) | 143 | + author_len + sizeof (Content_Description)) |
143 | return 0; | 144 | return 0; |
144 | 145 | ||
145 | copyright_len = ntohs (*(UINT16 *) & prop->data[title_len + | 146 | copyright_len = ntohs (*(UINT16 *) &prop->data[title_len |
146 | author_len + | 147 | + author_len |
147 | sizeof (UINT16)]); | 148 | + sizeof (UINT16)]); |
148 | 149 | ||
149 | if (prop_size <= title_len + 2 * sizeof (UINT16) | 150 | if (prop_size <= title_len + 2 * sizeof (UINT16) |
150 | + author_len + copyright_len + sizeof (Content_Description)) | 151 | + author_len + copyright_len + sizeof (Content_Description)) |
151 | return 0; | 152 | return 0; |
152 | 153 | ||
153 | comment_len = ntohs (*(UINT16 *) & prop->data[title_len + | 154 | comment_len = ntohs (*(UINT16 *) &prop->data[title_len |
154 | author_len + | 155 | + author_len |
155 | copyright_len + | 156 | + copyright_len |
156 | 2 * sizeof (UINT16)]); | 157 | + 2 * sizeof (UINT16)]); |
157 | 158 | ||
158 | if (prop_size < title_len + 3 * sizeof (UINT16) | 159 | if (prop_size < title_len + 3 * sizeof (UINT16) |
159 | + author_len + copyright_len + comment_len | 160 | + author_len + copyright_len + comment_len |
@@ -163,78 +164,79 @@ processContentDescription (const Content_Description * prop, | |||
163 | ret = 0; | 164 | ret = 0; |
164 | title = malloc (title_len + 1); | 165 | title = malloc (title_len + 1); |
165 | if (title != NULL) | 166 | if (title != NULL) |
166 | { | 167 | { |
167 | memcpy (title, &prop->data[0], title_len); | 168 | memcpy (title, &prop->data[0], title_len); |
168 | title[title_len] = '\0'; | 169 | title[title_len] = '\0'; |
169 | ret = proc (proc_cls, | 170 | ret = proc (proc_cls, |
170 | "real", | 171 | "real", |
171 | EXTRACTOR_METATYPE_TITLE, | 172 | EXTRACTOR_METATYPE_TITLE, |
172 | EXTRACTOR_METAFORMAT_UTF8, | 173 | EXTRACTOR_METAFORMAT_UTF8, |
173 | "text/plain", | 174 | "text/plain", |
174 | title, | 175 | title, |
175 | strlen (title)+1); | 176 | strlen (title) + 1); |
176 | free (title); | 177 | free (title); |
177 | } | 178 | } |
178 | if (ret != 0) | 179 | if (ret != 0) |
179 | return ret; | 180 | return ret; |
180 | 181 | ||
181 | author = malloc (author_len + 1); | 182 | author = malloc (author_len + 1); |
182 | if (author != NULL) | 183 | if (author != NULL) |
183 | { | 184 | { |
184 | memcpy (author, &prop->data[title_len + sizeof (UINT16)], author_len); | 185 | memcpy (author, &prop->data[title_len + sizeof (UINT16)], author_len); |
185 | author[author_len] = '\0'; | 186 | author[author_len] = '\0'; |
186 | ret = proc (proc_cls, | 187 | ret = proc (proc_cls, |
187 | "real", | 188 | "real", |
188 | EXTRACTOR_METATYPE_AUTHOR_NAME, | 189 | EXTRACTOR_METATYPE_AUTHOR_NAME, |
189 | EXTRACTOR_METAFORMAT_UTF8, | 190 | EXTRACTOR_METAFORMAT_UTF8, |
190 | "text/plain", | 191 | "text/plain", |
191 | author, | 192 | author, |
192 | strlen (author)+1); | 193 | strlen (author) + 1); |
193 | free (author); | 194 | free (author); |
194 | } | 195 | } |
195 | if (ret != 0) | 196 | if (ret != 0) |
196 | return ret; | 197 | return ret; |
197 | 198 | ||
198 | copyright = malloc (copyright_len + 1); | 199 | copyright = malloc (copyright_len + 1); |
199 | if (copyright != NULL) | 200 | if (copyright != NULL) |
200 | { | 201 | { |
201 | memcpy (copyright, | 202 | memcpy (copyright, |
202 | &prop->data[title_len + sizeof (UINT16) * 2 + author_len], | 203 | &prop->data[title_len + sizeof (UINT16) * 2 + author_len], |
203 | copyright_len); | 204 | copyright_len); |
204 | copyright[copyright_len] = '\0'; | 205 | copyright[copyright_len] = '\0'; |
205 | ret = proc (proc_cls, | 206 | ret = proc (proc_cls, |
206 | "real", | 207 | "real", |
207 | EXTRACTOR_METATYPE_COPYRIGHT, | 208 | EXTRACTOR_METATYPE_COPYRIGHT, |
208 | EXTRACTOR_METAFORMAT_UTF8, | 209 | EXTRACTOR_METAFORMAT_UTF8, |
209 | "text/plain", | 210 | "text/plain", |
210 | copyright, | 211 | copyright, |
211 | strlen (copyright)+1); | 212 | strlen (copyright) + 1); |
212 | free (copyright); | 213 | free (copyright); |
213 | } | 214 | } |
214 | if (ret != 0) | 215 | if (ret != 0) |
215 | return ret; | 216 | return ret; |
216 | 217 | ||
217 | comment = malloc (comment_len + 1); | 218 | comment = malloc (comment_len + 1); |
218 | if (comment != NULL) | 219 | if (comment != NULL) |
219 | { | 220 | { |
220 | memcpy (comment, | 221 | memcpy (comment, |
221 | &prop->data[title_len + sizeof (UINT16) * 3 + author_len + | 222 | &prop->data[title_len + sizeof (UINT16) * 3 + author_len |
222 | copyright_len], comment_len); | 223 | + copyright_len], comment_len); |
223 | comment[comment_len] = '\0'; | 224 | comment[comment_len] = '\0'; |
224 | ret = proc (proc_cls, | 225 | ret = proc (proc_cls, |
225 | "real", | 226 | "real", |
226 | EXTRACTOR_METATYPE_COMMENT, | 227 | EXTRACTOR_METATYPE_COMMENT, |
227 | EXTRACTOR_METAFORMAT_UTF8, | 228 | EXTRACTOR_METAFORMAT_UTF8, |
228 | "text/plain", | 229 | "text/plain", |
229 | comment, | 230 | comment, |
230 | strlen (comment)+1); | 231 | strlen (comment) + 1); |
231 | free (comment); | 232 | free (comment); |
232 | } | 233 | } |
233 | if (ret != 0) | 234 | if (ret != 0) |
234 | return ret; | 235 | return ret; |
235 | return 0; | 236 | return 0; |
236 | } | 237 | } |
237 | 238 | ||
239 | |||
238 | typedef struct RAFF4_header | 240 | typedef struct RAFF4_header |
239 | { | 241 | { |
240 | unsigned short version; | 242 | unsigned short version; |
@@ -281,13 +283,14 @@ stndup (const char *str, size_t n) | |||
281 | return tmp; | 283 | return tmp; |
282 | } | 284 | } |
283 | 285 | ||
286 | |||
284 | /* audio/vnd.rn-realaudio */ | 287 | /* audio/vnd.rn-realaudio */ |
285 | int | 288 | int |
286 | EXTRACTOR_real_extract (const unsigned char *data, | 289 | EXTRACTOR_real_extract (const unsigned char *data, |
287 | size_t size, | 290 | size_t size, |
288 | EXTRACTOR_MetaDataProcessor proc, | 291 | EXTRACTOR_MetaDataProcessor proc, |
289 | void *proc_cls, | 292 | void *proc_cls, |
290 | const char *options) | 293 | const char *options) |
291 | { | 294 | { |
292 | const unsigned char *pos; | 295 | const unsigned char *pos; |
293 | const unsigned char *end; | 296 | const unsigned char *end; |
@@ -303,132 +306,134 @@ EXTRACTOR_real_extract (const unsigned char *data, | |||
303 | if (size <= 2 * sizeof (int)) | 306 | if (size <= 2 * sizeof (int)) |
304 | return 0; | 307 | return 0; |
305 | if (RAFF4_HEADER == ntohl (*(int *) data)) | 308 | if (RAFF4_HEADER == ntohl (*(int *) data)) |
309 | { | ||
310 | /* HELIX */ | ||
311 | if (size <= RAFF4_HDR_SIZE + 16 + 4) | ||
312 | return 0; | ||
313 | if (0 != proc (proc_cls, | ||
314 | "real", | ||
315 | EXTRACTOR_METATYPE_MIMETYPE, | ||
316 | EXTRACTOR_METAFORMAT_UTF8, | ||
317 | "text/plain", | ||
318 | "audio/vnd.rn-realaudio", | ||
319 | strlen ("audio/vnd.rn-realaudio") + 1)) | ||
320 | return 1; | ||
321 | hdr = (const RAFF4_header *) &data[16]; | ||
322 | if (ntohs (hdr->header_length) + 16 > size) | ||
323 | return 0; | ||
324 | tlen = data[16 + RAFF4_HDR_SIZE]; | ||
325 | if (tlen + RAFF4_HDR_SIZE + 20 > size) | ||
326 | return 0; | ||
327 | alen = data[17 + tlen + RAFF4_HDR_SIZE]; | ||
328 | if (tlen + alen + RAFF4_HDR_SIZE + 20 > size) | ||
329 | return 0; | ||
330 | clen = data[18 + tlen + alen + RAFF4_HDR_SIZE]; | ||
331 | if (tlen + alen + clen + RAFF4_HDR_SIZE + 20 > size) | ||
332 | return 0; | ||
333 | aplen = data[19 + tlen + clen + alen + RAFF4_HDR_SIZE]; | ||
334 | if (tlen + alen + clen + aplen + RAFF4_HDR_SIZE + 20 > size) | ||
335 | return 0; | ||
336 | ret = 0; | ||
337 | if ( (tlen > 0) && (ret == 0) ) | ||
306 | { | 338 | { |
307 | /* HELIX */ | 339 | x = stndup ((const char *) &data[17 + RAFF4_HDR_SIZE], tlen); |
308 | if (size <= RAFF4_HDR_SIZE + 16 + 4) | 340 | if (x != NULL) |
309 | return 0; | 341 | { |
310 | if (0 != proc (proc_cls, | 342 | ret = proc (proc_cls, |
311 | "real", | 343 | "real", |
312 | EXTRACTOR_METATYPE_MIMETYPE, | 344 | EXTRACTOR_METATYPE_MIMETYPE, |
313 | EXTRACTOR_METAFORMAT_UTF8, | 345 | EXTRACTOR_METAFORMAT_UTF8, |
314 | "text/plain", | 346 | "text/plain", |
315 | "audio/vnd.rn-realaudio", | 347 | x, |
316 | strlen ("audio/vnd.rn-realaudio")+1)) | 348 | strlen (x) + 1); |
317 | return 1; | 349 | free (x); |
318 | hdr = (const RAFF4_header *) &data[16]; | 350 | } |
319 | if (ntohs (hdr->header_length) + 16 > size) | ||
320 | return 0; | ||
321 | tlen = data[16 + RAFF4_HDR_SIZE]; | ||
322 | if (tlen + RAFF4_HDR_SIZE + 20 > size) | ||
323 | return 0; | ||
324 | alen = data[17 + tlen + RAFF4_HDR_SIZE]; | ||
325 | if (tlen + alen + RAFF4_HDR_SIZE + 20 > size) | ||
326 | return 0; | ||
327 | clen = data[18 + tlen + alen + RAFF4_HDR_SIZE]; | ||
328 | if (tlen + alen + clen + RAFF4_HDR_SIZE + 20 > size) | ||
329 | return 0; | ||
330 | aplen = data[19 + tlen + clen + alen + RAFF4_HDR_SIZE]; | ||
331 | if (tlen + alen + clen + aplen + RAFF4_HDR_SIZE + 20 > size) | ||
332 | return 0; | ||
333 | ret = 0; | ||
334 | if ( (tlen > 0) && (ret == 0) ) | ||
335 | { | ||
336 | x = stndup ((const char *) &data[17 + RAFF4_HDR_SIZE], tlen); | ||
337 | if (x != NULL) | ||
338 | { | ||
339 | ret = proc (proc_cls, | ||
340 | "real", | ||
341 | EXTRACTOR_METATYPE_MIMETYPE, | ||
342 | EXTRACTOR_METAFORMAT_UTF8, | ||
343 | "text/plain", | ||
344 | x, | ||
345 | strlen (x)+1); | ||
346 | free (x); | ||
347 | } | ||
348 | } | ||
349 | if ( (alen > 0) && (ret == 0) ) | ||
350 | { | ||
351 | x = stndup ((const char *) &data[18 + RAFF4_HDR_SIZE + tlen], alen); | ||
352 | if (x != NULL) | ||
353 | { | ||
354 | ret = proc (proc_cls, | ||
355 | "real", | ||
356 | EXTRACTOR_METATYPE_MIMETYPE, | ||
357 | EXTRACTOR_METAFORMAT_UTF8, | ||
358 | "text/plain", | ||
359 | x, | ||
360 | strlen (x)+1); | ||
361 | free (x); | ||
362 | } | ||
363 | } | ||
364 | if ( (clen > 0) && (ret == 0) ) | ||
365 | { | ||
366 | x = stndup ((const char *) &data[19 + RAFF4_HDR_SIZE + tlen + alen], clen); | ||
367 | if (x != NULL) | ||
368 | { | ||
369 | ret = proc (proc_cls, | ||
370 | "real", | ||
371 | EXTRACTOR_METATYPE_MIMETYPE, | ||
372 | EXTRACTOR_METAFORMAT_UTF8, | ||
373 | "text/plain", | ||
374 | x, | ||
375 | strlen (x)+1); | ||
376 | free (x); | ||
377 | } | ||
378 | } | ||
379 | if ( (aplen > 0) && (ret == 0) ) | ||
380 | { | ||
381 | x = stndup ((const char *) &data[20 + RAFF4_HDR_SIZE + tlen + alen + clen], aplen); | ||
382 | if (x != NULL) | ||
383 | { | ||
384 | ret = proc (proc_cls, | ||
385 | "real", | ||
386 | EXTRACTOR_METATYPE_MIMETYPE, | ||
387 | EXTRACTOR_METAFORMAT_UTF8, | ||
388 | "text/plain", | ||
389 | x, | ||
390 | strlen (x)+1); | ||
391 | free (x); | ||
392 | } | ||
393 | } | ||
394 | return ret; | ||
395 | } | 351 | } |
352 | if ( (alen > 0) && (ret == 0) ) | ||
353 | { | ||
354 | x = stndup ((const char *) &data[18 + RAFF4_HDR_SIZE + tlen], alen); | ||
355 | if (x != NULL) | ||
356 | { | ||
357 | ret = proc (proc_cls, | ||
358 | "real", | ||
359 | EXTRACTOR_METATYPE_MIMETYPE, | ||
360 | EXTRACTOR_METAFORMAT_UTF8, | ||
361 | "text/plain", | ||
362 | x, | ||
363 | strlen (x) + 1); | ||
364 | free (x); | ||
365 | } | ||
366 | } | ||
367 | if ( (clen > 0) && (ret == 0) ) | ||
368 | { | ||
369 | x = stndup ((const char *) &data[19 + RAFF4_HDR_SIZE + tlen + alen], | ||
370 | clen); | ||
371 | if (x != NULL) | ||
372 | { | ||
373 | ret = proc (proc_cls, | ||
374 | "real", | ||
375 | EXTRACTOR_METATYPE_MIMETYPE, | ||
376 | EXTRACTOR_METAFORMAT_UTF8, | ||
377 | "text/plain", | ||
378 | x, | ||
379 | strlen (x) + 1); | ||
380 | free (x); | ||
381 | } | ||
382 | } | ||
383 | if ( (aplen > 0) && (ret == 0) ) | ||
384 | { | ||
385 | x = stndup ((const char *) &data[20 + RAFF4_HDR_SIZE + tlen + alen | ||
386 | + clen], aplen); | ||
387 | if (x != NULL) | ||
388 | { | ||
389 | ret = proc (proc_cls, | ||
390 | "real", | ||
391 | EXTRACTOR_METATYPE_MIMETYPE, | ||
392 | EXTRACTOR_METAFORMAT_UTF8, | ||
393 | "text/plain", | ||
394 | x, | ||
395 | strlen (x) + 1); | ||
396 | free (x); | ||
397 | } | ||
398 | } | ||
399 | return ret; | ||
400 | } | ||
396 | if (REAL_HEADER == ntohl (*(int *) data)) | 401 | if (REAL_HEADER == ntohl (*(int *) data)) |
402 | { | ||
403 | /* old real */ | ||
404 | end = &data[size]; | ||
405 | pos = &data[0]; | ||
406 | ret = 0; | ||
407 | while (0 == ret) | ||
397 | { | 408 | { |
398 | /* old real */ | 409 | if ((pos + 8 >= end) || (pos + 8 < pos)) |
399 | end = &data[size]; | 410 | break; |
400 | pos = &data[0]; | 411 | length = ntohl (*(((unsigned int *) pos) + 1)); |
401 | ret = 0; | 412 | if (length <= 0) |
402 | while (0 == ret) | 413 | break; |
403 | { | 414 | if ((pos + length >= end) || (pos + length < pos)) |
404 | if ((pos + 8 >= end) || (pos + 8 < pos)) | 415 | break; |
405 | break; | 416 | switch (ntohl (*((unsigned int *) pos))) |
406 | length = ntohl (*(((unsigned int *) pos) + 1)); | 417 | { |
407 | if (length <= 0) | 418 | case MDPR_HEADER: |
408 | break; | 419 | ret = processMediaProperties ((Media_Properties *) pos, |
409 | if ((pos + length >= end) || (pos + length < pos)) | 420 | proc, |
410 | break; | 421 | proc_cls); |
411 | switch (ntohl (*((unsigned int *) pos))) | 422 | pos += length; |
412 | { | 423 | break; |
413 | case MDPR_HEADER: | 424 | case CONT_HEADER: |
414 | ret = processMediaProperties ((Media_Properties *) pos, | 425 | ret = processContentDescription ((Content_Description *) pos, |
415 | proc, | 426 | proc, |
416 | proc_cls); | 427 | proc_cls); |
417 | pos += length; | 428 | pos += length; |
418 | break; | 429 | break; |
419 | case CONT_HEADER: | 430 | case REAL_HEADER: /* treat like default */ |
420 | ret = processContentDescription ((Content_Description *) pos, | 431 | default: |
421 | proc, | 432 | pos += length; |
422 | proc_cls); | 433 | break; |
423 | pos += length; | 434 | } |
424 | break; | ||
425 | case REAL_HEADER: /* treat like default */ | ||
426 | default: | ||
427 | pos += length; | ||
428 | break; | ||
429 | } | ||
430 | } | ||
431 | return ret; | ||
432 | } | 435 | } |
436 | return ret; | ||
437 | } | ||
433 | return 0; | 438 | return 0; |
434 | } | 439 | } |
diff --git a/src/plugins/ole2_extractor.c b/src/plugins/ole2_extractor.c index a48b726..38b380a 100644 --- a/src/plugins/ole2_extractor.c +++ b/src/plugins/ole2_extractor.c | |||
@@ -66,9 +66,9 @@ | |||
66 | */ | 66 | */ |
67 | static int | 67 | static int |
68 | add_metadata (EXTRACTOR_MetaDataProcessor proc, | 68 | add_metadata (EXTRACTOR_MetaDataProcessor proc, |
69 | void *proc_cls, | 69 | void *proc_cls, |
70 | const char *phrase, | 70 | const char *phrase, |
71 | enum EXTRACTOR_MetaType type) | 71 | enum EXTRACTOR_MetaType type) |
72 | { | 72 | { |
73 | char *tmp; | 73 | char *tmp; |
74 | int ret; | 74 | int ret; |
@@ -85,15 +85,15 @@ add_metadata (EXTRACTOR_MetaDataProcessor proc, | |||
85 | return 0; | 85 | return 0; |
86 | 86 | ||
87 | while ( (strlen (tmp) > 0) && | 87 | while ( (strlen (tmp) > 0) && |
88 | (isblank ((unsigned char) tmp [strlen (tmp) - 1])) ) | 88 | (isblank ((unsigned char) tmp [strlen (tmp) - 1])) ) |
89 | tmp [strlen (tmp) - 1] = '\0'; | 89 | tmp [strlen (tmp) - 1] = '\0'; |
90 | ret = proc (proc_cls, | 90 | ret = proc (proc_cls, |
91 | "ole2", | 91 | "ole2", |
92 | type, | 92 | type, |
93 | EXTRACTOR_METAFORMAT_UTF8, | 93 | EXTRACTOR_METAFORMAT_UTF8, |
94 | "text/plain", | 94 | "text/plain", |
95 | tmp, | 95 | tmp, |
96 | strlen (tmp) + 1); | 96 | strlen (tmp) + 1); |
97 | free (tmp); | 97 | free (tmp); |
98 | return ret; | 98 | return ret; |
99 | } | 99 | } |
@@ -133,7 +133,7 @@ static struct Matches tmap[] = { | |||
133 | { "RevisionNumber", EXTRACTOR_METATYPE_REVISION_NUMBER }, | 133 | { "RevisionNumber", EXTRACTOR_METATYPE_REVISION_NUMBER }, |
134 | { "NumBytes", EXTRACTOR_METATYPE_EMBEDDED_FILE_SIZE }, | 134 | { "NumBytes", EXTRACTOR_METATYPE_EMBEDDED_FILE_SIZE }, |
135 | { "CreatedTime", EXTRACTOR_METATYPE_CREATION_DATE }, | 135 | { "CreatedTime", EXTRACTOR_METATYPE_CREATION_DATE }, |
136 | { "LastSavedTime" , EXTRACTOR_METATYPE_MODIFICATION_DATE }, | 136 | { "LastSavedTime", EXTRACTOR_METATYPE_MODIFICATION_DATE }, |
137 | { "gsf:company", EXTRACTOR_METATYPE_COMPANY }, | 137 | { "gsf:company", EXTRACTOR_METATYPE_COMPANY }, |
138 | { "gsf:character-count", EXTRACTOR_METATYPE_CHARACTER_COUNT }, | 138 | { "gsf:character-count", EXTRACTOR_METATYPE_CHARACTER_COUNT }, |
139 | { "gsf:page-count", EXTRACTOR_METATYPE_PAGE_COUNT }, | 139 | { "gsf:page-count", EXTRACTOR_METATYPE_PAGE_COUNT }, |
@@ -194,8 +194,8 @@ struct ProcContext | |||
194 | */ | 194 | */ |
195 | static void | 195 | static void |
196 | process_metadata (gpointer key, | 196 | process_metadata (gpointer key, |
197 | gpointer value, | 197 | gpointer value, |
198 | gpointer user_data) | 198 | gpointer user_data) |
199 | { | 199 | { |
200 | const char *type = key; | 200 | const char *type = key; |
201 | const GsfDocProp *prop = value; | 201 | const GsfDocProp *prop = value; |
@@ -211,75 +211,76 @@ process_metadata (gpointer key, | |||
211 | return; | 211 | return; |
212 | gval = gsf_doc_prop_get_val (prop); | 212 | gval = gsf_doc_prop_get_val (prop); |
213 | 213 | ||
214 | if (G_VALUE_TYPE(gval) == G_TYPE_STRING) | 214 | if (G_VALUE_TYPE (gval) == G_TYPE_STRING) |
215 | { | 215 | { |
216 | const char *gvals; | 216 | const char *gvals; |
217 | 217 | ||
218 | gvals = g_value_get_string (gval); | 218 | gvals = g_value_get_string (gval); |
219 | if (NULL == gvals) | 219 | if (NULL == gvals) |
220 | return; | 220 | return; |
221 | contents = strdup (gvals); | 221 | contents = strdup (gvals); |
222 | } | 222 | } |
223 | else | 223 | else |
224 | { | 224 | { |
225 | /* convert other formats? */ | 225 | /* convert other formats? */ |
226 | contents = g_strdup_value_contents (gval); | 226 | contents = g_strdup_value_contents (gval); |
227 | } | 227 | } |
228 | if (NULL == contents) | 228 | if (NULL == contents) |
229 | return; | 229 | return; |
230 | if (0 == strcmp (type, | 230 | if (0 == strcmp (type, |
231 | "meta:generator")) | 231 | "meta:generator")) |
232 | { | ||
233 | const char *mimetype = "application/vnd.ms-files"; | ||
234 | struct | ||
232 | { | 235 | { |
233 | const char *mimetype = "application/vnd.ms-files"; | 236 | const char *v; |
234 | struct { | 237 | const char *m; |
235 | const char *v; | 238 | } mm[] = { |
236 | const char *m; | 239 | { "Microsoft Word", "application/msword" }, |
237 | } mm[] = { | 240 | { "Microsoft Office Word", "application/msword" }, |
238 | { "Microsoft Word", "application/msword" }, | 241 | { "Microsoft Excel", "application/vnd.ms-excel" }, |
239 | { "Microsoft Office Word", "application/msword" }, | 242 | { "Microsoft Office Excel", "application/vnd.ms-excel" }, |
240 | { "Microsoft Excel", "application/vnd.ms-excel" }, | 243 | { "Microsoft PowerPoint", "application/vnd.ms-powerpoint" }, |
241 | { "Microsoft Office Excel", "application/vnd.ms-excel" }, | 244 | { "Microsoft Office PowerPoint", "application/vnd.ms-powerpoint"}, |
242 | { "Microsoft PowerPoint", "application/vnd.ms-powerpoint" }, | 245 | { "Microsoft Project", "application/vnd.ms-project" }, |
243 | { "Microsoft Office PowerPoint", "application/vnd.ms-powerpoint"}, | 246 | { "Microsoft Visio", "application/vnd.visio" }, |
244 | { "Microsoft Project", "application/vnd.ms-project" }, | 247 | { "Microsoft Office", "application/vnd.ms-office" }, |
245 | { "Microsoft Visio", "application/vnd.visio" }, | 248 | { NULL, NULL } |
246 | { "Microsoft Office", "application/vnd.ms-office" }, | 249 | }; |
247 | { NULL, NULL } | 250 | int i; |
248 | }; | 251 | |
249 | int i; | 252 | for (i = 0; NULL != mm[i].v; i++) |
250 | 253 | if (0 == strncmp (value, | |
251 | for (i=0;NULL != mm[i].v; i++) | 254 | mm[i].v, |
252 | if (0 == strncmp (value, | 255 | strlen (mm[i].v) + 1)) |
253 | mm[i].v, | 256 | { |
254 | strlen (mm[i].v) + 1)) | 257 | mimetype = mm[i].m; |
255 | { | 258 | break; |
256 | mimetype = mm[i].m; | 259 | } |
257 | break; | 260 | if (0 != add_metadata (pc->proc, |
258 | } | 261 | pc->proc_cls, |
259 | if (0 != add_metadata (pc->proc, | 262 | mimetype, |
260 | pc->proc_cls, | 263 | EXTRACTOR_METATYPE_MIMETYPE)) |
261 | mimetype, | 264 | { |
262 | EXTRACTOR_METATYPE_MIMETYPE)) | 265 | free (contents); |
263 | { | 266 | pc->ret = 1; |
264 | free (contents); | 267 | return; |
265 | pc->ret = 1; | ||
266 | return; | ||
267 | } | ||
268 | } | 268 | } |
269 | } | ||
269 | for (pos = 0; NULL != tmap[pos].text; pos++) | 270 | for (pos = 0; NULL != tmap[pos].text; pos++) |
270 | if (0 == strcmp (tmap[pos].text, | 271 | if (0 == strcmp (tmap[pos].text, |
271 | type)) | 272 | type)) |
272 | break; | 273 | break; |
273 | if ( (NULL != tmap[pos].text) && | 274 | if ( (NULL != tmap[pos].text) && |
274 | (0 != add_metadata (pc->proc, pc->proc_cls, | 275 | (0 != add_metadata (pc->proc, pc->proc_cls, |
275 | contents, | 276 | contents, |
276 | tmap[pos].type)) ) | 277 | tmap[pos].type)) ) |
277 | { | 278 | { |
278 | free (contents); | 279 | free (contents); |
279 | pc->ret = 1; | 280 | pc->ret = 1; |
280 | return; | 281 | return; |
281 | } | 282 | } |
282 | free(contents); | 283 | free (contents); |
283 | } | 284 | } |
284 | 285 | ||
285 | 286 | ||
@@ -294,8 +295,8 @@ process_metadata (gpointer key, | |||
294 | */ | 295 | */ |
295 | static int | 296 | static int |
296 | process (GsfInput *in, | 297 | process (GsfInput *in, |
297 | EXTRACTOR_MetaDataProcessor proc, | 298 | EXTRACTOR_MetaDataProcessor proc, |
298 | void *proc_cls) | 299 | void *proc_cls) |
299 | { | 300 | { |
300 | struct ProcContext pc; | 301 | struct ProcContext pc; |
301 | GsfDocMetaData *sections; | 302 | GsfDocMetaData *sections; |
@@ -311,15 +312,15 @@ process (GsfInput *in, | |||
311 | error = gsf_msole_metadata_read (in, sections); | 312 | error = gsf_msole_metadata_read (in, sections); |
312 | #endif | 313 | #endif |
313 | if (NULL == error) | 314 | if (NULL == error) |
314 | { | 315 | { |
315 | gsf_doc_meta_data_foreach (sections, | 316 | gsf_doc_meta_data_foreach (sections, |
316 | &process_metadata, | 317 | &process_metadata, |
317 | &pc); | 318 | &pc); |
318 | } | 319 | } |
319 | else | 320 | else |
320 | { | 321 | { |
321 | g_error_free (error); | 322 | g_error_free (error); |
322 | } | 323 | } |
323 | g_object_unref (G_OBJECT (sections)); | 324 | g_object_unref (G_OBJECT (sections)); |
324 | return pc.ret; | 325 | return pc.ret; |
325 | } | 326 | } |
@@ -336,50 +337,50 @@ process (GsfInput *in, | |||
336 | */ | 337 | */ |
337 | static int | 338 | static int |
338 | process_star_office (GsfInput *src, | 339 | process_star_office (GsfInput *src, |
339 | EXTRACTOR_MetaDataProcessor proc, | 340 | EXTRACTOR_MetaDataProcessor proc, |
340 | void *proc_cls) | 341 | void *proc_cls) |
341 | { | 342 | { |
342 | off_t size = gsf_input_size (src); | 343 | off_t size = gsf_input_size (src); |
343 | 344 | ||
344 | if ( (size < 0x374) || | 345 | if ( (size < 0x374) || |
345 | (size > 4*1024*1024) ) /* == 0x375?? */ | 346 | (size > 4 * 1024 * 1024) ) /* == 0x375?? */ |
346 | return 0; | 347 | return 0; |
347 | { | 348 | { |
348 | char buf[size]; | 349 | char buf[size]; |
349 | 350 | ||
350 | gsf_input_read (src, size, (unsigned char*) buf); | 351 | gsf_input_read (src, size, (unsigned char*) buf); |
351 | if ( (buf[0] != 0x0F) || | 352 | if ( (buf[0] != 0x0F) || |
352 | (buf[1] != 0x0) || | 353 | (buf[1] != 0x0) || |
353 | (0 != strncmp (&buf[2], | 354 | (0 != strncmp (&buf[2], |
354 | "SfxDocumentInfo", | 355 | "SfxDocumentInfo", |
355 | strlen ("SfxDocumentInfo"))) || | 356 | strlen ("SfxDocumentInfo"))) || |
356 | (buf[0x11] != 0x0B) || | 357 | (buf[0x11] != 0x0B) || |
357 | (buf[0x13] != 0x00) || /* pw protected! */ | 358 | (buf[0x13] != 0x00) || /* pw protected! */ |
358 | (buf[0x12] != 0x00) ) | 359 | (buf[0x12] != 0x00) ) |
359 | return 0; | 360 | return 0; |
360 | buf[0xd3] = '\0'; | 361 | buf[0xd3] = '\0'; |
361 | if ( (buf[0x94] + buf[0x93] > 0) && | 362 | if ( (buf[0x94] + buf[0x93] > 0) && |
362 | (0 != add_metadata (proc, proc_cls, | 363 | (0 != add_metadata (proc, proc_cls, |
363 | &buf[0x95], | 364 | &buf[0x95], |
364 | EXTRACTOR_METATYPE_TITLE)) ) | 365 | EXTRACTOR_METATYPE_TITLE)) ) |
365 | return 1; | 366 | return 1; |
366 | buf[0x114] = '\0'; | 367 | buf[0x114] = '\0'; |
367 | if ( (buf[0xd5] + buf[0xd4] > 0) && | 368 | if ( (buf[0xd5] + buf[0xd4] > 0) && |
368 | (0 != add_metadata (proc, proc_cls, | 369 | (0 != add_metadata (proc, proc_cls, |
369 | &buf[0xd6], | 370 | &buf[0xd6], |
370 | EXTRACTOR_METATYPE_SUBJECT)) ) | 371 | EXTRACTOR_METATYPE_SUBJECT)) ) |
371 | return 1; | 372 | return 1; |
372 | buf[0x215] = '\0'; | 373 | buf[0x215] = '\0'; |
373 | if ( (buf[0x115] + buf[0x116] > 0) && | 374 | if ( (buf[0x115] + buf[0x116] > 0) && |
374 | (0 != add_metadata (proc, proc_cls, | 375 | (0 != add_metadata (proc, proc_cls, |
375 | &buf[0x117], | 376 | &buf[0x117], |
376 | EXTRACTOR_METATYPE_COMMENT)) ) | 377 | EXTRACTOR_METATYPE_COMMENT)) ) |
377 | return 1; | 378 | return 1; |
378 | buf[0x296] = '\0'; | 379 | buf[0x296] = '\0'; |
379 | if ( (buf[0x216] + buf[0x217] > 0) && | 380 | if ( (buf[0x216] + buf[0x217] > 0) && |
380 | (0 != add_metadata(proc, proc_cls, | 381 | (0 != add_metadata (proc, proc_cls, |
381 | &buf[0x218], | 382 | &buf[0x218], |
382 | EXTRACTOR_METATYPE_KEYWORDS)) ) | 383 | EXTRACTOR_METATYPE_KEYWORDS)) ) |
383 | return 1; | 384 | return 1; |
384 | /* fixme: do timestamps, | 385 | /* fixme: do timestamps, |
385 | mime-type, user-defined info's */ | 386 | mime-type, user-defined info's */ |
@@ -394,7 +395,7 @@ process_star_office (GsfInput *src, | |||
394 | * @param a string to translate | 395 | * @param a string to translate |
395 | * @return translated string | 396 | * @return translated string |
396 | */ | 397 | */ |
397 | #define __(a) dgettext("iso-639", a) | 398 | #define __(a) dgettext ("iso-639", a) |
398 | 399 | ||
399 | 400 | ||
400 | /** | 401 | /** |
@@ -408,126 +409,126 @@ static const char * | |||
408 | lid_to_language (unsigned int lid) | 409 | lid_to_language (unsigned int lid) |
409 | { | 410 | { |
410 | switch (lid) | 411 | switch (lid) |
411 | { | 412 | { |
412 | case 0x0400: | 413 | case 0x0400: |
413 | return _("No Proofing"); | 414 | return _ ("No Proofing"); |
414 | case 0x0401: | 415 | case 0x0401: |
415 | return __("Arabic"); | 416 | return __ ("Arabic"); |
416 | case 0x0402: | 417 | case 0x0402: |
417 | return __("Bulgarian"); | 418 | return __ ("Bulgarian"); |
418 | case 0x0403: | 419 | case 0x0403: |
419 | return __("Catalan"); | 420 | return __ ("Catalan"); |
420 | case 0x0404: | 421 | case 0x0404: |
421 | return _("Traditional Chinese"); | 422 | return _ ("Traditional Chinese"); |
422 | case 0x0804: | 423 | case 0x0804: |
423 | return _("Simplified Chinese"); | 424 | return _ ("Simplified Chinese"); |
424 | case 0x0405: | 425 | case 0x0405: |
425 | return __("Chechen"); | 426 | return __ ("Chechen"); |
426 | case 0x0406: | 427 | case 0x0406: |
427 | return __("Danish"); | 428 | return __ ("Danish"); |
428 | case 0x0407: | 429 | case 0x0407: |
429 | return __("German"); | 430 | return __ ("German"); |
430 | case 0x0807: | 431 | case 0x0807: |
431 | return _("Swiss German"); | 432 | return _ ("Swiss German"); |
432 | case 0x0408: | 433 | case 0x0408: |
433 | return __("Greek"); | 434 | return __ ("Greek"); |
434 | case 0x0409: | 435 | case 0x0409: |
435 | return _("U.S. English"); | 436 | return _ ("U.S. English"); |
436 | case 0x0809: | 437 | case 0x0809: |
437 | return _("U.K. English"); | 438 | return _ ("U.K. English"); |
438 | case 0x0c09: | 439 | case 0x0c09: |
439 | return _("Australian English"); | 440 | return _ ("Australian English"); |
440 | case 0x040a: | 441 | case 0x040a: |
441 | return _("Castilian Spanish"); | 442 | return _ ("Castilian Spanish"); |
442 | case 0x080a: | 443 | case 0x080a: |
443 | return _("Mexican Spanish"); | 444 | return _ ("Mexican Spanish"); |
444 | case 0x040b: | 445 | case 0x040b: |
445 | return __("Finnish"); | 446 | return __ ("Finnish"); |
446 | case 0x040c: | 447 | case 0x040c: |
447 | return __("French"); | 448 | return __ ("French"); |
448 | case 0x080c: | 449 | case 0x080c: |
449 | return _("Belgian French"); | 450 | return _ ("Belgian French"); |
450 | case 0x0c0c: | 451 | case 0x0c0c: |
451 | return _("Canadian French"); | 452 | return _ ("Canadian French"); |
452 | case 0x100c: | 453 | case 0x100c: |
453 | return _("Swiss French"); | 454 | return _ ("Swiss French"); |
454 | case 0x040d: | 455 | case 0x040d: |
455 | return __("Hebrew"); | 456 | return __ ("Hebrew"); |
456 | case 0x040e: | 457 | case 0x040e: |
457 | return __("Hungarian"); | 458 | return __ ("Hungarian"); |
458 | case 0x040f: | 459 | case 0x040f: |
459 | return __("Icelandic"); | 460 | return __ ("Icelandic"); |
460 | case 0x0410: | 461 | case 0x0410: |
461 | return __("Italian"); | 462 | return __ ("Italian"); |
462 | case 0x0810: | 463 | case 0x0810: |
463 | return _("Swiss Italian"); | 464 | return _ ("Swiss Italian"); |
464 | case 0x0411: | 465 | case 0x0411: |
465 | return __("Japanese"); | 466 | return __ ("Japanese"); |
466 | case 0x0412: | 467 | case 0x0412: |
467 | return __("Korean"); | 468 | return __ ("Korean"); |
468 | case 0x0413: | 469 | case 0x0413: |
469 | return __("Dutch"); | 470 | return __ ("Dutch"); |
470 | case 0x0813: | 471 | case 0x0813: |
471 | return _("Belgian Dutch"); | 472 | return _ ("Belgian Dutch"); |
472 | case 0x0414: | 473 | case 0x0414: |
473 | return _("Norwegian Bokmal"); | 474 | return _ ("Norwegian Bokmal"); |
474 | case 0x0814: | 475 | case 0x0814: |
475 | return __("Norwegian Nynorsk"); | 476 | return __ ("Norwegian Nynorsk"); |
476 | case 0x0415: | 477 | case 0x0415: |
477 | return __("Polish"); | 478 | return __ ("Polish"); |
478 | case 0x0416: | 479 | case 0x0416: |
479 | return __("Brazilian Portuguese"); | 480 | return __ ("Brazilian Portuguese"); |
480 | case 0x0816: | 481 | case 0x0816: |
481 | return __("Portuguese"); | 482 | return __ ("Portuguese"); |
482 | case 0x0417: | 483 | case 0x0417: |
483 | return _("Rhaeto-Romanic"); | 484 | return _ ("Rhaeto-Romanic"); |
484 | case 0x0418: | 485 | case 0x0418: |
485 | return __("Romanian"); | 486 | return __ ("Romanian"); |
486 | case 0x0419: | 487 | case 0x0419: |
487 | return __("Russian"); | 488 | return __ ("Russian"); |
488 | case 0x041a: | 489 | case 0x041a: |
489 | return _("Croato-Serbian (Latin)"); | 490 | return _ ("Croato-Serbian (Latin)"); |
490 | case 0x081a: | 491 | case 0x081a: |
491 | return _("Serbo-Croatian (Cyrillic)"); | 492 | return _ ("Serbo-Croatian (Cyrillic)"); |
492 | case 0x041b: | 493 | case 0x041b: |
493 | return __("Slovak"); | 494 | return __ ("Slovak"); |
494 | case 0x041c: | 495 | case 0x041c: |
495 | return __("Albanian"); | 496 | return __ ("Albanian"); |
496 | case 0x041d: | 497 | case 0x041d: |
497 | return __("Swedish"); | 498 | return __ ("Swedish"); |
498 | case 0x041e: | 499 | case 0x041e: |
499 | return __("Thai"); | 500 | return __ ("Thai"); |
500 | case 0x041f: | 501 | case 0x041f: |
501 | return __("Turkish"); | 502 | return __ ("Turkish"); |
502 | case 0x0420: | 503 | case 0x0420: |
503 | return __("Urdu"); | 504 | return __ ("Urdu"); |
504 | case 0x0421: | 505 | case 0x0421: |
505 | return __("Bahasa"); | 506 | return __ ("Bahasa"); |
506 | case 0x0422: | 507 | case 0x0422: |
507 | return __("Ukrainian"); | 508 | return __ ("Ukrainian"); |
508 | case 0x0423: | 509 | case 0x0423: |
509 | return __("Byelorussian"); | 510 | return __ ("Byelorussian"); |
510 | case 0x0424: | 511 | case 0x0424: |
511 | return __("Slovenian"); | 512 | return __ ("Slovenian"); |
512 | case 0x0425: | 513 | case 0x0425: |
513 | return __("Estonian"); | 514 | return __ ("Estonian"); |
514 | case 0x0426: | 515 | case 0x0426: |
515 | return __("Latvian"); | 516 | return __ ("Latvian"); |
516 | case 0x0427: | 517 | case 0x0427: |
517 | return __("Lithuanian"); | 518 | return __ ("Lithuanian"); |
518 | case 0x0429: | 519 | case 0x0429: |
519 | return _("Farsi"); | 520 | return _ ("Farsi"); |
520 | case 0x042D: | 521 | case 0x042D: |
521 | return __("Basque"); | 522 | return __ ("Basque"); |
522 | case 0x042F: | 523 | case 0x042F: |
523 | return __("Macedonian"); | 524 | return __ ("Macedonian"); |
524 | case 0x0436: | 525 | case 0x0436: |
525 | return __("Afrikaans"); | 526 | return __ ("Afrikaans"); |
526 | case 0x043E: | 527 | case 0x043E: |
527 | return __("Malayalam"); | 528 | return __ ("Malayalam"); |
528 | default: | 529 | default: |
529 | return NULL; | 530 | return NULL; |
530 | } | 531 | } |
531 | } | 532 | } |
532 | 533 | ||
533 | 534 | ||
@@ -543,10 +544,10 @@ lid_to_language (unsigned int lid) | |||
543 | */ | 544 | */ |
544 | static int | 545 | static int |
545 | history_extract (GsfInput *stream, | 546 | history_extract (GsfInput *stream, |
546 | unsigned int lcbSttbSavedBy, | 547 | unsigned int lcbSttbSavedBy, |
547 | unsigned int fcSttbSavedBy, | 548 | unsigned int fcSttbSavedBy, |
548 | EXTRACTOR_MetaDataProcessor proc, | 549 | EXTRACTOR_MetaDataProcessor proc, |
549 | void *proc_cls) | 550 | void *proc_cls) |
550 | { | 551 | { |
551 | unsigned int where; | 552 | unsigned int where; |
552 | unsigned char *lbuffer; | 553 | unsigned char *lbuffer; |
@@ -570,64 +571,64 @@ history_extract (GsfInput *stream, | |||
570 | nRev = (lbuffer[2] + (lbuffer[3] << 8)) / 2; | 571 | nRev = (lbuffer[2] + (lbuffer[3] << 8)) / 2; |
571 | where = 6; | 572 | where = 6; |
572 | ret = 0; | 573 | ret = 0; |
573 | for (i=0; i < nRev; i++) | 574 | for (i = 0; i < nRev; i++) |
575 | { | ||
576 | if (where >= lcbSttbSavedBy) | ||
577 | break; | ||
578 | length = lbuffer[where++]; | ||
579 | if ( (where + 2 * length + 2 >= lcbSttbSavedBy) || | ||
580 | (where + 2 * length + 2 <= where) ) | ||
581 | break; | ||
582 | author = EXTRACTOR_common_convert_to_utf8 ((const char*) &lbuffer[where], | ||
583 | length * 2, | ||
584 | "UTF-16BE"); | ||
585 | where += length * 2 + 1; | ||
586 | length = lbuffer[where++]; | ||
587 | if ( (where + 2 * length >= lcbSttbSavedBy) || | ||
588 | (where + 2 * length + 1 <= where) ) | ||
574 | { | 589 | { |
575 | if (where >= lcbSttbSavedBy) | ||
576 | break; | ||
577 | length = lbuffer[where++]; | ||
578 | if ( (where + 2 * length + 2 >= lcbSttbSavedBy) || | ||
579 | (where + 2 * length + 2 <= where) ) | ||
580 | break; | ||
581 | author = EXTRACTOR_common_convert_to_utf8 ((const char*) &lbuffer[where], | ||
582 | length * 2, | ||
583 | "UTF-16BE"); | ||
584 | where += length * 2 + 1; | ||
585 | length = lbuffer[where++]; | ||
586 | if ( (where + 2 * length >= lcbSttbSavedBy) || | ||
587 | (where + 2 * length + 1 <= where) ) | ||
588 | { | ||
589 | if (NULL != author) | ||
590 | free(author); | ||
591 | break; | ||
592 | } | ||
593 | filename = EXTRACTOR_common_convert_to_utf8 ((const char*) &lbuffer[where], | ||
594 | length * 2, | ||
595 | "UTF-16BE"); | ||
596 | where += length * 2 + 1; | ||
597 | if ( (NULL != author) && | ||
598 | (NULL != filename) ) | ||
599 | { | ||
600 | size_t bsize; | ||
601 | |||
602 | bsize = strlen (author) + strlen (filename) + 512; | ||
603 | if (NULL != (rbuf = malloc (bsize))) | ||
604 | { | ||
605 | int snret; | ||
606 | |||
607 | snret = snprintf (rbuf, | ||
608 | bsize, | ||
609 | _("Revision #%u: Author `%s' worked on `%s'"), | ||
610 | i, | ||
611 | author, | ||
612 | filename); | ||
613 | if ( (-1 != snret) && | ||
614 | (bsize > (size_t) snret) ) | ||
615 | { | ||
616 | ret = add_metadata (proc, | ||
617 | proc_cls, | ||
618 | rbuf, | ||
619 | EXTRACTOR_METATYPE_REVISION_HISTORY); | ||
620 | } | ||
621 | free (rbuf); | ||
622 | } | ||
623 | } | ||
624 | if (NULL != author) | 590 | if (NULL != author) |
625 | free (author); | 591 | free (author); |
626 | if (NULL != filename) | 592 | break; |
627 | free (filename); | 593 | } |
628 | if (0 != ret) | 594 | filename = EXTRACTOR_common_convert_to_utf8 ((const char*) &lbuffer[where], |
629 | break; | 595 | length * 2, |
596 | "UTF-16BE"); | ||
597 | where += length * 2 + 1; | ||
598 | if ( (NULL != author) && | ||
599 | (NULL != filename) ) | ||
600 | { | ||
601 | size_t bsize; | ||
602 | |||
603 | bsize = strlen (author) + strlen (filename) + 512; | ||
604 | if (NULL != (rbuf = malloc (bsize))) | ||
605 | { | ||
606 | int snret; | ||
607 | |||
608 | snret = snprintf (rbuf, | ||
609 | bsize, | ||
610 | _ ("Revision #%u: Author `%s' worked on `%s'"), | ||
611 | i, | ||
612 | author, | ||
613 | filename); | ||
614 | if ( (-1 != snret) && | ||
615 | (bsize > (size_t) snret) ) | ||
616 | { | ||
617 | ret = add_metadata (proc, | ||
618 | proc_cls, | ||
619 | rbuf, | ||
620 | EXTRACTOR_METATYPE_REVISION_HISTORY); | ||
621 | } | ||
622 | free (rbuf); | ||
623 | } | ||
630 | } | 624 | } |
625 | if (NULL != author) | ||
626 | free (author); | ||
627 | if (NULL != filename) | ||
628 | free (filename); | ||
629 | if (0 != ret) | ||
630 | break; | ||
631 | } | ||
631 | free (lbuffer); | 632 | free (lbuffer); |
632 | return ret; | 633 | return ret; |
633 | } | 634 | } |
@@ -636,11 +637,19 @@ history_extract (GsfInput *stream, | |||
636 | /* *************************** custom GSF input method ***************** */ | 637 | /* *************************** custom GSF input method ***************** */ |
637 | 638 | ||
638 | #define LE_TYPE_INPUT (le_input_get_type ()) | 639 | #define LE_TYPE_INPUT (le_input_get_type ()) |
639 | #define LE_INPUT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), LE_TYPE_INPUT, LeInput)) | 640 | #define LE_INPUT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ |
640 | #define LE_INPUT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), LE_TYPE_INPUT, LeInputClass)) | 641 | LE_TYPE_INPUT, \ |
641 | #define IS_LE_INPUT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LE_TYPE_INPUT)) | 642 | LeInput)) |
642 | #define IS_LE_INPUT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), LE_TYPE_INPUT)) | 643 | #define LE_INPUT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), \ |
643 | #define LE_INPUT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), LE_TYPE_INPUT, LeInputClass)) | 644 | LE_TYPE_INPUT, \ |
645 | LeInputClass)) | ||
646 | #define IS_LE_INPUT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \ | ||
647 | LE_TYPE_INPUT)) | ||
648 | #define IS_LE_INPUT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), \ | ||
649 | LE_TYPE_INPUT)) | ||
650 | #define LE_INPUT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \ | ||
651 | LE_TYPE_INPUT, \ | ||
652 | LeInputClass)) | ||
644 | 653 | ||
645 | /** | 654 | /** |
646 | * Internal state of an "LeInput" object. | 655 | * Internal state of an "LeInput" object. |
@@ -683,10 +692,10 @@ typedef struct _LeInputClass | |||
683 | GsfInputClass parent_class; | 692 | GsfInputClass parent_class; |
684 | 693 | ||
685 | /* Padding for future expansion */ | 694 | /* Padding for future expansion */ |
686 | void (*_gtk_reserved1) (void); | 695 | void (*_gtk_reserved1)(void); |
687 | void (*_gtk_reserved2) (void); | 696 | void (*_gtk_reserved2)(void); |
688 | void (*_gtk_reserved3) (void); | 697 | void (*_gtk_reserved3)(void); |
689 | void (*_gtk_reserved4) (void); | 698 | void (*_gtk_reserved4)(void); |
690 | } LeInputClass; | 699 | } LeInputClass; |
691 | 700 | ||
692 | 701 | ||
@@ -721,7 +730,8 @@ le_input_init (LeInput *input); | |||
721 | /** | 730 | /** |
722 | * Macro to create LeInput type definition and register the class. | 731 | * Macro to create LeInput type definition and register the class. |
723 | */ | 732 | */ |
724 | GSF_CLASS (LeInput, le_input, le_input_class_init, le_input_init, GSF_INPUT_TYPE) | 733 | GSF_CLASS (LeInput, le_input, le_input_class_init, le_input_init, |
734 | GSF_INPUT_TYPE) | ||
725 | 735 | ||
726 | 736 | ||
727 | /** | 737 | /** |
@@ -732,12 +742,12 @@ GSF_CLASS (LeInput, le_input, le_input_class_init, le_input_init, GSF_INPUT_TYPE | |||
732 | * @return NULL on error (always) | 742 | * @return NULL on error (always) |
733 | */ | 743 | */ |
734 | static GsfInput * | 744 | static GsfInput * |
735 | le_input_dup (GsfInput *input, | 745 | le_input_dup (GsfInput * input, |
736 | GError **err) | 746 | GError * *err) |
737 | { | 747 | { |
738 | if (NULL != err) | 748 | if (NULL != err) |
739 | *err = g_error_new (gsf_input_error_id (), 0, | 749 | *err = g_error_new (gsf_input_error_id (), 0, |
740 | "dup not supported on LeInput"); | 750 | "dup not supported on LeInput"); |
741 | return NULL; | 751 | return NULL; |
742 | } | 752 | } |
743 | 753 | ||
@@ -755,8 +765,8 @@ le_input_dup (GsfInput *input, | |||
755 | */ | 765 | */ |
756 | static const guint8 * | 766 | static const guint8 * |
757 | le_input_read (GsfInput *input, | 767 | le_input_read (GsfInput *input, |
758 | size_t num_bytes, | 768 | size_t num_bytes, |
759 | guint8 *optional_buffer) | 769 | guint8 *optional_buffer) |
760 | { | 770 | { |
761 | LeInput *li = LE_INPUT (input); | 771 | LeInput *li = LE_INPUT (input); |
762 | struct EXTRACTOR_ExtractContext *ec; | 772 | struct EXTRACTOR_ExtractContext *ec; |
@@ -768,21 +778,21 @@ le_input_read (GsfInput *input, | |||
768 | old_off = ec->seek (ec->cls, 0, SEEK_CUR); | 778 | old_off = ec->seek (ec->cls, 0, SEEK_CUR); |
769 | if (num_bytes | 779 | if (num_bytes |
770 | != (ret = ec->read (ec->cls, | 780 | != (ret = ec->read (ec->cls, |
771 | &buf, | 781 | &buf, |
772 | num_bytes))) | 782 | num_bytes))) |
773 | { | 783 | { |
774 | /* we don't support partial reads; | 784 | /* we don't support partial reads; |
775 | most other GsfInput implementations in this case | 785 | most other GsfInput implementations in this case |
776 | allocate some huge temporary buffer just to avoid | 786 | allocate some huge temporary buffer just to avoid |
777 | the partial read; we might need to do that as well!? */ | 787 | the partial read; we might need to do that as well!? */ |
778 | ec->seek (ec->cls, SEEK_SET, old_off); | 788 | ec->seek (ec->cls, SEEK_SET, old_off); |
779 | return NULL; | 789 | return NULL; |
780 | } | 790 | } |
781 | if (NULL != optional_buffer) | 791 | if (NULL != optional_buffer) |
782 | { | 792 | { |
783 | memcpy (optional_buffer, buf, num_bytes); | 793 | memcpy (optional_buffer, buf, num_bytes); |
784 | return optional_buffer; | 794 | return optional_buffer; |
785 | } | 795 | } |
786 | return buf; | 796 | return buf; |
787 | } | 797 | } |
788 | 798 | ||
@@ -797,8 +807,8 @@ le_input_read (GsfInput *input, | |||
797 | */ | 807 | */ |
798 | static gboolean | 808 | static gboolean |
799 | le_input_seek (GsfInput *input, | 809 | le_input_seek (GsfInput *input, |
800 | gsf_off_t offset, | 810 | gsf_off_t offset, |
801 | GSeekType whence) | 811 | GSeekType whence) |
802 | { | 812 | { |
803 | LeInput *li = LE_INPUT (input); | 813 | LeInput *li = LE_INPUT (input); |
804 | struct EXTRACTOR_ExtractContext *ec; | 814 | struct EXTRACTOR_ExtractContext *ec; |
@@ -807,23 +817,23 @@ le_input_seek (GsfInput *input, | |||
807 | 817 | ||
808 | ec = li->priv->ec; | 818 | ec = li->priv->ec; |
809 | switch (whence) | 819 | switch (whence) |
810 | { | 820 | { |
811 | case G_SEEK_SET: | 821 | case G_SEEK_SET: |
812 | w = SEEK_SET; | 822 | w = SEEK_SET; |
813 | break; | 823 | break; |
814 | case G_SEEK_CUR: | 824 | case G_SEEK_CUR: |
815 | w = SEEK_CUR; | 825 | w = SEEK_CUR; |
816 | break; | 826 | break; |
817 | case G_SEEK_END: | 827 | case G_SEEK_END: |
818 | w = SEEK_END; | 828 | w = SEEK_END; |
819 | break; | 829 | break; |
820 | default: | 830 | default: |
821 | return TRUE; | 831 | return TRUE; |
822 | } | 832 | } |
823 | if (-1 == | 833 | if (-1 == |
824 | (ret = ec->seek (ec->cls, | 834 | (ret = ec->seek (ec->cls, |
825 | offset, | 835 | offset, |
826 | w))) | 836 | w))) |
827 | return TRUE; | 837 | return TRUE; |
828 | return FALSE; | 838 | return FALSE; |
829 | } | 839 | } |
@@ -859,7 +869,7 @@ le_input_init (LeInput *input) | |||
859 | 869 | ||
860 | input->priv = | 870 | input->priv = |
861 | G_TYPE_INSTANCE_GET_PRIVATE (input, LE_TYPE_INPUT, | 871 | G_TYPE_INSTANCE_GET_PRIVATE (input, LE_TYPE_INPUT, |
862 | LeInputPrivate); | 872 | LeInputPrivate); |
863 | priv = input->priv; | 873 | priv = input->priv; |
864 | priv->ec = NULL; | 874 | priv->ec = NULL; |
865 | } | 875 | } |
@@ -878,9 +888,9 @@ le_input_new (struct EXTRACTOR_ExtractContext *ec) | |||
878 | 888 | ||
879 | input = g_object_new (LE_TYPE_INPUT, NULL); | 889 | input = g_object_new (LE_TYPE_INPUT, NULL); |
880 | gsf_input_set_size (GSF_INPUT (input), | 890 | gsf_input_set_size (GSF_INPUT (input), |
881 | ec->get_size (ec->cls)); | 891 | ec->get_size (ec->cls)); |
882 | gsf_input_seek_emulate (GSF_INPUT (input), | 892 | gsf_input_seek_emulate (GSF_INPUT (input), |
883 | 0); | 893 | 0); |
884 | input->input.name = NULL; | 894 | input->input.name = NULL; |
885 | input->input.container = NULL; | 895 | input->input.container = NULL; |
886 | input->priv->ec = ec; | 896 | input->priv->ec = ec; |
@@ -889,8 +899,6 @@ le_input_new (struct EXTRACTOR_ExtractContext *ec) | |||
889 | } | 899 | } |
890 | 900 | ||
891 | 901 | ||
892 | |||
893 | |||
894 | /* *********************** end of custom GSF input method ************* */ | 902 | /* *********************** end of custom GSF input method ************* */ |
895 | 903 | ||
896 | 904 | ||
@@ -919,90 +927,92 @@ EXTRACTOR_ole2_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
919 | 927 | ||
920 | fsize = ec->get_size (ec->cls); | 928 | fsize = ec->get_size (ec->cls); |
921 | if (fsize < 512 + 898) | 929 | if (fsize < 512 + 898) |
922 | { | 930 | { |
923 | /* File too small for OLE2 */ | 931 | /* File too small for OLE2 */ |
924 | return; /* can hardly be OLE2 */ | 932 | return; /* can hardly be OLE2 */ |
925 | } | 933 | } |
926 | if (512 + 898 > (data_size = ec->read (ec->cls, &data, fsize))) | 934 | if (512 + 898 > (data_size = ec->read (ec->cls, &data, fsize))) |
927 | { | 935 | { |
928 | /* Failed to read minimum file size to buffer */ | 936 | /* Failed to read minimum file size to buffer */ |
929 | return; | 937 | return; |
930 | } | 938 | } |
931 | data512 = (const unsigned char*) data + 512; | 939 | data512 = (const unsigned char*) data + 512; |
932 | lid = data512[6] + (data512[7] << 8); | 940 | lid = data512[6] + (data512[7] << 8); |
933 | if ( (NULL != (lang = lid_to_language (lid))) && | 941 | if ( (NULL != (lang = lid_to_language (lid))) && |
934 | (0 != (ret = add_metadata (ec->proc, ec->cls, | 942 | (0 != (ret = add_metadata (ec->proc, ec->cls, |
935 | lang, | 943 | lang, |
936 | EXTRACTOR_METATYPE_LANGUAGE))) ) | 944 | EXTRACTOR_METATYPE_LANGUAGE))) ) |
937 | return; | 945 | return; |
938 | lcb = data512[726] + (data512[727] << 8) + (data512[728] << 16) + (data512[729] << 24); | 946 | lcb = data512[726] + (data512[727] << 8) + (data512[728] << 16) |
939 | fcb = data512[722] + (data512[723] << 8) + (data512[724] << 16) + (data512[725] << 24); | 947 | + (data512[729] << 24); |
948 | fcb = data512[722] + (data512[723] << 8) + (data512[724] << 16) | ||
949 | + (data512[725] << 24); | ||
940 | if (0 != ec->seek (ec->cls, 0, SEEK_SET)) | 950 | if (0 != ec->seek (ec->cls, 0, SEEK_SET)) |
941 | { | 951 | { |
942 | /* seek failed!? */ | 952 | /* seek failed!? */ |
943 | return; | 953 | return; |
944 | } | 954 | } |
945 | #if USE_LE_INPUT | 955 | #if USE_LE_INPUT |
946 | if (NULL == (input = le_input_new (ec))) | 956 | if (NULL == (input = le_input_new (ec))) |
947 | { | 957 | { |
948 | fprintf (stderr, "le_input_new failed\n"); | 958 | fprintf (stderr, "le_input_new failed\n"); |
949 | return; | 959 | return; |
950 | } | 960 | } |
951 | #else | 961 | #else |
952 | input = gsf_input_memory_new ((const guint8 *) data, | 962 | input = gsf_input_memory_new ((const guint8 *) data, |
953 | data_size, | 963 | data_size, |
954 | FALSE); | 964 | FALSE); |
955 | #endif | 965 | #endif |
956 | if (NULL == (infile = gsf_infile_msole_new (input, NULL))) | 966 | if (NULL == (infile = gsf_infile_msole_new (input, NULL))) |
957 | { | 967 | { |
958 | g_object_unref (G_OBJECT (input)); | 968 | g_object_unref (G_OBJECT (input)); |
959 | return; | 969 | return; |
960 | } | 970 | } |
961 | ret = 0; | 971 | ret = 0; |
962 | for (i=0;i<gsf_infile_num_children (infile);i++) | 972 | for (i = 0; i<gsf_infile_num_children (infile); i++) |
963 | { | 973 | { |
964 | if (0 != ret) | 974 | if (0 != ret) |
965 | break; | 975 | break; |
966 | if (NULL == (name = gsf_infile_name_by_index (infile, i))) | 976 | if (NULL == (name = gsf_infile_name_by_index (infile, i))) |
967 | continue; | 977 | continue; |
968 | src = NULL; | 978 | src = NULL; |
969 | if ( ( (0 == strcmp (name, "\005SummaryInformation")) || | 979 | if ( ( (0 == strcmp (name, "\005SummaryInformation")) || |
970 | (0 == strcmp (name, "\005DocumentSummaryInformation")) ) && | 980 | (0 == strcmp (name, "\005DocumentSummaryInformation")) ) && |
971 | (NULL != (src = gsf_infile_child_by_index (infile, i))) ) | 981 | (NULL != (src = gsf_infile_child_by_index (infile, i))) ) |
972 | ret = process (src, | 982 | ret = process (src, |
973 | ec->proc, | 983 | ec->proc, |
974 | ec->cls); | 984 | ec->cls); |
975 | if ( (0 == strcmp (name, "SfxDocumentInfo")) && | 985 | if ( (0 == strcmp (name, "SfxDocumentInfo")) && |
976 | (NULL != (src = gsf_infile_child_by_index (infile, i))) ) | 986 | (NULL != (src = gsf_infile_child_by_index (infile, i))) ) |
977 | ret = process_star_office (src, | 987 | ret = process_star_office (src, |
978 | ec->proc, | 988 | ec->proc, |
979 | ec->cls); | 989 | ec->cls); |
980 | if (NULL != src) | 990 | if (NULL != src) |
981 | g_object_unref (G_OBJECT (src)); | 991 | g_object_unref (G_OBJECT (src)); |
982 | } | 992 | } |
983 | if (0 != ret) | 993 | if (0 != ret) |
984 | goto CLEANUP; | 994 | goto CLEANUP; |
985 | 995 | ||
986 | if (lcb < 6) | 996 | if (lcb < 6) |
987 | goto CLEANUP; | 997 | goto CLEANUP; |
988 | for (i=0;i<gsf_infile_num_children (infile);i++) | 998 | for (i = 0; i<gsf_infile_num_children (infile); i++) |
999 | { | ||
1000 | if (ret != 0) | ||
1001 | break; | ||
1002 | if (NULL == (name = gsf_infile_name_by_index (infile, i))) | ||
1003 | continue; | ||
1004 | if ( ( (0 == strcmp (name, "1Table")) || | ||
1005 | (0 == strcmp (name, "0Table")) ) && | ||
1006 | (NULL != (src = gsf_infile_child_by_index (infile, i))) ) | ||
989 | { | 1007 | { |
990 | if (ret != 0) | 1008 | ret = history_extract (src, |
991 | break; | 1009 | lcb, |
992 | if (NULL == (name = gsf_infile_name_by_index (infile, i))) | 1010 | fcb, |
993 | continue; | 1011 | ec->proc, ec->cls); |
994 | if ( ( (0 == strcmp (name, "1Table")) || | 1012 | g_object_unref (G_OBJECT (src)); |
995 | (0 == strcmp (name, "0Table")) ) && | ||
996 | (NULL != (src = gsf_infile_child_by_index (infile, i))) ) | ||
997 | { | ||
998 | ret = history_extract (src, | ||
999 | lcb, | ||
1000 | fcb, | ||
1001 | ec->proc, ec->cls); | ||
1002 | g_object_unref (G_OBJECT (src)); | ||
1003 | } | ||
1004 | } | 1013 | } |
1005 | CLEANUP: | 1014 | } |
1015 | CLEANUP: | ||
1006 | g_object_unref (G_OBJECT (infile)); | 1016 | g_object_unref (G_OBJECT (infile)); |
1007 | g_object_unref (G_OBJECT (input)); | 1017 | g_object_unref (G_OBJECT (input)); |
1008 | } | 1018 | } |
@@ -1031,18 +1041,18 @@ nolog (const gchar *log_domain, | |||
1031 | * gsf logging is disabled. | 1041 | * gsf logging is disabled. |
1032 | */ | 1042 | */ |
1033 | void __attribute__ ((constructor)) | 1043 | void __attribute__ ((constructor)) |
1034 | ole2_ltdl_init() | 1044 | ole2_ltdl_init () |
1035 | { | 1045 | { |
1036 | #if !GLIB_CHECK_VERSION(2, 35, 0) | 1046 | #if ! GLIB_CHECK_VERSION (2, 35, 0) |
1037 | g_type_init (); | 1047 | g_type_init (); |
1038 | #endif | 1048 | #endif |
1039 | #ifdef HAVE_GSF_INIT | 1049 | #ifdef HAVE_GSF_INIT |
1040 | gsf_init(); | 1050 | gsf_init (); |
1041 | #endif | 1051 | #endif |
1042 | /* disable logging -- thanks, Jody! */ | 1052 | /* disable logging -- thanks, Jody! */ |
1043 | g_log_set_handler ("libgsf:msole", | 1053 | g_log_set_handler ("libgsf:msole", |
1044 | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING, | 1054 | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING, |
1045 | &nolog, NULL); | 1055 | &nolog, NULL); |
1046 | } | 1056 | } |
1047 | 1057 | ||
1048 | 1058 | ||
@@ -1050,10 +1060,10 @@ ole2_ltdl_init() | |||
1050 | * OLE2 plugin destructor. Shutdown of gsf. | 1060 | * OLE2 plugin destructor. Shutdown of gsf. |
1051 | */ | 1061 | */ |
1052 | void __attribute__ ((destructor)) | 1062 | void __attribute__ ((destructor)) |
1053 | ole2_ltdl_fini() | 1063 | ole2_ltdl_fini () |
1054 | { | 1064 | { |
1055 | #ifdef HAVE_GSF_INIT | 1065 | #ifdef HAVE_GSF_INIT |
1056 | gsf_shutdown(); | 1066 | gsf_shutdown (); |
1057 | #endif | 1067 | #endif |
1058 | } | 1068 | } |
1059 | 1069 | ||
diff --git a/src/plugins/pdf_extractor.c b/src/plugins/pdf_extractor.c index da1f663..1bf3c84 100644 --- a/src/plugins/pdf_extractor.c +++ b/src/plugins/pdf_extractor.c | |||
@@ -80,8 +80,8 @@ static struct Matches tmap[] = { | |||
80 | */ | 80 | */ |
81 | static void | 81 | static void |
82 | process_stdout (FILE *fout, | 82 | process_stdout (FILE *fout, |
83 | EXTRACTOR_MetaDataProcessor proc, | 83 | EXTRACTOR_MetaDataProcessor proc, |
84 | void *proc_cls) | 84 | void *proc_cls) |
85 | { | 85 | { |
86 | unsigned int i; | 86 | unsigned int i; |
87 | char line[1025]; | 87 | char line[1025]; |
@@ -89,38 +89,38 @@ process_stdout (FILE *fout, | |||
89 | const char *colon; | 89 | const char *colon; |
90 | 90 | ||
91 | while (! feof (fout)) | 91 | while (! feof (fout)) |
92 | { | ||
93 | if (NULL == fgets (line, sizeof (line) - 1, fout)) | ||
94 | break; | ||
95 | if (0 == strlen (line)) | ||
96 | continue; | ||
97 | if ('\n' == line[strlen (line) - 1]) | ||
98 | line[strlen (line) - 1] = '\0'; | ||
99 | colon = strchr (line, (int) ':'); | ||
100 | if (NULL == colon) | ||
101 | break; | ||
102 | psuffix = colon + 1; | ||
103 | while (isblank ((unsigned char) psuffix[0])) | ||
104 | psuffix++; | ||
105 | if (0 == strlen (psuffix)) | ||
106 | continue; | ||
107 | for (i = 0; NULL != tmap[i].text; i++) | ||
92 | { | 108 | { |
93 | if (NULL == fgets (line, sizeof (line) - 1, fout)) | 109 | if (0 != strncasecmp (line, |
94 | break; | 110 | tmap[i].text, |
95 | if (0 == strlen (line)) | 111 | colon - line)) |
96 | continue; | ||
97 | if ('\n' == line[strlen(line)-1]) | ||
98 | line[strlen(line)-1] = '\0'; | ||
99 | colon = strchr (line, (int) ':'); | ||
100 | if (NULL == colon) | ||
101 | break; | ||
102 | psuffix = colon + 1; | ||
103 | while (isblank ((unsigned char) psuffix[0])) | ||
104 | psuffix++; | ||
105 | if (0 == strlen (psuffix)) | ||
106 | continue; | 112 | continue; |
107 | for (i = 0; NULL != tmap[i].text; i++) | 113 | if (0 != proc (proc_cls, |
108 | { | 114 | "pdf", |
109 | if (0 != strncasecmp (line, | 115 | tmap[i].type, |
110 | tmap[i].text, | 116 | EXTRACTOR_METAFORMAT_UTF8, |
111 | colon - line)) | 117 | "text/plain", |
112 | continue; | 118 | psuffix, |
113 | if (0 != proc (proc_cls, | 119 | strlen (psuffix) + 1)) |
114 | "pdf", | 120 | return; |
115 | tmap[i].type, | 121 | break; |
116 | EXTRACTOR_METAFORMAT_UTF8, | ||
117 | "text/plain", | ||
118 | psuffix, | ||
119 | strlen(psuffix) + 1)) | ||
120 | return; | ||
121 | break; | ||
122 | } | ||
123 | } | 122 | } |
123 | } | ||
124 | } | 124 | } |
125 | 125 | ||
126 | 126 | ||
@@ -154,79 +154,79 @@ EXTRACTOR_pdf_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
154 | if (0 != pipe (in)) | 154 | if (0 != pipe (in)) |
155 | return; | 155 | return; |
156 | if (0 != pipe (out)) | 156 | if (0 != pipe (out)) |
157 | { | 157 | { |
158 | close (in[0]); | 158 | close (in[0]); |
159 | close (in[1]); | 159 | close (in[1]); |
160 | return; | 160 | return; |
161 | } | 161 | } |
162 | pid = fork (); | 162 | pid = fork (); |
163 | if (-1 == pid) | 163 | if (-1 == pid) |
164 | { | 164 | { |
165 | close (in[0]); | 165 | close (in[0]); |
166 | close (in[1]); | 166 | close (in[1]); |
167 | close (out[0]); | 167 | close (out[0]); |
168 | close (out[1]); | 168 | close (out[1]); |
169 | return; | 169 | return; |
170 | } | 170 | } |
171 | if (0 == pid) | 171 | if (0 == pid) |
172 | { | 172 | { |
173 | char *const args[] = { | 173 | char *const args[] = { |
174 | "pdfinfo", | 174 | "pdfinfo", |
175 | "-", | 175 | "-", |
176 | NULL | 176 | NULL |
177 | }; | 177 | }; |
178 | /* am child, exec 'pdfinfo' */ | 178 | /* am child, exec 'pdfinfo' */ |
179 | close (0); | 179 | close (0); |
180 | close (1); | 180 | close (1); |
181 | if ( (-1 == dup2 (in[0], 0)) || | 181 | if ( (-1 == dup2 (in[0], 0)) || |
182 | (-1 == dup2 (out[1], 1)) ) | 182 | (-1 == dup2 (out[1], 1)) ) |
183 | exit (1); | ||
184 | close (in[0]); | ||
185 | close (in[1]); | ||
186 | close (out[0]); | ||
187 | close (out[1]); | ||
188 | execvp ("pdfinfo", args); | ||
189 | exit (1); | 183 | exit (1); |
190 | } | 184 | close (in[0]); |
185 | close (in[1]); | ||
186 | close (out[0]); | ||
187 | close (out[1]); | ||
188 | execvp ("pdfinfo", args); | ||
189 | exit (1); | ||
190 | } | ||
191 | /* am parent, send file */ | 191 | /* am parent, send file */ |
192 | close (in[0]); | 192 | close (in[0]); |
193 | close (out[1]); | 193 | close (out[1]); |
194 | fout = fdopen (out[0], "r"); | 194 | fout = fdopen (out[0], "r"); |
195 | if (NULL == fout) | 195 | if (NULL == fout) |
196 | { | 196 | { |
197 | close (in[1]); | 197 | close (in[1]); |
198 | close (out[0]); | 198 | close (out[0]); |
199 | kill (pid, SIGKILL); | 199 | kill (pid, SIGKILL); |
200 | waitpid (pid, NULL, 0); | 200 | waitpid (pid, NULL, 0); |
201 | return; | 201 | return; |
202 | } | 202 | } |
203 | pos = 0; | 203 | pos = 0; |
204 | while (pos < fsize) | 204 | while (pos < fsize) |
205 | { | ||
206 | ssize_t got; | ||
207 | size_t wpos; | ||
208 | |||
209 | data = NULL; | ||
210 | got = ec->read (ec->cls, | ||
211 | &data, | ||
212 | fsize - pos); | ||
213 | if ( (-1 == got) || | ||
214 | (NULL == data) ) | ||
215 | break; | ||
216 | wpos = 0; | ||
217 | while (wpos < got) | ||
205 | { | 218 | { |
206 | ssize_t got; | 219 | ssize_t out; |
207 | size_t wpos; | 220 | |
208 | 221 | out = write (in[1], data + wpos, got - wpos); | |
209 | data = NULL; | 222 | if (out <= 0) |
210 | got = ec->read (ec->cls, | ||
211 | &data, | ||
212 | fsize - pos); | ||
213 | if ( (-1 == got) || | ||
214 | (NULL == data) ) | ||
215 | break; | ||
216 | wpos = 0; | ||
217 | while (wpos < got) | ||
218 | { | ||
219 | ssize_t out; | ||
220 | |||
221 | out = write (in[1], data + wpos, got - wpos); | ||
222 | if (out <= 0) | ||
223 | break; | ||
224 | wpos += out; | ||
225 | } | ||
226 | if (wpos < got) | ||
227 | break; | 223 | break; |
228 | pos += got; | 224 | wpos += out; |
229 | } | 225 | } |
226 | if (wpos < got) | ||
227 | break; | ||
228 | pos += got; | ||
229 | } | ||
230 | close (in[1]); | 230 | close (in[1]); |
231 | process_stdout (fout, ec->proc, ec->cls); | 231 | process_stdout (fout, ec->proc, ec->cls); |
232 | fclose (fout); | 232 | fclose (fout); |
@@ -234,4 +234,5 @@ EXTRACTOR_pdf_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
234 | waitpid (pid, NULL, 0); | 234 | waitpid (pid, NULL, 0); |
235 | } | 235 | } |
236 | 236 | ||
237 | |||
237 | /* end of pdf_extractor.c */ | 238 | /* end of pdf_extractor.c */ |
diff --git a/src/plugins/png_extractor.c b/src/plugins/png_extractor.c index add1fde..fec6c17 100644 --- a/src/plugins/png_extractor.c +++ b/src/plugins/png_extractor.c | |||
@@ -43,7 +43,7 @@ | |||
43 | */ | 43 | */ |
44 | static char * | 44 | static char * |
45 | stndup (const char *str, | 45 | stndup (const char *str, |
46 | size_t n) | 46 | size_t n) |
47 | { | 47 | { |
48 | char *tmp; | 48 | char *tmp; |
49 | 49 | ||
@@ -67,13 +67,13 @@ stndup (const char *str, | |||
67 | */ | 67 | */ |
68 | static size_t | 68 | static size_t |
69 | stnlen (const char *str, | 69 | stnlen (const char *str, |
70 | size_t maxlen) | 70 | size_t maxlen) |
71 | { | 71 | { |
72 | size_t ret; | 72 | size_t ret; |
73 | 73 | ||
74 | ret = 0; | 74 | ret = 0; |
75 | while ( (ret < maxlen) && | 75 | while ( (ret < maxlen) && |
76 | ('\0' != str[ret]) ) | 76 | ('\0' != str[ret]) ) |
77 | ret++; | 77 | ret++; |
78 | return ret; | 78 | return ret; |
79 | } | 79 | } |
@@ -111,8 +111,7 @@ static struct | |||
111 | * Corresponding LE type. | 111 | * Corresponding LE type. |
112 | */ | 112 | */ |
113 | enum EXTRACTOR_MetaType type; | 113 | enum EXTRACTOR_MetaType type; |
114 | } tagmap[] = | 114 | } tagmap[] = { |
115 | { | ||
116 | { "Author", EXTRACTOR_METATYPE_AUTHOR_NAME }, | 115 | { "Author", EXTRACTOR_METATYPE_AUTHOR_NAME }, |
117 | { "Description", EXTRACTOR_METATYPE_DESCRIPTION }, | 116 | { "Description", EXTRACTOR_METATYPE_DESCRIPTION }, |
118 | { "Comment", EXTRACTOR_METATYPE_COMMENT }, | 117 | { "Comment", EXTRACTOR_METATYPE_COMMENT }, |
@@ -135,7 +134,11 @@ static struct | |||
135 | * @param t type of the metadata | 134 | * @param t type of the metadata |
136 | * @param s utf8 string with the metadata | 135 | * @param s utf8 string with the metadata |
137 | */ | 136 | */ |
138 | #define ADD(t,s) do { if (0 != (ret = ec->proc (ec->cls, "png", t, EXTRACTOR_METAFORMAT_UTF8, "text/plain", s, strlen (s) + 1))) goto FINISH; } while (0) | 137 | #define ADD(t,s) do { if (0 != (ret = ec->proc (ec->cls, "png", t, \ |
138 | EXTRACTOR_METAFORMAT_UTF8, \ | ||
139 | "text/plain", s, strlen (s) \ | ||
140 | + 1))) goto FINISH; \ | ||
141 | } while (0) | ||
139 | 142 | ||
140 | 143 | ||
141 | /** | 144 | /** |
@@ -145,7 +148,14 @@ static struct | |||
145 | * @param t type of the metadata | 148 | * @param t type of the metadata |
146 | * @param s utf8 string with the metadata, to be freed afterwards | 149 | * @param s utf8 string with the metadata, to be freed afterwards |
147 | */ | 150 | */ |
148 | #define ADDF(t,s) do { if ( (NULL != s) && (0 != (ret = ec->proc (ec->cls, "png", t, EXTRACTOR_METAFORMAT_UTF8, "text/plain", s, strlen (s) + 1))) ) { free (s); goto FINISH; } if (NULL != s) free (s); } while (0) | 151 | #define ADDF(t,s) do { if ( (NULL != s) && (0 != (ret = ec->proc (ec->cls, \ |
152 | "png", t, \ | ||
153 | EXTRACTOR_METAFORMAT_UTF8, \ | ||
154 | "text/plain", \ | ||
155 | s, strlen (s) \ | ||
156 | + 1))) ) { \ | ||
157 | free (s); goto FINISH; } if (NULL != s) free (s); \ | ||
158 | } while (0) | ||
149 | 159 | ||
150 | 160 | ||
151 | /** | 161 | /** |
@@ -173,16 +183,16 @@ processtEXt (struct EXTRACTOR_ExtractContext *ec, | |||
173 | if (off >= length) | 183 | if (off >= length) |
174 | return 0; /* failed to find '\0' */ | 184 | return 0; /* failed to find '\0' */ |
175 | if (NULL == (keyword = EXTRACTOR_common_convert_to_utf8 ((char*) &data[off], | 185 | if (NULL == (keyword = EXTRACTOR_common_convert_to_utf8 ((char*) &data[off], |
176 | length - off, | 186 | length - off, |
177 | "ISO-8859-1"))) | 187 | "ISO-8859-1"))) |
178 | return 0; | 188 | return 0; |
179 | ret = 0; | 189 | ret = 0; |
180 | for (i = 0; NULL != tagmap[i].name; i++) | 190 | for (i = 0; NULL != tagmap[i].name; i++) |
181 | if (0 == strcmp (tagmap[i].name, (char*) data)) | 191 | if (0 == strcmp (tagmap[i].name, (char*) data)) |
182 | { | 192 | { |
183 | ADDF (tagmap[i].type, keyword); | 193 | ADDF (tagmap[i].type, keyword); |
184 | return 0; | 194 | return 0; |
185 | } | 195 | } |
186 | ADDF (EXTRACTOR_METATYPE_KEYWORDS, keyword); | 196 | ADDF (EXTRACTOR_METATYPE_KEYWORDS, keyword); |
187 | FINISH: | 197 | FINISH: |
188 | return ret; | 198 | return ret; |
@@ -242,50 +252,50 @@ processiTXt (struct EXTRACTOR_ExtractContext *ec, | |||
242 | return 0; | 252 | return 0; |
243 | 253 | ||
244 | if (compressed) | 254 | if (compressed) |
255 | { | ||
256 | bufLen = 1024 + 2 * (length - pos); | ||
257 | while (1) | ||
245 | { | 258 | { |
246 | bufLen = 1024 + 2 * (length - pos); | 259 | if (bufLen * 2 < bufLen) |
247 | while (1) | 260 | return 0; |
248 | { | 261 | bufLen *= 2; |
249 | if (bufLen * 2 < bufLen) | 262 | if (bufLen > 50 * (length - pos)) |
250 | return 0; | 263 | { |
251 | bufLen *= 2; | 264 | /* printf("zlib problem"); */ |
252 | if (bufLen > 50 * (length - pos)) | 265 | return 0; |
253 | { | 266 | } |
254 | /* printf("zlib problem"); */ | 267 | if (NULL == (buf = malloc (bufLen))) |
255 | return 0; | 268 | { |
256 | } | 269 | /* printf("out of memory"); */ |
257 | if (NULL == (buf = malloc (bufLen))) | 270 | return 0; /* out of memory */ |
258 | { | 271 | } |
259 | /* printf("out of memory"); */ | 272 | if (Z_OK == |
260 | return 0; /* out of memory */ | 273 | (zret = uncompress ((Bytef *) buf, |
261 | } | 274 | &bufLen, |
262 | if (Z_OK == | 275 | (const Bytef *) &data[pos], length - pos))) |
263 | (zret = uncompress ((Bytef *) buf, | 276 | { |
264 | &bufLen, | 277 | /* printf("zlib ok"); */ |
265 | (const Bytef *) &data[pos], length - pos))) | 278 | break; |
266 | { | 279 | } |
267 | /* printf("zlib ok"); */ | ||
268 | break; | ||
269 | } | ||
270 | free (buf); | ||
271 | if (Z_BUF_ERROR != zret) | ||
272 | return 0; /* unknown error, abort */ | ||
273 | } | ||
274 | keyword = stndup (buf, bufLen); | ||
275 | free (buf); | 280 | free (buf); |
281 | if (Z_BUF_ERROR != zret) | ||
282 | return 0; /* unknown error, abort */ | ||
276 | } | 283 | } |
284 | keyword = stndup (buf, bufLen); | ||
285 | free (buf); | ||
286 | } | ||
277 | else | 287 | else |
278 | { | 288 | { |
279 | keyword = stndup ((char *) &data[pos], length - pos); | 289 | keyword = stndup ((char *) &data[pos], length - pos); |
280 | } | 290 | } |
281 | if (NULL == keyword) | 291 | if (NULL == keyword) |
282 | return ret; | 292 | return ret; |
283 | for (i = 0; NULL != tagmap[i].name; i++) | 293 | for (i = 0; NULL != tagmap[i].name; i++) |
284 | if (0 == strcmp (tagmap[i].name, (char*) data)) | 294 | if (0 == strcmp (tagmap[i].name, (char*) data)) |
285 | { | 295 | { |
286 | ADDF (tagmap[i].type, keyword /* already in utf8 */); | 296 | ADDF (tagmap[i].type, keyword /* already in utf8 */); |
287 | return 0; | 297 | return 0; |
288 | } | 298 | } |
289 | ADDF (EXTRACTOR_METATYPE_COMMENT, keyword); | 299 | ADDF (EXTRACTOR_METATYPE_COMMENT, keyword); |
290 | FINISH: | 300 | FINISH: |
291 | return ret; | 301 | return ret; |
@@ -357,43 +367,43 @@ processzTXt (struct EXTRACTOR_ExtractContext *ec, | |||
357 | ret = 0; | 367 | ret = 0; |
358 | bufLen = 1024 + 2 * (length - off); | 368 | bufLen = 1024 + 2 * (length - off); |
359 | while (1) | 369 | while (1) |
370 | { | ||
371 | if (bufLen * 2 < bufLen) | ||
372 | return 0; | ||
373 | bufLen *= 2; | ||
374 | if (bufLen > 50 * (length - off)) | ||
360 | { | 375 | { |
361 | if (bufLen * 2 < bufLen) | 376 | /* printf("zlib problem"); */ |
362 | return 0; | 377 | return 0; |
363 | bufLen *= 2; | 378 | } |
364 | if (bufLen > 50 * (length - off)) | 379 | if (NULL == (buf = malloc (bufLen))) |
365 | { | 380 | { |
366 | /* printf("zlib problem"); */ | 381 | /* printf("out of memory"); */ |
367 | return 0; | 382 | return 0; /* out of memory */ |
368 | } | 383 | } |
369 | if (NULL == (buf = malloc (bufLen))) | 384 | if (Z_OK == |
370 | { | 385 | (zret = uncompress ((Bytef *) buf, |
371 | /* printf("out of memory"); */ | 386 | &bufLen, |
372 | return 0; /* out of memory */ | 387 | (const Bytef *) &data[off], |
373 | } | 388 | length - off))) |
374 | if (Z_OK == | 389 | { |
375 | (zret = uncompress ((Bytef *) buf, | 390 | /* printf("zlib ok"); */ |
376 | &bufLen, | 391 | break; |
377 | (const Bytef *) &data[off], | ||
378 | length - off))) | ||
379 | { | ||
380 | /* printf("zlib ok"); */ | ||
381 | break; | ||
382 | } | ||
383 | free (buf); | ||
384 | if (Z_BUF_ERROR != zret) | ||
385 | return 0; /* unknown error, abort */ | ||
386 | } | 392 | } |
393 | free (buf); | ||
394 | if (Z_BUF_ERROR != zret) | ||
395 | return 0; /* unknown error, abort */ | ||
396 | } | ||
387 | keyword = EXTRACTOR_common_convert_to_utf8 (buf, | 397 | keyword = EXTRACTOR_common_convert_to_utf8 (buf, |
388 | bufLen, | 398 | bufLen, |
389 | "ISO-8859-1"); | 399 | "ISO-8859-1"); |
390 | free (buf); | 400 | free (buf); |
391 | for (i = 0; NULL != tagmap[i].name; i++) | 401 | for (i = 0; NULL != tagmap[i].name; i++) |
392 | if (0 == strcmp (tagmap[i].name, (char*) data)) | 402 | if (0 == strcmp (tagmap[i].name, (char*) data)) |
393 | { | 403 | { |
394 | ADDF (tagmap[i].type, keyword); | 404 | ADDF (tagmap[i].type, keyword); |
395 | return 0; | 405 | return 0; |
396 | } | 406 | } |
397 | ADDF (EXTRACTOR_METATYPE_COMMENT, keyword); | 407 | ADDF (EXTRACTOR_METATYPE_COMMENT, keyword); |
398 | FINISH: | 408 | FINISH: |
399 | return ret; | 409 | return ret; |
@@ -437,9 +447,9 @@ processtIME (struct EXTRACTOR_ExtractContext *ec, | |||
437 | m = (unsigned char) data[9]; | 447 | m = (unsigned char) data[9]; |
438 | s = (unsigned char) data[10]; | 448 | s = (unsigned char) data[10]; |
439 | snprintf (val, | 449 | snprintf (val, |
440 | sizeof (val), | 450 | sizeof (val), |
441 | "%04u-%02u-%02u %02d:%02d:%02d", | 451 | "%04u-%02u-%02u %02d:%02d:%02d", |
442 | year, mo, day, h, m, s); | 452 | year, mo, day, h, m, s); |
443 | ADD (EXTRACTOR_METATYPE_MODIFICATION_DATE, val); | 453 | ADD (EXTRACTOR_METATYPE_MODIFICATION_DATE, val); |
444 | FINISH: | 454 | FINISH: |
445 | return ret; | 455 | return ret; |
@@ -468,32 +478,33 @@ EXTRACTOR_png_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
468 | ADD (EXTRACTOR_METATYPE_MIMETYPE, "image/png"); | 478 | ADD (EXTRACTOR_METATYPE_MIMETYPE, "image/png"); |
469 | ret = 0; | 479 | ret = 0; |
470 | while (0 == ret) | 480 | while (0 == ret) |
471 | { | 481 | { |
472 | if (sizeof (uint32_t) + 4 != ec->read (ec->cls, | 482 | if (sizeof (uint32_t) + 4 != ec->read (ec->cls, |
473 | &data, | 483 | &data, |
474 | sizeof (uint32_t) + 4)) | 484 | sizeof (uint32_t) + 4)) |
475 | break; | 485 | break; |
476 | length = get_int_at (data); | 486 | length = get_int_at (data); |
477 | if (0 > (pos = ec->seek (ec->cls, 0, SEEK_CUR))) | 487 | if (0 > (pos = ec->seek (ec->cls, 0, SEEK_CUR))) |
478 | break; | 488 | break; |
479 | pos += length + 4; /* Chunk type, data, crc */ | 489 | pos += length + 4; /* Chunk type, data, crc */ |
480 | if (0 == strncmp ((char*) data + sizeof (uint32_t), "IHDR", 4)) | 490 | if (0 == strncmp ((char*) data + sizeof (uint32_t), "IHDR", 4)) |
481 | ret = processIHDR (ec, length); | 491 | ret = processIHDR (ec, length); |
482 | if (0 == strncmp ((char*) data + sizeof (uint32_t), "iTXt", 4)) | 492 | if (0 == strncmp ((char*) data + sizeof (uint32_t), "iTXt", 4)) |
483 | ret = processiTXt (ec, length); | 493 | ret = processiTXt (ec, length); |
484 | if (0 == strncmp ((char*) data + sizeof (uint32_t), "tEXt", 4)) | 494 | if (0 == strncmp ((char*) data + sizeof (uint32_t), "tEXt", 4)) |
485 | ret = processtEXt (ec, length); | 495 | ret = processtEXt (ec, length); |
486 | if (0 == strncmp ((char*) data + sizeof (uint32_t), "zTXt", 4)) | 496 | if (0 == strncmp ((char*) data + sizeof (uint32_t), "zTXt", 4)) |
487 | ret = processzTXt (ec, length); | 497 | ret = processzTXt (ec, length); |
488 | if (0 == strncmp ((char*) data + sizeof (uint32_t), "tIME", 4)) | 498 | if (0 == strncmp ((char*) data + sizeof (uint32_t), "tIME", 4)) |
489 | ret = processtIME (ec, length); | 499 | ret = processtIME (ec, length); |
490 | if (ret != 0) | 500 | if (ret != 0) |
491 | break; | 501 | break; |
492 | if (pos != ec->seek (ec->cls, pos, SEEK_SET)) | 502 | if (pos != ec->seek (ec->cls, pos, SEEK_SET)) |
493 | break; | 503 | break; |
494 | } | 504 | } |
495 | FINISH: | 505 | FINISH: |
496 | return; | 506 | return; |
497 | } | 507 | } |
498 | 508 | ||
509 | |||
499 | /* end of png_extractor.c */ | 510 | /* end of png_extractor.c */ |
diff --git a/src/plugins/previewopus_extractor.c b/src/plugins/previewopus_extractor.c index 4e137ec..0b9ab0b 100644 --- a/src/plugins/previewopus_extractor.c +++ b/src/plugins/previewopus_extractor.c | |||
@@ -65,15 +65,10 @@ | |||
65 | #include <ffmpeg/swscale.h> | 65 | #include <ffmpeg/swscale.h> |
66 | #endif | 66 | #endif |
67 | 67 | ||
68 | //TODO: Check for ffmpeg | 68 | // TODO: Check for ffmpeg |
69 | #include <libavresample/avresample.h> | 69 | #include <libavresample/avresample.h> |
70 | 70 | ||
71 | 71 | ||
72 | |||
73 | |||
74 | |||
75 | |||
76 | |||
77 | /** | 72 | /** |
78 | * Set to 1 to enable debug output. | 73 | * Set to 1 to enable debug output. |
79 | */ | 74 | */ |
@@ -85,16 +80,15 @@ | |||
85 | #define OUTPUT_FILE 0 | 80 | #define OUTPUT_FILE 0 |
86 | 81 | ||
87 | 82 | ||
88 | |||
89 | /** | 83 | /** |
90 | * Maximum size in bytes for the preview. | 84 | * Maximum size in bytes for the preview. |
91 | */ | 85 | */ |
92 | #define MAX_SIZE (28*1024) | 86 | #define MAX_SIZE (28 * 1024) |
93 | 87 | ||
94 | /** | 88 | /** |
95 | * HardLimit for file | 89 | * HardLimit for file |
96 | */ | 90 | */ |
97 | #define HARD_LIMIT_SIZE (50*1024) | 91 | #define HARD_LIMIT_SIZE (50 * 1024) |
98 | 92 | ||
99 | 93 | ||
100 | /** The output bit rate in kbit/s */ | 94 | /** The output bit rate in kbit/s */ |
@@ -116,11 +110,12 @@ static int totalSize; | |||
116 | * @param error Error code to be converted | 110 | * @param error Error code to be converted |
117 | * @return Corresponding error text (not thread-safe) | 111 | * @return Corresponding error text (not thread-safe) |
118 | */ | 112 | */ |
119 | static char *const get_error_text(const int error) | 113 | static char *const |
114 | get_error_text (const int error) | ||
120 | { | 115 | { |
121 | static char error_buffer[255]; | 116 | static char error_buffer[255]; |
122 | av_strerror(error, error_buffer, sizeof(error_buffer)); | 117 | av_strerror (error, error_buffer, sizeof(error_buffer)); |
123 | return error_buffer; | 118 | return error_buffer; |
124 | } | 119 | } |
125 | 120 | ||
126 | 121 | ||
@@ -134,8 +129,8 @@ static char *const get_error_text(const int error) | |||
134 | */ | 129 | */ |
135 | static int | 130 | static int |
136 | read_cb (void *opaque, | 131 | read_cb (void *opaque, |
137 | uint8_t *buf, | 132 | uint8_t *buf, |
138 | int buf_size) | 133 | int buf_size) |
139 | { | 134 | { |
140 | struct EXTRACTOR_ExtractContext *ec = opaque; | 135 | struct EXTRACTOR_ExtractContext *ec = opaque; |
141 | void *data; | 136 | void *data; |
@@ -159,8 +154,8 @@ read_cb (void *opaque, | |||
159 | */ | 154 | */ |
160 | static int64_t | 155 | static int64_t |
161 | seek_cb (void *opaque, | 156 | seek_cb (void *opaque, |
162 | int64_t offset, | 157 | int64_t offset, |
163 | int whence) | 158 | int whence) |
164 | { | 159 | { |
165 | struct EXTRACTOR_ExtractContext *ec = opaque; | 160 | struct EXTRACTOR_ExtractContext *ec = opaque; |
166 | 161 | ||
@@ -185,7 +180,7 @@ writePacket (void *opaque, | |||
185 | { | 180 | { |
186 | int sizeToCopy = pBufferSize; | 181 | int sizeToCopy = pBufferSize; |
187 | 182 | ||
188 | if( (totalSize + pBufferSize) > HARD_LIMIT_SIZE) | 183 | if ( (totalSize + pBufferSize) > HARD_LIMIT_SIZE) |
189 | sizeToCopy = HARD_LIMIT_SIZE - totalSize; | 184 | sizeToCopy = HARD_LIMIT_SIZE - totalSize; |
190 | 185 | ||
191 | memcpy (buffer + totalSize, pBuffer, sizeToCopy); | 186 | memcpy (buffer + totalSize, pBuffer, sizeToCopy); |
@@ -199,10 +194,11 @@ writePacket (void *opaque, | |||
199 | * Also set some basic encoder parameters. | 194 | * Also set some basic encoder parameters. |
200 | * Some of these parameters are based on the input file's parameters. | 195 | * Some of these parameters are based on the input file's parameters. |
201 | */ | 196 | */ |
202 | static int open_output_file( | 197 | static int |
203 | AVCodecContext *input_codec_context, | 198 | open_output_file ( |
204 | AVFormatContext **output_format_context, | 199 | AVCodecContext *input_codec_context, |
205 | AVCodecContext **output_codec_context) | 200 | AVFormatContext **output_format_context, |
201 | AVCodecContext **output_codec_context) | ||
206 | { | 202 | { |
207 | AVStream *stream = NULL; | 203 | AVStream *stream = NULL; |
208 | AVCodec *output_codec = NULL; | 204 | AVCodec *output_codec = NULL; |
@@ -213,50 +209,50 @@ static int open_output_file( | |||
213 | if (NULL == (iob = av_malloc (16 * 1024))) | 209 | if (NULL == (iob = av_malloc (16 * 1024))) |
214 | return AVERROR_EXIT; | 210 | return AVERROR_EXIT; |
215 | if (NULL == (io_ctx = avio_alloc_context (iob, 16 * 1024, | 211 | if (NULL == (io_ctx = avio_alloc_context (iob, 16 * 1024, |
216 | AVIO_FLAG_WRITE, NULL, | 212 | AVIO_FLAG_WRITE, NULL, |
217 | NULL, | 213 | NULL, |
218 | &writePacket /* no writing */, | 214 | &writePacket /* no writing */, |
219 | NULL))) | 215 | NULL))) |
220 | { | 216 | { |
221 | av_free (iob); | 217 | av_free (iob); |
222 | return AVERROR_EXIT; | 218 | return AVERROR_EXIT; |
223 | } | 219 | } |
224 | if (NULL == ((*output_format_context) = avformat_alloc_context ())) | 220 | if (NULL == ((*output_format_context) = avformat_alloc_context ())) |
225 | { | 221 | { |
226 | av_free (io_ctx); | 222 | av_free (io_ctx); |
227 | return AVERROR_EXIT; | 223 | return AVERROR_EXIT; |
228 | } | 224 | } |
229 | (*output_format_context)->pb = io_ctx; | 225 | (*output_format_context)->pb = io_ctx; |
230 | 226 | ||
231 | /** Guess the desired container format based on the file extension. */ | 227 | /** Guess the desired container format based on the file extension. */ |
232 | if (!((*output_format_context)->oformat = av_guess_format (NULL, | 228 | if (! ((*output_format_context)->oformat = av_guess_format (NULL, |
233 | "file.ogg", | 229 | "file.ogg", |
234 | NULL))) | 230 | NULL))) |
235 | { | 231 | { |
236 | #if DEBUG | 232 | #if DEBUG |
237 | fprintf(stderr, "Could not find output file format\n"); | 233 | fprintf (stderr, "Could not find output file format\n"); |
238 | #endif | 234 | #endif |
239 | goto cleanup; | 235 | goto cleanup; |
240 | } | 236 | } |
241 | 237 | ||
242 | /** Find the encoder to be used by its name. */ | 238 | /** Find the encoder to be used by its name. */ |
243 | if (!(output_codec = avcodec_find_encoder(AV_CODEC_ID_OPUS))) | 239 | if (! (output_codec = avcodec_find_encoder (AV_CODEC_ID_OPUS))) |
244 | { | 240 | { |
245 | #if DEBUG | 241 | #if DEBUG |
246 | fprintf(stderr, "Could not find an OPUS encoder.\n"); | 242 | fprintf (stderr, "Could not find an OPUS encoder.\n"); |
247 | #endif | 243 | #endif |
248 | goto cleanup; | 244 | goto cleanup; |
249 | } | 245 | } |
250 | 246 | ||
251 | /** Create a new audio stream in the output file container. */ | 247 | /** Create a new audio stream in the output file container. */ |
252 | if (!(stream = avformat_new_stream(*output_format_context, output_codec))) | 248 | if (! (stream = avformat_new_stream (*output_format_context, output_codec))) |
253 | { | 249 | { |
254 | #if DEBUG | 250 | #if DEBUG |
255 | fprintf(stderr, "Could not create new stream\n"); | 251 | fprintf (stderr, "Could not create new stream\n"); |
256 | #endif | 252 | #endif |
257 | error = AVERROR(ENOMEM); | 253 | error = AVERROR (ENOMEM); |
258 | goto cleanup; | 254 | goto cleanup; |
259 | } | 255 | } |
260 | 256 | ||
261 | /** Save the encoder context for easiert access later. */ | 257 | /** Save the encoder context for easiert access later. */ |
262 | *output_codec_context = stream->codec; | 258 | *output_codec_context = stream->codec; |
@@ -266,20 +262,21 @@ static int open_output_file( | |||
266 | * The input file's sample rate is used to avoid a sample rate conversion. | 262 | * The input file's sample rate is used to avoid a sample rate conversion. |
267 | */ | 263 | */ |
268 | (*output_codec_context)->channels = OUTPUT_CHANNELS; | 264 | (*output_codec_context)->channels = OUTPUT_CHANNELS; |
269 | (*output_codec_context)->channel_layout = av_get_default_channel_layout(OUTPUT_CHANNELS); | 265 | (*output_codec_context)->channel_layout = av_get_default_channel_layout ( |
270 | (*output_codec_context)->sample_rate = 48000; //Opus need 48000 | 266 | OUTPUT_CHANNELS); |
267 | (*output_codec_context)->sample_rate = 48000; // Opus need 48000 | ||
271 | (*output_codec_context)->sample_fmt = AV_SAMPLE_FMT_S16; | 268 | (*output_codec_context)->sample_fmt = AV_SAMPLE_FMT_S16; |
272 | (*output_codec_context)->bit_rate = OUTPUT_BIT_RATE; | 269 | (*output_codec_context)->bit_rate = OUTPUT_BIT_RATE; |
273 | 270 | ||
274 | /** Open the encoder for the audio stream to use it later. */ | 271 | /** Open the encoder for the audio stream to use it later. */ |
275 | if ((error = avcodec_open2(*output_codec_context, output_codec, NULL)) < 0) | 272 | if ((error = avcodec_open2 (*output_codec_context, output_codec, NULL)) < 0) |
276 | { | 273 | { |
277 | #if DEBUG | 274 | #if DEBUG |
278 | fprintf(stderr, "Could not open output codec (error '%s')\n", | 275 | fprintf (stderr, "Could not open output codec (error '%s')\n", |
279 | get_error_text(error)); | 276 | get_error_text (error)); |
280 | #endif | 277 | #endif |
281 | goto cleanup; | 278 | goto cleanup; |
282 | } | 279 | } |
283 | return 0; | 280 | return 0; |
284 | 281 | ||
285 | cleanup: | 282 | cleanup: |
@@ -290,9 +287,9 @@ cleanup: | |||
290 | 287 | ||
291 | /** Initialize one data packet for reading or writing. */ | 288 | /** Initialize one data packet for reading or writing. */ |
292 | static void | 289 | static void |
293 | init_packet(AVPacket *packet) | 290 | init_packet (AVPacket *packet) |
294 | { | 291 | { |
295 | av_init_packet(packet); | 292 | av_init_packet (packet); |
296 | /** Set the packet data and size so that it is recognized as being empty. */ | 293 | /** Set the packet data and size so that it is recognized as being empty. */ |
297 | packet->data = NULL; | 294 | packet->data = NULL; |
298 | packet->size = 0; | 295 | packet->size = 0; |
@@ -301,20 +298,20 @@ init_packet(AVPacket *packet) | |||
301 | 298 | ||
302 | /** Initialize one audio frame for reading from the input file */ | 299 | /** Initialize one audio frame for reading from the input file */ |
303 | static int | 300 | static int |
304 | init_input_frame(AVFrame **frame) | 301 | init_input_frame (AVFrame **frame) |
305 | { | 302 | { |
306 | #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1) | 303 | #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1) |
307 | *frame = av_frame_alloc (); | 304 | *frame = av_frame_alloc (); |
308 | #else | 305 | #else |
309 | *frame = avcodec_alloc_frame(); | 306 | *frame = avcodec_alloc_frame (); |
310 | #endif | 307 | #endif |
311 | if (NULL == *frame) | 308 | if (NULL == *frame) |
312 | { | 309 | { |
313 | #if DEBUG | 310 | #if DEBUG |
314 | fprintf(stderr, "Could not allocate input frame\n"); | 311 | fprintf (stderr, "Could not allocate input frame\n"); |
315 | #endif | 312 | #endif |
316 | return AVERROR(ENOMEM); | 313 | return AVERROR (ENOMEM); |
317 | } | 314 | } |
318 | return 0; | 315 | return 0; |
319 | } | 316 | } |
320 | 317 | ||
@@ -329,527 +326,591 @@ init_resampler (AVCodecContext *input_codec_context, | |||
329 | AVCodecContext *output_codec_context, | 326 | AVCodecContext *output_codec_context, |
330 | AVAudioResampleContext **resample_context) | 327 | AVAudioResampleContext **resample_context) |
331 | { | 328 | { |
332 | /** | 329 | /** |
333 | * Only initialize the resampler if it is necessary, i.e., | 330 | * Only initialize the resampler if it is necessary, i.e., |
334 | * if and only if the sample formats differ. | 331 | * if and only if the sample formats differ. |
335 | */ | 332 | */ |
336 | if (input_codec_context->sample_fmt != output_codec_context->sample_fmt || | 333 | if ((input_codec_context->sample_fmt != output_codec_context->sample_fmt) || |
337 | input_codec_context->channels != output_codec_context->channels) { | 334 | (input_codec_context->channels != output_codec_context->channels) ) |
338 | int error; | 335 | { |
336 | int error; | ||
339 | 337 | ||
340 | /** Create a resampler context for the conversion. */ | 338 | /** Create a resampler context for the conversion. */ |
341 | if (!(*resample_context = avresample_alloc_context())) { | 339 | if (! (*resample_context = avresample_alloc_context ())) |
340 | { | ||
342 | #if DEBUG | 341 | #if DEBUG |
343 | fprintf(stderr, "Could not allocate resample context\n"); | 342 | fprintf (stderr, "Could not allocate resample context\n"); |
344 | #endif | 343 | #endif |
345 | return AVERROR(ENOMEM); | 344 | return AVERROR (ENOMEM); |
346 | } | 345 | } |
347 | 346 | ||
348 | 347 | ||
349 | /** | 348 | /** |
350 | * Set the conversion parameters. | 349 | * Set the conversion parameters. |
351 | * Default channel layouts based on the number of channels | 350 | * Default channel layouts based on the number of channels |
352 | * are assumed for simplicity (they are sometimes not detected | 351 | * are assumed for simplicity (they are sometimes not detected |
353 | * properly by the demuxer and/or decoder). | 352 | * properly by the demuxer and/or decoder). |
354 | */ | 353 | */av_opt_set_int (*resample_context, "in_channel_layout", |
355 | av_opt_set_int(*resample_context, "in_channel_layout", | 354 | av_get_default_channel_layout ( |
356 | av_get_default_channel_layout(input_codec_context->channels), 0); | 355 | input_codec_context->channels), 0); |
357 | av_opt_set_int(*resample_context, "out_channel_layout", | 356 | av_opt_set_int (*resample_context, "out_channel_layout", |
358 | av_get_default_channel_layout(output_codec_context->channels), 0); | 357 | av_get_default_channel_layout ( |
359 | av_opt_set_int(*resample_context, "in_sample_rate", | 358 | output_codec_context->channels), 0); |
360 | input_codec_context->sample_rate, 0); | 359 | av_opt_set_int (*resample_context, "in_sample_rate", |
361 | av_opt_set_int(*resample_context, "out_sample_rate", | 360 | input_codec_context->sample_rate, 0); |
362 | output_codec_context->sample_rate, 0); | 361 | av_opt_set_int (*resample_context, "out_sample_rate", |
363 | av_opt_set_int(*resample_context, "in_sample_fmt", | 362 | output_codec_context->sample_rate, 0); |
364 | input_codec_context->sample_fmt, 0); | 363 | av_opt_set_int (*resample_context, "in_sample_fmt", |
365 | av_opt_set_int(*resample_context, "out_sample_fmt", | 364 | input_codec_context->sample_fmt, 0); |
366 | output_codec_context->sample_fmt, 0); | 365 | av_opt_set_int (*resample_context, "out_sample_fmt", |
367 | 366 | output_codec_context->sample_fmt, 0); | |
368 | /** Open the resampler with the specified parameters. */ | 367 | |
369 | if ((error = avresample_open(*resample_context)) < 0) { | 368 | /** Open the resampler with the specified parameters. */ |
369 | if ((error = avresample_open (*resample_context)) < 0) | ||
370 | { | ||
370 | #if DEBUG | 371 | #if DEBUG |
371 | fprintf(stderr, "Could not open resample context\n"); | 372 | fprintf (stderr, "Could not open resample context\n"); |
372 | #endif | 373 | #endif |
373 | avresample_free(resample_context); | 374 | avresample_free (resample_context); |
374 | return error; | 375 | return error; |
375 | } | ||
376 | } | 376 | } |
377 | return 0; | 377 | } |
378 | return 0; | ||
378 | } | 379 | } |
379 | 380 | ||
381 | |||
380 | /** Initialize a FIFO buffer for the audio samples to be encoded. */ | 382 | /** Initialize a FIFO buffer for the audio samples to be encoded. */ |
381 | static int init_fifo(AVAudioFifo **fifo) | 383 | static int |
384 | init_fifo (AVAudioFifo **fifo) | ||
382 | { | 385 | { |
383 | /** Create the FIFO buffer based on the specified output sample format. */ | 386 | /** Create the FIFO buffer based on the specified output sample format. */ |
384 | if (!(*fifo = av_audio_fifo_alloc(OUTPUT_SAMPLE_FORMAT, OUTPUT_CHANNELS, 1))) { | 387 | if (! (*fifo = av_audio_fifo_alloc (OUTPUT_SAMPLE_FORMAT, OUTPUT_CHANNELS, |
388 | 1))) | ||
389 | { | ||
385 | #if DEBUG | 390 | #if DEBUG |
386 | fprintf(stderr, "Could not allocate FIFO\n"); | 391 | fprintf (stderr, "Could not allocate FIFO\n"); |
387 | #endif | 392 | #endif |
388 | return AVERROR(ENOMEM); | 393 | return AVERROR (ENOMEM); |
389 | } | 394 | } |
390 | return 0; | 395 | return 0; |
391 | } | 396 | } |
392 | 397 | ||
398 | |||
393 | /** Write the header of the output file container. */ | 399 | /** Write the header of the output file container. */ |
394 | static int write_output_file_header(AVFormatContext *output_format_context) | 400 | static int |
401 | write_output_file_header (AVFormatContext *output_format_context) | ||
395 | { | 402 | { |
396 | int error; | 403 | int error; |
397 | if ((error = avformat_write_header(output_format_context, NULL)) < 0) { | 404 | if ((error = avformat_write_header (output_format_context, NULL)) < 0) |
405 | { | ||
398 | #if DEBUG | 406 | #if DEBUG |
399 | fprintf(stderr, "Could not write output file header (error '%s')\n", | 407 | fprintf (stderr, "Could not write output file header (error '%s')\n", |
400 | get_error_text(error)); | 408 | get_error_text (error)); |
401 | #endif | 409 | #endif |
402 | return error; | 410 | return error; |
403 | } | 411 | } |
404 | return 0; | 412 | return 0; |
405 | } | 413 | } |
406 | 414 | ||
415 | |||
407 | /** Decode one audio frame from the input file. */ | 416 | /** Decode one audio frame from the input file. */ |
408 | static int decode_audio_frame(AVFrame *frame, | 417 | static int |
409 | AVFormatContext *input_format_context, | 418 | decode_audio_frame (AVFrame *frame, |
410 | AVCodecContext *input_codec_context, int audio_stream_index, | 419 | AVFormatContext *input_format_context, |
411 | int *data_present, int *finished) | 420 | AVCodecContext *input_codec_context, int audio_stream_index, |
421 | int *data_present, int *finished) | ||
412 | { | 422 | { |
413 | /** Packet used for temporary storage. */ | 423 | /** Packet used for temporary storage. */ |
414 | AVPacket input_packet; | 424 | AVPacket input_packet; |
415 | int error; | 425 | int error; |
416 | init_packet(&input_packet); | 426 | init_packet (&input_packet); |
417 | 427 | ||
418 | /** Read one audio frame from the input file into a temporary packet. */ | 428 | /** Read one audio frame from the input file into a temporary packet. */ |
419 | while(1){ | 429 | while (1) |
420 | if ((error = av_read_frame(input_format_context, &input_packet)) < 0) { | 430 | { |
421 | /** If we are the the end of the file, flush the decoder below. */ | 431 | if ((error = av_read_frame (input_format_context, &input_packet)) < 0) |
422 | if (error == AVERROR_EOF){ | 432 | { |
433 | /** If we are the the end of the file, flush the decoder below. */ | ||
434 | if (error == AVERROR_EOF) | ||
435 | { | ||
423 | #if DEBUG | 436 | #if DEBUG |
424 | fprintf(stderr, "EOF in decode_audio\n"); | 437 | fprintf (stderr, "EOF in decode_audio\n"); |
425 | #endif | 438 | #endif |
426 | *finished = 1; | 439 | *finished = 1; |
427 | } | 440 | } |
428 | else { | 441 | else |
442 | { | ||
429 | #if DEBUG | 443 | #if DEBUG |
430 | fprintf(stderr, "Could not read frame (error '%s')\n", | 444 | fprintf (stderr, "Could not read frame (error '%s')\n", |
431 | get_error_text(error)); | 445 | get_error_text (error)); |
432 | #endif | 446 | #endif |
433 | return error; | 447 | return error; |
434 | } | 448 | } |
435 | } | 449 | } |
436 | 450 | ||
437 | if(input_packet.stream_index == audio_stream_index) | 451 | if (input_packet.stream_index == audio_stream_index) |
438 | break; | 452 | break; |
439 | } | 453 | } |
440 | 454 | ||
441 | /** | 455 | /** |
442 | * Decode the audio frame stored in the temporary packet. | 456 | * Decode the audio frame stored in the temporary packet. |
443 | * The input audio stream decoder is used to do this. | 457 | * The input audio stream decoder is used to do this. |
444 | * If we are at the end of the file, pass an empty packet to the decoder | 458 | * If we are at the end of the file, pass an empty packet to the decoder |
445 | * to flush it. | 459 | * to flush it. |
446 | */ | 460 | */if ((error = avcodec_decode_audio4 (input_codec_context, frame, |
447 | if ((error = avcodec_decode_audio4(input_codec_context, frame, | 461 | data_present, &input_packet)) < 0) |
448 | data_present, &input_packet)) < 0) { | 462 | { |
449 | #if DEBUG | 463 | #if DEBUG |
450 | fprintf(stderr, "Could not decode frame (error '%s')\n", | 464 | fprintf (stderr, "Could not decode frame (error '%s')\n", |
451 | get_error_text(error)); | 465 | get_error_text (error)); |
452 | #endif | 466 | #endif |
453 | av_free_packet(&input_packet); | 467 | av_free_packet (&input_packet); |
454 | return error; | 468 | return error; |
455 | } | 469 | } |
456 | 470 | ||
457 | /** | 471 | /** |
458 | * If the decoder has not been flushed completely, we are not finished, | 472 | * If the decoder has not been flushed completely, we are not finished, |
459 | * so that this function has to be called again. | 473 | * so that this function has to be called again. |
460 | */ | 474 | */ |
461 | if (*finished && *data_present) | 475 | if (*finished && *data_present) |
462 | *finished = 0; | 476 | *finished = 0; |
463 | av_free_packet(&input_packet); | 477 | av_free_packet (&input_packet); |
464 | return 0; | 478 | return 0; |
465 | } | 479 | } |
466 | 480 | ||
481 | |||
467 | /** | 482 | /** |
468 | * Initialize a temporary storage for the specified number of audio samples. | 483 | * Initialize a temporary storage for the specified number of audio samples. |
469 | * The conversion requires temporary storage due to the different format. | 484 | * The conversion requires temporary storage due to the different format. |
470 | * The number of audio samples to be allocated is specified in frame_size. | 485 | * The number of audio samples to be allocated is specified in frame_size. |
471 | */ | 486 | */ |
472 | static int init_converted_samples(uint8_t ***converted_input_samples, int* out_linesize, | 487 | static int |
473 | AVCodecContext *output_codec_context, | 488 | init_converted_samples (uint8_t ***converted_input_samples, int*out_linesize, |
474 | int frame_size) | 489 | AVCodecContext *output_codec_context, |
490 | int frame_size) | ||
475 | { | 491 | { |
476 | int error; | 492 | int error; |
477 | 493 | ||
478 | /** | 494 | /** |
479 | * Allocate as many pointers as there are audio channels. | 495 | * Allocate as many pointers as there are audio channels. |
480 | * Each pointer will later point to the audio samples of the corresponding | 496 | * Each pointer will later point to the audio samples of the corresponding |
481 | * channels (although it may be NULL for interleaved formats). | 497 | * channels (although it may be NULL for interleaved formats). |
482 | */ | 498 | */if (! (*converted_input_samples = calloc (output_codec_context->channels, |
483 | if (!(*converted_input_samples = calloc(output_codec_context->channels, | 499 | sizeof(**converted_input_samples)))) |
484 | sizeof(**converted_input_samples)))) { | 500 | { |
485 | #if DEBUG | 501 | #if DEBUG |
486 | fprintf(stderr, "Could not allocate converted input sample pointers\n"); | 502 | fprintf (stderr, "Could not allocate converted input sample pointers\n"); |
487 | #endif | 503 | #endif |
488 | return AVERROR(ENOMEM); | 504 | return AVERROR (ENOMEM); |
489 | } | 505 | } |
490 | 506 | ||
491 | /** | 507 | /** |
492 | * Allocate memory for the samples of all channels in one consecutive | 508 | * Allocate memory for the samples of all channels in one consecutive |
493 | * block for convenience. | 509 | * block for convenience. |
494 | */ | 510 | */ |
495 | if ((error = av_samples_alloc(*converted_input_samples, out_linesize, | 511 | if ((error = av_samples_alloc (*converted_input_samples, out_linesize, |
496 | output_codec_context->channels, | 512 | output_codec_context->channels, |
497 | frame_size, | 513 | frame_size, |
498 | output_codec_context->sample_fmt, 0)) < 0) { | 514 | output_codec_context->sample_fmt, 0)) < 0) |
515 | { | ||
499 | #if DEBUG | 516 | #if DEBUG |
500 | fprintf(stderr, | 517 | fprintf (stderr, |
501 | "Could not allocate converted input samples (error '%s')\n", | 518 | "Could not allocate converted input samples (error '%s')\n", |
502 | get_error_text(error)); | 519 | get_error_text (error)); |
503 | #endif | 520 | #endif |
504 | av_freep(&(*converted_input_samples)[0]); | 521 | av_freep (&(*converted_input_samples)[0]); |
505 | free(*converted_input_samples); | 522 | free (*converted_input_samples); |
506 | return error; | 523 | return error; |
507 | } | 524 | } |
508 | return 0; | 525 | return 0; |
509 | } | 526 | } |
510 | 527 | ||
528 | |||
511 | /** | 529 | /** |
512 | * Convert the input audio samples into the output sample format. | 530 | * Convert the input audio samples into the output sample format. |
513 | * The conversion happens on a per-frame basis, the size of which is specified | 531 | * The conversion happens on a per-frame basis, the size of which is specified |
514 | * by frame_size. | 532 | * by frame_size. |
515 | */ | 533 | */ |
516 | static int convert_samples(uint8_t **input_data, | 534 | static int |
517 | uint8_t **converted_data, const int in_sample, const int out_sample, const int out_linesize, | 535 | convert_samples (uint8_t **input_data, |
518 | AVAudioResampleContext *resample_context) | 536 | uint8_t **converted_data, const int in_sample, const int |
537 | out_sample, const int out_linesize, | ||
538 | AVAudioResampleContext *resample_context) | ||
519 | { | 539 | { |
520 | int error; | 540 | int error; |
521 | 541 | ||
522 | /** Convert the samples using the resampler. */ | 542 | /** Convert the samples using the resampler. */ |
523 | if ((error = avresample_convert(resample_context, converted_data, out_linesize, | 543 | if ((error = avresample_convert (resample_context, converted_data, |
524 | out_sample, input_data, 0, in_sample)) < 0) { | 544 | out_linesize, |
545 | out_sample, input_data, 0, in_sample)) < 0) | ||
546 | { | ||
525 | #if DEBUG | 547 | #if DEBUG |
526 | fprintf(stderr, "Could not convert input samples (error '%s')\n", | 548 | fprintf (stderr, "Could not convert input samples (error '%s')\n", |
527 | get_error_text(error)); | 549 | get_error_text (error)); |
528 | #endif | 550 | #endif |
529 | return error; | 551 | return error; |
530 | } | 552 | } |
531 | 553 | ||
532 | 554 | ||
533 | /** | 555 | /** |
534 | * Perform a sanity check so that the number of converted samples is | 556 | * Perform a sanity check so that the number of converted samples is |
535 | * not greater than the number of samples to be converted. | 557 | * not greater than the number of samples to be converted. |
536 | * If the sample rates differ, this case has to be handled differently | 558 | * If the sample rates differ, this case has to be handled differently |
537 | */ | 559 | */if (avresample_available (resample_context)) |
538 | if (avresample_available(resample_context)) { | 560 | { |
539 | #if DEBUG | 561 | #if DEBUG |
540 | fprintf(stderr, "%i Converted samples left over\n",avresample_available(resample_context)); | 562 | fprintf (stderr, "%i Converted samples left over\n",avresample_available ( |
563 | resample_context)); | ||
541 | #endif | 564 | #endif |
542 | } | 565 | } |
543 | 566 | ||
544 | 567 | ||
545 | return 0; | 568 | return 0; |
546 | } | 569 | } |
547 | 570 | ||
571 | |||
548 | /** Add converted input audio samples to the FIFO buffer for later processing. */ | 572 | /** Add converted input audio samples to the FIFO buffer for later processing. */ |
549 | static int add_samples_to_fifo(AVAudioFifo *fifo, | 573 | static int |
550 | uint8_t **converted_input_samples, | 574 | add_samples_to_fifo (AVAudioFifo *fifo, |
551 | const int frame_size) | 575 | uint8_t **converted_input_samples, |
576 | const int frame_size) | ||
552 | { | 577 | { |
553 | int error; | 578 | int error; |
554 | 579 | ||
555 | /** | 580 | /** |
556 | * Make the FIFO as large as it needs to be to hold both, | 581 | * Make the FIFO as large as it needs to be to hold both, |
557 | * the old and the new samples. | 582 | * the old and the new samples. |
558 | */ | 583 | */ |
559 | if ((error = av_audio_fifo_realloc(fifo, av_audio_fifo_size(fifo) + frame_size)) < 0) { | 584 | if ((error = av_audio_fifo_realloc (fifo, av_audio_fifo_size (fifo) |
585 | + frame_size)) < 0) | ||
586 | { | ||
560 | #if DEBUG | 587 | #if DEBUG |
561 | fprintf(stderr, "Could not reallocate FIFO\n"); | 588 | fprintf (stderr, "Could not reallocate FIFO\n"); |
562 | #endif | 589 | #endif |
563 | return error; | 590 | return error; |
564 | } | 591 | } |
565 | 592 | ||
566 | /** Store the new samples in the FIFO buffer. */ | 593 | /** Store the new samples in the FIFO buffer. */ |
567 | if (av_audio_fifo_write(fifo, (void **)converted_input_samples, | 594 | if (av_audio_fifo_write (fifo, (void **) converted_input_samples, |
568 | frame_size) < frame_size) { | 595 | frame_size) < frame_size) |
596 | { | ||
569 | #if DEBUG | 597 | #if DEBUG |
570 | fprintf(stderr, "Could not write data to FIFO\n"); | 598 | fprintf (stderr, "Could not write data to FIFO\n"); |
571 | #endif | 599 | #endif |
572 | return AVERROR_EXIT; | 600 | return AVERROR_EXIT; |
573 | } | 601 | } |
574 | return 0; | 602 | return 0; |
575 | } | 603 | } |
576 | 604 | ||
605 | |||
577 | /** | 606 | /** |
578 | * Read one audio frame from the input file, decodes, converts and stores | 607 | * Read one audio frame from the input file, decodes, converts and stores |
579 | * it in the FIFO buffer. | 608 | * it in the FIFO buffer. |
580 | */ | 609 | */ |
581 | static int read_decode_convert_and_store(AVAudioFifo *fifo, | 610 | static int |
582 | AVFormatContext *input_format_context, | 611 | read_decode_convert_and_store (AVAudioFifo *fifo, |
583 | AVCodecContext *input_codec_context, | 612 | AVFormatContext *input_format_context, |
584 | AVCodecContext *output_codec_context, | 613 | AVCodecContext *input_codec_context, |
585 | AVAudioResampleContext *resampler_context, int audio_stream_index, | 614 | AVCodecContext *output_codec_context, |
586 | int *finished) | 615 | AVAudioResampleContext *resampler_context, int |
616 | audio_stream_index, | ||
617 | int *finished) | ||
587 | { | 618 | { |
588 | /** Temporary storage of the input samples of the frame read from the file. */ | 619 | /** Temporary storage of the input samples of the frame read from the file. */ |
589 | AVFrame *input_frame = NULL; | 620 | AVFrame *input_frame = NULL; |
590 | /** Temporary storage for the converted input samples. */ | 621 | /** Temporary storage for the converted input samples. */ |
591 | uint8_t **converted_input_samples = NULL; | 622 | uint8_t **converted_input_samples = NULL; |
592 | int data_present; | 623 | int data_present; |
593 | int ret = AVERROR_EXIT; | 624 | int ret = AVERROR_EXIT; |
594 | 625 | ||
595 | /** Initialize temporary storage for one input frame. */ | 626 | /** Initialize temporary storage for one input frame. */ |
596 | if (init_input_frame(&input_frame)){ | 627 | if (init_input_frame (&input_frame)) |
628 | { | ||
597 | #if DEBUG | 629 | #if DEBUG |
598 | fprintf(stderr, "Failed at init frame\n"); | 630 | fprintf (stderr, "Failed at init frame\n"); |
599 | #endif | 631 | #endif |
600 | goto cleanup; | 632 | goto cleanup; |
601 | 633 | ||
602 | } | 634 | } |
603 | /** Decode one frame worth of audio samples. */ | 635 | /** Decode one frame worth of audio samples. */ |
604 | if (decode_audio_frame(input_frame, input_format_context, | 636 | if (decode_audio_frame (input_frame, input_format_context, |
605 | input_codec_context, audio_stream_index, &data_present, finished)){ | 637 | input_codec_context, audio_stream_index, |
638 | &data_present, finished)) | ||
639 | { | ||
606 | #if DEBUG | 640 | #if DEBUG |
607 | fprintf(stderr, "Failed at decode audio\n"); | 641 | fprintf (stderr, "Failed at decode audio\n"); |
608 | #endif | 642 | #endif |
609 | 643 | ||
610 | goto cleanup; | 644 | goto cleanup; |
611 | 645 | ||
612 | } | 646 | } |
613 | /** | 647 | /** |
614 | * If we are at the end of the file and there are no more samples | 648 | * If we are at the end of the file and there are no more samples |
615 | * in the decoder which are delayed, we are actually finished. | 649 | * in the decoder which are delayed, we are actually finished. |
616 | * This must not be treated as an error. | 650 | * This must not be treated as an error. |
617 | */ | 651 | */if (*finished && ! data_present) |
618 | if (*finished && !data_present) { | 652 | { |
619 | ret = 0; | 653 | ret = 0; |
620 | #if DEBUG | 654 | #if DEBUG |
621 | fprintf(stderr, "Failed at finished or no data\n"); | 655 | fprintf (stderr, "Failed at finished or no data\n"); |
622 | #endif | 656 | #endif |
623 | goto cleanup; | 657 | goto cleanup; |
624 | } | 658 | } |
625 | /** If there is decoded data, convert and store it */ | 659 | /** If there is decoded data, convert and store it */ |
626 | if (data_present) { | 660 | if (data_present) |
627 | int out_linesize; | 661 | { |
628 | //FIX ME: I'm losing samples, but can't get it to work. | 662 | int out_linesize; |
629 | int out_samples = avresample_available(resampler_context) + avresample_get_delay(resampler_context) + input_frame->nb_samples; | 663 | // FIX ME: I'm losing samples, but can't get it to work. |
664 | int out_samples = avresample_available (resampler_context) | ||
665 | + avresample_get_delay (resampler_context) | ||
666 | + input_frame->nb_samples; | ||
630 | 667 | ||
631 | 668 | ||
632 | //fprintf(stderr, "Input nbsamples %i out_samples: %i \n",input_frame->nb_samples,out_samples); | 669 | // fprintf(stderr, "Input nbsamples %i out_samples: %i \n",input_frame->nb_samples,out_samples); |
633 | 670 | ||
634 | /** Initialize the temporary storage for the converted input samples. */ | 671 | /** Initialize the temporary storage for the converted input samples. */ |
635 | if (init_converted_samples(&converted_input_samples, &out_linesize, output_codec_context, | 672 | if (init_converted_samples (&converted_input_samples, &out_linesize, |
636 | out_samples)){ | 673 | output_codec_context, |
674 | out_samples)) | ||
675 | { | ||
637 | #if DEBUG | 676 | #if DEBUG |
638 | fprintf(stderr, "Failed at init_converted_samples\n"); | 677 | fprintf (stderr, "Failed at init_converted_samples\n"); |
639 | #endif | 678 | #endif |
640 | goto cleanup; | 679 | goto cleanup; |
641 | } | 680 | } |
642 | 681 | ||
643 | /** | 682 | /** |
644 | * Convert the input samples to the desired output sample format. | 683 | * Convert the input samples to the desired output sample format. |
645 | * This requires a temporary storage provided by converted_input_samples. | 684 | * This requires a temporary storage provided by converted_input_samples. |
646 | */ | 685 | */ |
647 | if (convert_samples(input_frame->extended_data, converted_input_samples, | 686 | if (convert_samples (input_frame->extended_data, converted_input_samples, |
648 | input_frame->nb_samples, out_samples, out_linesize ,resampler_context)){ | 687 | input_frame->nb_samples, out_samples, out_linesize, |
688 | resampler_context)) | ||
689 | { | ||
649 | 690 | ||
650 | 691 | ||
651 | #if DEBUG | 692 | #if DEBUG |
652 | fprintf(stderr, "Failed at convert_samples, input frame %i \n",input_frame->nb_samples); | 693 | fprintf (stderr, "Failed at convert_samples, input frame %i \n", |
694 | input_frame->nb_samples); | ||
653 | #endif | 695 | #endif |
654 | goto cleanup; | 696 | goto cleanup; |
655 | } | 697 | } |
656 | /** Add the converted input samples to the FIFO buffer for later processing. */ | 698 | /** Add the converted input samples to the FIFO buffer for later processing. */ |
657 | if (add_samples_to_fifo(fifo, converted_input_samples, | 699 | if (add_samples_to_fifo (fifo, converted_input_samples, |
658 | out_samples)){ | 700 | out_samples)) |
701 | { | ||
659 | #if DEBUG | 702 | #if DEBUG |
660 | fprintf(stderr, "Failed at add_samples_to_fifo\n"); | 703 | fprintf (stderr, "Failed at add_samples_to_fifo\n"); |
661 | #endif | 704 | #endif |
662 | goto cleanup; | 705 | goto cleanup; |
663 | } | ||
664 | ret = 0; | ||
665 | } | 706 | } |
666 | ret = 0; | 707 | ret = 0; |
708 | } | ||
709 | ret = 0; | ||
667 | 710 | ||
668 | cleanup: | 711 | cleanup: |
669 | if (converted_input_samples) { | 712 | if (converted_input_samples) |
670 | av_freep(&converted_input_samples[0]); | 713 | { |
671 | free(converted_input_samples); | 714 | av_freep (&converted_input_samples[0]); |
672 | } | 715 | free (converted_input_samples); |
673 | #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1) | 716 | } |
674 | av_frame_free (&input_frame); | 717 | #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1) |
718 | av_frame_free (&input_frame); | ||
675 | #else | 719 | #else |
676 | avcodec_free_frame(&input_frame); | 720 | avcodec_free_frame (&input_frame); |
677 | #endif | 721 | #endif |
678 | 722 | ||
679 | return ret; | 723 | return ret; |
680 | } | 724 | } |
681 | 725 | ||
726 | |||
682 | /** | 727 | /** |
683 | * Initialize one input frame for writing to the output file. | 728 | * Initialize one input frame for writing to the output file. |
684 | * The frame will be exactly frame_size samples large. | 729 | * The frame will be exactly frame_size samples large. |
685 | */ | 730 | */ |
686 | static int init_output_frame(AVFrame **frame, | 731 | static int |
687 | AVCodecContext *output_codec_context, | 732 | init_output_frame (AVFrame **frame, |
688 | int frame_size) | 733 | AVCodecContext *output_codec_context, |
734 | int frame_size) | ||
689 | { | 735 | { |
690 | int error; | 736 | int error; |
691 | 737 | ||
692 | /** Create a new frame to store the audio samples. */ | 738 | /** Create a new frame to store the audio samples. */ |
693 | #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1) | 739 | #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1) |
694 | *frame = av_frame_alloc (); | 740 | *frame = av_frame_alloc (); |
695 | #else | 741 | #else |
696 | *frame = avcodec_alloc_frame(); | 742 | *frame = avcodec_alloc_frame (); |
697 | #endif | 743 | #endif |
698 | if (NULL == *frame) { | 744 | if (NULL == *frame) |
745 | { | ||
699 | #if DEBUG | 746 | #if DEBUG |
700 | fprintf(stderr, "Could not allocate output frame\n"); | 747 | fprintf (stderr, "Could not allocate output frame\n"); |
701 | #endif | 748 | #endif |
702 | return AVERROR_EXIT; | 749 | return AVERROR_EXIT; |
703 | } | 750 | } |
704 | |||
705 | /** | ||
706 | * Set the frame's parameters, especially its size and format. | ||
707 | * av_frame_get_buffer needs this to allocate memory for the | ||
708 | * audio samples of the frame. | ||
709 | * Default channel layouts based on the number of channels | ||
710 | * are assumed for simplicity. | ||
711 | */ | ||
712 | (*frame)->nb_samples = frame_size; | ||
713 | (*frame)->channel_layout = output_codec_context->channel_layout; | ||
714 | (*frame)->format = output_codec_context->sample_fmt; | ||
715 | (*frame)->sample_rate = output_codec_context->sample_rate; | ||
716 | 751 | ||
752 | /** | ||
753 | * Set the frame's parameters, especially its size and format. | ||
754 | * av_frame_get_buffer needs this to allocate memory for the | ||
755 | * audio samples of the frame. | ||
756 | * Default channel layouts based on the number of channels | ||
757 | * are assumed for simplicity. | ||
758 | */(*frame)->nb_samples = frame_size; | ||
759 | (*frame)->channel_layout = output_codec_context->channel_layout; | ||
760 | (*frame)->format = output_codec_context->sample_fmt; | ||
761 | (*frame)->sample_rate = output_codec_context->sample_rate; | ||
717 | 762 | ||
718 | 763 | ||
719 | //fprintf(stderr, "%i %i \n",frame_size , (*frame)->format,(*frame)->sample_rate); | 764 | // fprintf(stderr, "%i %i \n",frame_size , (*frame)->format,(*frame)->sample_rate); |
720 | 765 | ||
721 | /** | 766 | /** |
722 | * Allocate the samples of the created frame. This call will make | 767 | * Allocate the samples of the created frame. This call will make |
723 | * sure that the audio frame can hold as many samples as specified. | 768 | * sure that the audio frame can hold as many samples as specified. |
724 | */ | 769 | */ |
725 | if ((error = av_frame_get_buffer(*frame, 0)) < 0) { | 770 | if ((error = av_frame_get_buffer (*frame, 0)) < 0) |
771 | { | ||
726 | #if DEBUG | 772 | #if DEBUG |
727 | fprintf(stderr, "Could allocate output frame samples (error '%s')\n", get_error_text(error)); | 773 | fprintf (stderr, "Could allocate output frame samples (error '%s')\n", |
774 | get_error_text (error)); | ||
728 | #endif | 775 | #endif |
729 | #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1) | 776 | #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1) |
730 | av_frame_free (frame); | 777 | av_frame_free (frame); |
731 | #else | 778 | #else |
732 | avcodec_free_frame(frame); | 779 | avcodec_free_frame (frame); |
733 | #endif | 780 | #endif |
734 | return error; | 781 | return error; |
735 | } | 782 | } |
736 | 783 | ||
737 | return 0; | 784 | return 0; |
738 | } | 785 | } |
739 | 786 | ||
787 | |||
740 | /** Encode one frame worth of audio to the output file. */ | 788 | /** Encode one frame worth of audio to the output file. */ |
741 | static int encode_audio_frame(AVFrame *frame, | 789 | static int |
742 | AVFormatContext *output_format_context, | 790 | encode_audio_frame (AVFrame *frame, |
743 | AVCodecContext *output_codec_context, | 791 | AVFormatContext *output_format_context, |
744 | int *data_present) | 792 | AVCodecContext *output_codec_context, |
793 | int *data_present) | ||
745 | { | 794 | { |
746 | /** Packet used for temporary storage. */ | 795 | /** Packet used for temporary storage. */ |
747 | AVPacket output_packet; | 796 | AVPacket output_packet; |
748 | int error; | 797 | int error; |
749 | init_packet(&output_packet); | 798 | init_packet (&output_packet); |
750 | 799 | ||
751 | /** | 800 | /** |
752 | * Encode the audio frame and store it in the temporary packet. | 801 | * Encode the audio frame and store it in the temporary packet. |
753 | * The output audio stream encoder is used to do this. | 802 | * The output audio stream encoder is used to do this. |
754 | */ | 803 | */ |
755 | if ((error = avcodec_encode_audio2(output_codec_context, &output_packet, | 804 | if ((error = avcodec_encode_audio2 (output_codec_context, &output_packet, |
756 | frame, data_present)) < 0) { | 805 | frame, data_present)) < 0) |
806 | { | ||
757 | #if DEBUG | 807 | #if DEBUG |
758 | fprintf(stderr, "Could not encode frame (error '%s')\n", | 808 | fprintf (stderr, "Could not encode frame (error '%s')\n", |
759 | get_error_text(error)); | 809 | get_error_text (error)); |
760 | #endif | 810 | #endif |
761 | av_free_packet(&output_packet); | 811 | av_free_packet (&output_packet); |
762 | return error; | 812 | return error; |
763 | } | 813 | } |
764 | 814 | ||
765 | /** Write one audio frame from the temporary packet to the output file. */ | 815 | /** Write one audio frame from the temporary packet to the output file. */ |
766 | if (*data_present) { | 816 | if (*data_present) |
767 | if ((error = av_write_frame(output_format_context, &output_packet)) < 0) { | 817 | { |
818 | if ((error = av_write_frame (output_format_context, &output_packet)) < 0) | ||
819 | { | ||
768 | #if DEBUG | 820 | #if DEBUG |
769 | fprintf(stderr, "Could not write frame (error '%s')\n", | 821 | fprintf (stderr, "Could not write frame (error '%s')\n", |
770 | get_error_text(error)); | 822 | get_error_text (error)); |
771 | #endif | 823 | #endif |
772 | 824 | ||
773 | av_free_packet(&output_packet); | 825 | av_free_packet (&output_packet); |
774 | return error; | 826 | return error; |
775 | } | ||
776 | |||
777 | av_free_packet(&output_packet); | ||
778 | } | 827 | } |
779 | 828 | ||
780 | return 0; | 829 | av_free_packet (&output_packet); |
830 | } | ||
831 | |||
832 | return 0; | ||
781 | } | 833 | } |
782 | 834 | ||
835 | |||
783 | /** | 836 | /** |
784 | * Load one audio frame from the FIFO buffer, encode and write it to the | 837 | * Load one audio frame from the FIFO buffer, encode and write it to the |
785 | * output file. | 838 | * output file. |
786 | */ | 839 | */ |
787 | static int load_encode_and_write(AVAudioFifo *fifo, | 840 | static int |
788 | AVFormatContext *output_format_context, | 841 | load_encode_and_write (AVAudioFifo *fifo, |
789 | AVCodecContext *output_codec_context) | 842 | AVFormatContext *output_format_context, |
843 | AVCodecContext *output_codec_context) | ||
790 | { | 844 | { |
791 | /** Temporary storage of the output samples of the frame written to the file. */ | 845 | /** Temporary storage of the output samples of the frame written to the file. */ |
792 | AVFrame *output_frame; | 846 | AVFrame *output_frame; |
793 | /** | 847 | /** |
794 | * Use the maximum number of possible samples per frame. | 848 | * Use the maximum number of possible samples per frame. |
795 | * If there is less than the maximum possible frame size in the FIFO | 849 | * If there is less than the maximum possible frame size in the FIFO |
796 | * buffer use this number. Otherwise, use the maximum possible frame size | 850 | * buffer use this number. Otherwise, use the maximum possible frame size |
797 | */ | 851 | */const int frame_size = FFMIN (av_audio_fifo_size (fifo), |
798 | const int frame_size = FFMIN(av_audio_fifo_size(fifo), | 852 | output_codec_context->frame_size); |
799 | output_codec_context->frame_size); | 853 | int data_written; |
800 | int data_written; | 854 | |
801 | 855 | /** Initialize temporary storage for one output frame. */ | |
802 | /** Initialize temporary storage for one output frame. */ | 856 | if (init_output_frame (&output_frame, output_codec_context, frame_size)) |
803 | if (init_output_frame(&output_frame, output_codec_context, frame_size)) | 857 | return AVERROR_EXIT; |
804 | return AVERROR_EXIT; | ||
805 | 858 | ||
806 | /** | 859 | /** |
807 | * Read as many samples from the FIFO buffer as required to fill the frame. | 860 | * Read as many samples from the FIFO buffer as required to fill the frame. |
808 | * The samples are stored in the frame temporarily. | 861 | * The samples are stored in the frame temporarily. |
809 | */ | 862 | */ |
810 | if (av_audio_fifo_read(fifo, (void **)output_frame->data, frame_size) < frame_size) { | 863 | if (av_audio_fifo_read (fifo, (void **) output_frame->data, frame_size) < |
864 | frame_size) | ||
865 | { | ||
811 | #if DEBUG | 866 | #if DEBUG |
812 | fprintf(stderr, "Could not read data from FIFO\n"); | 867 | fprintf (stderr, "Could not read data from FIFO\n"); |
813 | #endif | 868 | #endif |
814 | #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1) | 869 | #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1) |
815 | av_frame_free (&output_frame); | 870 | av_frame_free (&output_frame); |
816 | #else | 871 | #else |
817 | avcodec_free_frame(&output_frame); | 872 | avcodec_free_frame (&output_frame); |
818 | #endif | 873 | #endif |
819 | return AVERROR_EXIT; | 874 | return AVERROR_EXIT; |
820 | } | 875 | } |
821 | 876 | ||
822 | /** Encode one frame worth of audio samples. */ | 877 | /** Encode one frame worth of audio samples. */ |
823 | if (encode_audio_frame(output_frame, output_format_context, | 878 | if (encode_audio_frame (output_frame, output_format_context, |
824 | output_codec_context, &data_written)) { | 879 | output_codec_context, &data_written)) |
825 | #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1) | 880 | { |
826 | av_frame_free (&output_frame); | 881 | #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1) |
882 | av_frame_free (&output_frame); | ||
827 | #else | 883 | #else |
828 | avcodec_free_frame(&output_frame); | 884 | avcodec_free_frame (&output_frame); |
829 | #endif | 885 | #endif |
830 | return AVERROR_EXIT; | 886 | return AVERROR_EXIT; |
831 | } | 887 | } |
832 | #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1) | 888 | #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1) |
833 | av_frame_free (&output_frame); | 889 | av_frame_free (&output_frame); |
834 | #else | 890 | #else |
835 | avcodec_free_frame(&output_frame); | 891 | avcodec_free_frame (&output_frame); |
836 | #endif | 892 | #endif |
837 | return 0; | 893 | return 0; |
838 | } | 894 | } |
895 | |||
896 | |||
839 | /** Write the trailer of the output file container. */ | 897 | /** Write the trailer of the output file container. */ |
840 | static int write_output_file_trailer(AVFormatContext *output_format_context) | 898 | static int |
899 | write_output_file_trailer (AVFormatContext *output_format_context) | ||
841 | { | 900 | { |
842 | int error; | 901 | int error; |
843 | if ((error = av_write_trailer(output_format_context)) < 0) { | 902 | if ((error = av_write_trailer (output_format_context)) < 0) |
903 | { | ||
844 | #if DEBUG | 904 | #if DEBUG |
845 | fprintf(stderr, "Could not write output file trailer (error '%s')\n", | 905 | fprintf (stderr, "Could not write output file trailer (error '%s')\n", |
846 | get_error_text(error)); | 906 | get_error_text (error)); |
847 | #endif | 907 | #endif |
848 | return error; | 908 | return error; |
849 | } | 909 | } |
850 | return 0; | 910 | return 0; |
851 | } | 911 | } |
852 | 912 | ||
913 | |||
853 | #define ENUM_CODEC_ID enum AVCodecID | 914 | #define ENUM_CODEC_ID enum AVCodecID |
854 | 915 | ||
855 | 916 | ||
@@ -868,7 +929,7 @@ extract_audio (struct EXTRACTOR_ExtractContext *ec) | |||
868 | AVCodec *codec; | 929 | AVCodec *codec; |
869 | AVDictionary *options; | 930 | AVDictionary *options; |
870 | AVFrame *frame; | 931 | AVFrame *frame; |
871 | AVCodecContext* output_codec_context = NULL; | 932 | AVCodecContext*output_codec_context = NULL; |
872 | AVAudioResampleContext *resample_context = NULL; | 933 | AVAudioResampleContext *resample_context = NULL; |
873 | AVAudioFifo *fifo = NULL; | 934 | AVAudioFifo *fifo = NULL; |
874 | 935 | ||
@@ -879,95 +940,95 @@ extract_audio (struct EXTRACTOR_ExtractContext *ec) | |||
879 | unsigned char *iob; | 940 | unsigned char *iob; |
880 | 941 | ||
881 | 942 | ||
882 | totalSize =0; | 943 | totalSize = 0; |
883 | if (NULL == (iob = av_malloc (16 * 1024))) | 944 | if (NULL == (iob = av_malloc (16 * 1024))) |
884 | return; | 945 | return; |
885 | if (NULL == (io_ctx = avio_alloc_context (iob, | 946 | if (NULL == (io_ctx = avio_alloc_context (iob, |
886 | 16 * 1024, | 947 | 16 * 1024, |
887 | 0, ec, | 948 | 0, ec, |
888 | &read_cb, | 949 | &read_cb, |
889 | NULL /* no writing */, | 950 | NULL /* no writing */, |
890 | &seek_cb))) | 951 | &seek_cb))) |
891 | { | 952 | { |
892 | av_free (iob); | 953 | av_free (iob); |
893 | return; | 954 | return; |
894 | } | 955 | } |
895 | if (NULL == (format_ctx = avformat_alloc_context ())) | 956 | if (NULL == (format_ctx = avformat_alloc_context ())) |
896 | { | 957 | { |
897 | av_free (io_ctx); | 958 | av_free (io_ctx); |
898 | return; | 959 | return; |
899 | } | 960 | } |
900 | format_ctx->pb = io_ctx; | 961 | format_ctx->pb = io_ctx; |
901 | options = NULL; | 962 | options = NULL; |
902 | if (0 != avformat_open_input (&format_ctx, "<no file>", NULL, &options)) | 963 | if (0 != avformat_open_input (&format_ctx, "<no file>", NULL, &options)) |
903 | { | 964 | { |
904 | av_free (io_ctx); | 965 | av_free (io_ctx); |
905 | return; | 966 | return; |
906 | } | 967 | } |
907 | av_dict_free (&options); | 968 | av_dict_free (&options); |
908 | if (0 > avformat_find_stream_info (format_ctx, NULL)) | 969 | if (0 > avformat_find_stream_info (format_ctx, NULL)) |
909 | { | 970 | { |
910 | #if DEBUG | 971 | #if DEBUG |
911 | fprintf (stderr, | 972 | fprintf (stderr, |
912 | "Failed to read stream info\n"); | 973 | "Failed to read stream info\n"); |
913 | #endif | 974 | #endif |
914 | avformat_close_input (&format_ctx); | 975 | avformat_close_input (&format_ctx); |
915 | av_free (io_ctx); | 976 | av_free (io_ctx); |
916 | return; | 977 | return; |
917 | } | 978 | } |
918 | codec = NULL; | 979 | codec = NULL; |
919 | codec_ctx = NULL; | 980 | codec_ctx = NULL; |
920 | audio_stream_index = -1; | 981 | audio_stream_index = -1; |
921 | for (i=0; i<format_ctx->nb_streams; i++) | 982 | for (i = 0; i<format_ctx->nb_streams; i++) |
983 | { | ||
984 | codec_ctx = format_ctx->streams[i]->codec; | ||
985 | if (AVMEDIA_TYPE_AUDIO != codec_ctx->codec_type) | ||
986 | continue; | ||
987 | if (NULL == (codec = avcodec_find_decoder (codec_ctx->codec_id))) | ||
988 | continue; | ||
989 | options = NULL; | ||
990 | if (0 != (err = avcodec_open2 (codec_ctx, codec, &options))) | ||
922 | { | 991 | { |
923 | codec_ctx = format_ctx->streams[i]->codec; | 992 | codec = NULL; |
924 | if (AVMEDIA_TYPE_AUDIO != codec_ctx->codec_type) | 993 | continue; |
925 | continue; | ||
926 | if (NULL == (codec = avcodec_find_decoder (codec_ctx->codec_id))) | ||
927 | continue; | ||
928 | options = NULL; | ||
929 | if (0 != (err = avcodec_open2 (codec_ctx, codec, &options))) | ||
930 | { | ||
931 | codec = NULL; | ||
932 | continue; | ||
933 | } | ||
934 | av_dict_free (&options); | ||
935 | audio_stream_index = i; | ||
936 | break; | ||
937 | } | 994 | } |
995 | av_dict_free (&options); | ||
996 | audio_stream_index = i; | ||
997 | break; | ||
998 | } | ||
938 | if ( (-1 == audio_stream_index) || | 999 | if ( (-1 == audio_stream_index) || |
939 | (0 == codec_ctx->channels) ) | 1000 | (0 == codec_ctx->channels) ) |
940 | { | 1001 | { |
941 | #if DEBUG | 1002 | #if DEBUG |
942 | fprintf (stderr, | 1003 | fprintf (stderr, |
943 | "No audio streams or no suitable codec found\n"); | 1004 | "No audio streams or no suitable codec found\n"); |
944 | #endif | 1005 | #endif |
945 | if (NULL != codec) | 1006 | if (NULL != codec) |
946 | avcodec_close (codec_ctx); | 1007 | avcodec_close (codec_ctx); |
947 | avformat_close_input (&format_ctx); | 1008 | avformat_close_input (&format_ctx); |
948 | av_free (io_ctx); | 1009 | av_free (io_ctx); |
949 | return; | 1010 | return; |
950 | } | 1011 | } |
951 | 1012 | ||
952 | #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1) | 1013 | #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1) |
953 | frame = av_frame_alloc (); | 1014 | frame = av_frame_alloc (); |
954 | #else | 1015 | #else |
955 | frame = avcodec_alloc_frame(); | 1016 | frame = avcodec_alloc_frame (); |
956 | #endif | 1017 | #endif |
957 | if (NULL == frame) | 1018 | if (NULL == frame) |
958 | { | 1019 | { |
959 | #if DEBUG | 1020 | #if DEBUG |
960 | fprintf (stderr, | 1021 | fprintf (stderr, |
961 | "Failed to allocate frame\n"); | 1022 | "Failed to allocate frame\n"); |
962 | #endif | 1023 | #endif |
963 | avcodec_close (codec_ctx); | 1024 | avcodec_close (codec_ctx); |
964 | avformat_close_input (&format_ctx); | 1025 | avformat_close_input (&format_ctx); |
965 | av_free (io_ctx); | 1026 | av_free (io_ctx); |
966 | return; | 1027 | return; |
967 | } | 1028 | } |
968 | 1029 | ||
969 | 1030 | ||
970 | if (! (buffer = malloc(HARD_LIMIT_SIZE))) | 1031 | if (! (buffer = malloc (HARD_LIMIT_SIZE))) |
971 | goto cleanup; | 1032 | goto cleanup; |
972 | 1033 | ||
973 | 1034 | ||
@@ -982,37 +1043,37 @@ extract_audio (struct EXTRACTOR_ExtractContext *ec) | |||
982 | &resample_context)) | 1043 | &resample_context)) |
983 | goto cleanup; | 1044 | goto cleanup; |
984 | /** Initialize the FIFO buffer to store audio samples to be encoded. */ | 1045 | /** Initialize the FIFO buffer to store audio samples to be encoded. */ |
985 | if (init_fifo(&fifo)) | 1046 | if (init_fifo (&fifo)) |
986 | goto cleanup; | 1047 | goto cleanup; |
987 | 1048 | ||
988 | /** Write the header of the output file container. */ | 1049 | /** Write the header of the output file container. */ |
989 | if (write_output_file_header(output_format_context)) | 1050 | if (write_output_file_header (output_format_context)) |
990 | goto cleanup; | 1051 | goto cleanup; |
991 | 1052 | ||
992 | 1053 | ||
993 | if (format_ctx->duration == AV_NOPTS_VALUE) | 1054 | if (format_ctx->duration == AV_NOPTS_VALUE) |
994 | { | 1055 | { |
995 | duration = -1; | 1056 | duration = -1; |
996 | #if DEBUG | 1057 | #if DEBUG |
997 | fprintf (stderr, | 1058 | fprintf (stderr, |
998 | "Duration unknown\n"); | 1059 | "Duration unknown\n"); |
999 | #endif | 1060 | #endif |
1000 | } | 1061 | } |
1001 | else | 1062 | else |
1002 | { | 1063 | { |
1003 | #if DEBUG | 1064 | #if DEBUG |
1004 | duration = format_ctx->duration; | 1065 | duration = format_ctx->duration; |
1005 | fprintf (stderr, | 1066 | fprintf (stderr, |
1006 | "Duration: %lld\n", | 1067 | "Duration: %lld\n", |
1007 | format_ctx->duration); | 1068 | format_ctx->duration); |
1008 | #endif | 1069 | #endif |
1009 | } | 1070 | } |
1010 | 1071 | ||
1011 | /* if duration is known, seek to first tried, | 1072 | /* if duration is known, seek to first tried, |
1012 | * else use 10 sec into stream */ | 1073 | * else use 10 sec into stream */ |
1013 | 1074 | ||
1014 | if(-1 != duration) | 1075 | if (-1 != duration) |
1015 | err = av_seek_frame (format_ctx, -1, (duration/3), 0); | 1076 | err = av_seek_frame (format_ctx, -1, (duration / 3), 0); |
1016 | else | 1077 | else |
1017 | err = av_seek_frame (format_ctx, -1, 10 * AV_TIME_BASE, 0); | 1078 | err = av_seek_frame (format_ctx, -1, 10 * AV_TIME_BASE, 0); |
1018 | 1079 | ||
@@ -1026,86 +1087,82 @@ extract_audio (struct EXTRACTOR_ExtractContext *ec) | |||
1026 | * to write; abort as soon as we have neither. | 1087 | * to write; abort as soon as we have neither. |
1027 | */ | 1088 | */ |
1028 | while (1) | 1089 | while (1) |
1029 | { | 1090 | { |
1030 | /** Use the encoder's desired frame size for processing. */ | 1091 | /** Use the encoder's desired frame size for processing. */ |
1031 | const int output_frame_size = output_codec_context->frame_size; | 1092 | const int output_frame_size = output_codec_context->frame_size; |
1032 | int finished = 0; | 1093 | int finished = 0; |
1033 | 1094 | ||
1095 | /** | ||
1096 | * Make sure that there is one frame worth of samples in the FIFO | ||
1097 | * buffer so that the encoder can do its work. | ||
1098 | * Since the decoder's and the encoder's frame size may differ, we | ||
1099 | * need to FIFO buffer to store as many frames worth of input samples | ||
1100 | * that they make up at least one frame worth of output samples. | ||
1101 | */while ((av_audio_fifo_size (fifo) < output_frame_size)) | ||
1102 | { | ||
1034 | /** | 1103 | /** |
1035 | * Make sure that there is one frame worth of samples in the FIFO | 1104 | * Decode one frame worth of audio samples, convert it to the |
1036 | * buffer so that the encoder can do its work. | 1105 | * output sample format and put it into the FIFO buffer. |
1037 | * Since the decoder's and the encoder's frame size may differ, we | ||
1038 | * need to FIFO buffer to store as many frames worth of input samples | ||
1039 | * that they make up at least one frame worth of output samples. | ||
1040 | */ | 1106 | */ |
1041 | 1107 | if (read_decode_convert_and_store (fifo, | |
1042 | while ((av_audio_fifo_size(fifo) < output_frame_size)) | 1108 | format_ctx, |
1043 | { | 1109 | codec_ctx, |
1044 | /** | 1110 | output_codec_context, |
1045 | * Decode one frame worth of audio samples, convert it to the | 1111 | resample_context, |
1046 | * output sample format and put it into the FIFO buffer. | 1112 | audio_stream_index, |
1047 | */ | 1113 | &finished)) |
1048 | if (read_decode_convert_and_store (fifo, | 1114 | { |
1049 | format_ctx, | 1115 | goto cleanup; |
1050 | codec_ctx, | 1116 | } |
1051 | output_codec_context, | ||
1052 | resample_context, | ||
1053 | audio_stream_index, | ||
1054 | &finished)) | ||
1055 | { | ||
1056 | goto cleanup; | ||
1057 | } | ||
1058 | |||
1059 | /** | ||
1060 | * If we are at the end of the input file, we continue | ||
1061 | * encoding the remaining audio samples to the output file. | ||
1062 | */ | ||
1063 | if (finished) | ||
1064 | break; | ||
1065 | } | ||
1066 | |||
1067 | /* Already over our limit*/ | ||
1068 | if (totalSize >= MAX_SIZE) | ||
1069 | finished = 1; | ||
1070 | 1117 | ||
1071 | /** | 1118 | /** |
1072 | * If we have enough samples for the encoder, we encode them. | 1119 | * If we are at the end of the input file, we continue |
1073 | * At the end of the file, we pass the remaining samples to | 1120 | * encoding the remaining audio samples to the output file. |
1074 | * the encoder. | ||
1075 | */ | 1121 | */ |
1122 | if (finished) | ||
1123 | break; | ||
1124 | } | ||
1076 | 1125 | ||
1077 | while (av_audio_fifo_size(fifo) >= output_frame_size || | 1126 | /* Already over our limit*/ |
1078 | (finished && av_audio_fifo_size(fifo) > 0)) | 1127 | if (totalSize >= MAX_SIZE) |
1079 | { | 1128 | finished = 1; |
1080 | /** | 1129 | |
1081 | * Take one frame worth of audio samples from the FIFO buffer, | 1130 | /** |
1082 | * encode it and write it to the output file. | 1131 | * If we have enough samples for the encoder, we encode them. |
1083 | */ | 1132 | * At the end of the file, we pass the remaining samples to |
1084 | if (load_encode_and_write (fifo, | 1133 | * the encoder. |
1085 | output_format_context, | 1134 | */while (av_audio_fifo_size (fifo) >= output_frame_size || |
1086 | output_codec_context)) | 1135 | (finished && av_audio_fifo_size (fifo) > 0)) |
1087 | goto cleanup; | 1136 | { |
1088 | } | ||
1089 | /** | 1137 | /** |
1090 | * If we are at the end of the input file and have encoded | 1138 | * Take one frame worth of audio samples from the FIFO buffer, |
1091 | * all remaining samples, we can exit this loop and finish. | 1139 | * encode it and write it to the output file. |
1092 | */ | 1140 | */ |
1093 | if (finished) | 1141 | if (load_encode_and_write (fifo, |
1094 | { | 1142 | output_format_context, |
1095 | int data_written; | 1143 | output_codec_context)) |
1096 | /** Flush the encoder as it may have delayed frames. */ | 1144 | goto cleanup; |
1097 | do { | 1145 | } |
1098 | encode_audio_frame (NULL, | 1146 | /** |
1099 | output_format_context, | 1147 | * If we are at the end of the input file and have encoded |
1100 | output_codec_context, | 1148 | * all remaining samples, we can exit this loop and finish. |
1101 | &data_written); | 1149 | */ |
1102 | } while (data_written); | 1150 | if (finished) |
1103 | break; | 1151 | { |
1104 | } | 1152 | int data_written; |
1153 | /** Flush the encoder as it may have delayed frames. */ | ||
1154 | do { | ||
1155 | encode_audio_frame (NULL, | ||
1156 | output_format_context, | ||
1157 | output_codec_context, | ||
1158 | &data_written); | ||
1159 | } while (data_written); | ||
1160 | break; | ||
1105 | } | 1161 | } |
1162 | } | ||
1106 | 1163 | ||
1107 | /** Write the trailer of the output file container. */ | 1164 | /** Write the trailer of the output file container. */ |
1108 | if (write_output_file_trailer(output_format_context)) | 1165 | if (write_output_file_trailer (output_format_context)) |
1109 | goto cleanup; | 1166 | goto cleanup; |
1110 | ec->proc (ec->cls, | 1167 | ec->proc (ec->cls, |
1111 | "previewopus", | 1168 | "previewopus", |
@@ -1120,34 +1177,34 @@ extract_audio (struct EXTRACTOR_ExtractContext *ec) | |||
1120 | FILE *f; | 1177 | FILE *f; |
1121 | 1178 | ||
1122 | f = fopen ("example.opus", "wb"); | 1179 | f = fopen ("example.opus", "wb"); |
1123 | if (!f) | 1180 | if (! f) |
1124 | { | 1181 | { |
1125 | fprintf (stderr, "Could not open %s\n", "file"); | 1182 | fprintf (stderr, "Could not open %s\n", "file"); |
1126 | exit(1); | 1183 | exit (1); |
1127 | } | 1184 | } |
1128 | fwrite (buffer, 1, totalSize, f); | 1185 | fwrite (buffer, 1, totalSize, f); |
1129 | fclose(f); | 1186 | fclose (f); |
1130 | } | 1187 | } |
1131 | #endif | 1188 | #endif |
1132 | 1189 | ||
1133 | cleanup: | 1190 | cleanup: |
1134 | av_free (frame); | 1191 | av_free (frame); |
1135 | free (buffer); | 1192 | free (buffer); |
1136 | 1193 | ||
1137 | if (fifo) | 1194 | if (fifo) |
1138 | av_audio_fifo_free(fifo); | 1195 | av_audio_fifo_free (fifo); |
1139 | if (resample_context) | 1196 | if (resample_context) |
1140 | { | 1197 | { |
1141 | avresample_close(resample_context); | 1198 | avresample_close (resample_context); |
1142 | avresample_free(&resample_context); | 1199 | avresample_free (&resample_context); |
1143 | } | 1200 | } |
1144 | if (output_codec_context) | 1201 | if (output_codec_context) |
1145 | avcodec_close(output_codec_context); | 1202 | avcodec_close (output_codec_context); |
1146 | 1203 | ||
1147 | if (codec_ctx) | 1204 | if (codec_ctx) |
1148 | avcodec_close(codec_ctx); | 1205 | avcodec_close (codec_ctx); |
1149 | if (format_ctx) | 1206 | if (format_ctx) |
1150 | avformat_close_input(&format_ctx); | 1207 | avformat_close_input (&format_ctx); |
1151 | av_free (io_ctx); | 1208 | av_free (io_ctx); |
1152 | } | 1209 | } |
1153 | 1210 | ||
@@ -1165,8 +1222,8 @@ EXTRACTOR_previewopus_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
1165 | 1222 | ||
1166 | 1223 | ||
1167 | if (-1 == (iret = ec->read (ec->cls, | 1224 | if (-1 == (iret = ec->read (ec->cls, |
1168 | &data, | 1225 | &data, |
1169 | 16 * 1024))) | 1226 | 16 * 1024))) |
1170 | return; | 1227 | return; |
1171 | 1228 | ||
1172 | if (0 != ec->seek (ec->cls, 0, SEEK_SET)) | 1229 | if (0 != ec->seek (ec->cls, 0, SEEK_SET)) |
@@ -1185,13 +1242,13 @@ EXTRACTOR_previewopus_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
1185 | * @param ap arguments for format | 1242 | * @param ap arguments for format |
1186 | */ | 1243 | */ |
1187 | static void | 1244 | static void |
1188 | previewopus_av_log_callback (void* ptr, | 1245 | previewopus_av_log_callback (void*ptr, |
1189 | int level, | 1246 | int level, |
1190 | const char *format, | 1247 | const char *format, |
1191 | va_list ap) | 1248 | va_list ap) |
1192 | { | 1249 | { |
1193 | #if DEBUG | 1250 | #if DEBUG |
1194 | vfprintf(stderr, format, ap); | 1251 | vfprintf (stderr, format, ap); |
1195 | #endif | 1252 | #endif |
1196 | } | 1253 | } |
1197 | 1254 | ||
diff --git a/src/plugins/ps_extractor.c b/src/plugins/ps_extractor.c index 3a7f26d..7b61410 100644 --- a/src/plugins/ps_extractor.c +++ b/src/plugins/ps_extractor.c | |||
@@ -137,81 +137,82 @@ EXTRACTOR_ps_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
137 | return; | 137 | return; |
138 | if ( (strlen (line) < strlen (PS_HEADER)) || | 138 | if ( (strlen (line) < strlen (PS_HEADER)) || |
139 | (0 != memcmp (PS_HEADER, | 139 | (0 != memcmp (PS_HEADER, |
140 | line, | 140 | line, |
141 | strlen (PS_HEADER))) ) | 141 | strlen (PS_HEADER))) ) |
142 | { | 142 | { |
143 | free (line); | 143 | free (line); |
144 | return; | 144 | return; |
145 | } | 145 | } |
146 | free (line); | 146 | free (line); |
147 | if (0 != ec->proc (ec->cls, | 147 | if (0 != ec->proc (ec->cls, |
148 | "ps", | 148 | "ps", |
149 | EXTRACTOR_METATYPE_MIMETYPE, | 149 | EXTRACTOR_METATYPE_MIMETYPE, |
150 | EXTRACTOR_METAFORMAT_UTF8, | 150 | EXTRACTOR_METAFORMAT_UTF8, |
151 | "text/plain", | 151 | "text/plain", |
152 | "application/postscript", | 152 | "application/postscript", |
153 | strlen ("application/postscript") + 1)) | 153 | strlen ("application/postscript") + 1)) |
154 | return; | 154 | return; |
155 | 155 | ||
156 | line = NULL; | 156 | line = NULL; |
157 | next = readline (ec); | 157 | next = readline (ec); |
158 | while ( (NULL != next) && | 158 | while ( (NULL != next) && |
159 | ('%' == next[0]) ) | 159 | ('%' == next[0]) ) |
160 | { | ||
161 | line = next; | ||
162 | next = readline (ec); | ||
163 | for (i = 0; NULL != tests[i].prefix; i++) | ||
160 | { | 164 | { |
161 | line = next; | 165 | match = tests[i].prefix; |
162 | next = readline (ec); | 166 | if ( (strlen (line) < strlen (match)) || |
163 | for (i = 0; NULL != tests[i].prefix; i++) | 167 | (0 != strncmp (line, match, strlen (match))) ) |
164 | { | 168 | continue; |
165 | match = tests[i].prefix; | 169 | /* %%+ continues previous meta-data type... */ |
166 | if ( (strlen (line) < strlen (match)) || | 170 | while ( (NULL != next) && |
167 | (0 != strncmp (line, match, strlen (match))) ) | 171 | (0 == strncmp (next, "%%+", strlen ("%%+"))) ) |
168 | continue; | 172 | { |
169 | /* %%+ continues previous meta-data type... */ | 173 | if (NULL == (acc = malloc (strlen (line) + strlen (next) - 1))) |
170 | while ( (NULL != next) && | 174 | break; |
171 | (0 == strncmp (next, "%%+", strlen ("%%+"))) ) | 175 | strcpy (acc, line); |
172 | { | 176 | strcat (acc, " "); |
173 | if (NULL == (acc = malloc (strlen (line) + strlen (next) - 1))) | 177 | strcat (acc, next + 3); |
174 | break; | 178 | free (line); |
175 | strcpy (acc, line); | 179 | line = acc; |
176 | strcat (acc, " "); | 180 | free (next); |
177 | strcat (acc, next + 3); | 181 | next = readline (ec); |
178 | free (line); | 182 | } |
179 | line = acc; | 183 | if ( (line[strlen (line) - 1] == ')') && |
180 | free (next); | 184 | (line[strlen (match)] == '(') ) |
181 | next = readline (ec); | 185 | { |
182 | } | 186 | acc = &line[strlen (match) + 1]; |
183 | if ( (line[strlen (line) - 1] == ')') && | 187 | acc[strlen (acc) - 1] = '\0'; /* remove ")" */ |
184 | (line[strlen (match)] == '(') ) | 188 | } |
185 | { | 189 | else |
186 | acc = &line[strlen (match) + 1]; | 190 | { |
187 | acc[strlen (acc) - 1] = '\0'; /* remove ")" */ | 191 | acc = &line[strlen (match)]; |
188 | } | 192 | } |
189 | else | 193 | while (isspace ((unsigned char) acc[0])) |
190 | { | 194 | acc++; |
191 | acc = &line[strlen (match)]; | 195 | if ( (strlen (acc) > 0) && |
192 | } | 196 | (0 != ec->proc (ec->cls, |
193 | while (isspace ((unsigned char) acc[0])) | 197 | "ps", |
194 | acc++; | 198 | tests[i].type, |
195 | if ( (strlen (acc) > 0) && | 199 | EXTRACTOR_METAFORMAT_UTF8, |
196 | (0 != ec->proc (ec->cls, | 200 | "text/plain", |
197 | "ps", | 201 | acc, |
198 | tests[i].type, | 202 | strlen (acc) + 1)) ) |
199 | EXTRACTOR_METAFORMAT_UTF8, | 203 | { |
200 | "text/plain", | 204 | free (line); |
201 | acc, | 205 | if (NULL != next) |
202 | strlen (acc) + 1)) ) | 206 | free (next); |
203 | { | 207 | return; |
204 | free (line); | 208 | } |
205 | if (NULL != next) | 209 | break; |
206 | free (next); | ||
207 | return; | ||
208 | } | ||
209 | break; | ||
210 | } | ||
211 | free (line); | ||
212 | } | 210 | } |
211 | free (line); | ||
212 | } | ||
213 | if (NULL != next) | 213 | if (NULL != next) |
214 | free (next); | 214 | free (next); |
215 | } | 215 | } |
216 | 216 | ||
217 | |||
217 | /* end of ps_extractor.c */ | 218 | /* end of ps_extractor.c */ |
diff --git a/src/plugins/riff_extractor.c b/src/plugins/riff_extractor.c index 9ff700a..c030617 100644 --- a/src/plugins/riff_extractor.c +++ b/src/plugins/riff_extractor.c | |||
@@ -76,15 +76,19 @@ round_double (double num) | |||
76 | * @param s 0-terminated UTF8 string value with the meta data | 76 | * @param s 0-terminated UTF8 string value with the meta data |
77 | * @param t libextractor type for the meta data | 77 | * @param t libextractor type for the meta data |
78 | */ | 78 | */ |
79 | #define ADD(s,t) do { if (0 != ec->proc (ec->cls, "riff", t, EXTRACTOR_METAFORMAT_UTF8, "text/plain", s, strlen (s) + 1)) return; } while (0) | 79 | #define ADD(s,t) do { if (0 != ec->proc (ec->cls, "riff", t, \ |
80 | EXTRACTOR_METAFORMAT_UTF8, \ | ||
81 | "text/plain", s, strlen (s) \ | ||
82 | + 1)) return; \ | ||
83 | } while (0) | ||
80 | 84 | ||
81 | 85 | ||
82 | /** | 86 | /** |
83 | * Main entry method for the 'video/x-msvideo' extraction plugin. | 87 | * Main entry method for the 'video/x-msvideo' extraction plugin. |
84 | * | 88 | * |
85 | * @param ec extraction context provided to the plugin | 89 | * @param ec extraction context provided to the plugin |
86 | */ | 90 | */ |
87 | void | 91 | void |
88 | EXTRACTOR_riff_extract_method (struct EXTRACTOR_ExtractContext *ec) | 92 | EXTRACTOR_riff_extract_method (struct EXTRACTOR_ExtractContext *ec) |
89 | { | 93 | { |
90 | ssize_t xsize; | 94 | ssize_t xsize; |
@@ -98,22 +102,22 @@ EXTRACTOR_riff_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
98 | uint32_t height; | 102 | uint32_t height; |
99 | char codec[5]; | 103 | char codec[5]; |
100 | char format[256]; | 104 | char format[256]; |
101 | 105 | ||
102 | /* read header */ | 106 | /* read header */ |
103 | if (72 > (xsize = ec->read (ec->cls, &data, 72))) | 107 | if (72 > (xsize = ec->read (ec->cls, &data, 72))) |
104 | return; | 108 | return; |
105 | xdata = data; | 109 | xdata = data; |
106 | 110 | ||
107 | /* check magic values */ | 111 | /* check magic values */ |
108 | if ( (0 != memcmp (&xdata[0], | 112 | if ( (0 != memcmp (&xdata[0], |
109 | "RIFF", 4)) || | 113 | "RIFF", 4)) || |
110 | (0 != memcmp (&xdata[8], "AVI ", 4)) || | 114 | (0 != memcmp (&xdata[8], "AVI ", 4)) || |
111 | (0 != memcmp (&xdata[12], "LIST", 4)) || | 115 | (0 != memcmp (&xdata[12], "LIST", 4)) || |
112 | (0 != memcmp (&xdata[20], "hdrlavih", 8)) ) | 116 | (0 != memcmp (&xdata[20], "hdrlavih", 8)) ) |
113 | return; | 117 | return; |
114 | 118 | ||
115 | blockLen = fread_le (&xdata[28]); | 119 | blockLen = fread_le (&xdata[28]); |
116 | 120 | ||
117 | /* begin of AVI header at 32 */ | 121 | /* begin of AVI header at 32 */ |
118 | fps = (unsigned int) round_double ((double) 1.0e6 / fread_le (&xdata[32])); | 122 | fps = (unsigned int) round_double ((double) 1.0e6 / fread_le (&xdata[32])); |
119 | duration = (unsigned int) round_double ((double) fread_le (&xdata[48]) | 123 | duration = (unsigned int) round_double ((double) fread_le (&xdata[48]) |
@@ -126,7 +130,7 @@ EXTRACTOR_riff_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
126 | 130 | ||
127 | if (pos != | 131 | if (pos != |
128 | ec->seek (ec->cls, pos, SEEK_SET)) | 132 | ec->seek (ec->cls, pos, SEEK_SET)) |
129 | return; | 133 | return; |
130 | if (32 > ec->read (ec->cls, &data, 32)) | 134 | if (32 > ec->read (ec->cls, &data, 32)) |
131 | return; | 135 | return; |
132 | xdata = data; | 136 | xdata = data; |
@@ -141,17 +145,18 @@ EXTRACTOR_riff_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
141 | memcpy (codec, &xdata[24], 4); | 145 | memcpy (codec, &xdata[24], 4); |
142 | codec[4] = '\0'; | 146 | codec[4] = '\0'; |
143 | snprintf (format, | 147 | snprintf (format, |
144 | sizeof (format), | 148 | sizeof (format), |
145 | _("codec: %s, %u fps, %u ms"), | 149 | _ ("codec: %s, %u fps, %u ms"), |
146 | codec, fps, duration); | 150 | codec, fps, duration); |
147 | ADD (format, EXTRACTOR_METATYPE_FORMAT); | 151 | ADD (format, EXTRACTOR_METATYPE_FORMAT); |
148 | snprintf (format, | 152 | snprintf (format, |
149 | sizeof (format), | 153 | sizeof (format), |
150 | "%ux%u", | 154 | "%ux%u", |
151 | (unsigned int) width, | 155 | (unsigned int) width, |
152 | (unsigned int) height); | 156 | (unsigned int) height); |
153 | ADD (format, EXTRACTOR_METATYPE_IMAGE_DIMENSIONS); | 157 | ADD (format, EXTRACTOR_METATYPE_IMAGE_DIMENSIONS); |
154 | ADD ("video/x-msvideo", EXTRACTOR_METATYPE_MIMETYPE); | 158 | ADD ("video/x-msvideo", EXTRACTOR_METATYPE_MIMETYPE); |
155 | } | 159 | } |
156 | 160 | ||
161 | |||
157 | /* end of riff_extractor.c */ | 162 | /* end of riff_extractor.c */ |
diff --git a/src/plugins/rpm_extractor.c b/src/plugins/rpm_extractor.c index 21596d2..90c5892 100644 --- a/src/plugins/rpm_extractor.c +++ b/src/plugins/rpm_extractor.c | |||
@@ -79,7 +79,7 @@ struct PipeArgs | |||
79 | * @return NULL | 79 | * @return NULL |
80 | */ | 80 | */ |
81 | static void * | 81 | static void * |
82 | pipe_feeder (void * args) | 82 | pipe_feeder (void *args) |
83 | { | 83 | { |
84 | struct PipeArgs *p = args; | 84 | struct PipeArgs *p = args; |
85 | ssize_t rret; | 85 | ssize_t rret; |
@@ -91,34 +91,34 @@ pipe_feeder (void * args) | |||
91 | /* buffer is heap-allocated as this is a thread and | 91 | /* buffer is heap-allocated as this is a thread and |
92 | large stack allocations might not be the best idea */ | 92 | large stack allocations might not be the best idea */ |
93 | while (0 == p->shutdown) | 93 | while (0 == p->shutdown) |
94 | { | ||
95 | pthread_mutex_lock (&p->lock); | ||
96 | if (-1 == (rret = p->ec->read (p->ec->cls, &ptr, BUF_SIZE))) | ||
94 | { | 97 | { |
95 | pthread_mutex_lock (&p->lock); | ||
96 | if (-1 == (rret = p->ec->read (p->ec->cls, &ptr, BUF_SIZE))) | ||
97 | { | ||
98 | pthread_mutex_unlock (&p->lock); | ||
99 | break; | ||
100 | } | ||
101 | pthread_mutex_unlock (&p->lock); | 98 | pthread_mutex_unlock (&p->lock); |
102 | if (0 == rret) | 99 | break; |
103 | break; | 100 | } |
104 | buf = ptr; | 101 | pthread_mutex_unlock (&p->lock); |
105 | done = 0; | 102 | if (0 == rret) |
106 | while ( (0 == p->shutdown) && | 103 | break; |
107 | (done < rret) ) | 104 | buf = ptr; |
108 | { | 105 | done = 0; |
109 | if (-1 == (wret = WRITE (p->pi[1], | 106 | while ( (0 == p->shutdown) && |
110 | &buf[done], | 107 | (done < rret) ) |
111 | rret - done))) | 108 | { |
112 | { | 109 | if (-1 == (wret = WRITE (p->pi[1], |
113 | break; | 110 | &buf[done], |
114 | } | 111 | rret - done))) |
115 | if (0 == wret) | 112 | { |
116 | break; | 113 | break; |
117 | done += wret; | 114 | } |
118 | } | 115 | if (0 == wret) |
119 | if (done != rret) | 116 | break; |
120 | break; | 117 | done += wret; |
121 | } | 118 | } |
119 | if (done != rret) | ||
120 | break; | ||
121 | } | ||
122 | CLOSE (p->pi[1]); | 122 | CLOSE (p->pi[1]); |
123 | return NULL; | 123 | return NULL; |
124 | } | 124 | } |
@@ -130,7 +130,7 @@ pipe_feeder (void * args) | |||
130 | */ | 130 | */ |
131 | static int | 131 | static int |
132 | discard_log_callback (rpmlogRec rec, | 132 | discard_log_callback (rpmlogRec rec, |
133 | void *ctx) | 133 | void *ctx) |
134 | { | 134 | { |
135 | /* do nothing! */ | 135 | /* do nothing! */ |
136 | return 0; | 136 | return 0; |
@@ -190,52 +190,52 @@ static struct Matches tests[] = { | |||
190 | 190 | ||
191 | #if 0 | 191 | #if 0 |
192 | /* FIXME: add support for some of these */ | 192 | /* FIXME: add support for some of these */ |
193 | RPMTAG_GIF = 1012, /* x */ | 193 | RPMTAG_GIF = 1012, /* x */ |
194 | RPMTAG_XPM = 1013, /* x */ | 194 | RPMTAG_XPM = 1013, /* x */ |
195 | RPMTAG_SOURCE = 1018, /* s[] */ | 195 | RPMTAG_SOURCE = 1018, /* s[] */ |
196 | RPMTAG_PATCH = 1019, /* s[] */ | 196 | RPMTAG_PATCH = 1019, /* s[] */ |
197 | RPMTAG_PREIN = 1023, /* s */ | 197 | RPMTAG_PREIN = 1023, /* s */ |
198 | RPMTAG_POSTIN = 1024, /* s */ | 198 | RPMTAG_POSTIN = 1024, /* s */ |
199 | RPMTAG_PREUN = 1025, /* s */ | 199 | RPMTAG_PREUN = 1025, /* s */ |
200 | RPMTAG_POSTUN = 1026, /* s */ | 200 | RPMTAG_POSTUN = 1026, /* s */ |
201 | RPMTAG_ICON = 1043, /* x */ | 201 | RPMTAG_ICON = 1043, /* x */ |
202 | RPMTAG_SOURCERPM = 1044, /* s */ | 202 | RPMTAG_SOURCERPM = 1044, /* s */ |
203 | RPMTAG_PROVIDENAME = 1047, /* s[] */ | 203 | RPMTAG_PROVIDENAME = 1047, /* s[] */ |
204 | RPMTAG_EXCLUDEARCH = 1059, /* s[] */ | 204 | RPMTAG_EXCLUDEARCH = 1059, /* s[] */ |
205 | RPMTAG_EXCLUDEOS = 1060, /* s[] */ | 205 | RPMTAG_EXCLUDEOS = 1060, /* s[] */ |
206 | RPMTAG_EXCLUSIVEARCH = 1061, /* s[] */ | 206 | RPMTAG_EXCLUSIVEARCH = 1061, /* s[] */ |
207 | RPMTAG_EXCLUSIVEOS = 1062, /* s[] */ | 207 | RPMTAG_EXCLUSIVEOS = 1062, /* s[] */ |
208 | RPMTAG_TRIGGERSCRIPTS = 1065, /* s[] */ | 208 | RPMTAG_TRIGGERSCRIPTS = 1065, /* s[] */ |
209 | RPMTAG_TRIGGERNAME = 1066, /* s[] */ | 209 | RPMTAG_TRIGGERNAME = 1066, /* s[] */ |
210 | RPMTAG_TRIGGERVERSION = 1067, /* s[] */ | 210 | RPMTAG_TRIGGERVERSION = 1067, /* s[] */ |
211 | RPMTAG_VERIFYSCRIPT = 1079, /* s */ | 211 | RPMTAG_VERIFYSCRIPT = 1079, /* s */ |
212 | RPMTAG_PREINPROG = 1085, /* s */ | 212 | RPMTAG_PREINPROG = 1085, /* s */ |
213 | RPMTAG_POSTINPROG = 1086, /* s */ | 213 | RPMTAG_POSTINPROG = 1086, /* s */ |
214 | RPMTAG_PREUNPROG = 1087, /* s */ | 214 | RPMTAG_PREUNPROG = 1087, /* s */ |
215 | RPMTAG_POSTUNPROG = 1088, /* s */ | 215 | RPMTAG_POSTUNPROG = 1088, /* s */ |
216 | RPMTAG_BUILDARCHS = 1089, /* s[] */ | 216 | RPMTAG_BUILDARCHS = 1089, /* s[] */ |
217 | RPMTAG_OBSOLETENAME = 1090, /* s[] */ | 217 | RPMTAG_OBSOLETENAME = 1090, /* s[] */ |
218 | RPMTAG_VERIFYSCRIPTPROG = 1091, /* s */ | 218 | RPMTAG_VERIFYSCRIPTPROG = 1091, /* s */ |
219 | RPMTAG_TRIGGERSCRIPTPROG = 1092, /* s[] */ | 219 | RPMTAG_TRIGGERSCRIPTPROG = 1092, /* s[] */ |
220 | RPMTAG_COOKIE = 1094, /* s */ | 220 | RPMTAG_COOKIE = 1094, /* s */ |
221 | RPMTAG_FILELANGS = 1097, /* s[] */ | 221 | RPMTAG_FILELANGS = 1097, /* s[] */ |
222 | RPMTAG_PREFIXES = 1098, /* s[] */ | 222 | RPMTAG_PREFIXES = 1098, /* s[] */ |
223 | RPMTAG_INSTPREFIXES = 1099, /* s[] */ | 223 | RPMTAG_INSTPREFIXES = 1099, /* s[] */ |
224 | RPMTAG_PROVIDEVERSION = 1113, /* s[] */ | 224 | RPMTAG_PROVIDEVERSION = 1113, /* s[] */ |
225 | RPMTAG_OBSOLETEVERSION = 1115, /* s[] */ | 225 | RPMTAG_OBSOLETEVERSION = 1115, /* s[] */ |
226 | RPMTAG_BASENAMES = 1117, /* s[] */ | 226 | RPMTAG_BASENAMES = 1117, /* s[] */ |
227 | RPMTAG_DIRNAMES = 1118, /* s[] */ | 227 | RPMTAG_DIRNAMES = 1118, /* s[] */ |
228 | RPMTAG_OPTFLAGS = 1122, /* s */ | 228 | RPMTAG_OPTFLAGS = 1122, /* s */ |
229 | RPMTAG_PAYLOADFORMAT = 1124, /* s */ | 229 | RPMTAG_PAYLOADFORMAT = 1124, /* s */ |
230 | RPMTAG_PAYLOADCOMPRESSOR = 1125, /* s */ | 230 | RPMTAG_PAYLOADCOMPRESSOR = 1125, /* s */ |
231 | RPMTAG_PAYLOADFLAGS = 1126, /* s */ | 231 | RPMTAG_PAYLOADFLAGS = 1126, /* s */ |
232 | RPMTAG_CLASSDICT = 1142, /* s[] */ | 232 | RPMTAG_CLASSDICT = 1142, /* s[] */ |
233 | RPMTAG_SOURCEPKGID = 1146, /* x */ | 233 | RPMTAG_SOURCEPKGID = 1146, /* x */ |
234 | RPMTAG_PRETRANS = 1151, /* s */ | 234 | RPMTAG_PRETRANS = 1151, /* s */ |
235 | RPMTAG_POSTTRANS = 1152, /* s */ | 235 | RPMTAG_POSTTRANS = 1152, /* s */ |
236 | RPMTAG_PRETRANSPROG = 1153, /* s */ | 236 | RPMTAG_PRETRANSPROG = 1153, /* s */ |
237 | RPMTAG_POSTTRANSPROG = 1154, /* s */ | 237 | RPMTAG_POSTTRANSPROG = 1154, /* s */ |
238 | RPMTAG_DISTTAG = 1155, /* s */ | 238 | RPMTAG_DISTTAG = 1155, /* s */ |
239 | #endif | 239 | #endif |
240 | {0, 0} | 240 | {0, 0} |
241 | }; | 241 | }; |
@@ -271,142 +271,142 @@ EXTRACTOR_rpm_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
271 | if (0 != pipe (parg.pi)) | 271 | if (0 != pipe (parg.pi)) |
272 | return; | 272 | return; |
273 | if (0 != pthread_mutex_init (&parg.lock, NULL)) | 273 | if (0 != pthread_mutex_init (&parg.lock, NULL)) |
274 | { | 274 | { |
275 | CLOSE (parg.pi[0]); | 275 | CLOSE (parg.pi[0]); |
276 | CLOSE (parg.pi[1]); | 276 | CLOSE (parg.pi[1]); |
277 | return; | 277 | return; |
278 | } | 278 | } |
279 | if (0 != pthread_create (&pthr, | 279 | if (0 != pthread_create (&pthr, |
280 | NULL, | 280 | NULL, |
281 | &pipe_feeder, | 281 | &pipe_feeder, |
282 | &parg)) | 282 | &parg)) |
283 | { | 283 | { |
284 | pthread_mutex_destroy (&parg.lock); | 284 | pthread_mutex_destroy (&parg.lock); |
285 | CLOSE (parg.pi[0]); | 285 | CLOSE (parg.pi[0]); |
286 | CLOSE (parg.pi[1]); | 286 | CLOSE (parg.pi[1]); |
287 | return; | 287 | return; |
288 | } | 288 | } |
289 | rpmlogSetCallback (&discard_log_callback, NULL); | 289 | rpmlogSetCallback (&discard_log_callback, NULL); |
290 | fdi = fdDup (parg.pi[0]); | 290 | fdi = fdDup (parg.pi[0]); |
291 | ts = rpmtsCreate(); | 291 | ts = rpmtsCreate (); |
292 | rc = rpmReadPackageFile (ts, fdi, "GNU libextractor", &hdr); | 292 | rc = rpmReadPackageFile (ts, fdi, "GNU libextractor", &hdr); |
293 | switch (rc) | 293 | switch (rc) |
294 | { | 294 | { |
295 | case RPMRC_OK: | 295 | case RPMRC_OK: |
296 | case RPMRC_NOKEY: | 296 | case RPMRC_NOKEY: |
297 | case RPMRC_NOTTRUSTED: | 297 | case RPMRC_NOTTRUSTED: |
298 | break; | 298 | break; |
299 | case RPMRC_NOTFOUND: | 299 | case RPMRC_NOTFOUND: |
300 | case RPMRC_FAIL: | 300 | case RPMRC_FAIL: |
301 | default: | 301 | default: |
302 | goto END; | 302 | goto END; |
303 | } | 303 | } |
304 | pthread_mutex_lock (&parg.lock); | 304 | pthread_mutex_lock (&parg.lock); |
305 | if (0 != ec->proc (ec->cls, | 305 | if (0 != ec->proc (ec->cls, |
306 | "rpm", | 306 | "rpm", |
307 | EXTRACTOR_METATYPE_MIMETYPE, | 307 | EXTRACTOR_METATYPE_MIMETYPE, |
308 | EXTRACTOR_METAFORMAT_UTF8, | 308 | EXTRACTOR_METAFORMAT_UTF8, |
309 | "text/plain", | 309 | "text/plain", |
310 | "application/x-rpm", | 310 | "application/x-rpm", |
311 | strlen ("application/x-rpm") +1)) | 311 | strlen ("application/x-rpm") + 1)) |
312 | { | 312 | { |
313 | pthread_mutex_unlock (&parg.lock); | 313 | pthread_mutex_unlock (&parg.lock); |
314 | goto END; | 314 | goto END; |
315 | } | 315 | } |
316 | pthread_mutex_unlock (&parg.lock); | 316 | pthread_mutex_unlock (&parg.lock); |
317 | hi = headerInitIterator (hdr); | 317 | hi = headerInitIterator (hdr); |
318 | p = rpmtdNew (); | 318 | p = rpmtdNew (); |
319 | while (1 == headerNext (hi, p)) | 319 | while (1 == headerNext (hi, p)) |
320 | for (i = 0; 0 != tests[i].rtype; i++) | 320 | for (i = 0; 0 != tests[i].rtype; i++) |
321 | { | ||
322 | if (tests[i].rtype != p->tag) | ||
323 | continue; | ||
324 | switch (p->type) | ||
321 | { | 325 | { |
322 | if (tests[i].rtype != p->tag) | 326 | case RPM_STRING_ARRAY_TYPE: |
323 | continue; | 327 | case RPM_I18NSTRING_TYPE: |
324 | switch (p->type) | 328 | case RPM_STRING_TYPE: |
325 | { | 329 | while (NULL != (str = rpmtdNextString (p))) |
326 | case RPM_STRING_ARRAY_TYPE: | 330 | { |
327 | case RPM_I18NSTRING_TYPE: | 331 | pthread_mutex_lock (&parg.lock); |
328 | case RPM_STRING_TYPE: | 332 | if (0 != ec->proc (ec->cls, |
329 | while (NULL != (str = rpmtdNextString (p))) | 333 | "rpm", |
330 | { | 334 | tests[i].type, |
331 | pthread_mutex_lock (&parg.lock); | 335 | EXTRACTOR_METAFORMAT_UTF8, |
332 | if (0 != ec->proc (ec->cls, | 336 | "text/plain", |
333 | "rpm", | 337 | str, |
334 | tests[i].type, | 338 | strlen (str) + 1)) |
335 | EXTRACTOR_METAFORMAT_UTF8, | 339 | |
336 | "text/plain", | 340 | { |
337 | str, | 341 | pthread_mutex_unlock (&parg.lock); |
338 | strlen (str) + 1)) | 342 | goto CLEANUP; |
339 | 343 | } | |
340 | { | 344 | pthread_mutex_unlock (&parg.lock); |
341 | pthread_mutex_unlock (&parg.lock); | 345 | } |
342 | goto CLEANUP; | 346 | break; |
343 | } | 347 | case RPM_INT32_TYPE: |
344 | pthread_mutex_unlock (&parg.lock); | 348 | { |
345 | } | 349 | if (p->tag == RPMTAG_BUILDTIME) |
346 | break; | 350 | { |
347 | case RPM_INT32_TYPE: | 351 | char tmp[80]; |
348 | { | 352 | uint32_t *v = rpmtdNextUint32 (p); |
349 | if (p->tag == RPMTAG_BUILDTIME) | 353 | time_t tp = (time_t) *v; |
350 | { | 354 | |
351 | char tmp[80]; | 355 | if (NULL == ctime_r (&tp, tmp)) |
352 | uint32_t *v = rpmtdNextUint32 (p); | 356 | break; |
353 | time_t tp = (time_t) *v; | 357 | if ( (strlen (tmp) > 0) && |
354 | 358 | (isspace ((unsigned char) tmp[strlen (tmp) - 1])) ) | |
355 | if (NULL == ctime_r (&tp, tmp)) | 359 | tmp[strlen (tmp) - 1] = '\0'; /* eat linefeed */ |
356 | break; | 360 | pthread_mutex_lock (&parg.lock); |
357 | if ( (strlen (tmp) > 0) && | 361 | if (0 != ec->proc (ec->cls, |
358 | (isspace ((unsigned char) tmp[strlen(tmp)-1])) ) | 362 | "rpm", |
359 | tmp[strlen (tmp) - 1] = '\0'; /* eat linefeed */ | 363 | tests[i].type, |
360 | pthread_mutex_lock (&parg.lock); | 364 | EXTRACTOR_METAFORMAT_UTF8, |
361 | if (0 != ec->proc (ec->cls, | 365 | "text/plain", |
362 | "rpm", | 366 | tmp, |
363 | tests[i].type, | 367 | strlen (tmp) + 1)) |
364 | EXTRACTOR_METAFORMAT_UTF8, | 368 | { |
365 | "text/plain", | 369 | pthread_mutex_unlock (&parg.lock); |
366 | tmp, | 370 | goto CLEANUP; |
367 | strlen (tmp) + 1)) | 371 | } |
368 | { | 372 | pthread_mutex_unlock (&parg.lock); |
369 | pthread_mutex_unlock (&parg.lock); | 373 | } |
370 | goto CLEANUP; | 374 | else |
371 | } | 375 | { |
372 | pthread_mutex_unlock (&parg.lock); | 376 | char tmp[14]; |
373 | } | 377 | uint32_t *s = rpmtdNextUint32 (p); |
374 | else | 378 | |
375 | { | 379 | snprintf (tmp, |
376 | char tmp[14]; | 380 | sizeof (tmp), |
377 | uint32_t *s = rpmtdNextUint32 (p); | 381 | "%u", |
378 | 382 | (unsigned int) *s); | |
379 | snprintf (tmp, | 383 | pthread_mutex_lock (&parg.lock); |
380 | sizeof (tmp), | 384 | if (0 != ec->proc (ec->cls, |
381 | "%u", | 385 | "rpm", |
382 | (unsigned int) *s); | 386 | tests[i].type, |
383 | pthread_mutex_lock (&parg.lock); | 387 | EXTRACTOR_METAFORMAT_UTF8, |
384 | if (0 != ec->proc (ec->cls, | 388 | "text/plain", |
385 | "rpm", | 389 | tmp, |
386 | tests[i].type, | 390 | strlen (tmp) + 1)) |
387 | EXTRACTOR_METAFORMAT_UTF8, | 391 | { |
388 | "text/plain", | 392 | pthread_mutex_unlock (&parg.lock); |
389 | tmp, | 393 | goto CLEANUP; |
390 | strlen (tmp) + 1)) | 394 | } |
391 | { | 395 | pthread_mutex_unlock (&parg.lock); |
392 | pthread_mutex_unlock (&parg.lock); | 396 | } |
393 | goto CLEANUP; | 397 | break; |
394 | } | 398 | } |
395 | pthread_mutex_unlock (&parg.lock); | 399 | default: |
396 | } | 400 | break; |
397 | break; | ||
398 | } | ||
399 | default: | ||
400 | break; | ||
401 | } | ||
402 | } | 401 | } |
403 | CLEANUP: | 402 | } |
403 | CLEANUP: | ||
404 | rpmtdFree (p); | 404 | rpmtdFree (p); |
405 | headerFreeIterator (hi); | 405 | headerFreeIterator (hi); |
406 | 406 | ||
407 | END: | 407 | END: |
408 | headerFree (hdr); | 408 | headerFree (hdr); |
409 | rpmtsFree(ts); | 409 | rpmtsFree (ts); |
410 | 410 | ||
411 | /* make sure SIGALRM does not kill us, then use it to | 411 | /* make sure SIGALRM does not kill us, then use it to |
412 | kill the thread */ | 412 | kill the thread */ |
@@ -424,4 +424,5 @@ EXTRACTOR_rpm_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
424 | sigaction (SIGALRM, &old, &sig); | 424 | sigaction (SIGALRM, &old, &sig); |
425 | } | 425 | } |
426 | 426 | ||
427 | |||
427 | /* end of rpm_extractor.c */ | 428 | /* end of rpm_extractor.c */ |
diff --git a/src/plugins/s3m_extractor.c b/src/plugins/s3m_extractor.c index c4789ce..9372110 100644 --- a/src/plugins/s3m_extractor.c +++ b/src/plugins/s3m_extractor.c | |||
@@ -61,7 +61,11 @@ LE_NETWORK_STRUCT_END | |||
61 | * @param t LE meta data type | 61 | * @param t LE meta data type |
62 | * @param s meta data to add | 62 | * @param s meta data to add |
63 | */ | 63 | */ |
64 | #define ADD(s, t) do { if (0 != ec->proc (ec->cls, "s3m", t, EXTRACTOR_METAFORMAT_UTF8, "text/plain", s, strlen (s) + 1)) return; } while (0) | 64 | #define ADD(s, t) do { if (0 != ec->proc (ec->cls, "s3m", t, \ |
65 | EXTRACTOR_METAFORMAT_UTF8, \ | ||
66 | "text/plain", s, strlen (s) \ | ||
67 | + 1)) return; \ | ||
68 | } while (0) | ||
65 | 69 | ||
66 | 70 | ||
67 | /** | 71 | /** |
@@ -82,8 +86,8 @@ EXTRACTOR_s3m_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
82 | 86 | ||
83 | if ((ssize_t) sizeof (header) > | 87 | if ((ssize_t) sizeof (header) > |
84 | ec->read (ec->cls, | 88 | ec->read (ec->cls, |
85 | &data, | 89 | &data, |
86 | sizeof (header))) | 90 | sizeof (header))) |
87 | return; | 91 | return; |
88 | memcpy (&header, data, sizeof (header)); | 92 | memcpy (&header, data, sizeof (header)); |
89 | if ( (0x1A != header.byte_1A) || | 93 | if ( (0x1A != header.byte_1A) || |
@@ -105,4 +109,5 @@ EXTRACTOR_s3m_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
105 | */ | 109 | */ |
106 | } | 110 | } |
107 | 111 | ||
112 | |||
108 | /* end of s3m_extractor.c */ | 113 | /* end of s3m_extractor.c */ |
diff --git a/src/plugins/sid_extractor.c b/src/plugins/sid_extractor.c index dface42..58d4e5d 100644 --- a/src/plugins/sid_extractor.c +++ b/src/plugins/sid_extractor.c | |||
@@ -154,7 +154,11 @@ sidword (const sidwrd data) | |||
154 | * @param s metadata value as UTF8 | 154 | * @param s metadata value as UTF8 |
155 | * @param t metadata type to use | 155 | * @param t metadata type to use |
156 | */ | 156 | */ |
157 | #define ADD(s,t) do { if (0 != ec->proc (ec->cls, "sid", t, EXTRACTOR_METAFORMAT_UTF8, "text/plain", s, strlen (s) + 1)) return; } while (0) | 157 | #define ADD(s,t) do { if (0 != ec->proc (ec->cls, "sid", t, \ |
158 | EXTRACTOR_METAFORMAT_UTF8, \ | ||
159 | "text/plain", s, strlen (s) \ | ||
160 | + 1)) return; \ | ||
161 | } while (0) | ||
158 | 162 | ||
159 | 163 | ||
160 | /** | 164 | /** |
@@ -178,8 +182,8 @@ EXTRACTOR_sid_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
178 | 182 | ||
179 | if ((ssize_t) sizeof (struct header) > | 183 | if ((ssize_t) sizeof (struct header) > |
180 | ec->read (ec->cls, | 184 | ec->read (ec->cls, |
181 | &data, | 185 | &data, |
182 | sizeof (struct header))) | 186 | sizeof (struct header))) |
183 | return; | 187 | return; |
184 | head = data; | 188 | head = data; |
185 | 189 | ||
@@ -194,22 +198,22 @@ EXTRACTOR_sid_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
194 | /* Version of SID format */ | 198 | /* Version of SID format */ |
195 | version = sidword (head->sidversion); | 199 | version = sidword (head->sidversion); |
196 | snprintf (sidversion, | 200 | snprintf (sidversion, |
197 | sizeof (sidversion), | 201 | sizeof (sidversion), |
198 | "%d", | 202 | "%d", |
199 | version); | 203 | version); |
200 | ADD (sidversion, EXTRACTOR_METATYPE_FORMAT_VERSION); | 204 | ADD (sidversion, EXTRACTOR_METATYPE_FORMAT_VERSION); |
201 | 205 | ||
202 | /* Get song count */ | 206 | /* Get song count */ |
203 | snprintf (songs, | 207 | snprintf (songs, |
204 | sizeof (songs), | 208 | sizeof (songs), |
205 | "%d", sidword (head->songs)); | 209 | "%d", sidword (head->songs)); |
206 | ADD (songs, EXTRACTOR_METATYPE_SONG_COUNT); | 210 | ADD (songs, EXTRACTOR_METATYPE_SONG_COUNT); |
207 | 211 | ||
208 | /* Get number of the first song to be played */ | 212 | /* Get number of the first song to be played */ |
209 | snprintf (startingsong, | 213 | snprintf (startingsong, |
210 | sizeof (startingsong), | 214 | sizeof (startingsong), |
211 | "%d", | 215 | "%d", |
212 | sidword (head->firstsong)); | 216 | sidword (head->firstsong)); |
213 | ADD (startingsong, EXTRACTOR_METATYPE_STARTING_SONG); | 217 | ADD (startingsong, EXTRACTOR_METATYPE_STARTING_SONG); |
214 | 218 | ||
215 | /* name, artist, copyright fields */ | 219 | /* name, artist, copyright fields */ |
@@ -232,8 +236,7 @@ EXTRACTOR_sid_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
232 | * | 236 | * |
233 | * Note: Had some troubles understanding specification | 237 | * Note: Had some troubles understanding specification |
234 | * on the flags in version 2. I hope this is correct. | 238 | * on the flags in version 2. I hope this is correct. |
235 | */ | 239 | */flags = sidword (head->flags); |
236 | flags = sidword (head->flags); | ||
237 | /* MUS data */ | 240 | /* MUS data */ |
238 | if (0 != (flags & MUSPLAYER_FLAG)) | 241 | if (0 != (flags & MUSPLAYER_FLAG)) |
239 | ADD ("Compute!'s Sidplayer", EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE); | 242 | ADD ("Compute!'s Sidplayer", EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE); |
@@ -256,4 +259,5 @@ EXTRACTOR_sid_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
256 | ADD ("MOS6581", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE); | 259 | ADD ("MOS6581", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE); |
257 | } | 260 | } |
258 | 261 | ||
262 | |||
259 | /* end of sid_extractor.c */ | 263 | /* end of sid_extractor.c */ |
diff --git a/src/plugins/template_extractor.c b/src/plugins/template_extractor.c index aad875e..9dad40d 100644 --- a/src/plugins/template_extractor.c +++ b/src/plugins/template_extractor.c | |||
@@ -46,13 +46,13 @@ EXTRACTOR_template_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
46 | return 1; | 46 | return 1; |
47 | 47 | ||
48 | /* initialize state here */ | 48 | /* initialize state here */ |
49 | 49 | ||
50 | /* Call seek (plugin, POSITION, WHENCE) to seek (if you know where | 50 | /* Call seek (plugin, POSITION, WHENCE) to seek (if you know where |
51 | * data starts): | 51 | * data starts): |
52 | */ | 52 | */ |
53 | // ec->seek (ec->cls, POSITION, SEEK_SET); | 53 | // ec->seek (ec->cls, POSITION, SEEK_SET); |
54 | 54 | ||
55 | /* Call read (plugin, &data, COUNT) to read COUNT bytes | 55 | /* Call read (plugin, &data, COUNT) to read COUNT bytes |
56 | */ | 56 | */ |
57 | 57 | ||
58 | 58 | ||
@@ -64,4 +64,5 @@ EXTRACTOR_template_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
64 | return; | 64 | return; |
65 | } | 65 | } |
66 | 66 | ||
67 | |||
67 | /* end of template_extractor.c */ | 68 | /* end of template_extractor.c */ |
diff --git a/src/plugins/test_archive.c b/src/plugins/test_archive.c index a7a8c1d..a98c05e 100644 --- a/src/plugins/test_archive.c +++ b/src/plugins/test_archive.c | |||
@@ -36,41 +36,40 @@ | |||
36 | int | 36 | int |
37 | main (int argc, char *argv[]) | 37 | main (int argc, char *argv[]) |
38 | { | 38 | { |
39 | struct SolutionData tar_archive_sol[] = | 39 | struct SolutionData tar_archive_sol[] = { |
40 | { | 40 | { |
41 | { | 41 | EXTRACTOR_METATYPE_FILENAME, |
42 | EXTRACTOR_METATYPE_FILENAME, | 42 | EXTRACTOR_METAFORMAT_UTF8, |
43 | EXTRACTOR_METAFORMAT_UTF8, | 43 | "text/plain", |
44 | "text/plain", | 44 | "test.html", |
45 | "test.html", | 45 | strlen ("test.html") + 1, |
46 | strlen ("test.html") + 1, | 46 | 0 |
47 | 0 | 47 | }, |
48 | }, | ||
49 | { | ||
50 | EXTRACTOR_METATYPE_FILENAME, | ||
51 | EXTRACTOR_METAFORMAT_UTF8, | ||
52 | "text/plain", | ||
53 | "test.jpg", | ||
54 | strlen ("test.jpg") + 1, | ||
55 | 0 | ||
56 | }, | ||
57 | { | ||
58 | EXTRACTOR_METATYPE_FORMAT, | ||
59 | EXTRACTOR_METAFORMAT_UTF8, | ||
60 | "text/plain", | ||
61 | "GNU tar format", | ||
62 | strlen ("GNU tar format") + 1, | ||
63 | 0 | ||
64 | }, | ||
65 | { 0, 0, NULL, NULL, 0, -1 } | ||
66 | }; | ||
67 | struct ProblemSet ps[] = | ||
68 | { | 48 | { |
69 | { "testdata/archive_test.tar", | 49 | EXTRACTOR_METATYPE_FILENAME, |
70 | tar_archive_sol }, | 50 | EXTRACTOR_METAFORMAT_UTF8, |
71 | { NULL, NULL } | 51 | "text/plain", |
72 | }; | 52 | "test.jpg", |
53 | strlen ("test.jpg") + 1, | ||
54 | 0 | ||
55 | }, | ||
56 | { | ||
57 | EXTRACTOR_METATYPE_FORMAT, | ||
58 | EXTRACTOR_METAFORMAT_UTF8, | ||
59 | "text/plain", | ||
60 | "GNU tar format", | ||
61 | strlen ("GNU tar format") + 1, | ||
62 | 0 | ||
63 | }, | ||
64 | { 0, 0, NULL, NULL, 0, -1 } | ||
65 | }; | ||
66 | struct ProblemSet ps[] = { | ||
67 | { "testdata/archive_test.tar", | ||
68 | tar_archive_sol }, | ||
69 | { NULL, NULL } | ||
70 | }; | ||
73 | return ET_main ("archive", ps); | 71 | return ET_main ("archive", ps); |
74 | } | 72 | } |
75 | 73 | ||
74 | |||
76 | /* end of test_archive.c */ | 75 | /* end of test_archive.c */ |
diff --git a/src/plugins/test_deb.c b/src/plugins/test_deb.c index 0b7c653..767c34f 100644 --- a/src/plugins/test_deb.c +++ b/src/plugins/test_deb.c | |||
@@ -36,139 +36,138 @@ | |||
36 | int | 36 | int |
37 | main (int argc, char *argv[]) | 37 | main (int argc, char *argv[]) |
38 | { | 38 | { |
39 | struct SolutionData deb_bzip2_sol[] = | 39 | struct SolutionData deb_bzip2_sol[] = { |
40 | { | 40 | { |
41 | { | 41 | EXTRACTOR_METATYPE_MIMETYPE, |
42 | EXTRACTOR_METATYPE_MIMETYPE, | 42 | EXTRACTOR_METAFORMAT_UTF8, |
43 | EXTRACTOR_METAFORMAT_UTF8, | 43 | "text/plain", |
44 | "text/plain", | 44 | "application/x-debian-package", |
45 | "application/x-debian-package", | 45 | strlen ("application/x-debian-package") + 1, |
46 | strlen ("application/x-debian-package") + 1, | 46 | 0 |
47 | 0 | 47 | }, |
48 | }, | ||
49 | { | ||
50 | EXTRACTOR_METATYPE_PACKAGE_NAME, | ||
51 | EXTRACTOR_METAFORMAT_UTF8, | ||
52 | "text/plain", | ||
53 | "bzip2", | ||
54 | strlen ("bzip2") + 1, | ||
55 | 0 | ||
56 | }, | ||
57 | { | ||
58 | EXTRACTOR_METATYPE_PACKAGE_VERSION, | ||
59 | EXTRACTOR_METAFORMAT_UTF8, | ||
60 | "text/plain", | ||
61 | "1.0.6-4", | ||
62 | strlen ("1.0.6-4") + 1, | ||
63 | 0 | ||
64 | }, | ||
65 | { | ||
66 | EXTRACTOR_METATYPE_TARGET_ARCHITECTURE, | ||
67 | EXTRACTOR_METAFORMAT_UTF8, | ||
68 | "text/plain", | ||
69 | "i386", | ||
70 | strlen ("i386") + 1, | ||
71 | 0 | ||
72 | }, | ||
73 | { | ||
74 | EXTRACTOR_METATYPE_PACKAGE_MAINTAINER, | ||
75 | EXTRACTOR_METAFORMAT_UTF8, | ||
76 | "text/plain", | ||
77 | "Anibal Monsalve Salazar <anibal@debian.org>", | ||
78 | strlen ("Anibal Monsalve Salazar <anibal@debian.org>") + 1, | ||
79 | 0 | ||
80 | }, | ||
81 | { | ||
82 | EXTRACTOR_METATYPE_PACKAGE_INSTALLED_SIZE, | ||
83 | EXTRACTOR_METAFORMAT_UTF8, | ||
84 | "text/plain", | ||
85 | "113", /* FIXME: should this be 'kb'? */ | ||
86 | strlen ("113") + 1, | ||
87 | 0 | ||
88 | }, | ||
89 | { | ||
90 | EXTRACTOR_METATYPE_PACKAGE_DEPENDENCY, | ||
91 | EXTRACTOR_METAFORMAT_UTF8, | ||
92 | "text/plain", | ||
93 | "libbz2-1.0 (= 1.0.6-4), libc6 (>= 2.4)", | ||
94 | strlen ("libbz2-1.0 (= 1.0.6-4), libc6 (>= 2.4)") + 1, | ||
95 | 0 | ||
96 | }, | ||
97 | { | ||
98 | EXTRACTOR_METATYPE_PACKAGE_SUGGESTS, | ||
99 | EXTRACTOR_METAFORMAT_UTF8, | ||
100 | "text/plain", | ||
101 | "bzip2-doc", | ||
102 | strlen ("bzip2-doc") + 1, | ||
103 | 0 | ||
104 | }, | ||
105 | { | ||
106 | EXTRACTOR_METATYPE_PACKAGE_REPLACES, | ||
107 | EXTRACTOR_METAFORMAT_UTF8, | ||
108 | "text/plain", | ||
109 | "libbz2 (<< 0.9.5d-3)", | ||
110 | strlen ("libbz2 (<< 0.9.5d-3)") + 1, | ||
111 | 0 | ||
112 | }, | ||
113 | { | ||
114 | EXTRACTOR_METATYPE_SECTION, | ||
115 | EXTRACTOR_METAFORMAT_UTF8, | ||
116 | "text/plain", | ||
117 | "utils", | ||
118 | strlen ("utils") + 1, | ||
119 | 0 | ||
120 | }, | ||
121 | { | ||
122 | EXTRACTOR_METATYPE_UPLOAD_PRIORITY, | ||
123 | EXTRACTOR_METAFORMAT_UTF8, | ||
124 | "text/plain", | ||
125 | "standard", | ||
126 | strlen ("standard") + 1, | ||
127 | 0 | ||
128 | }, | ||
129 | { | ||
130 | EXTRACTOR_METATYPE_DESCRIPTION, | ||
131 | EXTRACTOR_METAFORMAT_UTF8, | ||
132 | "text/plain", | ||
133 | "high-quality block-sorting file compressor - utilities\n" | ||
134 | " bzip2 is a freely available, patent free, high-quality data compressor.\n" | ||
135 | " It typically compresses files to within 10% to 15% of the best available\n" | ||
136 | " techniques, whilst being around twice as fast at compression and six\n" | ||
137 | " times faster at decompression.\n" | ||
138 | " .\n" | ||
139 | " bzip2 compresses files using the Burrows-Wheeler block-sorting text\n" | ||
140 | " compression algorithm, and Huffman coding. Compression is generally\n" | ||
141 | " considerably better than that achieved by more conventional\n" | ||
142 | " LZ77/LZ78-based compressors, and approaches the performance of the PPM\n" | ||
143 | " family of statistical compressors.\n" | ||
144 | " .\n" | ||
145 | " The archive file format of bzip2 (.bz2) is incompatible with that of its\n" | ||
146 | " predecessor, bzip (.bz).", | ||
147 | strlen ("high-quality block-sorting file compressor - utilities\n" | ||
148 | " bzip2 is a freely available, patent free, high-quality data compressor.\n" | ||
149 | " It typically compresses files to within 10% to 15% of the best available\n" | ||
150 | " techniques, whilst being around twice as fast at compression and six\n" | ||
151 | " times faster at decompression.\n" | ||
152 | " .\n" | ||
153 | " bzip2 compresses files using the Burrows-Wheeler block-sorting text\n" | ||
154 | " compression algorithm, and Huffman coding. Compression is generally\n" | ||
155 | " considerably better than that achieved by more conventional\n" | ||
156 | " LZ77/LZ78-based compressors, and approaches the performance of the PPM\n" | ||
157 | " family of statistical compressors.\n" | ||
158 | " .\n" | ||
159 | " The archive file format of bzip2 (.bz2) is incompatible with that of its\n" | ||
160 | " predecessor, bzip (.bz).") + 1, | ||
161 | 0 | ||
162 | }, | ||
163 | { 0, 0, NULL, NULL, 0, -1 } | ||
164 | }; | ||
165 | struct ProblemSet ps[] = | ||
166 | { | 48 | { |
167 | { "testdata/deb_bzip2.deb", | 49 | EXTRACTOR_METATYPE_PACKAGE_NAME, |
168 | deb_bzip2_sol }, | 50 | EXTRACTOR_METAFORMAT_UTF8, |
169 | { NULL, NULL } | 51 | "text/plain", |
170 | }; | 52 | "bzip2", |
53 | strlen ("bzip2") + 1, | ||
54 | 0 | ||
55 | }, | ||
56 | { | ||
57 | EXTRACTOR_METATYPE_PACKAGE_VERSION, | ||
58 | EXTRACTOR_METAFORMAT_UTF8, | ||
59 | "text/plain", | ||
60 | "1.0.6-4", | ||
61 | strlen ("1.0.6-4") + 1, | ||
62 | 0 | ||
63 | }, | ||
64 | { | ||
65 | EXTRACTOR_METATYPE_TARGET_ARCHITECTURE, | ||
66 | EXTRACTOR_METAFORMAT_UTF8, | ||
67 | "text/plain", | ||
68 | "i386", | ||
69 | strlen ("i386") + 1, | ||
70 | 0 | ||
71 | }, | ||
72 | { | ||
73 | EXTRACTOR_METATYPE_PACKAGE_MAINTAINER, | ||
74 | EXTRACTOR_METAFORMAT_UTF8, | ||
75 | "text/plain", | ||
76 | "Anibal Monsalve Salazar <anibal@debian.org>", | ||
77 | strlen ("Anibal Monsalve Salazar <anibal@debian.org>") + 1, | ||
78 | 0 | ||
79 | }, | ||
80 | { | ||
81 | EXTRACTOR_METATYPE_PACKAGE_INSTALLED_SIZE, | ||
82 | EXTRACTOR_METAFORMAT_UTF8, | ||
83 | "text/plain", | ||
84 | "113", /* FIXME: should this be 'kb'? */ | ||
85 | strlen ("113") + 1, | ||
86 | 0 | ||
87 | }, | ||
88 | { | ||
89 | EXTRACTOR_METATYPE_PACKAGE_DEPENDENCY, | ||
90 | EXTRACTOR_METAFORMAT_UTF8, | ||
91 | "text/plain", | ||
92 | "libbz2-1.0 (= 1.0.6-4), libc6 (>= 2.4)", | ||
93 | strlen ("libbz2-1.0 (= 1.0.6-4), libc6 (>= 2.4)") + 1, | ||
94 | 0 | ||
95 | }, | ||
96 | { | ||
97 | EXTRACTOR_METATYPE_PACKAGE_SUGGESTS, | ||
98 | EXTRACTOR_METAFORMAT_UTF8, | ||
99 | "text/plain", | ||
100 | "bzip2-doc", | ||
101 | strlen ("bzip2-doc") + 1, | ||
102 | 0 | ||
103 | }, | ||
104 | { | ||
105 | EXTRACTOR_METATYPE_PACKAGE_REPLACES, | ||
106 | EXTRACTOR_METAFORMAT_UTF8, | ||
107 | "text/plain", | ||
108 | "libbz2 (<< 0.9.5d-3)", | ||
109 | strlen ("libbz2 (<< 0.9.5d-3)") + 1, | ||
110 | 0 | ||
111 | }, | ||
112 | { | ||
113 | EXTRACTOR_METATYPE_SECTION, | ||
114 | EXTRACTOR_METAFORMAT_UTF8, | ||
115 | "text/plain", | ||
116 | "utils", | ||
117 | strlen ("utils") + 1, | ||
118 | 0 | ||
119 | }, | ||
120 | { | ||
121 | EXTRACTOR_METATYPE_UPLOAD_PRIORITY, | ||
122 | EXTRACTOR_METAFORMAT_UTF8, | ||
123 | "text/plain", | ||
124 | "standard", | ||
125 | strlen ("standard") + 1, | ||
126 | 0 | ||
127 | }, | ||
128 | { | ||
129 | EXTRACTOR_METATYPE_DESCRIPTION, | ||
130 | EXTRACTOR_METAFORMAT_UTF8, | ||
131 | "text/plain", | ||
132 | "high-quality block-sorting file compressor - utilities\n" | ||
133 | " bzip2 is a freely available, patent free, high-quality data compressor.\n" | ||
134 | " It typically compresses files to within 10% to 15% of the best available\n" | ||
135 | " techniques, whilst being around twice as fast at compression and six\n" | ||
136 | " times faster at decompression.\n" | ||
137 | " .\n" | ||
138 | " bzip2 compresses files using the Burrows-Wheeler block-sorting text\n" | ||
139 | " compression algorithm, and Huffman coding. Compression is generally\n" | ||
140 | " considerably better than that achieved by more conventional\n" | ||
141 | " LZ77/LZ78-based compressors, and approaches the performance of the PPM\n" | ||
142 | " family of statistical compressors.\n" | ||
143 | " .\n" | ||
144 | " The archive file format of bzip2 (.bz2) is incompatible with that of its\n" | ||
145 | " predecessor, bzip (.bz).", | ||
146 | strlen ("high-quality block-sorting file compressor - utilities\n" | ||
147 | " bzip2 is a freely available, patent free, high-quality data compressor.\n" | ||
148 | " It typically compresses files to within 10% to 15% of the best available\n" | ||
149 | " techniques, whilst being around twice as fast at compression and six\n" | ||
150 | " times faster at decompression.\n" | ||
151 | " .\n" | ||
152 | " bzip2 compresses files using the Burrows-Wheeler block-sorting text\n" | ||
153 | " compression algorithm, and Huffman coding. Compression is generally\n" | ||
154 | " considerably better than that achieved by more conventional\n" | ||
155 | " LZ77/LZ78-based compressors, and approaches the performance of the PPM\n" | ||
156 | " family of statistical compressors.\n" | ||
157 | " .\n" | ||
158 | " The archive file format of bzip2 (.bz2) is incompatible with that of its\n" | ||
159 | " predecessor, bzip (.bz).") + 1, | ||
160 | 0 | ||
161 | }, | ||
162 | { 0, 0, NULL, NULL, 0, -1 } | ||
163 | }; | ||
164 | struct ProblemSet ps[] = { | ||
165 | { "testdata/deb_bzip2.deb", | ||
166 | deb_bzip2_sol }, | ||
167 | { NULL, NULL } | ||
168 | }; | ||
171 | return ET_main ("deb", ps); | 169 | return ET_main ("deb", ps); |
172 | } | 170 | } |
173 | 171 | ||
172 | |||
174 | /* end of test_deb.c */ | 173 | /* end of test_deb.c */ |
diff --git a/src/plugins/test_dvi.c b/src/plugins/test_dvi.c index 9a5f27f..2ec364b 100644 --- a/src/plugins/test_dvi.c +++ b/src/plugins/test_dvi.c | |||
@@ -36,89 +36,94 @@ | |||
36 | int | 36 | int |
37 | main (int argc, char *argv[]) | 37 | main (int argc, char *argv[]) |
38 | { | 38 | { |
39 | struct SolutionData dvi_ora_sol[] = | 39 | struct SolutionData dvi_ora_sol[] = { |
40 | { | 40 | { |
41 | { | 41 | EXTRACTOR_METATYPE_MIMETYPE, |
42 | EXTRACTOR_METATYPE_MIMETYPE, | 42 | EXTRACTOR_METAFORMAT_UTF8, |
43 | EXTRACTOR_METAFORMAT_UTF8, | 43 | "text/plain", |
44 | "text/plain", | 44 | "application/x-dvi", |
45 | "application/x-dvi", | 45 | strlen ("application/x-dvi") + 1, |
46 | strlen ("application/x-dvi") + 1, | 46 | 0 |
47 | 0 | 47 | }, |
48 | }, | ||
49 | { | ||
50 | EXTRACTOR_METATYPE_PAGE_COUNT, | ||
51 | EXTRACTOR_METAFORMAT_UTF8, | ||
52 | "text/plain", | ||
53 | "10", | ||
54 | strlen ("10") + 1, | ||
55 | 0 | ||
56 | }, | ||
57 | { | ||
58 | EXTRACTOR_METATYPE_TITLE, | ||
59 | EXTRACTOR_METAFORMAT_C_STRING, | ||
60 | "text/plain", | ||
61 | "Optimal Bitwise Register Allocation using Integer Linear Programming", | ||
62 | strlen ("Optimal Bitwise Register Allocation using Integer Linear Programming") + 1, | ||
63 | 0 | ||
64 | }, | ||
65 | { | ||
66 | EXTRACTOR_METATYPE_SUBJECT, | ||
67 | EXTRACTOR_METAFORMAT_C_STRING, | ||
68 | "text/plain", | ||
69 | "Register Allocation", | ||
70 | strlen ("Register Allocation") + 1, | ||
71 | 0 | ||
72 | }, | ||
73 | { | ||
74 | EXTRACTOR_METATYPE_COMMENT, | ||
75 | EXTRACTOR_METAFORMAT_C_STRING, | ||
76 | "text/plain", | ||
77 | " TeX output 2005.02.06:0725", | ||
78 | strlen (" TeX output 2005.02.06:0725") + 1, | ||
79 | 0 | ||
80 | }, | ||
81 | { | ||
82 | EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE, | ||
83 | EXTRACTOR_METAFORMAT_C_STRING, | ||
84 | "text/plain", | ||
85 | "LaTeX with hyperref package", | ||
86 | strlen ("LaTeX with hyperref package") + 1, | ||
87 | 0 | ||
88 | }, | ||
89 | { | ||
90 | EXTRACTOR_METATYPE_AUTHOR_NAME, | ||
91 | EXTRACTOR_METAFORMAT_C_STRING, | ||
92 | "text/plain", | ||
93 | "Rajkishore Barik and Christian Grothoff and Rahul Gupta and Vinayaka Pandit and Raghavendra Udupa", | ||
94 | strlen ("Rajkishore Barik and Christian Grothoff and Rahul Gupta and Vinayaka Pandit and Raghavendra Udupa") + 1, | ||
95 | 0 | ||
96 | }, | ||
97 | { | ||
98 | EXTRACTOR_METATYPE_PRODUCED_BY_SOFTWARE, | ||
99 | EXTRACTOR_METAFORMAT_C_STRING, | ||
100 | "text/plain", | ||
101 | "dvips + Distiller", | ||
102 | strlen ("dvips + Distiller") + 1, | ||
103 | 0 | ||
104 | }, | ||
105 | { | ||
106 | EXTRACTOR_METATYPE_KEYWORDS, | ||
107 | EXTRACTOR_METAFORMAT_C_STRING, | ||
108 | "text/plain", | ||
109 | "register allocation integer linear programming bit-wise spilling coalesing rematerialization", | ||
110 | strlen ("register allocation integer linear programming bit-wise spilling coalesing rematerialization") + 1, | ||
111 | 0 | ||
112 | }, | ||
113 | { 0, 0, NULL, NULL, 0, -1 } | ||
114 | }; | ||
115 | struct ProblemSet ps[] = | ||
116 | { | 48 | { |
117 | { "testdata/dvi_ora.dvi", | 49 | EXTRACTOR_METATYPE_PAGE_COUNT, |
118 | dvi_ora_sol }, | 50 | EXTRACTOR_METAFORMAT_UTF8, |
119 | { NULL, NULL } | 51 | "text/plain", |
120 | }; | 52 | "10", |
53 | strlen ("10") + 1, | ||
54 | 0 | ||
55 | }, | ||
56 | { | ||
57 | EXTRACTOR_METATYPE_TITLE, | ||
58 | EXTRACTOR_METAFORMAT_C_STRING, | ||
59 | "text/plain", | ||
60 | "Optimal Bitwise Register Allocation using Integer Linear Programming", | ||
61 | strlen ( | ||
62 | "Optimal Bitwise Register Allocation using Integer Linear Programming") | ||
63 | + 1, | ||
64 | 0 | ||
65 | }, | ||
66 | { | ||
67 | EXTRACTOR_METATYPE_SUBJECT, | ||
68 | EXTRACTOR_METAFORMAT_C_STRING, | ||
69 | "text/plain", | ||
70 | "Register Allocation", | ||
71 | strlen ("Register Allocation") + 1, | ||
72 | 0 | ||
73 | }, | ||
74 | { | ||
75 | EXTRACTOR_METATYPE_COMMENT, | ||
76 | EXTRACTOR_METAFORMAT_C_STRING, | ||
77 | "text/plain", | ||
78 | " TeX output 2005.02.06:0725", | ||
79 | strlen (" TeX output 2005.02.06:0725") + 1, | ||
80 | 0 | ||
81 | }, | ||
82 | { | ||
83 | EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE, | ||
84 | EXTRACTOR_METAFORMAT_C_STRING, | ||
85 | "text/plain", | ||
86 | "LaTeX with hyperref package", | ||
87 | strlen ("LaTeX with hyperref package") + 1, | ||
88 | 0 | ||
89 | }, | ||
90 | { | ||
91 | EXTRACTOR_METATYPE_AUTHOR_NAME, | ||
92 | EXTRACTOR_METAFORMAT_C_STRING, | ||
93 | "text/plain", | ||
94 | "Rajkishore Barik and Christian Grothoff and Rahul Gupta and Vinayaka Pandit and Raghavendra Udupa", | ||
95 | strlen ( | ||
96 | "Rajkishore Barik and Christian Grothoff and Rahul Gupta and Vinayaka Pandit and Raghavendra Udupa") | ||
97 | + 1, | ||
98 | 0 | ||
99 | }, | ||
100 | { | ||
101 | EXTRACTOR_METATYPE_PRODUCED_BY_SOFTWARE, | ||
102 | EXTRACTOR_METAFORMAT_C_STRING, | ||
103 | "text/plain", | ||
104 | "dvips + Distiller", | ||
105 | strlen ("dvips + Distiller") + 1, | ||
106 | 0 | ||
107 | }, | ||
108 | { | ||
109 | EXTRACTOR_METATYPE_KEYWORDS, | ||
110 | EXTRACTOR_METAFORMAT_C_STRING, | ||
111 | "text/plain", | ||
112 | "register allocation integer linear programming bit-wise spilling coalesing rematerialization", | ||
113 | strlen ( | ||
114 | "register allocation integer linear programming bit-wise spilling coalesing rematerialization") | ||
115 | + 1, | ||
116 | 0 | ||
117 | }, | ||
118 | { 0, 0, NULL, NULL, 0, -1 } | ||
119 | }; | ||
120 | struct ProblemSet ps[] = { | ||
121 | { "testdata/dvi_ora.dvi", | ||
122 | dvi_ora_sol }, | ||
123 | { NULL, NULL } | ||
124 | }; | ||
121 | return ET_main ("dvi", ps); | 125 | return ET_main ("dvi", ps); |
122 | } | 126 | } |
123 | 127 | ||
128 | |||
124 | /* end of test_dvi.c */ | 129 | /* end of test_dvi.c */ |
diff --git a/src/plugins/test_exiv2.c b/src/plugins/test_exiv2.c index 292ea18..e4e5319 100644 --- a/src/plugins/test_exiv2.c +++ b/src/plugins/test_exiv2.c | |||
@@ -36,305 +36,306 @@ | |||
36 | int | 36 | int |
37 | main (int argc, char *argv[]) | 37 | main (int argc, char *argv[]) |
38 | { | 38 | { |
39 | struct SolutionData exiv2_iptc_sol[] = | 39 | struct SolutionData exiv2_iptc_sol[] = { |
40 | { | 40 | { |
41 | { | 41 | EXTRACTOR_METATYPE_GPS_LATITUDE_REF, |
42 | EXTRACTOR_METATYPE_GPS_LATITUDE_REF, | 42 | EXTRACTOR_METAFORMAT_UTF8, |
43 | EXTRACTOR_METAFORMAT_UTF8, | 43 | "text/plain", |
44 | "text/plain", | 44 | "North", |
45 | "North", | 45 | strlen ("North") + 1, |
46 | strlen ("North") + 1, | 46 | 0 |
47 | 0 | 47 | }, |
48 | }, | 48 | { |
49 | { | 49 | EXTRACTOR_METATYPE_GPS_LATITUDE, |
50 | EXTRACTOR_METATYPE_GPS_LATITUDE, | 50 | EXTRACTOR_METAFORMAT_UTF8, |
51 | EXTRACTOR_METAFORMAT_UTF8, | 51 | "text/plain", |
52 | "text/plain", | 52 | "28deg 8' 17.585\" ", |
53 | "28deg 8' 17.585\" ", | 53 | strlen ("28deg 8' 17.585\" ") + 1, |
54 | strlen ("28deg 8' 17.585\" ") + 1, | 54 | 0 |
55 | 0 | 55 | }, |
56 | }, | 56 | { |
57 | { | 57 | EXTRACTOR_METATYPE_GPS_LONGITUDE_REF, |
58 | EXTRACTOR_METATYPE_GPS_LONGITUDE_REF, | 58 | EXTRACTOR_METAFORMAT_UTF8, |
59 | EXTRACTOR_METAFORMAT_UTF8, | 59 | "text/plain", |
60 | "text/plain", | 60 | "West", |
61 | "West", | 61 | strlen ("West") + 1, |
62 | strlen ("West") + 1, | 62 | 0 |
63 | 0 | 63 | }, |
64 | }, | 64 | { |
65 | { | 65 | EXTRACTOR_METATYPE_GPS_LONGITUDE, |
66 | EXTRACTOR_METATYPE_GPS_LONGITUDE, | 66 | EXTRACTOR_METAFORMAT_UTF8, |
67 | EXTRACTOR_METAFORMAT_UTF8, | 67 | "text/plain", |
68 | "text/plain", | 68 | "14deg 14' 21.713\" ", |
69 | "14deg 14' 21.713\" ", | 69 | strlen ("14deg 14' 21.713\" ") + 1, |
70 | strlen ("14deg 14' 21.713\" ") + 1, | 70 | 0 |
71 | 0 | 71 | }, |
72 | }, | 72 | { |
73 | { | 73 | EXTRACTOR_METATYPE_CAMERA_MAKE, |
74 | EXTRACTOR_METATYPE_CAMERA_MAKE, | 74 | EXTRACTOR_METAFORMAT_UTF8, |
75 | EXTRACTOR_METAFORMAT_UTF8, | 75 | "text/plain", |
76 | "text/plain", | 76 | "PENTAX Corporation", |
77 | "PENTAX Corporation", | 77 | strlen ("PENTAX Corporation") + 1, |
78 | strlen ("PENTAX Corporation") + 1, | 78 | 0 |
79 | 0 | 79 | }, |
80 | }, | 80 | { |
81 | { | 81 | EXTRACTOR_METATYPE_CAMERA_MODEL, |
82 | EXTRACTOR_METATYPE_CAMERA_MODEL, | 82 | EXTRACTOR_METAFORMAT_UTF8, |
83 | EXTRACTOR_METAFORMAT_UTF8, | 83 | "text/plain", |
84 | "text/plain", | 84 | "PENTAX Optio W30", |
85 | "PENTAX Optio W30", | 85 | strlen ("PENTAX Optio W30") + 1, |
86 | strlen ("PENTAX Optio W30") + 1, | 86 | 0 |
87 | 0 | 87 | }, |
88 | }, | 88 | { |
89 | { | 89 | EXTRACTOR_METATYPE_ORIENTATION, |
90 | EXTRACTOR_METATYPE_ORIENTATION, | 90 | EXTRACTOR_METAFORMAT_UTF8, |
91 | EXTRACTOR_METAFORMAT_UTF8, | 91 | "text/plain", |
92 | "text/plain", | 92 | "top, left", |
93 | "top, left", | 93 | strlen ("top, left") + 1, |
94 | strlen ("top, left") + 1, | 94 | 0 |
95 | 0 | 95 | }, |
96 | }, | 96 | { |
97 | { | 97 | EXTRACTOR_METATYPE_CREATION_DATE, |
98 | EXTRACTOR_METATYPE_CREATION_DATE, | 98 | EXTRACTOR_METAFORMAT_UTF8, |
99 | EXTRACTOR_METAFORMAT_UTF8, | 99 | "text/plain", |
100 | "text/plain", | 100 | "2008:06:29 16:06:10", |
101 | "2008:06:29 16:06:10", | 101 | strlen ("2008:06:29 16:06:10") + 1, |
102 | strlen ("2008:06:29 16:06:10") + 1, | 102 | 0 |
103 | 0 | 103 | }, |
104 | }, | 104 | { |
105 | { | 105 | EXTRACTOR_METATYPE_EXPOSURE_BIAS, |
106 | EXTRACTOR_METATYPE_EXPOSURE_BIAS, | 106 | EXTRACTOR_METAFORMAT_UTF8, |
107 | EXTRACTOR_METAFORMAT_UTF8, | 107 | "text/plain", |
108 | "text/plain", | 108 | "0 EV", |
109 | "0 EV", | 109 | strlen ("0 EV") + 1, |
110 | strlen ("0 EV") + 1, | 110 | 0 |
111 | 0 | 111 | }, |
112 | }, | 112 | { |
113 | { | 113 | EXTRACTOR_METATYPE_FLASH, |
114 | EXTRACTOR_METATYPE_FLASH, | 114 | EXTRACTOR_METAFORMAT_UTF8, |
115 | EXTRACTOR_METAFORMAT_UTF8, | 115 | "text/plain", |
116 | "text/plain", | 116 | "No, compulsory", |
117 | "No, compulsory", | 117 | strlen ("No, compulsory") + 1, |
118 | strlen ("No, compulsory") + 1, | 118 | 0 |
119 | 0 | 119 | }, |
120 | }, | 120 | { |
121 | { | 121 | EXTRACTOR_METATYPE_FOCAL_LENGTH, |
122 | EXTRACTOR_METATYPE_FOCAL_LENGTH, | 122 | EXTRACTOR_METAFORMAT_UTF8, |
123 | EXTRACTOR_METAFORMAT_UTF8, | 123 | "text/plain", |
124 | "text/plain", | 124 | "18.9 mm", |
125 | "18.9 mm", | 125 | strlen ("18.9 mm") + 1, |
126 | strlen ("18.9 mm") + 1, | 126 | 0 |
127 | 0 | 127 | }, |
128 | }, | 128 | { |
129 | { | 129 | EXTRACTOR_METATYPE_FOCAL_LENGTH_35MM, |
130 | EXTRACTOR_METATYPE_FOCAL_LENGTH_35MM, | 130 | EXTRACTOR_METAFORMAT_UTF8, |
131 | EXTRACTOR_METAFORMAT_UTF8, | 131 | "text/plain", |
132 | "text/plain", | 132 | "114.0 mm", |
133 | "114.0 mm", | 133 | strlen ("114.0 mm") + 1, |
134 | strlen ("114.0 mm") + 1, | 134 | 0 |
135 | 0 | 135 | }, |
136 | }, | 136 | { |
137 | { | 137 | EXTRACTOR_METATYPE_ISO_SPEED, |
138 | EXTRACTOR_METATYPE_ISO_SPEED, | 138 | EXTRACTOR_METAFORMAT_UTF8, |
139 | EXTRACTOR_METAFORMAT_UTF8, | 139 | "text/plain", |
140 | "text/plain", | 140 | "64", |
141 | "64", | 141 | strlen ("64") + 1, |
142 | strlen ("64") + 1, | 142 | 0 |
143 | 0 | 143 | }, |
144 | }, | 144 | { |
145 | { | 145 | EXTRACTOR_METATYPE_METERING_MODE, |
146 | EXTRACTOR_METATYPE_METERING_MODE, | 146 | EXTRACTOR_METAFORMAT_UTF8, |
147 | EXTRACTOR_METAFORMAT_UTF8, | 147 | "text/plain", |
148 | "text/plain", | 148 | "Multi-segment", |
149 | "Multi-segment", | 149 | strlen ("Multi-segment") + 1, |
150 | strlen ("Multi-segment") + 1, | 150 | 0 |
151 | 0 | 151 | }, |
152 | }, | 152 | { |
153 | { | 153 | EXTRACTOR_METATYPE_APERTURE, |
154 | EXTRACTOR_METATYPE_APERTURE, | 154 | EXTRACTOR_METAFORMAT_UTF8, |
155 | EXTRACTOR_METAFORMAT_UTF8, | 155 | "text/plain", |
156 | "text/plain", | 156 | "F8", |
157 | "F8", | 157 | strlen ("F8") + 1, |
158 | strlen ("F8") + 1, | 158 | 0 |
159 | 0 | 159 | }, |
160 | }, | 160 | { |
161 | { | 161 | EXTRACTOR_METATYPE_EXPOSURE, |
162 | EXTRACTOR_METATYPE_EXPOSURE, | 162 | EXTRACTOR_METAFORMAT_UTF8, |
163 | EXTRACTOR_METAFORMAT_UTF8, | 163 | "text/plain", |
164 | "text/plain", | 164 | "1/320 s", |
165 | "1/320 s", | 165 | strlen ("1/320 s") + 1, |
166 | strlen ("1/320 s") + 1, | 166 | 0 |
167 | 0 | 167 | }, |
168 | }, | 168 | { |
169 | { | 169 | EXTRACTOR_METATYPE_LOCATION_CITY, |
170 | EXTRACTOR_METATYPE_LOCATION_CITY, | 170 | EXTRACTOR_METAFORMAT_UTF8, |
171 | EXTRACTOR_METAFORMAT_UTF8, | 171 | "text/plain", |
172 | "text/plain", | 172 | "Los Verdes", |
173 | "Los Verdes", | 173 | strlen ("Los Verdes") + 1, |
174 | strlen ("Los Verdes") + 1, | 174 | 0 |
175 | 0 | 175 | }, |
176 | }, | 176 | { |
177 | { | 177 | EXTRACTOR_METATYPE_LOCATION_CITY, |
178 | EXTRACTOR_METATYPE_LOCATION_CITY, | 178 | EXTRACTOR_METAFORMAT_UTF8, |
179 | EXTRACTOR_METAFORMAT_UTF8, | 179 | "text/plain", |
180 | "text/plain", | 180 | "Los Verdes", |
181 | "Los Verdes", | 181 | strlen ("Los Verdes") + 1, |
182 | strlen ("Los Verdes") + 1, | 182 | 0 |
183 | 0 | 183 | }, |
184 | }, | 184 | { |
185 | { | 185 | EXTRACTOR_METATYPE_LOCATION_SUBLOCATION, |
186 | EXTRACTOR_METATYPE_LOCATION_SUBLOCATION, | 186 | EXTRACTOR_METAFORMAT_UTF8, |
187 | EXTRACTOR_METAFORMAT_UTF8, | 187 | "text/plain", |
188 | "text/plain", | 188 | "Fuerteventura", |
189 | "Fuerteventura", | 189 | strlen ("Fuerteventura") + 1, |
190 | strlen ("Fuerteventura") + 1, | 190 | 0 |
191 | 0 | 191 | }, |
192 | }, | 192 | { |
193 | { | 193 | EXTRACTOR_METATYPE_LOCATION_COUNTRY, |
194 | EXTRACTOR_METATYPE_LOCATION_COUNTRY, | 194 | EXTRACTOR_METAFORMAT_UTF8, |
195 | EXTRACTOR_METAFORMAT_UTF8, | 195 | "text/plain", |
196 | "text/plain", | 196 | "Spain", |
197 | "Spain", | 197 | strlen ("Spain") + 1, |
198 | strlen ("Spain") + 1, | 198 | 0 |
199 | 0 | 199 | }, |
200 | }, | 200 | { |
201 | { | 201 | EXTRACTOR_METATYPE_LOCATION_COUNTRY, |
202 | EXTRACTOR_METATYPE_LOCATION_COUNTRY, | 202 | EXTRACTOR_METAFORMAT_UTF8, |
203 | EXTRACTOR_METAFORMAT_UTF8, | 203 | "text/plain", |
204 | "text/plain", | 204 | "Spain", |
205 | "Spain", | 205 | strlen ("Spain") + 1, |
206 | strlen ("Spain") + 1, | 206 | 0 |
207 | 0 | 207 | }, |
208 | }, | 208 | { |
209 | { | 209 | EXTRACTOR_METATYPE_KEYWORDS, |
210 | EXTRACTOR_METATYPE_KEYWORDS, | 210 | EXTRACTOR_METAFORMAT_UTF8, |
211 | EXTRACTOR_METAFORMAT_UTF8, | 211 | "text/plain", |
212 | "text/plain", | 212 | "Fuerteventura", |
213 | "Fuerteventura", | 213 | strlen ("Fuerteventura") + 1, |
214 | strlen ("Fuerteventura") + 1, | 214 | 0 |
215 | 0 | 215 | }, |
216 | }, | 216 | { |
217 | { | 217 | EXTRACTOR_METATYPE_KEYWORDS, |
218 | EXTRACTOR_METATYPE_KEYWORDS, | 218 | EXTRACTOR_METAFORMAT_UTF8, |
219 | EXTRACTOR_METAFORMAT_UTF8, | 219 | "text/plain", |
220 | "text/plain", | 220 | "Landschaftsbild", |
221 | "Landschaftsbild", | 221 | strlen ("Landschaftsbild") + 1, |
222 | strlen ("Landschaftsbild") + 1, | 222 | 0 |
223 | 0 | 223 | }, |
224 | }, | 224 | { |
225 | { | 225 | EXTRACTOR_METATYPE_KEYWORDS, |
226 | EXTRACTOR_METATYPE_KEYWORDS, | 226 | EXTRACTOR_METAFORMAT_UTF8, |
227 | EXTRACTOR_METAFORMAT_UTF8, | 227 | "text/plain", |
228 | "text/plain", | 228 | "ProCenter Rene Egli", |
229 | "ProCenter Rene Egli", | 229 | strlen ("ProCenter Rene Egli") + 1, |
230 | strlen ("ProCenter Rene Egli") + 1, | 230 | 0 |
231 | 0 | 231 | }, |
232 | }, | 232 | { |
233 | { | 233 | EXTRACTOR_METATYPE_KEYWORDS, |
234 | EXTRACTOR_METATYPE_KEYWORDS, | 234 | EXTRACTOR_METAFORMAT_UTF8, |
235 | EXTRACTOR_METAFORMAT_UTF8, | 235 | "text/plain", |
236 | "text/plain", | 236 | "Sand", |
237 | "Sand", | 237 | strlen ("Sand") + 1, |
238 | strlen ("Sand") + 1, | 238 | 0 |
239 | 0 | 239 | }, |
240 | }, | 240 | { |
241 | { | 241 | EXTRACTOR_METATYPE_KEYWORDS, |
242 | EXTRACTOR_METATYPE_KEYWORDS, | 242 | EXTRACTOR_METAFORMAT_UTF8, |
243 | EXTRACTOR_METAFORMAT_UTF8, | 243 | "text/plain", |
244 | "text/plain", | 244 | "Sport", |
245 | "Sport", | 245 | strlen ("Sport") + 1, |
246 | strlen ("Sport") + 1, | 246 | 0 |
247 | 0 | 247 | }, |
248 | }, | 248 | { |
249 | { | 249 | EXTRACTOR_METATYPE_KEYWORDS, |
250 | EXTRACTOR_METATYPE_KEYWORDS, | 250 | EXTRACTOR_METAFORMAT_UTF8, |
251 | EXTRACTOR_METAFORMAT_UTF8, | 251 | "text/plain", |
252 | "text/plain", | 252 | "Urlaub", |
253 | "Urlaub", | 253 | strlen ("Urlaub") + 1, |
254 | strlen ("Urlaub") + 1, | 254 | 0 |
255 | 0 | 255 | }, |
256 | }, | 256 | { |
257 | { | 257 | EXTRACTOR_METATYPE_KEYWORDS, |
258 | EXTRACTOR_METATYPE_KEYWORDS, | 258 | EXTRACTOR_METAFORMAT_UTF8, |
259 | EXTRACTOR_METAFORMAT_UTF8, | 259 | "text/plain", |
260 | "text/plain", | 260 | "Was?", |
261 | "Was?", | 261 | strlen ("Was?") + 1, |
262 | strlen ("Was?") + 1, | 262 | 0 |
263 | 0 | 263 | }, |
264 | }, | 264 | { |
265 | { | 265 | EXTRACTOR_METATYPE_KEYWORDS, |
266 | EXTRACTOR_METATYPE_KEYWORDS, | 266 | EXTRACTOR_METAFORMAT_UTF8, |
267 | EXTRACTOR_METAFORMAT_UTF8, | 267 | "text/plain", |
268 | "text/plain", | 268 | "Wind", |
269 | "Wind", | 269 | strlen ("Wind") + 1, |
270 | strlen ("Wind") + 1, | 270 | 0 |
271 | 0 | 271 | }, |
272 | }, | 272 | { |
273 | { | 273 | EXTRACTOR_METATYPE_KEYWORDS, |
274 | EXTRACTOR_METATYPE_KEYWORDS, | 274 | EXTRACTOR_METAFORMAT_UTF8, |
275 | EXTRACTOR_METAFORMAT_UTF8, | 275 | "text/plain", |
276 | "text/plain", | 276 | "Windsurfen", |
277 | "Windsurfen", | 277 | strlen ("Windsurfen") + 1, |
278 | strlen ("Windsurfen") + 1, | 278 | 0 |
279 | 0 | 279 | }, |
280 | }, | 280 | { |
281 | { | 281 | EXTRACTOR_METATYPE_KEYWORDS, |
282 | EXTRACTOR_METATYPE_KEYWORDS, | 282 | EXTRACTOR_METAFORMAT_UTF8, |
283 | EXTRACTOR_METAFORMAT_UTF8, | 283 | "text/plain", |
284 | "text/plain", | 284 | "Wo?", |
285 | "Wo?", | 285 | strlen ("Wo?") + 1, |
286 | strlen ("Wo?") + 1, | 286 | 0 |
287 | 0 | 287 | }, |
288 | }, | 288 | { |
289 | { | 289 | EXTRACTOR_METATYPE_RATING, |
290 | EXTRACTOR_METATYPE_RATING, | 290 | EXTRACTOR_METAFORMAT_UTF8, |
291 | EXTRACTOR_METAFORMAT_UTF8, | 291 | "text/plain", |
292 | "text/plain", | 292 | "3", |
293 | "3", | 293 | strlen ("3") + 1, |
294 | strlen ("3") + 1, | 294 | 0 |
295 | 0 | 295 | }, |
296 | }, | 296 | { |
297 | { | 297 | EXTRACTOR_METATYPE_RATING, |
298 | EXTRACTOR_METATYPE_RATING, | 298 | EXTRACTOR_METAFORMAT_UTF8, |
299 | EXTRACTOR_METAFORMAT_UTF8, | 299 | "text/plain", |
300 | "text/plain", | 300 | "50", |
301 | "50", | 301 | strlen ("50") + 1, |
302 | strlen ("50") + 1, | 302 | 0 |
303 | 0 | 303 | }, |
304 | }, | 304 | { |
305 | { | 305 | EXTRACTOR_METATYPE_LOCATION_COUNTRY_CODE, |
306 | EXTRACTOR_METATYPE_LOCATION_COUNTRY_CODE, | 306 | EXTRACTOR_METAFORMAT_UTF8, |
307 | EXTRACTOR_METAFORMAT_UTF8, | 307 | "text/plain", |
308 | "text/plain", | 308 | "ES", |
309 | "ES", | 309 | strlen ("ES") + 1, |
310 | strlen ("ES") + 1, | 310 | 0 |
311 | 0 | 311 | }, |
312 | }, | 312 | { |
313 | { | 313 | EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE, |
314 | EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE, | 314 | EXTRACTOR_METAFORMAT_UTF8, |
315 | EXTRACTOR_METAFORMAT_UTF8, | 315 | "text/plain", |
316 | "text/plain", | 316 | "Optio W30 Ver 1.00", |
317 | "Optio W30 Ver 1.00", | 317 | strlen ("Optio W30 Ver 1.00") + 1, |
318 | strlen ("Optio W30 Ver 1.00") + 1, | 318 | 0 |
319 | 0 | 319 | }, |
320 | }, | 320 | { |
321 | { | 321 | EXTRACTOR_METATYPE_SUBJECT, |
322 | EXTRACTOR_METATYPE_SUBJECT, | 322 | EXTRACTOR_METAFORMAT_UTF8, |
323 | EXTRACTOR_METAFORMAT_UTF8, | 323 | "text/plain", |
324 | "text/plain", | 324 | "Wo?, Wo?|Fuerteventura, Was?, Was?|Anlass]|Urlaub, Was?|Aufnahme]|Landschaftsbild, Was?|Natur]|Wind, Was?|Natur]|Sand, Wo?|Fuerteventura|ProCenter Rene Egli, Was?|Sport, Was?|Sport|Windsurfen", |
325 | "Wo?, Wo?|Fuerteventura, Was?, Was?|Anlass]|Urlaub, Was?|Aufnahme]|Landschaftsbild, Was?|Natur]|Wind, Was?|Natur]|Sand, Wo?|Fuerteventura|ProCenter Rene Egli, Was?|Sport, Was?|Sport|Windsurfen", | 325 | strlen ( |
326 | strlen ("Wo?, Wo?|Fuerteventura, Was?, Was?|Anlass]|Urlaub, Was?|Aufnahme]|Landschaftsbild, Was?|Natur]|Wind, Was?|Natur]|Sand, Wo?|Fuerteventura|ProCenter Rene Egli, Was?|Sport, Was?|Sport|Windsurfen") + 1, | 326 | "Wo?, Wo?|Fuerteventura, Was?, Was?|Anlass]|Urlaub, Was?|Aufnahme]|Landschaftsbild, Was?|Natur]|Wind, Was?|Natur]|Sand, Wo?|Fuerteventura|ProCenter Rene Egli, Was?|Sport, Was?|Sport|Windsurfen") |
327 | 0 | 327 | + 1, |
328 | }, | 328 | 0 |
329 | { 0, 0, NULL, NULL, 0, -1 } | 329 | }, |
330 | }; | 330 | { 0, 0, NULL, NULL, 0, -1 } |
331 | struct ProblemSet ps[] = | 331 | }; |
332 | { | 332 | struct ProblemSet ps[] = { |
333 | { "testdata/exiv2_iptc.jpg", | 333 | { "testdata/exiv2_iptc.jpg", |
334 | exiv2_iptc_sol }, | 334 | exiv2_iptc_sol }, |
335 | { NULL, NULL } | 335 | { NULL, NULL } |
336 | }; | 336 | }; |
337 | return ET_main ("exiv2", ps); | 337 | return ET_main ("exiv2", ps); |
338 | } | 338 | } |
339 | 339 | ||
340 | |||
340 | /* end of test_exiv2.c */ | 341 | /* end of test_exiv2.c */ |
diff --git a/src/plugins/test_flac.c b/src/plugins/test_flac.c index 1fa39f3..64a16b4 100644 --- a/src/plugins/test_flac.c +++ b/src/plugins/test_flac.c | |||
@@ -26,7 +26,6 @@ | |||
26 | #include "test_lib.h" | 26 | #include "test_lib.h" |
27 | 27 | ||
28 | 28 | ||
29 | |||
30 | /** | 29 | /** |
31 | * Main function for the FLAC testcase. | 30 | * Main function for the FLAC testcase. |
32 | * | 31 | * |
@@ -37,39 +36,37 @@ | |||
37 | int | 36 | int |
38 | main (int argc, char *argv[]) | 37 | main (int argc, char *argv[]) |
39 | { | 38 | { |
40 | struct SolutionData kraftwerk_sol[] = | 39 | struct SolutionData kraftwerk_sol[] = { |
41 | { | ||
42 | { | ||
43 | EXTRACTOR_METATYPE_RESOURCE_TYPE, | ||
44 | EXTRACTOR_METAFORMAT_UTF8, | ||
45 | "text/plain", | ||
46 | "44100 Hz, 2 channels", | ||
47 | strlen ("44100 Hz, 2 channels") + 1, | ||
48 | 0 | ||
49 | }, | ||
50 | { | ||
51 | EXTRACTOR_METATYPE_TITLE, | ||
52 | EXTRACTOR_METAFORMAT_UTF8, | ||
53 | "text/plain", | ||
54 | "Test Title", | ||
55 | strlen ("Test Title") + 1, | ||
56 | 0 | ||
57 | }, | ||
58 | { 0, 0, NULL, NULL, 0, -1 } | ||
59 | }; | ||
60 | struct SolutionData alien_sol[] = | ||
61 | { | 40 | { |
62 | { 0, 0, NULL, NULL, 0, -1 } | 41 | EXTRACTOR_METATYPE_RESOURCE_TYPE, |
63 | }; | 42 | EXTRACTOR_METAFORMAT_UTF8, |
64 | struct ProblemSet ps[] = | 43 | "text/plain", |
44 | "44100 Hz, 2 channels", | ||
45 | strlen ("44100 Hz, 2 channels") + 1, | ||
46 | 0 | ||
47 | }, | ||
65 | { | 48 | { |
66 | { "testdata/flac_kraftwerk.flac", | 49 | EXTRACTOR_METATYPE_TITLE, |
67 | kraftwerk_sol }, | 50 | EXTRACTOR_METAFORMAT_UTF8, |
68 | { "testdata/mpeg_alien.mpg", | 51 | "text/plain", |
69 | alien_sol }, | 52 | "Test Title", |
70 | { NULL, NULL } | 53 | strlen ("Test Title") + 1, |
71 | }; | 54 | 0 |
55 | }, | ||
56 | { 0, 0, NULL, NULL, 0, -1 } | ||
57 | }; | ||
58 | struct SolutionData alien_sol[] = { | ||
59 | { 0, 0, NULL, NULL, 0, -1 } | ||
60 | }; | ||
61 | struct ProblemSet ps[] = { | ||
62 | { "testdata/flac_kraftwerk.flac", | ||
63 | kraftwerk_sol }, | ||
64 | { "testdata/mpeg_alien.mpg", | ||
65 | alien_sol }, | ||
66 | { NULL, NULL } | ||
67 | }; | ||
72 | return ET_main ("flac", ps); | 68 | return ET_main ("flac", ps); |
73 | } | 69 | } |
74 | 70 | ||
71 | |||
75 | /* end of test_flac.c */ | 72 | /* end of test_flac.c */ |
diff --git a/src/plugins/test_gif.c b/src/plugins/test_gif.c index e98f888..abe1e41 100644 --- a/src/plugins/test_gif.c +++ b/src/plugins/test_gif.c | |||
@@ -26,7 +26,6 @@ | |||
26 | #include "test_lib.h" | 26 | #include "test_lib.h" |
27 | 27 | ||
28 | 28 | ||
29 | |||
30 | /** | 29 | /** |
31 | * Main function for the GIF testcase. | 30 | * Main function for the GIF testcase. |
32 | * | 31 | * |
@@ -37,41 +36,40 @@ | |||
37 | int | 36 | int |
38 | main (int argc, char *argv[]) | 37 | main (int argc, char *argv[]) |
39 | { | 38 | { |
40 | struct SolutionData gif_image_sol[] = | 39 | struct SolutionData gif_image_sol[] = { |
40 | { | ||
41 | EXTRACTOR_METATYPE_MIMETYPE, | ||
42 | EXTRACTOR_METAFORMAT_UTF8, | ||
43 | "text/plain", | ||
44 | "image/gif", | ||
45 | strlen ("image/gif") + 1, | ||
46 | 0 | ||
47 | }, | ||
41 | { | 48 | { |
42 | { | 49 | EXTRACTOR_METATYPE_IMAGE_DIMENSIONS, |
43 | EXTRACTOR_METATYPE_MIMETYPE, | 50 | EXTRACTOR_METAFORMAT_UTF8, |
44 | EXTRACTOR_METAFORMAT_UTF8, | 51 | "text/plain", |
45 | "text/plain", | 52 | "4x4", |
46 | "image/gif", | 53 | strlen ("4x4") + 1, |
47 | strlen ("image/gif") + 1, | 54 | 0 |
48 | 0 | 55 | }, |
49 | }, | ||
50 | { | ||
51 | EXTRACTOR_METATYPE_IMAGE_DIMENSIONS, | ||
52 | EXTRACTOR_METAFORMAT_UTF8, | ||
53 | "text/plain", | ||
54 | "4x4", | ||
55 | strlen ("4x4") + 1, | ||
56 | 0 | ||
57 | }, | ||
58 | { | ||
59 | EXTRACTOR_METATYPE_COMMENT, | ||
60 | EXTRACTOR_METAFORMAT_C_STRING, | ||
61 | "text/plain", | ||
62 | "Testing keyword extraction\n", | ||
63 | strlen ("Testing keyword extraction\n"), | ||
64 | 0 | ||
65 | }, | ||
66 | { 0, 0, NULL, NULL, 0, -1 } | ||
67 | }; | ||
68 | struct ProblemSet ps[] = | ||
69 | { | 56 | { |
70 | { "testdata/gif_image.gif", | 57 | EXTRACTOR_METATYPE_COMMENT, |
71 | gif_image_sol }, | 58 | EXTRACTOR_METAFORMAT_C_STRING, |
72 | { NULL, NULL } | 59 | "text/plain", |
73 | }; | 60 | "Testing keyword extraction\n", |
61 | strlen ("Testing keyword extraction\n"), | ||
62 | 0 | ||
63 | }, | ||
64 | { 0, 0, NULL, NULL, 0, -1 } | ||
65 | }; | ||
66 | struct ProblemSet ps[] = { | ||
67 | { "testdata/gif_image.gif", | ||
68 | gif_image_sol }, | ||
69 | { NULL, NULL } | ||
70 | }; | ||
74 | return ET_main ("gif", ps); | 71 | return ET_main ("gif", ps); |
75 | } | 72 | } |
76 | 73 | ||
74 | |||
77 | /* end of test_gif.c */ | 75 | /* end of test_gif.c */ |
diff --git a/src/plugins/test_gstreamer.c b/src/plugins/test_gstreamer.c index 0f3d9ca..0210e54 100644 --- a/src/plugins/test_gstreamer.c +++ b/src/plugins/test_gstreamer.c | |||
@@ -42,67 +42,69 @@ discoverer_main (GstDiscoverer *dc, const char *filename) | |||
42 | GstDiscovererInfo *info; | 42 | GstDiscovererInfo *info; |
43 | GstDiscovererResult result; | 43 | GstDiscovererResult result; |
44 | 44 | ||
45 | if (! gst_uri_is_valid (filename)) | 45 | if (! gst_uri_is_valid (filename)) |
46 | { | ||
47 | if (! g_path_is_absolute (filename)) | ||
46 | { | 48 | { |
47 | if (! g_path_is_absolute (filename)) | 49 | gchar *cur_dir; |
48 | { | 50 | |
49 | gchar *cur_dir; | 51 | cur_dir = g_get_current_dir (); |
50 | 52 | path = g_build_filename (cur_dir, filename, NULL); | |
51 | cur_dir = g_get_current_dir (); | 53 | g_free (cur_dir); |
52 | path = g_build_filename (cur_dir, filename, NULL); | ||
53 | g_free (cur_dir); | ||
54 | } | ||
55 | else | ||
56 | { | ||
57 | path = g_strdup (filename); | ||
58 | } | ||
59 | |||
60 | uri = g_filename_to_uri (path, NULL, &err); | ||
61 | g_free (path); | ||
62 | path = NULL; | ||
63 | |||
64 | if (err) | ||
65 | { | ||
66 | g_warning ("Couldn't convert filename %s to URI: %s\n", filename, err->message); | ||
67 | g_error_free (err); | ||
68 | return GST_DISCOVERER_ERROR; | ||
69 | } | ||
70 | } | 54 | } |
71 | else | 55 | else |
72 | { | 56 | { |
73 | uri = g_strdup (filename); | 57 | path = g_strdup (filename); |
74 | } | 58 | } |
75 | info = gst_discoverer_discover_uri (dc, uri, &err); | 59 | |
76 | result = gst_discoverer_info_get_result (info); | 60 | uri = g_filename_to_uri (path, NULL, &err); |
77 | switch (result) | 61 | g_free (path); |
62 | path = NULL; | ||
63 | |||
64 | if (err) | ||
78 | { | 65 | { |
79 | case GST_DISCOVERER_OK: | 66 | g_warning ("Couldn't convert filename %s to URI: %s\n", filename, |
80 | break; | 67 | err->message); |
81 | case GST_DISCOVERER_URI_INVALID: | 68 | g_error_free (err); |
82 | g_print ("URI %s is not valid\n", uri); | 69 | return GST_DISCOVERER_ERROR; |
83 | break; | 70 | } |
84 | case GST_DISCOVERER_ERROR: | 71 | } |
85 | g_print ("An error was encountered while discovering the file %s\n", filename); | 72 | else |
86 | g_print (" %s\n", err->message); | 73 | { |
87 | break; | 74 | uri = g_strdup (filename); |
88 | case GST_DISCOVERER_TIMEOUT: | 75 | } |
89 | g_print ("Analyzing URI %s timed out\n", uri); | 76 | info = gst_discoverer_discover_uri (dc, uri, &err); |
90 | break; | 77 | result = gst_discoverer_info_get_result (info); |
91 | case GST_DISCOVERER_BUSY: | 78 | switch (result) |
92 | g_print ("Discoverer was busy\n"); | 79 | { |
93 | break; | 80 | case GST_DISCOVERER_OK: |
94 | case GST_DISCOVERER_MISSING_PLUGINS: | 81 | break; |
95 | g_print ("Will skip %s: missing plugins\n", filename); | 82 | case GST_DISCOVERER_URI_INVALID: |
96 | break; | 83 | g_print ("URI %s is not valid\n", uri); |
97 | default: | 84 | break; |
98 | g_print ("Unexpected result %d\n", result); | 85 | case GST_DISCOVERER_ERROR: |
99 | break; | 86 | g_print ("An error was encountered while discovering the file %s\n", |
100 | } | 87 | filename); |
88 | g_print (" %s\n", err->message); | ||
89 | break; | ||
90 | case GST_DISCOVERER_TIMEOUT: | ||
91 | g_print ("Analyzing URI %s timed out\n", uri); | ||
92 | break; | ||
93 | case GST_DISCOVERER_BUSY: | ||
94 | g_print ("Discoverer was busy\n"); | ||
95 | break; | ||
96 | case GST_DISCOVERER_MISSING_PLUGINS: | ||
97 | g_print ("Will skip %s: missing plugins\n", filename); | ||
98 | break; | ||
99 | default: | ||
100 | g_print ("Unexpected result %d\n", result); | ||
101 | break; | ||
102 | } | ||
101 | if (err) | 103 | if (err) |
102 | g_error_free (err); | 104 | g_error_free (err); |
103 | gst_discoverer_info_unref (info); | 105 | gst_discoverer_info_unref (info); |
104 | g_free (uri); | 106 | g_free (uri); |
105 | 107 | ||
106 | return result; | 108 | return result; |
107 | } | 109 | } |
108 | 110 | ||
@@ -124,11 +126,11 @@ main (int argc, char *argv[]) | |||
124 | 126 | ||
125 | gst_init (&argc, &argv); | 127 | gst_init (&argc, &argv); |
126 | dc = gst_discoverer_new (10 * GST_SECOND, &err); | 128 | dc = gst_discoverer_new (10 * GST_SECOND, &err); |
127 | if (NULL == dc) | 129 | if (NULL == dc) |
128 | { | 130 | { |
129 | g_print ("Error initializing: %s\n", err->message); | 131 | g_print ("Error initializing: %s\n", err->message); |
130 | return 0; | 132 | return 0; |
131 | } | 133 | } |
132 | if (NULL != err) | 134 | if (NULL != err) |
133 | g_error_free (err); | 135 | g_error_free (err); |
134 | 136 | ||
@@ -136,171 +138,170 @@ main (int argc, char *argv[]) | |||
136 | if (GST_DISCOVERER_MISSING_PLUGINS != pre_test) | 138 | if (GST_DISCOVERER_MISSING_PLUGINS != pre_test) |
137 | { | 139 | { |
138 | int test_result; | 140 | int test_result; |
139 | struct SolutionData thirty_and_thirtythree_sol[] = | 141 | struct SolutionData thirty_and_thirtythree_sol[] = { |
140 | { | 142 | { |
141 | { | 143 | EXTRACTOR_METATYPE_DURATION, |
142 | EXTRACTOR_METATYPE_DURATION, | 144 | EXTRACTOR_METAFORMAT_UTF8, |
143 | EXTRACTOR_METAFORMAT_UTF8, | 145 | "text/plain", |
144 | "text/plain", | 146 | "0:00:05.061000000", |
145 | "0:00:05.061000000", | 147 | strlen ("0:00:05.061000000") + 1, |
146 | strlen ("0:00:05.061000000") + 1, | 148 | 0 |
147 | 0 | 149 | }, |
148 | }, | 150 | { |
149 | { | 151 | EXTRACTOR_METATYPE_TRACK_NUMBER, |
150 | EXTRACTOR_METATYPE_TRACK_NUMBER, | 152 | EXTRACTOR_METAFORMAT_UTF8, |
151 | EXTRACTOR_METAFORMAT_UTF8, | 153 | "text/plain", |
152 | "text/plain", | 154 | "21", |
153 | "21", | 155 | strlen ("21") + 1, |
154 | strlen ("21") + 1, | 156 | 0 |
155 | 0 | 157 | }, |
156 | }, | 158 | { |
157 | { | 159 | EXTRACTOR_METATYPE_ALBUM, |
158 | EXTRACTOR_METATYPE_ALBUM, | 160 | EXTRACTOR_METAFORMAT_UTF8, |
159 | EXTRACTOR_METAFORMAT_UTF8, | 161 | "text/plain", |
160 | "text/plain", | 162 | "Zee Album", |
161 | "Zee Album", | 163 | strlen ("Zee Album") + 1, |
162 | strlen ("Zee Album") + 1, | 164 | 0 |
163 | 0 | 165 | }, |
164 | }, | 166 | { |
165 | { | 167 | EXTRACTOR_METATYPE_CREATION_TIME, |
166 | EXTRACTOR_METATYPE_CREATION_TIME, | 168 | EXTRACTOR_METAFORMAT_UTF8, |
167 | EXTRACTOR_METAFORMAT_UTF8, | 169 | "text/plain", |
168 | "text/plain", | 170 | "9999", |
169 | "9999", | 171 | strlen ("9999") + 1, |
170 | strlen ("9999") + 1, | 172 | 0 |
171 | 0 | 173 | }, |
172 | }, | 174 | { |
173 | { | 175 | EXTRACTOR_METATYPE_ARTIST, |
174 | EXTRACTOR_METATYPE_ARTIST, | 176 | EXTRACTOR_METAFORMAT_UTF8, |
175 | EXTRACTOR_METAFORMAT_UTF8, | 177 | "text/plain", |
176 | "text/plain", | 178 | "All performed by Nobody", |
177 | "All performed by Nobody", | 179 | strlen ("All performed by Nobody") + 1, |
178 | strlen ("All performed by Nobody") + 1, | 180 | 0 |
179 | 0 | 181 | }, |
180 | }, | 182 | { |
181 | { | 183 | EXTRACTOR_METATYPE_ARTIST, |
182 | EXTRACTOR_METATYPE_ARTIST, | 184 | EXTRACTOR_METAFORMAT_UTF8, |
183 | EXTRACTOR_METAFORMAT_UTF8, | 185 | "text/plain", |
184 | "text/plain", | 186 | "This Artist Contributed", |
185 | "This Artist Contributed", | 187 | strlen ("This Artist Contributed") + 1, |
186 | strlen ("This Artist Contributed") + 1, | 188 | 0 |
187 | 0 | 189 | }, |
188 | }, | 190 | { |
189 | { | 191 | EXTRACTOR_METATYPE_TITLE, |
190 | EXTRACTOR_METATYPE_TITLE, | 192 | EXTRACTOR_METAFORMAT_UTF8, |
191 | EXTRACTOR_METAFORMAT_UTF8, | 193 | "text/plain", |
192 | "text/plain", | 194 | "Some title", |
193 | "Some title", | 195 | strlen ("Some title") + 1, |
194 | strlen ("Some title") + 1, | 196 | 0 |
195 | 0 | 197 | }, |
196 | }, | 198 | /* Suggest a fix to gst devs; should be a comment, not description */ |
197 | /* Suggest a fix to gst devs; should be a comment, not description */ | 199 | { |
198 | { | 200 | EXTRACTOR_METATYPE_DESCRIPTION, |
199 | EXTRACTOR_METATYPE_DESCRIPTION, | 201 | EXTRACTOR_METAFORMAT_UTF8, |
200 | EXTRACTOR_METAFORMAT_UTF8, | 202 | "text/plain", |
201 | "text/plain", | 203 | "A witty comment", |
202 | "A witty comment", | 204 | strlen ("A witty comment") + 1, |
203 | strlen ("A witty comment") + 1, | 205 | 0 |
204 | 0 | 206 | }, |
205 | }, | 207 | { |
206 | { | 208 | EXTRACTOR_METATYPE_CONTAINER_FORMAT, |
207 | EXTRACTOR_METATYPE_CONTAINER_FORMAT, | 209 | EXTRACTOR_METAFORMAT_UTF8, |
208 | EXTRACTOR_METAFORMAT_UTF8, | 210 | "text/plain", |
209 | "text/plain", | 211 | "ASF", |
210 | "ASF", | 212 | strlen ("ASF") + 1, |
211 | strlen ("ASF") + 1, | 213 | 0 |
212 | 0 | 214 | }, |
213 | }, | 215 | { |
214 | { | 216 | EXTRACTOR_METATYPE_AUDIO_CODEC, |
215 | EXTRACTOR_METATYPE_AUDIO_CODEC, | 217 | EXTRACTOR_METAFORMAT_UTF8, |
216 | EXTRACTOR_METAFORMAT_UTF8, | 218 | "text/plain", |
217 | "text/plain", | 219 | "WMA Version 8", |
218 | "WMA Version 8", | 220 | strlen ("WMA Version 8") + 1, |
219 | strlen ("WMA Version 8") + 1, | 221 | 0 |
220 | 0 | 222 | }, |
221 | }, | 223 | { |
222 | { | 224 | EXTRACTOR_METATYPE_MIMETYPE, |
223 | EXTRACTOR_METATYPE_MIMETYPE, | 225 | EXTRACTOR_METAFORMAT_UTF8, |
224 | EXTRACTOR_METAFORMAT_UTF8, | 226 | "text/plain", |
225 | "text/plain", | 227 | "video/x-ms-asf", |
226 | "video/x-ms-asf", | 228 | strlen ("video/x-ms-asf") + 1, |
227 | strlen ("video/x-ms-asf") + 1, | 229 | 0 |
228 | 0 | 230 | }, |
229 | }, | 231 | { |
230 | { | 232 | EXTRACTOR_METATYPE_MIMETYPE, |
231 | EXTRACTOR_METATYPE_MIMETYPE, | 233 | EXTRACTOR_METAFORMAT_UTF8, |
232 | EXTRACTOR_METAFORMAT_UTF8, | 234 | "text/plain", |
233 | "text/plain", | 235 | "audio/x-wma", |
234 | "audio/x-wma", | 236 | strlen ("audio/x-wma") + 1, |
235 | strlen ("audio/x-wma") + 1, | 237 | 0 |
236 | 0 | 238 | }, |
237 | }, | 239 | { |
238 | { | 240 | EXTRACTOR_METATYPE_UNKNOWN, |
239 | EXTRACTOR_METATYPE_UNKNOWN, | 241 | EXTRACTOR_METAFORMAT_UTF8, |
240 | EXTRACTOR_METAFORMAT_UTF8, | 242 | "text/plain", |
241 | "text/plain", | 243 | "wmaversion=2", |
242 | "wmaversion=2", | 244 | strlen ("wmaversion=2") + 1, |
243 | strlen ("wmaversion=2") + 1, | 245 | 0 |
244 | 0 | 246 | }, |
245 | }, | 247 | { |
246 | { | 248 | EXTRACTOR_METATYPE_UNKNOWN, |
247 | EXTRACTOR_METATYPE_UNKNOWN, | 249 | EXTRACTOR_METAFORMAT_UTF8, |
248 | EXTRACTOR_METAFORMAT_UTF8, | 250 | "text/plain", |
249 | "text/plain", | 251 | "bitrate=96024", |
250 | "bitrate=96024", | 252 | strlen ("bitrate=96024") + 1, |
251 | strlen ("bitrate=96024") + 1, | 253 | 0 |
252 | 0 | 254 | }, |
253 | }, | 255 | { |
254 | { | 256 | EXTRACTOR_METATYPE_UNKNOWN, |
255 | EXTRACTOR_METATYPE_UNKNOWN, | 257 | EXTRACTOR_METAFORMAT_UTF8, |
256 | EXTRACTOR_METAFORMAT_UTF8, | 258 | "text/plain", |
257 | "text/plain", | 259 | "block_align=4459", |
258 | "block_align=4459", | 260 | strlen ("block_align=4459") + 1, |
259 | strlen ("block_align=4459") + 1, | 261 | 0 |
260 | 0 | 262 | }, |
261 | }, | 263 | { |
262 | { | 264 | EXTRACTOR_METATYPE_AUDIO_LANGUAGE, |
263 | EXTRACTOR_METATYPE_AUDIO_LANGUAGE, | 265 | EXTRACTOR_METAFORMAT_UTF8, |
264 | EXTRACTOR_METAFORMAT_UTF8, | 266 | "text/plain", |
265 | "text/plain", | 267 | "en", |
266 | "en", | 268 | strlen ("en") + 1, |
267 | strlen ("en") + 1, | 269 | 0 |
268 | 0 | 270 | }, |
269 | }, | 271 | { |
270 | { | 272 | EXTRACTOR_METATYPE_CHANNELS, |
271 | EXTRACTOR_METATYPE_CHANNELS, | 273 | EXTRACTOR_METAFORMAT_UTF8, |
272 | EXTRACTOR_METAFORMAT_UTF8, | 274 | "text/plain", |
273 | "text/plain", | 275 | "2", |
274 | "2", | 276 | strlen ("2") + 1, |
275 | strlen ("2") + 1, | 277 | 0 |
276 | 0 | 278 | }, |
277 | }, | 279 | { |
278 | { | 280 | EXTRACTOR_METATYPE_SAMPLE_RATE, |
279 | EXTRACTOR_METATYPE_SAMPLE_RATE, | 281 | EXTRACTOR_METAFORMAT_UTF8, |
280 | EXTRACTOR_METAFORMAT_UTF8, | 282 | "text/plain", |
281 | "text/plain", | 283 | "44100", |
282 | "44100", | 284 | strlen ("44100") + 1, |
283 | strlen ("44100") + 1, | 285 | 0 |
284 | 0 | 286 | }, |
285 | }, | 287 | { |
286 | { | 288 | EXTRACTOR_METATYPE_AUDIO_DEPTH, |
287 | EXTRACTOR_METATYPE_AUDIO_DEPTH, | 289 | EXTRACTOR_METAFORMAT_UTF8, |
288 | EXTRACTOR_METAFORMAT_UTF8, | 290 | "text/plain", |
289 | "text/plain", | 291 | "16", |
290 | "16", | 292 | strlen ("16") + 1, |
291 | strlen ("16") + 1, | 293 | 0 |
292 | 0 | 294 | }, |
293 | }, | 295 | { 0, 0, NULL, NULL, 0, -1 } |
294 | { 0, 0, NULL, NULL, 0, -1 } | 296 | }; |
295 | }; | 297 | struct ProblemSet ps[] = { |
296 | struct ProblemSet ps[] = | 298 | { "testdata/gstreamer_30_and_33.asf", thirty_and_thirtythree_sol }, |
297 | { | 299 | { NULL, NULL } |
298 | { "testdata/gstreamer_30_and_33.asf", thirty_and_thirtythree_sol }, | 300 | }; |
299 | { NULL, NULL } | ||
300 | }; | ||
301 | g_print ("Running asf test on GStreamer:\n"); | 301 | g_print ("Running asf test on GStreamer:\n"); |
302 | test_result = (0 == ET_main ("gstreamer", ps) ? 0 : 1); | 302 | test_result = (0 == ET_main ("gstreamer", ps) ? 0 : 1); |
303 | g_print ("asf GStreamer test result: %s\n", test_result == 0 ? "OK" : "FAILED"); | 303 | g_print ("asf GStreamer test result: %s\n", test_result == 0 ? "OK" : |
304 | "FAILED"); | ||
304 | result += test_result; | 305 | result += test_result; |
305 | } | 306 | } |
306 | 307 | ||
@@ -308,401 +309,399 @@ main (int argc, char *argv[]) | |||
308 | if (pre_test != GST_DISCOVERER_MISSING_PLUGINS) | 309 | if (pre_test != GST_DISCOVERER_MISSING_PLUGINS) |
309 | { | 310 | { |
310 | int test_result; | 311 | int test_result; |
311 | struct SolutionData barsandtone_sol[] = | 312 | struct SolutionData barsandtone_sol[] = { |
312 | { | 313 | { |
313 | { | 314 | EXTRACTOR_METATYPE_DURATION, |
314 | EXTRACTOR_METATYPE_DURATION, | 315 | EXTRACTOR_METAFORMAT_UTF8, |
315 | EXTRACTOR_METAFORMAT_UTF8, | 316 | "text/plain", |
316 | "text/plain", | 317 | "0:00:06.060000000", |
317 | "0:00:06.060000000", | 318 | strlen ("0:00:06.060000000") + 1, |
318 | strlen ("0:00:06.060000000") + 1, | 319 | 0 |
319 | 0 | 320 | }, |
320 | }, | 321 | { |
321 | { | 322 | EXTRACTOR_METATYPE_MIMETYPE, |
322 | EXTRACTOR_METATYPE_MIMETYPE, | 323 | EXTRACTOR_METAFORMAT_UTF8, |
323 | EXTRACTOR_METAFORMAT_UTF8, | 324 | "text/plain", |
324 | "text/plain", | 325 | "video/x-flv", |
325 | "video/x-flv", | 326 | strlen ("video/x-flv") + 1, |
326 | strlen ("video/x-flv") + 1, | 327 | 0 |
327 | 0 | 328 | }, |
328 | }, | 329 | { |
329 | { | 330 | EXTRACTOR_METATYPE_MIMETYPE, |
330 | EXTRACTOR_METATYPE_MIMETYPE, | 331 | EXTRACTOR_METAFORMAT_UTF8, |
331 | EXTRACTOR_METAFORMAT_UTF8, | 332 | "text/plain", |
332 | "text/plain", | 333 | "video/x-vp6-flash", |
333 | "video/x-vp6-flash", | 334 | strlen ("video/x-vp6-flash") + 1, |
334 | strlen ("video/x-vp6-flash") + 1, | 335 | 0 |
335 | 0 | 336 | }, |
336 | }, | 337 | { |
337 | { | 338 | EXTRACTOR_METATYPE_VIDEO_DURATION, |
338 | EXTRACTOR_METATYPE_VIDEO_DURATION, | 339 | EXTRACTOR_METAFORMAT_UTF8, |
339 | EXTRACTOR_METAFORMAT_UTF8, | 340 | "text/plain", |
340 | "text/plain", | 341 | "0:00:06.000000000", |
341 | "0:00:06.000000000", | 342 | strlen ("0:00:06.000000000") + 1, |
342 | strlen ("0:00:06.000000000") + 1, | 343 | 0 |
343 | 0 | 344 | }, |
344 | }, | 345 | { |
345 | { | 346 | EXTRACTOR_METATYPE_AUDIO_CODEC, |
346 | EXTRACTOR_METATYPE_AUDIO_CODEC, | 347 | EXTRACTOR_METAFORMAT_UTF8, |
347 | EXTRACTOR_METAFORMAT_UTF8, | 348 | "text/plain", |
348 | "text/plain", | 349 | "MPEG-1 Layer 3 (MP3)", |
349 | "MPEG-1 Layer 3 (MP3)", | 350 | strlen ("MPEG-1 Layer 3 (MP3)") + 1, |
350 | strlen ("MPEG-1 Layer 3 (MP3)") + 1, | 351 | 0 |
351 | 0 | 352 | }, |
352 | }, | 353 | { |
353 | { | 354 | EXTRACTOR_METATYPE_VIDEO_CODEC, |
354 | EXTRACTOR_METATYPE_VIDEO_CODEC, | 355 | EXTRACTOR_METAFORMAT_UTF8, |
355 | EXTRACTOR_METAFORMAT_UTF8, | 356 | "text/plain", |
356 | "text/plain", | 357 | "On2 VP6/Flash", |
357 | "On2 VP6/Flash", | 358 | strlen ("On2 VP6/Flash") + 1, |
358 | strlen ("On2 VP6/Flash") + 1, | 359 | 0 |
359 | 0 | 360 | }, |
360 | }, | 361 | { |
361 | { | 362 | EXTRACTOR_METATYPE_VIDEO_DIMENSIONS, |
362 | EXTRACTOR_METATYPE_VIDEO_DIMENSIONS, | 363 | EXTRACTOR_METAFORMAT_UTF8, |
363 | EXTRACTOR_METAFORMAT_UTF8, | 364 | "text/plain", |
364 | "text/plain", | 365 | "368x288", |
365 | "368x288", | 366 | strlen ("368x288") + 1, |
366 | strlen ("368x288") + 1, | 367 | 0 |
367 | 0 | 368 | }, |
368 | }, | 369 | { |
369 | { | 370 | EXTRACTOR_METATYPE_FRAME_RATE, |
370 | EXTRACTOR_METATYPE_FRAME_RATE, | 371 | EXTRACTOR_METAFORMAT_UTF8, |
371 | EXTRACTOR_METAFORMAT_UTF8, | 372 | "text/plain", |
372 | "text/plain", | 373 | "10/1", |
373 | "10/1", | 374 | strlen ("10/1") + 1, |
374 | strlen ("10/1") + 1, | 375 | 0 |
375 | 0 | 376 | }, |
376 | }, | 377 | { |
377 | { | 378 | EXTRACTOR_METATYPE_PIXEL_ASPECT_RATIO, |
378 | EXTRACTOR_METATYPE_PIXEL_ASPECT_RATIO, | 379 | EXTRACTOR_METAFORMAT_UTF8, |
379 | EXTRACTOR_METAFORMAT_UTF8, | 380 | "text/plain", |
380 | "text/plain", | 381 | "1/1", |
381 | "1/1", | 382 | strlen ("1/1") + 1, |
382 | strlen ("1/1") + 1, | 383 | 0 |
383 | 0 | 384 | }, |
384 | }, | 385 | { |
385 | { | 386 | EXTRACTOR_METATYPE_MIMETYPE, |
386 | EXTRACTOR_METATYPE_MIMETYPE, | 387 | EXTRACTOR_METAFORMAT_UTF8, |
387 | EXTRACTOR_METAFORMAT_UTF8, | 388 | "text/plain", |
388 | "text/plain", | 389 | "audio/mpeg", |
389 | "audio/mpeg", | 390 | strlen ("audio/mpeg") + 1, |
390 | strlen ("audio/mpeg") + 1, | 391 | 0 |
391 | 0 | 392 | }, |
392 | }, | 393 | { |
393 | { | 394 | EXTRACTOR_METATYPE_UNKNOWN, |
394 | EXTRACTOR_METATYPE_UNKNOWN, | 395 | EXTRACTOR_METAFORMAT_UTF8, |
395 | EXTRACTOR_METAFORMAT_UTF8, | 396 | "text/plain", |
396 | "text/plain", | 397 | "mpegversion=1", |
397 | "mpegversion=1", | 398 | strlen ("mpegversion=1") + 1, |
398 | strlen ("mpegversion=1") + 1, | 399 | 0 |
399 | 0 | 400 | }, |
400 | }, | 401 | { |
401 | { | 402 | EXTRACTOR_METATYPE_UNKNOWN, |
402 | EXTRACTOR_METATYPE_UNKNOWN, | 403 | EXTRACTOR_METAFORMAT_UTF8, |
403 | EXTRACTOR_METAFORMAT_UTF8, | 404 | "text/plain", |
404 | "text/plain", | 405 | "mpegaudioversion=1", |
405 | "mpegaudioversion=1", | 406 | strlen ("mpegaudioversion=1") + 1, |
406 | strlen ("mpegaudioversion=1") + 1, | 407 | 0 |
407 | 0 | 408 | }, |
408 | }, | 409 | { |
409 | { | 410 | EXTRACTOR_METATYPE_UNKNOWN, |
410 | EXTRACTOR_METATYPE_UNKNOWN, | 411 | EXTRACTOR_METAFORMAT_UTF8, |
411 | EXTRACTOR_METAFORMAT_UTF8, | 412 | "text/plain", |
412 | "text/plain", | 413 | "layer=3", |
413 | "layer=3", | 414 | strlen ("layer=3") + 1, |
414 | strlen ("layer=3") + 1, | 415 | 0 |
415 | 0 | 416 | }, |
416 | }, | 417 | { |
417 | { | 418 | EXTRACTOR_METATYPE_UNKNOWN, |
418 | EXTRACTOR_METATYPE_UNKNOWN, | 419 | EXTRACTOR_METAFORMAT_UTF8, |
419 | EXTRACTOR_METAFORMAT_UTF8, | 420 | "text/plain", |
420 | "text/plain", | 421 | "parsed=true", |
421 | "parsed=true", | 422 | strlen ("parsed=true") + 1, |
422 | strlen ("parsed=true") + 1, | 423 | 0 |
423 | 0 | 424 | }, |
424 | }, | 425 | { |
425 | { | 426 | EXTRACTOR_METATYPE_AUDIO_DURATION, |
426 | EXTRACTOR_METATYPE_AUDIO_DURATION, | 427 | EXTRACTOR_METAFORMAT_UTF8, |
427 | EXTRACTOR_METAFORMAT_UTF8, | 428 | "text/plain", |
428 | "text/plain", | 429 | "0:00:06.000000000", |
429 | "0:00:06.000000000", | 430 | strlen ("0:00:06.000000000") + 1, |
430 | strlen ("0:00:06.000000000") + 1, | 431 | 0 |
431 | 0 | 432 | }, |
432 | }, | 433 | /* Yes, again. This seems to be a bug/feature of the element that |
433 | /* Yes, again. This seems to be a bug/feature of the element that | 434 | * gives us these streams; this doesn't happen when discovering |
434 | * gives us these streams; this doesn't happen when discovering | 435 | * Matroska files, for example. Or maybe file itself is made that way. |
435 | * Matroska files, for example. Or maybe file itself is made that way. | 436 | */ |
436 | */ | 437 | { |
437 | { | 438 | EXTRACTOR_METATYPE_AUDIO_CODEC, |
438 | EXTRACTOR_METATYPE_AUDIO_CODEC, | 439 | EXTRACTOR_METAFORMAT_UTF8, |
439 | EXTRACTOR_METAFORMAT_UTF8, | 440 | "text/plain", |
440 | "text/plain", | 441 | "MPEG-1 Layer 3 (MP3)", |
441 | "MPEG-1 Layer 3 (MP3)", | 442 | strlen ("MPEG-1 Layer 3 (MP3)") + 1, |
442 | strlen ("MPEG-1 Layer 3 (MP3)") + 1, | 443 | 0 |
443 | 0 | 444 | }, |
444 | }, | 445 | { |
445 | { | 446 | EXTRACTOR_METATYPE_VIDEO_CODEC, |
446 | EXTRACTOR_METATYPE_VIDEO_CODEC, | 447 | EXTRACTOR_METAFORMAT_UTF8, |
447 | EXTRACTOR_METAFORMAT_UTF8, | 448 | "text/plain", |
448 | "text/plain", | 449 | "On2 VP6/Flash", |
449 | "On2 VP6/Flash", | 450 | strlen ("On2 VP6/Flash") + 1, |
450 | strlen ("On2 VP6/Flash") + 1, | 451 | 0 |
451 | 0 | 452 | }, |
452 | }, | 453 | { |
453 | { | 454 | EXTRACTOR_METATYPE_UNKNOWN, |
454 | EXTRACTOR_METATYPE_UNKNOWN, | 455 | EXTRACTOR_METAFORMAT_UTF8, |
455 | EXTRACTOR_METAFORMAT_UTF8, | 456 | "text/plain", |
456 | "text/plain", | 457 | "has-crc=false", |
457 | "has-crc=false", | 458 | strlen ("has-crc=false") + 1, |
458 | strlen ("has-crc=false") + 1, | 459 | 0 |
459 | 0 | 460 | }, |
460 | }, | 461 | { |
461 | { | 462 | EXTRACTOR_METATYPE_UNKNOWN, |
462 | EXTRACTOR_METATYPE_UNKNOWN, | 463 | EXTRACTOR_METAFORMAT_UTF8, |
463 | EXTRACTOR_METAFORMAT_UTF8, | 464 | "text/plain", |
464 | "text/plain", | 465 | "channel-mode=joint-stereo", |
465 | "channel-mode=joint-stereo", | 466 | strlen ("channel-mode=joint-stereo") + 1, |
466 | strlen ("channel-mode=joint-stereo") + 1, | 467 | 0 |
467 | 0 | 468 | }, |
468 | }, | 469 | { |
469 | { | 470 | EXTRACTOR_METATYPE_CHANNELS, |
470 | EXTRACTOR_METATYPE_CHANNELS, | 471 | EXTRACTOR_METAFORMAT_UTF8, |
471 | EXTRACTOR_METAFORMAT_UTF8, | 472 | "text/plain", |
472 | "text/plain", | 473 | "2", |
473 | "2", | 474 | strlen ("2") + 1, |
474 | strlen ("2") + 1, | 475 | 0 |
475 | 0 | 476 | }, |
476 | }, | 477 | { |
477 | { | 478 | EXTRACTOR_METATYPE_SAMPLE_RATE, |
478 | EXTRACTOR_METATYPE_SAMPLE_RATE, | 479 | EXTRACTOR_METAFORMAT_UTF8, |
479 | EXTRACTOR_METAFORMAT_UTF8, | 480 | "text/plain", |
480 | "text/plain", | 481 | "44100", |
481 | "44100", | 482 | strlen ("44100") + 1, |
482 | strlen ("44100") + 1, | 483 | 0 |
483 | 0 | 484 | }, |
484 | }, | 485 | { |
485 | { | 486 | EXTRACTOR_METATYPE_AUDIO_BITRATE, |
486 | EXTRACTOR_METATYPE_AUDIO_BITRATE, | 487 | EXTRACTOR_METAFORMAT_UTF8, |
487 | EXTRACTOR_METAFORMAT_UTF8, | 488 | "text/plain", |
488 | "text/plain", | 489 | "96000", |
489 | "96000", | 490 | strlen ("96000") + 1, |
490 | strlen ("96000") + 1, | 491 | 0 |
491 | 0 | 492 | }, |
492 | }, | 493 | { 0, 0, NULL, NULL, 0, -1 } |
493 | { 0, 0, NULL, NULL, 0, -1 } | 494 | }; |
494 | }; | 495 | struct ProblemSet ps[] = { |
495 | struct ProblemSet ps[] = | 496 | { "testdata/gstreamer_barsandtone.flv", barsandtone_sol }, |
496 | { | 497 | { NULL, NULL } |
497 | { "testdata/gstreamer_barsandtone.flv", barsandtone_sol }, | 498 | }; |
498 | { NULL, NULL } | ||
499 | }; | ||
500 | g_print ("Running flv test on GStreamer:\n"); | 499 | g_print ("Running flv test on GStreamer:\n"); |
501 | test_result = (0 == ET_main ("gstreamer", ps) ? 0 : 1); | 500 | test_result = (0 == ET_main ("gstreamer", ps) ? 0 : 1); |
502 | g_print ("flv GStreamer test result: %s\n", test_result == 0 ? "OK" : "FAILED"); | 501 | g_print ("flv GStreamer test result: %s\n", test_result == 0 ? "OK" : |
502 | "FAILED"); | ||
503 | result += test_result; | 503 | result += test_result; |
504 | } | 504 | } |
505 | pre_test = discoverer_main (dc, "testdata/gstreamer_sample_sorenson.mov"); | 505 | pre_test = discoverer_main (dc, "testdata/gstreamer_sample_sorenson.mov"); |
506 | if (pre_test != GST_DISCOVERER_MISSING_PLUGINS) | 506 | if (pre_test != GST_DISCOVERER_MISSING_PLUGINS) |
507 | { | 507 | { |
508 | int test_result; | 508 | int test_result; |
509 | struct SolutionData sample_sorenson_sol[] = | 509 | struct SolutionData sample_sorenson_sol[] = { |
510 | { | 510 | { |
511 | { | 511 | EXTRACTOR_METATYPE_DURATION, |
512 | EXTRACTOR_METATYPE_DURATION, | 512 | EXTRACTOR_METAFORMAT_UTF8, |
513 | EXTRACTOR_METAFORMAT_UTF8, | 513 | "text/plain", |
514 | "text/plain", | 514 | "0:00:05.000000000", |
515 | "0:00:05.000000000", | 515 | strlen ("0:00:05.000000000") + 1, |
516 | strlen ("0:00:05.000000000") + 1, | 516 | 0 |
517 | 0 | 517 | }, |
518 | }, | 518 | { |
519 | { | 519 | EXTRACTOR_METATYPE_MIMETYPE, |
520 | EXTRACTOR_METATYPE_MIMETYPE, | 520 | EXTRACTOR_METAFORMAT_UTF8, |
521 | EXTRACTOR_METAFORMAT_UTF8, | 521 | "text/plain", |
522 | "text/plain", | 522 | "video/quicktime", |
523 | "video/quicktime", | 523 | strlen ("video/quicktime") + 1, |
524 | strlen ("video/quicktime") + 1, | 524 | 0 |
525 | 0 | 525 | }, |
526 | }, | 526 | { |
527 | { | 527 | EXTRACTOR_METATYPE_MIMETYPE, |
528 | EXTRACTOR_METATYPE_MIMETYPE, | 528 | EXTRACTOR_METAFORMAT_UTF8, |
529 | EXTRACTOR_METAFORMAT_UTF8, | 529 | "text/plain", |
530 | "text/plain", | 530 | "audio/x-qdm2", |
531 | "audio/x-qdm2", | 531 | strlen ("audio/x-qdm2") + 1, |
532 | strlen ("audio/x-qdm2") + 1, | 532 | 0 |
533 | 0 | 533 | }, |
534 | }, | 534 | { |
535 | { | 535 | EXTRACTOR_METATYPE_UNKNOWN, |
536 | EXTRACTOR_METATYPE_UNKNOWN, | 536 | EXTRACTOR_METAFORMAT_UTF8, |
537 | EXTRACTOR_METAFORMAT_UTF8, | 537 | "text/plain", |
538 | "text/plain", | 538 | "samplesize=16", |
539 | "samplesize=16", | 539 | strlen ("samplesize=16") + 1, |
540 | strlen ("samplesize=16") + 1, | 540 | 0 |
541 | 0 | 541 | }, |
542 | }, | 542 | { |
543 | { | 543 | EXTRACTOR_METATYPE_AUDIO_CODEC, |
544 | EXTRACTOR_METATYPE_AUDIO_CODEC, | 544 | EXTRACTOR_METAFORMAT_UTF8, |
545 | EXTRACTOR_METAFORMAT_UTF8, | 545 | "text/plain", |
546 | "text/plain", | 546 | "QDesign Music v.2", |
547 | "QDesign Music v.2", | 547 | strlen ("QDesign Music v.2") + 1, |
548 | strlen ("QDesign Music v.2") + 1, | 548 | 0 |
549 | 0 | 549 | }, |
550 | }, | 550 | { |
551 | { | 551 | EXTRACTOR_METATYPE_CREATION_TIME, |
552 | EXTRACTOR_METATYPE_CREATION_TIME, | 552 | EXTRACTOR_METAFORMAT_UTF8, |
553 | EXTRACTOR_METAFORMAT_UTF8, | 553 | "text/plain", |
554 | "text/plain", | 554 | "2001-02-19T16:45:54Z", |
555 | "2001-02-19T16:45:54Z", | 555 | strlen ("2001-02-19T16:45:54Z") + 1, |
556 | strlen ("2001-02-19T16:45:54Z") + 1, | 556 | 0 |
557 | 0 | 557 | }, |
558 | }, | 558 | { |
559 | { | 559 | EXTRACTOR_METATYPE_TITLE, |
560 | EXTRACTOR_METATYPE_TITLE, | 560 | EXTRACTOR_METAFORMAT_UTF8, |
561 | EXTRACTOR_METAFORMAT_UTF8, | 561 | "text/plain", |
562 | "text/plain", | 562 | "QuickTime Sample Movie", |
563 | "QuickTime Sample Movie", | 563 | strlen ("QuickTime Sample Movie") + 1, |
564 | strlen ("QuickTime Sample Movie") + 1, | 564 | 0 |
565 | 0 | 565 | }, |
566 | }, | 566 | { |
567 | { | 567 | EXTRACTOR_METATYPE_COPYRIGHT, |
568 | EXTRACTOR_METATYPE_COPYRIGHT, | 568 | EXTRACTOR_METAFORMAT_UTF8, |
569 | EXTRACTOR_METAFORMAT_UTF8, | 569 | "text/plain", |
570 | "text/plain", | 570 | "© Apple Computer, Inc. 2001", |
571 | "© Apple Computer, Inc. 2001", | 571 | strlen ("© Apple Computer, Inc. 2001") + 1, |
572 | strlen ("© Apple Computer, Inc. 2001") + 1, | 572 | 0 |
573 | 0 | 573 | }, |
574 | }, | 574 | { |
575 | { | 575 | EXTRACTOR_METATYPE_CONTAINER_FORMAT, |
576 | EXTRACTOR_METATYPE_CONTAINER_FORMAT, | 576 | EXTRACTOR_METAFORMAT_UTF8, |
577 | EXTRACTOR_METAFORMAT_UTF8, | 577 | "text/plain", |
578 | "text/plain", | 578 | "ISO MP4/M4A", |
579 | "ISO MP4/M4A", | 579 | strlen ("ISO MP4/M4A") + 1, |
580 | strlen ("ISO MP4/M4A") + 1, | 580 | 0 |
581 | 0 | 581 | }, |
582 | }, | 582 | { |
583 | { | 583 | EXTRACTOR_METATYPE_AUDIO_LANGUAGE, |
584 | EXTRACTOR_METATYPE_AUDIO_LANGUAGE, | 584 | EXTRACTOR_METAFORMAT_UTF8, |
585 | EXTRACTOR_METAFORMAT_UTF8, | 585 | "text/plain", |
586 | "text/plain", | 586 | "en", |
587 | "en", | 587 | strlen ("en") + 1, |
588 | strlen ("en") + 1, | 588 | 0 |
589 | 0 | 589 | }, |
590 | }, | 590 | { |
591 | { | 591 | EXTRACTOR_METATYPE_CHANNELS, |
592 | EXTRACTOR_METATYPE_CHANNELS, | 592 | EXTRACTOR_METAFORMAT_UTF8, |
593 | EXTRACTOR_METAFORMAT_UTF8, | 593 | "text/plain", |
594 | "text/plain", | 594 | "2", |
595 | "2", | 595 | strlen ("2") + 1, |
596 | strlen ("2") + 1, | 596 | 0 |
597 | 0 | 597 | }, |
598 | }, | 598 | { |
599 | { | 599 | EXTRACTOR_METATYPE_SAMPLE_RATE, |
600 | EXTRACTOR_METATYPE_SAMPLE_RATE, | 600 | EXTRACTOR_METAFORMAT_UTF8, |
601 | EXTRACTOR_METAFORMAT_UTF8, | 601 | "text/plain", |
602 | "text/plain", | 602 | "22050", |
603 | "22050", | 603 | strlen ("22050") + 1, |
604 | strlen ("22050") + 1, | 604 | 0 |
605 | 0 | 605 | }, |
606 | }, | 606 | { |
607 | { | 607 | EXTRACTOR_METATYPE_MIMETYPE, |
608 | EXTRACTOR_METATYPE_MIMETYPE, | 608 | EXTRACTOR_METAFORMAT_UTF8, |
609 | EXTRACTOR_METAFORMAT_UTF8, | 609 | "text/plain", |
610 | "text/plain", | 610 | "video/x-svq", |
611 | "video/x-svq", | 611 | strlen ("video/x-svq") + 1, |
612 | strlen ("video/x-svq") + 1, | 612 | 0 |
613 | 0 | 613 | }, |
614 | }, | 614 | { |
615 | { | 615 | EXTRACTOR_METATYPE_UNKNOWN, |
616 | EXTRACTOR_METATYPE_UNKNOWN, | 616 | EXTRACTOR_METAFORMAT_UTF8, |
617 | EXTRACTOR_METAFORMAT_UTF8, | 617 | "text/plain", |
618 | "text/plain", | 618 | "svqversion=1", |
619 | "svqversion=1", | 619 | strlen ("svqversion=1") + 1, |
620 | strlen ("svqversion=1") + 1, | 620 | 0 |
621 | 0 | 621 | }, |
622 | }, | 622 | /* Yep, again... */ |
623 | /* Yep, again... */ | 623 | { |
624 | { | 624 | EXTRACTOR_METATYPE_CREATION_TIME, |
625 | EXTRACTOR_METATYPE_CREATION_TIME, | 625 | EXTRACTOR_METAFORMAT_UTF8, |
626 | EXTRACTOR_METAFORMAT_UTF8, | 626 | "text/plain", |
627 | "text/plain", | 627 | "2001-02-19T16:45:54Z", |
628 | "2001-02-19T16:45:54Z", | 628 | strlen ("2001-02-19T16:45:54Z") + 1, |
629 | strlen ("2001-02-19T16:45:54Z") + 1, | 629 | 0 |
630 | 0 | 630 | }, |
631 | }, | 631 | { |
632 | { | 632 | EXTRACTOR_METATYPE_TITLE, |
633 | EXTRACTOR_METATYPE_TITLE, | 633 | EXTRACTOR_METAFORMAT_UTF8, |
634 | EXTRACTOR_METAFORMAT_UTF8, | 634 | "text/plain", |
635 | "text/plain", | 635 | "QuickTime Sample Movie", |
636 | "QuickTime Sample Movie", | 636 | strlen ("QuickTime Sample Movie") + 1, |
637 | strlen ("QuickTime Sample Movie") + 1, | 637 | 0 |
638 | 0 | 638 | }, |
639 | }, | 639 | { |
640 | { | 640 | EXTRACTOR_METATYPE_COPYRIGHT, |
641 | EXTRACTOR_METATYPE_COPYRIGHT, | 641 | EXTRACTOR_METAFORMAT_UTF8, |
642 | EXTRACTOR_METAFORMAT_UTF8, | 642 | "text/plain", |
643 | "text/plain", | 643 | "© Apple Computer, Inc. 2001", |
644 | "© Apple Computer, Inc. 2001", | 644 | strlen ("© Apple Computer, Inc. 2001") + 1, |
645 | strlen ("© Apple Computer, Inc. 2001") + 1, | 645 | 0 |
646 | 0 | 646 | }, |
647 | }, | 647 | { |
648 | { | 648 | EXTRACTOR_METATYPE_CONTAINER_FORMAT, |
649 | EXTRACTOR_METATYPE_CONTAINER_FORMAT, | 649 | EXTRACTOR_METAFORMAT_UTF8, |
650 | EXTRACTOR_METAFORMAT_UTF8, | 650 | "text/plain", |
651 | "text/plain", | 651 | "ISO MP4/M4A", |
652 | "ISO MP4/M4A", | 652 | strlen ("ISO MP4/M4A") + 1, |
653 | strlen ("ISO MP4/M4A") + 1, | 653 | 0 |
654 | 0 | 654 | }, |
655 | }, | 655 | { |
656 | { | 656 | EXTRACTOR_METATYPE_VIDEO_CODEC, |
657 | EXTRACTOR_METATYPE_VIDEO_CODEC, | 657 | EXTRACTOR_METAFORMAT_UTF8, |
658 | EXTRACTOR_METAFORMAT_UTF8, | 658 | "text/plain", |
659 | "text/plain", | 659 | "Sorensen video v.1", |
660 | "Sorensen video v.1", | 660 | strlen ("Sorensen video v.1") + 1, |
661 | strlen ("Sorensen video v.1") + 1, | 661 | 0 |
662 | 0 | 662 | }, |
663 | }, | 663 | { |
664 | { | 664 | EXTRACTOR_METATYPE_VIDEO_LANGUAGE, |
665 | EXTRACTOR_METATYPE_VIDEO_LANGUAGE, | 665 | EXTRACTOR_METAFORMAT_UTF8, |
666 | EXTRACTOR_METAFORMAT_UTF8, | 666 | "text/plain", |
667 | "text/plain", | 667 | "en", |
668 | "en", | 668 | strlen ("en") + 1, |
669 | strlen ("en") + 1, | 669 | 0 |
670 | 0 | 670 | }, |
671 | }, | 671 | { |
672 | { | 672 | EXTRACTOR_METATYPE_VIDEO_DIMENSIONS, |
673 | EXTRACTOR_METATYPE_VIDEO_DIMENSIONS, | 673 | EXTRACTOR_METAFORMAT_UTF8, |
674 | EXTRACTOR_METAFORMAT_UTF8, | 674 | "text/plain", |
675 | "text/plain", | 675 | "190x240", |
676 | "190x240", | 676 | strlen ("190x240") + 1, |
677 | strlen ("190x240") + 1, | 677 | 0 |
678 | 0 | 678 | }, |
679 | }, | 679 | { |
680 | { | 680 | EXTRACTOR_METATYPE_FRAME_RATE, |
681 | EXTRACTOR_METATYPE_FRAME_RATE, | 681 | EXTRACTOR_METAFORMAT_UTF8, |
682 | EXTRACTOR_METAFORMAT_UTF8, | 682 | "text/plain", |
683 | "text/plain", | 683 | "12/1", |
684 | "12/1", | 684 | strlen ("12/1") + 1, |
685 | strlen ("12/1") + 1, | 685 | 0 |
686 | 0 | 686 | }, |
687 | }, | 687 | { |
688 | { | 688 | EXTRACTOR_METATYPE_PIXEL_ASPECT_RATIO, |
689 | EXTRACTOR_METATYPE_PIXEL_ASPECT_RATIO, | 689 | EXTRACTOR_METAFORMAT_UTF8, |
690 | EXTRACTOR_METAFORMAT_UTF8, | 690 | "text/plain", |
691 | "text/plain", | 691 | "1/1", |
692 | "1/1", | 692 | strlen ("1/1") + 1, |
693 | strlen ("1/1") + 1, | 693 | 0 |
694 | 0 | 694 | }, |
695 | }, | 695 | { 0, 0, NULL, NULL, 0, -1 } |
696 | { 0, 0, NULL, NULL, 0, -1 } | 696 | }; |
697 | }; | 697 | struct ProblemSet ps[] = { |
698 | struct ProblemSet ps[] = | 698 | { "testdata/gstreamer_sample_sorenson.mov", sample_sorenson_sol }, |
699 | { | 699 | { NULL, NULL } |
700 | { "testdata/gstreamer_sample_sorenson.mov", sample_sorenson_sol }, | 700 | }; |
701 | { NULL, NULL } | ||
702 | }; | ||
703 | g_print ("Running mov test on GStreamer:\n"); | 701 | g_print ("Running mov test on GStreamer:\n"); |
704 | test_result = (0 == ET_main ("gstreamer", ps) ? 0 : 1); | 702 | test_result = (0 == ET_main ("gstreamer", ps) ? 0 : 1); |
705 | g_print ("mov GStreamer test result: %s\n", test_result == 0 ? "OK" : "FAILED"); | 703 | g_print ("mov GStreamer test result: %s\n", test_result == 0 ? "OK" : |
704 | "FAILED"); | ||
706 | result += test_result; | 705 | result += test_result; |
707 | } | 706 | } |
708 | 707 | ||
@@ -711,956 +710,957 @@ main (int argc, char *argv[]) | |||
711 | { | 710 | { |
712 | int result_stock; | 711 | int result_stock; |
713 | int result_patched; | 712 | int result_patched; |
714 | struct SolutionData matroska_flame_stock_sol[] = | 713 | struct SolutionData matroska_flame_stock_sol[] = { |
715 | { | 714 | { |
716 | { | 715 | EXTRACTOR_METATYPE_DURATION, |
717 | EXTRACTOR_METATYPE_DURATION, | 716 | EXTRACTOR_METAFORMAT_UTF8, |
718 | EXTRACTOR_METAFORMAT_UTF8, | 717 | "text/plain", |
719 | "text/plain", | 718 | "0:00:03.143000000", |
720 | "0:00:03.143000000", | 719 | strlen ("0:00:03.143000000") + 1, |
721 | strlen ("0:00:03.143000000") + 1, | 720 | 0 |
722 | 0 | 721 | }, |
723 | }, | 722 | { |
724 | { | 723 | EXTRACTOR_METATYPE_MIMETYPE, |
725 | EXTRACTOR_METATYPE_MIMETYPE, | 724 | EXTRACTOR_METAFORMAT_UTF8, |
726 | EXTRACTOR_METAFORMAT_UTF8, | 725 | "text/plain", |
727 | "text/plain", | 726 | "video/x-matroska", |
728 | "video/x-matroska", | 727 | strlen ("video/x-matroska") + 1, |
729 | strlen ("video/x-matroska") + 1, | 728 | 0 |
730 | 0 | 729 | }, |
731 | }, | 730 | { |
732 | { | 731 | EXTRACTOR_METATYPE_MIMETYPE, |
733 | EXTRACTOR_METATYPE_MIMETYPE, | 732 | EXTRACTOR_METAFORMAT_UTF8, |
734 | EXTRACTOR_METAFORMAT_UTF8, | 733 | "text/plain", |
735 | "text/plain", | 734 | "video/x-indeo", |
736 | "video/x-indeo", | 735 | strlen ("video/x-indeo") + 1, |
737 | strlen ("video/x-indeo") + 1, | 736 | 0 |
738 | 0 | 737 | }, |
739 | }, | 738 | { |
740 | { | 739 | EXTRACTOR_METATYPE_UNKNOWN, |
741 | EXTRACTOR_METATYPE_UNKNOWN, | 740 | EXTRACTOR_METAFORMAT_UTF8, |
742 | EXTRACTOR_METAFORMAT_UTF8, | 741 | "text/plain", |
743 | "text/plain", | 742 | "indeoversion=4", |
744 | "indeoversion=4", | 743 | strlen ("indeoversion=4") + 1, |
745 | strlen ("indeoversion=4") + 1, | 744 | 0 |
746 | 0 | 745 | }, |
747 | }, | 746 | { |
748 | { | 747 | EXTRACTOR_METATYPE_TITLE, |
749 | EXTRACTOR_METATYPE_TITLE, | 748 | EXTRACTOR_METAFORMAT_UTF8, |
750 | EXTRACTOR_METAFORMAT_UTF8, | 749 | "text/plain", |
751 | "text/plain", | 750 | "filesegmenttitle", |
752 | "filesegmenttitle", | 751 | strlen ("filesegmenttitle") + 1, |
753 | strlen ("filesegmenttitle") + 1, | 752 | 0 |
754 | 0 | 753 | }, |
755 | }, | 754 | { |
756 | { | 755 | EXTRACTOR_METATYPE_TITLE, |
757 | EXTRACTOR_METATYPE_TITLE, | 756 | EXTRACTOR_METAFORMAT_UTF8, |
758 | EXTRACTOR_METAFORMAT_UTF8, | 757 | "text/plain", |
759 | "text/plain", | 758 | "TITLE", |
760 | "TITLE", | 759 | strlen ("TITLE") + 1, |
761 | strlen ("TITLE") + 1, | 760 | 0 |
762 | 0 | 761 | }, |
763 | }, | 762 | { |
764 | { | 763 | EXTRACTOR_METATYPE_ARTIST, |
765 | EXTRACTOR_METATYPE_ARTIST, | 764 | EXTRACTOR_METAFORMAT_UTF8, |
766 | EXTRACTOR_METAFORMAT_UTF8, | 765 | "text/plain", |
767 | "text/plain", | 766 | "ALBUM/ARTIST", |
768 | "ALBUM/ARTIST", | 767 | strlen ("ALBUM/ARTIST") + 1, |
769 | strlen ("ALBUM/ARTIST") + 1, | 768 | 0 |
770 | 0 | 769 | }, |
771 | }, | 770 | { |
772 | { | 771 | EXTRACTOR_METATYPE_ARTIST, |
773 | EXTRACTOR_METATYPE_ARTIST, | 772 | EXTRACTOR_METAFORMAT_UTF8, |
774 | EXTRACTOR_METAFORMAT_UTF8, | 773 | "text/plain", |
775 | "text/plain", | 774 | "ARTIST", |
776 | "ARTIST", | 775 | strlen ("ARTIST") + 1, |
777 | strlen ("ARTIST") + 1, | 776 | 0 |
778 | 0 | 777 | }, |
779 | }, | 778 | { |
780 | { | 779 | EXTRACTOR_METATYPE_COPYRIGHT, |
781 | EXTRACTOR_METATYPE_COPYRIGHT, | 780 | EXTRACTOR_METAFORMAT_UTF8, |
782 | EXTRACTOR_METAFORMAT_UTF8, | 781 | "text/plain", |
783 | "text/plain", | 782 | "COPYRIGHT", |
784 | "COPYRIGHT", | 783 | strlen ("COPYRIGHT") + 1, |
785 | strlen ("COPYRIGHT") + 1, | 784 | 0 |
786 | 0 | 785 | }, |
787 | }, | 786 | { |
788 | { | 787 | EXTRACTOR_METATYPE_COMPOSER, |
789 | EXTRACTOR_METATYPE_COMPOSER, | 788 | EXTRACTOR_METAFORMAT_UTF8, |
790 | EXTRACTOR_METAFORMAT_UTF8, | 789 | "text/plain", |
791 | "text/plain", | 790 | "COMPOSER", |
792 | "COMPOSER", | 791 | strlen ("COMPOSER") + 1, |
793 | strlen ("COMPOSER") + 1, | 792 | 0 |
794 | 0 | 793 | }, |
795 | }, | 794 | { |
796 | { | 795 | EXTRACTOR_METATYPE_GENRE, |
797 | EXTRACTOR_METATYPE_GENRE, | 796 | EXTRACTOR_METAFORMAT_UTF8, |
798 | EXTRACTOR_METAFORMAT_UTF8, | 797 | "text/plain", |
799 | "text/plain", | 798 | "GENRE", |
800 | "GENRE", | 799 | strlen ("GENRE") + 1, |
801 | strlen ("GENRE") + 1, | 800 | 0 |
802 | 0 | 801 | }, |
803 | }, | 802 | { |
804 | { | 803 | EXTRACTOR_METATYPE_ENCODER, |
805 | EXTRACTOR_METATYPE_ENCODER, | 804 | EXTRACTOR_METAFORMAT_UTF8, |
806 | EXTRACTOR_METAFORMAT_UTF8, | 805 | "text/plain", |
807 | "text/plain", | 806 | "ENCODER", |
808 | "ENCODER", | 807 | strlen ("ENCODER") + 1, |
809 | strlen ("ENCODER") + 1, | 808 | 0 |
810 | 0 | 809 | }, |
811 | }, | 810 | { |
812 | { | 811 | EXTRACTOR_METATYPE_ISRC, |
813 | EXTRACTOR_METATYPE_ISRC, | 812 | EXTRACTOR_METAFORMAT_UTF8, |
814 | EXTRACTOR_METAFORMAT_UTF8, | 813 | "text/plain", |
815 | "text/plain", | 814 | "ISRC", |
816 | "ISRC", | 815 | strlen ("ISRC") + 1, |
817 | strlen ("ISRC") + 1, | 816 | 0 |
818 | 0 | 817 | }, |
819 | }, | 818 | { |
820 | { | 819 | EXTRACTOR_METATYPE_CONTAINER_FORMAT, |
821 | EXTRACTOR_METATYPE_CONTAINER_FORMAT, | 820 | EXTRACTOR_METAFORMAT_UTF8, |
822 | EXTRACTOR_METAFORMAT_UTF8, | 821 | "text/plain", |
823 | "text/plain", | 822 | "Matroska", |
824 | "Matroska", | 823 | strlen ("Matroska") + 1, |
825 | strlen ("Matroska") + 1, | 824 | 0 |
826 | 0 | 825 | }, |
827 | }, | 826 | { |
828 | { | 827 | EXTRACTOR_METATYPE_VIDEO_CODEC, |
829 | EXTRACTOR_METATYPE_VIDEO_CODEC, | 828 | EXTRACTOR_METAFORMAT_UTF8, |
830 | EXTRACTOR_METAFORMAT_UTF8, | 829 | "text/plain", |
831 | "text/plain", | 830 | "Intel Video 4", |
832 | "Intel Video 4", | 831 | strlen ("Intel Video 4") + 1, |
833 | strlen ("Intel Video 4") + 1, | 832 | 0 |
834 | 0 | 833 | }, |
835 | }, | 834 | { |
836 | { | 835 | EXTRACTOR_METATYPE_VIDEO_LANGUAGE, |
837 | EXTRACTOR_METATYPE_VIDEO_LANGUAGE, | 836 | EXTRACTOR_METAFORMAT_UTF8, |
838 | EXTRACTOR_METAFORMAT_UTF8, | 837 | "text/plain", |
839 | "text/plain", | 838 | "it", |
840 | "it", | 839 | strlen ("it") + 1, |
841 | strlen ("it") + 1, | 840 | 0 |
842 | 0 | 841 | }, |
843 | }, | 842 | { |
844 | { | 843 | EXTRACTOR_METATYPE_VIDEO_DIMENSIONS, |
845 | EXTRACTOR_METATYPE_VIDEO_DIMENSIONS, | 844 | EXTRACTOR_METAFORMAT_UTF8, |
846 | EXTRACTOR_METAFORMAT_UTF8, | 845 | "text/plain", |
847 | "text/plain", | 846 | "256x240", |
848 | "256x240", | 847 | strlen ("256x240") + 1, |
849 | strlen ("256x240") + 1, | 848 | 0 |
850 | 0 | 849 | }, |
851 | }, | 850 | { |
852 | { | 851 | EXTRACTOR_METATYPE_FRAME_RATE, |
853 | EXTRACTOR_METATYPE_FRAME_RATE, | 852 | EXTRACTOR_METAFORMAT_UTF8, |
854 | EXTRACTOR_METAFORMAT_UTF8, | 853 | "text/plain", |
855 | "text/plain", | 854 | "35/1", |
856 | "35/1", | 855 | strlen ("35/1") + 1, |
857 | strlen ("35/1") + 1, | 856 | 0 |
858 | 0 | 857 | }, |
859 | }, | 858 | { |
860 | { | 859 | EXTRACTOR_METATYPE_PIXEL_ASPECT_RATIO, |
861 | EXTRACTOR_METATYPE_PIXEL_ASPECT_RATIO, | 860 | EXTRACTOR_METAFORMAT_UTF8, |
862 | EXTRACTOR_METAFORMAT_UTF8, | 861 | "text/plain", |
863 | "text/plain", | 862 | "1/1", |
864 | "1/1", | 863 | strlen ("1/1") + 1, |
865 | strlen ("1/1") + 1, | 864 | 0 |
866 | 0 | 865 | }, |
867 | }, | 866 | { 0, 0, NULL, NULL, 0, -1 } |
868 | { 0, 0, NULL, NULL, 0, -1 } | 867 | }; |
869 | }; | 868 | struct ProblemSet stock_ps[] = { |
870 | struct ProblemSet stock_ps[] = | 869 | { "testdata/matroska_flame.mkv", matroska_flame_stock_sol }, |
871 | { | 870 | { NULL, NULL } |
872 | { "testdata/matroska_flame.mkv", matroska_flame_stock_sol }, | 871 | }; |
873 | { NULL, NULL } | ||
874 | }; | ||
875 | 872 | ||
876 | 873 | ||
877 | struct SolutionData matroska_flame_patched_sol[] = | 874 | struct SolutionData matroska_flame_patched_sol[] = { |
878 | { | 875 | { |
879 | { | 876 | EXTRACTOR_METATYPE_DURATION, |
880 | EXTRACTOR_METATYPE_DURATION, | 877 | EXTRACTOR_METAFORMAT_UTF8, |
881 | EXTRACTOR_METAFORMAT_UTF8, | 878 | "text/plain", |
882 | "text/plain", | 879 | "0:00:03.143000000", |
883 | "0:00:03.143000000", | 880 | strlen ("0:00:03.143000000") + 1, |
884 | strlen ("0:00:03.143000000") + 1, | 881 | 0 |
885 | 0 | 882 | }, |
886 | }, | 883 | { |
887 | { | 884 | EXTRACTOR_METATYPE_MIMETYPE, |
888 | EXTRACTOR_METATYPE_MIMETYPE, | 885 | EXTRACTOR_METAFORMAT_UTF8, |
889 | EXTRACTOR_METAFORMAT_UTF8, | 886 | "text/plain", |
890 | "text/plain", | 887 | "video/x-matroska", |
891 | "video/x-matroska", | 888 | strlen ("video/x-matroska") + 1, |
892 | strlen ("video/x-matroska") + 1, | 889 | 0 |
893 | 0 | 890 | }, |
894 | }, | 891 | { |
895 | { | 892 | EXTRACTOR_METATYPE_MIMETYPE, |
896 | EXTRACTOR_METATYPE_MIMETYPE, | 893 | EXTRACTOR_METAFORMAT_UTF8, |
897 | EXTRACTOR_METAFORMAT_UTF8, | 894 | "text/plain", |
898 | "text/plain", | 895 | "video/x-indeo", |
899 | "video/x-indeo", | 896 | strlen ("video/x-indeo") + 1, |
900 | strlen ("video/x-indeo") + 1, | 897 | 0 |
901 | 0 | 898 | }, |
902 | }, | 899 | { |
903 | { | 900 | EXTRACTOR_METATYPE_UNKNOWN, |
904 | EXTRACTOR_METATYPE_UNKNOWN, | 901 | EXTRACTOR_METAFORMAT_UTF8, |
905 | EXTRACTOR_METAFORMAT_UTF8, | 902 | "text/plain", |
906 | "text/plain", | 903 | "indeoversion=4", |
907 | "indeoversion=4", | 904 | strlen ("indeoversion=4") + 1, |
908 | strlen ("indeoversion=4") + 1, | 905 | 0 |
909 | 0 | 906 | }, |
910 | }, | 907 | { |
911 | { | 908 | EXTRACTOR_METATYPE_TITLE, |
912 | EXTRACTOR_METATYPE_TITLE, | 909 | EXTRACTOR_METAFORMAT_UTF8, |
913 | EXTRACTOR_METAFORMAT_UTF8, | 910 | "text/plain", |
914 | "text/plain", | 911 | "filesegmenttitle", |
915 | "filesegmenttitle", | 912 | strlen ("filesegmenttitle") + 1, |
916 | strlen ("filesegmenttitle") + 1, | 913 | 0 |
917 | 0 | 914 | }, |
918 | }, | 915 | { |
919 | { | 916 | EXTRACTOR_METATYPE_ALBUM, |
920 | EXTRACTOR_METATYPE_ALBUM, | 917 | EXTRACTOR_METAFORMAT_UTF8, |
921 | EXTRACTOR_METAFORMAT_UTF8, | 918 | "text/plain", |
922 | "text/plain", | 919 | "ALBUM/TITLE", |
923 | "ALBUM/TITLE", | 920 | strlen ("ALBUM/TITLE") + 1, |
924 | strlen ("ALBUM/TITLE") + 1, | 921 | 0 |
925 | 0 | 922 | }, |
926 | }, | 923 | { |
927 | { | 924 | EXTRACTOR_METATYPE_TITLE, |
928 | EXTRACTOR_METATYPE_TITLE, | 925 | EXTRACTOR_METAFORMAT_UTF8, |
929 | EXTRACTOR_METAFORMAT_UTF8, | 926 | "text/plain", |
930 | "text/plain", | 927 | "TITLE", |
931 | "TITLE", | 928 | strlen ("TITLE") + 1, |
932 | strlen ("TITLE") + 1, | 929 | 0 |
933 | 0 | 930 | }, |
934 | }, | 931 | { |
935 | { | 932 | EXTRACTOR_METATYPE_TITLE, |
936 | EXTRACTOR_METATYPE_TITLE, | 933 | EXTRACTOR_METAFORMAT_UTF8, |
937 | EXTRACTOR_METAFORMAT_UTF8, | 934 | "text/plain", |
938 | "text/plain", | 935 | "SUBTITLE", |
939 | "SUBTITLE", | 936 | strlen ("SUBTITLE") + 1, |
940 | strlen ("SUBTITLE") + 1, | 937 | 0 |
941 | 0 | 938 | }, |
942 | }, | 939 | { |
943 | { | 940 | EXTRACTOR_METATYPE_TITLE, |
944 | EXTRACTOR_METATYPE_TITLE, | 941 | EXTRACTOR_METAFORMAT_UTF8, |
945 | EXTRACTOR_METAFORMAT_UTF8, | 942 | "text/plain", |
946 | "text/plain", | 943 | "VIDEO/TITLE", |
947 | "VIDEO/TITLE", | 944 | strlen ("VIDEO/TITLE") + 1, |
948 | strlen ("VIDEO/TITLE") + 1, | 945 | 0 |
949 | 0 | 946 | }, |
950 | }, | 947 | { |
951 | { | 948 | EXTRACTOR_METATYPE_ARTIST, |
952 | EXTRACTOR_METATYPE_ARTIST, | 949 | EXTRACTOR_METAFORMAT_UTF8, |
953 | EXTRACTOR_METAFORMAT_UTF8, | 950 | "text/plain", |
954 | "text/plain", | 951 | "ALBUM/ARTIST", |
955 | "ALBUM/ARTIST", | 952 | strlen ("ALBUM/ARTIST") + 1, |
956 | strlen ("ALBUM/ARTIST") + 1, | 953 | 0 |
957 | 0 | 954 | }, |
958 | }, | 955 | { |
959 | { | 956 | EXTRACTOR_METATYPE_ARTIST, |
960 | EXTRACTOR_METATYPE_ARTIST, | 957 | EXTRACTOR_METAFORMAT_UTF8, |
961 | EXTRACTOR_METAFORMAT_UTF8, | 958 | "text/plain", |
962 | "text/plain", | 959 | "ARTIST", |
963 | "ARTIST", | 960 | strlen ("ARTIST") + 1, |
964 | strlen ("ARTIST") + 1, | 961 | 0 |
965 | 0 | 962 | }, |
966 | }, | 963 | { |
967 | { | 964 | EXTRACTOR_METATYPE_SONG_COUNT, |
968 | EXTRACTOR_METATYPE_SONG_COUNT, | 965 | EXTRACTOR_METAFORMAT_UTF8, |
969 | EXTRACTOR_METAFORMAT_UTF8, | 966 | "text/plain", |
970 | "text/plain", | 967 | "20", |
971 | "20", | 968 | strlen ("20") + 1, |
972 | strlen ("20") + 1, | 969 | 0 |
973 | 0 | 970 | }, |
974 | }, | 971 | { |
975 | { | 972 | EXTRACTOR_METATYPE_UNKNOWN, |
976 | EXTRACTOR_METATYPE_UNKNOWN, | 973 | EXTRACTOR_METAFORMAT_UTF8, |
977 | EXTRACTOR_METAFORMAT_UTF8, | 974 | "text/plain", |
978 | "text/plain", | 975 | "PART_OFFSET=5", |
979 | "PART_OFFSET=5", | 976 | strlen ("PART_OFFSET=5") + 1, |
980 | strlen ("PART_OFFSET=5") + 1, | 977 | 0 |
981 | 0 | 978 | }, |
982 | }, | 979 | { |
983 | { | 980 | EXTRACTOR_METATYPE_UNKNOWN, |
984 | EXTRACTOR_METATYPE_UNKNOWN, | 981 | EXTRACTOR_METAFORMAT_UTF8, |
985 | EXTRACTOR_METAFORMAT_UTF8, | 982 | "text/plain", |
986 | "text/plain", | 983 | "ARTIST/INSTRUMENTS=ARTIST/INSTRUMENTS", |
987 | "ARTIST/INSTRUMENTS=ARTIST/INSTRUMENTS", | 984 | strlen ("ARTIST/INSTRUMENTS=ARTIST/INSTRUMENTS") + 1, |
988 | strlen ("ARTIST/INSTRUMENTS=ARTIST/INSTRUMENTS") + 1, | 985 | 0 |
989 | 0 | 986 | }, |
990 | }, | 987 | { |
991 | { | 988 | EXTRACTOR_METATYPE_UNKNOWN, |
992 | EXTRACTOR_METATYPE_UNKNOWN, | 989 | EXTRACTOR_METAFORMAT_UTF8, |
993 | EXTRACTOR_METAFORMAT_UTF8, | 990 | "text/plain", |
994 | "text/plain", | 991 | "LEAD_PERFORMER=LEAD_PERFORMER", |
995 | "LEAD_PERFORMER=LEAD_PERFORMER", | 992 | strlen ("LEAD_PERFORMER=LEAD_PERFORMER") + 1, |
996 | strlen ("LEAD_PERFORMER=LEAD_PERFORMER") + 1, | 993 | 0 |
997 | 0 | 994 | }, |
998 | }, | 995 | { |
999 | { | 996 | EXTRACTOR_METATYPE_UNKNOWN, |
1000 | EXTRACTOR_METATYPE_UNKNOWN, | 997 | EXTRACTOR_METAFORMAT_UTF8, |
1001 | EXTRACTOR_METAFORMAT_UTF8, | 998 | "text/plain", |
1002 | "text/plain", | 999 | "ARRANGER=ARRANGER", |
1003 | "ARRANGER=ARRANGER", | 1000 | strlen ("ARRANGER=ARRANGER") + 1, |
1004 | strlen ("ARRANGER=ARRANGER") + 1, | 1001 | 0 |
1005 | 0 | 1002 | }, |
1006 | }, | 1003 | { |
1007 | { | 1004 | EXTRACTOR_METATYPE_UNKNOWN, |
1008 | EXTRACTOR_METATYPE_UNKNOWN, | 1005 | EXTRACTOR_METAFORMAT_UTF8, |
1009 | EXTRACTOR_METAFORMAT_UTF8, | 1006 | "text/plain", |
1010 | "text/plain", | 1007 | "LYRICIST=LYRICIST", |
1011 | "LYRICIST=LYRICIST", | 1008 | strlen ("LYRICIST=LYRICIST") + 1, |
1012 | strlen ("LYRICIST=LYRICIST") + 1, | 1009 | 0 |
1013 | 0 | 1010 | }, |
1014 | }, | 1011 | { |
1015 | { | 1012 | EXTRACTOR_METATYPE_MOVIE_DIRECTOR, |
1016 | EXTRACTOR_METATYPE_MOVIE_DIRECTOR, | 1013 | EXTRACTOR_METAFORMAT_UTF8, |
1017 | EXTRACTOR_METAFORMAT_UTF8, | 1014 | "text/plain", |
1018 | "text/plain", | 1015 | "DIRECTOR", |
1019 | "DIRECTOR", | 1016 | strlen ("DIRECTOR") + 1, |
1020 | strlen ("DIRECTOR") + 1, | 1017 | 0 |
1021 | 0 | 1018 | }, |
1022 | }, | 1019 | { |
1023 | { | 1020 | EXTRACTOR_METATYPE_UNKNOWN, |
1024 | EXTRACTOR_METATYPE_UNKNOWN, | 1021 | EXTRACTOR_METAFORMAT_UTF8, |
1025 | EXTRACTOR_METAFORMAT_UTF8, | 1022 | "text/plain", |
1026 | "text/plain", | 1023 | "ASSISTANT_DIRECTOR=ASSISTANT_DIRECTOR", |
1027 | "ASSISTANT_DIRECTOR=ASSISTANT_DIRECTOR", | 1024 | strlen ("ASSISTANT_DIRECTOR=ASSISTANT_DIRECTOR") + 1, |
1028 | strlen ("ASSISTANT_DIRECTOR=ASSISTANT_DIRECTOR") + 1, | 1025 | 0 |
1029 | 0 | 1026 | }, |
1030 | }, | 1027 | { |
1031 | { | 1028 | EXTRACTOR_METATYPE_UNKNOWN, |
1032 | EXTRACTOR_METATYPE_UNKNOWN, | 1029 | EXTRACTOR_METAFORMAT_UTF8, |
1033 | EXTRACTOR_METAFORMAT_UTF8, | 1030 | "text/plain", |
1034 | "text/plain", | 1031 | "DIRECTOR_OF_PHOTOGRAPHY=DIRECTOR_OF_PHOTOGRAPHY", |
1035 | "DIRECTOR_OF_PHOTOGRAPHY=DIRECTOR_OF_PHOTOGRAPHY", | 1032 | strlen ("DIRECTOR_OF_PHOTOGRAPHY=DIRECTOR_OF_PHOTOGRAPHY") + 1, |
1036 | strlen ("DIRECTOR_OF_PHOTOGRAPHY=DIRECTOR_OF_PHOTOGRAPHY") + 1, | 1033 | 0 |
1037 | 0 | 1034 | }, |
1038 | }, | 1035 | { |
1039 | { | 1036 | EXTRACTOR_METATYPE_UNKNOWN, |
1040 | EXTRACTOR_METATYPE_UNKNOWN, | 1037 | EXTRACTOR_METAFORMAT_UTF8, |
1041 | EXTRACTOR_METAFORMAT_UTF8, | 1038 | "text/plain", |
1042 | "text/plain", | 1039 | "SOUND_ENGINEER=SOUND_ENGINEER", |
1043 | "SOUND_ENGINEER=SOUND_ENGINEER", | 1040 | strlen ("SOUND_ENGINEER=SOUND_ENGINEER") + 1, |
1044 | strlen ("SOUND_ENGINEER=SOUND_ENGINEER") + 1, | 1041 | 0 |
1045 | 0 | 1042 | }, |
1046 | }, | 1043 | { |
1047 | { | 1044 | EXTRACTOR_METATYPE_UNKNOWN, |
1048 | EXTRACTOR_METATYPE_UNKNOWN, | 1045 | EXTRACTOR_METAFORMAT_UTF8, |
1049 | EXTRACTOR_METAFORMAT_UTF8, | 1046 | "text/plain", |
1050 | "text/plain", | 1047 | "ART_DIRECTOR=ART_DIRECTOR", |
1051 | "ART_DIRECTOR=ART_DIRECTOR", | 1048 | strlen ("ART_DIRECTOR=ART_DIRECTOR") + 1, |
1052 | strlen ("ART_DIRECTOR=ART_DIRECTOR") + 1, | 1049 | 0 |
1053 | 0 | 1050 | }, |
1054 | }, | 1051 | { |
1055 | { | 1052 | EXTRACTOR_METATYPE_UNKNOWN, |
1056 | EXTRACTOR_METATYPE_UNKNOWN, | 1053 | EXTRACTOR_METAFORMAT_UTF8, |
1057 | EXTRACTOR_METAFORMAT_UTF8, | 1054 | "text/plain", |
1058 | "text/plain", | 1055 | "PRODUCTION_DESIGNER=PRODUCTION_DESIGNER", |
1059 | "PRODUCTION_DESIGNER=PRODUCTION_DESIGNER", | 1056 | strlen ("PRODUCTION_DESIGNER=PRODUCTION_DESIGNER") + 1, |
1060 | strlen ("PRODUCTION_DESIGNER=PRODUCTION_DESIGNER") + 1, | 1057 | 0 |
1061 | 0 | 1058 | }, |
1062 | }, | 1059 | { |
1063 | { | 1060 | EXTRACTOR_METATYPE_UNKNOWN, |
1064 | EXTRACTOR_METATYPE_UNKNOWN, | 1061 | EXTRACTOR_METAFORMAT_UTF8, |
1065 | EXTRACTOR_METAFORMAT_UTF8, | 1062 | "text/plain", |
1066 | "text/plain", | 1063 | "CHOREGRAPHER=CHOREGRAPHER", |
1067 | "CHOREGRAPHER=CHOREGRAPHER", | 1064 | strlen ("CHOREGRAPHER=CHOREGRAPHER") + 1, |
1068 | strlen ("CHOREGRAPHER=CHOREGRAPHER") + 1, | 1065 | 0 |
1069 | 0 | 1066 | }, |
1070 | }, | 1067 | { |
1071 | { | 1068 | EXTRACTOR_METATYPE_UNKNOWN, |
1072 | EXTRACTOR_METATYPE_UNKNOWN, | 1069 | EXTRACTOR_METAFORMAT_UTF8, |
1073 | EXTRACTOR_METAFORMAT_UTF8, | 1070 | "text/plain", |
1074 | "text/plain", | 1071 | "COSTUME_DESIGNER=COSTUME_DESIGNER", |
1075 | "COSTUME_DESIGNER=COSTUME_DESIGNER", | 1072 | strlen ("COSTUME_DESIGNER=COSTUME_DESIGNER") + 1, |
1076 | strlen ("COSTUME_DESIGNER=COSTUME_DESIGNER") + 1, | 1073 | 0 |
1077 | 0 | 1074 | }, |
1078 | }, | 1075 | { |
1079 | { | 1076 | EXTRACTOR_METATYPE_UNKNOWN, |
1080 | EXTRACTOR_METATYPE_UNKNOWN, | 1077 | EXTRACTOR_METAFORMAT_UTF8, |
1081 | EXTRACTOR_METAFORMAT_UTF8, | 1078 | "text/plain", |
1082 | "text/plain", | 1079 | "ACTOR=ACTOR", |
1083 | "ACTOR=ACTOR", | 1080 | strlen ("ACTOR=ACTOR") + 1, |
1084 | strlen ("ACTOR=ACTOR") + 1, | 1081 | 0 |
1085 | 0 | 1082 | }, |
1086 | }, | 1083 | { |
1087 | { | 1084 | EXTRACTOR_METATYPE_UNKNOWN, |
1088 | EXTRACTOR_METATYPE_UNKNOWN, | 1085 | EXTRACTOR_METAFORMAT_UTF8, |
1089 | EXTRACTOR_METAFORMAT_UTF8, | 1086 | "text/plain", |
1090 | "text/plain", | 1087 | "CHARACTER=CHARACTER", |
1091 | "CHARACTER=CHARACTER", | 1088 | strlen ("CHARACTER=CHARACTER") + 1, |
1092 | strlen ("CHARACTER=CHARACTER") + 1, | 1089 | 0 |
1093 | 0 | 1090 | }, |
1094 | }, | 1091 | { |
1095 | { | 1092 | EXTRACTOR_METATYPE_WRITER, |
1096 | EXTRACTOR_METATYPE_WRITER, | 1093 | EXTRACTOR_METAFORMAT_UTF8, |
1097 | EXTRACTOR_METAFORMAT_UTF8, | 1094 | "text/plain", |
1098 | "text/plain", | 1095 | "WRITTEN_BY", |
1099 | "WRITTEN_BY", | 1096 | strlen ("WRITTEN_BY") + 1, |
1100 | strlen ("WRITTEN_BY") + 1, | 1097 | 0 |
1101 | 0 | 1098 | }, |
1102 | }, | 1099 | { |
1103 | { | 1100 | EXTRACTOR_METATYPE_UNKNOWN, |
1104 | EXTRACTOR_METATYPE_UNKNOWN, | 1101 | EXTRACTOR_METAFORMAT_UTF8, |
1105 | EXTRACTOR_METAFORMAT_UTF8, | 1102 | "text/plain", |
1106 | "text/plain", | 1103 | "SCREENPLAY_BY=SCREENPLAY_BY", |
1107 | "SCREENPLAY_BY=SCREENPLAY_BY", | 1104 | strlen ("SCREENPLAY_BY=SCREENPLAY_BY") + 1, |
1108 | strlen ("SCREENPLAY_BY=SCREENPLAY_BY") + 1, | 1105 | 0 |
1109 | 0 | 1106 | }, |
1110 | }, | 1107 | { |
1111 | { | 1108 | EXTRACTOR_METATYPE_UNKNOWN, |
1112 | EXTRACTOR_METATYPE_UNKNOWN, | 1109 | EXTRACTOR_METAFORMAT_UTF8, |
1113 | EXTRACTOR_METAFORMAT_UTF8, | 1110 | "text/plain", |
1114 | "text/plain", | 1111 | "EDITED_BY=EDITED_BY", |
1115 | "EDITED_BY=EDITED_BY", | 1112 | strlen ("EDITED_BY=EDITED_BY") + 1, |
1116 | strlen ("EDITED_BY=EDITED_BY") + 1, | 1113 | 0 |
1117 | 0 | 1114 | }, |
1118 | }, | 1115 | { |
1119 | { | 1116 | EXTRACTOR_METATYPE_PRODUCER, |
1120 | EXTRACTOR_METATYPE_PRODUCER, | 1117 | EXTRACTOR_METAFORMAT_UTF8, |
1121 | EXTRACTOR_METAFORMAT_UTF8, | 1118 | "text/plain", |
1122 | "text/plain", | 1119 | "PRODUCER", |
1123 | "PRODUCER", | 1120 | strlen ("PRODUCER") + 1, |
1124 | strlen ("PRODUCER") + 1, | 1121 | 0 |
1125 | 0 | 1122 | }, |
1126 | }, | 1123 | { |
1127 | { | 1124 | EXTRACTOR_METATYPE_UNKNOWN, |
1128 | EXTRACTOR_METATYPE_UNKNOWN, | 1125 | EXTRACTOR_METAFORMAT_UTF8, |
1129 | EXTRACTOR_METAFORMAT_UTF8, | 1126 | "text/plain", |
1130 | "text/plain", | 1127 | "COPRODUCER=COPRODUCER", |
1131 | "COPRODUCER=COPRODUCER", | 1128 | strlen ("COPRODUCER=COPRODUCER") + 1, |
1132 | strlen ("COPRODUCER=COPRODUCER") + 1, | 1129 | 0 |
1133 | 0 | 1130 | }, |
1134 | }, | 1131 | { |
1135 | { | 1132 | EXTRACTOR_METATYPE_UNKNOWN, |
1136 | EXTRACTOR_METATYPE_UNKNOWN, | 1133 | EXTRACTOR_METAFORMAT_UTF8, |
1137 | EXTRACTOR_METAFORMAT_UTF8, | 1134 | "text/plain", |
1138 | "text/plain", | 1135 | "EXECUTIVE_PRODUCER=EXECUTIVE_PRODUCER", |
1139 | "EXECUTIVE_PRODUCER=EXECUTIVE_PRODUCER", | 1136 | strlen ("EXECUTIVE_PRODUCER=EXECUTIVE_PRODUCER") + 1, |
1140 | strlen ("EXECUTIVE_PRODUCER=EXECUTIVE_PRODUCER") + 1, | 1137 | 0 |
1141 | 0 | 1138 | }, |
1142 | }, | 1139 | { |
1143 | { | 1140 | EXTRACTOR_METATYPE_UNKNOWN, |
1144 | EXTRACTOR_METATYPE_UNKNOWN, | 1141 | EXTRACTOR_METAFORMAT_UTF8, |
1145 | EXTRACTOR_METAFORMAT_UTF8, | 1142 | "text/plain", |
1146 | "text/plain", | 1143 | "DISTRIBUTED_BY=DISTRIBUTED_BY", |
1147 | "DISTRIBUTED_BY=DISTRIBUTED_BY", | 1144 | strlen ("DISTRIBUTED_BY=DISTRIBUTED_BY") + 1, |
1148 | strlen ("DISTRIBUTED_BY=DISTRIBUTED_BY") + 1, | 1145 | 0 |
1149 | 0 | 1146 | }, |
1150 | }, | 1147 | { |
1151 | { | 1148 | EXTRACTOR_METATYPE_UNKNOWN, |
1152 | EXTRACTOR_METATYPE_UNKNOWN, | 1149 | EXTRACTOR_METAFORMAT_UTF8, |
1153 | EXTRACTOR_METAFORMAT_UTF8, | 1150 | "text/plain", |
1154 | "text/plain", | 1151 | "MASTERED_BY=MASTERED_BY", |
1155 | "MASTERED_BY=MASTERED_BY", | 1152 | strlen ("MASTERED_BY=MASTERED_BY") + 1, |
1156 | strlen ("MASTERED_BY=MASTERED_BY") + 1, | 1153 | 0 |
1157 | 0 | 1154 | }, |
1158 | }, | 1155 | { |
1159 | { | 1156 | EXTRACTOR_METATYPE_UNKNOWN, |
1160 | EXTRACTOR_METATYPE_UNKNOWN, | 1157 | EXTRACTOR_METAFORMAT_UTF8, |
1161 | EXTRACTOR_METAFORMAT_UTF8, | 1158 | "text/plain", |
1162 | "text/plain", | 1159 | "MIXED_BY=MIXED_BY", |
1163 | "MIXED_BY=MIXED_BY", | 1160 | strlen ("MIXED_BY=MIXED_BY") + 1, |
1164 | strlen ("MIXED_BY=MIXED_BY") + 1, | 1161 | 0 |
1165 | 0 | 1162 | }, |
1166 | }, | 1163 | { |
1167 | { | 1164 | EXTRACTOR_METATYPE_UNKNOWN, |
1168 | EXTRACTOR_METATYPE_UNKNOWN, | 1165 | EXTRACTOR_METAFORMAT_UTF8, |
1169 | EXTRACTOR_METAFORMAT_UTF8, | 1166 | "text/plain", |
1170 | "text/plain", | 1167 | "REMIXED_BY=REMIXED_BY", |
1171 | "REMIXED_BY=REMIXED_BY", | 1168 | strlen ("REMIXED_BY=REMIXED_BY") + 1, |
1172 | strlen ("REMIXED_BY=REMIXED_BY") + 1, | 1169 | 0 |
1173 | 0 | 1170 | }, |
1174 | }, | 1171 | { |
1175 | { | 1172 | EXTRACTOR_METATYPE_UNKNOWN, |
1176 | EXTRACTOR_METATYPE_UNKNOWN, | 1173 | EXTRACTOR_METAFORMAT_UTF8, |
1177 | EXTRACTOR_METAFORMAT_UTF8, | 1174 | "text/plain", |
1178 | "text/plain", | 1175 | "PRODUCTION_STUDIO=PRODUCTION_STUDIO", |
1179 | "PRODUCTION_STUDIO=PRODUCTION_STUDIO", | 1176 | strlen ("PRODUCTION_STUDIO=PRODUCTION_STUDIO") + 1, |
1180 | strlen ("PRODUCTION_STUDIO=PRODUCTION_STUDIO") + 1, | 1177 | 0 |
1181 | 0 | 1178 | }, |
1182 | }, | 1179 | { |
1183 | { | 1180 | EXTRACTOR_METATYPE_UNKNOWN, |
1184 | EXTRACTOR_METATYPE_UNKNOWN, | 1181 | EXTRACTOR_METAFORMAT_UTF8, |
1185 | EXTRACTOR_METAFORMAT_UTF8, | 1182 | "text/plain", |
1186 | "text/plain", | 1183 | "THANKS_TO=THANKS_TO", |
1187 | "THANKS_TO=THANKS_TO", | 1184 | strlen ("THANKS_TO=THANKS_TO") + 1, |
1188 | strlen ("THANKS_TO=THANKS_TO") + 1, | 1185 | 0 |
1189 | 0 | 1186 | }, |
1190 | }, | 1187 | { |
1191 | { | 1188 | EXTRACTOR_METATYPE_PUBLISHER, |
1192 | EXTRACTOR_METATYPE_PUBLISHER, | 1189 | EXTRACTOR_METAFORMAT_UTF8, |
1193 | EXTRACTOR_METAFORMAT_UTF8, | 1190 | "text/plain", |
1194 | "text/plain", | 1191 | "PUBLISHER", |
1195 | "PUBLISHER", | 1192 | strlen ("PUBLISHER") + 1, |
1196 | strlen ("PUBLISHER") + 1, | 1193 | 0 |
1197 | 0 | 1194 | }, |
1198 | }, | 1195 | { |
1199 | { | 1196 | EXTRACTOR_METATYPE_UNKNOWN, |
1200 | EXTRACTOR_METATYPE_UNKNOWN, | 1197 | EXTRACTOR_METAFORMAT_UTF8, |
1201 | EXTRACTOR_METAFORMAT_UTF8, | 1198 | "text/plain", |
1202 | "text/plain", | 1199 | "LABEL=LABEL", |
1203 | "LABEL=LABEL", | 1200 | strlen ("LABEL=LABEL") + 1, |
1204 | strlen ("LABEL=LABEL") + 1, | 1201 | 0 |
1205 | 0 | 1202 | }, |
1206 | }, | 1203 | { |
1207 | { | 1204 | EXTRACTOR_METATYPE_MOOD, |
1208 | EXTRACTOR_METATYPE_MOOD, | 1205 | EXTRACTOR_METAFORMAT_UTF8, |
1209 | EXTRACTOR_METAFORMAT_UTF8, | 1206 | "text/plain", |
1210 | "text/plain", | 1207 | "MOOD", |
1211 | "MOOD", | 1208 | strlen ("MOOD") + 1, |
1212 | strlen ("MOOD") + 1, | 1209 | 0 |
1213 | 0 | 1210 | }, |
1214 | }, | 1211 | { |
1215 | { | 1212 | EXTRACTOR_METATYPE_UNKNOWN, |
1216 | EXTRACTOR_METATYPE_UNKNOWN, | 1213 | EXTRACTOR_METAFORMAT_UTF8, |
1217 | EXTRACTOR_METAFORMAT_UTF8, | 1214 | "text/plain", |
1218 | "text/plain", | 1215 | "ORIGINAL_MEDIA_TYPE=ORIGINAL_MEDIA_TYPE", |
1219 | "ORIGINAL_MEDIA_TYPE=ORIGINAL_MEDIA_TYPE", | 1216 | strlen ("ORIGINAL_MEDIA_TYPE=ORIGINAL_MEDIA_TYPE") + 1, |
1220 | strlen ("ORIGINAL_MEDIA_TYPE=ORIGINAL_MEDIA_TYPE") + 1, | 1217 | 0 |
1221 | 0 | 1218 | }, |
1222 | }, | 1219 | { |
1223 | { | 1220 | EXTRACTOR_METATYPE_UNKNOWN, |
1224 | EXTRACTOR_METATYPE_UNKNOWN, | 1221 | EXTRACTOR_METAFORMAT_UTF8, |
1225 | EXTRACTOR_METAFORMAT_UTF8, | 1222 | "text/plain", |
1226 | "text/plain", | 1223 | "CONTENT_TYPE=CONTENT_TYPE", |
1227 | "CONTENT_TYPE=CONTENT_TYPE", | 1224 | strlen ("CONTENT_TYPE=CONTENT_TYPE") + 1, |
1228 | strlen ("CONTENT_TYPE=CONTENT_TYPE") + 1, | 1225 | 0 |
1229 | 0 | 1226 | }, |
1230 | }, | 1227 | { |
1231 | { | 1228 | EXTRACTOR_METATYPE_SUBJECT, |
1232 | EXTRACTOR_METATYPE_SUBJECT, | 1229 | EXTRACTOR_METAFORMAT_UTF8, |
1233 | EXTRACTOR_METAFORMAT_UTF8, | 1230 | "text/plain", |
1234 | "text/plain", | 1231 | "SUBJECT", |
1235 | "SUBJECT", | 1232 | strlen ("SUBJECT") + 1, |
1236 | strlen ("SUBJECT") + 1, | 1233 | 0 |
1237 | 0 | 1234 | }, |
1238 | }, | 1235 | { |
1239 | { | 1236 | EXTRACTOR_METATYPE_SUMMARY, |
1240 | EXTRACTOR_METATYPE_SUMMARY, | 1237 | EXTRACTOR_METAFORMAT_UTF8, |
1241 | EXTRACTOR_METAFORMAT_UTF8, | 1238 | "text/plain", |
1242 | "text/plain", | 1239 | "SUMMARY", |
1243 | "SUMMARY", | 1240 | strlen ("SUMMARY") + 1, |
1244 | strlen ("SUMMARY") + 1, | 1241 | 0 |
1245 | 0 | 1242 | }, |
1246 | }, | 1243 | { |
1247 | { | 1244 | EXTRACTOR_METATYPE_UNKNOWN, |
1248 | EXTRACTOR_METATYPE_UNKNOWN, | 1245 | EXTRACTOR_METAFORMAT_UTF8, |
1249 | EXTRACTOR_METAFORMAT_UTF8, | 1246 | "text/plain", |
1250 | "text/plain", | 1247 | "SYNOPSIS=SYNOPSIS", |
1251 | "SYNOPSIS=SYNOPSIS", | 1248 | strlen ("SYNOPSIS=SYNOPSIS") + 1, |
1252 | strlen ("SYNOPSIS=SYNOPSIS") + 1, | 1249 | 0 |
1253 | 0 | 1250 | }, |
1254 | }, | 1251 | { |
1255 | { | 1252 | EXTRACTOR_METATYPE_UNKNOWN, |
1256 | EXTRACTOR_METATYPE_UNKNOWN, | 1253 | EXTRACTOR_METAFORMAT_UTF8, |
1257 | EXTRACTOR_METAFORMAT_UTF8, | 1254 | "text/plain", |
1258 | "text/plain", | 1255 | "INITIAL_KEY=INITIAL_KEY", |
1259 | "INITIAL_KEY=INITIAL_KEY", | 1256 | strlen ("INITIAL_KEY=INITIAL_KEY") + 1, |
1260 | strlen ("INITIAL_KEY=INITIAL_KEY") + 1, | 1257 | 0 |
1261 | 0 | 1258 | }, |
1262 | }, | 1259 | { |
1263 | { | 1260 | EXTRACTOR_METATYPE_UNKNOWN, |
1264 | EXTRACTOR_METATYPE_UNKNOWN, | 1261 | EXTRACTOR_METAFORMAT_UTF8, |
1265 | EXTRACTOR_METAFORMAT_UTF8, | 1262 | "text/plain", |
1266 | "text/plain", | 1263 | "PERIOD=PERIOD", |
1267 | "PERIOD=PERIOD", | 1264 | strlen ("PERIOD=PERIOD") + 1, |
1268 | strlen ("PERIOD=PERIOD") + 1, | 1265 | 0 |
1269 | 0 | 1266 | }, |
1270 | }, | 1267 | { |
1271 | { | 1268 | EXTRACTOR_METATYPE_UNKNOWN, |
1272 | EXTRACTOR_METATYPE_UNKNOWN, | 1269 | EXTRACTOR_METAFORMAT_UTF8, |
1273 | EXTRACTOR_METAFORMAT_UTF8, | 1270 | "text/plain", |
1274 | "text/plain", | 1271 | "LAW_RATING=LAW_RATING", |
1275 | "LAW_RATING=LAW_RATING", | 1272 | strlen ("LAW_RATING=LAW_RATING") + 1, |
1276 | strlen ("LAW_RATING=LAW_RATING") + 1, | 1273 | 0 |
1277 | 0 | 1274 | }, |
1278 | }, | 1275 | { |
1279 | { | 1276 | EXTRACTOR_METATYPE_UNKNOWN, |
1280 | EXTRACTOR_METATYPE_UNKNOWN, | 1277 | EXTRACTOR_METAFORMAT_UTF8, |
1281 | EXTRACTOR_METAFORMAT_UTF8, | 1278 | "text/plain", |
1282 | "text/plain", | 1279 | "COMPOSITION_LOCATION=COMPOSITION_LOCATION", |
1283 | "COMPOSITION_LOCATION=COMPOSITION_LOCATION", | 1280 | strlen ("COMPOSITION_LOCATION=COMPOSITION_LOCATION") + 1, |
1284 | strlen ("COMPOSITION_LOCATION=COMPOSITION_LOCATION") + 1, | 1281 | 0 |
1285 | 0 | 1282 | }, |
1286 | }, | 1283 | { |
1287 | { | 1284 | EXTRACTOR_METATYPE_UNKNOWN, |
1288 | EXTRACTOR_METATYPE_UNKNOWN, | 1285 | EXTRACTOR_METAFORMAT_UTF8, |
1289 | EXTRACTOR_METAFORMAT_UTF8, | 1286 | "text/plain", |
1290 | "text/plain", | 1287 | "COMPOSER_NATIONALITY=COMPOSER_NATIONALITY", |
1291 | "COMPOSER_NATIONALITY=COMPOSER_NATIONALITY", | 1288 | strlen ("COMPOSER_NATIONALITY=COMPOSER_NATIONALITY") + 1, |
1292 | strlen ("COMPOSER_NATIONALITY=COMPOSER_NATIONALITY") + 1, | 1289 | 0 |
1293 | 0 | 1290 | }, |
1294 | }, | 1291 | { |
1295 | { | 1292 | EXTRACTOR_METATYPE_PLAY_COUNTER, |
1296 | EXTRACTOR_METATYPE_PLAY_COUNTER, | 1293 | EXTRACTOR_METAFORMAT_UTF8, |
1297 | EXTRACTOR_METAFORMAT_UTF8, | 1294 | "text/plain", |
1298 | "text/plain", | 1295 | "PLAY_COUNTER", |
1299 | "PLAY_COUNTER", | 1296 | strlen ("PLAY_COUNTER") + 1, |
1300 | strlen ("PLAY_COUNTER") + 1, | 1297 | 0 |
1301 | 0 | 1298 | }, |
1302 | }, | 1299 | { |
1303 | { | 1300 | EXTRACTOR_METATYPE_RATING, |
1304 | EXTRACTOR_METATYPE_RATING, | 1301 | EXTRACTOR_METAFORMAT_UTF8, |
1305 | EXTRACTOR_METAFORMAT_UTF8, | 1302 | "text/plain", |
1306 | "text/plain", | 1303 | "RATING", |
1307 | "RATING", | 1304 | strlen ("RATING") + 1, |
1308 | strlen ("RATING") + 1, | 1305 | 0 |
1309 | 0 | 1306 | }, |
1310 | }, | 1307 | { |
1311 | { | 1308 | EXTRACTOR_METATYPE_UNKNOWN, |
1312 | EXTRACTOR_METATYPE_UNKNOWN, | 1309 | EXTRACTOR_METAFORMAT_UTF8, |
1313 | EXTRACTOR_METAFORMAT_UTF8, | 1310 | "text/plain", |
1314 | "text/plain", | 1311 | "ENCODER_SETTINGS=ENCODER_SETTINGS", |
1315 | "ENCODER_SETTINGS=ENCODER_SETTINGS", | 1312 | strlen ("ENCODER_SETTINGS=ENCODER_SETTINGS") + 1, |
1316 | strlen ("ENCODER_SETTINGS=ENCODER_SETTINGS") + 1, | 1313 | 0 |
1317 | 0 | 1314 | }, |
1318 | }, | 1315 | { |
1319 | { | 1316 | EXTRACTOR_METATYPE_FRAME_RATE, |
1320 | EXTRACTOR_METATYPE_FRAME_RATE, | 1317 | EXTRACTOR_METAFORMAT_UTF8, |
1321 | EXTRACTOR_METAFORMAT_UTF8, | 1318 | "text/plain", |
1322 | "text/plain", | 1319 | "FPS", |
1323 | "FPS", | 1320 | strlen ("FPS") + 1, |
1324 | strlen ("FPS") + 1, | 1321 | 0 |
1325 | 0 | 1322 | }, |
1326 | }, | 1323 | { |
1327 | { | 1324 | EXTRACTOR_METATYPE_UNKNOWN, |
1328 | EXTRACTOR_METATYPE_UNKNOWN, | 1325 | EXTRACTOR_METAFORMAT_UTF8, |
1329 | EXTRACTOR_METAFORMAT_UTF8, | 1326 | "text/plain", |
1330 | "text/plain", | 1327 | "MEASURE=MEASURE", |
1331 | "MEASURE=MEASURE", | 1328 | strlen ("MEASURE=MEASURE") + 1, |
1332 | strlen ("MEASURE=MEASURE") + 1, | 1329 | 0 |
1333 | 0 | 1330 | }, |
1334 | }, | 1331 | { |
1335 | { | 1332 | EXTRACTOR_METATYPE_UNKNOWN, |
1336 | EXTRACTOR_METATYPE_UNKNOWN, | 1333 | EXTRACTOR_METAFORMAT_UTF8, |
1337 | EXTRACTOR_METAFORMAT_UTF8, | 1334 | "text/plain", |
1338 | "text/plain", | 1335 | "TUNING=TUNING", |
1339 | "TUNING=TUNING", | 1336 | strlen ("TUNING=TUNING") + 1, |
1340 | strlen ("TUNING=TUNING") + 1, | 1337 | 0 |
1341 | 0 | 1338 | }, |
1342 | }, | 1339 | { |
1343 | { | 1340 | EXTRACTOR_METATYPE_UNKNOWN, |
1344 | EXTRACTOR_METATYPE_UNKNOWN, | 1341 | EXTRACTOR_METAFORMAT_UTF8, |
1345 | EXTRACTOR_METAFORMAT_UTF8, | 1342 | "text/plain", |
1346 | "text/plain", | 1343 | "ISBN=ISBN", |
1347 | "ISBN=ISBN", | 1344 | strlen ("ISBN=ISBN") + 1, |
1348 | strlen ("ISBN=ISBN") + 1, | 1345 | 0 |
1349 | 0 | 1346 | }, |
1350 | }, | 1347 | { |
1351 | { | 1348 | EXTRACTOR_METATYPE_UNKNOWN, |
1352 | EXTRACTOR_METATYPE_UNKNOWN, | 1349 | EXTRACTOR_METAFORMAT_UTF8, |
1353 | EXTRACTOR_METAFORMAT_UTF8, | 1350 | "text/plain", |
1354 | "text/plain", | 1351 | "BARCODE=BARCODE", |
1355 | "BARCODE=BARCODE", | 1352 | strlen ("BARCODE=BARCODE") + 1, |
1356 | strlen ("BARCODE=BARCODE") + 1, | 1353 | 0 |
1357 | 0 | 1354 | }, |
1358 | }, | 1355 | { |
1359 | { | 1356 | EXTRACTOR_METATYPE_UNKNOWN, |
1360 | EXTRACTOR_METATYPE_UNKNOWN, | 1357 | EXTRACTOR_METAFORMAT_UTF8, |
1361 | EXTRACTOR_METAFORMAT_UTF8, | 1358 | "text/plain", |
1362 | "text/plain", | 1359 | "CATALOG_NUMBER=CATALOG_NUMBER", |
1363 | "CATALOG_NUMBER=CATALOG_NUMBER", | 1360 | strlen ("CATALOG_NUMBER=CATALOG_NUMBER") + 1, |
1364 | strlen ("CATALOG_NUMBER=CATALOG_NUMBER") + 1, | 1361 | 0 |
1365 | 0 | 1362 | }, |
1366 | }, | 1363 | { |
1367 | { | 1364 | EXTRACTOR_METATYPE_UNKNOWN, |
1368 | EXTRACTOR_METATYPE_UNKNOWN, | 1365 | EXTRACTOR_METAFORMAT_UTF8, |
1369 | EXTRACTOR_METAFORMAT_UTF8, | 1366 | "text/plain", |
1370 | "text/plain", | 1367 | "LABEL_CODE=LABEL_CODE", |
1371 | "LABEL_CODE=LABEL_CODE", | 1368 | strlen ("LABEL_CODE=LABEL_CODE") + 1, |
1372 | strlen ("LABEL_CODE=LABEL_CODE") + 1, | 1369 | 0 |
1373 | 0 | 1370 | }, |
1374 | }, | 1371 | { |
1375 | { | 1372 | EXTRACTOR_METATYPE_UNKNOWN, |
1376 | EXTRACTOR_METATYPE_UNKNOWN, | 1373 | EXTRACTOR_METAFORMAT_UTF8, |
1377 | EXTRACTOR_METAFORMAT_UTF8, | 1374 | "text/plain", |
1378 | "text/plain", | 1375 | "LCCN=LCCN", |
1379 | "LCCN=LCCN", | 1376 | strlen ("LCCN=LCCN") + 1, |
1380 | strlen ("LCCN=LCCN") + 1, | 1377 | 0 |
1381 | 0 | 1378 | }, |
1382 | }, | 1379 | { |
1383 | { | 1380 | EXTRACTOR_METATYPE_UNKNOWN, |
1384 | EXTRACTOR_METATYPE_UNKNOWN, | 1381 | EXTRACTOR_METAFORMAT_UTF8, |
1385 | EXTRACTOR_METAFORMAT_UTF8, | 1382 | "text/plain", |
1386 | "text/plain", | 1383 | "PURCHASE_ITEM=PURCHASE_ITEM", |
1387 | "PURCHASE_ITEM=PURCHASE_ITEM", | 1384 | strlen ("PURCHASE_ITEM=PURCHASE_ITEM") + 1, |
1388 | strlen ("PURCHASE_ITEM=PURCHASE_ITEM") + 1, | 1385 | 0 |
1389 | 0 | 1386 | }, |
1390 | }, | 1387 | { |
1391 | { | 1388 | EXTRACTOR_METATYPE_UNKNOWN, |
1392 | EXTRACTOR_METATYPE_UNKNOWN, | 1389 | EXTRACTOR_METAFORMAT_UTF8, |
1393 | EXTRACTOR_METAFORMAT_UTF8, | 1390 | "text/plain", |
1394 | "text/plain", | 1391 | "PURCHASE_INFO=PURCHASE_INFO", |
1395 | "PURCHASE_INFO=PURCHASE_INFO", | 1392 | strlen ("PURCHASE_INFO=PURCHASE_INFO") + 1, |
1396 | strlen ("PURCHASE_INFO=PURCHASE_INFO") + 1, | 1393 | 0 |
1397 | 0 | 1394 | }, |
1398 | }, | 1395 | { |
1399 | { | 1396 | EXTRACTOR_METATYPE_UNKNOWN, |
1400 | EXTRACTOR_METATYPE_UNKNOWN, | 1397 | EXTRACTOR_METAFORMAT_UTF8, |
1401 | EXTRACTOR_METAFORMAT_UTF8, | 1398 | "text/plain", |
1402 | "text/plain", | 1399 | "PURCHASE_OWNER=PURCHASE_OWNER", |
1403 | "PURCHASE_OWNER=PURCHASE_OWNER", | 1400 | strlen ("PURCHASE_OWNER=PURCHASE_OWNER") + 1, |
1404 | strlen ("PURCHASE_OWNER=PURCHASE_OWNER") + 1, | 1401 | 0 |
1405 | 0 | 1402 | }, |
1406 | }, | 1403 | { |
1407 | { | 1404 | EXTRACTOR_METATYPE_UNKNOWN, |
1408 | EXTRACTOR_METATYPE_UNKNOWN, | 1405 | EXTRACTOR_METAFORMAT_UTF8, |
1409 | EXTRACTOR_METAFORMAT_UTF8, | 1406 | "text/plain", |
1410 | "text/plain", | 1407 | "PURCHASE_PRICE=PURCHASE_PRICE", |
1411 | "PURCHASE_PRICE=PURCHASE_PRICE", | 1408 | strlen ("PURCHASE_PRICE=PURCHASE_PRICE") + 1, |
1412 | strlen ("PURCHASE_PRICE=PURCHASE_PRICE") + 1, | 1409 | 0 |
1413 | 0 | 1410 | }, |
1414 | }, | 1411 | { |
1415 | { | 1412 | EXTRACTOR_METATYPE_UNKNOWN, |
1416 | EXTRACTOR_METATYPE_UNKNOWN, | 1413 | EXTRACTOR_METAFORMAT_UTF8, |
1417 | EXTRACTOR_METAFORMAT_UTF8, | 1414 | "text/plain", |
1418 | "text/plain", | 1415 | "PURCHASE_CURRENCY=PURCHASE_CURRENCY", |
1419 | "PURCHASE_CURRENCY=PURCHASE_CURRENCY", | 1416 | strlen ("PURCHASE_CURRENCY=PURCHASE_CURRENCY") + 1, |
1420 | strlen ("PURCHASE_CURRENCY=PURCHASE_CURRENCY") + 1, | 1417 | 0 |
1421 | 0 | 1418 | }, |
1422 | }, | 1419 | { |
1423 | { | 1420 | EXTRACTOR_METATYPE_ORIGINAL_TITLE, |
1424 | EXTRACTOR_METATYPE_ORIGINAL_TITLE, | 1421 | EXTRACTOR_METAFORMAT_UTF8, |
1425 | EXTRACTOR_METAFORMAT_UTF8, | 1422 | "text/plain", |
1426 | "text/plain", | 1423 | "ORIGINAL/TITLE", |
1427 | "ORIGINAL/TITLE", | 1424 | strlen ("ORIGINAL/TITLE") + 1, |
1428 | strlen ("ORIGINAL/TITLE") + 1, | 1425 | 0 |
1429 | 0 | 1426 | }, |
1430 | }, | 1427 | { |
1431 | { | 1428 | EXTRACTOR_METATYPE_UNKNOWN, |
1432 | EXTRACTOR_METATYPE_UNKNOWN, | 1429 | EXTRACTOR_METAFORMAT_UTF8, |
1433 | EXTRACTOR_METAFORMAT_UTF8, | 1430 | "text/plain", |
1434 | "text/plain", | 1431 | "ORIGINAL/ARTIST/SORT_WITH=ORIGINAL/ARTIST/SORT_WITH", |
1435 | "ORIGINAL/ARTIST/SORT_WITH=ORIGINAL/ARTIST/SORT_WITH", | 1432 | strlen ("ORIGINAL/ARTIST/SORT_WITH=ORIGINAL/ARTIST/SORT_WITH") + 1, |
1436 | strlen ("ORIGINAL/ARTIST/SORT_WITH=ORIGINAL/ARTIST/SORT_WITH") + 1, | 1433 | 0 |
1437 | 0 | 1434 | }, |
1438 | }, | 1435 | { |
1439 | { | 1436 | EXTRACTOR_METATYPE_ORIGINAL_ARTIST, |
1440 | EXTRACTOR_METATYPE_ORIGINAL_ARTIST, | 1437 | EXTRACTOR_METAFORMAT_UTF8, |
1441 | EXTRACTOR_METAFORMAT_UTF8, | 1438 | "text/plain", |
1442 | "text/plain", | 1439 | "ORIGINAL/ARTIST", |
1443 | "ORIGINAL/ARTIST", | 1440 | strlen ("ORIGINAL/ARTIST") + 1, |
1444 | strlen ("ORIGINAL/ARTIST") + 1, | 1441 | 0 |
1445 | 0 | 1442 | }, |
1446 | }, | 1443 | { |
1447 | { | 1444 | EXTRACTOR_METATYPE_TRACK_NUMBER, |
1448 | EXTRACTOR_METATYPE_TRACK_NUMBER, | 1445 | EXTRACTOR_METAFORMAT_UTF8, |
1449 | EXTRACTOR_METAFORMAT_UTF8, | 1446 | "text/plain", |
1450 | "text/plain", | 1447 | "10", |
1451 | "10", | 1448 | strlen ("10") + 1, |
1452 | strlen ("10") + 1, | 1449 | 0 |
1453 | 0 | 1450 | }, |
1454 | }, | 1451 | { |
1455 | { | 1452 | EXTRACTOR_METATYPE_COPYRIGHT, |
1456 | EXTRACTOR_METATYPE_COPYRIGHT, | 1453 | EXTRACTOR_METAFORMAT_UTF8, |
1457 | EXTRACTOR_METAFORMAT_UTF8, | 1454 | "text/plain", |
1458 | "text/plain", | 1455 | "COPYRIGHT", |
1459 | "COPYRIGHT", | 1456 | strlen ("COPYRIGHT") + 1, |
1460 | strlen ("COPYRIGHT") + 1, | 1457 | 0 |
1461 | 0 | 1458 | }, |
1462 | }, | 1459 | { |
1463 | { | 1460 | EXTRACTOR_METATYPE_CONTACT_INFORMATION, |
1464 | EXTRACTOR_METATYPE_CONTACT_INFORMATION, | 1461 | EXTRACTOR_METAFORMAT_UTF8, |
1465 | EXTRACTOR_METAFORMAT_UTF8, | 1462 | "text/plain", |
1466 | "text/plain", | 1463 | "COPYRIGHT/EMAIL", |
1467 | "COPYRIGHT/EMAIL", | 1464 | strlen ("COPYRIGHT/EMAIL") + 1, |
1468 | strlen ("COPYRIGHT/EMAIL") + 1, | 1465 | 0 |
1469 | 0 | 1466 | }, |
1470 | }, | 1467 | { |
1471 | { | 1468 | EXTRACTOR_METATYPE_CONTACT_INFORMATION, |
1472 | EXTRACTOR_METATYPE_CONTACT_INFORMATION, | 1469 | EXTRACTOR_METAFORMAT_UTF8, |
1473 | EXTRACTOR_METAFORMAT_UTF8, | 1470 | "text/plain", |
1474 | "text/plain", | 1471 | "COPYRIGHT/ADDRESS", |
1475 | "COPYRIGHT/ADDRESS", | 1472 | strlen ("COPYRIGHT/ADDRESS") + 1, |
1476 | strlen ("COPYRIGHT/ADDRESS") + 1, | 1473 | 0 |
1477 | 0 | 1474 | }, |
1478 | }, | 1475 | { |
1479 | { | 1476 | EXTRACTOR_METATYPE_CREATION_TIME, |
1480 | EXTRACTOR_METATYPE_CREATION_TIME, | 1477 | EXTRACTOR_METAFORMAT_UTF8, |
1481 | EXTRACTOR_METAFORMAT_UTF8, | 1478 | "text/plain", |
1482 | "text/plain", | 1479 | "1999-01-01", |
1483 | "1999-01-01", | 1480 | strlen ("1999-01-01") + 1, |
1484 | strlen ("1999-01-01") + 1, | 1481 | 0 |
1485 | 0 | 1482 | }, |
1486 | }, | 1483 | { |
1487 | { | 1484 | EXTRACTOR_METATYPE_COMMENT, |
1488 | EXTRACTOR_METATYPE_COMMENT, | 1485 | EXTRACTOR_METAFORMAT_UTF8, |
1489 | EXTRACTOR_METAFORMAT_UTF8, | 1486 | "text/plain", |
1490 | "text/plain", | 1487 | "The purpose of this file is to hold as many examples of Matroska tags as possible.", |
1491 | "The purpose of this file is to hold as many examples of Matroska tags as possible.", | 1488 | strlen ( |
1492 | strlen ("The purpose of this file is to hold as many examples of Matroska tags as possible.") + 1, | 1489 | "The purpose of this file is to hold as many examples of Matroska tags as possible.") |
1493 | 0 | 1490 | + 1, |
1494 | }, | 1491 | 0 |
1495 | { | 1492 | }, |
1496 | EXTRACTOR_METATYPE_COMPOSER, | 1493 | { |
1497 | EXTRACTOR_METAFORMAT_UTF8, | 1494 | EXTRACTOR_METATYPE_COMPOSER, |
1498 | "text/plain", | 1495 | EXTRACTOR_METAFORMAT_UTF8, |
1499 | "COMPOSER", | 1496 | "text/plain", |
1500 | strlen ("COMPOSER") + 1, | 1497 | "COMPOSER", |
1501 | 0 | 1498 | strlen ("COMPOSER") + 1, |
1502 | }, | 1499 | 0 |
1503 | { | 1500 | }, |
1504 | EXTRACTOR_METATYPE_PERFORMER, | 1501 | { |
1505 | EXTRACTOR_METAFORMAT_UTF8, | 1502 | EXTRACTOR_METATYPE_PERFORMER, |
1506 | "text/plain", | 1503 | EXTRACTOR_METAFORMAT_UTF8, |
1507 | "ACCOMPANIMENT", | 1504 | "text/plain", |
1508 | strlen ("ACCOMPANIMENT") + 1, | 1505 | "ACCOMPANIMENT", |
1509 | 0 | 1506 | strlen ("ACCOMPANIMENT") + 1, |
1510 | }, | 1507 | 0 |
1511 | { | 1508 | }, |
1512 | EXTRACTOR_METATYPE_PERFORMER, | 1509 | { |
1513 | EXTRACTOR_METAFORMAT_UTF8, | 1510 | EXTRACTOR_METATYPE_PERFORMER, |
1514 | "text/plain", | 1511 | EXTRACTOR_METAFORMAT_UTF8, |
1515 | "CONDUCTOR", | 1512 | "text/plain", |
1516 | strlen ("CONDUCTOR") + 1, | 1513 | "CONDUCTOR", |
1517 | 0 | 1514 | strlen ("CONDUCTOR") + 1, |
1518 | }, | 1515 | 0 |
1519 | { | 1516 | }, |
1520 | EXTRACTOR_METATYPE_LYRICS, | 1517 | { |
1521 | EXTRACTOR_METAFORMAT_UTF8, | 1518 | EXTRACTOR_METATYPE_LYRICS, |
1522 | "text/plain", | 1519 | EXTRACTOR_METAFORMAT_UTF8, |
1523 | "LYRICS", | 1520 | "text/plain", |
1524 | strlen ("LYRICS") + 1, | 1521 | "LYRICS", |
1525 | 0 | 1522 | strlen ("LYRICS") + 1, |
1526 | }, | 1523 | 0 |
1527 | { | 1524 | }, |
1528 | EXTRACTOR_METATYPE_ENCODED_BY, | 1525 | { |
1529 | EXTRACTOR_METAFORMAT_UTF8, | 1526 | EXTRACTOR_METATYPE_ENCODED_BY, |
1530 | "text/plain", | 1527 | EXTRACTOR_METAFORMAT_UTF8, |
1531 | "ENCODED_BY", | 1528 | "text/plain", |
1532 | strlen ("ENCODED_BY") + 1, | 1529 | "ENCODED_BY", |
1533 | 0 | 1530 | strlen ("ENCODED_BY") + 1, |
1534 | }, | 1531 | 0 |
1535 | { | 1532 | }, |
1536 | EXTRACTOR_METATYPE_GENRE, | 1533 | { |
1537 | EXTRACTOR_METAFORMAT_UTF8, | 1534 | EXTRACTOR_METATYPE_GENRE, |
1538 | "text/plain", | 1535 | EXTRACTOR_METAFORMAT_UTF8, |
1539 | "GENRE", | 1536 | "text/plain", |
1540 | strlen ("GENRE") + 1, | 1537 | "GENRE", |
1541 | 0 | 1538 | strlen ("GENRE") + 1, |
1542 | }, | 1539 | 0 |
1543 | { | 1540 | }, |
1544 | EXTRACTOR_METATYPE_DESCRIPTION, | 1541 | { |
1545 | EXTRACTOR_METAFORMAT_UTF8, | 1542 | EXTRACTOR_METATYPE_DESCRIPTION, |
1546 | "text/plain", | 1543 | EXTRACTOR_METAFORMAT_UTF8, |
1547 | "DESCRIPTION", | 1544 | "text/plain", |
1548 | strlen ("DESCRIPTION") + 1, | 1545 | "DESCRIPTION", |
1549 | 0 | 1546 | strlen ("DESCRIPTION") + 1, |
1550 | }, | 1547 | 0 |
1551 | { | 1548 | }, |
1552 | EXTRACTOR_METATYPE_KEYWORDS, | 1549 | { |
1553 | EXTRACTOR_METAFORMAT_UTF8, | 1550 | EXTRACTOR_METATYPE_KEYWORDS, |
1554 | "text/plain", | 1551 | EXTRACTOR_METAFORMAT_UTF8, |
1555 | "KEYWORDS", | 1552 | "text/plain", |
1556 | strlen ("KEYWORDS") + 1, | 1553 | "KEYWORDS", |
1557 | 0 | 1554 | strlen ("KEYWORDS") + 1, |
1558 | }, | 1555 | 0 |
1559 | { | 1556 | }, |
1560 | EXTRACTOR_METATYPE_LOCATION_NAME, | 1557 | { |
1561 | EXTRACTOR_METAFORMAT_UTF8, | 1558 | EXTRACTOR_METATYPE_LOCATION_NAME, |
1562 | "text/plain", | 1559 | EXTRACTOR_METAFORMAT_UTF8, |
1563 | "RECORDING_LOCATION", | 1560 | "text/plain", |
1564 | strlen ("RECORDING_LOCATION") + 1, | 1561 | "RECORDING_LOCATION", |
1565 | 0 | 1562 | strlen ("RECORDING_LOCATION") + 1, |
1566 | }, | 1563 | 0 |
1567 | { | 1564 | }, |
1568 | EXTRACTOR_METATYPE_ENCODER, | 1565 | { |
1569 | EXTRACTOR_METAFORMAT_UTF8, | 1566 | EXTRACTOR_METATYPE_ENCODER, |
1570 | "text/plain", | 1567 | EXTRACTOR_METAFORMAT_UTF8, |
1571 | "ENCODER", | 1568 | "text/plain", |
1572 | strlen ("ENCODER") + 1, | 1569 | "ENCODER", |
1573 | 0 | 1570 | strlen ("ENCODER") + 1, |
1574 | }, | 1571 | 0 |
1575 | { | 1572 | }, |
1576 | EXTRACTOR_METATYPE_ISRC, | 1573 | { |
1577 | EXTRACTOR_METAFORMAT_UTF8, | 1574 | EXTRACTOR_METATYPE_ISRC, |
1578 | "text/plain", | 1575 | EXTRACTOR_METAFORMAT_UTF8, |
1579 | "ISRC", | 1576 | "text/plain", |
1580 | strlen ("ISRC") + 1, | 1577 | "ISRC", |
1581 | 0 | 1578 | strlen ("ISRC") + 1, |
1582 | }, | 1579 | 0 |
1583 | { | 1580 | }, |
1584 | EXTRACTOR_METATYPE_LICENSE, | 1581 | { |
1585 | EXTRACTOR_METAFORMAT_UTF8, | 1582 | EXTRACTOR_METATYPE_LICENSE, |
1586 | "text/plain", | 1583 | EXTRACTOR_METAFORMAT_UTF8, |
1587 | "LICENSE", | 1584 | "text/plain", |
1588 | strlen ("LICENSE") + 1, | 1585 | "LICENSE", |
1589 | 0 | 1586 | strlen ("LICENSE") + 1, |
1590 | }, | 1587 | 0 |
1591 | { | 1588 | }, |
1592 | EXTRACTOR_METATYPE_CONTAINER_FORMAT, | 1589 | { |
1593 | EXTRACTOR_METAFORMAT_UTF8, | 1590 | EXTRACTOR_METATYPE_CONTAINER_FORMAT, |
1594 | "text/plain", | 1591 | EXTRACTOR_METAFORMAT_UTF8, |
1595 | "Matroska", | 1592 | "text/plain", |
1596 | strlen ("Matroska") + 1, | 1593 | "Matroska", |
1597 | 0 | 1594 | strlen ("Matroska") + 1, |
1598 | }, | 1595 | 0 |
1599 | { | 1596 | }, |
1600 | EXTRACTOR_METATYPE_VIDEO_CODEC, | 1597 | { |
1601 | EXTRACTOR_METAFORMAT_UTF8, | 1598 | EXTRACTOR_METATYPE_VIDEO_CODEC, |
1602 | "text/plain", | 1599 | EXTRACTOR_METAFORMAT_UTF8, |
1603 | "Intel Video 4", | 1600 | "text/plain", |
1604 | strlen ("Intel Video 4") + 1, | 1601 | "Intel Video 4", |
1605 | 0 | 1602 | strlen ("Intel Video 4") + 1, |
1606 | }, | 1603 | 0 |
1607 | { | 1604 | }, |
1608 | EXTRACTOR_METATYPE_VIDEO_LANGUAGE, | 1605 | { |
1609 | EXTRACTOR_METAFORMAT_UTF8, | 1606 | EXTRACTOR_METATYPE_VIDEO_LANGUAGE, |
1610 | "text/plain", | 1607 | EXTRACTOR_METAFORMAT_UTF8, |
1611 | "it", | 1608 | "text/plain", |
1612 | strlen ("it") + 1, | 1609 | "it", |
1613 | 0 | 1610 | strlen ("it") + 1, |
1614 | }, | 1611 | 0 |
1615 | { | 1612 | }, |
1616 | EXTRACTOR_METATYPE_VIDEO_DIMENSIONS, | 1613 | { |
1617 | EXTRACTOR_METAFORMAT_UTF8, | 1614 | EXTRACTOR_METATYPE_VIDEO_DIMENSIONS, |
1618 | "text/plain", | 1615 | EXTRACTOR_METAFORMAT_UTF8, |
1619 | "256x240", | 1616 | "text/plain", |
1620 | strlen ("256x240") + 1, | 1617 | "256x240", |
1621 | 0 | 1618 | strlen ("256x240") + 1, |
1622 | }, | 1619 | 0 |
1623 | { | 1620 | }, |
1624 | EXTRACTOR_METATYPE_FRAME_RATE, | 1621 | { |
1625 | EXTRACTOR_METAFORMAT_UTF8, | 1622 | EXTRACTOR_METATYPE_FRAME_RATE, |
1626 | "text/plain", | 1623 | EXTRACTOR_METAFORMAT_UTF8, |
1627 | "35/1", | 1624 | "text/plain", |
1628 | strlen ("35/1") + 1, | 1625 | "35/1", |
1629 | 0 | 1626 | strlen ("35/1") + 1, |
1630 | }, | 1627 | 0 |
1631 | { | 1628 | }, |
1632 | EXTRACTOR_METATYPE_PIXEL_ASPECT_RATIO, | 1629 | { |
1633 | EXTRACTOR_METAFORMAT_UTF8, | 1630 | EXTRACTOR_METATYPE_PIXEL_ASPECT_RATIO, |
1634 | "text/plain", | 1631 | EXTRACTOR_METAFORMAT_UTF8, |
1635 | "1/1", | 1632 | "text/plain", |
1636 | strlen ("1/1") + 1, | 1633 | "1/1", |
1637 | 0 | 1634 | strlen ("1/1") + 1, |
1638 | }, | 1635 | 0 |
1639 | { 0, 0, NULL, NULL, 0, -1 } | 1636 | }, |
1640 | }; | 1637 | { 0, 0, NULL, NULL, 0, -1 } |
1641 | struct ProblemSet patched_ps[] = | 1638 | }; |
1642 | { | 1639 | struct ProblemSet patched_ps[] = { |
1643 | { "testdata/matroska_flame.mkv", matroska_flame_patched_sol }, | 1640 | { "testdata/matroska_flame.mkv", matroska_flame_patched_sol }, |
1644 | { NULL, NULL } | 1641 | { NULL, NULL } |
1645 | }; | 1642 | }; |
1646 | g_print ("Running mkv test on GStreamer, assuming old version:\n"); | 1643 | g_print ("Running mkv test on GStreamer, assuming old version:\n"); |
1647 | result_stock = (0 == ET_main ("gstreamer", stock_ps)); | 1644 | result_stock = (0 == ET_main ("gstreamer", stock_ps)); |
1648 | g_print ("Old GStreamer test result: %s\n", result_stock == 0 ? "OK" : "FAILED"); | 1645 | g_print ("Old GStreamer test result: %s\n", result_stock == 0 ? "OK" : |
1646 | "FAILED"); | ||
1649 | g_print ("Running mkv test on GStreamer, assuming new version:\n"); | 1647 | g_print ("Running mkv test on GStreamer, assuming new version:\n"); |
1650 | result_patched = (0 == ET_main ("gstreamer", patched_ps)); | 1648 | result_patched = (0 == ET_main ("gstreamer", patched_ps)); |
1651 | g_print ("New GStreamer test result: %s\n", result_patched == 0 ? "OK" : "FAILED"); | 1649 | g_print ("New GStreamer test result: %s\n", result_patched == 0 ? "OK" : |
1650 | "FAILED"); | ||
1652 | if ((! result_stock) && (! result_patched)) | 1651 | if ((! result_stock) && (! result_patched)) |
1653 | result++; | 1652 | result++; |
1654 | } | 1653 | } |
1655 | g_object_unref (dc); | 1654 | g_object_unref (dc); |
1656 | if (0 != result) | 1655 | if (0 != result) |
1657 | { | 1656 | { |
1658 | fprintf (stderr, | 1657 | fprintf (stderr, |
1659 | "gstreamer library did not work perfectly --- consider updating it.\n"); | 1658 | "gstreamer library did not work perfectly --- consider updating it.\n"); |
1660 | /* do not fail hard, as we know many users have outdated gstreamer packages */ | 1659 | /* do not fail hard, as we know many users have outdated gstreamer packages */ |
1661 | result = 0; | 1660 | result = 0; |
1662 | } | 1661 | } |
1663 | return result; | 1662 | return result; |
1664 | } | 1663 | } |
1665 | 1664 | ||
1665 | |||
1666 | /* end of test_gstreamer.c */ | 1666 | /* end of test_gstreamer.c */ |
diff --git a/src/plugins/test_html.c b/src/plugins/test_html.c index e459eec..80d4a37 100644 --- a/src/plugins/test_html.c +++ b/src/plugins/test_html.c | |||
@@ -36,89 +36,88 @@ | |||
36 | int | 36 | int |
37 | main (int argc, char *argv[]) | 37 | main (int argc, char *argv[]) |
38 | { | 38 | { |
39 | struct SolutionData html_grothoff_sol[] = | 39 | struct SolutionData html_grothoff_sol[] = { |
40 | { | 40 | { |
41 | { | 41 | EXTRACTOR_METATYPE_TITLE, |
42 | EXTRACTOR_METATYPE_TITLE, | 42 | EXTRACTOR_METAFORMAT_UTF8, |
43 | EXTRACTOR_METAFORMAT_UTF8, | 43 | "text/plain", |
44 | "text/plain", | 44 | "Christian Grothoff", |
45 | "Christian Grothoff", | 45 | strlen ("Christian Grothoff") + 1, |
46 | strlen ("Christian Grothoff") + 1, | 46 | 0 |
47 | 0 | 47 | }, |
48 | }, | ||
49 | { | ||
50 | EXTRACTOR_METATYPE_DESCRIPTION, | ||
51 | EXTRACTOR_METAFORMAT_UTF8, | ||
52 | "text/plain", | ||
53 | "Homepage of Christian Grothoff", | ||
54 | strlen ("Homepage of Christian Grothoff") + 1, | ||
55 | 0 | ||
56 | }, | ||
57 | { | ||
58 | EXTRACTOR_METATYPE_AUTHOR_NAME, | ||
59 | EXTRACTOR_METAFORMAT_UTF8, | ||
60 | "text/plain", | ||
61 | "Christian Grothoff", | ||
62 | strlen ("Christian Grothoff") + 1, | ||
63 | 0 | ||
64 | }, | ||
65 | { | ||
66 | EXTRACTOR_METATYPE_KEYWORDS, | ||
67 | EXTRACTOR_METAFORMAT_UTF8, | ||
68 | "text/plain", | ||
69 | "Christian,Grothoff", | ||
70 | strlen ("Christian,Grothoff") + 1, | ||
71 | 0 | ||
72 | }, | ||
73 | { | ||
74 | EXTRACTOR_METATYPE_TITLE, | ||
75 | EXTRACTOR_METAFORMAT_UTF8, | ||
76 | "text/plain", | ||
77 | "Welcome to Christian Grothoff", | ||
78 | strlen ("Welcome to Christian Grothoff") + 1, | ||
79 | 0 | ||
80 | }, | ||
81 | { | ||
82 | EXTRACTOR_METATYPE_LANGUAGE, | ||
83 | EXTRACTOR_METAFORMAT_UTF8, | ||
84 | "text/plain", | ||
85 | "en", | ||
86 | strlen ("en") + 1, | ||
87 | 0 | ||
88 | }, | ||
89 | { | ||
90 | EXTRACTOR_METATYPE_PUBLISHER, | ||
91 | EXTRACTOR_METAFORMAT_UTF8, | ||
92 | "text/plain", | ||
93 | "Christian Grothoff", | ||
94 | strlen ("Christian Grothoff") + 1, | ||
95 | 0 | ||
96 | }, | ||
97 | { | ||
98 | EXTRACTOR_METATYPE_UNKNOWN_DATE, | ||
99 | EXTRACTOR_METAFORMAT_UTF8, | ||
100 | "text/plain", | ||
101 | "2000-08-20", | ||
102 | strlen ("2000-08-20") + 1, | ||
103 | 0 | ||
104 | }, | ||
105 | { | ||
106 | EXTRACTOR_METATYPE_RIGHTS, | ||
107 | EXTRACTOR_METAFORMAT_UTF8, | ||
108 | "text/plain", | ||
109 | "(C) 2000 by Christian Grothoff", | ||
110 | strlen ("(C) 2000 by Christian Grothoff") + 1, | ||
111 | 0 | ||
112 | }, | ||
113 | { 0, 0, NULL, NULL, 0, -1 } | ||
114 | }; | ||
115 | struct ProblemSet ps[] = | ||
116 | { | 48 | { |
117 | { "testdata/html_grothoff.html", | 49 | EXTRACTOR_METATYPE_DESCRIPTION, |
118 | html_grothoff_sol }, | 50 | EXTRACTOR_METAFORMAT_UTF8, |
119 | { NULL, NULL } | 51 | "text/plain", |
120 | }; | 52 | "Homepage of Christian Grothoff", |
53 | strlen ("Homepage of Christian Grothoff") + 1, | ||
54 | 0 | ||
55 | }, | ||
56 | { | ||
57 | EXTRACTOR_METATYPE_AUTHOR_NAME, | ||
58 | EXTRACTOR_METAFORMAT_UTF8, | ||
59 | "text/plain", | ||
60 | "Christian Grothoff", | ||
61 | strlen ("Christian Grothoff") + 1, | ||
62 | 0 | ||
63 | }, | ||
64 | { | ||
65 | EXTRACTOR_METATYPE_KEYWORDS, | ||
66 | EXTRACTOR_METAFORMAT_UTF8, | ||
67 | "text/plain", | ||
68 | "Christian,Grothoff", | ||
69 | strlen ("Christian,Grothoff") + 1, | ||
70 | 0 | ||
71 | }, | ||
72 | { | ||
73 | EXTRACTOR_METATYPE_TITLE, | ||
74 | EXTRACTOR_METAFORMAT_UTF8, | ||
75 | "text/plain", | ||
76 | "Welcome to Christian Grothoff", | ||
77 | strlen ("Welcome to Christian Grothoff") + 1, | ||
78 | 0 | ||
79 | }, | ||
80 | { | ||
81 | EXTRACTOR_METATYPE_LANGUAGE, | ||
82 | EXTRACTOR_METAFORMAT_UTF8, | ||
83 | "text/plain", | ||
84 | "en", | ||
85 | strlen ("en") + 1, | ||
86 | 0 | ||
87 | }, | ||
88 | { | ||
89 | EXTRACTOR_METATYPE_PUBLISHER, | ||
90 | EXTRACTOR_METAFORMAT_UTF8, | ||
91 | "text/plain", | ||
92 | "Christian Grothoff", | ||
93 | strlen ("Christian Grothoff") + 1, | ||
94 | 0 | ||
95 | }, | ||
96 | { | ||
97 | EXTRACTOR_METATYPE_UNKNOWN_DATE, | ||
98 | EXTRACTOR_METAFORMAT_UTF8, | ||
99 | "text/plain", | ||
100 | "2000-08-20", | ||
101 | strlen ("2000-08-20") + 1, | ||
102 | 0 | ||
103 | }, | ||
104 | { | ||
105 | EXTRACTOR_METATYPE_RIGHTS, | ||
106 | EXTRACTOR_METAFORMAT_UTF8, | ||
107 | "text/plain", | ||
108 | "(C) 2000 by Christian Grothoff", | ||
109 | strlen ("(C) 2000 by Christian Grothoff") + 1, | ||
110 | 0 | ||
111 | }, | ||
112 | { 0, 0, NULL, NULL, 0, -1 } | ||
113 | }; | ||
114 | struct ProblemSet ps[] = { | ||
115 | { "testdata/html_grothoff.html", | ||
116 | html_grothoff_sol }, | ||
117 | { NULL, NULL } | ||
118 | }; | ||
121 | return ET_main ("html", ps); | 119 | return ET_main ("html", ps); |
122 | } | 120 | } |
123 | 121 | ||
122 | |||
124 | /* end of test_html.c */ | 123 | /* end of test_html.c */ |
diff --git a/src/plugins/test_it.c b/src/plugins/test_it.c index c729a9a..408b009 100644 --- a/src/plugins/test_it.c +++ b/src/plugins/test_it.c | |||
@@ -36,41 +36,40 @@ | |||
36 | int | 36 | int |
37 | main (int argc, char *argv[]) | 37 | main (int argc, char *argv[]) |
38 | { | 38 | { |
39 | struct SolutionData it_dawn_sol[] = | 39 | struct SolutionData it_dawn_sol[] = { |
40 | { | 40 | { |
41 | { | 41 | EXTRACTOR_METATYPE_MIMETYPE, |
42 | EXTRACTOR_METATYPE_MIMETYPE, | 42 | EXTRACTOR_METAFORMAT_UTF8, |
43 | EXTRACTOR_METAFORMAT_UTF8, | 43 | "text/plain", |
44 | "text/plain", | 44 | "audio/x-mod", |
45 | "audio/x-mod", | 45 | strlen ("audio/x-mod") + 1, |
46 | strlen ("audio/x-mod") + 1, | 46 | 0 |
47 | 0 | 47 | }, |
48 | }, | ||
49 | { | ||
50 | EXTRACTOR_METATYPE_TITLE, | ||
51 | EXTRACTOR_METAFORMAT_C_STRING, | ||
52 | "text/plain", | ||
53 | "Dawn", | ||
54 | strlen ("Dawn") + 1, | ||
55 | 0 | ||
56 | }, | ||
57 | { | ||
58 | EXTRACTOR_METATYPE_FORMAT_VERSION, | ||
59 | EXTRACTOR_METAFORMAT_C_STRING, | ||
60 | "text/plain", | ||
61 | "1.2", | ||
62 | strlen ("1.2") + 1, | ||
63 | 0 | ||
64 | }, | ||
65 | { 0, 0, NULL, NULL, 0, -1 } | ||
66 | }; | ||
67 | struct ProblemSet ps[] = | ||
68 | { | 48 | { |
69 | { "testdata/it_dawn.it", | 49 | EXTRACTOR_METATYPE_TITLE, |
70 | it_dawn_sol }, | 50 | EXTRACTOR_METAFORMAT_C_STRING, |
71 | { NULL, NULL } | 51 | "text/plain", |
72 | }; | 52 | "Dawn", |
53 | strlen ("Dawn") + 1, | ||
54 | 0 | ||
55 | }, | ||
56 | { | ||
57 | EXTRACTOR_METATYPE_FORMAT_VERSION, | ||
58 | EXTRACTOR_METAFORMAT_C_STRING, | ||
59 | "text/plain", | ||
60 | "1.2", | ||
61 | strlen ("1.2") + 1, | ||
62 | 0 | ||
63 | }, | ||
64 | { 0, 0, NULL, NULL, 0, -1 } | ||
65 | }; | ||
66 | struct ProblemSet ps[] = { | ||
67 | { "testdata/it_dawn.it", | ||
68 | it_dawn_sol }, | ||
69 | { NULL, NULL } | ||
70 | }; | ||
73 | return ET_main ("it", ps); | 71 | return ET_main ("it", ps); |
74 | } | 72 | } |
75 | 73 | ||
74 | |||
76 | /* end of test_it.c */ | 75 | /* end of test_it.c */ |
diff --git a/src/plugins/test_jpeg.c b/src/plugins/test_jpeg.c index f36c7ed..a8d693e 100644 --- a/src/plugins/test_jpeg.c +++ b/src/plugins/test_jpeg.c | |||
@@ -26,7 +26,6 @@ | |||
26 | #include "test_lib.h" | 26 | #include "test_lib.h" |
27 | 27 | ||
28 | 28 | ||
29 | |||
30 | /** | 29 | /** |
31 | * Main function for the JPEG testcase. | 30 | * Main function for the JPEG testcase. |
32 | * | 31 | * |
@@ -37,41 +36,40 @@ | |||
37 | int | 36 | int |
38 | main (int argc, char *argv[]) | 37 | main (int argc, char *argv[]) |
39 | { | 38 | { |
40 | struct SolutionData jpeg_image_sol[] = | 39 | struct SolutionData jpeg_image_sol[] = { |
40 | { | ||
41 | EXTRACTOR_METATYPE_MIMETYPE, | ||
42 | EXTRACTOR_METAFORMAT_UTF8, | ||
43 | "text/plain", | ||
44 | "image/jpeg", | ||
45 | strlen ("image/jpeg") + 1, | ||
46 | 0 | ||
47 | }, | ||
41 | { | 48 | { |
42 | { | 49 | EXTRACTOR_METATYPE_IMAGE_DIMENSIONS, |
43 | EXTRACTOR_METATYPE_MIMETYPE, | 50 | EXTRACTOR_METAFORMAT_UTF8, |
44 | EXTRACTOR_METAFORMAT_UTF8, | 51 | "text/plain", |
45 | "text/plain", | 52 | "3x3", |
46 | "image/jpeg", | 53 | strlen ("3x3") + 1, |
47 | strlen ("image/jpeg") + 1, | 54 | 0 |
48 | 0 | 55 | }, |
49 | }, | ||
50 | { | ||
51 | EXTRACTOR_METATYPE_IMAGE_DIMENSIONS, | ||
52 | EXTRACTOR_METAFORMAT_UTF8, | ||
53 | "text/plain", | ||
54 | "3x3", | ||
55 | strlen ("3x3") + 1, | ||
56 | 0 | ||
57 | }, | ||
58 | { | ||
59 | EXTRACTOR_METATYPE_COMMENT, | ||
60 | EXTRACTOR_METAFORMAT_C_STRING, | ||
61 | "text/plain", | ||
62 | "(C) 2001 by Christian Grothoff, using gimp 1.2 1", | ||
63 | strlen ("(C) 2001 by Christian Grothoff, using gimp 1.2 1"), | ||
64 | 0 | ||
65 | }, | ||
66 | { 0, 0, NULL, NULL, 0, -1 } | ||
67 | }; | ||
68 | struct ProblemSet ps[] = | ||
69 | { | 56 | { |
70 | { "testdata/jpeg_image.jpg", | 57 | EXTRACTOR_METATYPE_COMMENT, |
71 | jpeg_image_sol }, | 58 | EXTRACTOR_METAFORMAT_C_STRING, |
72 | { NULL, NULL } | 59 | "text/plain", |
73 | }; | 60 | "(C) 2001 by Christian Grothoff, using gimp 1.2 1", |
61 | strlen ("(C) 2001 by Christian Grothoff, using gimp 1.2 1"), | ||
62 | 0 | ||
63 | }, | ||
64 | { 0, 0, NULL, NULL, 0, -1 } | ||
65 | }; | ||
66 | struct ProblemSet ps[] = { | ||
67 | { "testdata/jpeg_image.jpg", | ||
68 | jpeg_image_sol }, | ||
69 | { NULL, NULL } | ||
70 | }; | ||
74 | return ET_main ("jpeg", ps); | 71 | return ET_main ("jpeg", ps); |
75 | } | 72 | } |
76 | 73 | ||
74 | |||
77 | /* end of test_jpeg.c */ | 75 | /* end of test_jpeg.c */ |
diff --git a/src/plugins/test_lib.c b/src/plugins/test_lib.c index ebc8f04..efbe2cf 100644 --- a/src/plugins/test_lib.c +++ b/src/plugins/test_lib.c | |||
@@ -38,56 +38,56 @@ | |||
38 | * @param data hello world or good bye | 38 | * @param data hello world or good bye |
39 | * @param data_len number of bytes in data | 39 | * @param data_len number of bytes in data |
40 | * @return 0 (always) | 40 | * @return 0 (always) |
41 | */ | 41 | */ |
42 | static int | 42 | static int |
43 | process_replies (void *cls, | 43 | process_replies (void *cls, |
44 | const char *plugin_name, | 44 | const char *plugin_name, |
45 | enum EXTRACTOR_MetaType type, | 45 | enum EXTRACTOR_MetaType type, |
46 | enum EXTRACTOR_MetaFormat format, | 46 | enum EXTRACTOR_MetaFormat format, |
47 | const char *data_mime_type, | 47 | const char *data_mime_type, |
48 | const char *data, | 48 | const char *data, |
49 | size_t data_len) | 49 | size_t data_len) |
50 | { | 50 | { |
51 | struct SolutionData *sd = cls; | 51 | struct SolutionData *sd = cls; |
52 | unsigned int i; | 52 | unsigned int i; |
53 | 53 | ||
54 | for (i=0; -1 != sd[i].solved; i++) | 54 | for (i = 0; -1 != sd[i].solved; i++) |
55 | { | ||
56 | if ( (0 != sd[i].solved) || | ||
57 | (sd[i].type != type) || | ||
58 | (sd[i].format != format) ) | ||
59 | continue; | ||
60 | if ( (EXTRACTOR_METAFORMAT_BINARY != format) && | ||
61 | ( (sd[i].data_len != data_len) || | ||
62 | (0 != memcmp (sd[i].data, data, data_len)) ) ) | ||
63 | continue; | ||
64 | if ( (EXTRACTOR_METAFORMAT_BINARY == format) && | ||
65 | ( (sd[i].data_len > data_len) || | ||
66 | (0 != memcmp (sd[i].data, data, sd[i].data_len)) ) ) | ||
67 | continue; | ||
68 | |||
69 | if (NULL != sd[i].data_mime_type) | ||
55 | { | 70 | { |
56 | if ( (0 != sd[i].solved) || | 71 | if (NULL == data_mime_type) |
57 | (sd[i].type != type) || | 72 | continue; |
58 | (sd[i].format != format) ) | 73 | if (0 != strcmp (sd[i].data_mime_type, data_mime_type)) |
59 | continue; | 74 | continue; |
60 | if ( (EXTRACTOR_METAFORMAT_BINARY != format) && | ||
61 | ( (sd[i].data_len != data_len) || | ||
62 | (0 != memcmp (sd[i].data, data, data_len)) ) ) | ||
63 | continue; | ||
64 | if ( (EXTRACTOR_METAFORMAT_BINARY == format) && | ||
65 | ( (sd[i].data_len > data_len) || | ||
66 | (0 != memcmp (sd[i].data, data, sd[i].data_len)) ) ) | ||
67 | continue; | ||
68 | |||
69 | if (NULL != sd[i].data_mime_type) | ||
70 | { | ||
71 | if (NULL == data_mime_type) | ||
72 | continue; | ||
73 | if (0 != strcmp (sd[i].data_mime_type, data_mime_type)) | ||
74 | continue; | ||
75 | } | ||
76 | else | ||
77 | { | ||
78 | if (NULL != data_mime_type) | ||
79 | continue; | ||
80 | } | ||
81 | sd[i].solved = 1; | ||
82 | return 0; | ||
83 | } | 75 | } |
84 | fprintf (stderr, | 76 | else |
85 | "Got additional meta data of type %d and format %d with value `%.*s' from plugin `%s'\n", | 77 | { |
86 | type, | 78 | if (NULL != data_mime_type) |
87 | format, | 79 | continue; |
88 | (int) data_len, | 80 | } |
89 | data, | 81 | sd[i].solved = 1; |
90 | plugin_name); | 82 | return 0; |
83 | } | ||
84 | fprintf (stderr, | ||
85 | "Got additional meta data of type %d and format %d with value `%.*s' from plugin `%s'\n", | ||
86 | type, | ||
87 | format, | ||
88 | (int) data_len, | ||
89 | data, | ||
90 | plugin_name); | ||
91 | return 0; | 91 | return 0; |
92 | } | 92 | } |
93 | 93 | ||
@@ -97,11 +97,11 @@ process_replies (void *cls, | |||
97 | * | 97 | * |
98 | * @param plugin_name name of the plugin to load | 98 | * @param plugin_name name of the plugin to load |
99 | * @param ps array of problems the plugin should solve; | 99 | * @param ps array of problems the plugin should solve; |
100 | * NULL in filename terminates the array. | 100 | * NULL in filename terminates the array. |
101 | * @param opt options to use for loading the plugin | 101 | * @param opt options to use for loading the plugin |
102 | * @return 0 on success, 1 on failure | 102 | * @return 0 on success, 1 on failure |
103 | */ | 103 | */ |
104 | static int | 104 | static int |
105 | run (const char *plugin_name, | 105 | run (const char *plugin_name, |
106 | struct ProblemSet *ps, | 106 | struct ProblemSet *ps, |
107 | enum EXTRACTOR_Options opt) | 107 | enum EXTRACTOR_Options opt) |
@@ -111,32 +111,33 @@ run (const char *plugin_name, | |||
111 | unsigned int j; | 111 | unsigned int j; |
112 | int ret; | 112 | int ret; |
113 | 113 | ||
114 | pl = EXTRACTOR_plugin_add_config (NULL, | 114 | pl = EXTRACTOR_plugin_add_config (NULL, |
115 | plugin_name, | 115 | plugin_name, |
116 | opt); | 116 | opt); |
117 | for (i=0; NULL != ps[i].filename; i++) | 117 | for (i = 0; NULL != ps[i].filename; i++) |
118 | EXTRACTOR_extract (pl, | 118 | EXTRACTOR_extract (pl, |
119 | ps[i].filename, | 119 | ps[i].filename, |
120 | NULL, 0, | 120 | NULL, 0, |
121 | &process_replies, | 121 | &process_replies, |
122 | ps[i].solution); | 122 | ps[i].solution); |
123 | EXTRACTOR_plugin_remove_all (pl); | 123 | EXTRACTOR_plugin_remove_all (pl); |
124 | ret = 0; | 124 | ret = 0; |
125 | for (i=0; NULL != ps[i].filename; i++) | 125 | for (i = 0; NULL != ps[i].filename; i++) |
126 | for (j=0; -1 != ps[i].solution[j].solved; j++) | 126 | for (j = 0; -1 != ps[i].solution[j].solved; j++) |
127 | if (0 == ps[i].solution[j].solved) | 127 | if (0 == ps[i].solution[j].solved) |
128 | { | 128 | { |
129 | ret = 1; | 129 | ret = 1; |
130 | fprintf (stderr, | 130 | fprintf (stderr, |
131 | "Did not get expected meta data of type %d and format %d with value `%.*s' from plugin `%s'\n", | 131 | "Did not get expected meta data of type %d and format %d with value `%.*s' from plugin `%s'\n", |
132 | ps[i].solution[j].type, | 132 | ps[i].solution[j].type, |
133 | ps[i].solution[j].format, | 133 | ps[i].solution[j].format, |
134 | (int) ps[i].solution[j].data_len, | 134 | (int) ps[i].solution[j].data_len, |
135 | ps[i].solution[j].data, | 135 | ps[i].solution[j].data, |
136 | plugin_name); | 136 | plugin_name); |
137 | } | 137 | } |
138 | else | 138 | else |
139 | ps[i].solution[j].solved = 0; /* reset for next round */ | 139 | ps[i].solution[j].solved = 0; |
140 | /* reset for next round */ | ||
140 | return ret; | 141 | return ret; |
141 | } | 142 | } |
142 | 143 | ||
@@ -146,22 +147,22 @@ run (const char *plugin_name, | |||
146 | * | 147 | * |
147 | * @param plugin_name name of the plugin to load | 148 | * @param plugin_name name of the plugin to load |
148 | * @param ps array of problems the plugin should solve; | 149 | * @param ps array of problems the plugin should solve; |
149 | * NULL in filename terminates the array. | 150 | * NULL in filename terminates the array. |
150 | * @return 0 on success, 1 on failure | 151 | * @return 0 on success, 1 on failure |
151 | */ | 152 | */ |
152 | int | 153 | int |
153 | ET_main (const char *plugin_name, | 154 | ET_main (const char *plugin_name, |
154 | struct ProblemSet *ps) | 155 | struct ProblemSet *ps) |
155 | { | 156 | { |
156 | int ret; | 157 | int ret; |
157 | 158 | ||
158 | /* change environment to find plugins which may not yet be | 159 | /* change environment to find plugins which may not yet be |
159 | not installed but should be in the current directory (or .libs) | 160 | not installed but should be in the current directory (or .libs) |
160 | on 'make check' */ | 161 | on 'make check' */ |
161 | if (0 != putenv ("LIBEXTRACTOR_PREFIX=." PATH_SEPARATOR_STR ".libs/")) | 162 | if (0 != putenv ("LIBEXTRACTOR_PREFIX=." PATH_SEPARATOR_STR ".libs/")) |
162 | fprintf (stderr, | 163 | fprintf (stderr, |
163 | "Failed to update my environment, plugin loading may fail: %s\n", | 164 | "Failed to update my environment, plugin loading may fail: %s\n", |
164 | strerror (errno)); | 165 | strerror (errno)); |
165 | ret = run (plugin_name, ps, EXTRACTOR_OPTION_DEFAULT_POLICY); | 166 | ret = run (plugin_name, ps, EXTRACTOR_OPTION_DEFAULT_POLICY); |
166 | if (0 != ret) | 167 | if (0 != ret) |
167 | return ret; | 168 | return ret; |
diff --git a/src/plugins/test_lib.h b/src/plugins/test_lib.h index 05bf35d..9400314 100644 --- a/src/plugins/test_lib.h +++ b/src/plugins/test_lib.h | |||
@@ -67,7 +67,7 @@ struct SolutionData | |||
67 | 67 | ||
68 | 68 | ||
69 | /** | 69 | /** |
70 | * Set of problems | 70 | * Set of problems |
71 | */ | 71 | */ |
72 | struct ProblemSet | 72 | struct ProblemSet |
73 | { | 73 | { |
@@ -90,11 +90,11 @@ struct ProblemSet | |||
90 | * | 90 | * |
91 | * @param plugin_name name of the plugin to load | 91 | * @param plugin_name name of the plugin to load |
92 | * @param ps array of problems the plugin should solve; | 92 | * @param ps array of problems the plugin should solve; |
93 | * NULL in filename terminates the array. | 93 | * NULL in filename terminates the array. |
94 | * @return 0 on success, 1 on failure | 94 | * @return 0 on success, 1 on failure |
95 | */ | 95 | */ |
96 | int | 96 | int |
97 | ET_main (const char *plugin_name, | 97 | ET_main (const char *plugin_name, |
98 | struct ProblemSet *ps); | 98 | struct ProblemSet *ps); |
99 | 99 | ||
100 | #endif | 100 | #endif |
diff --git a/src/plugins/test_man.c b/src/plugins/test_man.c index 026a6ce..73b02fc 100644 --- a/src/plugins/test_man.c +++ b/src/plugins/test_man.c | |||
@@ -26,7 +26,6 @@ | |||
26 | #include "test_lib.h" | 26 | #include "test_lib.h" |
27 | 27 | ||
28 | 28 | ||
29 | |||
30 | /** | 29 | /** |
31 | * Main function for the MAN testcase. | 30 | * Main function for the MAN testcase. |
32 | * | 31 | * |
@@ -37,49 +36,48 @@ | |||
37 | int | 36 | int |
38 | main (int argc, char *argv[]) | 37 | main (int argc, char *argv[]) |
39 | { | 38 | { |
40 | struct SolutionData man_extract_sol[] = | 39 | struct SolutionData man_extract_sol[] = { |
40 | { | ||
41 | EXTRACTOR_METATYPE_TITLE, | ||
42 | EXTRACTOR_METAFORMAT_UTF8, | ||
43 | "text/plain", | ||
44 | "EXTRACT", | ||
45 | strlen ("EXTRACT") + 1, | ||
46 | 0 | ||
47 | }, | ||
41 | { | 48 | { |
42 | { | 49 | EXTRACTOR_METATYPE_SECTION, |
43 | EXTRACTOR_METATYPE_TITLE, | 50 | EXTRACTOR_METAFORMAT_UTF8, |
44 | EXTRACTOR_METAFORMAT_UTF8, | 51 | "text/plain", |
45 | "text/plain", | 52 | _ ("Commands"), |
46 | "EXTRACT", | 53 | strlen (_ ("Commands")) + 1, |
47 | strlen ("EXTRACT") + 1, | 54 | 0 |
48 | 0 | 55 | }, |
49 | }, | ||
50 | { | ||
51 | EXTRACTOR_METATYPE_SECTION, | ||
52 | EXTRACTOR_METAFORMAT_UTF8, | ||
53 | "text/plain", | ||
54 | _("Commands"), | ||
55 | strlen (_("Commands")) + 1, | ||
56 | 0 | ||
57 | }, | ||
58 | { | ||
59 | EXTRACTOR_METATYPE_MODIFICATION_DATE, | ||
60 | EXTRACTOR_METAFORMAT_UTF8, | ||
61 | "text/plain", | ||
62 | "Aug 7, 2012", | ||
63 | strlen ("Aug 7, 2012") + 1, | ||
64 | 0 | ||
65 | }, | ||
66 | { | ||
67 | EXTRACTOR_METATYPE_SOURCE, | ||
68 | EXTRACTOR_METAFORMAT_UTF8, | ||
69 | "text/plain", | ||
70 | _("libextractor 0.7.0"), | ||
71 | strlen (_("libextractor 0.7.0")) + 1, | ||
72 | 0 | ||
73 | }, | ||
74 | { 0, 0, NULL, NULL, 0, -1 } | ||
75 | }; | ||
76 | struct ProblemSet ps[] = | ||
77 | { | 56 | { |
78 | { "testdata/man_extract.1", | 57 | EXTRACTOR_METATYPE_MODIFICATION_DATE, |
79 | man_extract_sol }, | 58 | EXTRACTOR_METAFORMAT_UTF8, |
80 | { NULL, NULL } | 59 | "text/plain", |
81 | }; | 60 | "Aug 7, 2012", |
61 | strlen ("Aug 7, 2012") + 1, | ||
62 | 0 | ||
63 | }, | ||
64 | { | ||
65 | EXTRACTOR_METATYPE_SOURCE, | ||
66 | EXTRACTOR_METAFORMAT_UTF8, | ||
67 | "text/plain", | ||
68 | _ ("libextractor 0.7.0"), | ||
69 | strlen (_ ("libextractor 0.7.0")) + 1, | ||
70 | 0 | ||
71 | }, | ||
72 | { 0, 0, NULL, NULL, 0, -1 } | ||
73 | }; | ||
74 | struct ProblemSet ps[] = { | ||
75 | { "testdata/man_extract.1", | ||
76 | man_extract_sol }, | ||
77 | { NULL, NULL } | ||
78 | }; | ||
82 | return ET_main ("man", ps); | 79 | return ET_main ("man", ps); |
83 | } | 80 | } |
84 | 81 | ||
82 | |||
85 | /* end of test_man.c */ | 83 | /* end of test_man.c */ |
diff --git a/src/plugins/test_midi.c b/src/plugins/test_midi.c index 4191f96..61438ab 100644 --- a/src/plugins/test_midi.c +++ b/src/plugins/test_midi.c | |||
@@ -36,57 +36,56 @@ | |||
36 | int | 36 | int |
37 | main (int argc, char *argv[]) | 37 | main (int argc, char *argv[]) |
38 | { | 38 | { |
39 | struct SolutionData midi_dth_sol[] = | 39 | struct SolutionData midi_dth_sol[] = { |
40 | { | 40 | { |
41 | { | 41 | EXTRACTOR_METATYPE_MIMETYPE, |
42 | EXTRACTOR_METATYPE_MIMETYPE, | 42 | EXTRACTOR_METAFORMAT_UTF8, |
43 | EXTRACTOR_METAFORMAT_UTF8, | 43 | "text/plain", |
44 | "text/plain", | 44 | "audio/midi", |
45 | "audio/midi", | 45 | strlen ("audio/midi") + 1, |
46 | strlen ("audio/midi") + 1, | 46 | 0 |
47 | 0 | 47 | }, |
48 | }, | ||
49 | { | ||
50 | EXTRACTOR_METATYPE_COPYRIGHT, | ||
51 | EXTRACTOR_METAFORMAT_UTF8, | ||
52 | "text/plain", | ||
53 | "(c) 2012 d-o-o", | ||
54 | strlen ("(c) 2012 d-o-o"), | ||
55 | 0 | ||
56 | }, | ||
57 | { | ||
58 | EXTRACTOR_METATYPE_TITLE, | ||
59 | EXTRACTOR_METAFORMAT_UTF8, | ||
60 | "text/plain", | ||
61 | "Tage wie diese T2", | ||
62 | strlen ("Tage wie diese T2"), | ||
63 | 0 | ||
64 | }, | ||
65 | { | ||
66 | EXTRACTOR_METATYPE_COMMENT, | ||
67 | EXTRACTOR_METAFORMAT_UTF8, | ||
68 | "text/plain", | ||
69 | "XFhd:::Rock:8 Beat:1:m1:-:-:-:-:DD", | ||
70 | strlen ("XFhd:::Rock:8 Beat:1:m1:-:-:-:-:DD"), | ||
71 | 0 | ||
72 | }, | ||
73 | { | ||
74 | EXTRACTOR_METATYPE_COMMENT, | ||
75 | EXTRACTOR_METAFORMAT_UTF8, | ||
76 | "text/plain", | ||
77 | "XFln:L1:Tage wie diese:von Holst:von Holst:-:Toten Hosen:DD", | ||
78 | strlen ("XFln:L1:Tage wie diese:von Holst:von Holst:-:Toten Hosen:DD"), | ||
79 | 0 | ||
80 | }, | ||
81 | { 0, 0, NULL, NULL, 0, -1 } | ||
82 | }; | ||
83 | struct ProblemSet ps[] = | ||
84 | { | 48 | { |
85 | { "testdata/midi_dth.mid", | 49 | EXTRACTOR_METATYPE_COPYRIGHT, |
86 | midi_dth_sol }, | 50 | EXTRACTOR_METAFORMAT_UTF8, |
87 | { NULL, NULL } | 51 | "text/plain", |
88 | }; | 52 | "(c) 2012 d-o-o", |
53 | strlen ("(c) 2012 d-o-o"), | ||
54 | 0 | ||
55 | }, | ||
56 | { | ||
57 | EXTRACTOR_METATYPE_TITLE, | ||
58 | EXTRACTOR_METAFORMAT_UTF8, | ||
59 | "text/plain", | ||
60 | "Tage wie diese T2", | ||
61 | strlen ("Tage wie diese T2"), | ||
62 | 0 | ||
63 | }, | ||
64 | { | ||
65 | EXTRACTOR_METATYPE_COMMENT, | ||
66 | EXTRACTOR_METAFORMAT_UTF8, | ||
67 | "text/plain", | ||
68 | "XFhd:::Rock:8 Beat:1:m1:-:-:-:-:DD", | ||
69 | strlen ("XFhd:::Rock:8 Beat:1:m1:-:-:-:-:DD"), | ||
70 | 0 | ||
71 | }, | ||
72 | { | ||
73 | EXTRACTOR_METATYPE_COMMENT, | ||
74 | EXTRACTOR_METAFORMAT_UTF8, | ||
75 | "text/plain", | ||
76 | "XFln:L1:Tage wie diese:von Holst:von Holst:-:Toten Hosen:DD", | ||
77 | strlen ("XFln:L1:Tage wie diese:von Holst:von Holst:-:Toten Hosen:DD"), | ||
78 | 0 | ||
79 | }, | ||
80 | { 0, 0, NULL, NULL, 0, -1 } | ||
81 | }; | ||
82 | struct ProblemSet ps[] = { | ||
83 | { "testdata/midi_dth.mid", | ||
84 | midi_dth_sol }, | ||
85 | { NULL, NULL } | ||
86 | }; | ||
89 | return ET_main ("midi", ps); | 87 | return ET_main ("midi", ps); |
90 | } | 88 | } |
91 | 89 | ||
90 | |||
92 | /* end of test_midi.c */ | 91 | /* end of test_midi.c */ |
diff --git a/src/plugins/test_mime.c b/src/plugins/test_mime.c index e55b153..98e0586 100644 --- a/src/plugins/test_mime.c +++ b/src/plugins/test_mime.c | |||
@@ -40,70 +40,64 @@ main (int argc, char *argv[]) | |||
40 | int result = 0; | 40 | int result = 0; |
41 | int test_result; | 41 | int test_result; |
42 | int test_result_around_19, test_result_around_22; | 42 | int test_result_around_19, test_result_around_22; |
43 | struct SolutionData courseclear_file_around_19_sol[] = | 43 | struct SolutionData courseclear_file_around_19_sol[] = { |
44 | { | 44 | { |
45 | { | 45 | EXTRACTOR_METATYPE_MIMETYPE, |
46 | EXTRACTOR_METATYPE_MIMETYPE, | 46 | EXTRACTOR_METAFORMAT_UTF8, |
47 | EXTRACTOR_METAFORMAT_UTF8, | 47 | "text/plain", |
48 | "text/plain", | 48 | /* not sure which is the exact version, but old ones do |
49 | /* not sure which is the exact version, but old ones do | 49 | not even define MAGIC_VERSION, so this is approximately |
50 | not even define MAGIC_VERSION, so this is approximately | 50 | right. Users where this tests fail should report |
51 | right. Users where this tests fail should report | 51 | their version number from "magic.h" so we can adjust |
52 | their version number from "magic.h" so we can adjust | 52 | if necessary. */ |
53 | if necessary. */ | ||
54 | #ifdef MAGIC_VERSION | 53 | #ifdef MAGIC_VERSION |
55 | "audio/ogg", | 54 | "audio/ogg", |
56 | strlen ("audio/ogg") + 1, | 55 | strlen ("audio/ogg") + 1, |
57 | #else | 56 | #else |
58 | "application/ogg", | 57 | "application/ogg", |
59 | strlen ("application/ogg") + 1, | 58 | strlen ("application/ogg") + 1, |
60 | #endif | 59 | #endif |
61 | 0 | 60 | 0 |
62 | }, | 61 | }, |
63 | { 0, 0, NULL, NULL, 0, -1 } | 62 | { 0, 0, NULL, NULL, 0, -1 } |
64 | }; | 63 | }; |
65 | struct SolutionData courseclear_file_around_22_sol[] = | 64 | struct SolutionData courseclear_file_around_22_sol[] = { |
66 | { | 65 | { |
67 | { | 66 | EXTRACTOR_METATYPE_MIMETYPE, |
68 | EXTRACTOR_METATYPE_MIMETYPE, | 67 | EXTRACTOR_METAFORMAT_UTF8, |
69 | EXTRACTOR_METAFORMAT_UTF8, | 68 | "text/plain", |
70 | "text/plain", | 69 | "audio/ogg", |
71 | "audio/ogg", | 70 | strlen ("audio/ogg") + 1, |
72 | strlen ("audio/ogg") + 1, | 71 | 0 |
73 | 0 | 72 | }, |
74 | }, | 73 | { 0, 0, NULL, NULL, 0, -1 } |
75 | { 0, 0, NULL, NULL, 0, -1 } | 74 | }; |
76 | }; | 75 | struct SolutionData gif_image_sol[] = { |
77 | struct SolutionData gif_image_sol[] = | ||
78 | { | 76 | { |
79 | { | 77 | EXTRACTOR_METATYPE_MIMETYPE, |
80 | EXTRACTOR_METATYPE_MIMETYPE, | 78 | EXTRACTOR_METAFORMAT_UTF8, |
81 | EXTRACTOR_METAFORMAT_UTF8, | 79 | "text/plain", |
82 | "text/plain", | 80 | "image/gif", |
83 | "image/gif", | 81 | strlen ("image/gif") + 1, |
84 | strlen ("image/gif") + 1, | 82 | 0 |
85 | 0 | 83 | }, |
86 | }, | 84 | { 0, 0, NULL, NULL, 0, -1 } |
87 | { 0, 0, NULL, NULL, 0, -1 } | 85 | }; |
88 | }; | 86 | struct ProblemSet ps_gif[] = { |
89 | struct ProblemSet ps_gif[] = | 87 | { "testdata/gif_image.gif", |
90 | { | 88 | gif_image_sol }, |
91 | { "testdata/gif_image.gif", | 89 | { NULL, NULL } |
92 | gif_image_sol }, | 90 | }; |
93 | { NULL, NULL } | 91 | struct ProblemSet ps_ogg_around_19[] = { |
94 | }; | 92 | { "testdata/ogg_courseclear.ogg", |
95 | struct ProblemSet ps_ogg_around_19[] = | 93 | courseclear_file_around_19_sol }, |
96 | { | 94 | { NULL, NULL } |
97 | { "testdata/ogg_courseclear.ogg", | 95 | }; |
98 | courseclear_file_around_19_sol }, | 96 | struct ProblemSet ps_ogg_around_22[] = { |
99 | { NULL, NULL } | 97 | { "testdata/ogg_courseclear.ogg", |
100 | }; | 98 | courseclear_file_around_22_sol }, |
101 | struct ProblemSet ps_ogg_around_22[] = | 99 | { NULL, NULL } |
102 | { | 100 | }; |
103 | { "testdata/ogg_courseclear.ogg", | ||
104 | courseclear_file_around_22_sol }, | ||
105 | { NULL, NULL } | ||
106 | }; | ||
107 | printf ("Running gif test on libmagic:\n"); | 101 | printf ("Running gif test on libmagic:\n"); |
108 | test_result = (0 == ET_main ("mime", ps_gif) ? 0 : 1); | 102 | test_result = (0 == ET_main ("mime", ps_gif) ? 0 : 1); |
109 | printf ("gif libmagic test result: %s\n", test_result == 0 ? "OK" : "FAILED"); | 103 | printf ("gif libmagic test result: %s\n", test_result == 0 ? "OK" : "FAILED"); |
@@ -111,15 +105,18 @@ main (int argc, char *argv[]) | |||
111 | 105 | ||
112 | printf ("Running ogg test on libmagic, assuming version ~5.19:\n"); | 106 | printf ("Running ogg test on libmagic, assuming version ~5.19:\n"); |
113 | test_result_around_19 = (0 == ET_main ("mime", ps_ogg_around_19) ? 0 : 1); | 107 | test_result_around_19 = (0 == ET_main ("mime", ps_ogg_around_19) ? 0 : 1); |
114 | printf ("ogg libmagic test result: %s\n", test_result_around_19 == 0 ? "OK" : "FAILED"); | 108 | printf ("ogg libmagic test result: %s\n", test_result_around_19 == 0 ? "OK" : |
109 | "FAILED"); | ||
115 | 110 | ||
116 | printf ("Running ogg test on libmagic, assuming version ~5.22:\n"); | 111 | printf ("Running ogg test on libmagic, assuming version ~5.22:\n"); |
117 | test_result_around_22 = (0 == ET_main ("mime", ps_ogg_around_22) ? 0 : 1); | 112 | test_result_around_22 = (0 == ET_main ("mime", ps_ogg_around_22) ? 0 : 1); |
118 | printf ("ogg libmagic test result: %s\n", test_result_around_22 == 0 ? "OK" : "FAILED"); | 113 | printf ("ogg libmagic test result: %s\n", test_result_around_22 == 0 ? "OK" : |
114 | "FAILED"); | ||
119 | 115 | ||
120 | if ((test_result_around_19 != 0) && (test_result_around_22 != 0)) | 116 | if ((test_result_around_19 != 0) && (test_result_around_22 != 0)) |
121 | result++; | 117 | result++; |
122 | return result; | 118 | return result; |
123 | } | 119 | } |
124 | 120 | ||
121 | |||
125 | /* end of test_mime.c */ | 122 | /* end of test_mime.c */ |
diff --git a/src/plugins/test_mpeg.c b/src/plugins/test_mpeg.c index cd306c3..ce12722 100644 --- a/src/plugins/test_mpeg.c +++ b/src/plugins/test_mpeg.c | |||
@@ -26,7 +26,6 @@ | |||
26 | #include "test_lib.h" | 26 | #include "test_lib.h" |
27 | 27 | ||
28 | 28 | ||
29 | |||
30 | /** | 29 | /** |
31 | * Main function for the MPEG testcase. | 30 | * Main function for the MPEG testcase. |
32 | * | 31 | * |
@@ -37,79 +36,77 @@ | |||
37 | int | 36 | int |
38 | main (int argc, char *argv[]) | 37 | main (int argc, char *argv[]) |
39 | { | 38 | { |
40 | struct SolutionData melt_sol[] = | 39 | struct SolutionData melt_sol[] = { |
40 | { | ||
41 | EXTRACTOR_METATYPE_MIMETYPE, | ||
42 | EXTRACTOR_METAFORMAT_UTF8, | ||
43 | "text/plain", | ||
44 | "video/mpeg", | ||
45 | strlen ("video/mpeg") + 1, | ||
46 | 0 | ||
47 | }, | ||
48 | { | ||
49 | EXTRACTOR_METATYPE_IMAGE_DIMENSIONS, | ||
50 | EXTRACTOR_METAFORMAT_UTF8, | ||
51 | "text/plain", | ||
52 | "320x208", | ||
53 | strlen ("320x208") + 1, | ||
54 | 0 | ||
55 | }, | ||
41 | { | 56 | { |
42 | { | 57 | EXTRACTOR_METATYPE_FORMAT_VERSION, |
43 | EXTRACTOR_METATYPE_MIMETYPE, | 58 | EXTRACTOR_METAFORMAT_UTF8, |
44 | EXTRACTOR_METAFORMAT_UTF8, | 59 | "text/plain", |
45 | "text/plain", | 60 | "MPEG1", |
46 | "video/mpeg", | 61 | strlen ("MPEG1") + 1, |
47 | strlen ("video/mpeg") + 1, | 62 | 0 |
48 | 0 | 63 | }, |
49 | }, | ||
50 | { | ||
51 | EXTRACTOR_METATYPE_IMAGE_DIMENSIONS, | ||
52 | EXTRACTOR_METAFORMAT_UTF8, | ||
53 | "text/plain", | ||
54 | "320x208", | ||
55 | strlen ("320x208") + 1, | ||
56 | 0 | ||
57 | }, | ||
58 | { | ||
59 | EXTRACTOR_METATYPE_FORMAT_VERSION, | ||
60 | EXTRACTOR_METAFORMAT_UTF8, | ||
61 | "text/plain", | ||
62 | "MPEG1", | ||
63 | strlen ("MPEG1") + 1, | ||
64 | 0 | ||
65 | }, | ||
66 | { | ||
67 | EXTRACTOR_METATYPE_DURATION, | ||
68 | EXTRACTOR_METAFORMAT_UTF8, | ||
69 | "text/plain", | ||
70 | "00:00:03 (22 frames)", | ||
71 | strlen ("00:00:03 (22 frames)") + 1, | ||
72 | 0 | ||
73 | }, | ||
74 | { 0, 0, NULL, NULL, 0, -1 } | ||
75 | }; | ||
76 | struct SolutionData alien_sol[] = | ||
77 | { | 64 | { |
78 | { | 65 | EXTRACTOR_METATYPE_DURATION, |
79 | EXTRACTOR_METATYPE_MIMETYPE, | 66 | EXTRACTOR_METAFORMAT_UTF8, |
80 | EXTRACTOR_METAFORMAT_UTF8, | 67 | "text/plain", |
81 | "text/plain", | 68 | "00:00:03 (22 frames)", |
82 | "video/mpeg", | 69 | strlen ("00:00:03 (22 frames)") + 1, |
83 | strlen ("video/mpeg") + 1, | 70 | 0 |
84 | 0 | 71 | }, |
85 | }, | 72 | { 0, 0, NULL, NULL, 0, -1 } |
86 | { | 73 | }; |
87 | EXTRACTOR_METATYPE_IMAGE_DIMENSIONS, | 74 | struct SolutionData alien_sol[] = { |
88 | EXTRACTOR_METAFORMAT_UTF8, | ||
89 | "text/plain", | ||
90 | "320x240", | ||
91 | strlen ("320x240") + 1, | ||
92 | 0 | ||
93 | }, | ||
94 | { | ||
95 | EXTRACTOR_METATYPE_FORMAT_VERSION, | ||
96 | EXTRACTOR_METAFORMAT_UTF8, | ||
97 | "text/plain", | ||
98 | "MPEG1", | ||
99 | strlen ("MPEG1") + 1, | ||
100 | 0 | ||
101 | }, | ||
102 | { 0, 0, NULL, NULL, 0, -1 } | ||
103 | }; | ||
104 | struct ProblemSet ps[] = | ||
105 | { | 75 | { |
106 | { "testdata/mpeg_melt.mpg", | 76 | EXTRACTOR_METATYPE_MIMETYPE, |
107 | melt_sol }, | 77 | EXTRACTOR_METAFORMAT_UTF8, |
108 | { "testdata/mpeg_alien.mpg", | 78 | "text/plain", |
109 | alien_sol }, | 79 | "video/mpeg", |
110 | { NULL, NULL } | 80 | strlen ("video/mpeg") + 1, |
111 | }; | 81 | 0 |
82 | }, | ||
83 | { | ||
84 | EXTRACTOR_METATYPE_IMAGE_DIMENSIONS, | ||
85 | EXTRACTOR_METAFORMAT_UTF8, | ||
86 | "text/plain", | ||
87 | "320x240", | ||
88 | strlen ("320x240") + 1, | ||
89 | 0 | ||
90 | }, | ||
91 | { | ||
92 | EXTRACTOR_METATYPE_FORMAT_VERSION, | ||
93 | EXTRACTOR_METAFORMAT_UTF8, | ||
94 | "text/plain", | ||
95 | "MPEG1", | ||
96 | strlen ("MPEG1") + 1, | ||
97 | 0 | ||
98 | }, | ||
99 | { 0, 0, NULL, NULL, 0, -1 } | ||
100 | }; | ||
101 | struct ProblemSet ps[] = { | ||
102 | { "testdata/mpeg_melt.mpg", | ||
103 | melt_sol }, | ||
104 | { "testdata/mpeg_alien.mpg", | ||
105 | alien_sol }, | ||
106 | { NULL, NULL } | ||
107 | }; | ||
112 | return ET_main ("mpeg", ps); | 108 | return ET_main ("mpeg", ps); |
113 | } | 109 | } |
114 | 110 | ||
111 | |||
115 | /* end of test_mpeg.c */ | 112 | /* end of test_mpeg.c */ |
diff --git a/src/plugins/test_nsf.c b/src/plugins/test_nsf.c index ca10c75..fe022cd 100644 --- a/src/plugins/test_nsf.c +++ b/src/plugins/test_nsf.c | |||
@@ -26,7 +26,6 @@ | |||
26 | #include "test_lib.h" | 26 | #include "test_lib.h" |
27 | 27 | ||
28 | 28 | ||
29 | |||
30 | /** | 29 | /** |
31 | * Main function for the NSF testcase. | 30 | * Main function for the NSF testcase. |
32 | * | 31 | * |
@@ -37,81 +36,80 @@ | |||
37 | int | 36 | int |
38 | main (int argc, char *argv[]) | 37 | main (int argc, char *argv[]) |
39 | { | 38 | { |
40 | struct SolutionData nsf_arkanoid_sol[] = | 39 | struct SolutionData nsf_arkanoid_sol[] = { |
40 | { | ||
41 | EXTRACTOR_METATYPE_MIMETYPE, | ||
42 | EXTRACTOR_METAFORMAT_UTF8, | ||
43 | "text/plain", | ||
44 | "audio/x-nsf", | ||
45 | strlen ("audio/x-nsf") + 1, | ||
46 | 0 | ||
47 | }, | ||
48 | { | ||
49 | EXTRACTOR_METATYPE_FORMAT_VERSION, | ||
50 | EXTRACTOR_METAFORMAT_UTF8, | ||
51 | "text/plain", | ||
52 | "1", | ||
53 | strlen ("1") + 1, | ||
54 | 0 | ||
55 | }, | ||
56 | { | ||
57 | EXTRACTOR_METATYPE_SONG_COUNT, | ||
58 | EXTRACTOR_METAFORMAT_UTF8, | ||
59 | "text/plain", | ||
60 | "26", | ||
61 | strlen ("26") + 1, | ||
62 | 0 | ||
63 | }, | ||
41 | { | 64 | { |
42 | { | 65 | EXTRACTOR_METATYPE_STARTING_SONG, |
43 | EXTRACTOR_METATYPE_MIMETYPE, | 66 | EXTRACTOR_METAFORMAT_UTF8, |
44 | EXTRACTOR_METAFORMAT_UTF8, | 67 | "text/plain", |
45 | "text/plain", | 68 | "1", |
46 | "audio/x-nsf", | 69 | strlen ("1") + 1, |
47 | strlen ("audio/x-nsf") + 1, | 70 | 0 |
48 | 0 | 71 | }, |
49 | }, | ||
50 | { | ||
51 | EXTRACTOR_METATYPE_FORMAT_VERSION, | ||
52 | EXTRACTOR_METAFORMAT_UTF8, | ||
53 | "text/plain", | ||
54 | "1", | ||
55 | strlen ("1") + 1, | ||
56 | 0 | ||
57 | }, | ||
58 | { | ||
59 | EXTRACTOR_METATYPE_SONG_COUNT, | ||
60 | EXTRACTOR_METAFORMAT_UTF8, | ||
61 | "text/plain", | ||
62 | "26", | ||
63 | strlen ("26") + 1, | ||
64 | 0 | ||
65 | }, | ||
66 | { | ||
67 | EXTRACTOR_METATYPE_STARTING_SONG, | ||
68 | EXTRACTOR_METAFORMAT_UTF8, | ||
69 | "text/plain", | ||
70 | "1", | ||
71 | strlen ("1") + 1, | ||
72 | 0 | ||
73 | }, | ||
74 | { | ||
75 | EXTRACTOR_METATYPE_ALBUM, | ||
76 | EXTRACTOR_METAFORMAT_UTF8, | ||
77 | "text/plain", | ||
78 | "Arkanoid II - Revenge of Doh", | ||
79 | strlen ("Arkanoid II - Revenge of Doh") + 1, | ||
80 | 0 | ||
81 | }, | ||
82 | { | ||
83 | EXTRACTOR_METATYPE_ARTIST, | ||
84 | EXTRACTOR_METAFORMAT_UTF8, | ||
85 | "text/plain", | ||
86 | "<?>", | ||
87 | strlen ("<?>") + 1, | ||
88 | 0 | ||
89 | }, | ||
90 | { | ||
91 | EXTRACTOR_METATYPE_COPYRIGHT, | ||
92 | EXTRACTOR_METAFORMAT_UTF8, | ||
93 | "text/plain", | ||
94 | "1988 Taito", | ||
95 | strlen ("1988 Taito") + 1, | ||
96 | 0 | ||
97 | }, | ||
98 | { | ||
99 | EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM, | ||
100 | EXTRACTOR_METAFORMAT_UTF8, | ||
101 | "text/plain", | ||
102 | "NTSC", | ||
103 | strlen ("NTSC") + 1, | ||
104 | 0 | ||
105 | }, | ||
106 | { 0, 0, NULL, NULL, 0, -1 } | ||
107 | }; | ||
108 | struct ProblemSet ps[] = | ||
109 | { | 72 | { |
110 | { "testdata/nsf_arkanoid.nsf", | 73 | EXTRACTOR_METATYPE_ALBUM, |
111 | nsf_arkanoid_sol }, | 74 | EXTRACTOR_METAFORMAT_UTF8, |
112 | { NULL, NULL } | 75 | "text/plain", |
113 | }; | 76 | "Arkanoid II - Revenge of Doh", |
77 | strlen ("Arkanoid II - Revenge of Doh") + 1, | ||
78 | 0 | ||
79 | }, | ||
80 | { | ||
81 | EXTRACTOR_METATYPE_ARTIST, | ||
82 | EXTRACTOR_METAFORMAT_UTF8, | ||
83 | "text/plain", | ||
84 | "<?>", | ||
85 | strlen ("<?>") + 1, | ||
86 | 0 | ||
87 | }, | ||
88 | { | ||
89 | EXTRACTOR_METATYPE_COPYRIGHT, | ||
90 | EXTRACTOR_METAFORMAT_UTF8, | ||
91 | "text/plain", | ||
92 | "1988 Taito", | ||
93 | strlen ("1988 Taito") + 1, | ||
94 | 0 | ||
95 | }, | ||
96 | { | ||
97 | EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM, | ||
98 | EXTRACTOR_METAFORMAT_UTF8, | ||
99 | "text/plain", | ||
100 | "NTSC", | ||
101 | strlen ("NTSC") + 1, | ||
102 | 0 | ||
103 | }, | ||
104 | { 0, 0, NULL, NULL, 0, -1 } | ||
105 | }; | ||
106 | struct ProblemSet ps[] = { | ||
107 | { "testdata/nsf_arkanoid.nsf", | ||
108 | nsf_arkanoid_sol }, | ||
109 | { NULL, NULL } | ||
110 | }; | ||
114 | return ET_main ("nsf", ps); | 111 | return ET_main ("nsf", ps); |
115 | } | 112 | } |
116 | 113 | ||
114 | |||
117 | /* end of test_nsf.c */ | 115 | /* end of test_nsf.c */ |
diff --git a/src/plugins/test_nsfe.c b/src/plugins/test_nsfe.c index a28f1ea..358dd7f 100644 --- a/src/plugins/test_nsfe.c +++ b/src/plugins/test_nsfe.c | |||
@@ -26,7 +26,6 @@ | |||
26 | #include "test_lib.h" | 26 | #include "test_lib.h" |
27 | 27 | ||
28 | 28 | ||
29 | |||
30 | /** | 29 | /** |
31 | * Main function for the NSFE testcase. | 30 | * Main function for the NSFE testcase. |
32 | * | 31 | * |
@@ -37,97 +36,96 @@ | |||
37 | int | 36 | int |
38 | main (int argc, char *argv[]) | 37 | main (int argc, char *argv[]) |
39 | { | 38 | { |
40 | struct SolutionData nsfe_classics_sol[] = | 39 | struct SolutionData nsfe_classics_sol[] = { |
40 | { | ||
41 | EXTRACTOR_METATYPE_MIMETYPE, | ||
42 | EXTRACTOR_METAFORMAT_UTF8, | ||
43 | "text/plain", | ||
44 | "audio/x-nsfe", | ||
45 | strlen ("audio/x-nsfe") + 1, | ||
46 | 0 | ||
47 | }, | ||
48 | { | ||
49 | EXTRACTOR_METATYPE_SONG_COUNT, | ||
50 | EXTRACTOR_METAFORMAT_UTF8, | ||
51 | "text/plain", | ||
52 | "2", | ||
53 | strlen ("2") + 1, | ||
54 | 0 | ||
55 | }, | ||
56 | { | ||
57 | EXTRACTOR_METATYPE_STARTING_SONG, | ||
58 | EXTRACTOR_METAFORMAT_UTF8, | ||
59 | "text/plain", | ||
60 | "0", | ||
61 | strlen ("0") + 1, | ||
62 | 0 | ||
63 | }, | ||
64 | { | ||
65 | EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM, | ||
66 | EXTRACTOR_METAFORMAT_UTF8, | ||
67 | "text/plain", | ||
68 | "PAL", | ||
69 | strlen ("PAL") + 1, | ||
70 | 0 | ||
71 | }, | ||
41 | { | 72 | { |
42 | { | 73 | EXTRACTOR_METATYPE_ALBUM, |
43 | EXTRACTOR_METATYPE_MIMETYPE, | 74 | EXTRACTOR_METAFORMAT_UTF8, |
44 | EXTRACTOR_METAFORMAT_UTF8, | 75 | "text/plain", |
45 | "text/plain", | 76 | "Adventures of Dr. Franken,The", |
46 | "audio/x-nsfe", | 77 | strlen ("Adventures of Dr. Franken,The") + 1, |
47 | strlen ("audio/x-nsfe") + 1, | 78 | 0 |
48 | 0 | 79 | }, |
49 | }, | ||
50 | { | ||
51 | EXTRACTOR_METATYPE_SONG_COUNT, | ||
52 | EXTRACTOR_METAFORMAT_UTF8, | ||
53 | "text/plain", | ||
54 | "2", | ||
55 | strlen ("2") + 1, | ||
56 | 0 | ||
57 | }, | ||
58 | { | ||
59 | EXTRACTOR_METATYPE_STARTING_SONG, | ||
60 | EXTRACTOR_METAFORMAT_UTF8, | ||
61 | "text/plain", | ||
62 | "0", | ||
63 | strlen ("0") + 1, | ||
64 | 0 | ||
65 | }, | ||
66 | { | ||
67 | EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM, | ||
68 | EXTRACTOR_METAFORMAT_UTF8, | ||
69 | "text/plain", | ||
70 | "PAL", | ||
71 | strlen ("PAL") + 1, | ||
72 | 0 | ||
73 | }, | ||
74 | { | ||
75 | EXTRACTOR_METATYPE_ALBUM, | ||
76 | EXTRACTOR_METAFORMAT_UTF8, | ||
77 | "text/plain", | ||
78 | "Adventures of Dr. Franken,The", | ||
79 | strlen ("Adventures of Dr. Franken,The") + 1, | ||
80 | 0 | ||
81 | }, | ||
82 | { | ||
83 | EXTRACTOR_METATYPE_ARTIST, | ||
84 | EXTRACTOR_METAFORMAT_UTF8, | ||
85 | "text/plain", | ||
86 | "Mark Cooksey", | ||
87 | strlen ("Mark Cooksey") + 1, | ||
88 | 0 | ||
89 | }, | ||
90 | { | ||
91 | EXTRACTOR_METATYPE_COPYRIGHT, | ||
92 | EXTRACTOR_METAFORMAT_UTF8, | ||
93 | "text/plain", | ||
94 | "1993 Motivetime LTD.", | ||
95 | strlen ("1993 Motivetime LTD.") + 1, | ||
96 | 0 | ||
97 | }, | ||
98 | { | ||
99 | EXTRACTOR_METATYPE_RIPPER, | ||
100 | EXTRACTOR_METAFORMAT_UTF8, | ||
101 | "text/plain", | ||
102 | "Gil_Galad", | ||
103 | strlen ("Gil_Galad") + 1, | ||
104 | 0 | ||
105 | }, | ||
106 | { | ||
107 | EXTRACTOR_METATYPE_TITLE, | ||
108 | EXTRACTOR_METAFORMAT_UTF8, | ||
109 | "text/plain", | ||
110 | "Bach: Prelude & Fugue In C Minor", | ||
111 | strlen ("Bach: Prelude & Fugue In C Minor") + 1, | ||
112 | 0 | ||
113 | }, | ||
114 | { | ||
115 | EXTRACTOR_METATYPE_TITLE, | ||
116 | EXTRACTOR_METAFORMAT_UTF8, | ||
117 | "text/plain", | ||
118 | "Beethoven: Moonlight Sonata", | ||
119 | strlen ("Beethoven: Moonlight Sonata") + 1, | ||
120 | 0 | ||
121 | }, | ||
122 | { 0, 0, NULL, NULL, 0, -1 } | ||
123 | }; | ||
124 | struct ProblemSet ps[] = | ||
125 | { | 80 | { |
126 | { "testdata/nsfe_classics.nsfe", | 81 | EXTRACTOR_METATYPE_ARTIST, |
127 | nsfe_classics_sol }, | 82 | EXTRACTOR_METAFORMAT_UTF8, |
128 | { NULL, NULL } | 83 | "text/plain", |
129 | }; | 84 | "Mark Cooksey", |
85 | strlen ("Mark Cooksey") + 1, | ||
86 | 0 | ||
87 | }, | ||
88 | { | ||
89 | EXTRACTOR_METATYPE_COPYRIGHT, | ||
90 | EXTRACTOR_METAFORMAT_UTF8, | ||
91 | "text/plain", | ||
92 | "1993 Motivetime LTD.", | ||
93 | strlen ("1993 Motivetime LTD.") + 1, | ||
94 | 0 | ||
95 | }, | ||
96 | { | ||
97 | EXTRACTOR_METATYPE_RIPPER, | ||
98 | EXTRACTOR_METAFORMAT_UTF8, | ||
99 | "text/plain", | ||
100 | "Gil_Galad", | ||
101 | strlen ("Gil_Galad") + 1, | ||
102 | 0 | ||
103 | }, | ||
104 | { | ||
105 | EXTRACTOR_METATYPE_TITLE, | ||
106 | EXTRACTOR_METAFORMAT_UTF8, | ||
107 | "text/plain", | ||
108 | "Bach: Prelude & Fugue In C Minor", | ||
109 | strlen ("Bach: Prelude & Fugue In C Minor") + 1, | ||
110 | 0 | ||
111 | }, | ||
112 | { | ||
113 | EXTRACTOR_METATYPE_TITLE, | ||
114 | EXTRACTOR_METAFORMAT_UTF8, | ||
115 | "text/plain", | ||
116 | "Beethoven: Moonlight Sonata", | ||
117 | strlen ("Beethoven: Moonlight Sonata") + 1, | ||
118 | 0 | ||
119 | }, | ||
120 | { 0, 0, NULL, NULL, 0, -1 } | ||
121 | }; | ||
122 | struct ProblemSet ps[] = { | ||
123 | { "testdata/nsfe_classics.nsfe", | ||
124 | nsfe_classics_sol }, | ||
125 | { NULL, NULL } | ||
126 | }; | ||
130 | return ET_main ("nsfe", ps); | 127 | return ET_main ("nsfe", ps); |
131 | } | 128 | } |
132 | 129 | ||
130 | |||
133 | /* end of test_nsfe.c */ | 131 | /* end of test_nsfe.c */ |
diff --git a/src/plugins/test_odf.c b/src/plugins/test_odf.c index 0d95dbf..cc1447a 100644 --- a/src/plugins/test_odf.c +++ b/src/plugins/test_odf.c | |||
@@ -36,65 +36,65 @@ | |||
36 | int | 36 | int |
37 | main (int argc, char *argv[]) | 37 | main (int argc, char *argv[]) |
38 | { | 38 | { |
39 | struct SolutionData odf_cg_sol[] = | 39 | struct SolutionData odf_cg_sol[] = { |
40 | { | 40 | { |
41 | { | 41 | EXTRACTOR_METATYPE_MIMETYPE, |
42 | EXTRACTOR_METATYPE_MIMETYPE, | 42 | EXTRACTOR_METAFORMAT_UTF8, |
43 | EXTRACTOR_METAFORMAT_UTF8, | 43 | "text/plain", |
44 | "text/plain", | 44 | "application/vnd.oasis.opendocument.text", |
45 | "application/vnd.oasis.opendocument.text", | 45 | strlen ("application/vnd.oasis.opendocument.text") + 1, |
46 | strlen ("application/vnd.oasis.opendocument.text") + 1, | 46 | 0 |
47 | 0 | 47 | }, |
48 | }, | ||
49 | { | ||
50 | EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE, | ||
51 | EXTRACTOR_METAFORMAT_UTF8, | ||
52 | "text/plain", | ||
53 | "OpenOffice.org/3.2$Unix OpenOffice.org_project/320m12$Build-9483", | ||
54 | strlen ("OpenOffice.org/3.2$Unix OpenOffice.org_project/320m12$Build-9483") + 1, | ||
55 | 0 | ||
56 | }, | ||
57 | { | ||
58 | EXTRACTOR_METATYPE_PAGE_COUNT, | ||
59 | EXTRACTOR_METAFORMAT_UTF8, | ||
60 | "text/plain", | ||
61 | "1", | ||
62 | strlen ("1") + 1, | ||
63 | 0 | ||
64 | }, | ||
65 | { | ||
66 | EXTRACTOR_METATYPE_CREATION_DATE, | ||
67 | EXTRACTOR_METAFORMAT_UTF8, | ||
68 | "text/plain", | ||
69 | "2005-11-22T11:44:00", | ||
70 | strlen ("2005-11-22T11:44:00") + 1, | ||
71 | 0 | ||
72 | }, | ||
73 | { | ||
74 | EXTRACTOR_METATYPE_UNKNOWN_DATE, | ||
75 | EXTRACTOR_METAFORMAT_UTF8, | ||
76 | "text/plain", | ||
77 | "2010-06-09T13:09:34", | ||
78 | strlen ("2010-06-09T13:09:34") + 1, | ||
79 | 0 | ||
80 | }, | ||
81 | { | ||
82 | EXTRACTOR_METATYPE_TITLE, | ||
83 | EXTRACTOR_METAFORMAT_UTF8, | ||
84 | "text/plain", | ||
85 | "Anhang 1: Profile der beteiligten Wissenschaftler", | ||
86 | strlen ("Anhang 1: Profile der beteiligten Wissenschaftler") + 1, | ||
87 | 0 | ||
88 | }, | ||
89 | { 0, 0, NULL, NULL, 0, -1 } | ||
90 | }; | ||
91 | struct ProblemSet ps[] = | ||
92 | { | 48 | { |
93 | { "testdata/odf_cg.odt", | 49 | EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE, |
94 | odf_cg_sol }, | 50 | EXTRACTOR_METAFORMAT_UTF8, |
95 | { NULL, NULL } | 51 | "text/plain", |
96 | }; | 52 | "OpenOffice.org/3.2$Unix OpenOffice.org_project/320m12$Build-9483", |
53 | strlen ( | ||
54 | "OpenOffice.org/3.2$Unix OpenOffice.org_project/320m12$Build-9483") + 1, | ||
55 | 0 | ||
56 | }, | ||
57 | { | ||
58 | EXTRACTOR_METATYPE_PAGE_COUNT, | ||
59 | EXTRACTOR_METAFORMAT_UTF8, | ||
60 | "text/plain", | ||
61 | "1", | ||
62 | strlen ("1") + 1, | ||
63 | 0 | ||
64 | }, | ||
65 | { | ||
66 | EXTRACTOR_METATYPE_CREATION_DATE, | ||
67 | EXTRACTOR_METAFORMAT_UTF8, | ||
68 | "text/plain", | ||
69 | "2005-11-22T11:44:00", | ||
70 | strlen ("2005-11-22T11:44:00") + 1, | ||
71 | 0 | ||
72 | }, | ||
73 | { | ||
74 | EXTRACTOR_METATYPE_UNKNOWN_DATE, | ||
75 | EXTRACTOR_METAFORMAT_UTF8, | ||
76 | "text/plain", | ||
77 | "2010-06-09T13:09:34", | ||
78 | strlen ("2010-06-09T13:09:34") + 1, | ||
79 | 0 | ||
80 | }, | ||
81 | { | ||
82 | EXTRACTOR_METATYPE_TITLE, | ||
83 | EXTRACTOR_METAFORMAT_UTF8, | ||
84 | "text/plain", | ||
85 | "Anhang 1: Profile der beteiligten Wissenschaftler", | ||
86 | strlen ("Anhang 1: Profile der beteiligten Wissenschaftler") + 1, | ||
87 | 0 | ||
88 | }, | ||
89 | { 0, 0, NULL, NULL, 0, -1 } | ||
90 | }; | ||
91 | struct ProblemSet ps[] = { | ||
92 | { "testdata/odf_cg.odt", | ||
93 | odf_cg_sol }, | ||
94 | { NULL, NULL } | ||
95 | }; | ||
97 | return ET_main ("odf", ps); | 96 | return ET_main ("odf", ps); |
98 | } | 97 | } |
99 | 98 | ||
99 | |||
100 | /* end of test_odf.c */ | 100 | /* end of test_odf.c */ |
diff --git a/src/plugins/test_ogg.c b/src/plugins/test_ogg.c index 418f192..d82f80f 100644 --- a/src/plugins/test_ogg.c +++ b/src/plugins/test_ogg.c | |||
@@ -26,7 +26,6 @@ | |||
26 | #include "test_lib.h" | 26 | #include "test_lib.h" |
27 | 27 | ||
28 | 28 | ||
29 | |||
30 | /** | 29 | /** |
31 | * Main function for the OGG testcase. | 30 | * Main function for the OGG testcase. |
32 | * | 31 | * |
@@ -37,57 +36,56 @@ | |||
37 | int | 36 | int |
38 | main (int argc, char *argv[]) | 37 | main (int argc, char *argv[]) |
39 | { | 38 | { |
40 | struct SolutionData courseclear_sol[] = | 39 | struct SolutionData courseclear_sol[] = { |
40 | { | ||
41 | EXTRACTOR_METATYPE_MIMETYPE, | ||
42 | EXTRACTOR_METAFORMAT_UTF8, | ||
43 | "text/plain", | ||
44 | "application/ogg", | ||
45 | strlen ("application/ogg") + 1, | ||
46 | 0 | ||
47 | }, | ||
48 | { | ||
49 | EXTRACTOR_METATYPE_VENDOR, | ||
50 | EXTRACTOR_METAFORMAT_UTF8, | ||
51 | "text/plain", | ||
52 | "Xiphophorus libVorbis I 20010813", | ||
53 | strlen ("Xiphophorus libVorbis I 20010813") + 1, | ||
54 | 0 | ||
55 | }, | ||
41 | { | 56 | { |
42 | { | 57 | EXTRACTOR_METATYPE_TITLE, |
43 | EXTRACTOR_METATYPE_MIMETYPE, | 58 | EXTRACTOR_METAFORMAT_UTF8, |
44 | EXTRACTOR_METAFORMAT_UTF8, | 59 | "text/plain", |
45 | "text/plain", | 60 | "xoc_SMW_06_courseclear", |
46 | "application/ogg", | 61 | strlen ("xoc_SMW_06_courseclear") + 1, |
47 | strlen ("application/ogg") + 1, | 62 | 0 |
48 | 0 | 63 | }, |
49 | }, | ||
50 | { | ||
51 | EXTRACTOR_METATYPE_VENDOR, | ||
52 | EXTRACTOR_METAFORMAT_UTF8, | ||
53 | "text/plain", | ||
54 | "Xiphophorus libVorbis I 20010813", | ||
55 | strlen ("Xiphophorus libVorbis I 20010813") + 1, | ||
56 | 0 | ||
57 | }, | ||
58 | { | ||
59 | EXTRACTOR_METATYPE_TITLE, | ||
60 | EXTRACTOR_METAFORMAT_UTF8, | ||
61 | "text/plain", | ||
62 | "xoc_SMW_06_courseclear", | ||
63 | strlen ("xoc_SMW_06_courseclear") + 1, | ||
64 | 0 | ||
65 | }, | ||
66 | { | ||
67 | EXTRACTOR_METATYPE_ARTIST, | ||
68 | EXTRACTOR_METAFORMAT_UTF8, | ||
69 | "text/plain", | ||
70 | "XOC", | ||
71 | strlen ("XOC") + 1, | ||
72 | 0 | ||
73 | }, | ||
74 | { | ||
75 | EXTRACTOR_METATYPE_TRACK_NUMBER, | ||
76 | EXTRACTOR_METAFORMAT_UTF8, | ||
77 | "text/plain", | ||
78 | "6", | ||
79 | strlen ("6") + 1, | ||
80 | 0 | ||
81 | }, | ||
82 | { 0, 0, NULL, NULL, 0, -1 } | ||
83 | }; | ||
84 | struct ProblemSet ps[] = | ||
85 | { | 64 | { |
86 | { "testdata/ogg_courseclear.ogg", | 65 | EXTRACTOR_METATYPE_ARTIST, |
87 | courseclear_sol }, | 66 | EXTRACTOR_METAFORMAT_UTF8, |
88 | { NULL, NULL } | 67 | "text/plain", |
89 | }; | 68 | "XOC", |
69 | strlen ("XOC") + 1, | ||
70 | 0 | ||
71 | }, | ||
72 | { | ||
73 | EXTRACTOR_METATYPE_TRACK_NUMBER, | ||
74 | EXTRACTOR_METAFORMAT_UTF8, | ||
75 | "text/plain", | ||
76 | "6", | ||
77 | strlen ("6") + 1, | ||
78 | 0 | ||
79 | }, | ||
80 | { 0, 0, NULL, NULL, 0, -1 } | ||
81 | }; | ||
82 | struct ProblemSet ps[] = { | ||
83 | { "testdata/ogg_courseclear.ogg", | ||
84 | courseclear_sol }, | ||
85 | { NULL, NULL } | ||
86 | }; | ||
90 | return ET_main ("ogg", ps); | 87 | return ET_main ("ogg", ps); |
91 | } | 88 | } |
92 | 89 | ||
90 | |||
93 | /* end of test_ogg.c */ | 91 | /* end of test_ogg.c */ |
diff --git a/src/plugins/test_ole2.c b/src/plugins/test_ole2.c index 2859bb4..2870050 100644 --- a/src/plugins/test_ole2.c +++ b/src/plugins/test_ole2.c | |||
@@ -36,457 +36,476 @@ | |||
36 | int | 36 | int |
37 | main (int argc, char *argv[]) | 37 | main (int argc, char *argv[]) |
38 | { | 38 | { |
39 | struct SolutionData ole2_msword_sol[] = | 39 | struct SolutionData ole2_msword_sol[] = { |
40 | { | 40 | { |
41 | { | 41 | EXTRACTOR_METATYPE_CREATOR, |
42 | EXTRACTOR_METATYPE_CREATOR, | 42 | EXTRACTOR_METAFORMAT_UTF8, |
43 | EXTRACTOR_METAFORMAT_UTF8, | 43 | "text/plain", |
44 | "text/plain", | 44 | "Nils Durner", |
45 | "Nils Durner", | 45 | strlen ("Nils Durner") + 1, |
46 | strlen ("Nils Durner") + 1, | 46 | 0 |
47 | 0 | 47 | }, |
48 | }, | 48 | { |
49 | { | 49 | EXTRACTOR_METATYPE_UNKNOWN_DATE, |
50 | EXTRACTOR_METATYPE_UNKNOWN_DATE, | 50 | EXTRACTOR_METAFORMAT_UTF8, |
51 | EXTRACTOR_METAFORMAT_UTF8, | 51 | "text/plain", |
52 | "text/plain", | 52 | "2005-03-21T06:11:12Z", |
53 | "2005-03-21T06:11:12Z", | 53 | strlen ("2005-03-21T06:11:12Z") + 1, |
54 | strlen ("2005-03-21T06:11:12Z") + 1, | 54 | 0 |
55 | 0 | 55 | }, |
56 | }, | 56 | { |
57 | { | 57 | EXTRACTOR_METATYPE_DESCRIPTION, |
58 | EXTRACTOR_METATYPE_DESCRIPTION, | 58 | EXTRACTOR_METAFORMAT_UTF8, |
59 | EXTRACTOR_METAFORMAT_UTF8, | 59 | "text/plain", |
60 | "text/plain", | 60 | "This is a small document to test meta data extraction by GNU libextractor.", |
61 | "This is a small document to test meta data extraction by GNU libextractor.", | 61 | strlen ( |
62 | strlen ("This is a small document to test meta data extraction by GNU libextractor.") + 1, | 62 | "This is a small document to test meta data extraction by GNU libextractor.") |
63 | 0 | 63 | + 1, |
64 | }, | 64 | 0 |
65 | { | 65 | }, |
66 | EXTRACTOR_METATYPE_KEYWORDS, | 66 | { |
67 | EXTRACTOR_METAFORMAT_UTF8, | 67 | EXTRACTOR_METATYPE_KEYWORDS, |
68 | "text/plain", | 68 | EXTRACTOR_METAFORMAT_UTF8, |
69 | "ole ole2 eole2extractor", | 69 | "text/plain", |
70 | strlen ("ole ole2 eole2extractor") + 1, | 70 | "ole ole2 eole2extractor", |
71 | 0 | 71 | strlen ("ole ole2 eole2extractor") + 1, |
72 | }, | 72 | 0 |
73 | { | 73 | }, |
74 | EXTRACTOR_METATYPE_SUBJECT, | 74 | { |
75 | EXTRACTOR_METAFORMAT_UTF8, | 75 | EXTRACTOR_METATYPE_SUBJECT, |
76 | "text/plain", | 76 | EXTRACTOR_METAFORMAT_UTF8, |
77 | "GNU libextractor", | 77 | "text/plain", |
78 | strlen ("GNU libextractor") + 1, | 78 | "GNU libextractor", |
79 | 0 | 79 | strlen ("GNU libextractor") + 1, |
80 | }, | 80 | 0 |
81 | { | 81 | }, |
82 | EXTRACTOR_METATYPE_TITLE, | 82 | { |
83 | EXTRACTOR_METAFORMAT_UTF8, | 83 | EXTRACTOR_METATYPE_TITLE, |
84 | "text/plain", | 84 | EXTRACTOR_METAFORMAT_UTF8, |
85 | "Testcase for the ole2 extractor", | 85 | "text/plain", |
86 | strlen ("Testcase for the ole2 extractor") + 1, | 86 | "Testcase for the ole2 extractor", |
87 | 0 | 87 | strlen ("Testcase for the ole2 extractor") + 1, |
88 | }, | 88 | 0 |
89 | { | 89 | }, |
90 | EXTRACTOR_METATYPE_LAST_SAVED_BY, | 90 | { |
91 | EXTRACTOR_METAFORMAT_UTF8, | 91 | EXTRACTOR_METATYPE_LAST_SAVED_BY, |
92 | "text/plain", | 92 | EXTRACTOR_METAFORMAT_UTF8, |
93 | "Nils Durner", | 93 | "text/plain", |
94 | strlen ("Nils Durner") + 1, | 94 | "Nils Durner", |
95 | 0 | 95 | strlen ("Nils Durner") + 1, |
96 | }, | 96 | 0 |
97 | { | 97 | }, |
98 | EXTRACTOR_METATYPE_CREATION_DATE, | 98 | { |
99 | EXTRACTOR_METAFORMAT_UTF8, | 99 | EXTRACTOR_METATYPE_CREATION_DATE, |
100 | "text/plain", | 100 | EXTRACTOR_METAFORMAT_UTF8, |
101 | "2005-03-21T06:10:19Z", | 101 | "text/plain", |
102 | strlen ("2005-03-21T06:10:19Z") + 1, | 102 | "2005-03-21T06:10:19Z", |
103 | 0 | 103 | strlen ("2005-03-21T06:10:19Z") + 1, |
104 | }, | 104 | 0 |
105 | { | 105 | }, |
106 | EXTRACTOR_METATYPE_EDITING_CYCLES, | 106 | { |
107 | EXTRACTOR_METAFORMAT_UTF8, | 107 | EXTRACTOR_METATYPE_EDITING_CYCLES, |
108 | "text/plain", | 108 | EXTRACTOR_METAFORMAT_UTF8, |
109 | "2", | 109 | "text/plain", |
110 | strlen ("2") + 1, | 110 | "2", |
111 | 0 | 111 | strlen ("2") + 1, |
112 | }, | 112 | 0 |
113 | { 0, 0, NULL, NULL, 0, -1 } | 113 | }, |
114 | }; | 114 | { 0, 0, NULL, NULL, 0, -1 } |
115 | }; | ||
115 | 116 | ||
116 | struct SolutionData ole2_starwriter_sol[] = | 117 | struct SolutionData ole2_starwriter_sol[] = { |
117 | { | 118 | { |
118 | { | 119 | EXTRACTOR_METATYPE_CREATOR, |
119 | EXTRACTOR_METATYPE_CREATOR, | 120 | EXTRACTOR_METAFORMAT_UTF8, |
120 | EXTRACTOR_METAFORMAT_UTF8, | 121 | "text/plain", |
121 | "text/plain", | 122 | "Christian Grothoff", |
122 | "Christian Grothoff", | 123 | strlen ("Christian Grothoff") + 1, |
123 | strlen ("Christian Grothoff") + 1, | 124 | 0 |
124 | 0 | 125 | }, |
125 | }, | 126 | { |
126 | { | 127 | EXTRACTOR_METATYPE_UNKNOWN_DATE, |
127 | EXTRACTOR_METATYPE_UNKNOWN_DATE, | 128 | EXTRACTOR_METAFORMAT_UTF8, |
128 | EXTRACTOR_METAFORMAT_UTF8, | 129 | "text/plain", |
129 | "text/plain", | 130 | "2004-09-24T02:54:31Z", |
130 | "2004-09-24T02:54:31Z", | 131 | strlen ("2004-09-24T02:54:31Z") + 1, |
131 | strlen ("2004-09-24T02:54:31Z") + 1, | 132 | 0 |
132 | 0 | 133 | }, |
133 | }, | 134 | { |
134 | { | 135 | EXTRACTOR_METATYPE_DESCRIPTION, |
135 | EXTRACTOR_METATYPE_DESCRIPTION, | 136 | EXTRACTOR_METAFORMAT_UTF8, |
136 | EXTRACTOR_METAFORMAT_UTF8, | 137 | "text/plain", |
137 | "text/plain", | 138 | "The comments", |
138 | "The comments", | 139 | strlen ("The comments") + 1, |
139 | strlen ("The comments") + 1, | 140 | 0 |
140 | 0 | 141 | }, |
141 | }, | 142 | { |
142 | { | 143 | EXTRACTOR_METATYPE_KEYWORDS, |
143 | EXTRACTOR_METATYPE_KEYWORDS, | 144 | EXTRACTOR_METAFORMAT_UTF8, |
144 | EXTRACTOR_METAFORMAT_UTF8, | 145 | "text/plain", |
145 | "text/plain", | 146 | "The Keywords", |
146 | "The Keywords", | 147 | strlen ("The Keywords") + 1, |
147 | strlen ("The Keywords") + 1, | 148 | 0 |
148 | 0 | 149 | }, |
149 | }, | 150 | { |
150 | { | 151 | EXTRACTOR_METATYPE_SUBJECT, |
151 | EXTRACTOR_METATYPE_SUBJECT, | 152 | EXTRACTOR_METAFORMAT_UTF8, |
152 | EXTRACTOR_METAFORMAT_UTF8, | 153 | "text/plain", |
153 | "text/plain", | 154 | "The Subject", |
154 | "The Subject", | 155 | strlen ("The Subject") + 1, |
155 | strlen ("The Subject") + 1, | 156 | 0 |
156 | 0 | 157 | }, |
157 | }, | 158 | { |
158 | { | 159 | EXTRACTOR_METATYPE_TITLE, |
159 | EXTRACTOR_METATYPE_TITLE, | 160 | EXTRACTOR_METAFORMAT_UTF8, |
160 | EXTRACTOR_METAFORMAT_UTF8, | 161 | "text/plain", |
161 | "text/plain", | 162 | "The Title", |
162 | "The Title", | 163 | strlen ("The Title") + 1, |
163 | strlen ("The Title") + 1, | 164 | 0 |
164 | 0 | 165 | }, |
165 | }, | 166 | { |
166 | { | 167 | EXTRACTOR_METATYPE_LAST_SAVED_BY, |
167 | EXTRACTOR_METATYPE_LAST_SAVED_BY, | 168 | EXTRACTOR_METAFORMAT_UTF8, |
168 | EXTRACTOR_METAFORMAT_UTF8, | 169 | "text/plain", |
169 | "text/plain", | 170 | "Christian Grothoff", |
170 | "Christian Grothoff", | 171 | strlen ("Christian Grothoff") + 1, |
171 | strlen ("Christian Grothoff") + 1, | 172 | 0 |
172 | 0 | 173 | }, |
173 | }, | 174 | { |
174 | { | 175 | EXTRACTOR_METATYPE_CREATION_DATE, |
175 | EXTRACTOR_METATYPE_CREATION_DATE, | 176 | EXTRACTOR_METAFORMAT_UTF8, |
176 | EXTRACTOR_METAFORMAT_UTF8, | 177 | "text/plain", |
177 | "text/plain", | 178 | "2004-09-24T02:53:15Z", |
178 | "2004-09-24T02:53:15Z", | 179 | strlen ("2004-09-24T02:53:15Z") + 1, |
179 | strlen ("2004-09-24T02:53:15Z") + 1, | 180 | 0 |
180 | 0 | 181 | }, |
181 | }, | 182 | { |
182 | { | 183 | EXTRACTOR_METATYPE_EDITING_CYCLES, |
183 | EXTRACTOR_METATYPE_EDITING_CYCLES, | 184 | EXTRACTOR_METAFORMAT_UTF8, |
184 | EXTRACTOR_METAFORMAT_UTF8, | 185 | "text/plain", |
185 | "text/plain", | 186 | "4", |
186 | "4", | 187 | strlen ("4") + 1, |
187 | strlen ("4") + 1, | 188 | 0 |
188 | 0 | 189 | }, |
189 | }, | 190 | { |
190 | { | 191 | EXTRACTOR_METATYPE_TITLE, |
191 | EXTRACTOR_METATYPE_TITLE, | 192 | EXTRACTOR_METAFORMAT_UTF8, |
192 | EXTRACTOR_METAFORMAT_UTF8, | 193 | "text/plain", |
193 | "text/plain", | 194 | "The Title", |
194 | "The Title", | 195 | strlen ("The Title") + 1, |
195 | strlen ("The Title") + 1, | 196 | 0 |
196 | 0 | 197 | }, |
197 | }, | 198 | { |
198 | { | 199 | EXTRACTOR_METATYPE_SUBJECT, |
199 | EXTRACTOR_METATYPE_SUBJECT, | 200 | EXTRACTOR_METAFORMAT_UTF8, |
200 | EXTRACTOR_METAFORMAT_UTF8, | 201 | "text/plain", |
201 | "text/plain", | 202 | "The Subject", |
202 | "The Subject", | 203 | strlen ("The Subject") + 1, |
203 | strlen ("The Subject") + 1, | 204 | 0 |
204 | 0 | 205 | }, |
205 | }, | 206 | { |
206 | { | 207 | EXTRACTOR_METATYPE_COMMENT, |
207 | EXTRACTOR_METATYPE_COMMENT, | 208 | EXTRACTOR_METAFORMAT_UTF8, |
208 | EXTRACTOR_METAFORMAT_UTF8, | 209 | "text/plain", |
209 | "text/plain", | 210 | "The comments", |
210 | "The comments", | 211 | strlen ("The comments") + 1, |
211 | strlen ("The comments") + 1, | 212 | 0 |
212 | 0 | 213 | }, |
213 | }, | 214 | { |
214 | { | 215 | EXTRACTOR_METATYPE_KEYWORDS, |
215 | EXTRACTOR_METATYPE_KEYWORDS, | 216 | EXTRACTOR_METAFORMAT_UTF8, |
216 | EXTRACTOR_METAFORMAT_UTF8, | 217 | "text/plain", |
217 | "text/plain", | 218 | "The Keywords", |
218 | "The Keywords", | 219 | strlen ("The Keywords") + 1, |
219 | strlen ("The Keywords") + 1, | 220 | 0 |
220 | 0 | 221 | }, |
221 | }, | 222 | { 0, 0, NULL, NULL, 0, -1 } |
222 | { 0, 0, NULL, NULL, 0, -1 } | 223 | }; |
223 | }; | ||
224 | #if HAVE_ICONV | 224 | #if HAVE_ICONV |
225 | struct SolutionData ole2_blair_sol[] = | 225 | struct SolutionData ole2_blair_sol[] = { |
226 | { | 226 | { |
227 | { | 227 | EXTRACTOR_METATYPE_LANGUAGE, |
228 | EXTRACTOR_METATYPE_LANGUAGE, | 228 | EXTRACTOR_METAFORMAT_UTF8, |
229 | EXTRACTOR_METAFORMAT_UTF8, | 229 | "text/plain", |
230 | "text/plain", | 230 | "U.S. English", |
231 | "U.S. English", | 231 | strlen ("U.S. English") + 1, |
232 | strlen ("U.S. English") + 1, | 232 | 0 |
233 | 0 | 233 | }, |
234 | }, | 234 | { |
235 | { | 235 | EXTRACTOR_METATYPE_CREATOR, |
236 | EXTRACTOR_METATYPE_CREATOR, | 236 | EXTRACTOR_METAFORMAT_UTF8, |
237 | EXTRACTOR_METAFORMAT_UTF8, | 237 | "text/plain", |
238 | "text/plain", | 238 | "default", |
239 | "default", | 239 | strlen ("default") + 1, |
240 | strlen ("default") + 1, | 240 | 0 |
241 | 0 | 241 | }, |
242 | }, | 242 | { |
243 | { | 243 | EXTRACTOR_METATYPE_UNKNOWN_DATE, |
244 | EXTRACTOR_METATYPE_UNKNOWN_DATE, | 244 | EXTRACTOR_METAFORMAT_UTF8, |
245 | EXTRACTOR_METAFORMAT_UTF8, | 245 | "text/plain", |
246 | "text/plain", | 246 | "2003-02-03T11:18:00Z", |
247 | "2003-02-03T11:18:00Z", | 247 | strlen ("2003-02-03T11:18:00Z") + 1, |
248 | strlen ("2003-02-03T11:18:00Z") + 1, | 248 | 0 |
249 | 0 | 249 | }, |
250 | }, | 250 | { |
251 | { | 251 | EXTRACTOR_METATYPE_TITLE, |
252 | EXTRACTOR_METATYPE_TITLE, | 252 | EXTRACTOR_METAFORMAT_UTF8, |
253 | EXTRACTOR_METAFORMAT_UTF8, | 253 | "text/plain", |
254 | "text/plain", | 254 | "Iraq- ITS INFRASTRUCTURE OF CONCEALMENT, DECEPTION AND INTIMIDATION", |
255 | "Iraq- ITS INFRASTRUCTURE OF CONCEALMENT, DECEPTION AND INTIMIDATION", | 255 | strlen ( |
256 | strlen ("Iraq- ITS INFRASTRUCTURE OF CONCEALMENT, DECEPTION AND INTIMIDATION") + 1, | 256 | "Iraq- ITS INFRASTRUCTURE OF CONCEALMENT, DECEPTION AND INTIMIDATION") |
257 | 0 | 257 | + 1, |
258 | }, | 258 | 0 |
259 | { | 259 | }, |
260 | EXTRACTOR_METATYPE_CHARACTER_COUNT, | 260 | { |
261 | EXTRACTOR_METAFORMAT_UTF8, | 261 | EXTRACTOR_METATYPE_CHARACTER_COUNT, |
262 | "text/plain", | 262 | EXTRACTOR_METAFORMAT_UTF8, |
263 | "22090", | 263 | "text/plain", |
264 | strlen ("22090") + 1, | 264 | "22090", |
265 | 0 | 265 | strlen ("22090") + 1, |
266 | }, | 266 | 0 |
267 | { | 267 | }, |
268 | EXTRACTOR_METATYPE_LAST_SAVED_BY, | 268 | { |
269 | EXTRACTOR_METAFORMAT_UTF8, | 269 | EXTRACTOR_METATYPE_LAST_SAVED_BY, |
270 | "text/plain", | 270 | EXTRACTOR_METAFORMAT_UTF8, |
271 | "MKhan", | 271 | "text/plain", |
272 | strlen ("MKhan") + 1, | 272 | "MKhan", |
273 | 0 | 273 | strlen ("MKhan") + 1, |
274 | }, | 274 | 0 |
275 | { | 275 | }, |
276 | EXTRACTOR_METATYPE_PAGE_COUNT, | 276 | { |
277 | EXTRACTOR_METAFORMAT_UTF8, | 277 | EXTRACTOR_METATYPE_PAGE_COUNT, |
278 | "text/plain", | 278 | EXTRACTOR_METAFORMAT_UTF8, |
279 | "1", | 279 | "text/plain", |
280 | strlen ("1") + 1, | 280 | "1", |
281 | 0 | 281 | strlen ("1") + 1, |
282 | }, | 282 | 0 |
283 | { | 283 | }, |
284 | EXTRACTOR_METATYPE_WORD_COUNT, | 284 | { |
285 | EXTRACTOR_METAFORMAT_UTF8, | 285 | EXTRACTOR_METATYPE_WORD_COUNT, |
286 | "text/plain", | 286 | EXTRACTOR_METAFORMAT_UTF8, |
287 | "3875", | 287 | "text/plain", |
288 | strlen ("3875") + 1, | 288 | "3875", |
289 | 0 | 289 | strlen ("3875") + 1, |
290 | }, | 290 | 0 |
291 | { | 291 | }, |
292 | EXTRACTOR_METATYPE_CREATION_DATE, | 292 | { |
293 | EXTRACTOR_METAFORMAT_UTF8, | 293 | EXTRACTOR_METATYPE_CREATION_DATE, |
294 | "text/plain", | 294 | EXTRACTOR_METAFORMAT_UTF8, |
295 | "2003-02-03T09:31:00Z", | 295 | "text/plain", |
296 | strlen ("2003-02-03T09:31:00Z") + 1, | 296 | "2003-02-03T09:31:00Z", |
297 | 0 | 297 | strlen ("2003-02-03T09:31:00Z") + 1, |
298 | }, | 298 | 0 |
299 | { | 299 | }, |
300 | EXTRACTOR_METATYPE_EDITING_CYCLES, | 300 | { |
301 | EXTRACTOR_METAFORMAT_UTF8, | 301 | EXTRACTOR_METATYPE_EDITING_CYCLES, |
302 | "text/plain", | 302 | EXTRACTOR_METAFORMAT_UTF8, |
303 | "4", | 303 | "text/plain", |
304 | strlen ("4") + 1, | 304 | "4", |
305 | 0 | 305 | strlen ("4") + 1, |
306 | }, | 306 | 0 |
307 | { | 307 | }, |
308 | EXTRACTOR_METATYPE_MIMETYPE, | 308 | { |
309 | EXTRACTOR_METAFORMAT_UTF8, | 309 | EXTRACTOR_METATYPE_MIMETYPE, |
310 | "text/plain", | 310 | EXTRACTOR_METAFORMAT_UTF8, |
311 | "application/vnd.ms-files", | 311 | "text/plain", |
312 | strlen ("application/vnd.ms-files") + 1, | 312 | "application/vnd.ms-files", |
313 | 0 | 313 | strlen ("application/vnd.ms-files") + 1, |
314 | }, | 314 | 0 |
315 | { | 315 | }, |
316 | EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE, | 316 | { |
317 | EXTRACTOR_METAFORMAT_UTF8, | 317 | EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE, |
318 | "text/plain", | 318 | EXTRACTOR_METAFORMAT_UTF8, |
319 | "Microsoft Word 8.0", | 319 | "text/plain", |
320 | strlen ("Microsoft Word 8.0") + 1, | 320 | "Microsoft Word 8.0", |
321 | 0 | 321 | strlen ("Microsoft Word 8.0") + 1, |
322 | }, | 322 | 0 |
323 | { | 323 | }, |
324 | EXTRACTOR_METATYPE_TEMPLATE, | 324 | { |
325 | EXTRACTOR_METAFORMAT_UTF8, | 325 | EXTRACTOR_METATYPE_TEMPLATE, |
326 | "text/plain", | 326 | EXTRACTOR_METAFORMAT_UTF8, |
327 | "Normal.dot", | 327 | "text/plain", |
328 | strlen ("Normal.dot") + 1, | 328 | "Normal.dot", |
329 | 0 | 329 | strlen ("Normal.dot") + 1, |
330 | }, | 330 | 0 |
331 | { | 331 | }, |
332 | EXTRACTOR_METATYPE_LINE_COUNT, | 332 | { |
333 | EXTRACTOR_METAFORMAT_UTF8, | 333 | EXTRACTOR_METATYPE_LINE_COUNT, |
334 | "text/plain", | 334 | EXTRACTOR_METAFORMAT_UTF8, |
335 | "184", | 335 | "text/plain", |
336 | strlen ("184") + 1, | 336 | "184", |
337 | 0 | 337 | strlen ("184") + 1, |
338 | }, | 338 | 0 |
339 | { | 339 | }, |
340 | EXTRACTOR_METATYPE_PARAGRAPH_COUNT, | 340 | { |
341 | EXTRACTOR_METAFORMAT_UTF8, | 341 | EXTRACTOR_METATYPE_PARAGRAPH_COUNT, |
342 | "text/plain", | 342 | EXTRACTOR_METAFORMAT_UTF8, |
343 | "44", | 343 | "text/plain", |
344 | strlen ("44") + 1, | 344 | "44", |
345 | 0 | 345 | strlen ("44") + 1, |
346 | }, | 346 | 0 |
347 | { | 347 | }, |
348 | EXTRACTOR_METATYPE_REVISION_HISTORY, | 348 | { |
349 | EXTRACTOR_METAFORMAT_UTF8, | 349 | EXTRACTOR_METATYPE_REVISION_HISTORY, |
350 | "text/plain", | 350 | EXTRACTOR_METAFORMAT_UTF8, |
351 | "Revision #0: Author `cic22' worked on `C:\\DOCUME~1\\phamill\\LOCALS~1\\Temp\\AutoRecovery save of Iraq - security.asd'", | 351 | "text/plain", |
352 | strlen ("Revision #0: Author `cic22' worked on `C:\\DOCUME~1\\phamill\\LOCALS~1\\Temp\\AutoRecovery save of Iraq - security.asd'") + 1, | 352 | "Revision #0: Author `cic22' worked on `C:\\DOCUME~1\\phamill\\LOCALS~1\\Temp\\AutoRecovery save of Iraq - security.asd'", |
353 | 0 | 353 | strlen ( |
354 | }, | 354 | "Revision #0: Author `cic22' worked on `C:\\DOCUME~1\\phamill\\LOCALS~1\\Temp\\AutoRecovery save of Iraq - security.asd'") |
355 | { | 355 | + 1, |
356 | EXTRACTOR_METATYPE_REVISION_HISTORY, | 356 | 0 |
357 | EXTRACTOR_METAFORMAT_UTF8, | 357 | }, |
358 | "text/plain", | 358 | { |
359 | "Revision #1: Author `cic22' worked on `C:\\DOCUME~1\\phamill\\LOCALS~1\\Temp\\AutoRecovery save of Iraq - security.asd'", | 359 | EXTRACTOR_METATYPE_REVISION_HISTORY, |
360 | strlen ("Revision #1: Author `cic22' worked on `C:\\DOCUME~1\\phamill\\LOCALS~1\\Temp\\AutoRecovery save of Iraq - security.asd'") + 1, | 360 | EXTRACTOR_METAFORMAT_UTF8, |
361 | 0 | 361 | "text/plain", |
362 | }, | 362 | "Revision #1: Author `cic22' worked on `C:\\DOCUME~1\\phamill\\LOCALS~1\\Temp\\AutoRecovery save of Iraq - security.asd'", |
363 | { | 363 | strlen ( |
364 | EXTRACTOR_METATYPE_REVISION_HISTORY, | 364 | "Revision #1: Author `cic22' worked on `C:\\DOCUME~1\\phamill\\LOCALS~1\\Temp\\AutoRecovery save of Iraq - security.asd'") |
365 | EXTRACTOR_METAFORMAT_UTF8, | 365 | + 1, |
366 | "text/plain", | 366 | 0 |
367 | "Revision #2: Author `cic22' worked on `C:\\DOCUME~1\\phamill\\LOCALS~1\\Temp\\AutoRecovery save of Iraq - security.asd'", | 367 | }, |
368 | strlen ("Revision #2: Author `cic22' worked on `C:\\DOCUME~1\\phamill\\LOCALS~1\\Temp\\AutoRecovery save of Iraq - security.asd'") + 1, | 368 | { |
369 | 0 | 369 | EXTRACTOR_METATYPE_REVISION_HISTORY, |
370 | }, | 370 | EXTRACTOR_METAFORMAT_UTF8, |
371 | { | 371 | "text/plain", |
372 | EXTRACTOR_METATYPE_REVISION_HISTORY, | 372 | "Revision #2: Author `cic22' worked on `C:\\DOCUME~1\\phamill\\LOCALS~1\\Temp\\AutoRecovery save of Iraq - security.asd'", |
373 | EXTRACTOR_METAFORMAT_UTF8, | 373 | strlen ( |
374 | "text/plain", | 374 | "Revision #2: Author `cic22' worked on `C:\\DOCUME~1\\phamill\\LOCALS~1\\Temp\\AutoRecovery save of Iraq - security.asd'") |
375 | "Revision #3: Author `JPratt' worked on `C:\\TEMP\\Iraq - security.doc'", | 375 | + 1, |
376 | strlen ("Revision #3: Author `JPratt' worked on `C:\\TEMP\\Iraq - security.doc'") + 1, | 376 | 0 |
377 | 0 | 377 | }, |
378 | }, | 378 | { |
379 | { | 379 | EXTRACTOR_METATYPE_REVISION_HISTORY, |
380 | EXTRACTOR_METATYPE_REVISION_HISTORY, | 380 | EXTRACTOR_METAFORMAT_UTF8, |
381 | EXTRACTOR_METAFORMAT_UTF8, | 381 | "text/plain", |
382 | "text/plain", | 382 | "Revision #3: Author `JPratt' worked on `C:\\TEMP\\Iraq - security.doc'", |
383 | "Revision #4: Author `JPratt' worked on `A:\\Iraq - security.doc'", | 383 | strlen ( |
384 | strlen ("Revision #4: Author `JPratt' worked on `A:\\Iraq - security.doc'") + 1, | 384 | "Revision #3: Author `JPratt' worked on `C:\\TEMP\\Iraq - security.doc'") |
385 | 0 | 385 | + 1, |
386 | }, | 386 | 0 |
387 | { | 387 | }, |
388 | EXTRACTOR_METATYPE_REVISION_HISTORY, | 388 | { |
389 | EXTRACTOR_METAFORMAT_UTF8, | 389 | EXTRACTOR_METATYPE_REVISION_HISTORY, |
390 | "text/plain", | 390 | EXTRACTOR_METAFORMAT_UTF8, |
391 | "Revision #5: Author `ablackshaw' worked on `C:\\ABlackshaw\\Iraq - security.doc'", | 391 | "text/plain", |
392 | strlen ("Revision #5: Author `ablackshaw' worked on `C:\\ABlackshaw\\Iraq - security.doc'") + 1, | 392 | "Revision #4: Author `JPratt' worked on `A:\\Iraq - security.doc'", |
393 | 0 | 393 | strlen ( |
394 | }, | 394 | "Revision #4: Author `JPratt' worked on `A:\\Iraq - security.doc'") + 1, |
395 | { | 395 | 0 |
396 | EXTRACTOR_METATYPE_REVISION_HISTORY, | 396 | }, |
397 | EXTRACTOR_METAFORMAT_UTF8, | 397 | { |
398 | "text/plain", | 398 | EXTRACTOR_METATYPE_REVISION_HISTORY, |
399 | "Revision #6: Author `ablackshaw' worked on `C:\\ABlackshaw\\A;Iraq - security.doc'", | 399 | EXTRACTOR_METAFORMAT_UTF8, |
400 | strlen ("Revision #6: Author `ablackshaw' worked on `C:\\ABlackshaw\\A;Iraq - security.doc'") + 1, | 400 | "text/plain", |
401 | 0 | 401 | "Revision #5: Author `ablackshaw' worked on `C:\\ABlackshaw\\Iraq - security.doc'", |
402 | }, | 402 | strlen ( |
403 | { | 403 | "Revision #5: Author `ablackshaw' worked on `C:\\ABlackshaw\\Iraq - security.doc'") |
404 | EXTRACTOR_METATYPE_REVISION_HISTORY, | 404 | + 1, |
405 | EXTRACTOR_METAFORMAT_UTF8, | 405 | 0 |
406 | "text/plain", | 406 | }, |
407 | "Revision #7: Author `ablackshaw' worked on `A:\\Iraq - security.doc'", | 407 | { |
408 | strlen ("Revision #7: Author `ablackshaw' worked on `A:\\Iraq - security.doc'") + 1, | 408 | EXTRACTOR_METATYPE_REVISION_HISTORY, |
409 | 0 | 409 | EXTRACTOR_METAFORMAT_UTF8, |
410 | }, | 410 | "text/plain", |
411 | { | 411 | "Revision #6: Author `ablackshaw' worked on `C:\\ABlackshaw\\A;Iraq - security.doc'", |
412 | EXTRACTOR_METATYPE_REVISION_HISTORY, | 412 | strlen ( |
413 | EXTRACTOR_METAFORMAT_UTF8, | 413 | "Revision #6: Author `ablackshaw' worked on `C:\\ABlackshaw\\A;Iraq - security.doc'") |
414 | "text/plain", | 414 | + 1, |
415 | "Revision #8: Author `MKhan' worked on `C:\\TEMP\\Iraq - security.doc'", | 415 | 0 |
416 | strlen ("Revision #8: Author `MKhan' worked on `C:\\TEMP\\Iraq - security.doc'") + 1, | 416 | }, |
417 | 0 | 417 | { |
418 | }, | 418 | EXTRACTOR_METATYPE_REVISION_HISTORY, |
419 | { | 419 | EXTRACTOR_METAFORMAT_UTF8, |
420 | EXTRACTOR_METATYPE_REVISION_HISTORY, | 420 | "text/plain", |
421 | EXTRACTOR_METAFORMAT_UTF8, | 421 | "Revision #7: Author `ablackshaw' worked on `A:\\Iraq - security.doc'", |
422 | "text/plain", | 422 | strlen ( |
423 | "Revision #9: Author `MKhan' worked on `C:\\WINNT\\Profiles\\mkhan\\Desktop\\Iraq.doc'", | 423 | "Revision #7: Author `ablackshaw' worked on `A:\\Iraq - security.doc'") |
424 | strlen ("Revision #9: Author `MKhan' worked on `C:\\WINNT\\Profiles\\mkhan\\Desktop\\Iraq.doc'") + 1, | 424 | + 1, |
425 | 0 | 425 | 0 |
426 | }, | 426 | }, |
427 | { 0, 0, NULL, NULL, 0, -1 } | 427 | { |
428 | }; | 428 | EXTRACTOR_METATYPE_REVISION_HISTORY, |
429 | EXTRACTOR_METAFORMAT_UTF8, | ||
430 | "text/plain", | ||
431 | "Revision #8: Author `MKhan' worked on `C:\\TEMP\\Iraq - security.doc'", | ||
432 | strlen ( | ||
433 | "Revision #8: Author `MKhan' worked on `C:\\TEMP\\Iraq - security.doc'") | ||
434 | + 1, | ||
435 | 0 | ||
436 | }, | ||
437 | { | ||
438 | EXTRACTOR_METATYPE_REVISION_HISTORY, | ||
439 | EXTRACTOR_METAFORMAT_UTF8, | ||
440 | "text/plain", | ||
441 | "Revision #9: Author `MKhan' worked on `C:\\WINNT\\Profiles\\mkhan\\Desktop\\Iraq.doc'", | ||
442 | strlen ( | ||
443 | "Revision #9: Author `MKhan' worked on `C:\\WINNT\\Profiles\\mkhan\\Desktop\\Iraq.doc'") | ||
444 | + 1, | ||
445 | 0 | ||
446 | }, | ||
447 | { 0, 0, NULL, NULL, 0, -1 } | ||
448 | }; | ||
429 | #endif | 449 | #endif |
430 | struct SolutionData ole2_excel_sol[] = | 450 | struct SolutionData ole2_excel_sol[] = { |
431 | { | ||
432 | { | ||
433 | EXTRACTOR_METATYPE_CREATOR, | ||
434 | EXTRACTOR_METAFORMAT_UTF8, | ||
435 | "text/plain", | ||
436 | "JV", | ||
437 | strlen ("JV") + 1, | ||
438 | 0 | ||
439 | }, | ||
440 | { | ||
441 | EXTRACTOR_METATYPE_LAST_SAVED_BY, | ||
442 | EXTRACTOR_METAFORMAT_UTF8, | ||
443 | "text/plain", | ||
444 | "JV", | ||
445 | strlen ("JV") + 1, | ||
446 | 0 | ||
447 | }, | ||
448 | { | ||
449 | EXTRACTOR_METATYPE_CREATION_DATE, | ||
450 | EXTRACTOR_METAFORMAT_UTF8, | ||
451 | "text/plain", | ||
452 | "2002-03-20T21:26:28Z", | ||
453 | strlen ("2002-03-20T21:26:28Z") + 1, | ||
454 | 0 | ||
455 | }, | ||
456 | { | ||
457 | EXTRACTOR_METATYPE_MIMETYPE, | ||
458 | EXTRACTOR_METAFORMAT_UTF8, | ||
459 | "text/plain", | ||
460 | "application/vnd.ms-files", | ||
461 | strlen ("application/vnd.ms-files") + 1, | ||
462 | 0 | ||
463 | }, | ||
464 | { | ||
465 | EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE, | ||
466 | EXTRACTOR_METAFORMAT_UTF8, | ||
467 | "text/plain", | ||
468 | "Microsoft Excel", | ||
469 | strlen ("Microsoft Excel") + 1, | ||
470 | 0 | ||
471 | }, | ||
472 | { 0, 0, NULL, NULL, 0, -1 } | ||
473 | }; | ||
474 | |||
475 | struct ProblemSet ps[] = | ||
476 | { | 451 | { |
477 | { "testdata/ole2_msword.doc", | 452 | EXTRACTOR_METATYPE_CREATOR, |
478 | ole2_msword_sol }, | 453 | EXTRACTOR_METAFORMAT_UTF8, |
479 | { "testdata/ole2_starwriter40.sdw", | 454 | "text/plain", |
480 | ole2_starwriter_sol }, | 455 | "JV", |
456 | strlen ("JV") + 1, | ||
457 | 0 | ||
458 | }, | ||
459 | { | ||
460 | EXTRACTOR_METATYPE_LAST_SAVED_BY, | ||
461 | EXTRACTOR_METAFORMAT_UTF8, | ||
462 | "text/plain", | ||
463 | "JV", | ||
464 | strlen ("JV") + 1, | ||
465 | 0 | ||
466 | }, | ||
467 | { | ||
468 | EXTRACTOR_METATYPE_CREATION_DATE, | ||
469 | EXTRACTOR_METAFORMAT_UTF8, | ||
470 | "text/plain", | ||
471 | "2002-03-20T21:26:28Z", | ||
472 | strlen ("2002-03-20T21:26:28Z") + 1, | ||
473 | 0 | ||
474 | }, | ||
475 | { | ||
476 | EXTRACTOR_METATYPE_MIMETYPE, | ||
477 | EXTRACTOR_METAFORMAT_UTF8, | ||
478 | "text/plain", | ||
479 | "application/vnd.ms-files", | ||
480 | strlen ("application/vnd.ms-files") + 1, | ||
481 | 0 | ||
482 | }, | ||
483 | { | ||
484 | EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE, | ||
485 | EXTRACTOR_METAFORMAT_UTF8, | ||
486 | "text/plain", | ||
487 | "Microsoft Excel", | ||
488 | strlen ("Microsoft Excel") + 1, | ||
489 | 0 | ||
490 | }, | ||
491 | { 0, 0, NULL, NULL, 0, -1 } | ||
492 | }; | ||
493 | |||
494 | struct ProblemSet ps[] = { | ||
495 | { "testdata/ole2_msword.doc", | ||
496 | ole2_msword_sol }, | ||
497 | { "testdata/ole2_starwriter40.sdw", | ||
498 | ole2_starwriter_sol }, | ||
481 | #if HAVE_ICONV | 499 | #if HAVE_ICONV |
482 | { "testdata/ole2_blair.doc", | 500 | { "testdata/ole2_blair.doc", |
483 | ole2_blair_sol }, | 501 | ole2_blair_sol }, |
484 | #endif | 502 | #endif |
485 | { "testdata/ole2_excel.xls", | 503 | { "testdata/ole2_excel.xls", |
486 | ole2_excel_sol }, | 504 | ole2_excel_sol }, |
487 | { NULL, NULL } | 505 | { NULL, NULL } |
488 | }; | 506 | }; |
489 | return ET_main ("ole2", ps); | 507 | return ET_main ("ole2", ps); |
490 | } | 508 | } |
491 | 509 | ||
510 | |||
492 | /* end of test_ole2.c */ | 511 | /* end of test_ole2.c */ |
diff --git a/src/plugins/test_png.c b/src/plugins/test_png.c index 323865a..01be527 100644 --- a/src/plugins/test_png.c +++ b/src/plugins/test_png.c | |||
@@ -36,49 +36,48 @@ | |||
36 | int | 36 | int |
37 | main (int argc, char *argv[]) | 37 | main (int argc, char *argv[]) |
38 | { | 38 | { |
39 | struct SolutionData png_image_sol[] = | 39 | struct SolutionData png_image_sol[] = { |
40 | { | 40 | { |
41 | { | 41 | EXTRACTOR_METATYPE_MIMETYPE, |
42 | EXTRACTOR_METATYPE_MIMETYPE, | 42 | EXTRACTOR_METAFORMAT_UTF8, |
43 | EXTRACTOR_METAFORMAT_UTF8, | 43 | "text/plain", |
44 | "text/plain", | 44 | "image/png", |
45 | "image/png", | 45 | strlen ("image/png") + 1, |
46 | strlen ("image/png") + 1, | 46 | 0 |
47 | 0 | 47 | }, |
48 | }, | ||
49 | { | ||
50 | EXTRACTOR_METATYPE_IMAGE_DIMENSIONS, | ||
51 | EXTRACTOR_METAFORMAT_UTF8, | ||
52 | "text/plain", | ||
53 | "4x4", | ||
54 | strlen ("4x4") + 1, | ||
55 | 0 | ||
56 | }, | ||
57 | { | ||
58 | EXTRACTOR_METATYPE_COMMENT, | ||
59 | EXTRACTOR_METAFORMAT_UTF8, | ||
60 | "text/plain", | ||
61 | "Testing keyword extraction\n", | ||
62 | strlen ("Testing keyword extraction\n") + 1, | ||
63 | 0 | ||
64 | }, | ||
65 | { | ||
66 | EXTRACTOR_METATYPE_UNKNOWN, | ||
67 | EXTRACTOR_METAFORMAT_UTF8, | ||
68 | "text/plain", | ||
69 | "dc6c58c971715e8043baef058b675eec", | ||
70 | strlen ("dc6c58c971715e8043baef058b675eec") + 1, | ||
71 | 0 | ||
72 | }, | ||
73 | { 0, 0, NULL, NULL, 0, -1 } | ||
74 | }; | ||
75 | struct ProblemSet ps[] = | ||
76 | { | 48 | { |
77 | { "testdata/png_image.png", | 49 | EXTRACTOR_METATYPE_IMAGE_DIMENSIONS, |
78 | png_image_sol }, | 50 | EXTRACTOR_METAFORMAT_UTF8, |
79 | { NULL, NULL } | 51 | "text/plain", |
80 | }; | 52 | "4x4", |
53 | strlen ("4x4") + 1, | ||
54 | 0 | ||
55 | }, | ||
56 | { | ||
57 | EXTRACTOR_METATYPE_COMMENT, | ||
58 | EXTRACTOR_METAFORMAT_UTF8, | ||
59 | "text/plain", | ||
60 | "Testing keyword extraction\n", | ||
61 | strlen ("Testing keyword extraction\n") + 1, | ||
62 | 0 | ||
63 | }, | ||
64 | { | ||
65 | EXTRACTOR_METATYPE_UNKNOWN, | ||
66 | EXTRACTOR_METAFORMAT_UTF8, | ||
67 | "text/plain", | ||
68 | "dc6c58c971715e8043baef058b675eec", | ||
69 | strlen ("dc6c58c971715e8043baef058b675eec") + 1, | ||
70 | 0 | ||
71 | }, | ||
72 | { 0, 0, NULL, NULL, 0, -1 } | ||
73 | }; | ||
74 | struct ProblemSet ps[] = { | ||
75 | { "testdata/png_image.png", | ||
76 | png_image_sol }, | ||
77 | { NULL, NULL } | ||
78 | }; | ||
81 | return ET_main ("png", ps); | 79 | return ET_main ("png", ps); |
82 | } | 80 | } |
83 | 81 | ||
82 | |||
84 | /* end of test_png.c */ | 83 | /* end of test_png.c */ |
diff --git a/src/plugins/test_previewopus.c b/src/plugins/test_previewopus.c index 6178d19..6b0b1b8 100644 --- a/src/plugins/test_previewopus.c +++ b/src/plugins/test_previewopus.c | |||
@@ -26,7 +26,6 @@ | |||
26 | #include "test_lib.h" | 26 | #include "test_lib.h" |
27 | 27 | ||
28 | 28 | ||
29 | |||
30 | /** | 29 | /** |
31 | * Main function for the previewopus testcase. | 30 | * Main function for the previewopus testcase. |
32 | * | 31 | * |
@@ -37,18 +36,17 @@ | |||
37 | int | 36 | int |
38 | main (int argc, char *argv[]) | 37 | main (int argc, char *argv[]) |
39 | { | 38 | { |
40 | struct SolutionData previewopus_audio_sol[] = | 39 | struct SolutionData previewopus_audio_sol[] = { |
41 | { | 40 | // TODO. Can't test as it depends on the encoder. |
42 | //TODO. Can't test as it depends on the encoder. | 41 | { 0, 0, NULL, NULL, 0, -1 } |
43 | { 0, 0, NULL, NULL, 0, -1 } | 42 | }; |
44 | }; | 43 | struct ProblemSet ps[] = { |
45 | struct ProblemSet ps[] = | 44 | { "testdata/mpeg_alien.mpg", |
46 | { | 45 | previewopus_audio_sol }, |
47 | { "testdata/mpeg_alien.mpg", | 46 | { NULL, NULL } |
48 | previewopus_audio_sol }, | 47 | }; |
49 | { NULL, NULL } | ||
50 | }; | ||
51 | return ET_main ("previewopus", ps); | 48 | return ET_main ("previewopus", ps); |
52 | } | 49 | } |
53 | 50 | ||
51 | |||
54 | /* end of test_thumbnailffmpeg.c */ | 52 | /* end of test_thumbnailffmpeg.c */ |
diff --git a/src/plugins/test_ps.c b/src/plugins/test_ps.c index 6fc66bb..73167fa 100644 --- a/src/plugins/test_ps.c +++ b/src/plugins/test_ps.c | |||
@@ -26,7 +26,6 @@ | |||
26 | #include "test_lib.h" | 26 | #include "test_lib.h" |
27 | 27 | ||
28 | 28 | ||
29 | |||
30 | /** | 29 | /** |
31 | * Main function for the PS testcase. | 30 | * Main function for the PS testcase. |
32 | * | 31 | * |
@@ -37,103 +36,105 @@ | |||
37 | int | 36 | int |
38 | main (int argc, char *argv[]) | 37 | main (int argc, char *argv[]) |
39 | { | 38 | { |
40 | struct SolutionData ps_bloomfilter_sol[] = | 39 | struct SolutionData ps_bloomfilter_sol[] = { |
40 | { | ||
41 | EXTRACTOR_METATYPE_MIMETYPE, | ||
42 | EXTRACTOR_METAFORMAT_UTF8, | ||
43 | "text/plain", | ||
44 | "application/postscript", | ||
45 | strlen ("application/postscript") + 1, | ||
46 | 0 | ||
47 | }, | ||
48 | { | ||
49 | EXTRACTOR_METATYPE_TITLE, | ||
50 | EXTRACTOR_METAFORMAT_UTF8, | ||
51 | "text/plain", | ||
52 | "A Quick Introduction to Bloom Filters", | ||
53 | strlen ("A Quick Introduction to Bloom Filters") + 1, | ||
54 | 0 | ||
55 | }, | ||
56 | { | ||
57 | EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE, | ||
58 | EXTRACTOR_METAFORMAT_UTF8, | ||
59 | "text/plain", | ||
60 | "dvips(k) 5.92b Copyright 2002 Radical Eye Software", | ||
61 | strlen ("dvips(k) 5.92b Copyright 2002 Radical Eye Software") + 1, | ||
62 | 0 | ||
63 | }, | ||
64 | { | ||
65 | EXTRACTOR_METATYPE_PAGE_COUNT, | ||
66 | EXTRACTOR_METAFORMAT_UTF8, | ||
67 | "text/plain", | ||
68 | "1", | ||
69 | strlen ("1") + 1, | ||
70 | 0 | ||
71 | }, | ||
41 | { | 72 | { |
42 | { | 73 | EXTRACTOR_METATYPE_PAGE_ORDER, |
43 | EXTRACTOR_METATYPE_MIMETYPE, | 74 | EXTRACTOR_METAFORMAT_UTF8, |
44 | EXTRACTOR_METAFORMAT_UTF8, | 75 | "text/plain", |
45 | "text/plain", | 76 | "Ascend", |
46 | "application/postscript", | 77 | strlen ("Ascend") + 1, |
47 | strlen ("application/postscript") + 1, | 78 | 0 |
48 | 0 | 79 | }, |
49 | }, | 80 | { 0, 0, NULL, NULL, 0, -1 } |
50 | { | 81 | }; |
51 | EXTRACTOR_METATYPE_TITLE, | 82 | struct SolutionData ps_wallace_sol[] = { |
52 | EXTRACTOR_METAFORMAT_UTF8, | ||
53 | "text/plain", | ||
54 | "A Quick Introduction to Bloom Filters", | ||
55 | strlen ("A Quick Introduction to Bloom Filters") + 1, | ||
56 | 0 | ||
57 | }, | ||
58 | { | ||
59 | EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE, | ||
60 | EXTRACTOR_METAFORMAT_UTF8, | ||
61 | "text/plain", | ||
62 | "dvips(k) 5.92b Copyright 2002 Radical Eye Software", | ||
63 | strlen ("dvips(k) 5.92b Copyright 2002 Radical Eye Software") + 1, | ||
64 | 0 | ||
65 | }, | ||
66 | { | ||
67 | EXTRACTOR_METATYPE_PAGE_COUNT, | ||
68 | EXTRACTOR_METAFORMAT_UTF8, | ||
69 | "text/plain", | ||
70 | "1", | ||
71 | strlen ("1") + 1, | ||
72 | 0 | ||
73 | }, | ||
74 | { | ||
75 | EXTRACTOR_METATYPE_PAGE_ORDER, | ||
76 | EXTRACTOR_METAFORMAT_UTF8, | ||
77 | "text/plain", | ||
78 | "Ascend", | ||
79 | strlen ("Ascend") + 1, | ||
80 | 0 | ||
81 | }, | ||
82 | { 0, 0, NULL, NULL, 0, -1 } | ||
83 | }; | ||
84 | struct SolutionData ps_wallace_sol[] = | ||
85 | { | 83 | { |
86 | { | 84 | EXTRACTOR_METATYPE_MIMETYPE, |
87 | EXTRACTOR_METATYPE_MIMETYPE, | 85 | EXTRACTOR_METAFORMAT_UTF8, |
88 | EXTRACTOR_METAFORMAT_UTF8, | 86 | "text/plain", |
89 | "text/plain", | 87 | "application/postscript", |
90 | "application/postscript", | 88 | strlen ("application/postscript") + 1, |
91 | strlen ("application/postscript") + 1, | 89 | 0 |
92 | 0 | 90 | }, |
93 | }, | ||
94 | { | ||
95 | EXTRACTOR_METATYPE_SUBJECT, | ||
96 | EXTRACTOR_METAFORMAT_UTF8, | ||
97 | "text/plain", | ||
98 | "PS preprint of JPEG article submitted to IEEE Trans on Consum. Elect", | ||
99 | strlen ("PS preprint of JPEG article submitted to IEEE Trans on Consum. Elect") + 1, | ||
100 | 0 | ||
101 | }, | ||
102 | { | ||
103 | EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE, | ||
104 | EXTRACTOR_METAFORMAT_UTF8, | ||
105 | "text/plain", | ||
106 | "DECwrite V1.1 Copyright (c) 1990 DIGITAL EQUIPMENT CORPORATION. All Rights Reserved.", | ||
107 | strlen ("DECwrite V1.1 Copyright (c) 1990 DIGITAL EQUIPMENT CORPORATION. All Rights Reserved.") + 1, | ||
108 | 0 | ||
109 | }, | ||
110 | { | ||
111 | EXTRACTOR_METATYPE_AUTHOR_NAME, | ||
112 | EXTRACTOR_METAFORMAT_UTF8, | ||
113 | "text/plain", | ||
114 | "Greg Wallace", | ||
115 | strlen ("Greg Wallace") + 1, | ||
116 | 0 | ||
117 | }, | ||
118 | { | ||
119 | EXTRACTOR_METATYPE_UNKNOWN_DATE, | ||
120 | EXTRACTOR_METAFORMAT_UTF8, | ||
121 | "text/plain", | ||
122 | "Tue, 17 Dec 91 14:49:50 PST", | ||
123 | strlen ("Tue, 17 Dec 91 14:49:50 PST") + 1, | ||
124 | 0 | ||
125 | }, | ||
126 | { 0, 0, NULL, NULL, 0, -1 } | ||
127 | }; | ||
128 | struct ProblemSet ps[] = | ||
129 | { | 91 | { |
130 | { "testdata/ps_bloomfilter.ps", | 92 | EXTRACTOR_METATYPE_SUBJECT, |
131 | ps_bloomfilter_sol }, | 93 | EXTRACTOR_METAFORMAT_UTF8, |
132 | { "testdata/ps_wallace.ps", | 94 | "text/plain", |
133 | ps_wallace_sol }, | 95 | "PS preprint of JPEG article submitted to IEEE Trans on Consum. Elect", |
134 | { NULL, NULL } | 96 | strlen ( |
135 | }; | 97 | "PS preprint of JPEG article submitted to IEEE Trans on Consum. Elect") |
98 | + 1, | ||
99 | 0 | ||
100 | }, | ||
101 | { | ||
102 | EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE, | ||
103 | EXTRACTOR_METAFORMAT_UTF8, | ||
104 | "text/plain", | ||
105 | "DECwrite V1.1 Copyright (c) 1990 DIGITAL EQUIPMENT CORPORATION. All Rights Reserved.", | ||
106 | strlen ( | ||
107 | "DECwrite V1.1 Copyright (c) 1990 DIGITAL EQUIPMENT CORPORATION. All Rights Reserved.") | ||
108 | + 1, | ||
109 | 0 | ||
110 | }, | ||
111 | { | ||
112 | EXTRACTOR_METATYPE_AUTHOR_NAME, | ||
113 | EXTRACTOR_METAFORMAT_UTF8, | ||
114 | "text/plain", | ||
115 | "Greg Wallace", | ||
116 | strlen ("Greg Wallace") + 1, | ||
117 | 0 | ||
118 | }, | ||
119 | { | ||
120 | EXTRACTOR_METATYPE_UNKNOWN_DATE, | ||
121 | EXTRACTOR_METAFORMAT_UTF8, | ||
122 | "text/plain", | ||
123 | "Tue, 17 Dec 91 14:49:50 PST", | ||
124 | strlen ("Tue, 17 Dec 91 14:49:50 PST") + 1, | ||
125 | 0 | ||
126 | }, | ||
127 | { 0, 0, NULL, NULL, 0, -1 } | ||
128 | }; | ||
129 | struct ProblemSet ps[] = { | ||
130 | { "testdata/ps_bloomfilter.ps", | ||
131 | ps_bloomfilter_sol }, | ||
132 | { "testdata/ps_wallace.ps", | ||
133 | ps_wallace_sol }, | ||
134 | { NULL, NULL } | ||
135 | }; | ||
136 | return ET_main ("ps", ps); | 136 | return ET_main ("ps", ps); |
137 | } | 137 | } |
138 | 138 | ||
139 | |||
139 | /* end of test_ps.c */ | 140 | /* end of test_ps.c */ |
diff --git a/src/plugins/test_riff.c b/src/plugins/test_riff.c index 2838a08..6993b2c 100644 --- a/src/plugins/test_riff.c +++ b/src/plugins/test_riff.c | |||
@@ -26,7 +26,6 @@ | |||
26 | #include "test_lib.h" | 26 | #include "test_lib.h" |
27 | 27 | ||
28 | 28 | ||
29 | |||
30 | /** | 29 | /** |
31 | * Main function for the RIFF testcase. | 30 | * Main function for the RIFF testcase. |
32 | * | 31 | * |
@@ -37,41 +36,40 @@ | |||
37 | int | 36 | int |
38 | main (int argc, char *argv[]) | 37 | main (int argc, char *argv[]) |
39 | { | 38 | { |
40 | struct SolutionData riff_flame_sol[] = | 39 | struct SolutionData riff_flame_sol[] = { |
40 | { | ||
41 | EXTRACTOR_METATYPE_MIMETYPE, | ||
42 | EXTRACTOR_METAFORMAT_UTF8, | ||
43 | "text/plain", | ||
44 | "video/x-msvideo", | ||
45 | strlen ("video/x-msvideo") + 1, | ||
46 | 0 | ||
47 | }, | ||
41 | { | 48 | { |
42 | { | 49 | EXTRACTOR_METATYPE_FORMAT, |
43 | EXTRACTOR_METATYPE_MIMETYPE, | 50 | EXTRACTOR_METAFORMAT_UTF8, |
44 | EXTRACTOR_METAFORMAT_UTF8, | 51 | "text/plain", |
45 | "text/plain", | 52 | "codec: cvid, 35 fps, 3143 ms", |
46 | "video/x-msvideo", | 53 | strlen ("codec: cvid, 35 fps, 3143 ms") + 1, |
47 | strlen ("video/x-msvideo") + 1, | 54 | 0 |
48 | 0 | 55 | }, |
49 | }, | ||
50 | { | ||
51 | EXTRACTOR_METATYPE_FORMAT, | ||
52 | EXTRACTOR_METAFORMAT_UTF8, | ||
53 | "text/plain", | ||
54 | "codec: cvid, 35 fps, 3143 ms", | ||
55 | strlen ("codec: cvid, 35 fps, 3143 ms") + 1, | ||
56 | 0 | ||
57 | }, | ||
58 | { | ||
59 | EXTRACTOR_METATYPE_IMAGE_DIMENSIONS, | ||
60 | EXTRACTOR_METAFORMAT_UTF8, | ||
61 | "text/plain", | ||
62 | "256x240", | ||
63 | strlen ("256x240") + 1, | ||
64 | 0 | ||
65 | }, | ||
66 | { 0, 0, NULL, NULL, 0, -1 } | ||
67 | }; | ||
68 | struct ProblemSet ps[] = | ||
69 | { | 56 | { |
70 | { "testdata/riff_flame.avi", | 57 | EXTRACTOR_METATYPE_IMAGE_DIMENSIONS, |
71 | riff_flame_sol }, | 58 | EXTRACTOR_METAFORMAT_UTF8, |
72 | { NULL, NULL } | 59 | "text/plain", |
73 | }; | 60 | "256x240", |
61 | strlen ("256x240") + 1, | ||
62 | 0 | ||
63 | }, | ||
64 | { 0, 0, NULL, NULL, 0, -1 } | ||
65 | }; | ||
66 | struct ProblemSet ps[] = { | ||
67 | { "testdata/riff_flame.avi", | ||
68 | riff_flame_sol }, | ||
69 | { NULL, NULL } | ||
70 | }; | ||
74 | return ET_main ("riff", ps); | 71 | return ET_main ("riff", ps); |
75 | } | 72 | } |
76 | 73 | ||
74 | |||
77 | /* end of test_riff.c */ | 75 | /* end of test_riff.c */ |
diff --git a/src/plugins/test_rpm.c b/src/plugins/test_rpm.c index 95affa5..e9fbfc6 100644 --- a/src/plugins/test_rpm.c +++ b/src/plugins/test_rpm.c | |||
@@ -34,12 +34,13 @@ | |||
34 | /** | 34 | /** |
35 | * Expected package description text. | 35 | * Expected package description text. |
36 | */ | 36 | */ |
37 | #define DESCRIPTION "The libtool package contains the GNU libtool, a set of shell scripts\n"\ | 37 | #define DESCRIPTION \ |
38 | "which automatically configure UNIX and UNIX-like architectures to\n" \ | 38 | "The libtool package contains the GNU libtool, a set of shell scripts\n" \ |
39 | "which automatically configure UNIX and UNIX-like architectures to\n" \ | ||
39 | "generically build shared libraries. Libtool provides a consistent,\n" \ | 40 | "generically build shared libraries. Libtool provides a consistent,\n" \ |
40 | "portable interface which simplifies the process of using shared\n" \ | 41 | "portable interface which simplifies the process of using shared\n" \ |
41 | "libraries.\n" \ | 42 | "libraries.\n" \ |
42 | "\n" \ | 43 | "\n" \ |
43 | "If you are developing programs which will use shared libraries, you\n" \ | 44 | "If you are developing programs which will use shared libraries, you\n" \ |
44 | "should install libtool." | 45 | "should install libtool." |
45 | 46 | ||
@@ -54,273 +55,272 @@ | |||
54 | int | 55 | int |
55 | main (int argc, char *argv[]) | 56 | main (int argc, char *argv[]) |
56 | { | 57 | { |
57 | struct SolutionData rpm_test_sol[] = | 58 | struct SolutionData rpm_test_sol[] = { |
58 | { | 59 | { |
59 | { | 60 | EXTRACTOR_METATYPE_MIMETYPE, |
60 | EXTRACTOR_METATYPE_MIMETYPE, | 61 | EXTRACTOR_METAFORMAT_UTF8, |
61 | EXTRACTOR_METAFORMAT_UTF8, | 62 | "text/plain", |
62 | "text/plain", | 63 | "application/x-rpm", |
63 | "application/x-rpm", | 64 | strlen ("application/x-rpm") + 1, |
64 | strlen ("application/x-rpm") + 1, | 65 | 0 |
65 | 0 | 66 | }, |
66 | }, | 67 | { |
67 | { | 68 | EXTRACTOR_METATYPE_PACKAGE_NAME, |
68 | EXTRACTOR_METATYPE_PACKAGE_NAME, | 69 | EXTRACTOR_METAFORMAT_UTF8, |
69 | EXTRACTOR_METAFORMAT_UTF8, | 70 | "text/plain", |
70 | "text/plain", | 71 | "libtool", |
71 | "libtool", | 72 | strlen ("libtool") + 1, |
72 | strlen ("libtool") + 1, | 73 | 0 |
73 | 0 | 74 | }, |
74 | }, | 75 | { |
75 | { | 76 | EXTRACTOR_METATYPE_SOFTWARE_VERSION, |
76 | EXTRACTOR_METATYPE_SOFTWARE_VERSION, | 77 | EXTRACTOR_METAFORMAT_UTF8, |
77 | EXTRACTOR_METAFORMAT_UTF8, | 78 | "text/plain", |
78 | "text/plain", | 79 | "1.5", |
79 | "1.5", | 80 | strlen ("1.5") + 1, |
80 | strlen ("1.5") + 1, | 81 | 0 |
81 | 0 | 82 | }, |
82 | }, | 83 | { |
83 | { | 84 | EXTRACTOR_METATYPE_PACKAGE_VERSION, |
84 | EXTRACTOR_METATYPE_PACKAGE_VERSION, | 85 | EXTRACTOR_METAFORMAT_UTF8, |
85 | EXTRACTOR_METAFORMAT_UTF8, | 86 | "text/plain", |
86 | "text/plain", | 87 | "6", |
87 | "6", | 88 | strlen ("6") + 1, |
88 | strlen ("6") + 1, | 89 | 0 |
89 | 0 | 90 | }, |
90 | }, | 91 | { |
91 | { | 92 | EXTRACTOR_METATYPE_SUMMARY, |
92 | EXTRACTOR_METATYPE_SUMMARY, | 93 | EXTRACTOR_METAFORMAT_UTF8, |
93 | EXTRACTOR_METAFORMAT_UTF8, | 94 | "text/plain", |
94 | "text/plain", | 95 | SUMMARY, |
95 | SUMMARY, | 96 | strlen (SUMMARY) + 1, |
96 | strlen (SUMMARY) + 1, | 97 | 0 |
97 | 0 | 98 | }, |
98 | }, | 99 | { |
99 | { | 100 | EXTRACTOR_METATYPE_DESCRIPTION, |
100 | EXTRACTOR_METATYPE_DESCRIPTION, | 101 | EXTRACTOR_METAFORMAT_UTF8, |
101 | EXTRACTOR_METAFORMAT_UTF8, | 102 | "text/plain", |
102 | "text/plain", | 103 | DESCRIPTION, |
103 | DESCRIPTION, | 104 | strlen (DESCRIPTION) + 1, |
104 | strlen (DESCRIPTION) + 1, | 105 | 0 |
105 | 0 | 106 | }, |
106 | }, | 107 | { |
107 | { | 108 | EXTRACTOR_METATYPE_CREATION_DATE, |
108 | EXTRACTOR_METATYPE_CREATION_DATE, | 109 | EXTRACTOR_METAFORMAT_UTF8, |
109 | EXTRACTOR_METAFORMAT_UTF8, | 110 | "text/plain", |
110 | "text/plain", | 111 | "Thu Oct 2 11:44:33 2003", |
111 | "Thu Oct 2 11:44:33 2003", | 112 | strlen ("Thu Oct 2 11:44:33 2003") + 1, |
112 | strlen ("Thu Oct 2 11:44:33 2003") + 1, | 113 | 0 |
113 | 0 | 114 | }, |
114 | }, | 115 | { |
115 | { | 116 | EXTRACTOR_METATYPE_BUILDHOST, |
116 | EXTRACTOR_METATYPE_BUILDHOST, | 117 | EXTRACTOR_METAFORMAT_UTF8, |
117 | EXTRACTOR_METAFORMAT_UTF8, | 118 | "text/plain", |
118 | "text/plain", | 119 | "bullwinkle.devel.redhat.com", |
119 | "bullwinkle.devel.redhat.com", | 120 | strlen ("bullwinkle.devel.redhat.com") + 1, |
120 | strlen ("bullwinkle.devel.redhat.com") + 1, | 121 | 0 |
121 | 0 | 122 | }, |
122 | }, | 123 | { |
123 | { | 124 | EXTRACTOR_METATYPE_PACKAGE_INSTALLED_SIZE, |
124 | EXTRACTOR_METATYPE_PACKAGE_INSTALLED_SIZE, | 125 | EXTRACTOR_METAFORMAT_UTF8, |
125 | EXTRACTOR_METAFORMAT_UTF8, | 126 | "text/plain", |
126 | "text/plain", | 127 | "2623621", |
127 | "2623621", | 128 | strlen ("2623621") + 1, |
128 | strlen ("2623621") + 1, | 129 | 0 |
129 | 0 | 130 | }, |
130 | }, | 131 | { |
131 | { | 132 | EXTRACTOR_METATYPE_PACKAGE_DISTRIBUTION, |
132 | EXTRACTOR_METATYPE_PACKAGE_DISTRIBUTION, | 133 | EXTRACTOR_METAFORMAT_UTF8, |
133 | EXTRACTOR_METAFORMAT_UTF8, | 134 | "text/plain", |
134 | "text/plain", | 135 | "Red Hat Linux", |
135 | "Red Hat Linux", | 136 | strlen ("Red Hat Linux") + 1, |
136 | strlen ("Red Hat Linux") + 1, | 137 | 0 |
137 | 0 | 138 | }, |
138 | }, | 139 | { |
139 | { | 140 | EXTRACTOR_METATYPE_VENDOR, |
140 | EXTRACTOR_METATYPE_VENDOR, | 141 | EXTRACTOR_METAFORMAT_UTF8, |
141 | EXTRACTOR_METAFORMAT_UTF8, | 142 | "text/plain", |
142 | "text/plain", | 143 | "Red Hat, Inc.", |
143 | "Red Hat, Inc.", | 144 | strlen ("Red Hat, Inc.") + 1, |
144 | strlen ("Red Hat, Inc.") + 1, | 145 | 0 |
145 | 0 | 146 | }, |
146 | }, | 147 | { |
147 | { | 148 | EXTRACTOR_METATYPE_LICENSE, |
148 | EXTRACTOR_METATYPE_LICENSE, | 149 | EXTRACTOR_METAFORMAT_UTF8, |
149 | EXTRACTOR_METAFORMAT_UTF8, | 150 | "text/plain", |
150 | "text/plain", | 151 | "GPL", |
151 | "GPL", | 152 | strlen ("GPL") + 1, |
152 | strlen ("GPL") + 1, | 153 | 0 |
153 | 0 | 154 | }, |
154 | }, | 155 | { |
155 | { | 156 | EXTRACTOR_METATYPE_PACKAGE_MAINTAINER, |
156 | EXTRACTOR_METATYPE_PACKAGE_MAINTAINER, | 157 | EXTRACTOR_METAFORMAT_UTF8, |
157 | EXTRACTOR_METAFORMAT_UTF8, | 158 | "text/plain", |
158 | "text/plain", | 159 | "Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>", |
159 | "Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>", | 160 | strlen ("Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>") + 1, |
160 | strlen ("Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>") + 1, | 161 | 0 |
161 | 0 | 162 | }, |
162 | }, | 163 | { |
163 | { | 164 | EXTRACTOR_METATYPE_SECTION, |
164 | EXTRACTOR_METATYPE_SECTION, | 165 | EXTRACTOR_METAFORMAT_UTF8, |
165 | EXTRACTOR_METAFORMAT_UTF8, | 166 | "text/plain", |
166 | "text/plain", | 167 | "Development/Tools", |
167 | "Development/Tools", | 168 | strlen ("Development/Tools") + 1, |
168 | strlen ("Development/Tools") + 1, | 169 | 0 |
169 | 0 | 170 | }, |
170 | }, | 171 | { |
171 | { | 172 | EXTRACTOR_METATYPE_URL, |
172 | EXTRACTOR_METATYPE_URL, | 173 | EXTRACTOR_METAFORMAT_UTF8, |
173 | EXTRACTOR_METAFORMAT_UTF8, | 174 | "text/plain", |
174 | "text/plain", | 175 | "http://www.gnu.org/software/libtool/", |
175 | "http://www.gnu.org/software/libtool/", | 176 | strlen ("http://www.gnu.org/software/libtool/") + 1, |
176 | strlen ("http://www.gnu.org/software/libtool/") + 1, | 177 | 0 |
177 | 0 | 178 | }, |
178 | }, | 179 | { |
179 | { | 180 | EXTRACTOR_METATYPE_TARGET_OS, |
180 | EXTRACTOR_METATYPE_TARGET_OS, | 181 | EXTRACTOR_METAFORMAT_UTF8, |
181 | EXTRACTOR_METAFORMAT_UTF8, | 182 | "text/plain", |
182 | "text/plain", | 183 | "linux", |
183 | "linux", | 184 | strlen ("linux") + 1, |
184 | strlen ("linux") + 1, | 185 | 0 |
185 | 0 | 186 | }, |
186 | }, | 187 | { |
187 | { | 188 | EXTRACTOR_METATYPE_TARGET_ARCHITECTURE, |
188 | EXTRACTOR_METATYPE_TARGET_ARCHITECTURE, | 189 | EXTRACTOR_METAFORMAT_UTF8, |
189 | EXTRACTOR_METAFORMAT_UTF8, | 190 | "text/plain", |
190 | "text/plain", | 191 | "ia64", |
191 | "ia64", | 192 | strlen ("ia64") + 1, |
192 | strlen ("ia64") + 1, | 193 | 0 |
193 | 0 | 194 | }, |
194 | }, | 195 | { |
195 | { | 196 | EXTRACTOR_METATYPE_PACKAGE_PROVIDES, |
196 | EXTRACTOR_METATYPE_PACKAGE_PROVIDES, | 197 | EXTRACTOR_METAFORMAT_UTF8, |
197 | EXTRACTOR_METAFORMAT_UTF8, | 198 | "text/plain", |
198 | "text/plain", | 199 | "libtool", |
199 | "libtool", | 200 | strlen ("libtool") + 1, |
200 | strlen ("libtool") + 1, | 201 | 0 |
201 | 0 | 202 | }, |
202 | }, | 203 | { |
203 | { | 204 | EXTRACTOR_METATYPE_PACKAGE_DEPENDENCY, |
204 | EXTRACTOR_METATYPE_PACKAGE_DEPENDENCY, | 205 | EXTRACTOR_METAFORMAT_UTF8, |
205 | EXTRACTOR_METAFORMAT_UTF8, | 206 | "text/plain", |
206 | "text/plain", | 207 | "/bin/sh", |
207 | "/bin/sh", | 208 | strlen ("/bin/sh") + 1, |
208 | strlen ("/bin/sh") + 1, | 209 | 0 |
209 | 0 | 210 | }, |
210 | }, | 211 | { |
211 | { | 212 | EXTRACTOR_METATYPE_PACKAGE_DEPENDENCY, |
212 | EXTRACTOR_METATYPE_PACKAGE_DEPENDENCY, | 213 | EXTRACTOR_METAFORMAT_UTF8, |
213 | EXTRACTOR_METAFORMAT_UTF8, | 214 | "text/plain", |
214 | "text/plain", | 215 | "/bin/sh", |
215 | "/bin/sh", | 216 | strlen ("/bin/sh") + 1, |
216 | strlen ("/bin/sh") + 1, | 217 | 0 |
217 | 0 | 218 | }, |
218 | }, | 219 | { |
219 | { | 220 | EXTRACTOR_METATYPE_PACKAGE_DEPENDENCY, |
220 | EXTRACTOR_METATYPE_PACKAGE_DEPENDENCY, | 221 | EXTRACTOR_METAFORMAT_UTF8, |
221 | EXTRACTOR_METAFORMAT_UTF8, | 222 | "text/plain", |
222 | "text/plain", | 223 | "/bin/sh", |
223 | "/bin/sh", | 224 | strlen ("/bin/sh") + 1, |
224 | strlen ("/bin/sh") + 1, | 225 | 0 |
225 | 0 | 226 | }, |
226 | }, | 227 | { |
227 | { | 228 | EXTRACTOR_METATYPE_PACKAGE_DEPENDENCY, |
228 | EXTRACTOR_METATYPE_PACKAGE_DEPENDENCY, | 229 | EXTRACTOR_METAFORMAT_UTF8, |
229 | EXTRACTOR_METAFORMAT_UTF8, | 230 | "text/plain", |
230 | "text/plain", | 231 | "/sbin/install-info", |
231 | "/sbin/install-info", | 232 | strlen ("/sbin/install-info") + 1, |
232 | strlen ("/sbin/install-info") + 1, | 233 | 0 |
233 | 0 | 234 | }, |
234 | }, | 235 | { |
235 | { | 236 | EXTRACTOR_METATYPE_PACKAGE_DEPENDENCY, |
236 | EXTRACTOR_METATYPE_PACKAGE_DEPENDENCY, | 237 | EXTRACTOR_METAFORMAT_UTF8, |
237 | EXTRACTOR_METAFORMAT_UTF8, | 238 | "text/plain", |
238 | "text/plain", | 239 | "autoconf", |
239 | "autoconf", | 240 | strlen ("autoconf") + 1, |
240 | strlen ("autoconf") + 1, | 241 | 0 |
241 | 0 | 242 | }, |
242 | }, | 243 | { |
243 | { | 244 | EXTRACTOR_METATYPE_PACKAGE_DEPENDENCY, |
244 | EXTRACTOR_METATYPE_PACKAGE_DEPENDENCY, | 245 | EXTRACTOR_METAFORMAT_UTF8, |
245 | EXTRACTOR_METAFORMAT_UTF8, | 246 | "text/plain", |
246 | "text/plain", | 247 | "automake", |
247 | "automake", | 248 | strlen ("automake") + 1, |
248 | strlen ("automake") + 1, | 249 | 0 |
249 | 0 | 250 | }, |
250 | }, | 251 | { |
251 | { | 252 | EXTRACTOR_METATYPE_PACKAGE_DEPENDENCY, |
252 | EXTRACTOR_METATYPE_PACKAGE_DEPENDENCY, | 253 | EXTRACTOR_METAFORMAT_UTF8, |
253 | EXTRACTOR_METAFORMAT_UTF8, | 254 | "text/plain", |
254 | "text/plain", | 255 | "libtool-libs", |
255 | "libtool-libs", | 256 | strlen ("libtool-libs") + 1, |
256 | strlen ("libtool-libs") + 1, | 257 | 0 |
257 | 0 | 258 | }, |
258 | }, | 259 | { |
259 | { | 260 | EXTRACTOR_METATYPE_PACKAGE_DEPENDENCY, |
260 | EXTRACTOR_METATYPE_PACKAGE_DEPENDENCY, | 261 | EXTRACTOR_METAFORMAT_UTF8, |
261 | EXTRACTOR_METAFORMAT_UTF8, | 262 | "text/plain", |
262 | "text/plain", | 263 | "m4", |
263 | "m4", | 264 | strlen ("m4") + 1, |
264 | strlen ("m4") + 1, | 265 | 0 |
265 | 0 | 266 | }, |
266 | }, | 267 | { |
267 | { | 268 | EXTRACTOR_METATYPE_PACKAGE_DEPENDENCY, |
268 | EXTRACTOR_METATYPE_PACKAGE_DEPENDENCY, | 269 | EXTRACTOR_METAFORMAT_UTF8, |
269 | EXTRACTOR_METAFORMAT_UTF8, | 270 | "text/plain", |
270 | "text/plain", | 271 | "mktemp", |
271 | "mktemp", | 272 | strlen ("mktemp") + 1, |
272 | strlen ("mktemp") + 1, | 273 | 0 |
273 | 0 | 274 | }, |
274 | }, | 275 | { |
275 | { | 276 | EXTRACTOR_METATYPE_PACKAGE_DEPENDENCY, |
276 | EXTRACTOR_METATYPE_PACKAGE_DEPENDENCY, | 277 | EXTRACTOR_METAFORMAT_UTF8, |
277 | EXTRACTOR_METAFORMAT_UTF8, | 278 | "text/plain", |
278 | "text/plain", | 279 | "perl", |
279 | "perl", | 280 | strlen ("perl") + 1, |
280 | strlen ("perl") + 1, | 281 | 0 |
281 | 0 | 282 | }, |
282 | }, | 283 | { |
283 | { | 284 | EXTRACTOR_METATYPE_PACKAGE_DEPENDENCY, |
284 | EXTRACTOR_METATYPE_PACKAGE_DEPENDENCY, | 285 | EXTRACTOR_METAFORMAT_UTF8, |
285 | EXTRACTOR_METAFORMAT_UTF8, | 286 | "text/plain", |
286 | "text/plain", | 287 | "rpmlib(CompressedFileNames)", |
287 | "rpmlib(CompressedFileNames)", | 288 | strlen ("rpmlib(CompressedFileNames)") + 1, |
288 | strlen ("rpmlib(CompressedFileNames)") + 1, | 289 | 0 |
289 | 0 | 290 | }, |
290 | }, | 291 | { |
291 | { | 292 | EXTRACTOR_METATYPE_PACKAGE_DEPENDENCY, |
292 | EXTRACTOR_METATYPE_PACKAGE_DEPENDENCY, | 293 | EXTRACTOR_METAFORMAT_UTF8, |
293 | EXTRACTOR_METAFORMAT_UTF8, | 294 | "text/plain", |
294 | "text/plain", | 295 | "rpmlib(PayloadFilesHavePrefix)", |
295 | "rpmlib(PayloadFilesHavePrefix)", | 296 | strlen ("rpmlib(PayloadFilesHavePrefix)") + 1, |
296 | strlen ("rpmlib(PayloadFilesHavePrefix)") + 1, | 297 | 0 |
297 | 0 | 298 | }, |
298 | }, | 299 | { |
299 | { | 300 | EXTRACTOR_METATYPE_PACKAGE_DEPENDENCY, |
300 | EXTRACTOR_METATYPE_PACKAGE_DEPENDENCY, | 301 | EXTRACTOR_METAFORMAT_UTF8, |
301 | EXTRACTOR_METAFORMAT_UTF8, | 302 | "text/plain", |
302 | "text/plain", | 303 | "rpmlib(VersionedDependencies)", |
303 | "rpmlib(VersionedDependencies)", | 304 | strlen ("rpmlib(VersionedDependencies)") + 1, |
304 | strlen ("rpmlib(VersionedDependencies)") + 1, | 305 | 0 |
305 | 0 | 306 | }, |
306 | }, | 307 | { |
307 | { | 308 | EXTRACTOR_METATYPE_TARGET_PLATFORM, |
308 | EXTRACTOR_METATYPE_TARGET_PLATFORM, | 309 | EXTRACTOR_METAFORMAT_UTF8, |
309 | EXTRACTOR_METAFORMAT_UTF8, | 310 | "text/plain", |
310 | "text/plain", | 311 | "ia64-redhat-linux-gnu", |
311 | "ia64-redhat-linux-gnu", | 312 | strlen ("ia64-redhat-linux-gnu") + 1, |
312 | strlen ("ia64-redhat-linux-gnu") + 1, | 313 | 0 |
313 | 0 | 314 | }, |
314 | }, | 315 | { 0, 0, NULL, NULL, 0, -1 } |
315 | { 0, 0, NULL, NULL, 0, -1 } | 316 | }; |
316 | }; | 317 | struct ProblemSet ps[] = { |
317 | struct ProblemSet ps[] = | 318 | { "testdata/rpm_test.rpm", |
318 | { | 319 | rpm_test_sol }, |
319 | { "testdata/rpm_test.rpm", | 320 | { NULL, NULL } |
320 | rpm_test_sol }, | 321 | }; |
321 | { NULL, NULL } | ||
322 | }; | ||
323 | return ET_main ("rpm", ps); | 322 | return ET_main ("rpm", ps); |
324 | } | 323 | } |
325 | 324 | ||
325 | |||
326 | /* end of test_rpm.c */ | 326 | /* end of test_rpm.c */ |
diff --git a/src/plugins/test_s3m.c b/src/plugins/test_s3m.c index 1487daf..af99df2 100644 --- a/src/plugins/test_s3m.c +++ b/src/plugins/test_s3m.c | |||
@@ -26,7 +26,6 @@ | |||
26 | #include "test_lib.h" | 26 | #include "test_lib.h" |
27 | 27 | ||
28 | 28 | ||
29 | |||
30 | /** | 29 | /** |
31 | * Main function for the S3M testcase. | 30 | * Main function for the S3M testcase. |
32 | * | 31 | * |
@@ -37,33 +36,32 @@ | |||
37 | int | 36 | int |
38 | main (int argc, char *argv[]) | 37 | main (int argc, char *argv[]) |
39 | { | 38 | { |
40 | struct SolutionData s3m_2ndpm_sol[] = | 39 | struct SolutionData s3m_2ndpm_sol[] = { |
41 | { | 40 | { |
42 | { | 41 | EXTRACTOR_METATYPE_MIMETYPE, |
43 | EXTRACTOR_METATYPE_MIMETYPE, | 42 | EXTRACTOR_METAFORMAT_UTF8, |
44 | EXTRACTOR_METAFORMAT_UTF8, | 43 | "text/plain", |
45 | "text/plain", | 44 | "audio/x-s3m", |
46 | "audio/x-s3m", | 45 | strlen ("audio/x-s3m") + 1, |
47 | strlen ("audio/x-s3m") + 1, | 46 | 0 |
48 | 0 | 47 | }, |
49 | }, | ||
50 | { | ||
51 | EXTRACTOR_METATYPE_TITLE, | ||
52 | EXTRACTOR_METAFORMAT_UTF8, | ||
53 | "text/plain", | ||
54 | "UnreaL ][ / PM ", | ||
55 | strlen ("UnreaL ][ / PM ") + 1, | ||
56 | 0 | ||
57 | }, | ||
58 | { 0, 0, NULL, NULL, 0, -1 } | ||
59 | }; | ||
60 | struct ProblemSet ps[] = | ||
61 | { | 48 | { |
62 | { "testdata/s3m_2nd_pm.s3m", | 49 | EXTRACTOR_METATYPE_TITLE, |
63 | s3m_2ndpm_sol }, | 50 | EXTRACTOR_METAFORMAT_UTF8, |
64 | { NULL, NULL } | 51 | "text/plain", |
65 | }; | 52 | "UnreaL ][ / PM ", |
53 | strlen ("UnreaL ][ / PM ") + 1, | ||
54 | 0 | ||
55 | }, | ||
56 | { 0, 0, NULL, NULL, 0, -1 } | ||
57 | }; | ||
58 | struct ProblemSet ps[] = { | ||
59 | { "testdata/s3m_2nd_pm.s3m", | ||
60 | s3m_2ndpm_sol }, | ||
61 | { NULL, NULL } | ||
62 | }; | ||
66 | return ET_main ("s3m", ps); | 63 | return ET_main ("s3m", ps); |
67 | } | 64 | } |
68 | 65 | ||
66 | |||
69 | /* end of test_s3m.c */ | 67 | /* end of test_s3m.c */ |
diff --git a/src/plugins/test_sid.c b/src/plugins/test_sid.c index cab6c0a..0591626 100644 --- a/src/plugins/test_sid.c +++ b/src/plugins/test_sid.c | |||
@@ -36,89 +36,88 @@ | |||
36 | int | 36 | int |
37 | main (int argc, char *argv[]) | 37 | main (int argc, char *argv[]) |
38 | { | 38 | { |
39 | struct SolutionData sid_wizball_sol[] = | 39 | struct SolutionData sid_wizball_sol[] = { |
40 | { | 40 | { |
41 | { | 41 | EXTRACTOR_METATYPE_MIMETYPE, |
42 | EXTRACTOR_METATYPE_MIMETYPE, | 42 | EXTRACTOR_METAFORMAT_UTF8, |
43 | EXTRACTOR_METAFORMAT_UTF8, | 43 | "text/plain", |
44 | "text/plain", | 44 | "audio/prs.sid", |
45 | "audio/prs.sid", | 45 | strlen ("audio/prs.sid") + 1, |
46 | strlen ("audio/prs.sid") + 1, | 46 | 0 |
47 | 0 | 47 | }, |
48 | }, | ||
49 | { | ||
50 | EXTRACTOR_METATYPE_FORMAT_VERSION, | ||
51 | EXTRACTOR_METAFORMAT_UTF8, | ||
52 | "text/plain", | ||
53 | "2", | ||
54 | strlen ("2") + 1, | ||
55 | 0 | ||
56 | }, | ||
57 | { | ||
58 | EXTRACTOR_METATYPE_SONG_COUNT, | ||
59 | EXTRACTOR_METAFORMAT_UTF8, | ||
60 | "text/plain", | ||
61 | "9", | ||
62 | strlen ("9") + 1, | ||
63 | 0 | ||
64 | }, | ||
65 | { | ||
66 | EXTRACTOR_METATYPE_STARTING_SONG, | ||
67 | EXTRACTOR_METAFORMAT_UTF8, | ||
68 | "text/plain", | ||
69 | "4", | ||
70 | strlen ("4") + 1, | ||
71 | 0 | ||
72 | }, | ||
73 | { | ||
74 | EXTRACTOR_METATYPE_ALBUM, | ||
75 | EXTRACTOR_METAFORMAT_UTF8, | ||
76 | "text/plain", | ||
77 | "Wizball", | ||
78 | strlen ("Wizball") + 1, | ||
79 | 0 | ||
80 | }, | ||
81 | { | ||
82 | EXTRACTOR_METATYPE_ARTIST, | ||
83 | EXTRACTOR_METAFORMAT_UTF8, | ||
84 | "text/plain", | ||
85 | "Martin Galway", | ||
86 | strlen ("Martin Galway") + 1, | ||
87 | 0 | ||
88 | }, | ||
89 | { | ||
90 | EXTRACTOR_METATYPE_COPYRIGHT, | ||
91 | EXTRACTOR_METAFORMAT_UTF8, | ||
92 | "text/plain", | ||
93 | "1987 Ocean", | ||
94 | strlen ("1987 Ocean") + 1, | ||
95 | 0 | ||
96 | }, | ||
97 | { | ||
98 | EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM, | ||
99 | EXTRACTOR_METAFORMAT_UTF8, | ||
100 | "text/plain", | ||
101 | "PAL", | ||
102 | strlen ("PAL") + 1, | ||
103 | 0 | ||
104 | }, | ||
105 | { | ||
106 | EXTRACTOR_METATYPE_TARGET_ARCHITECTURE, | ||
107 | EXTRACTOR_METAFORMAT_UTF8, | ||
108 | "text/plain", | ||
109 | "MOS6581", | ||
110 | strlen ("MOS6581") + 1, | ||
111 | 0 | ||
112 | }, | ||
113 | { 0, 0, NULL, NULL, 0, -1 } | ||
114 | }; | ||
115 | struct ProblemSet ps[] = | ||
116 | { | 48 | { |
117 | { "testdata/sid_wizball.sid", | 49 | EXTRACTOR_METATYPE_FORMAT_VERSION, |
118 | sid_wizball_sol }, | 50 | EXTRACTOR_METAFORMAT_UTF8, |
119 | { NULL, NULL } | 51 | "text/plain", |
120 | }; | 52 | "2", |
53 | strlen ("2") + 1, | ||
54 | 0 | ||
55 | }, | ||
56 | { | ||
57 | EXTRACTOR_METATYPE_SONG_COUNT, | ||
58 | EXTRACTOR_METAFORMAT_UTF8, | ||
59 | "text/plain", | ||
60 | "9", | ||
61 | strlen ("9") + 1, | ||
62 | 0 | ||
63 | }, | ||
64 | { | ||
65 | EXTRACTOR_METATYPE_STARTING_SONG, | ||
66 | EXTRACTOR_METAFORMAT_UTF8, | ||
67 | "text/plain", | ||
68 | "4", | ||
69 | strlen ("4") + 1, | ||
70 | 0 | ||
71 | }, | ||
72 | { | ||
73 | EXTRACTOR_METATYPE_ALBUM, | ||
74 | EXTRACTOR_METAFORMAT_UTF8, | ||
75 | "text/plain", | ||
76 | "Wizball", | ||
77 | strlen ("Wizball") + 1, | ||
78 | 0 | ||
79 | }, | ||
80 | { | ||
81 | EXTRACTOR_METATYPE_ARTIST, | ||
82 | EXTRACTOR_METAFORMAT_UTF8, | ||
83 | "text/plain", | ||
84 | "Martin Galway", | ||
85 | strlen ("Martin Galway") + 1, | ||
86 | 0 | ||
87 | }, | ||
88 | { | ||
89 | EXTRACTOR_METATYPE_COPYRIGHT, | ||
90 | EXTRACTOR_METAFORMAT_UTF8, | ||
91 | "text/plain", | ||
92 | "1987 Ocean", | ||
93 | strlen ("1987 Ocean") + 1, | ||
94 | 0 | ||
95 | }, | ||
96 | { | ||
97 | EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM, | ||
98 | EXTRACTOR_METAFORMAT_UTF8, | ||
99 | "text/plain", | ||
100 | "PAL", | ||
101 | strlen ("PAL") + 1, | ||
102 | 0 | ||
103 | }, | ||
104 | { | ||
105 | EXTRACTOR_METATYPE_TARGET_ARCHITECTURE, | ||
106 | EXTRACTOR_METAFORMAT_UTF8, | ||
107 | "text/plain", | ||
108 | "MOS6581", | ||
109 | strlen ("MOS6581") + 1, | ||
110 | 0 | ||
111 | }, | ||
112 | { 0, 0, NULL, NULL, 0, -1 } | ||
113 | }; | ||
114 | struct ProblemSet ps[] = { | ||
115 | { "testdata/sid_wizball.sid", | ||
116 | sid_wizball_sol }, | ||
117 | { NULL, NULL } | ||
118 | }; | ||
121 | return ET_main ("sid", ps); | 119 | return ET_main ("sid", ps); |
122 | } | 120 | } |
123 | 121 | ||
122 | |||
124 | /* end of test_sid.c */ | 123 | /* end of test_sid.c */ |
diff --git a/src/plugins/test_thumbnailffmpeg.c b/src/plugins/test_thumbnailffmpeg.c index b7ad9c5..3efd69b 100644 --- a/src/plugins/test_thumbnailffmpeg.c +++ b/src/plugins/test_thumbnailffmpeg.c | |||
@@ -26,7 +26,6 @@ | |||
26 | #include "test_lib.h" | 26 | #include "test_lib.h" |
27 | 27 | ||
28 | 28 | ||
29 | |||
30 | /** | 29 | /** |
31 | * Main function for the THUMBNAILFFMPEG testcase. | 30 | * Main function for the THUMBNAILFFMPEG testcase. |
32 | * | 31 | * |
@@ -37,17 +36,16 @@ | |||
37 | int | 36 | int |
38 | main (int argc, char *argv[]) | 37 | main (int argc, char *argv[]) |
39 | { | 38 | { |
40 | struct SolutionData thumbnailffmpeg_video_sol[] = | 39 | struct SolutionData thumbnailffmpeg_video_sol[] = { |
41 | { | 40 | { 0, 0, NULL, NULL, 0, -1 } |
42 | { 0, 0, NULL, NULL, 0, -1 } | 41 | }; |
43 | }; | 42 | struct ProblemSet ps[] = { |
44 | struct ProblemSet ps[] = | 43 | { "testdata/thumbnailffmpeg_video.mov", |
45 | { | 44 | thumbnailffmpeg_video_sol }, |
46 | { "testdata/thumbnailffmpeg_video.mov", | 45 | { NULL, NULL } |
47 | thumbnailffmpeg_video_sol }, | 46 | }; |
48 | { NULL, NULL } | ||
49 | }; | ||
50 | return ET_main ("thumbnailffmpeg", ps); | 47 | return ET_main ("thumbnailffmpeg", ps); |
51 | } | 48 | } |
52 | 49 | ||
50 | |||
53 | /* end of test_thumbnailffmpeg.c */ | 51 | /* end of test_thumbnailffmpeg.c */ |
diff --git a/src/plugins/test_thumbnailgtk.c b/src/plugins/test_thumbnailgtk.c index 53edb19..4970af7 100644 --- a/src/plugins/test_thumbnailgtk.c +++ b/src/plugins/test_thumbnailgtk.c | |||
@@ -26,7 +26,6 @@ | |||
26 | #include "test_lib.h" | 26 | #include "test_lib.h" |
27 | 27 | ||
28 | 28 | ||
29 | |||
30 | /** | 29 | /** |
31 | * Main function for the THUMBNAILGTKJ testcase. | 30 | * Main function for the THUMBNAILGTKJ testcase. |
32 | * | 31 | * |
@@ -38,33 +37,32 @@ int | |||
38 | main (int argc, char *argv[]) | 37 | main (int argc, char *argv[]) |
39 | { | 38 | { |
40 | uint8_t thumbnail_data[] = { 137, 80, 78, 71 /* rest omitted */ }; | 39 | uint8_t thumbnail_data[] = { 137, 80, 78, 71 /* rest omitted */ }; |
41 | struct SolutionData thumbnail_torsten_sol[] = | 40 | struct SolutionData thumbnail_torsten_sol[] = { |
42 | { | 41 | { |
43 | { | 42 | EXTRACTOR_METATYPE_IMAGE_DIMENSIONS, |
44 | EXTRACTOR_METATYPE_IMAGE_DIMENSIONS, | 43 | EXTRACTOR_METAFORMAT_UTF8, |
45 | EXTRACTOR_METAFORMAT_UTF8, | 44 | "text/plain", |
46 | "text/plain", | 45 | "1600x1200", |
47 | "1600x1200", | 46 | strlen ("1600x1200") + 1, |
48 | strlen ("1600x1200") + 1, | 47 | 0 |
49 | 0 | 48 | }, |
50 | }, | ||
51 | { | ||
52 | EXTRACTOR_METATYPE_THUMBNAIL, | ||
53 | EXTRACTOR_METAFORMAT_BINARY, | ||
54 | "image/png", | ||
55 | (void *) thumbnail_data, | ||
56 | sizeof (thumbnail_data), | ||
57 | 0 | ||
58 | }, | ||
59 | { 0, 0, NULL, NULL, 0, -1 } | ||
60 | }; | ||
61 | struct ProblemSet ps[] = | ||
62 | { | 49 | { |
63 | { "testdata/thumbnail_torsten.jpg", | 50 | EXTRACTOR_METATYPE_THUMBNAIL, |
64 | thumbnail_torsten_sol }, | 51 | EXTRACTOR_METAFORMAT_BINARY, |
65 | { NULL, NULL } | 52 | "image/png", |
66 | }; | 53 | (void *) thumbnail_data, |
54 | sizeof (thumbnail_data), | ||
55 | 0 | ||
56 | }, | ||
57 | { 0, 0, NULL, NULL, 0, -1 } | ||
58 | }; | ||
59 | struct ProblemSet ps[] = { | ||
60 | { "testdata/thumbnail_torsten.jpg", | ||
61 | thumbnail_torsten_sol }, | ||
62 | { NULL, NULL } | ||
63 | }; | ||
67 | return ET_main ("thumbnailgtk", ps); | 64 | return ET_main ("thumbnailgtk", ps); |
68 | } | 65 | } |
69 | 66 | ||
67 | |||
70 | /* end of test_thumbnailgtk.c */ | 68 | /* end of test_thumbnailgtk.c */ |
diff --git a/src/plugins/test_tiff.c b/src/plugins/test_tiff.c index 1d0ae5f..6d20610 100644 --- a/src/plugins/test_tiff.c +++ b/src/plugins/test_tiff.c | |||
@@ -26,7 +26,6 @@ | |||
26 | #include "test_lib.h" | 26 | #include "test_lib.h" |
27 | 27 | ||
28 | 28 | ||
29 | |||
30 | /** | 29 | /** |
31 | * Main function for the TIFF testcase. | 30 | * Main function for the TIFF testcase. |
32 | * | 31 | * |
@@ -37,85 +36,84 @@ | |||
37 | int | 36 | int |
38 | main (int argc, char *argv[]) | 37 | main (int argc, char *argv[]) |
39 | { | 38 | { |
40 | struct SolutionData tiff_haute_sol[] = | 39 | struct SolutionData tiff_haute_sol[] = { |
40 | { | ||
41 | EXTRACTOR_METATYPE_MIMETYPE, | ||
42 | EXTRACTOR_METAFORMAT_UTF8, | ||
43 | "text/plain", | ||
44 | "image/tiff", | ||
45 | strlen ("image/tiff") + 1, | ||
46 | 0 | ||
47 | }, | ||
48 | { | ||
49 | EXTRACTOR_METATYPE_ARTIST, | ||
50 | EXTRACTOR_METAFORMAT_UTF8, | ||
51 | "text/plain", | ||
52 | "Anders Espersen", | ||
53 | strlen ("Anders Espersen") + 1, | ||
54 | 0 | ||
55 | }, | ||
56 | { | ||
57 | EXTRACTOR_METATYPE_CREATION_DATE, | ||
58 | EXTRACTOR_METAFORMAT_UTF8, | ||
59 | "text/plain", | ||
60 | "2012:05:15 10:51:47", | ||
61 | strlen ("2012:05:15 10:51:47") + 1, | ||
62 | 0 | ||
63 | }, | ||
41 | { | 64 | { |
42 | { | 65 | EXTRACTOR_METATYPE_COPYRIGHT, |
43 | EXTRACTOR_METATYPE_MIMETYPE, | 66 | EXTRACTOR_METAFORMAT_UTF8, |
44 | EXTRACTOR_METAFORMAT_UTF8, | 67 | "text/plain", |
45 | "text/plain", | 68 | "© Anders Espersen", |
46 | "image/tiff", | 69 | strlen ("© Anders Espersen") + 1, |
47 | strlen ("image/tiff") + 1, | 70 | 0 |
48 | 0 | 71 | }, |
49 | }, | ||
50 | { | ||
51 | EXTRACTOR_METATYPE_ARTIST, | ||
52 | EXTRACTOR_METAFORMAT_UTF8, | ||
53 | "text/plain", | ||
54 | "Anders Espersen", | ||
55 | strlen ("Anders Espersen") + 1, | ||
56 | 0 | ||
57 | }, | ||
58 | { | ||
59 | EXTRACTOR_METATYPE_CREATION_DATE, | ||
60 | EXTRACTOR_METAFORMAT_UTF8, | ||
61 | "text/plain", | ||
62 | "2012:05:15 10:51:47", | ||
63 | strlen ("2012:05:15 10:51:47") + 1, | ||
64 | 0 | ||
65 | }, | ||
66 | { | ||
67 | EXTRACTOR_METATYPE_COPYRIGHT, | ||
68 | EXTRACTOR_METAFORMAT_UTF8, | ||
69 | "text/plain", | ||
70 | "© Anders Espersen", | ||
71 | strlen ("© Anders Espersen") + 1, | ||
72 | 0 | ||
73 | }, | ||
74 | { | ||
75 | EXTRACTOR_METATYPE_CAMERA_MAKE, | ||
76 | EXTRACTOR_METAFORMAT_UTF8, | ||
77 | "text/plain", | ||
78 | "Hasselblad", | ||
79 | strlen ("Hasselblad") + 1, | ||
80 | 0 | ||
81 | }, | ||
82 | { | ||
83 | EXTRACTOR_METATYPE_CAMERA_MODEL, | ||
84 | EXTRACTOR_METAFORMAT_UTF8, | ||
85 | "text/plain", | ||
86 | "Hasselblad H4D-31", | ||
87 | strlen ("Hasselblad H4D-31") + 1, | ||
88 | 0 | ||
89 | }, | ||
90 | { | ||
91 | EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE, | ||
92 | EXTRACTOR_METAFORMAT_UTF8, | ||
93 | "text/plain", | ||
94 | "Adobe Photoshop CS5 Macintosh", | ||
95 | strlen ("Adobe Photoshop CS5 Macintosh") + 1, | ||
96 | 0 | ||
97 | }, | ||
98 | { | ||
99 | EXTRACTOR_METATYPE_IMAGE_DIMENSIONS, | ||
100 | EXTRACTOR_METAFORMAT_UTF8, | ||
101 | "text/plain", | ||
102 | "4872x6496", | ||
103 | strlen ("4872x6496") + 1, | ||
104 | 0 | ||
105 | }, | ||
106 | { 0, 0, NULL, NULL, 0, -1 } | ||
107 | }; | ||
108 | struct ProblemSet ps[] = | ||
109 | { | 72 | { |
110 | /* note that the original test image was almost | 73 | EXTRACTOR_METATYPE_CAMERA_MAKE, |
111 | 100 MB large; so for SVN it was cut down to | 74 | EXTRACTOR_METAFORMAT_UTF8, |
112 | only contain the first 64 KB, which still parse | 75 | "text/plain", |
113 | fine and give use the meta data */ | 76 | "Hasselblad", |
114 | { "testdata/tiff_haute.tiff", | 77 | strlen ("Hasselblad") + 1, |
115 | tiff_haute_sol }, | 78 | 0 |
116 | { NULL, NULL } | 79 | }, |
117 | }; | 80 | { |
81 | EXTRACTOR_METATYPE_CAMERA_MODEL, | ||
82 | EXTRACTOR_METAFORMAT_UTF8, | ||
83 | "text/plain", | ||
84 | "Hasselblad H4D-31", | ||
85 | strlen ("Hasselblad H4D-31") + 1, | ||
86 | 0 | ||
87 | }, | ||
88 | { | ||
89 | EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE, | ||
90 | EXTRACTOR_METAFORMAT_UTF8, | ||
91 | "text/plain", | ||
92 | "Adobe Photoshop CS5 Macintosh", | ||
93 | strlen ("Adobe Photoshop CS5 Macintosh") + 1, | ||
94 | 0 | ||
95 | }, | ||
96 | { | ||
97 | EXTRACTOR_METATYPE_IMAGE_DIMENSIONS, | ||
98 | EXTRACTOR_METAFORMAT_UTF8, | ||
99 | "text/plain", | ||
100 | "4872x6496", | ||
101 | strlen ("4872x6496") + 1, | ||
102 | 0 | ||
103 | }, | ||
104 | { 0, 0, NULL, NULL, 0, -1 } | ||
105 | }; | ||
106 | struct ProblemSet ps[] = { | ||
107 | /* note that the original test image was almost | ||
108 | 100 MB large; so for SVN it was cut down to | ||
109 | only contain the first 64 KB, which still parse | ||
110 | fine and give use the meta data */ | ||
111 | { "testdata/tiff_haute.tiff", | ||
112 | tiff_haute_sol }, | ||
113 | { NULL, NULL } | ||
114 | }; | ||
118 | return ET_main ("tiff", ps); | 115 | return ET_main ("tiff", ps); |
119 | } | 116 | } |
120 | 117 | ||
118 | |||
121 | /* end of test_tiff.c */ | 119 | /* end of test_tiff.c */ |
diff --git a/src/plugins/test_wav.c b/src/plugins/test_wav.c index dc4f6fe..3325386 100644 --- a/src/plugins/test_wav.c +++ b/src/plugins/test_wav.c | |||
@@ -26,7 +26,6 @@ | |||
26 | #include "test_lib.h" | 26 | #include "test_lib.h" |
27 | 27 | ||
28 | 28 | ||
29 | |||
30 | /** | 29 | /** |
31 | * Main function for the WAV testcase. | 30 | * Main function for the WAV testcase. |
32 | * | 31 | * |
@@ -37,55 +36,53 @@ | |||
37 | int | 36 | int |
38 | main (int argc, char *argv[]) | 37 | main (int argc, char *argv[]) |
39 | { | 38 | { |
40 | struct SolutionData wav_noise_sol[] = | 39 | struct SolutionData wav_noise_sol[] = { |
40 | { | ||
41 | EXTRACTOR_METATYPE_MIMETYPE, | ||
42 | EXTRACTOR_METAFORMAT_UTF8, | ||
43 | "text/plain", | ||
44 | "audio/x-wav", | ||
45 | strlen ("audio/x-wav") + 1, | ||
46 | 0 | ||
47 | }, | ||
41 | { | 48 | { |
42 | { | 49 | EXTRACTOR_METATYPE_RESOURCE_TYPE, |
43 | EXTRACTOR_METATYPE_MIMETYPE, | 50 | EXTRACTOR_METAFORMAT_UTF8, |
44 | EXTRACTOR_METAFORMAT_UTF8, | 51 | "text/plain", |
45 | "text/plain", | 52 | "1000 ms, 48000 Hz, mono", |
46 | "audio/x-wav", | 53 | strlen ("1000 ms, 48000 Hz, mono") + 1, |
47 | strlen ("audio/x-wav") + 1, | 54 | 0 |
48 | 0 | 55 | }, |
49 | }, | 56 | { 0, 0, NULL, NULL, 0, -1 } |
50 | { | 57 | }; |
51 | EXTRACTOR_METATYPE_RESOURCE_TYPE, | 58 | struct SolutionData wav_alert_sol[] = { |
52 | EXTRACTOR_METAFORMAT_UTF8, | ||
53 | "text/plain", | ||
54 | "1000 ms, 48000 Hz, mono", | ||
55 | strlen ("1000 ms, 48000 Hz, mono") + 1, | ||
56 | 0 | ||
57 | }, | ||
58 | { 0, 0, NULL, NULL, 0, -1 } | ||
59 | }; | ||
60 | struct SolutionData wav_alert_sol[] = | ||
61 | { | 59 | { |
62 | { | 60 | EXTRACTOR_METATYPE_MIMETYPE, |
63 | EXTRACTOR_METATYPE_MIMETYPE, | 61 | EXTRACTOR_METAFORMAT_UTF8, |
64 | EXTRACTOR_METAFORMAT_UTF8, | 62 | "text/plain", |
65 | "text/plain", | 63 | "audio/x-wav", |
66 | "audio/x-wav", | 64 | strlen ("audio/x-wav") + 1, |
67 | strlen ("audio/x-wav") + 1, | 65 | 0 |
68 | 0 | 66 | }, |
69 | }, | ||
70 | { | ||
71 | EXTRACTOR_METATYPE_RESOURCE_TYPE, | ||
72 | EXTRACTOR_METAFORMAT_UTF8, | ||
73 | "text/plain", | ||
74 | "525 ms, 22050 Hz, mono", | ||
75 | strlen ("525 ms, 22050 Hz, mono") + 1, | ||
76 | 0 | ||
77 | }, | ||
78 | { 0, 0, NULL, NULL, 0, -1 } | ||
79 | }; | ||
80 | struct ProblemSet ps[] = | ||
81 | { | 67 | { |
82 | { "testdata/wav_noise.wav", | 68 | EXTRACTOR_METATYPE_RESOURCE_TYPE, |
83 | wav_noise_sol }, | 69 | EXTRACTOR_METAFORMAT_UTF8, |
84 | { "testdata/wav_alert.wav", | 70 | "text/plain", |
85 | wav_alert_sol }, | 71 | "525 ms, 22050 Hz, mono", |
86 | { NULL, NULL } | 72 | strlen ("525 ms, 22050 Hz, mono") + 1, |
87 | }; | 73 | 0 |
74 | }, | ||
75 | { 0, 0, NULL, NULL, 0, -1 } | ||
76 | }; | ||
77 | struct ProblemSet ps[] = { | ||
78 | { "testdata/wav_noise.wav", | ||
79 | wav_noise_sol }, | ||
80 | { "testdata/wav_alert.wav", | ||
81 | wav_alert_sol }, | ||
82 | { NULL, NULL } | ||
83 | }; | ||
88 | return ET_main ("wav", ps); | 84 | return ET_main ("wav", ps); |
89 | } | 85 | } |
90 | 86 | ||
87 | |||
91 | /* end of test_wav.c */ | 88 | /* end of test_wav.c */ |
diff --git a/src/plugins/test_xm.c b/src/plugins/test_xm.c index c4a6c27..776bb20 100644 --- a/src/plugins/test_xm.c +++ b/src/plugins/test_xm.c | |||
@@ -26,7 +26,6 @@ | |||
26 | #include "test_lib.h" | 26 | #include "test_lib.h" |
27 | 27 | ||
28 | 28 | ||
29 | |||
30 | /** | 29 | /** |
31 | * Main function for the XM testcase. | 30 | * Main function for the XM testcase. |
32 | * | 31 | * |
@@ -37,49 +36,48 @@ | |||
37 | int | 36 | int |
38 | main (int argc, char *argv[]) | 37 | main (int argc, char *argv[]) |
39 | { | 38 | { |
40 | struct SolutionData xm_diesel_sol[] = | 39 | struct SolutionData xm_diesel_sol[] = { |
40 | { | ||
41 | EXTRACTOR_METATYPE_MIMETYPE, | ||
42 | EXTRACTOR_METAFORMAT_UTF8, | ||
43 | "text/plain", | ||
44 | "audio/x-xm", | ||
45 | strlen ("audio/x-xm") + 1, | ||
46 | 0 | ||
47 | }, | ||
41 | { | 48 | { |
42 | { | 49 | EXTRACTOR_METATYPE_FORMAT_VERSION, |
43 | EXTRACTOR_METATYPE_MIMETYPE, | 50 | EXTRACTOR_METAFORMAT_UTF8, |
44 | EXTRACTOR_METAFORMAT_UTF8, | 51 | "text/plain", |
45 | "text/plain", | 52 | "1.4", |
46 | "audio/x-xm", | 53 | strlen ("1.4") + 1, |
47 | strlen ("audio/x-xm") + 1, | 54 | 0 |
48 | 0 | 55 | }, |
49 | }, | ||
50 | { | ||
51 | EXTRACTOR_METATYPE_FORMAT_VERSION, | ||
52 | EXTRACTOR_METAFORMAT_UTF8, | ||
53 | "text/plain", | ||
54 | "1.4", | ||
55 | strlen ("1.4") + 1, | ||
56 | 0 | ||
57 | }, | ||
58 | { | ||
59 | EXTRACTOR_METATYPE_TITLE, | ||
60 | EXTRACTOR_METAFORMAT_UTF8, | ||
61 | "text/plain", | ||
62 | "diesel", | ||
63 | strlen ("diesel") + 1, | ||
64 | 0 | ||
65 | }, | ||
66 | { | ||
67 | EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE, | ||
68 | EXTRACTOR_METAFORMAT_UTF8, | ||
69 | "text/plain", | ||
70 | "FastTracker v2.00", | ||
71 | strlen ("FastTracker v2.00") + 1, | ||
72 | 0 | ||
73 | }, | ||
74 | { 0, 0, NULL, NULL, 0, -1 } | ||
75 | }; | ||
76 | struct ProblemSet ps[] = | ||
77 | { | 56 | { |
78 | { "testdata/xm_diesel.xm", | 57 | EXTRACTOR_METATYPE_TITLE, |
79 | xm_diesel_sol }, | 58 | EXTRACTOR_METAFORMAT_UTF8, |
80 | { NULL, NULL } | 59 | "text/plain", |
81 | }; | 60 | "diesel", |
61 | strlen ("diesel") + 1, | ||
62 | 0 | ||
63 | }, | ||
64 | { | ||
65 | EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE, | ||
66 | EXTRACTOR_METAFORMAT_UTF8, | ||
67 | "text/plain", | ||
68 | "FastTracker v2.00", | ||
69 | strlen ("FastTracker v2.00") + 1, | ||
70 | 0 | ||
71 | }, | ||
72 | { 0, 0, NULL, NULL, 0, -1 } | ||
73 | }; | ||
74 | struct ProblemSet ps[] = { | ||
75 | { "testdata/xm_diesel.xm", | ||
76 | xm_diesel_sol }, | ||
77 | { NULL, NULL } | ||
78 | }; | ||
82 | return ET_main ("xm", ps); | 79 | return ET_main ("xm", ps); |
83 | } | 80 | } |
84 | 81 | ||
82 | |||
85 | /* end of test_xm.c */ | 83 | /* end of test_xm.c */ |
diff --git a/src/plugins/test_zip.c b/src/plugins/test_zip.c index 92e94c9..1ef52d9 100644 --- a/src/plugins/test_zip.c +++ b/src/plugins/test_zip.c | |||
@@ -36,73 +36,72 @@ | |||
36 | int | 36 | int |
37 | main (int argc, char *argv[]) | 37 | main (int argc, char *argv[]) |
38 | { | 38 | { |
39 | struct SolutionData zip_test_sol[] = | 39 | struct SolutionData zip_test_sol[] = { |
40 | { | 40 | { |
41 | { | 41 | EXTRACTOR_METATYPE_MIMETYPE, |
42 | EXTRACTOR_METATYPE_MIMETYPE, | 42 | EXTRACTOR_METAFORMAT_UTF8, |
43 | EXTRACTOR_METAFORMAT_UTF8, | 43 | "text/plain", |
44 | "text/plain", | 44 | "application/zip", |
45 | "application/zip", | 45 | strlen ("application/zip") + 1, |
46 | strlen ("application/zip") + 1, | 46 | 0 |
47 | 0 | 47 | }, |
48 | }, | ||
49 | { | ||
50 | EXTRACTOR_METATYPE_COMMENT, | ||
51 | EXTRACTOR_METAFORMAT_C_STRING, | ||
52 | "text/plain", | ||
53 | "global zipfile comment", | ||
54 | strlen ("global zipfile comment") + 1, | ||
55 | 0 | ||
56 | }, | ||
57 | { | ||
58 | EXTRACTOR_METATYPE_FILENAME, | ||
59 | EXTRACTOR_METAFORMAT_C_STRING, | ||
60 | "text/plain", | ||
61 | "ChangeLog", | ||
62 | strlen ("ChangeLog") + 1, | ||
63 | 0 | ||
64 | }, | ||
65 | { | ||
66 | EXTRACTOR_METATYPE_FILENAME, | ||
67 | EXTRACTOR_METAFORMAT_C_STRING, | ||
68 | "text/plain", | ||
69 | "test.png", | ||
70 | strlen ("test.png") + 1, | ||
71 | 0 | ||
72 | }, | ||
73 | { | ||
74 | EXTRACTOR_METATYPE_COMMENT, | ||
75 | EXTRACTOR_METAFORMAT_C_STRING, | ||
76 | "text/plain", | ||
77 | "comment for test.png", | ||
78 | strlen ("comment for test.png") + 1, | ||
79 | 0 | ||
80 | }, | ||
81 | { | ||
82 | EXTRACTOR_METATYPE_FILENAME, | ||
83 | EXTRACTOR_METAFORMAT_C_STRING, | ||
84 | "text/plain", | ||
85 | "test.jpg", | ||
86 | strlen ("test.jpg") + 1, | ||
87 | 0 | ||
88 | }, | ||
89 | { | ||
90 | EXTRACTOR_METATYPE_COMMENT, | ||
91 | EXTRACTOR_METAFORMAT_C_STRING, | ||
92 | "text/plain", | ||
93 | "comment for test.jpg", | ||
94 | strlen ("comment for test.jpg") + 1, | ||
95 | 0 | ||
96 | }, | ||
97 | { 0, 0, NULL, NULL, 0, -1 } | ||
98 | }; | ||
99 | struct ProblemSet ps[] = | ||
100 | { | 48 | { |
101 | { "testdata/zip_test.zip", | 49 | EXTRACTOR_METATYPE_COMMENT, |
102 | zip_test_sol }, | 50 | EXTRACTOR_METAFORMAT_C_STRING, |
103 | { NULL, NULL } | 51 | "text/plain", |
104 | }; | 52 | "global zipfile comment", |
53 | strlen ("global zipfile comment") + 1, | ||
54 | 0 | ||
55 | }, | ||
56 | { | ||
57 | EXTRACTOR_METATYPE_FILENAME, | ||
58 | EXTRACTOR_METAFORMAT_C_STRING, | ||
59 | "text/plain", | ||
60 | "ChangeLog", | ||
61 | strlen ("ChangeLog") + 1, | ||
62 | 0 | ||
63 | }, | ||
64 | { | ||
65 | EXTRACTOR_METATYPE_FILENAME, | ||
66 | EXTRACTOR_METAFORMAT_C_STRING, | ||
67 | "text/plain", | ||
68 | "test.png", | ||
69 | strlen ("test.png") + 1, | ||
70 | 0 | ||
71 | }, | ||
72 | { | ||
73 | EXTRACTOR_METATYPE_COMMENT, | ||
74 | EXTRACTOR_METAFORMAT_C_STRING, | ||
75 | "text/plain", | ||
76 | "comment for test.png", | ||
77 | strlen ("comment for test.png") + 1, | ||
78 | 0 | ||
79 | }, | ||
80 | { | ||
81 | EXTRACTOR_METATYPE_FILENAME, | ||
82 | EXTRACTOR_METAFORMAT_C_STRING, | ||
83 | "text/plain", | ||
84 | "test.jpg", | ||
85 | strlen ("test.jpg") + 1, | ||
86 | 0 | ||
87 | }, | ||
88 | { | ||
89 | EXTRACTOR_METATYPE_COMMENT, | ||
90 | EXTRACTOR_METAFORMAT_C_STRING, | ||
91 | "text/plain", | ||
92 | "comment for test.jpg", | ||
93 | strlen ("comment for test.jpg") + 1, | ||
94 | 0 | ||
95 | }, | ||
96 | { 0, 0, NULL, NULL, 0, -1 } | ||
97 | }; | ||
98 | struct ProblemSet ps[] = { | ||
99 | { "testdata/zip_test.zip", | ||
100 | zip_test_sol }, | ||
101 | { NULL, NULL } | ||
102 | }; | ||
105 | return ET_main ("zip", ps); | 103 | return ET_main ("zip", ps); |
106 | } | 104 | } |
107 | 105 | ||
106 | |||
108 | /* end of test_zip.c */ | 107 | /* end of test_zip.c */ |
diff --git a/src/plugins/thumbnailffmpeg_extractor.c b/src/plugins/thumbnailffmpeg_extractor.c index 72af79f..72f0137 100644 --- a/src/plugins/thumbnailffmpeg_extractor.c +++ b/src/plugins/thumbnailffmpeg_extractor.c | |||
@@ -97,7 +97,7 @@ | |||
97 | /** | 97 | /** |
98 | * Maximum size in bytes for the thumbnail. | 98 | * Maximum size in bytes for the thumbnail. |
99 | */ | 99 | */ |
100 | #define MAX_THUMB_BYTES (100*1024) | 100 | #define MAX_THUMB_BYTES (100 * 1024) |
101 | 101 | ||
102 | /** | 102 | /** |
103 | * Number of bytes to feed to libav in one go. | 103 | * Number of bytes to feed to libav in one go. |
@@ -135,8 +135,8 @@ static magic_t magic; | |||
135 | */ | 135 | */ |
136 | static int | 136 | static int |
137 | read_cb (void *opaque, | 137 | read_cb (void *opaque, |
138 | uint8_t *buf, | 138 | uint8_t *buf, |
139 | int buf_size) | 139 | int buf_size) |
140 | { | 140 | { |
141 | struct EXTRACTOR_ExtractContext *ec = opaque; | 141 | struct EXTRACTOR_ExtractContext *ec = opaque; |
142 | void *data; | 142 | void *data; |
@@ -160,8 +160,8 @@ read_cb (void *opaque, | |||
160 | */ | 160 | */ |
161 | static int64_t | 161 | static int64_t |
162 | seek_cb (void *opaque, | 162 | seek_cb (void *opaque, |
163 | int64_t offset, | 163 | int64_t offset, |
164 | int whence) | 164 | int whence) |
165 | { | 165 | { |
166 | struct EXTRACTOR_ExtractContext *ec = opaque; | 166 | struct EXTRACTOR_ExtractContext *ec = opaque; |
167 | 167 | ||
@@ -187,12 +187,12 @@ seek_cb (void *opaque, | |||
187 | */ | 187 | */ |
188 | static size_t | 188 | static size_t |
189 | create_thumbnail (AVCodecContext *pCodecCtx, int src_width, int src_height, | 189 | create_thumbnail (AVCodecContext *pCodecCtx, int src_width, int src_height, |
190 | int src_stride[], | 190 | int src_stride[], |
191 | enum AVPixelFormat src_pixfmt, | 191 | enum AVPixelFormat src_pixfmt, |
192 | const uint8_t * const src_data[], | 192 | const uint8_t *const src_data[], |
193 | int dst_width, int dst_height, | 193 | int dst_width, int dst_height, |
194 | uint8_t **output_data, | 194 | uint8_t **output_data, |
195 | size_t output_max_size) | 195 | size_t output_max_size) |
196 | { | 196 | { |
197 | AVCodecContext *encoder_codec_ctx; | 197 | AVCodecContext *encoder_codec_ctx; |
198 | AVDictionary *opts; | 198 | AVDictionary *opts; |
@@ -205,73 +205,73 @@ create_thumbnail (AVCodecContext *pCodecCtx, int src_width, int src_height, | |||
205 | int err; | 205 | int err; |
206 | 206 | ||
207 | AVPacket pkt; | 207 | AVPacket pkt; |
208 | av_init_packet(&pkt); | 208 | av_init_packet (&pkt); |
209 | pkt.data = NULL; | 209 | pkt.data = NULL; |
210 | pkt.size = 0; | 210 | pkt.size = 0; |
211 | int gotPacket; | 211 | int gotPacket; |
212 | #if USE_JPEG | 212 | #if USE_JPEG |
213 | #if LIBAVCODEC_BUILD >= AV_VERSION_INT(54,25,0) | 213 | #if LIBAVCODEC_BUILD >= AV_VERSION_INT (54,25,0) |
214 | if (NULL == (encoder_codec = avcodec_find_encoder ( AV_CODEC_ID_MJPEG ))) | 214 | if (NULL == (encoder_codec = avcodec_find_encoder (AV_CODEC_ID_MJPEG))) |
215 | #else | 215 | #else |
216 | if (NULL == (encoder_codec = avcodec_find_encoder ( CODEC_ID_MJPEG ))) | 216 | if (NULL == (encoder_codec = avcodec_find_encoder (CODEC_ID_MJPEG))) |
217 | #endif | 217 | #endif |
218 | #else | 218 | #else |
219 | if (NULL == (encoder_codec = avcodec_find_encoder_by_name ("png"))) | 219 | if (NULL == (encoder_codec = avcodec_find_encoder_by_name ("png"))) |
220 | #endif | 220 | #endif |
221 | { | 221 | { |
222 | #if DEBUG | 222 | #if DEBUG |
223 | fprintf (stderr, | 223 | fprintf (stderr, |
224 | "Couldn't find a encoder\n"); | 224 | "Couldn't find a encoder\n"); |
225 | #endif | 225 | #endif |
226 | return 0; | 226 | return 0; |
227 | } | 227 | } |
228 | 228 | ||
229 | /* NOTE: the scaler will be used even if the src and dst image dimensions | 229 | /* NOTE: the scaler will be used even if the src and dst image dimensions |
230 | * match, because the scaler will also perform colour space conversion */ | 230 | * match, because the scaler will also perform colour space conversion */ |
231 | if (NULL == | 231 | if (NULL == |
232 | (scaler_ctx = | 232 | (scaler_ctx = |
233 | sws_getContext (src_width, src_height, src_pixfmt, | 233 | sws_getContext (src_width, src_height, src_pixfmt, |
234 | dst_width, dst_height, | 234 | dst_width, dst_height, |
235 | PIX_OUTPUT_FORMAT, | 235 | PIX_OUTPUT_FORMAT, |
236 | SWS_BILINEAR, NULL, NULL, NULL))) | 236 | SWS_BILINEAR, NULL, NULL, NULL))) |
237 | { | 237 | { |
238 | #if DEBUG | 238 | #if DEBUG |
239 | fprintf (stderr, | 239 | fprintf (stderr, |
240 | "Failed to get a scaler context\n"); | 240 | "Failed to get a scaler context\n"); |
241 | #endif | 241 | #endif |
242 | return 0; | 242 | return 0; |
243 | } | 243 | } |
244 | 244 | ||
245 | #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1) | 245 | #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1) |
246 | dst_frame = av_frame_alloc (); | 246 | dst_frame = av_frame_alloc (); |
247 | #else | 247 | #else |
248 | dst_frame = avcodec_alloc_frame(); | 248 | dst_frame = avcodec_alloc_frame (); |
249 | #endif | 249 | #endif |
250 | if (NULL == dst_frame) | 250 | if (NULL == dst_frame) |
251 | { | 251 | { |
252 | #if DEBUG | 252 | #if DEBUG |
253 | fprintf (stderr, | 253 | fprintf (stderr, |
254 | "Failed to allocate the destination image frame\n"); | 254 | "Failed to allocate the destination image frame\n"); |
255 | #endif | 255 | #endif |
256 | sws_freeContext (scaler_ctx); | 256 | sws_freeContext (scaler_ctx); |
257 | return 0; | 257 | return 0; |
258 | } | 258 | } |
259 | if (NULL == (dst_buffer = | 259 | if (NULL == (dst_buffer = |
260 | av_malloc (avpicture_get_size (PIX_OUTPUT_FORMAT, | 260 | av_malloc (avpicture_get_size (PIX_OUTPUT_FORMAT, |
261 | dst_width, dst_height)))) | 261 | dst_width, dst_height)))) |
262 | { | 262 | { |
263 | #if DEBUG | 263 | #if DEBUG |
264 | fprintf (stderr, | 264 | fprintf (stderr, |
265 | "Failed to allocate the destination image buffer\n"); | 265 | "Failed to allocate the destination image buffer\n"); |
266 | #endif | 266 | #endif |
267 | #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1) | 267 | #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1) |
268 | av_frame_free (&dst_frame); | 268 | av_frame_free (&dst_frame); |
269 | #else | 269 | #else |
270 | avcodec_free_frame (&dst_frame); | 270 | avcodec_free_frame (&dst_frame); |
271 | #endif | 271 | #endif |
272 | sws_freeContext (scaler_ctx); | 272 | sws_freeContext (scaler_ctx); |
273 | return 0; | 273 | return 0; |
274 | } | 274 | } |
275 | avpicture_fill ((AVPicture *) dst_frame, dst_buffer, | 275 | avpicture_fill ((AVPicture *) dst_frame, dst_buffer, |
276 | PIX_OUTPUT_FORMAT, | 276 | PIX_OUTPUT_FORMAT, |
277 | dst_width, dst_height); | 277 | dst_width, dst_height); |
@@ -284,47 +284,47 @@ create_thumbnail (AVCodecContext *pCodecCtx, int src_width, int src_height, | |||
284 | 284 | ||
285 | encoder_output_buffer_size = output_max_size; | 285 | encoder_output_buffer_size = output_max_size; |
286 | if (NULL == (encoder_output_buffer = av_malloc (encoder_output_buffer_size))) | 286 | if (NULL == (encoder_output_buffer = av_malloc (encoder_output_buffer_size))) |
287 | { | 287 | { |
288 | #if DEBUG | 288 | #if DEBUG |
289 | fprintf (stderr, | 289 | fprintf (stderr, |
290 | "Failed to allocate the encoder output buffer\n"); | 290 | "Failed to allocate the encoder output buffer\n"); |
291 | #endif | 291 | #endif |
292 | av_free (dst_buffer); | 292 | av_free (dst_buffer); |
293 | #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1) | 293 | #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1) |
294 | av_frame_free (&dst_frame); | 294 | av_frame_free (&dst_frame); |
295 | #else | 295 | #else |
296 | avcodec_free_frame (&dst_frame); | 296 | avcodec_free_frame (&dst_frame); |
297 | #endif | 297 | #endif |
298 | sws_freeContext (scaler_ctx); | 298 | sws_freeContext (scaler_ctx); |
299 | return 0; | 299 | return 0; |
300 | } | 300 | } |
301 | 301 | ||
302 | if (NULL == (encoder_codec_ctx = avcodec_alloc_context3 (encoder_codec))) | 302 | if (NULL == (encoder_codec_ctx = avcodec_alloc_context3 (encoder_codec))) |
303 | { | 303 | { |
304 | #if DEBUG | 304 | #if DEBUG |
305 | fprintf (stderr, | 305 | fprintf (stderr, |
306 | "Failed to allocate the encoder codec context\n"); | 306 | "Failed to allocate the encoder codec context\n"); |
307 | #endif | 307 | #endif |
308 | av_free (encoder_output_buffer); | 308 | av_free (encoder_output_buffer); |
309 | av_free (dst_buffer); | 309 | av_free (dst_buffer); |
310 | #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1) | 310 | #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1) |
311 | av_frame_free (&dst_frame); | 311 | av_frame_free (&dst_frame); |
312 | #else | 312 | #else |
313 | avcodec_free_frame (&dst_frame); | 313 | avcodec_free_frame (&dst_frame); |
314 | #endif | 314 | #endif |
315 | sws_freeContext (scaler_ctx); | 315 | sws_freeContext (scaler_ctx); |
316 | return 0; | 316 | return 0; |
317 | } | 317 | } |
318 | encoder_codec_ctx->width = dst_width; | 318 | encoder_codec_ctx->width = dst_width; |
319 | encoder_codec_ctx->height = dst_height; | 319 | encoder_codec_ctx->height = dst_height; |
320 | #if USE_JPEG | 320 | #if USE_JPEG |
321 | encoder_codec_ctx->bit_rate = pCodecCtx->bit_rate; | 321 | encoder_codec_ctx->bit_rate = pCodecCtx->bit_rate; |
322 | #if LIBAVCODEC_BUILD >= AV_VERSION_INT(54,25,0) | 322 | #if LIBAVCODEC_BUILD >= AV_VERSION_INT (54,25,0) |
323 | encoder_codec_ctx->codec_id = AV_CODEC_ID_MJPEG; | 323 | encoder_codec_ctx->codec_id = AV_CODEC_ID_MJPEG; |
324 | #else | 324 | #else |
325 | encoder_codec_ctx->codec_id = CODEC_ID_MJPEG; | 325 | encoder_codec_ctx->codec_id = CODEC_ID_MJPEG; |
326 | #endif | 326 | #endif |
327 | #if LIBAVCODEC_BUILD >= AV_VERSION_INT(53,35,0) | 327 | #if LIBAVCODEC_BUILD >= AV_VERSION_INT (53,35,0) |
328 | encoder_codec_ctx->codec_type = AVMEDIA_TYPE_VIDEO; | 328 | encoder_codec_ctx->codec_type = AVMEDIA_TYPE_VIDEO; |
329 | #else | 329 | #else |
330 | encoder_codec_ctx->codec_type = CODEC_TYPE_VIDEO; | 330 | encoder_codec_ctx->codec_type = CODEC_TYPE_VIDEO; |
@@ -338,51 +338,52 @@ create_thumbnail (AVCodecContext *pCodecCtx, int src_width, int src_height, | |||
338 | 338 | ||
339 | opts = NULL; | 339 | opts = NULL; |
340 | if (avcodec_open2 (encoder_codec_ctx, encoder_codec, &opts) < 0) | 340 | if (avcodec_open2 (encoder_codec_ctx, encoder_codec, &opts) < 0) |
341 | { | 341 | { |
342 | #if DEBUG | 342 | #if DEBUG |
343 | fprintf (stderr, | 343 | fprintf (stderr, |
344 | "Failed to open the encoder\n"); | 344 | "Failed to open the encoder\n"); |
345 | #endif | 345 | #endif |
346 | avcodec_free_context (&encoder_codec_ctx); | 346 | avcodec_free_context (&encoder_codec_ctx); |
347 | av_free (encoder_output_buffer); | 347 | av_free (encoder_output_buffer); |
348 | av_free (dst_buffer); | 348 | av_free (dst_buffer); |
349 | #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1) | 349 | #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1) |
350 | av_frame_free (&dst_frame); | 350 | av_frame_free (&dst_frame); |
351 | #else | 351 | #else |
352 | avcodec_free_frame (&dst_frame); | 352 | avcodec_free_frame (&dst_frame); |
353 | #endif | 353 | #endif |
354 | sws_freeContext (scaler_ctx); | 354 | sws_freeContext (scaler_ctx); |
355 | return 0; | 355 | return 0; |
356 | } | 356 | } |
357 | |||
358 | 357 | ||
359 | 358 | ||
360 | #ifdef USE_JPEG | 359 | #ifdef USE_JPEG |
361 | #if FF_API_MPV_OPT | 360 | #if FF_API_MPV_OPT |
362 | encoder_codec_ctx->mb_lmin = encoder_codec_ctx->lmin = encoder_codec_ctx->qmin * FF_QP2LAMBDA; | 361 | encoder_codec_ctx->mb_lmin = encoder_codec_ctx->lmin = |
363 | encoder_codec_ctx->mb_lmax = encoder_codec_ctx->lmax = encoder_codec_ctx->qmax * FF_QP2LAMBDA; | 362 | encoder_codec_ctx->qmin * FF_QP2LAMBDA; |
363 | encoder_codec_ctx->mb_lmax = encoder_codec_ctx->lmax = | ||
364 | encoder_codec_ctx->qmax * FF_QP2LAMBDA; | ||
364 | #else | 365 | #else |
365 | encoder_codec_ctx->mb_lmin = encoder_codec_ctx->qmin * FF_QP2LAMBDA; | 366 | encoder_codec_ctx->mb_lmin = encoder_codec_ctx->qmin * FF_QP2LAMBDA; |
366 | encoder_codec_ctx->mb_lmax = encoder_codec_ctx->qmax * FF_QP2LAMBDA; | 367 | encoder_codec_ctx->mb_lmax = encoder_codec_ctx->qmax * FF_QP2LAMBDA; |
367 | #endif | 368 | #endif |
368 | encoder_codec_ctx->flags = AV_CODEC_FLAG_QSCALE; | 369 | encoder_codec_ctx->flags = AV_CODEC_FLAG_QSCALE; |
369 | encoder_codec_ctx->global_quality = encoder_codec_ctx->qmin * FF_QP2LAMBDA; | 370 | encoder_codec_ctx->global_quality = encoder_codec_ctx->qmin * FF_QP2LAMBDA; |
370 | 371 | ||
371 | dst_frame->pts = 1; | 372 | dst_frame->pts = 1; |
372 | dst_frame->quality = encoder_codec_ctx->global_quality; | 373 | dst_frame->quality = encoder_codec_ctx->global_quality; |
373 | #endif | 374 | #endif |
374 | 375 | ||
375 | #if LIBAVCODEC_BUILD >= AV_VERSION_INT(54,25,0) | 376 | #if LIBAVCODEC_BUILD >= AV_VERSION_INT (54,25,0) |
376 | err = avcodec_encode_video2 (encoder_codec_ctx, | 377 | err = avcodec_encode_video2 (encoder_codec_ctx, |
377 | &pkt, | 378 | &pkt, |
378 | dst_frame, &gotPacket); | 379 | dst_frame, &gotPacket); |
379 | 380 | ||
380 | if(err < 0) | 381 | if (err < 0) |
381 | goto cleanup; | 382 | goto cleanup; |
382 | err = pkt.size; | 383 | err = pkt.size; |
383 | memcpy(encoder_output_buffer,pkt.data, pkt.size); | 384 | memcpy (encoder_output_buffer,pkt.data, pkt.size); |
384 | 385 | ||
385 | av_free_packet(&pkt); | 386 | av_free_packet (&pkt); |
386 | 387 | ||
387 | 388 | ||
388 | #else | 389 | #else |
@@ -396,7 +397,7 @@ cleanup: | |||
396 | avcodec_close (encoder_codec_ctx); | 397 | avcodec_close (encoder_codec_ctx); |
397 | avcodec_free_context (&encoder_codec_ctx); | 398 | avcodec_free_context (&encoder_codec_ctx); |
398 | av_free (dst_buffer); | 399 | av_free (dst_buffer); |
399 | #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1) | 400 | #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1) |
400 | av_frame_free (&dst_frame); | 401 | av_frame_free (&dst_frame); |
401 | #else | 402 | #else |
402 | avcodec_free_frame (&dst_frame); | 403 | avcodec_free_frame (&dst_frame); |
@@ -408,7 +409,6 @@ cleanup: | |||
408 | } | 409 | } |
409 | 410 | ||
410 | 411 | ||
411 | |||
412 | /** | 412 | /** |
413 | * calculate the thumbnail dimensions, taking pixel aspect into account | 413 | * calculate the thumbnail dimensions, taking pixel aspect into account |
414 | * | 414 | * |
@@ -421,30 +421,30 @@ cleanup: | |||
421 | */ | 421 | */ |
422 | static void | 422 | static void |
423 | calculate_thumbnail_dimensions (int src_width, | 423 | calculate_thumbnail_dimensions (int src_width, |
424 | int src_height, | 424 | int src_height, |
425 | int src_sar_num, | 425 | int src_sar_num, |
426 | int src_sar_den, | 426 | int src_sar_den, |
427 | int *dst_width, | 427 | int *dst_width, |
428 | int *dst_height) | 428 | int *dst_height) |
429 | { | 429 | { |
430 | if ( (src_sar_num <= 0) || (src_sar_den <= 0) ) | 430 | if ( (src_sar_num <= 0) || (src_sar_den <= 0) ) |
431 | { | 431 | { |
432 | src_sar_num = 1; | 432 | src_sar_num = 1; |
433 | src_sar_den = 1; | 433 | src_sar_den = 1; |
434 | } | 434 | } |
435 | if ((src_width * src_sar_num) / src_sar_den > src_height) | 435 | if ((src_width * src_sar_num) / src_sar_den > src_height) |
436 | { | 436 | { |
437 | *dst_width = MAX_THUMB_DIMENSION; | 437 | *dst_width = MAX_THUMB_DIMENSION; |
438 | *dst_height = (*dst_width * src_height) / | 438 | *dst_height = (*dst_width * src_height) |
439 | ((src_width * src_sar_num) / src_sar_den); | 439 | / ((src_width * src_sar_num) / src_sar_den); |
440 | } | 440 | } |
441 | else | 441 | else |
442 | { | 442 | { |
443 | *dst_height = MAX_THUMB_DIMENSION; | 443 | *dst_height = MAX_THUMB_DIMENSION; |
444 | *dst_width = (*dst_height * | 444 | *dst_width = (*dst_height |
445 | ((src_width * src_sar_num) / src_sar_den)) / | 445 | * ((src_width * src_sar_num) / src_sar_den)) |
446 | src_height; | 446 | / src_height; |
447 | } | 447 | } |
448 | if (*dst_width < 8) | 448 | if (*dst_width < 8) |
449 | *dst_width = 8; | 449 | *dst_width = 8; |
450 | if (*dst_height < 1) | 450 | if (*dst_height < 1) |
@@ -456,10 +456,11 @@ calculate_thumbnail_dimensions (int src_width, | |||
456 | #endif | 456 | #endif |
457 | } | 457 | } |
458 | 458 | ||
459 | #if LIBAVCODEC_BUILD >= AV_VERSION_INT(54,25,0) | 459 | |
460 | #define ENUM_CODEC_ID enum AVCodecID | 460 | #if LIBAVCODEC_BUILD >= AV_VERSION_INT (54,25,0) |
461 | #define ENUM_CODEC_ID enum AVCodecID | ||
461 | #else | 462 | #else |
462 | #define ENUM_CODEC_ID enum CodecID | 463 | #define ENUM_CODEC_ID enum CodecID |
463 | #endif | 464 | #endif |
464 | 465 | ||
465 | /** | 466 | /** |
@@ -487,77 +488,77 @@ extract_image (ENUM_CODEC_ID image_codec_id, | |||
487 | unsigned char padded_data[PADDED_BUFFER_SIZE]; | 488 | unsigned char padded_data[PADDED_BUFFER_SIZE]; |
488 | 489 | ||
489 | if (NULL == (codec = avcodec_find_decoder (image_codec_id))) | 490 | if (NULL == (codec = avcodec_find_decoder (image_codec_id))) |
490 | { | 491 | { |
491 | #if DEBUG | 492 | #if DEBUG |
492 | fprintf (stderr, | 493 | fprintf (stderr, |
493 | "No suitable codec found\n"); | 494 | "No suitable codec found\n"); |
494 | #endif | 495 | #endif |
495 | return; | 496 | return; |
496 | } | 497 | } |
497 | if (NULL == (codec_ctx = avcodec_alloc_context3 (codec))) | 498 | if (NULL == (codec_ctx = avcodec_alloc_context3 (codec))) |
498 | { | 499 | { |
499 | #if DEBUG | 500 | #if DEBUG |
500 | fprintf (stderr, | 501 | fprintf (stderr, |
501 | "Failed to allocate codec context\n"); | 502 | "Failed to allocate codec context\n"); |
502 | #endif | 503 | #endif |
503 | return; | 504 | return; |
504 | } | 505 | } |
505 | opts = NULL; | 506 | opts = NULL; |
506 | if (0 != avcodec_open2 (codec_ctx, codec, &opts)) | 507 | if (0 != avcodec_open2 (codec_ctx, codec, &opts)) |
507 | { | 508 | { |
508 | #if DEBUG | 509 | #if DEBUG |
509 | fprintf (stderr, | 510 | fprintf (stderr, |
510 | "Failed to open image codec\n"); | 511 | "Failed to open image codec\n"); |
511 | #endif | 512 | #endif |
512 | avcodec_free_context (&codec_ctx); | 513 | avcodec_free_context (&codec_ctx); |
513 | return; | 514 | return; |
514 | } | 515 | } |
515 | av_dict_free (&opts); | 516 | av_dict_free (&opts); |
516 | #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1) | 517 | #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1) |
517 | frame = av_frame_alloc (); | 518 | frame = av_frame_alloc (); |
518 | #else | 519 | #else |
519 | frame = avcodec_alloc_frame(); | 520 | frame = avcodec_alloc_frame (); |
520 | #endif | 521 | #endif |
521 | if (NULL == frame) | 522 | if (NULL == frame) |
522 | { | 523 | { |
523 | #if DEBUG | 524 | #if DEBUG |
524 | fprintf (stderr, | 525 | fprintf (stderr, |
525 | "Failed to allocate frame\n"); | 526 | "Failed to allocate frame\n"); |
526 | #endif | 527 | #endif |
527 | avcodec_close (codec_ctx); | 528 | avcodec_close (codec_ctx); |
528 | avcodec_free_context (&codec_ctx); | 529 | avcodec_free_context (&codec_ctx); |
529 | return; | 530 | return; |
530 | } | 531 | } |
531 | 532 | ||
532 | frame_finished = 0; | 533 | frame_finished = 0; |
533 | while (! frame_finished) | 534 | while (! frame_finished) |
534 | { | 535 | { |
535 | if (0 >= (iret = ec->read (ec->cls, | 536 | if (0 >= (iret = ec->read (ec->cls, |
536 | &data, | 537 | &data, |
537 | BUFFER_SIZE))) | 538 | BUFFER_SIZE))) |
538 | break; | 539 | break; |
539 | memcpy (padded_data, data, iret); | 540 | memcpy (padded_data, data, iret); |
540 | memset (&padded_data[iret], 0, PADDED_BUFFER_SIZE - iret); | 541 | memset (&padded_data[iret], 0, PADDED_BUFFER_SIZE - iret); |
541 | av_init_packet (&avpkt); | 542 | av_init_packet (&avpkt); |
542 | avpkt.data = padded_data; | 543 | avpkt.data = padded_data; |
543 | avpkt.size = iret; | 544 | avpkt.size = iret; |
544 | avcodec_decode_video2 (codec_ctx, frame, &frame_finished, &avpkt); | 545 | avcodec_decode_video2 (codec_ctx, frame, &frame_finished, &avpkt); |
545 | } | 546 | } |
546 | if (! frame_finished) | 547 | if (! frame_finished) |
547 | { | 548 | { |
548 | #if DEBUG | 549 | #if DEBUG |
549 | fprintf (stderr, | 550 | fprintf (stderr, |
550 | "Failed to decode a complete frame\n"); | 551 | "Failed to decode a complete frame\n"); |
551 | #endif | 552 | #endif |
552 | #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1) | 553 | #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1) |
553 | av_frame_free (&frame); | 554 | av_frame_free (&frame); |
554 | #else | 555 | #else |
555 | avcodec_free_frame (&frame); | 556 | avcodec_free_frame (&frame); |
556 | #endif | 557 | #endif |
557 | avcodec_close (codec_ctx); | 558 | avcodec_close (codec_ctx); |
558 | avcodec_free_context (&codec_ctx); | 559 | avcodec_free_context (&codec_ctx); |
559 | return; | 560 | return; |
560 | } | 561 | } |
561 | calculate_thumbnail_dimensions (codec_ctx->width, codec_ctx->height, | 562 | calculate_thumbnail_dimensions (codec_ctx->width, codec_ctx->height, |
562 | codec_ctx->sample_aspect_ratio.num, | 563 | codec_ctx->sample_aspect_ratio.num, |
563 | codec_ctx->sample_aspect_ratio.den, | 564 | codec_ctx->sample_aspect_ratio.den, |
@@ -565,40 +566,41 @@ extract_image (ENUM_CODEC_ID image_codec_id, | |||
565 | 566 | ||
566 | err = create_thumbnail (codec_ctx, codec_ctx->width, codec_ctx->height, | 567 | err = create_thumbnail (codec_ctx, codec_ctx->width, codec_ctx->height, |
567 | frame->linesize, codec_ctx->pix_fmt, | 568 | frame->linesize, codec_ctx->pix_fmt, |
568 | (const uint8_t * const*) frame->data, | 569 | (const uint8_t *const*) frame->data, |
569 | thumb_width, thumb_height, | 570 | thumb_width, thumb_height, |
570 | &encoded_thumbnail, MAX_THUMB_BYTES); | 571 | &encoded_thumbnail, MAX_THUMB_BYTES); |
571 | if (err > 0) | 572 | if (err > 0) |
573 | { | ||
574 | ec->proc (ec->cls, | ||
575 | "thumbnailffmpeg", | ||
576 | EXTRACTOR_METATYPE_THUMBNAIL, | ||
577 | EXTRACTOR_METAFORMAT_BINARY, | ||
578 | "image/png", | ||
579 | (const char*) encoded_thumbnail, | ||
580 | err); | ||
581 | |||
582 | #if OUTPUT_FILE | ||
583 | FILE *f; | ||
584 | #ifdef USE_JPEG | ||
585 | f = fopen ("thumb.jpg", "wb"); | ||
586 | #else | ||
587 | f = fopen ("thumb.png", "wb"); | ||
588 | #endif | ||
589 | if (! f) | ||
572 | { | 590 | { |
573 | ec->proc (ec->cls, | 591 | fprintf (stderr, "Could not open %s\n", "file"); |
574 | "thumbnailffmpeg", | 592 | exit (1); |
575 | EXTRACTOR_METATYPE_THUMBNAIL, | 593 | } |
576 | EXTRACTOR_METAFORMAT_BINARY, | 594 | |
577 | "image/png", | 595 | fwrite (encoded_thumbnail, 1, err, f); |
578 | (const char*) encoded_thumbnail, | 596 | fclose (f); |
579 | err); | ||
580 | |||
581 | #if OUTPUT_FILE | ||
582 | FILE *f; | ||
583 | #ifdef USE_JPEG | ||
584 | f = fopen("thumb.jpg", "wb"); | ||
585 | #else | ||
586 | f = fopen("thumb.png", "wb"); | ||
587 | #endif | ||
588 | if (!f) { | ||
589 | fprintf(stderr, "Could not open %s\n", "file"); | ||
590 | exit(1); | ||
591 | } | ||
592 | |||
593 | fwrite(encoded_thumbnail, 1, err, f); | ||
594 | fclose(f); | ||
595 | 597 | ||
596 | #endif | 598 | #endif |
597 | 599 | ||
598 | 600 | ||
599 | av_free (encoded_thumbnail); | 601 | av_free (encoded_thumbnail); |
600 | } | 602 | } |
601 | #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1) | 603 | #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1) |
602 | av_frame_free (&frame); | 604 | av_frame_free (&frame); |
603 | #else | 605 | #else |
604 | avcodec_free_frame (&frame); | 606 | avcodec_free_frame (&frame); |
@@ -637,107 +639,107 @@ extract_video (struct EXTRACTOR_ExtractContext *ec) | |||
637 | return; | 639 | return; |
638 | if (NULL == (io_ctx = avio_alloc_context (iob, | 640 | if (NULL == (io_ctx = avio_alloc_context (iob, |
639 | 16 * 1024, | 641 | 16 * 1024, |
640 | 0, ec, | 642 | 0, ec, |
641 | &read_cb, | 643 | &read_cb, |
642 | NULL /* no writing */, | 644 | NULL /* no writing */, |
643 | &seek_cb))) | 645 | &seek_cb))) |
644 | { | 646 | { |
645 | av_free (iob); | 647 | av_free (iob); |
646 | return; | 648 | return; |
647 | } | 649 | } |
648 | if (NULL == (format_ctx = avformat_alloc_context ())) | 650 | if (NULL == (format_ctx = avformat_alloc_context ())) |
649 | { | 651 | { |
650 | av_free (io_ctx); | 652 | av_free (io_ctx); |
651 | return; | 653 | return; |
652 | } | 654 | } |
653 | format_ctx->pb = io_ctx; | 655 | format_ctx->pb = io_ctx; |
654 | options = NULL; | 656 | options = NULL; |
655 | if (0 != avformat_open_input (&format_ctx, "<no file>", NULL, &options)) | 657 | if (0 != avformat_open_input (&format_ctx, "<no file>", NULL, &options)) |
656 | { | 658 | { |
657 | av_free (io_ctx); | 659 | av_free (io_ctx); |
658 | return; | 660 | return; |
659 | } | 661 | } |
660 | av_dict_free (&options); | 662 | av_dict_free (&options); |
661 | if (0 > avformat_find_stream_info (format_ctx, NULL)) | 663 | if (0 > avformat_find_stream_info (format_ctx, NULL)) |
662 | { | 664 | { |
663 | #if DEBUG | 665 | #if DEBUG |
664 | fprintf (stderr, | 666 | fprintf (stderr, |
665 | "Failed to read stream info\n"); | 667 | "Failed to read stream info\n"); |
666 | #endif | 668 | #endif |
667 | avformat_close_input (&format_ctx); | 669 | avformat_close_input (&format_ctx); |
668 | av_free (io_ctx); | 670 | av_free (io_ctx); |
669 | return; | 671 | return; |
670 | } | 672 | } |
671 | codec = NULL; | 673 | codec = NULL; |
672 | codec_ctx = NULL; | 674 | codec_ctx = NULL; |
673 | video_stream_index = -1; | 675 | video_stream_index = -1; |
674 | for (i=0; i<format_ctx->nb_streams; i++) | 676 | for (i = 0; i<format_ctx->nb_streams; i++) |
677 | { | ||
678 | codec_ctx = format_ctx->streams[i]->codec; | ||
679 | if (AVMEDIA_TYPE_VIDEO != codec_ctx->codec_type) | ||
680 | continue; | ||
681 | if (NULL == (codec = avcodec_find_decoder (codec_ctx->codec_id))) | ||
682 | continue; | ||
683 | options = NULL; | ||
684 | if (0 != (err = avcodec_open2 (codec_ctx, codec, &options))) | ||
675 | { | 685 | { |
676 | codec_ctx = format_ctx->streams[i]->codec; | 686 | codec = NULL; |
677 | if (AVMEDIA_TYPE_VIDEO != codec_ctx->codec_type) | 687 | continue; |
678 | continue; | ||
679 | if (NULL == (codec = avcodec_find_decoder (codec_ctx->codec_id))) | ||
680 | continue; | ||
681 | options = NULL; | ||
682 | if (0 != (err = avcodec_open2 (codec_ctx, codec, &options))) | ||
683 | { | ||
684 | codec = NULL; | ||
685 | continue; | ||
686 | } | ||
687 | av_dict_free (&options); | ||
688 | video_stream_index = i; | ||
689 | break; | ||
690 | } | 688 | } |
689 | av_dict_free (&options); | ||
690 | video_stream_index = i; | ||
691 | break; | ||
692 | } | ||
691 | if ( (-1 == video_stream_index) || | 693 | if ( (-1 == video_stream_index) || |
692 | (0 == codec_ctx->width) || | 694 | (0 == codec_ctx->width) || |
693 | (0 == codec_ctx->height) ) | 695 | (0 == codec_ctx->height) ) |
694 | { | 696 | { |
695 | #if DEBUG | 697 | #if DEBUG |
696 | fprintf (stderr, | 698 | fprintf (stderr, |
697 | "No video streams or no suitable codec found\n"); | 699 | "No video streams or no suitable codec found\n"); |
698 | #endif | 700 | #endif |
699 | if (NULL != codec) | 701 | if (NULL != codec) |
700 | avcodec_close (codec_ctx); | 702 | avcodec_close (codec_ctx); |
701 | avformat_close_input (&format_ctx); | 703 | avformat_close_input (&format_ctx); |
702 | av_free (io_ctx); | 704 | av_free (io_ctx); |
703 | return; | 705 | return; |
704 | } | 706 | } |
705 | 707 | ||
706 | #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1) | 708 | #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1) |
707 | frame = av_frame_alloc (); | 709 | frame = av_frame_alloc (); |
708 | #else | 710 | #else |
709 | frame = avcodec_alloc_frame(); | 711 | frame = avcodec_alloc_frame (); |
710 | #endif | 712 | #endif |
711 | if (NULL == frame) | 713 | if (NULL == frame) |
712 | { | 714 | { |
713 | #if DEBUG | 715 | #if DEBUG |
714 | fprintf (stderr, | 716 | fprintf (stderr, |
715 | "Failed to allocate frame\n"); | 717 | "Failed to allocate frame\n"); |
716 | #endif | 718 | #endif |
717 | avcodec_close (codec_ctx); | 719 | avcodec_close (codec_ctx); |
718 | avformat_close_input (&format_ctx); | 720 | avformat_close_input (&format_ctx); |
719 | av_free (io_ctx); | 721 | av_free (io_ctx); |
720 | return; | 722 | return; |
721 | } | 723 | } |
722 | 724 | ||
723 | if (format_ctx->duration == AV_NOPTS_VALUE) | 725 | if (format_ctx->duration == AV_NOPTS_VALUE) |
724 | { | 726 | { |
725 | duration = -1; | 727 | duration = -1; |
726 | #if DEBUG | 728 | #if DEBUG |
727 | fprintf (stderr, | 729 | fprintf (stderr, |
728 | "Duration unknown\n"); | 730 | "Duration unknown\n"); |
729 | #endif | 731 | #endif |
730 | } | 732 | } |
731 | else | 733 | else |
732 | { | 734 | { |
733 | duration = format_ctx->duration; | 735 | duration = format_ctx->duration; |
734 | } | 736 | } |
735 | 737 | ||
736 | /* if duration is known, seek to first tried, | 738 | /* if duration is known, seek to first tried, |
737 | * else use 10 sec into stream */ | 739 | * else use 10 sec into stream */ |
738 | 740 | ||
739 | if(-1 != duration) | 741 | if (-1 != duration) |
740 | err = av_seek_frame (format_ctx, -1, (duration/3), 0); | 742 | err = av_seek_frame (format_ctx, -1, (duration / 3), 0); |
741 | else | 743 | else |
742 | err = av_seek_frame (format_ctx, -1, 10 * AV_TIME_BASE, 0); | 744 | err = av_seek_frame (format_ctx, -1, 10 * AV_TIME_BASE, 0); |
743 | 745 | ||
@@ -746,41 +748,41 @@ extract_video (struct EXTRACTOR_ExtractContext *ec) | |||
746 | frame_finished = 0; | 748 | frame_finished = 0; |
747 | 749 | ||
748 | while (1) | 750 | while (1) |
751 | { | ||
752 | err = av_read_frame (format_ctx, &packet); | ||
753 | if (err < 0) | ||
754 | break; | ||
755 | if (packet.stream_index == video_stream_index) | ||
749 | { | 756 | { |
750 | err = av_read_frame (format_ctx, &packet); | 757 | avcodec_decode_video2 (codec_ctx, |
751 | if (err < 0) | 758 | frame, |
759 | &frame_finished, | ||
760 | &packet); | ||
761 | if (frame_finished && frame->key_frame) | ||
762 | { | ||
763 | av_free_packet (&packet); | ||
752 | break; | 764 | break; |
753 | if (packet.stream_index == video_stream_index) | 765 | } |
754 | { | ||
755 | avcodec_decode_video2 (codec_ctx, | ||
756 | frame, | ||
757 | &frame_finished, | ||
758 | &packet); | ||
759 | if (frame_finished && frame->key_frame) | ||
760 | { | ||
761 | av_free_packet (&packet); | ||
762 | break; | ||
763 | } | ||
764 | } | ||
765 | av_free_packet (&packet); | ||
766 | } | 766 | } |
767 | av_free_packet (&packet); | ||
768 | } | ||
767 | 769 | ||
768 | if (! frame_finished) | 770 | if (! frame_finished) |
769 | { | 771 | { |
770 | #if DEBUG | 772 | #if DEBUG |
771 | fprintf (stderr, | 773 | fprintf (stderr, |
772 | "Failed to decode a complete frame\n"); | 774 | "Failed to decode a complete frame\n"); |
773 | #endif | 775 | #endif |
774 | #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1) | 776 | #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1) |
775 | av_frame_free (&frame); | 777 | av_frame_free (&frame); |
776 | #else | 778 | #else |
777 | avcodec_free_frame (&frame); | 779 | avcodec_free_frame (&frame); |
778 | #endif | 780 | #endif |
779 | avcodec_close (codec_ctx); | 781 | avcodec_close (codec_ctx); |
780 | avformat_close_input (&format_ctx); | 782 | avformat_close_input (&format_ctx); |
781 | av_free (io_ctx); | 783 | av_free (io_ctx); |
782 | return; | 784 | return; |
783 | } | 785 | } |
784 | calculate_thumbnail_dimensions (codec_ctx->width, codec_ctx->height, | 786 | calculate_thumbnail_dimensions (codec_ctx->width, codec_ctx->height, |
785 | codec_ctx->sample_aspect_ratio.num, | 787 | codec_ctx->sample_aspect_ratio.num, |
786 | codec_ctx->sample_aspect_ratio.den, | 788 | codec_ctx->sample_aspect_ratio.den, |
@@ -788,37 +790,37 @@ extract_video (struct EXTRACTOR_ExtractContext *ec) | |||
788 | 790 | ||
789 | err = create_thumbnail (codec_ctx, codec_ctx->width, codec_ctx->height, | 791 | err = create_thumbnail (codec_ctx, codec_ctx->width, codec_ctx->height, |
790 | frame->linesize, codec_ctx->pix_fmt, | 792 | frame->linesize, codec_ctx->pix_fmt, |
791 | (const uint8_t* const *) frame->data, | 793 | (const uint8_t*const *) frame->data, |
792 | thumb_width, thumb_height, | 794 | thumb_width, thumb_height, |
793 | &encoded_thumbnail, MAX_THUMB_BYTES); | 795 | &encoded_thumbnail, MAX_THUMB_BYTES); |
794 | if (err > 0) | 796 | if (err > 0) |
795 | { | 797 | { |
796 | ec->proc (ec->cls, | 798 | ec->proc (ec->cls, |
797 | "thumbnailffmpeg", | 799 | "thumbnailffmpeg", |
798 | EXTRACTOR_METATYPE_THUMBNAIL, | 800 | EXTRACTOR_METATYPE_THUMBNAIL, |
799 | EXTRACTOR_METAFORMAT_BINARY, | 801 | EXTRACTOR_METAFORMAT_BINARY, |
800 | "image/png", | 802 | "image/png", |
801 | (const char*) encoded_thumbnail, | 803 | (const char*) encoded_thumbnail, |
802 | err); | 804 | err); |
803 | #if OUTPUT_FILE | 805 | #if OUTPUT_FILE |
804 | FILE *f; | 806 | FILE *f; |
805 | #ifdef USE_JPEG | 807 | #ifdef USE_JPEG |
806 | f = fopen("thumb.jpg", "wb"); | 808 | f = fopen ("thumb.jpg", "wb"); |
807 | #else | 809 | #else |
808 | f = fopen("thumb.png", "wb"); | 810 | f = fopen ("thumb.png", "wb"); |
809 | #endif | 811 | #endif |
810 | if (!f) | 812 | if (! f) |
811 | { | 813 | { |
812 | fprintf(stderr, "Could not open %s\n", "file"); | 814 | fprintf (stderr, "Could not open %s\n", "file"); |
813 | exit(1); | 815 | exit (1); |
814 | } | 816 | } |
815 | 817 | ||
816 | fwrite(encoded_thumbnail, 1, err, f); | 818 | fwrite (encoded_thumbnail, 1, err, f); |
817 | fclose(f); | 819 | fclose (f); |
818 | #endif | 820 | #endif |
819 | av_free (encoded_thumbnail); | 821 | av_free (encoded_thumbnail); |
820 | } | 822 | } |
821 | #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1) | 823 | #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1) |
822 | av_frame_free (&frame); | 824 | av_frame_free (&frame); |
823 | #else | 825 | #else |
824 | avcodec_free_frame (&frame); | 826 | avcodec_free_frame (&frame); |
@@ -849,28 +851,27 @@ struct MIMEToDecoderMapping | |||
849 | /** | 851 | /** |
850 | * map MIME image types to an ffmpeg decoder | 852 | * map MIME image types to an ffmpeg decoder |
851 | */ | 853 | */ |
852 | static const struct MIMEToDecoderMapping m2d_map[] = | 854 | static const struct MIMEToDecoderMapping m2d_map[] = { |
853 | { | 855 | |
854 | 856 | #if LIBAVCODEC_BUILD >= AV_VERSION_INT (54,25,0) | |
855 | #if LIBAVCODEC_BUILD >= AV_VERSION_INT(54,25,0) | 857 | { "image/x-bmp", AV_CODEC_ID_BMP }, |
856 | { "image/x-bmp", AV_CODEC_ID_BMP }, | 858 | { "image/gif", AV_CODEC_ID_GIF }, |
857 | { "image/gif", AV_CODEC_ID_GIF }, | 859 | { "image/jpeg", AV_CODEC_ID_MJPEG }, |
858 | { "image/jpeg", AV_CODEC_ID_MJPEG }, | 860 | { "image/png", AV_CODEC_ID_PNG }, |
859 | { "image/png", AV_CODEC_ID_PNG }, | 861 | { "image/x-png", AV_CODEC_ID_PNG }, |
860 | { "image/x-png", AV_CODEC_ID_PNG }, | 862 | { "image/x-portable-pixmap", AV_CODEC_ID_PPM }, |
861 | { "image/x-portable-pixmap", AV_CODEC_ID_PPM }, | 863 | { NULL, AV_CODEC_ID_NONE } |
862 | { NULL, AV_CODEC_ID_NONE } | ||
863 | #else | 864 | #else |
864 | { "image/x-bmp", CODEC_ID_BMP }, | 865 | { "image/x-bmp", CODEC_ID_BMP }, |
865 | { "image/gif", CODEC_ID_GIF }, | 866 | { "image/gif", CODEC_ID_GIF }, |
866 | { "image/jpeg", CODEC_ID_MJPEG }, | 867 | { "image/jpeg", CODEC_ID_MJPEG }, |
867 | { "image/png", CODEC_ID_PNG }, | 868 | { "image/png", CODEC_ID_PNG }, |
868 | { "image/x-png", CODEC_ID_PNG }, | 869 | { "image/x-png", CODEC_ID_PNG }, |
869 | { "image/x-portable-pixmap", CODEC_ID_PPM }, | 870 | { "image/x-portable-pixmap", CODEC_ID_PPM }, |
870 | { NULL, CODEC_ID_NONE } | 871 | { NULL, CODEC_ID_NONE } |
871 | #endif | 872 | #endif |
872 | 873 | ||
873 | }; | 874 | }; |
874 | 875 | ||
875 | 876 | ||
876 | /** | 877 | /** |
@@ -887,8 +888,8 @@ EXTRACTOR_thumbnailffmpeg_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
887 | const char *mime; | 888 | const char *mime; |
888 | 889 | ||
889 | if (-1 == (iret = ec->read (ec->cls, | 890 | if (-1 == (iret = ec->read (ec->cls, |
890 | &data, | 891 | &data, |
891 | 16 * 1024))) | 892 | 16 * 1024))) |
892 | return; | 893 | return; |
893 | if (NULL == (mime = magic_buffer (magic, data, iret))) | 894 | if (NULL == (mime = magic_buffer (magic, data, iret))) |
894 | return; | 895 | return; |
@@ -896,10 +897,10 @@ EXTRACTOR_thumbnailffmpeg_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
896 | return; | 897 | return; |
897 | for (i = 0; NULL != m2d_map[i].mime_type; i++) | 898 | for (i = 0; NULL != m2d_map[i].mime_type; i++) |
898 | if (0 == strcmp (m2d_map[i].mime_type, mime)) | 899 | if (0 == strcmp (m2d_map[i].mime_type, mime)) |
899 | { | 900 | { |
900 | extract_image (m2d_map[i].codec_id, ec); | 901 | extract_image (m2d_map[i].codec_id, ec); |
901 | return; | 902 | return; |
902 | } | 903 | } |
903 | extract_video (ec); | 904 | extract_video (ec); |
904 | } | 905 | } |
905 | 906 | ||
@@ -926,13 +927,13 @@ EXTRACTOR_thumbnail_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
926 | * @param ap arguments for format | 927 | * @param ap arguments for format |
927 | */ | 928 | */ |
928 | static void | 929 | static void |
929 | thumbnailffmpeg_av_log_callback (void* ptr, | 930 | thumbnailffmpeg_av_log_callback (void*ptr, |
930 | int level, | 931 | int level, |
931 | const char *format, | 932 | const char *format, |
932 | va_list ap) | 933 | va_list ap) |
933 | { | 934 | { |
934 | #if DEBUG | 935 | #if DEBUG |
935 | vfprintf(stderr, format, ap); | 936 | vfprintf (stderr, format, ap); |
936 | #endif | 937 | #endif |
937 | } | 938 | } |
938 | 939 | ||
@@ -947,9 +948,9 @@ thumbnailffmpeg_lib_init (void) | |||
947 | av_register_all (); | 948 | av_register_all (); |
948 | magic = magic_open (MAGIC_MIME_TYPE); | 949 | magic = magic_open (MAGIC_MIME_TYPE); |
949 | if (0 != magic_load (magic, NULL)) | 950 | if (0 != magic_load (magic, NULL)) |
950 | { | 951 | { |
951 | /* FIXME: how to deal with errors? */ | 952 | /* FIXME: how to deal with errors? */ |
952 | } | 953 | } |
953 | } | 954 | } |
954 | 955 | ||
955 | 956 | ||
@@ -960,10 +961,10 @@ void __attribute__ ((destructor)) | |||
960 | thumbnailffmpeg_ltdl_fini () | 961 | thumbnailffmpeg_ltdl_fini () |
961 | { | 962 | { |
962 | if (NULL != magic) | 963 | if (NULL != magic) |
963 | { | 964 | { |
964 | magic_close (magic); | 965 | magic_close (magic); |
965 | magic = NULL; | 966 | magic = NULL; |
966 | } | 967 | } |
967 | } | 968 | } |
968 | 969 | ||
969 | 970 | ||
diff --git a/src/plugins/thumbnailgtk_extractor.c b/src/plugins/thumbnailgtk_extractor.c index 8df7079..8775de3 100644 --- a/src/plugins/thumbnailgtk_extractor.c +++ b/src/plugins/thumbnailgtk_extractor.c | |||
@@ -75,14 +75,14 @@ EXTRACTOR_thumbnailgtk_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
75 | const char *mime; | 75 | const char *mime; |
76 | 76 | ||
77 | if (-1 == (iret = ec->read (ec->cls, | 77 | if (-1 == (iret = ec->read (ec->cls, |
78 | &data, | 78 | &data, |
79 | 16 * 1024))) | 79 | 16 * 1024))) |
80 | return; | 80 | return; |
81 | if (NULL == (mime = magic_buffer (magic, data, iret))) | 81 | if (NULL == (mime = magic_buffer (magic, data, iret))) |
82 | return; | 82 | return; |
83 | if (0 != strncmp (mime, | 83 | if (0 != strncmp (mime, |
84 | "image/", | 84 | "image/", |
85 | strlen ("image/"))) | 85 | strlen ("image/"))) |
86 | return; /* not an image */ | 86 | return; /* not an image */ |
87 | 87 | ||
88 | /* read entire image into memory */ | 88 | /* read entire image into memory */ |
@@ -98,95 +98,95 @@ EXTRACTOR_thumbnailgtk_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
98 | memcpy (buf, data, iret); | 98 | memcpy (buf, data, iret); |
99 | off = iret; | 99 | off = iret; |
100 | while (off < size) | 100 | while (off < size) |
101 | { | ||
102 | iret = ec->read (ec->cls, &data, size - off); | ||
103 | if (iret <= 0) | ||
101 | { | 104 | { |
102 | iret = ec->read (ec->cls, &data, size - off); | 105 | /* io error */ |
103 | if (iret <= 0) | 106 | free (buf); |
104 | { | 107 | return; |
105 | /* io error */ | ||
106 | free (buf); | ||
107 | return; | ||
108 | } | ||
109 | memcpy (buf + off, data, iret); | ||
110 | off += iret; | ||
111 | } | 108 | } |
109 | memcpy (buf + off, data, iret); | ||
110 | off += iret; | ||
111 | } | ||
112 | 112 | ||
113 | loader = gdk_pixbuf_loader_new (); | 113 | loader = gdk_pixbuf_loader_new (); |
114 | gdk_pixbuf_loader_write (loader, | 114 | gdk_pixbuf_loader_write (loader, |
115 | buf, | 115 | buf, |
116 | size, NULL); | 116 | size, NULL); |
117 | free (buf); | 117 | free (buf); |
118 | in = gdk_pixbuf_loader_get_pixbuf (loader); | 118 | in = gdk_pixbuf_loader_get_pixbuf (loader); |
119 | gdk_pixbuf_loader_close (loader, NULL); | 119 | gdk_pixbuf_loader_close (loader, NULL); |
120 | if (NULL == in) | 120 | if (NULL == in) |
121 | { | 121 | { |
122 | g_object_unref (loader); | 122 | g_object_unref (loader); |
123 | return; | 123 | return; |
124 | } | 124 | } |
125 | g_object_ref (in); | 125 | g_object_ref (in); |
126 | g_object_unref (loader); | 126 | g_object_unref (loader); |
127 | height = gdk_pixbuf_get_height (in); | 127 | height = gdk_pixbuf_get_height (in); |
128 | width = gdk_pixbuf_get_width (in); | 128 | width = gdk_pixbuf_get_width (in); |
129 | snprintf (format, | 129 | snprintf (format, |
130 | sizeof (format), | 130 | sizeof (format), |
131 | "%ux%u", | 131 | "%ux%u", |
132 | (unsigned int) width, | 132 | (unsigned int) width, |
133 | (unsigned int) height); | 133 | (unsigned int) height); |
134 | if (0 != ec->proc (ec->cls, | 134 | if (0 != ec->proc (ec->cls, |
135 | "thumbnailgtk", | 135 | "thumbnailgtk", |
136 | EXTRACTOR_METATYPE_IMAGE_DIMENSIONS, | 136 | EXTRACTOR_METATYPE_IMAGE_DIMENSIONS, |
137 | EXTRACTOR_METAFORMAT_UTF8, | 137 | EXTRACTOR_METAFORMAT_UTF8, |
138 | "text/plain", | 138 | "text/plain", |
139 | format, | 139 | format, |
140 | strlen (format) + 1)) | 140 | strlen (format) + 1)) |
141 | { | 141 | { |
142 | g_object_unref (in); | 142 | g_object_unref (in); |
143 | return; | 143 | return; |
144 | } | 144 | } |
145 | if ((height <= THUMBSIZE) && (width <= THUMBSIZE)) | 145 | if ((height <= THUMBSIZE) && (width <= THUMBSIZE)) |
146 | { | 146 | { |
147 | g_object_unref (in); | 147 | g_object_unref (in); |
148 | return; | 148 | return; |
149 | } | 149 | } |
150 | if (height > THUMBSIZE) | 150 | if (height > THUMBSIZE) |
151 | { | 151 | { |
152 | width = width * THUMBSIZE / height; | 152 | width = width * THUMBSIZE / height; |
153 | height = THUMBSIZE; | 153 | height = THUMBSIZE; |
154 | } | 154 | } |
155 | if (width > THUMBSIZE) | 155 | if (width > THUMBSIZE) |
156 | { | 156 | { |
157 | height = height * THUMBSIZE / width; | 157 | height = height * THUMBSIZE / width; |
158 | width = THUMBSIZE; | 158 | width = THUMBSIZE; |
159 | } | 159 | } |
160 | if ( (0 == height) || (0 == width) ) | 160 | if ( (0 == height) || (0 == width) ) |
161 | { | 161 | { |
162 | g_object_unref (in); | 162 | g_object_unref (in); |
163 | return; | 163 | return; |
164 | } | 164 | } |
165 | out = gdk_pixbuf_scale_simple (in, width, height, | 165 | out = gdk_pixbuf_scale_simple (in, width, height, |
166 | GDK_INTERP_BILINEAR); | 166 | GDK_INTERP_BILINEAR); |
167 | g_object_unref (in); | 167 | g_object_unref (in); |
168 | thumb = NULL; | 168 | thumb = NULL; |
169 | length = 0; | 169 | length = 0; |
170 | if (NULL == out) | 170 | if (NULL == out) |
171 | return; | 171 | return; |
172 | if (! gdk_pixbuf_save_to_buffer (out, &thumb, | 172 | if (! gdk_pixbuf_save_to_buffer (out, &thumb, |
173 | &length, | 173 | &length, |
174 | "png", NULL, | 174 | "png", NULL, |
175 | "compression", "9", | 175 | "compression", "9", |
176 | NULL)) | 176 | NULL)) |
177 | { | 177 | { |
178 | g_object_unref (out); | 178 | g_object_unref (out); |
179 | return; | 179 | return; |
180 | } | 180 | } |
181 | g_object_unref (out); | 181 | g_object_unref (out); |
182 | if (NULL == thumb) | 182 | if (NULL == thumb) |
183 | return; | 183 | return; |
184 | ec->proc (ec->cls, | 184 | ec->proc (ec->cls, |
185 | "thumbnailgtk", | 185 | "thumbnailgtk", |
186 | EXTRACTOR_METATYPE_THUMBNAIL, | 186 | EXTRACTOR_METATYPE_THUMBNAIL, |
187 | EXTRACTOR_METAFORMAT_BINARY, | 187 | EXTRACTOR_METAFORMAT_BINARY, |
188 | "image/png", | 188 | "image/png", |
189 | thumb, length); | 189 | thumb, length); |
190 | free (thumb); | 190 | free (thumb); |
191 | } | 191 | } |
192 | 192 | ||
@@ -207,31 +207,32 @@ EXTRACTOR_thumbnail_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
207 | /** | 207 | /** |
208 | * Initialize glib and load magic file. | 208 | * Initialize glib and load magic file. |
209 | */ | 209 | */ |
210 | void __attribute__ ((constructor)) | 210 | void __attribute__ ((constructor)) |
211 | thumbnailgtk_gobject_init () | 211 | thumbnailgtk_gobject_init () |
212 | { | 212 | { |
213 | #if !GLIB_CHECK_VERSION(2, 35, 0) | 213 | #if ! GLIB_CHECK_VERSION (2, 35, 0) |
214 | g_type_init (); | 214 | g_type_init (); |
215 | #endif | 215 | #endif |
216 | magic = magic_open (MAGIC_MIME_TYPE); | 216 | magic = magic_open (MAGIC_MIME_TYPE); |
217 | if (0 != magic_load (magic, NULL)) | 217 | if (0 != magic_load (magic, NULL)) |
218 | { | 218 | { |
219 | /* FIXME: how to deal with errors? */ | 219 | /* FIXME: how to deal with errors? */ |
220 | } | 220 | } |
221 | } | 221 | } |
222 | 222 | ||
223 | 223 | ||
224 | /** | 224 | /** |
225 | * Destructor for the library, cleans up. | 225 | * Destructor for the library, cleans up. |
226 | */ | 226 | */ |
227 | void __attribute__ ((destructor)) | 227 | void __attribute__ ((destructor)) |
228 | thumbnailgtk_ltdl_fini () | 228 | thumbnailgtk_ltdl_fini () |
229 | { | 229 | { |
230 | if (NULL != magic) | 230 | if (NULL != magic) |
231 | { | 231 | { |
232 | magic_close (magic); | 232 | magic_close (magic); |
233 | magic = NULL; | 233 | magic = NULL; |
234 | } | 234 | } |
235 | } | 235 | } |
236 | 236 | ||
237 | |||
237 | /* end of thumbnailgtk_extractor.c */ | 238 | /* end of thumbnailgtk_extractor.c */ |
diff --git a/src/plugins/tiff_extractor.c b/src/plugins/tiff_extractor.c index 82ba94f..163bd80 100644 --- a/src/plugins/tiff_extractor.c +++ b/src/plugins/tiff_extractor.c | |||
@@ -36,8 +36,8 @@ | |||
36 | */ | 36 | */ |
37 | static void | 37 | static void |
38 | error_cb (const char *module, | 38 | error_cb (const char *module, |
39 | const char *fmt, | 39 | const char *fmt, |
40 | va_list ap) | 40 | va_list ap) |
41 | { | 41 | { |
42 | /* do nothing */ | 42 | /* do nothing */ |
43 | } | 43 | } |
@@ -53,13 +53,13 @@ error_cb (const char *module, | |||
53 | */ | 53 | */ |
54 | static tsize_t | 54 | static tsize_t |
55 | read_cb (thandle_t ctx, | 55 | read_cb (thandle_t ctx, |
56 | tdata_t data, | 56 | tdata_t data, |
57 | tsize_t size) | 57 | tsize_t size) |
58 | { | 58 | { |
59 | struct EXTRACTOR_ExtractContext *ec = ctx; | 59 | struct EXTRACTOR_ExtractContext *ec = ctx; |
60 | void *ptr; | 60 | void *ptr; |
61 | ssize_t ret; | 61 | ssize_t ret; |
62 | 62 | ||
63 | ret = ec->read (ec->cls, &ptr, size); | 63 | ret = ec->read (ec->cls, &ptr, size); |
64 | if (ret > 0) | 64 | if (ret > 0) |
65 | memcpy (data, ptr, ret); | 65 | memcpy (data, ptr, ret); |
@@ -77,8 +77,8 @@ read_cb (thandle_t ctx, | |||
77 | */ | 77 | */ |
78 | static tsize_t | 78 | static tsize_t |
79 | write_cb (thandle_t ctx, | 79 | write_cb (thandle_t ctx, |
80 | tdata_t data, | 80 | tdata_t data, |
81 | tsize_t size) | 81 | tsize_t size) |
82 | { | 82 | { |
83 | return -1; | 83 | return -1; |
84 | } | 84 | } |
@@ -94,8 +94,8 @@ write_cb (thandle_t ctx, | |||
94 | */ | 94 | */ |
95 | static toff_t | 95 | static toff_t |
96 | seek_cb (thandle_t ctx, | 96 | seek_cb (thandle_t ctx, |
97 | toff_t offset, | 97 | toff_t offset, |
98 | int whence) | 98 | int whence) |
99 | { | 99 | { |
100 | struct EXTRACTOR_ExtractContext *ec = ctx; | 100 | struct EXTRACTOR_ExtractContext *ec = ctx; |
101 | 101 | ||
@@ -168,77 +168,78 @@ static struct Matches tmap[] = { | |||
168 | 168 | ||
169 | 169 | ||
170 | /** | 170 | /** |
171 | * Main entry method for the 'image/tiff' extraction plugin. | 171 | * Main entry method for the 'image/tiff' extraction plugin. |
172 | * | 172 | * |
173 | * @param ec extraction context provided to the plugin | 173 | * @param ec extraction context provided to the plugin |
174 | */ | 174 | */ |
175 | void | 175 | void |
176 | EXTRACTOR_tiff_extract_method (struct EXTRACTOR_ExtractContext *ec) | 176 | EXTRACTOR_tiff_extract_method (struct EXTRACTOR_ExtractContext *ec) |
177 | { | 177 | { |
178 | TIFF *tiff; | 178 | TIFF *tiff; |
179 | unsigned int i; | 179 | unsigned int i; |
180 | char *meta; | 180 | char *meta; |
181 | char format[128]; | 181 | char format[128]; |
182 | uint32_t width; | 182 | uint32_t width; |
183 | uint32_t height; | 183 | uint32_t height; |
184 | 184 | ||
185 | TIFFSetErrorHandler (&error_cb); | 185 | TIFFSetErrorHandler (&error_cb); |
186 | TIFFSetWarningHandler (&error_cb); | 186 | TIFFSetWarningHandler (&error_cb); |
187 | tiff = TIFFClientOpen ("<no filename>", | 187 | tiff = TIFFClientOpen ("<no filename>", |
188 | "rm", /* read-only, no mmap */ | 188 | "rm", /* read-only, no mmap */ |
189 | ec, | 189 | ec, |
190 | &read_cb, | 190 | &read_cb, |
191 | &write_cb, | 191 | &write_cb, |
192 | &seek_cb, | 192 | &seek_cb, |
193 | &close_cb, | 193 | &close_cb, |
194 | &size_cb, | 194 | &size_cb, |
195 | NULL, NULL); | 195 | NULL, NULL); |
196 | if (NULL == tiff) | 196 | if (NULL == tiff) |
197 | return; | 197 | return; |
198 | for (i = 0; 0 != tmap[i].tag; i++) | 198 | for (i = 0; 0 != tmap[i].tag; i++) |
199 | if ( (1 == | 199 | if ( (1 == |
200 | TIFFGetField (tiff, tmap[i].tag, &meta)) && | 200 | TIFFGetField (tiff, tmap[i].tag, &meta)) && |
201 | (0 != | 201 | (0 != |
202 | ec->proc (ec->cls, | 202 | ec->proc (ec->cls, |
203 | "tiff", | 203 | "tiff", |
204 | tmap[i].type, | 204 | tmap[i].type, |
205 | EXTRACTOR_METAFORMAT_UTF8, | 205 | EXTRACTOR_METAFORMAT_UTF8, |
206 | "text/plain", | 206 | "text/plain", |
207 | meta, | 207 | meta, |
208 | strlen (meta) + 1)) ) | 208 | strlen (meta) + 1)) ) |
209 | goto CLEANUP; | 209 | goto CLEANUP; |
210 | if ( (1 == | 210 | if ( (1 == |
211 | TIFFGetField (tiff, TIFFTAG_IMAGEWIDTH, &width)) && | 211 | TIFFGetField (tiff, TIFFTAG_IMAGEWIDTH, &width)) && |
212 | (1 == | 212 | (1 == |
213 | TIFFGetField (tiff, TIFFTAG_IMAGELENGTH, &height)) ) | 213 | TIFFGetField (tiff, TIFFTAG_IMAGELENGTH, &height)) ) |
214 | { | 214 | { |
215 | snprintf (format, | 215 | snprintf (format, |
216 | sizeof (format), | 216 | sizeof (format), |
217 | "%ux%u", | 217 | "%ux%u", |
218 | (unsigned int) width, | 218 | (unsigned int) width, |
219 | (unsigned int) height); | 219 | (unsigned int) height); |
220 | if (0 != | 220 | if (0 != |
221 | ec->proc (ec->cls, | 221 | ec->proc (ec->cls, |
222 | "tiff", | 222 | "tiff", |
223 | EXTRACTOR_METATYPE_IMAGE_DIMENSIONS, | 223 | EXTRACTOR_METATYPE_IMAGE_DIMENSIONS, |
224 | EXTRACTOR_METAFORMAT_UTF8, | 224 | EXTRACTOR_METAFORMAT_UTF8, |
225 | "text/plain", | 225 | "text/plain", |
226 | format, | 226 | format, |
227 | strlen (format) + 1)) | 227 | strlen (format) + 1)) |
228 | goto CLEANUP; | 228 | goto CLEANUP; |
229 | if (0 != | 229 | if (0 != |
230 | ec->proc (ec->cls, | 230 | ec->proc (ec->cls, |
231 | "tiff", | 231 | "tiff", |
232 | EXTRACTOR_METATYPE_MIMETYPE, | 232 | EXTRACTOR_METATYPE_MIMETYPE, |
233 | EXTRACTOR_METAFORMAT_UTF8, | 233 | EXTRACTOR_METAFORMAT_UTF8, |
234 | "text/plain", | 234 | "text/plain", |
235 | "image/tiff", | 235 | "image/tiff", |
236 | strlen ("image/tiff") + 1)) | 236 | strlen ("image/tiff") + 1)) |
237 | goto CLEANUP; | 237 | goto CLEANUP; |
238 | } | 238 | } |
239 | 239 | ||
240 | CLEANUP: | 240 | CLEANUP: |
241 | TIFFClose (tiff); | 241 | TIFFClose (tiff); |
242 | } | 242 | } |
243 | 243 | ||
244 | |||
244 | /* end of tiff_extractor.c */ | 245 | /* end of tiff_extractor.c */ |
diff --git a/src/plugins/wav_extractor.c b/src/plugins/wav_extractor.c index dae8890..5a7793b 100644 --- a/src/plugins/wav_extractor.c +++ b/src/plugins/wav_extractor.c | |||
@@ -49,9 +49,11 @@ little_endian_to_host32 (uint32_t in) | |||
49 | { | 49 | { |
50 | unsigned char *ptr = (unsigned char *) ∈ | 50 | unsigned char *ptr = (unsigned char *) ∈ |
51 | 51 | ||
52 | return ((ptr[3] & 0xFF) << 24) | ((ptr[2] & 0xFF) << 16) | | 52 | return ((ptr[3] & 0xFF) << 24) | ((ptr[2] & 0xFF) << 16) |
53 | ((ptr[1] & 0xFF) << 8) | (ptr[0] & 0xFF); | 53 | | ((ptr[1] & 0xFF) << 8) | (ptr[0] & 0xFF); |
54 | } | 54 | } |
55 | |||
56 | |||
55 | #endif | 57 | #endif |
56 | 58 | ||
57 | 59 | ||
@@ -85,11 +87,12 @@ EXTRACTOR_wav_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
85 | ec->read (ec->cls, &data, 44)) | 87 | ec->read (ec->cls, &data, 44)) |
86 | return; | 88 | return; |
87 | buf = data; | 89 | buf = data; |
88 | if ((buf[0] != 'R' || buf[1] != 'I' || | 90 | if (((buf[0] != 'R') || (buf[1] != 'I') || |
89 | buf[2] != 'F' || buf[3] != 'F' || | 91 | (buf[2] != 'F') || (buf[3] != 'F') || |
90 | buf[8] != 'W' || buf[9] != 'A' || | 92 | (buf[8] != 'W') || (buf[9] != 'A') || |
91 | buf[10] != 'V' || buf[11] != 'E' || | 93 | (buf[10] != 'V') || (buf[11] != 'E') || |
92 | buf[12] != 'f' || buf[13] != 'm' || buf[14] != 't' || buf[15] != ' ')) | 94 | (buf[12] != 'f') || (buf[13] != 'm') || (buf[14] != 't') || (buf[15] != |
95 | ' ') )) | ||
93 | return; /* not a WAV file */ | 96 | return; /* not a WAV file */ |
94 | 97 | ||
95 | channels = *((uint16_t *) &buf[22]); | 98 | channels = *((uint16_t *) &buf[22]); |
@@ -119,23 +122,24 @@ EXTRACTOR_wav_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
119 | (samples < sample_rate) | 122 | (samples < sample_rate) |
120 | ? (samples * 1000 / sample_rate) | 123 | ? (samples * 1000 / sample_rate) |
121 | : (samples / sample_rate) * 1000, | 124 | : (samples / sample_rate) * 1000, |
122 | sample_rate, (1 == channels) ? _("mono") : _("stereo")); | 125 | sample_rate, (1 == channels) ? _ ("mono") : _ ("stereo")); |
123 | if (0 != ec->proc (ec->cls, | 126 | if (0 != ec->proc (ec->cls, |
124 | "wav", | 127 | "wav", |
125 | EXTRACTOR_METATYPE_RESOURCE_TYPE, | 128 | EXTRACTOR_METATYPE_RESOURCE_TYPE, |
126 | EXTRACTOR_METAFORMAT_UTF8, | 129 | EXTRACTOR_METAFORMAT_UTF8, |
127 | "text/plain", | 130 | "text/plain", |
128 | scratch, | 131 | scratch, |
129 | strlen (scratch) + 1)) | 132 | strlen (scratch) + 1)) |
130 | return; | 133 | return; |
131 | if (0 != ec->proc (ec->cls, | 134 | if (0 != ec->proc (ec->cls, |
132 | "wav", | 135 | "wav", |
133 | EXTRACTOR_METATYPE_MIMETYPE, | 136 | EXTRACTOR_METATYPE_MIMETYPE, |
134 | EXTRACTOR_METAFORMAT_UTF8, | 137 | EXTRACTOR_METAFORMAT_UTF8, |
135 | "text/plain", | 138 | "text/plain", |
136 | "audio/x-wav", | 139 | "audio/x-wav", |
137 | strlen ("audio/x-wav") +1 )) | 140 | strlen ("audio/x-wav") + 1)) |
138 | return; | 141 | return; |
139 | } | 142 | } |
140 | 143 | ||
144 | |||
141 | /* end of wav_extractor.c */ | 145 | /* end of wav_extractor.c */ |
diff --git a/src/plugins/xm_extractor.c b/src/plugins/xm_extractor.c index 854ff15..91b014b 100644 --- a/src/plugins/xm_extractor.c +++ b/src/plugins/xm_extractor.c | |||
@@ -47,7 +47,11 @@ struct Header | |||
47 | * @param s utf-8 string meta data value | 47 | * @param s utf-8 string meta data value |
48 | * @param t type of the meta data | 48 | * @param t type of the meta data |
49 | */ | 49 | */ |
50 | #define ADD(s,t) do { if (0 != ec->proc (ec->cls, "xm", t, EXTRACTOR_METAFORMAT_UTF8, "text/plain", s, strlen (s) + 1)) return; } while (0) | 50 | #define ADD(s,t) do { if (0 != ec->proc (ec->cls, "xm", t, \ |
51 | EXTRACTOR_METAFORMAT_UTF8, \ | ||
52 | "text/plain", s, strlen (s) \ | ||
53 | + 1)) return; \ | ||
54 | } while (0) | ||
51 | 55 | ||
52 | 56 | ||
53 | /** | 57 | /** |
@@ -72,20 +76,20 @@ EXTRACTOR_xm_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
72 | 76 | ||
73 | if ((ssize_t) sizeof (struct Header) > | 77 | if ((ssize_t) sizeof (struct Header) > |
74 | ec->read (ec->cls, | 78 | ec->read (ec->cls, |
75 | &data, | 79 | &data, |
76 | sizeof (struct Header))) | 80 | sizeof (struct Header))) |
77 | return; | 81 | return; |
78 | head = data; | 82 | head = data; |
79 | /* Check "magic" id bytes */ | 83 | /* Check "magic" id bytes */ |
80 | if (memcmp (head->magicid, "Extended Module: ", 17)) | 84 | if (memcmp (head->magicid, "Extended Module: ", 17)) |
81 | return; | 85 | return; |
82 | ADD("audio/x-xm", EXTRACTOR_METATYPE_MIMETYPE); | 86 | ADD ("audio/x-xm", EXTRACTOR_METATYPE_MIMETYPE); |
83 | /* Version of Tracker */ | 87 | /* Version of Tracker */ |
84 | snprintf (xmversion, | 88 | snprintf (xmversion, |
85 | sizeof (xmversion), | 89 | sizeof (xmversion), |
86 | "%u.%u", | 90 | "%u.%u", |
87 | head->version[1], | 91 | head->version[1], |
88 | head->version[0]); | 92 | head->version[0]); |
89 | ADD (xmversion, EXTRACTOR_METATYPE_FORMAT_VERSION); | 93 | ADD (xmversion, EXTRACTOR_METATYPE_FORMAT_VERSION); |
90 | /* Song title */ | 94 | /* Song title */ |
91 | memcpy (&title, head->title, 20); | 95 | memcpy (&title, head->title, 20); |
@@ -104,4 +108,5 @@ EXTRACTOR_xm_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
104 | return; | 108 | return; |
105 | } | 109 | } |
106 | 110 | ||
111 | |||
107 | /* end of xm_extractor.c */ | 112 | /* end of xm_extractor.c */ |
diff --git a/src/plugins/zip_extractor.c b/src/plugins/zip_extractor.c index 717d76d..1ffa5f6 100644 --- a/src/plugins/zip_extractor.c +++ b/src/plugins/zip_extractor.c | |||
@@ -44,86 +44,87 @@ EXTRACTOR_zip_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
44 | if (NULL == (uf = EXTRACTOR_common_unzip_open (ec))) | 44 | if (NULL == (uf = EXTRACTOR_common_unzip_open (ec))) |
45 | return; | 45 | return; |
46 | if ( (EXTRACTOR_UNZIP_OK == | 46 | if ( (EXTRACTOR_UNZIP_OK == |
47 | EXTRACTOR_common_unzip_go_find_local_file (uf, | 47 | EXTRACTOR_common_unzip_go_find_local_file (uf, |
48 | "meta.xml", | 48 | "meta.xml", |
49 | 2)) || | 49 | 2)) || |
50 | (EXTRACTOR_UNZIP_OK == | 50 | (EXTRACTOR_UNZIP_OK == |
51 | EXTRACTOR_common_unzip_go_find_local_file (uf, | 51 | EXTRACTOR_common_unzip_go_find_local_file (uf, |
52 | "META-INF/MANIFEST.MF", | 52 | "META-INF/MANIFEST.MF", |
53 | 2)) ) | 53 | 2)) ) |
54 | { | 54 | { |
55 | /* not a normal zip, might be odf, jar, etc. */ | 55 | /* not a normal zip, might be odf, jar, etc. */ |
56 | goto CLEANUP; | 56 | goto CLEANUP; |
57 | } | 57 | } |
58 | if (EXTRACTOR_UNZIP_OK != | 58 | if (EXTRACTOR_UNZIP_OK != |
59 | EXTRACTOR_common_unzip_go_to_first_file (uf)) | 59 | EXTRACTOR_common_unzip_go_to_first_file (uf)) |
60 | { | 60 | { |
61 | /* zip malformed? */ | 61 | /* zip malformed? */ |
62 | goto CLEANUP; | 62 | goto CLEANUP; |
63 | } | 63 | } |
64 | if (0 != | 64 | if (0 != |
65 | ec->proc (ec->cls, | 65 | ec->proc (ec->cls, |
66 | "zip", | 66 | "zip", |
67 | EXTRACTOR_METATYPE_MIMETYPE, | 67 | EXTRACTOR_METATYPE_MIMETYPE, |
68 | EXTRACTOR_METAFORMAT_UTF8, | 68 | EXTRACTOR_METAFORMAT_UTF8, |
69 | "text/plain", | 69 | "text/plain", |
70 | "application/zip", | 70 | "application/zip", |
71 | strlen ("application/zip") + 1)) | 71 | strlen ("application/zip") + 1)) |
72 | goto CLEANUP; | 72 | goto CLEANUP; |
73 | if (EXTRACTOR_UNZIP_OK == | 73 | if (EXTRACTOR_UNZIP_OK == |
74 | EXTRACTOR_common_unzip_get_global_comment (uf, | 74 | EXTRACTOR_common_unzip_get_global_comment (uf, |
75 | fcomment, | 75 | fcomment, |
76 | sizeof (fcomment))) | 76 | sizeof (fcomment))) |
77 | { | 77 | { |
78 | if ( (0 != strlen (fcomment)) && | 78 | if ( (0 != strlen (fcomment)) && |
79 | (0 != | 79 | (0 != |
80 | ec->proc (ec->cls, | 80 | ec->proc (ec->cls, |
81 | "zip", | 81 | "zip", |
82 | EXTRACTOR_METATYPE_COMMENT, | 82 | EXTRACTOR_METATYPE_COMMENT, |
83 | EXTRACTOR_METAFORMAT_C_STRING, | 83 | EXTRACTOR_METAFORMAT_C_STRING, |
84 | "text/plain", | 84 | "text/plain", |
85 | fcomment, | 85 | fcomment, |
86 | strlen (fcomment) + 1))) | 86 | strlen (fcomment) + 1))) |
87 | goto CLEANUP; | 87 | goto CLEANUP; |
88 | } | 88 | } |
89 | do | 89 | do |
90 | { | ||
91 | if (EXTRACTOR_UNZIP_OK == | ||
92 | EXTRACTOR_common_unzip_get_current_file_info (uf, | ||
93 | &fi, | ||
94 | fname, | ||
95 | sizeof (fname), | ||
96 | NULL, 0, | ||
97 | fcomment, | ||
98 | sizeof (fcomment))) | ||
90 | { | 99 | { |
91 | if (EXTRACTOR_UNZIP_OK == | 100 | if ( (0 != strlen (fname)) && |
92 | EXTRACTOR_common_unzip_get_current_file_info (uf, | 101 | (0 != |
93 | &fi, | 102 | ec->proc (ec->cls, |
94 | fname, | 103 | "zip", |
95 | sizeof (fname), | 104 | EXTRACTOR_METATYPE_FILENAME, |
96 | NULL, 0, | 105 | EXTRACTOR_METAFORMAT_C_STRING, |
97 | fcomment, | 106 | "text/plain", |
98 | sizeof (fcomment))) | 107 | fname, |
99 | { | 108 | strlen (fname) + 1))) |
100 | if ( (0 != strlen (fname)) && | 109 | goto CLEANUP; |
101 | (0 != | 110 | if ( (0 != strlen (fcomment)) && |
102 | ec->proc (ec->cls, | 111 | (0 != |
103 | "zip", | 112 | ec->proc (ec->cls, |
104 | EXTRACTOR_METATYPE_FILENAME, | 113 | "zip", |
105 | EXTRACTOR_METAFORMAT_C_STRING, | 114 | EXTRACTOR_METATYPE_COMMENT, |
106 | "text/plain", | 115 | EXTRACTOR_METAFORMAT_C_STRING, |
107 | fname, | 116 | "text/plain", |
108 | strlen (fname) + 1))) | 117 | fcomment, |
109 | goto CLEANUP; | 118 | strlen (fcomment) + 1))) |
110 | if ( (0 != strlen (fcomment)) && | 119 | goto CLEANUP; |
111 | (0 != | ||
112 | ec->proc (ec->cls, | ||
113 | "zip", | ||
114 | EXTRACTOR_METATYPE_COMMENT, | ||
115 | EXTRACTOR_METAFORMAT_C_STRING, | ||
116 | "text/plain", | ||
117 | fcomment, | ||
118 | strlen (fcomment) + 1))) | ||
119 | goto CLEANUP; | ||
120 | } | ||
121 | } | 120 | } |
121 | } | ||
122 | while (EXTRACTOR_UNZIP_OK == | 122 | while (EXTRACTOR_UNZIP_OK == |
123 | EXTRACTOR_common_unzip_go_to_next_file (uf)); | 123 | EXTRACTOR_common_unzip_go_to_next_file (uf)); |
124 | 124 | ||
125 | CLEANUP: | 125 | CLEANUP: |
126 | (void) EXTRACTOR_common_unzip_close (uf); | 126 | (void) EXTRACTOR_common_unzip_close (uf); |
127 | } | 127 | } |
128 | 128 | ||
129 | |||
129 | /* end of zip_extractor.c */ | 130 | /* end of zip_extractor.c */ |