aboutsummaryrefslogtreecommitdiff
path: root/src/main/extractor.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/extractor.c')
-rw-r--r--src/main/extractor.c60
1 files changed, 31 insertions, 29 deletions
diff --git a/src/main/extractor.c b/src/main/extractor.c
index 830eac8..74740a2 100644
--- a/src/main/extractor.c
+++ b/src/main/extractor.c
@@ -92,7 +92,7 @@ send_update_message (struct EXTRACTOR_PluginList *plugin,
92 EXTRACTOR_IPC_channel_destroy_ (plugin->channel); 92 EXTRACTOR_IPC_channel_destroy_ (plugin->channel);
93 plugin->channel = NULL; 93 plugin->channel = NULL;
94 plugin->round_finished = 1; 94 plugin->round_finished = 1;
95 } 95 }
96} 96}
97 97
98 98
@@ -166,7 +166,7 @@ process_plugin_reply (void *cls,
166 if (0 != prp->file_finished) 166 if (0 != prp->file_finished)
167 { 167 {
168 /* client already aborted, ignore message, tell plugin about abort */ 168 /* client already aborted, ignore message, tell plugin about abort */
169 return; 169 return;
170 } 170 }
171 if (0 != prp->proc (prp->proc_cls, 171 if (0 != prp->proc (prp->proc_cls,
172 plugin->short_libname, 172 plugin->short_libname,
@@ -271,13 +271,13 @@ in_process_read (void *cls,
271 * Seek in the file. Use 'SEEK_CUR' for whence and 'pos' of 0 to 271 * Seek in the file. Use 'SEEK_CUR' for whence and 'pos' of 0 to
272 * obtain the current position in the file. 272 * obtain the current position in the file.
273 * Callback used for in-process plugins. 273 * Callback used for in-process plugins.
274 * 274 *
275 * @param cls a 'struct InProcessContext' 275 * @param cls a 'struct InProcessContext'
276 * @param pos position to seek (see 'man lseek') 276 * @param pos position to seek (see 'man lseek')
277 * @param whence how to see (absolute to start, relative, absolute to end) 277 * @param whence how to see (absolute to start, relative, absolute to end)
278 * @return new absolute position, -1 on error (i.e. desired position 278 * @return new absolute position, -1 on error (i.e. desired position
279 * does not exist) 279 * does not exist)
280 */ 280 */
281static int64_t 281static int64_t
282in_process_seek (void *cls, 282in_process_seek (void *cls,
283 int64_t pos, 283 int64_t pos,
@@ -294,15 +294,15 @@ in_process_seek (void *cls,
294/** 294/**
295 * Determine the overall size of the file. 295 * Determine the overall size of the file.
296 * Callback used for in-process plugins. 296 * Callback used for in-process plugins.
297 * 297 *
298 * @param cls a 'struct InProcessContext' 298 * @param cls a 'struct InProcessContext'
299 * @return overall file size, UINT64_MAX on error (i.e. IPC failure) 299 * @return overall file size, UINT64_MAX on error (i.e. IPC failure)
300 */ 300 */
301static uint64_t 301static uint64_t
302in_process_get_size (void *cls) 302in_process_get_size (void *cls)
303{ 303{
304 struct InProcessContext *ctx = cls; 304 struct InProcessContext *ctx = cls;
305 305
306 return (uint64_t) EXTRACTOR_datasource_get_size_ (ctx->ds, 0); 306 return (uint64_t) EXTRACTOR_datasource_get_size_ (ctx->ds, 0);
307} 307}
308 308
@@ -318,13 +318,13 @@ in_process_get_size (void *cls)
318 * used in the main libextractor library and yielding 318 * used in the main libextractor library and yielding
319 * meta data). 319 * meta data).
320 * @param type libextractor-type describing the meta data 320 * @param type libextractor-type describing the meta data
321 * @param format basic format information about data 321 * @param format basic format information about data
322 * @param data_mime_type mime-type of data (not of the original file); 322 * @param data_mime_type mime-type of data (not of the original file);
323 * can be NULL (if mime-type is not known) 323 * can be NULL (if mime-type is not known)
324 * @param data actual meta-data found 324 * @param data actual meta-data found
325 * @param data_len number of bytes in data 325 * @param data_len number of bytes in data
326 * @return 0 to continue extracting, 1 to abort 326 * @return 0 to continue extracting, 1 to abort
327 */ 327 */
328static int 328static int
329in_process_proc (void *cls, 329in_process_proc (void *cls,
330 const char *plugin_name, 330 const char *plugin_name,
@@ -363,7 +363,7 @@ in_process_proc (void *cls,
363 * @param proc_cls cls argument to proc 363 * @param proc_cls cls argument to proc
364 */ 364 */
365static void 365static void
366do_extract (struct EXTRACTOR_PluginList *plugins, 366do_extract (struct EXTRACTOR_PluginList *plugins,
367 struct EXTRACTOR_SharedMemory *shm, 367 struct EXTRACTOR_SharedMemory *shm,
368 struct EXTRACTOR_Datasource *ds, 368 struct EXTRACTOR_Datasource *ds,
369 EXTRACTOR_MetaDataProcessor proc, void *proc_cls) 369 EXTRACTOR_MetaDataProcessor proc, void *proc_cls)
@@ -438,12 +438,12 @@ do_extract (struct EXTRACTOR_PluginList *plugins,
438 else 438 else
439 { 439 {
440 /* not running this round, seeking! */ 440 /* not running this round, seeking! */
441 channels[plugin_off] = NULL; 441 channels[plugin_off] = NULL;
442 } 442 }
443 plugin_off++; 443 plugin_off++;
444 } 444 }
445 /* give plugins chance to send us meta data, seek or finished messages */ 445 /* give plugins chance to send us meta data, seek or finished messages */
446 if (-1 == 446 if (-1 ==
447 EXTRACTOR_IPC_channel_recv_ (channels, 447 EXTRACTOR_IPC_channel_recv_ (channels,
448 plugin_count, 448 plugin_count,
449 &process_plugin_reply, 449 &process_plugin_reply,
@@ -464,12 +464,14 @@ do_extract (struct EXTRACTOR_PluginList *plugins,
464 plugin_off++; 464 plugin_off++;
465 if ( (1 == pos->round_finished) || 465 if ( (1 == pos->round_finished) ||
466 (NULL == pos->channel) ) 466 (NULL == pos->channel) )
467 continue; /* inactive plugin */ 467 {
468 continue; /* inactive plugin */
469 }
468 if (-1 == pos->seek_request) 470 if (-1 == pos->seek_request)
469 { 471 {
470 /* possibly more meta data at current position, at least 472 /* possibly more meta data at current position, at least
471 this plugin is still working on it... */ 473 this plugin is still working on it... */
472 done = 0; 474 done = 0;
473 break; 475 break;
474 } 476 }
475 if (-1 != pos->seek_request) 477 if (-1 != pos->seek_request)
@@ -485,14 +487,14 @@ do_extract (struct EXTRACTOR_PluginList *plugins,
485 pos->seek_request = 0; 487 pos->seek_request = 0;
486 } 488 }
487 else 489 else
488 { 490 {
489 pos->seek_request = end - pos->seek_request; 491 pos->seek_request = end - pos->seek_request;
490 } 492 }
491 } 493 }
492 if ( (-1 == min_seek) || 494 if ( (-1 == min_seek) ||
493 (min_seek > pos->seek_request) ) 495 (min_seek > pos->seek_request) )
494 { 496 {
495 min_seek = pos->seek_request; 497 min_seek = pos->seek_request;
496 } 498 }
497 } 499 }
498 } 500 }
@@ -521,16 +523,16 @@ do_extract (struct EXTRACTOR_PluginList *plugins,
521 { 523 {
522 /* Skipping plugin: channel down */ 524 /* Skipping plugin: channel down */
523 continue; 525 continue;
524 } 526 }
525 if ( (-1 != pos->seek_request) && 527 if ( (-1 != pos->seek_request) &&
526 (1 == prp.file_finished) ) 528 (1 == prp.file_finished) )
527 { 529 {
528 send_discard_message (pos); 530 send_discard_message (pos);
529 pos->round_finished = 1; 531 pos->round_finished = 1;
530 pos->seek_request = -1; 532 pos->seek_request = -1;
531 } 533 }
532 if ( (-1 != data_available) && 534 if ( (-1 != data_available) &&
533 (-1 != pos->seek_request) && 535 (-1 != pos->seek_request) &&
534 (min_seek <= pos->seek_request) && 536 (min_seek <= pos->seek_request) &&
535 ( (min_seek + data_available > pos->seek_request) || 537 ( (min_seek + data_available > pos->seek_request) ||
536 (min_seek == EXTRACTOR_datasource_get_size_ (ds, 0))) ) 538 (min_seek == EXTRACTOR_datasource_get_size_ (ds, 0))) )
@@ -540,10 +542,10 @@ do_extract (struct EXTRACTOR_PluginList *plugins,
540 min_seek, 542 min_seek,
541 data_available, 543 data_available,
542 ds); 544 ds);
543 pos->seek_request = -1; 545 pos->seek_request = -1;
544 } 546 }
545 if (0 == pos->round_finished) 547 if (0 == pos->round_finished)
546 done = 0; /* can't be done, plugin still active */ 548 done = 0; /* can't be done, plugin still active */
547 } 549 }
548 } 550 }
549 551
@@ -615,7 +617,7 @@ EXTRACTOR_extract (struct EXTRACTOR_PluginList *plugins,
615 datasource = EXTRACTOR_datasource_create_from_file_ (filename, 617 datasource = EXTRACTOR_datasource_create_from_file_ (filename,
616 proc, proc_cls); 618 proc, proc_cls);
617 if (NULL == datasource) 619 if (NULL == datasource)
618 return; 620 return;
619 shm = NULL; 621 shm = NULL;
620 have_oop = 0; 622 have_oop = 0;
621 for (pos = plugins; NULL != pos; pos = pos->next) 623 for (pos = plugins; NULL != pos; pos = pos->next)
@@ -658,8 +660,8 @@ EXTRACTOR_extract (struct EXTRACTOR_PluginList *plugins,
658/** 660/**
659 * Initialize gettext and libltdl (and W32 if needed). 661 * Initialize gettext and libltdl (and W32 if needed).
660 */ 662 */
661void __attribute__ ((constructor)) 663void __attribute__ ((constructor))
662EXTRACTOR_ltdl_init () 664EXTRACTOR_ltdl_init ()
663{ 665{
664 int err; 666 int err;
665 667
@@ -667,7 +669,7 @@ EXTRACTOR_ltdl_init ()
667 BINDTEXTDOMAIN (PACKAGE, LOCALEDIR); 669 BINDTEXTDOMAIN (PACKAGE, LOCALEDIR);
668#endif 670#endif
669 err = lt_dlinit (); 671 err = lt_dlinit ();
670 if (err > 0) 672 if (err > 0)
671 { 673 {
672#if DEBUG 674#if DEBUG
673 fprintf (stderr, 675 fprintf (stderr,
@@ -685,7 +687,7 @@ EXTRACTOR_ltdl_init ()
685/** 687/**
686 * Deinit. 688 * Deinit.
687 */ 689 */
688void __attribute__ ((destructor)) 690void __attribute__ ((destructor))
689EXTRACTOR_ltdl_fini () { 691EXTRACTOR_ltdl_fini () {
690#if WINDOWS 692#if WINDOWS
691 plibc_shutdown (); 693 plibc_shutdown ();