1#![allow(non_camel_case_types)]
3use libc::FILE;
4
5#[doc = "< No flag."]
6pub const CQDB_NONE: ::std::os::raw::c_uint = 0;
7#[doc = "< A reverse lookup array is omitted."]
8pub const CQDB_ONEWAY: ::std::os::raw::c_uint = 1;
9#[doc = "< An error has occurred."]
10pub const CQDB_ERROR_OCCURRED: ::std::os::raw::c_uint = 65536;
11#[doc = " CQDB flags."]
12#[doc = "< Success."]
13pub const CQDB_SUCCESS: ::std::os::raw::c_int = 0;
14#[doc = "< Unspecified error."]
15pub const CQDB_ERROR: ::std::os::raw::c_int = -1024;
16#[doc = "< String not found."]
17pub const CQDB_ERROR_NOTFOUND: ::std::os::raw::c_int = -1023;
18#[doc = "< Insufficient memory."]
19pub const CQDB_ERROR_OUTOFMEMORY: ::std::os::raw::c_int = -1022;
20#[doc = "< Error in fwrite() operations."]
21pub const CQDB_ERROR_FILEWRITE: ::std::os::raw::c_int = -1021;
22#[doc = "< Error in ftell() operations."]
23pub const CQDB_ERROR_FILETELL: ::std::os::raw::c_int = -1020;
24#[doc = "< Error in fseek() operations."]
25pub const CQDB_ERROR_FILESEEK: ::std::os::raw::c_int = -1019;
26#[doc = "< Invalid parameters."]
27pub const CQDB_ERROR_INVALIDID: ::std::os::raw::c_int = -1018;
28#[doc = " CQDB status codes."]
29#[doc = " \\addtogroup cqdb_writer CQDB Writer API"]
30#[doc = " @{"]
31#[doc = ""]
32#[doc = " The CQDB Writer API constructs a CQDB chunk on a seekable stream. The"]
33#[doc = " seekable stream must be created by the fopen() function with writable and"]
34#[doc = " binary flags (\"wb\"). The CQDB Writer API can build a CQDB chunk at any"]
35#[doc = " position on the stream; one can thus write some data, append a CQDB chunk,"]
36#[doc = " and continue writing other data on the stream."]
37#[doc = ""]
38#[doc = " By default, the function cqdb_writer() constructs a database with forward"]
39#[doc = " (string to integer identifier) and backward (integer identifier to string)"]
40#[doc = " lookups. The data for reverse lookup is omitted with ::CQDB_ONEWAY flag"]
41#[doc = " specified."]
42#[doc = ""]
43#[doc = " It is recommended to keep the maximum number of identifiers as smallest as"]
44#[doc = " possible because reverse lookup is maintained by a array with the size of"]
45#[doc = " sizeof(int) * (maximum number of identifiers + 1). For example, putting a"]
46#[doc = " set of integer identifers (0, 1, 1000) creates a reverse lookup array with"]
47#[doc = " 1001 elements only to waste the disk space for 998 (= 1001-3) elements in"]
48#[doc = " the array."]
49#[repr(C)]
50#[derive(Debug, Copy, Clone)]
51pub struct tag_cqdb_writer {
52 _unused: [u8; 0],
53}
54pub type cqdb_writer_t = tag_cqdb_writer;
55extern "C" {
56 #[doc = " Create a new CQDB writer on a seekable stream."]
57 #[doc = ""]
58 #[doc = " This function initializes a database on the seekable stream and returns"]
59 #[doc = " the pointer to a ::cqdb_writer_t instance to write the database."]
60 #[doc = " The stream must have the writable and binary flags. The database creation"]
61 #[doc = " flag must be zero except when the reverse lookup array is unnecessary;"]
62 #[doc = " specifying ::CQDB_ONEWAY flag will save the storage space for the reverse"]
63 #[doc = " lookup array. Once calling this function, one should avoid accessing the"]
64 #[doc = " seekable stream directly until calling cqdb_writer_close()."]
65 #[doc = ""]
66 #[doc = " @param fp The pointer to the writable and seekable stream."]
67 #[doc = " @param flag Database creation flag."]
68 #[doc = " @retval cqdb_writer_t* The pointer to the new ::cqdb_writer_t instance if"]
69 #[doc = " successful; otherwise \\c NULL."]
70 pub fn cqdb_writer(fp: *mut FILE, flag: ::std::os::raw::c_int) -> *mut cqdb_writer_t;
71}
72extern "C" {
73 #[doc = " Put a string/identifier association to the database."]
74 #[doc = ""]
75 #[doc = " This function append a string/identifier association into the database."]
76 #[doc = " Make sure that the string and/or identifier have never been inserted to"]
77 #[doc = " the database and that the identifier is a non-negative value."]
78 #[doc = ""]
79 #[doc = " @param dbw The pointer to the ::cqdb_writer_t instance."]
80 #[doc = " @param str The pointer to the string."]
81 #[doc = " @param id The identifier."]
82 #[doc = " @retval int Zero if successful, or a status code otherwise."]
83 pub fn cqdb_writer_put(
84 dbw: *mut cqdb_writer_t,
85 str_: *const ::std::os::raw::c_char,
86 id: ::std::os::raw::c_int,
87 ) -> ::std::os::raw::c_int;
88}
89extern "C" {
90 #[doc = " Close a CQDB writer."]
91 #[doc = ""]
92 #[doc = " This function finalizes the database on the stream. If successful, the"]
93 #[doc = " data remaining on the memory is flushed to the stream; the stream position"]
94 #[doc = " is moved to the end of the chunk. If an unexpected error occurs, this"]
95 #[doc = " function tries to rewind the stream position to the original position when"]
96 #[doc = " the function cqdb_writer() was called."]
97 #[doc = ""]
98 #[doc = " @param dbw The pointer to the ::cqdb_writer_t instance."]
99 #[doc = " @retval int Zero if successful, or a status code otherwise."]
100 pub fn cqdb_writer_close(dbw: *mut cqdb_writer_t) -> ::std::os::raw::c_int;
101}
102#[doc = " \\addtogroup cqdb_reader CQDB Reader API"]
103#[doc = " @{"]
104#[doc = ""]
105#[doc = " The CQDB reader API provides a read access to the database whose memory"]
106#[doc = " image is loaded on a memory block. The memory-passing interface has"]
107#[doc = " several advantages. Firstly, one can choose an efficient way for their"]
108#[doc = " application to load a database image to a memory block, e.g., to read"]
109#[doc = " the whole image from a file, to use the Memory Mapped File (mmap) API,"]
110#[doc = " etc."]
111#[doc = " Secondaly, one can design the file format freely only if the memory"]
112#[doc = " block for a database is extracted from the file."]
113#[doc = ""]
114#[doc = " The most fundamental operation on the CQDB reader API is forward lookup"]
115#[doc = " through the use of cqdb_to_id() function, which retrieves integer"]
116#[doc = " identifiers from strings. Reverse lookup (retrieving strings from integer"]
117#[doc = " identifiers) with cqdb_to_string() function is not supported if the"]
118#[doc = " database has been created with ::CQDB_ONEWAY flag."]
119#[repr(C)]
120#[derive(Debug, Copy, Clone)]
121pub struct tag_cqdb {
122 _unused: [u8; 0],
123}
124pub type cqdb_t = tag_cqdb;
125extern "C" {
126 #[doc = " Open a new CQDB reader on a memory block."]
127 #[doc = ""]
128 #[doc = " This function initializes a database on a memory block and returns the"]
129 #[doc = " pointer to a ::cqdb_t instance to access the database."]
130 #[doc = ""]
131 #[doc = " @param buffer The pointer to the memory block."]
132 #[doc = " @param size The size of the memory block."]
133 #[doc = " @retval cqdb_t* The pointer to the ::cqdb_t instance."]
134 pub fn cqdb_reader(buffer: *const ::std::os::raw::c_void, size: usize) -> *mut cqdb_t;
135}
136extern "C" {
137 #[doc = " Delete the CQDB reader."]
138 #[doc = ""]
139 #[doc = " This function frees the work area allocated by cqdb_reader() function."]
140 #[doc = ""]
141 #[doc = " @param db The pointer to the ::cqdb_t instance."]
142 pub fn cqdb_delete(db: *mut cqdb_t);
143}
144extern "C" {
145 #[doc = " Retrieve the identifier associated with a string."]
146 #[doc = ""]
147 #[doc = " This function returns the identifier associated with a string."]
148 #[doc = ""]
149 #[doc = " @param db The pointer to the ::cqdb_t instance."]
150 #[doc = " @param str The pointer to a string."]
151 #[doc = " @retval int The non-negative identifier if successful, negative"]
152 #[doc = " status code otherwise."]
153 pub fn cqdb_to_id(
154 db: *mut cqdb_t,
155 str_: *const ::std::os::raw::c_char,
156 ) -> ::std::os::raw::c_int;
157}
158extern "C" {
159 #[doc = " Retrieve the string associated with an identifier."]
160 #[doc = ""]
161 #[doc = " This function returns the string associated with an identifier."]
162 #[doc = ""]
163 #[doc = " @param db The pointer to the cqdb_t instance."]
164 #[doc = " @param id The id."]
165 #[doc = " @retval const char* The pointer to the string associated with the"]
166 #[doc = " identifier if successful; otherwise \\c NULL."]
167 pub fn cqdb_to_string(
168 db: *mut cqdb_t,
169 id: ::std::os::raw::c_int,
170 ) -> *const ::std::os::raw::c_char;
171}
172extern "C" {
173 #[doc = " Get the number of associations in the database."]
174 #[doc = ""]
175 #[doc = " This function returns the number of associations in the database."]
176 #[doc = ""]
177 #[doc = " @param db The pointer to the ::cqdb_t instance."]
178 #[doc = " @retval int The number of string/identifier associations."]
179 pub fn cqdb_num(db: *mut cqdb_t) -> ::std::os::raw::c_int;
180}