libextractor  1.11
About: GNU libextractor is a library used to extract meta-data from files of arbitrary type.
  Fossies Dox: libextractor-1.11.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

extractor_datasource.h File Reference

random access and possibly decompression of data from buffer in memory or file on disk More...

#include "extractor.h"
Include dependency graph for extractor_datasource.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

struct EXTRACTOR_DatasourceEXTRACTOR_datasource_create_from_file_ (const char *filename, EXTRACTOR_MetaDataProcessor proc, void *proc_cls)
 
struct EXTRACTOR_DatasourceEXTRACTOR_datasource_create_from_buffer_ (const char *buf, size_t size, EXTRACTOR_MetaDataProcessor proc, void *proc_cls)
 
void EXTRACTOR_datasource_destroy_ (struct EXTRACTOR_Datasource *ds)
 
ssize_t EXTRACTOR_datasource_read_ (void *cls, void *data, size_t size)
 
int64_t EXTRACTOR_datasource_seek_ (void *cls, int64_t pos, int whence)
 
int64_t EXTRACTOR_datasource_get_size_ (void *cls, int force)
 

Detailed Description

random access and possibly decompression of data from buffer in memory or file on disk

Author
Christian Grothoff

Definition in file extractor_datasource.h.

Function Documentation

◆ EXTRACTOR_datasource_create_from_buffer_()

struct EXTRACTOR_Datasource* EXTRACTOR_datasource_create_from_buffer_ ( const char *  buf,
size_t  size,
EXTRACTOR_MetaDataProcessor  proc,
void *  proc_cls 
)

Create a datasource from a buffer in memory.

Parameters
bufdata in memory
sizenumber of bytes in 'buf'
procmetadata callback to call with meta data found upon opening
proc_clscallback cls
Returns
handle to the datasource, NULL on error

Create a datasource from a buffer in memory.

Parameters
bufdata in memory
sizenumber of bytes in 'buf'
procmetadata callback to call with meta data found upon opening
proc_clscallback cls
Returns
handle to the datasource

Definition at line 1282 of file extractor_datasource.c.

References EXTRACTOR_Datasource::bfds, bfds_delete(), bfds_new(), EXTRACTOR_Datasource::cfs, cfs_new(), COMP_TYPE_BZ2, COMP_TYPE_ZLIB, EXTRACTOR_Datasource::fd, get_compression_type(), LOG, LOG_STRERROR, and NULL.

Referenced by EXTRACTOR_extract().

◆ EXTRACTOR_datasource_create_from_file_()

struct EXTRACTOR_Datasource* EXTRACTOR_datasource_create_from_file_ ( const char *  filename,
EXTRACTOR_MetaDataProcessor  proc,
void *  proc_cls 
)

Create a datasource from a file on disk.

Parameters
filenamename of the file on disk
procmetadata callback to call with meta data found upon opening
proc_clscallback cls
Returns
handle to the datasource, NULL on error

Definition at line 1202 of file extractor_datasource.c.

References EXTRACTOR_Datasource::bfds, bfds_delete(), bfds_new(), EXTRACTOR_Datasource::cfs, cfs_new(), COMP_TYPE_BZ2, COMP_TYPE_ZLIB, EXTRACTOR_Datasource::fd, get_compression_type(), LOG, LOG_STRERROR, LOG_STRERROR_FILE, NULL, and O_LARGEFILE.

Referenced by EXTRACTOR_extract().

◆ EXTRACTOR_datasource_destroy_()

void EXTRACTOR_datasource_destroy_ ( struct EXTRACTOR_Datasource ds)

Destroy a data source.

Parameters
dssource to destroy

Definition at line 1330 of file extractor_datasource.c.

References EXTRACTOR_Datasource::bfds, bfds_delete(), EXTRACTOR_Datasource::cfs, cfs_destroy(), EXTRACTOR_Datasource::fd, and NULL.

Referenced by EXTRACTOR_extract().

◆ EXTRACTOR_datasource_get_size_()

int64_t EXTRACTOR_datasource_get_size_ ( void *  cls,
int  force 
)

Determine the overall size of the data source (after compression).

Parameters
clsmust be a 'struct EXTRACTOR_Datasource'
forceforce computing the size if it is unavailable
Returns
overall file size, -1 on error or unknown

Determine the overall size of the data source (after compression).

Parameters
clsmust be a 'struct EXTRACTOR_Datasource'
forceforce computing the size if it is unavailable
Returns
overall file size, UINT64_MAX on error or unknown

Definition at line 1404 of file extractor_datasource.c.

References EXTRACTOR_Datasource::bfds, EXTRACTOR_Datasource::cfs, cfs_read(), cfs_seek(), CompressedFileSource::fpos, BufferedFileDataSource::fsize, LOG, NULL, and CompressedFileSource::uncompressed_size.

Referenced by do_extract(), EXTRACTOR_datasource_seek_(), in_process_get_size(), and send_update_message().

◆ EXTRACTOR_datasource_read_()

ssize_t EXTRACTOR_datasource_read_ ( void *  cls,
void *  data,
size_t  size 
)

Make 'size' bytes of data from the data source available at 'data'.

Parameters
clsmust be a 'struct EXTRACTOR_Datasource'
datawhere the data should be copied to
sizemaximum number of bytes requested
Returns
number of bytes now available in data (can be smaller than 'size'), -1 on error

Definition at line 1351 of file extractor_datasource.c.

References EXTRACTOR_Datasource::bfds, bfds_read(), EXTRACTOR_Datasource::cfs, cfs_read(), and NULL.

Referenced by EXTRACTOR_IPC_shared_memory_set_(), and in_process_read().

◆ EXTRACTOR_datasource_seek_()

int64_t EXTRACTOR_datasource_seek_ ( void *  cls,
int64_t  pos,
int  whence 
)

Seek in the datasource. Use 'SEEK_CUR' for whence and 'pos' of 0 to obtain the current position in the file.

Parameters
clsmust be a 'struct EXTRACTOR_Datasource'
posposition to seek (see 'man lseek')o
whencehow to see (absolute to start, relative, absolute to end)
Returns
new absolute position, -1 on error (i.e. desired position does not exist)

Seek in the datasource. Use 'SEEK_CUR' for whence and 'pos' of 0 to obtain the current position in the file.

Parameters
clsmust be a 'struct EXTRACTOR_Datasource'
posposition to seek (see 'man lseek')
whencehow to see (absolute to start, relative, absolute to end)
Returns
new absolute position, UINT64_MAX on error (i.e. desired position does not exist)

Definition at line 1374 of file extractor_datasource.c.

References EXTRACTOR_Datasource::bfds, bfds_seek(), EXTRACTOR_Datasource::cfs, cfs_seek(), EXTRACTOR_datasource_get_size_(), NULL, and CompressedFileSource::uncompressed_size.

Referenced by do_extract(), EXTRACTOR_datasource_get_pos_(), EXTRACTOR_IPC_shared_memory_set_(), and in_process_seek().