diff options
Diffstat (limited to 'src/include/extractor.h')
-rw-r--r-- | src/include/extractor.h | 139 |
1 files changed, 97 insertions, 42 deletions
diff --git a/src/include/extractor.h b/src/include/extractor.h index 10692ae..c404a48 100644 --- a/src/include/extractor.h +++ b/src/include/extractor.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libextractor. | 2 | This file is part of libextractor. |
3 | (C) 2002, 2003, 2004, 2005, 2006, 2009 Vidyut Samanta and Christian Grothoff | 3 | (C) 2002, 2003, 2004, 2005, 2006, 2009, 2012 Vidyut Samanta and Christian Grothoff |
4 | 4 | ||
5 | libextractor is free software; you can redistribute it and/or modify | 5 | libextractor is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -32,7 +32,7 @@ extern "C" { | |||
32 | * 0.2.6-1 => 0x00020601 | 32 | * 0.2.6-1 => 0x00020601 |
33 | * 4.5.2-0 => 0x04050200 | 33 | * 4.5.2-0 => 0x04050200 |
34 | */ | 34 | */ |
35 | #define EXTRACTOR_VERSION 0x00060301 | 35 | #define EXTRACTOR_VERSION 0x00060900 |
36 | 36 | ||
37 | #include <stdio.h> | 37 | #include <stdio.h> |
38 | 38 | ||
@@ -331,7 +331,7 @@ enum EXTRACTOR_MetaType | |||
331 | * translate using 'dgettext ("libextractor", rval)' | 331 | * translate using 'dgettext ("libextractor", rval)' |
332 | */ | 332 | */ |
333 | const char * | 333 | const char * |
334 | EXTRACTOR_metatype_to_string(enum EXTRACTOR_MetaType type); | 334 | EXTRACTOR_metatype_to_string (enum EXTRACTOR_MetaType type); |
335 | 335 | ||
336 | 336 | ||
337 | /** | 337 | /** |
@@ -343,7 +343,7 @@ EXTRACTOR_metatype_to_string(enum EXTRACTOR_MetaType type); | |||
343 | * translate using 'dgettext ("libextractor", rval)' | 343 | * translate using 'dgettext ("libextractor", rval)' |
344 | */ | 344 | */ |
345 | const char * | 345 | const char * |
346 | EXTRACTOR_metatype_to_description(enum EXTRACTOR_MetaType type); | 346 | EXTRACTOR_metatype_to_description (enum EXTRACTOR_MetaType type); |
347 | 347 | ||
348 | 348 | ||
349 | /** | 349 | /** |
@@ -372,26 +372,84 @@ EXTRACTOR_metatype_get_max (void); | |||
372 | * @param data_len number of bytes in data | 372 | * @param data_len number of bytes in data |
373 | * @return 0 to continue extracting, 1 to abort | 373 | * @return 0 to continue extracting, 1 to abort |
374 | */ | 374 | */ |
375 | typedef int (*EXTRACTOR_MetaDataProcessor)(void *cls, | 375 | typedef int (*EXTRACTOR_MetaDataProcessor) (void *cls, |
376 | const char *plugin_name, | 376 | const char *plugin_name, |
377 | enum EXTRACTOR_MetaType type, | 377 | enum EXTRACTOR_MetaType type, |
378 | enum EXTRACTOR_MetaFormat format, | 378 | enum EXTRACTOR_MetaFormat format, |
379 | const char *data_mime_type, | 379 | const char *data_mime_type, |
380 | const char *data, | 380 | const char *data, |
381 | size_t data_len); | 381 | size_t data_len); |
382 | 382 | ||
383 | 383 | ||
384 | /** | ||
385 | * Context provided for plugins that perform meta data extraction. | ||
386 | */ | ||
387 | struct EXTRACTOR_ExtractContext | ||
388 | { | ||
389 | |||
390 | /** | ||
391 | * Closure argument to pass to all callbacks. | ||
392 | */ | ||
393 | void *cls; | ||
394 | |||
395 | /** | ||
396 | * Configuration string for the plugin. | ||
397 | */ | ||
398 | const char *config; | ||
399 | |||
400 | /** | ||
401 | * Obtain a pointer to up to 'size' bytes of data from the file to process. | ||
402 | * | ||
403 | * @param cls the 'cls' member of this struct | ||
404 | * @param data pointer to set to the file data, set to NULL on error | ||
405 | * @param size maximum number of bytes requested | ||
406 | * @return number of bytes now available in data (can be smaller than 'size'), | ||
407 | * -1 on error | ||
408 | */ | ||
409 | ssize_t (*read) (void *cls, | ||
410 | unsigned char **data, | ||
411 | size_t size); | ||
412 | |||
413 | |||
414 | /** | ||
415 | * Seek in the file. Use 'SEEK_CUR' for whence and 'pos' of 0 to | ||
416 | * obtain the current position in the file. | ||
417 | * | ||
418 | * @param cls the 'cls' member of this struct | ||
419 | * @param pos position to seek (see 'man lseek') | ||
420 | * @param whence how to see (absolute to start, relative, absolute to end) | ||
421 | * @return new absolute position, UINT64_MAX on error (i.e. desired position | ||
422 | * does not exist) | ||
423 | */ | ||
424 | uint64_t (*seek) (void *cls, | ||
425 | int64_t pos, | ||
426 | int whence); | ||
427 | |||
428 | |||
429 | /** | ||
430 | * Determine the overall size of the file. | ||
431 | * | ||
432 | * @param cls the 'cls' member of this struct | ||
433 | * @return overall file size, UINT64_MAX on error (i.e. IPC failure) | ||
434 | */ | ||
435 | uint64_t (*get_size) (void *cls); | ||
436 | |||
437 | /** | ||
438 | * Function to call on extracted data. | ||
439 | */ | ||
440 | EXTRACTOR_MetaDataProcessor proc; | ||
441 | |||
442 | }; | ||
443 | |||
444 | |||
384 | /** | 445 | /** |
385 | * Signature of the extract method that each plugin | 446 | * Signature of the extract method that each plugin |
386 | * must provide. | 447 | * must provide. |
387 | * | 448 | * |
388 | * @param data data to process | 449 | * @param ec extraction context provided to the plugin |
389 | * @param datasize number of bytes available in data | ||
390 | * @param proc function to call for meta data found | ||
391 | * @param proc_cls cls argument to proc | ||
392 | * @param options options for this plugin; can be NULL | ||
393 | * @return 0 if all calls to proc returned 0, otherwise 1 | ||
394 | */ | 450 | */ |
451 | typedef void (*EXTRACTOR_extract_method) (struct EXTRACTOR_ExtractContext *ec); | ||
452 | |||
395 | 453 | ||
396 | /** | 454 | /** |
397 | * Linked list of extractor plugins. An application builds this list | 455 | * Linked list of extractor plugins. An application builds this list |
@@ -401,10 +459,6 @@ typedef int (*EXTRACTOR_MetaDataProcessor)(void *cls, | |||
401 | */ | 459 | */ |
402 | struct EXTRACTOR_PluginList; | 460 | struct EXTRACTOR_PluginList; |
403 | 461 | ||
404 | typedef int (*EXTRACTOR_extract_method) (struct EXTRACTOR_PluginList *plugin, | ||
405 | EXTRACTOR_MetaDataProcessor proc, void *proc_cls); | ||
406 | |||
407 | |||
408 | 462 | ||
409 | /** | 463 | /** |
410 | * Load the default set of plugins. The default can be changed | 464 | * Load the default set of plugins. The default can be changed |
@@ -428,7 +482,7 @@ typedef int (*EXTRACTOR_extract_method) (struct EXTRACTOR_PluginList *plugin, | |||
428 | * @return the default set of plugins, NULL if no plugins were found | 482 | * @return the default set of plugins, NULL if no plugins were found |
429 | */ | 483 | */ |
430 | struct EXTRACTOR_PluginList * | 484 | struct EXTRACTOR_PluginList * |
431 | EXTRACTOR_plugin_add_defaults(enum EXTRACTOR_Options flags); | 485 | EXTRACTOR_plugin_add_defaults (enum EXTRACTOR_Options flags); |
432 | 486 | ||
433 | 487 | ||
434 | /** | 488 | /** |
@@ -442,10 +496,11 @@ EXTRACTOR_plugin_add_defaults(enum EXTRACTOR_Options flags); | |||
442 | */ | 496 | */ |
443 | struct EXTRACTOR_PluginList * | 497 | struct EXTRACTOR_PluginList * |
444 | EXTRACTOR_plugin_add (struct EXTRACTOR_PluginList * prev, | 498 | EXTRACTOR_plugin_add (struct EXTRACTOR_PluginList * prev, |
445 | const char * library, | 499 | const char *library, |
446 | const char *options, | 500 | const char *options, |
447 | enum EXTRACTOR_Options flags); | 501 | enum EXTRACTOR_Options flags); |
448 | 502 | ||
503 | |||
449 | /** | 504 | /** |
450 | * Load multiple libraries as specified by the user. | 505 | * Load multiple libraries as specified by the user. |
451 | * | 506 | * |
@@ -462,7 +517,7 @@ EXTRACTOR_plugin_add (struct EXTRACTOR_PluginList * prev, | |||
462 | * or if config was empty (or NULL). | 517 | * or if config was empty (or NULL). |
463 | */ | 518 | */ |
464 | struct EXTRACTOR_PluginList * | 519 | struct EXTRACTOR_PluginList * |
465 | EXTRACTOR_plugin_add_config (struct EXTRACTOR_PluginList * prev, | 520 | EXTRACTOR_plugin_add_config (struct EXTRACTOR_PluginList *prev, |
466 | const char *config, | 521 | const char *config, |
467 | enum EXTRACTOR_Options flags); | 522 | enum EXTRACTOR_Options flags); |
468 | 523 | ||
@@ -475,8 +530,8 @@ EXTRACTOR_plugin_add_config (struct EXTRACTOR_PluginList * prev, | |||
475 | * @return the reduced list, unchanged if the plugin was not loaded | 530 | * @return the reduced list, unchanged if the plugin was not loaded |
476 | */ | 531 | */ |
477 | struct EXTRACTOR_PluginList * | 532 | struct EXTRACTOR_PluginList * |
478 | EXTRACTOR_plugin_remove(struct EXTRACTOR_PluginList * prev, | 533 | EXTRACTOR_plugin_remove (struct EXTRACTOR_PluginList *prev, |
479 | const char * library); | 534 | const char *library); |
480 | 535 | ||
481 | 536 | ||
482 | /** | 537 | /** |
@@ -485,7 +540,7 @@ EXTRACTOR_plugin_remove(struct EXTRACTOR_PluginList * prev, | |||
485 | * @param plugin the list of plugins | 540 | * @param plugin the list of plugins |
486 | */ | 541 | */ |
487 | void | 542 | void |
488 | EXTRACTOR_plugin_remove_all(struct EXTRACTOR_PluginList *plugins); | 543 | EXTRACTOR_plugin_remove_all (struct EXTRACTOR_PluginList *plugins); |
489 | 544 | ||
490 | 545 | ||
491 | /** | 546 | /** |
@@ -500,12 +555,12 @@ EXTRACTOR_plugin_remove_all(struct EXTRACTOR_PluginList *plugins); | |||
500 | * @param proc_cls cls argument to proc | 555 | * @param proc_cls cls argument to proc |
501 | */ | 556 | */ |
502 | void | 557 | void |
503 | EXTRACTOR_extract(struct EXTRACTOR_PluginList *plugins, | 558 | EXTRACTOR_extract (struct EXTRACTOR_PluginList *plugins, |
504 | const char *filename, | 559 | const char *filename, |
505 | const void *data, | 560 | const void *data, |
506 | size_t size, | 561 | size_t size, |
507 | EXTRACTOR_MetaDataProcessor proc, | 562 | EXTRACTOR_MetaDataProcessor proc, |
508 | void *proc_cls); | 563 | void *proc_cls); |
509 | 564 | ||
510 | 565 | ||
511 | /** | 566 | /** |
@@ -525,13 +580,13 @@ EXTRACTOR_extract(struct EXTRACTOR_PluginList *plugins, | |||
525 | * @return non-zero if printing failed, otherwise 0. | 580 | * @return non-zero if printing failed, otherwise 0. |
526 | */ | 581 | */ |
527 | int | 582 | int |
528 | EXTRACTOR_meta_data_print(void * handle, | 583 | EXTRACTOR_meta_data_print (void * handle, |
529 | const char *plugin_name, | 584 | const char *plugin_name, |
530 | enum EXTRACTOR_MetaType type, | 585 | enum EXTRACTOR_MetaType type, |
531 | enum EXTRACTOR_MetaFormat format, | 586 | enum EXTRACTOR_MetaFormat format, |
532 | const char *data_mime_type, | 587 | const char *data_mime_type, |
533 | const char *data, | 588 | const char *data, |
534 | size_t data_len); | 589 | size_t data_len); |
535 | 590 | ||
536 | 591 | ||
537 | #if 0 /* keep Emacsens' auto-indent happy */ | 592 | #if 0 /* keep Emacsens' auto-indent happy */ |