diff options
Diffstat (limited to 'src/main/extractor_datasource.h')
-rw-r--r-- | src/main/extractor_datasource.h | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/src/main/extractor_datasource.h b/src/main/extractor_datasource.h new file mode 100644 index 0000000..5037377 --- /dev/null +++ b/src/main/extractor_datasource.h | |||
@@ -0,0 +1,101 @@ | |||
1 | /* | ||
2 | This file is part of libextractor. | ||
3 | (C) 2002, 2003, 2004, 2005, 2006, 2009, 2012 Vidyut Samanta and Christian Grothoff | ||
4 | |||
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 | ||
7 | by the Free Software Foundation; either version 3, or (at your | ||
8 | option) any later version. | ||
9 | |||
10 | libextractor is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with libextractor; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | #ifndef EXTRACTOR_DATASOURCE_H | ||
21 | #define EXTRACTOR_DATASOURCE_H | ||
22 | |||
23 | /** | ||
24 | * Handle to a datasource we can use for the plugins. | ||
25 | */ | ||
26 | struct EXTRACTOR_Datasource; | ||
27 | |||
28 | |||
29 | /** | ||
30 | * Create a datasource from a file on disk. | ||
31 | * | ||
32 | * @param filename name of the file on disk | ||
33 | * @return handle to the datasource | ||
34 | */ | ||
35 | struct EXTRACTOR_Datasource * | ||
36 | EXTRACTOR_datasource_create_from_file_ (const char *filename); | ||
37 | |||
38 | |||
39 | /** | ||
40 | * Create a datasource from a buffer in memory. | ||
41 | * | ||
42 | * @param buf data in memory | ||
43 | * @param size number of bytes in 'buf' | ||
44 | * @return handle to the datasource | ||
45 | */ | ||
46 | struct EXTRACTOR_Datasource * | ||
47 | EXTRACTOR_datasource_create_from_buffer_ (const char *buf, | ||
48 | size_t size); | ||
49 | |||
50 | |||
51 | /** | ||
52 | * Destroy a data source. | ||
53 | * | ||
54 | * @param datasource source to destroy | ||
55 | */ | ||
56 | void | ||
57 | EXTRACTOR_datasource_destroy_ (struct EXTRACTOR_Datasource *datasource); | ||
58 | |||
59 | |||
60 | /** | ||
61 | * Make 'size' bytes of data from the data source available at '*data'. | ||
62 | * | ||
63 | * @param cls must be a 'struct EXTRACTOR_Datasource' | ||
64 | * @param data where the data should be copied to | ||
65 | * @param size maximum number of bytes requested | ||
66 | * @return number of bytes now available in data (can be smaller than 'size'), | ||
67 | * -1 on error | ||
68 | */ | ||
69 | ssize_t | ||
70 | EXTRACTOR_datasource_read_ (void *cls, | ||
71 | void *data, | ||
72 | size_t size); | ||
73 | |||
74 | |||
75 | /** | ||
76 | * Seek in the datasource. Use 'SEEK_CUR' for whence and 'pos' of 0 to | ||
77 | * obtain the current position in the file. | ||
78 | * | ||
79 | * @param cls must be a 'struct EXTRACTOR_Datasource' | ||
80 | * @param pos position to seek (see 'man lseek') | ||
81 | * @param whence how to see (absolute to start, relative, absolute to end) | ||
82 | * @return new absolute position, UINT64_MAX on error (i.e. desired position | ||
83 | * does not exist) | ||
84 | */ | ||
85 | uint64_t | ||
86 | EXTRACTOR_datasource_seek_ (void *cls, | ||
87 | uint64_t pos, | ||
88 | int whence); | ||
89 | |||
90 | |||
91 | /** | ||
92 | * Determine the overall size of the data source (after compression). | ||
93 | * | ||
94 | * @param cls must be a 'struct EXTRACTOR_Datasource' | ||
95 | * @return overall file size, UINT64_MAX on error (i.e. IPC failure) | ||
96 | */ | ||
97 | uint64_t | ||
98 | EXTRACTOR_datasource_get_size_ (void *cls); | ||
99 | |||
100 | |||
101 | #endif | ||