aboutsummaryrefslogtreecommitdiff
path: root/src/include/extractor.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/extractor.h')
-rw-r--r--src/include/extractor.h139
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 */
333const char * 333const char *
334EXTRACTOR_metatype_to_string(enum EXTRACTOR_MetaType type); 334EXTRACTOR_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 */
345const char * 345const char *
346EXTRACTOR_metatype_to_description(enum EXTRACTOR_MetaType type); 346EXTRACTOR_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 */
375typedef int (*EXTRACTOR_MetaDataProcessor)(void *cls, 375typedef 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 */
387struct 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 */
451typedef 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 */
402struct EXTRACTOR_PluginList; 460struct EXTRACTOR_PluginList;
403 461
404typedef 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 */
430struct EXTRACTOR_PluginList * 484struct EXTRACTOR_PluginList *
431EXTRACTOR_plugin_add_defaults(enum EXTRACTOR_Options flags); 485EXTRACTOR_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 */
443struct EXTRACTOR_PluginList * 497struct EXTRACTOR_PluginList *
444EXTRACTOR_plugin_add (struct EXTRACTOR_PluginList * prev, 498EXTRACTOR_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 */
464struct EXTRACTOR_PluginList * 519struct EXTRACTOR_PluginList *
465EXTRACTOR_plugin_add_config (struct EXTRACTOR_PluginList * prev, 520EXTRACTOR_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 */
477struct EXTRACTOR_PluginList * 532struct EXTRACTOR_PluginList *
478EXTRACTOR_plugin_remove(struct EXTRACTOR_PluginList * prev, 533EXTRACTOR_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 */
487void 542void
488EXTRACTOR_plugin_remove_all(struct EXTRACTOR_PluginList *plugins); 543EXTRACTOR_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 */
502void 557void
503EXTRACTOR_extract(struct EXTRACTOR_PluginList *plugins, 558EXTRACTOR_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 */
527int 582int
528EXTRACTOR_meta_data_print(void * handle, 583EXTRACTOR_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 */