summaryrefslogtreecommitdiffstats
path: root/common/unqlite/unqlite.h
diff options
context:
space:
mode:
authorAaron Seigo <aseigo@kde.org>2014-12-14 12:00:05 +0100
committerAaron Seigo <aseigo@kde.org>2014-12-14 12:00:05 +0100
commit7cc25005b8c46d1fa783d33def2c6923e8ef8469 (patch)
tree64fa59d17af29838396cf37b912b3babd885e5dd /common/unqlite/unqlite.h
parentbfc32f265e8ad72823db960fed371d72596003b7 (diff)
parenta6ed70495f9f3ecb21c26860dda16aadcdc91c3a (diff)
downloadsink-7cc25005b8c46d1fa783d33def2c6923e8ef8469.tar.gz
sink-7cc25005b8c46d1fa783d33def2c6923e8ef8469.zip
Merge branch 'unqlite'
Diffstat (limited to 'common/unqlite/unqlite.h')
-rw-r--r--common/unqlite/unqlite.h954
1 files changed, 954 insertions, 0 deletions
diff --git a/common/unqlite/unqlite.h b/common/unqlite/unqlite.h
new file mode 100644
index 0000000..f9b6ae6
--- /dev/null
+++ b/common/unqlite/unqlite.h
@@ -0,0 +1,954 @@
1/* This file was automatically generated. Do not edit (Except for compile time directives)! */
2#ifndef _UNQLITE_H_
3#define _UNQLITE_H_
4/*
5 * Symisc UnQLite: An Embeddable NoSQL (Post Modern) Database Engine.
6 * Copyright (C) 2012-2013, Symisc Systems http://unqlite.org/
7 * Version 1.1.6
8 * For information on licensing, redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES
9 * please contact Symisc Systems via:
10 * legal@symisc.net
11 * licensing@symisc.net
12 * contact@symisc.net
13 * or visit:
14 * http://unqlite.org/licensing.html
15 */
16/*
17 * Copyright (C) 2012, 2013 Symisc Systems, S.U.A.R.L [M.I.A.G Mrad Chems Eddine <chm@symisc.net>].
18 * All rights reserved.
19 *
20 * Redistribution and use in source and binary forms, with or without
21 * modification, are permitted provided that the following conditions
22 * are met:
23 * 1. Redistributions of source code must retain the above copyright
24 * notice, this list of conditions and the following disclaimer.
25 * 2. Redistributions in binary form must reproduce the above copyright
26 * notice, this list of conditions and the following disclaimer in the
27 * documentation and/or other materials provided with the distribution.
28 *
29 * THIS SOFTWARE IS PROVIDED BY SYMISC SYSTEMS ``AS IS'' AND ANY EXPRESS
30 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
31 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
32 * NON-INFRINGEMENT, ARE DISCLAIMED. IN NO EVENT SHALL SYMISC SYSTEMS
33 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
34 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
35 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
36 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
37 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
38 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
39 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 */
41 /* $SymiscID: unqlite.h v1.1 UNIX|WIN32/64 2012-11-02 02:10 stable <chm@symisc.net> $ */
42#include <stdarg.h> /* needed for the definition of va_list */
43/*
44 * Compile time engine version, signature, identification in the symisc source tree
45 * and copyright notice.
46 * Each macro have an equivalent C interface associated with it that provide the same
47 * information but are associated with the library instead of the header file.
48 * Refer to [unqlite_lib_version()], [unqlite_lib_signature()], [unqlite_lib_ident()] and
49 * [unqlite_lib_copyright()] for more information.
50 */
51/*
52 * The UNQLITE_VERSION C preprocessor macroevaluates to a string literal
53 * that is the unqlite version in the format "X.Y.Z" where X is the major
54 * version number and Y is the minor version number and Z is the release
55 * number.
56 */
57#define UNQLITE_VERSION "1.1.6"
58/*
59 * The UNQLITE_VERSION_NUMBER C preprocessor macro resolves to an integer
60 * with the value (X*1000000 + Y*1000 + Z) where X, Y, and Z are the same
61 * numbers used in [UNQLITE_VERSION].
62 */
63#define UNQLITE_VERSION_NUMBER 1001006
64/*
65 * The UNQLITE_SIG C preprocessor macro evaluates to a string
66 * literal which is the public signature of the unqlite engine.
67 * This signature could be included for example in a host-application
68 * generated Server MIME header as follows:
69 * Server: YourWebServer/x.x unqlite/x.x.x \r\n
70 */
71#define UNQLITE_SIG "unqlite/1.1.6"
72/*
73 * UnQLite identification in the Symisc source tree:
74 * Each particular check-in of a particular software released
75 * by symisc systems have an unique identifier associated with it.
76 * This macro hold the one associated with unqlite.
77 */
78#define UNQLITE_IDENT "unqlite:b172a1e2c3f62fb35c8e1fb2795121f82356cad6"
79/*
80 * Copyright notice.
81 * If you have any questions about the licensing situation, please
82 * visit http://unqlite.org/licensing.html
83 * or contact Symisc Systems via:
84 * legal@symisc.net
85 * licensing@symisc.net
86 * contact@symisc.net
87 */
88#define UNQLITE_COPYRIGHT "Copyright (C) Symisc Systems, S.U.A.R.L [Mrad Chems Eddine <chm@symisc.net>] 2012-2013, http://unqlite.org/"
89/* Make sure we can call this stuff from C++ */
90#ifdef __cplusplus
91extern "C" {
92#endif
93/* Forward declaration to public objects */
94typedef struct unqlite_io_methods unqlite_io_methods;
95typedef struct unqlite_kv_methods unqlite_kv_methods;
96typedef struct unqlite_kv_engine unqlite_kv_engine;
97typedef struct jx9_io_stream unqlite_io_stream;
98typedef struct jx9_context unqlite_context;
99typedef struct jx9_value unqlite_value;
100typedef struct unqlite_vfs unqlite_vfs;
101typedef struct unqlite_vm unqlite_vm;
102typedef struct unqlite unqlite;
103/*
104 * ------------------------------
105 * Compile time directives
106 * ------------------------------
107 * For most purposes, UnQLite can be built just fine using the default compilation options.
108 * However, if required, the compile-time options documented below can be used to omit UnQLite
109 * features (resulting in a smaller compiled library size) or to change the default values
110 * of some parameters.
111 * Every effort has been made to ensure that the various combinations of compilation options
112 * work harmoniously and produce a working library.
113 *
114 * UNQLITE_ENABLE_THREADS
115 * This option controls whether or not code is included in UnQLite to enable it to operate
116 * safely in a multithreaded environment. The default is not. All mutexing code is omitted
117 * and it is unsafe to use UnQLite in a multithreaded program. When compiled with the
118 * UNQLITE_ENABLE_THREADS directive enabled, UnQLite can be used in a multithreaded program
119 * and it is safe to share the same virtual machine and engine handle between two or more threads.
120 * The value of UNQLITE_ENABLE_THREADS can be determined at run-time using the unqlite_lib_is_threadsafe()
121 * interface.
122 * When UnQLite has been compiled with threading support then the threading mode can be altered
123 * at run-time using the unqlite_lib_config() interface together with one of these verbs:
124 * UNQLITE_LIB_CONFIG_THREAD_LEVEL_SINGLE
125 * UNQLITE_LIB_CONFIG_THREAD_LEVEL_MULTI
126 * Platforms others than Windows and UNIX systems must install their own mutex subsystem via
127 * unqlite_lib_config() with a configuration verb set to UNQLITE_LIB_CONFIG_USER_MUTEX.
128 * Otherwise the library is not threadsafe.
129 * Note that you must link UnQLite with the POSIX threads library under UNIX systems (i.e: -lpthread).
130 *
131 * Options To Omit/Enable Features
132 *
133 * The following options can be used to reduce the size of the compiled library by omitting optional
134 * features. This is probably only useful in embedded systems where space is especially tight, as even
135 * with all features included the UnQLite library is relatively small. Don't forget to tell your
136 * compiler to optimize for binary size! (the -Os option if using GCC). Telling your compiler
137 * to optimize for size usually has a much larger impact on library footprint than employing
138 * any of these compile-time options.
139 *
140 * JX9_DISABLE_BUILTIN_FUNC
141 * Jx9 is shipped with more than 312 built-in functions suitable for most purposes like
142 * string and INI processing, ZIP extracting, Base64 encoding/decoding, JSON encoding/decoding
143 * and so forth.
144 * If this directive is enabled, then all built-in Jx9 functions are omitted from the build.
145 * Note that special functions such as db_create(), db_store(), db_fetch(), etc. are not omitted
146 * from the build and are not affected by this directive.
147 *
148 * JX9_ENABLE_MATH_FUNC
149 * If this directive is enabled, built-in math functions such as sqrt(), abs(), log(), ceil(), etc.
150 * are included in the build. Note that you may need to link UnQLite with the math library in same
151 * Linux/BSD flavor (i.e: -lm).
152 *
153 * JX9_DISABLE_DISK_IO
154 * If this directive is enabled, built-in VFS functions such as chdir(), mkdir(), chroot(), unlink(),
155 * sleep(), etc. are omitted from the build.
156 *
157 * UNQLITE_ENABLE_JX9_HASH_IO
158 * If this directive is enabled, built-in hash functions such as md5(), sha1(), md5_file(), crc32(), etc.
159 * are included in the build.
160 */
161/* Symisc public definitions */
162#if !defined(SYMISC_STANDARD_DEFS)
163#define SYMISC_STANDARD_DEFS
164#if defined (_WIN32) || defined (WIN32) || defined(__MINGW32__) || defined (_MSC_VER) || defined (_WIN32_WCE)
165/* Windows Systems */
166#if !defined(__WINNT__)
167#define __WINNT__
168#endif
169/*
170 * Determine if we are dealing with WindowsCE - which has a much
171 * reduced API.
172 */
173#if defined(_WIN32_WCE)
174#ifndef __WIN_CE__
175#define __WIN_CE__
176#endif /* __WIN_CE__ */
177#endif /* _WIN32_WCE */
178#else
179/*
180 * By default we will assume that we are compiling on a UNIX systems.
181 * Otherwise the OS_OTHER directive must be defined.
182 */
183#if !defined(OS_OTHER)
184#if !defined(__UNIXES__)
185#define __UNIXES__
186#endif /* __UNIXES__ */
187#else
188#endif /* OS_OTHER */
189#endif /* __WINNT__/__UNIXES__ */
190#if defined(_MSC_VER) || defined(__BORLANDC__)
191typedef signed __int64 sxi64; /* 64 bits(8 bytes) signed int64 */
192typedef unsigned __int64 sxu64; /* 64 bits(8 bytes) unsigned int64 */
193#else
194typedef signed long long int sxi64; /* 64 bits(8 bytes) signed int64 */
195typedef unsigned long long int sxu64; /* 64 bits(8 bytes) unsigned int64 */
196#endif /* _MSC_VER */
197/* Signature of the consumer routine */
198typedef int (*ProcConsumer)(const void *, unsigned int, void *);
199/* Forward reference */
200typedef struct SyMutexMethods SyMutexMethods;
201typedef struct SyMemMethods SyMemMethods;
202typedef struct SyString SyString;
203typedef struct syiovec syiovec;
204typedef struct SyMutex SyMutex;
205typedef struct Sytm Sytm;
206/* Scatter and gather array. */
207struct syiovec
208{
209#if defined (__WINNT__)
210 /* Same fields type and offset as WSABUF structure defined one winsock2 header */
211 unsigned long nLen;
212 char *pBase;
213#else
214 void *pBase;
215 unsigned long nLen;
216#endif
217};
218struct SyString
219{
220 const char *zString; /* Raw string (may not be null terminated) */
221 unsigned int nByte; /* Raw string length */
222};
223/* Time structure. */
224struct Sytm
225{
226 int tm_sec; /* seconds (0 - 60) */
227 int tm_min; /* minutes (0 - 59) */
228 int tm_hour; /* hours (0 - 23) */
229 int tm_mday; /* day of month (1 - 31) */
230 int tm_mon; /* month of year (0 - 11) */
231 int tm_year; /* year + 1900 */
232 int tm_wday; /* day of week (Sunday = 0) */
233 int tm_yday; /* day of year (0 - 365) */
234 int tm_isdst; /* is summer time in effect? */
235 char *tm_zone; /* abbreviation of timezone name */
236 long tm_gmtoff; /* offset from UTC in seconds */
237};
238/* Convert a tm structure (struct tm *) found in <time.h> to a Sytm structure */
239#define STRUCT_TM_TO_SYTM(pTM, pSYTM) \
240 (pSYTM)->tm_hour = (pTM)->tm_hour;\
241 (pSYTM)->tm_min = (pTM)->tm_min;\
242 (pSYTM)->tm_sec = (pTM)->tm_sec;\
243 (pSYTM)->tm_mon = (pTM)->tm_mon;\
244 (pSYTM)->tm_mday = (pTM)->tm_mday;\
245 (pSYTM)->tm_year = (pTM)->tm_year + 1900;\
246 (pSYTM)->tm_yday = (pTM)->tm_yday;\
247 (pSYTM)->tm_wday = (pTM)->tm_wday;\
248 (pSYTM)->tm_isdst = (pTM)->tm_isdst;\
249 (pSYTM)->tm_gmtoff = 0;\
250 (pSYTM)->tm_zone = 0;
251
252/* Convert a SYSTEMTIME structure (LPSYSTEMTIME: Windows Systems only ) to a Sytm structure */
253#define SYSTEMTIME_TO_SYTM(pSYSTIME, pSYTM) \
254 (pSYTM)->tm_hour = (pSYSTIME)->wHour;\
255 (pSYTM)->tm_min = (pSYSTIME)->wMinute;\
256 (pSYTM)->tm_sec = (pSYSTIME)->wSecond;\
257 (pSYTM)->tm_mon = (pSYSTIME)->wMonth - 1;\
258 (pSYTM)->tm_mday = (pSYSTIME)->wDay;\
259 (pSYTM)->tm_year = (pSYSTIME)->wYear;\
260 (pSYTM)->tm_yday = 0;\
261 (pSYTM)->tm_wday = (pSYSTIME)->wDayOfWeek;\
262 (pSYTM)->tm_gmtoff = 0;\
263 (pSYTM)->tm_isdst = -1;\
264 (pSYTM)->tm_zone = 0;
265
266/* Dynamic memory allocation methods. */
267struct SyMemMethods
268{
269 void * (*xAlloc)(unsigned int); /* [Required:] Allocate a memory chunk */
270 void * (*xRealloc)(void *, unsigned int); /* [Required:] Re-allocate a memory chunk */
271 void (*xFree)(void *); /* [Required:] Release a memory chunk */
272 unsigned int (*xChunkSize)(void *); /* [Optional:] Return chunk size */
273 int (*xInit)(void *); /* [Optional:] Initialization callback */
274 void (*xRelease)(void *); /* [Optional:] Release callback */
275 void *pUserData; /* [Optional:] First argument to xInit() and xRelease() */
276};
277/* Out of memory callback signature. */
278typedef int (*ProcMemError)(void *);
279/* Mutex methods. */
280struct SyMutexMethods
281{
282 int (*xGlobalInit)(void); /* [Optional:] Global mutex initialization */
283 void (*xGlobalRelease)(void); /* [Optional:] Global Release callback () */
284 SyMutex * (*xNew)(int); /* [Required:] Request a new mutex */
285 void (*xRelease)(SyMutex *); /* [Optional:] Release a mutex */
286 void (*xEnter)(SyMutex *); /* [Required:] Enter mutex */
287 int (*xTryEnter)(SyMutex *); /* [Optional:] Try to enter a mutex */
288 void (*xLeave)(SyMutex *); /* [Required:] Leave a locked mutex */
289};
290#if defined (_MSC_VER) || defined (__MINGW32__) || defined (__GNUC__) && defined (__declspec)
291#define SX_APIIMPORT __declspec(dllimport)
292#define SX_APIEXPORT __declspec(dllexport)
293#else
294#define SX_APIIMPORT
295#define SX_APIEXPORT
296#endif
297/* Standard return values from Symisc public interfaces */
298#define SXRET_OK 0 /* Not an error */
299#define SXERR_MEM (-1) /* Out of memory */
300#define SXERR_IO (-2) /* IO error */
301#define SXERR_EMPTY (-3) /* Empty field */
302#define SXERR_LOCKED (-4) /* Locked operation */
303#define SXERR_ORANGE (-5) /* Out of range value */
304#define SXERR_NOTFOUND (-6) /* Item not found */
305#define SXERR_LIMIT (-7) /* Limit reached */
306#define SXERR_MORE (-8) /* Need more input */
307#define SXERR_INVALID (-9) /* Invalid parameter */
308#define SXERR_ABORT (-10) /* User callback request an operation abort */
309#define SXERR_EXISTS (-11) /* Item exists */
310#define SXERR_SYNTAX (-12) /* Syntax error */
311#define SXERR_UNKNOWN (-13) /* Unknown error */
312#define SXERR_BUSY (-14) /* Busy operation */
313#define SXERR_OVERFLOW (-15) /* Stack or buffer overflow */
314#define SXERR_WILLBLOCK (-16) /* Operation will block */
315#define SXERR_NOTIMPLEMENTED (-17) /* Operation not implemented */
316#define SXERR_EOF (-18) /* End of input */
317#define SXERR_PERM (-19) /* Permission error */
318#define SXERR_NOOP (-20) /* No-op */
319#define SXERR_FORMAT (-21) /* Invalid format */
320#define SXERR_NEXT (-22) /* Not an error */
321#define SXERR_OS (-23) /* System call return an error */
322#define SXERR_CORRUPT (-24) /* Corrupted pointer */
323#define SXERR_CONTINUE (-25) /* Not an error: Operation in progress */
324#define SXERR_NOMATCH (-26) /* No match */
325#define SXERR_RESET (-27) /* Operation reset */
326#define SXERR_DONE (-28) /* Not an error */
327#define SXERR_SHORT (-29) /* Buffer too short */
328#define SXERR_PATH (-30) /* Path error */
329#define SXERR_TIMEOUT (-31) /* Timeout */
330#define SXERR_BIG (-32) /* Too big for processing */
331#define SXERR_RETRY (-33) /* Retry your call */
332#define SXERR_IGNORE (-63) /* Ignore */
333#endif /* SYMISC_PUBLIC_DEFS */
334/*
335 * Marker for exported interfaces.
336 */
337#define UNQLITE_APIEXPORT SX_APIEXPORT
338/*
339 * If compiling for a processor that lacks floating point
340 * support, substitute integer for floating-point.
341 */
342#ifdef UNQLITE_OMIT_FLOATING_POINT
343typedef sxi64 uqlite_real;
344#else
345typedef double unqlite_real;
346#endif
347typedef sxi64 unqlite_int64;
348/* Standard UnQLite return values */
349#define UNQLITE_OK SXRET_OK /* Successful result */
350/* Beginning of error codes */
351#define UNQLITE_NOMEM SXERR_MEM /* Out of memory */
352#define UNQLITE_ABORT SXERR_ABORT /* Another thread have released this instance */
353#define UNQLITE_IOERR SXERR_IO /* IO error */
354#define UNQLITE_CORRUPT SXERR_CORRUPT /* Corrupt pointer */
355#define UNQLITE_LOCKED SXERR_LOCKED /* Forbidden Operation */
356#define UNQLITE_BUSY SXERR_BUSY /* The database file is locked */
357#define UNQLITE_DONE SXERR_DONE /* Operation done */
358#define UNQLITE_PERM SXERR_PERM /* Permission error */
359#define UNQLITE_NOTIMPLEMENTED SXERR_NOTIMPLEMENTED /* Method not implemented by the underlying Key/Value storage engine */
360#define UNQLITE_NOTFOUND SXERR_NOTFOUND /* No such record */
361#define UNQLITE_NOOP SXERR_NOOP /* No such method */
362#define UNQLITE_INVALID SXERR_INVALID /* Invalid parameter */
363#define UNQLITE_EOF SXERR_EOF /* End Of Input */
364#define UNQLITE_UNKNOWN SXERR_UNKNOWN /* Unknown configuration option */
365#define UNQLITE_LIMIT SXERR_LIMIT /* Database limit reached */
366#define UNQLITE_EXISTS SXERR_EXISTS /* Record exists */
367#define UNQLITE_EMPTY SXERR_EMPTY /* Empty record */
368#define UNQLITE_COMPILE_ERR (-70) /* Compilation error */
369#define UNQLITE_VM_ERR (-71) /* Virtual machine error */
370#define UNQLITE_FULL (-73) /* Full database (unlikely) */
371#define UNQLITE_CANTOPEN (-74) /* Unable to open the database file */
372#define UNQLITE_READ_ONLY (-75) /* Read only Key/Value storage engine */
373#define UNQLITE_LOCKERR (-76) /* Locking protocol error */
374/* end-of-error-codes */
375/*
376 * Database Handle Configuration Commands.
377 *
378 * The following set of constants are the available configuration verbs that can
379 * be used by the host-application to configure an UnQLite database handle.
380 * These constants must be passed as the second argument to [unqlite_config()].
381 *
382 * Each options require a variable number of arguments.
383 * The [unqlite_config()] interface will return UNQLITE_OK on success, any other
384 * return value indicates failure.
385 * For a full discussion on the configuration verbs and their expected
386 * parameters, please refer to this page:
387 * http://unqlite.org/c_api/unqlite_config.html
388 */
389#define UNQLITE_CONFIG_JX9_ERR_LOG 1 /* TWO ARGUMENTS: const char **pzBuf, int *pLen */
390#define UNQLITE_CONFIG_MAX_PAGE_CACHE 2 /* ONE ARGUMENT: int nMaxPage */
391#define UNQLITE_CONFIG_ERR_LOG 3 /* TWO ARGUMENTS: const char **pzBuf, int *pLen */
392#define UNQLITE_CONFIG_KV_ENGINE 4 /* ONE ARGUMENT: const char *zKvName */
393#define UNQLITE_CONFIG_DISABLE_AUTO_COMMIT 5 /* NO ARGUMENTS */
394#define UNQLITE_CONFIG_GET_KV_NAME 6 /* ONE ARGUMENT: const char **pzPtr */
395/*
396 * UnQLite/Jx9 Virtual Machine Configuration Commands.
397 *
398 * The following set of constants are the available configuration verbs that can
399 * be used by the host-application to configure the Jx9 (Via UnQLite) Virtual machine.
400 * These constants must be passed as the second argument to the [unqlite_vm_config()]
401 * interface.
402 * Each options require a variable number of arguments.
403 * The [unqlite_vm_config()] interface will return UNQLITE_OK on success, any other return
404 * value indicates failure.
405 * There are many options but the most importants are: UNQLITE_VM_CONFIG_OUTPUT which install
406 * a VM output consumer callback, UNQLITE_VM_CONFIG_HTTP_REQUEST which parse and register
407 * a HTTP request and UNQLITE_VM_CONFIG_ARGV_ENTRY which populate the $argv array.
408 * For a full discussion on the configuration verbs and their expected parameters, please
409 * refer to this page:
410 * http://unqlite.org/c_api/unqlite_vm_config.html
411 */
412#define UNQLITE_VM_CONFIG_OUTPUT 1 /* TWO ARGUMENTS: int (*xConsumer)(const void *pOut, unsigned int nLen, void *pUserData), void *pUserData */
413#define UNQLITE_VM_CONFIG_IMPORT_PATH 2 /* ONE ARGUMENT: const char *zIncludePath */
414#define UNQLITE_VM_CONFIG_ERR_REPORT 3 /* NO ARGUMENTS: Report all run-time errors in the VM output */
415#define UNQLITE_VM_CONFIG_RECURSION_DEPTH 4 /* ONE ARGUMENT: int nMaxDepth */
416#define UNQLITE_VM_OUTPUT_LENGTH 5 /* ONE ARGUMENT: unsigned int *pLength */
417#define UNQLITE_VM_CONFIG_CREATE_VAR 6 /* TWO ARGUMENTS: const char *zName, unqlite_value *pValue */
418#define UNQLITE_VM_CONFIG_HTTP_REQUEST 7 /* TWO ARGUMENTS: const char *zRawRequest, int nRequestLength */
419#define UNQLITE_VM_CONFIG_SERVER_ATTR 8 /* THREE ARGUMENTS: const char *zKey, const char *zValue, int nLen */
420#define UNQLITE_VM_CONFIG_ENV_ATTR 9 /* THREE ARGUMENTS: const char *zKey, const char *zValue, int nLen */
421#define UNQLITE_VM_CONFIG_EXEC_VALUE 10 /* ONE ARGUMENT: unqlite_value **ppValue */
422#define UNQLITE_VM_CONFIG_IO_STREAM 11 /* ONE ARGUMENT: const unqlite_io_stream *pStream */
423#define UNQLITE_VM_CONFIG_ARGV_ENTRY 12 /* ONE ARGUMENT: const char *zValue */
424#define UNQLITE_VM_CONFIG_EXTRACT_OUTPUT 13 /* TWO ARGUMENTS: const void **ppOut, unsigned int *pOutputLen */
425/*
426 * Storage engine configuration commands.
427 *
428 * The following set of constants are the available configuration verbs that can
429 * be used by the host-application to configure the underlying storage engine (i.e Hash, B+tree, R+tree).
430 * These constants must be passed as the first argument to [unqlite_kv_config()].
431 * Each options require a variable number of arguments.
432 * The [unqlite_kv_config()] interface will return UNQLITE_OK on success, any other return
433 * value indicates failure.
434 * For a full discussion on the configuration verbs and their expected parameters, please
435 * refer to this page:
436 * http://unqlite.org/c_api/unqlite_kv_config.html
437 */
438#define UNQLITE_KV_CONFIG_HASH_FUNC 1 /* ONE ARGUMENT: unsigned int (*xHash)(const void *,unsigned int) */
439#define UNQLITE_KV_CONFIG_CMP_FUNC 2 /* ONE ARGUMENT: int (*xCmp)(const void *,const void *,unsigned int) */
440/*
441 * Global Library Configuration Commands.
442 *
443 * The following set of constants are the available configuration verbs that can
444 * be used by the host-application to configure the whole library.
445 * These constants must be passed as the first argument to [unqlite_lib_config()].
446 *
447 * Each options require a variable number of arguments.
448 * The [unqlite_lib_config()] interface will return UNQLITE_OK on success, any other return
449 * value indicates failure.
450 * Notes:
451 * The default configuration is recommended for most applications and so the call to
452 * [unqlite_lib_config()] is usually not necessary. It is provided to support rare
453 * applications with unusual needs.
454 * The [unqlite_lib_config()] interface is not threadsafe. The application must insure that
455 * no other [unqlite_*()] interfaces are invoked by other threads while [unqlite_lib_config()]
456 * is running. Furthermore, [unqlite_lib_config()] may only be invoked prior to library
457 * initialization using [unqlite_lib_init()] or [unqlite_init()] or after shutdown
458 * by [unqlite_lib_shutdown()]. If [unqlite_lib_config()] is called after [unqlite_lib_init()]
459 * or [unqlite_init()] and before [unqlite_lib_shutdown()] then it will return UNQLITE_LOCKED.
460 * For a full discussion on the configuration verbs and their expected parameters, please
461 * refer to this page:
462 * http://unqlite.org/c_api/unqlite_lib.html
463 */
464#define UNQLITE_LIB_CONFIG_USER_MALLOC 1 /* ONE ARGUMENT: const SyMemMethods *pMemMethods */
465#define UNQLITE_LIB_CONFIG_MEM_ERR_CALLBACK 2 /* TWO ARGUMENTS: int (*xMemError)(void *), void *pUserData */
466#define UNQLITE_LIB_CONFIG_USER_MUTEX 3 /* ONE ARGUMENT: const SyMutexMethods *pMutexMethods */
467#define UNQLITE_LIB_CONFIG_THREAD_LEVEL_SINGLE 4 /* NO ARGUMENTS */
468#define UNQLITE_LIB_CONFIG_THREAD_LEVEL_MULTI 5 /* NO ARGUMENTS */
469#define UNQLITE_LIB_CONFIG_VFS 6 /* ONE ARGUMENT: const unqlite_vfs *pVfs */
470#define UNQLITE_LIB_CONFIG_STORAGE_ENGINE 7 /* ONE ARGUMENT: unqlite_kv_methods *pStorage */
471#define UNQLITE_LIB_CONFIG_PAGE_SIZE 8 /* ONE ARGUMENT: int iPageSize */
472/*
473 * These bit values are intended for use in the 3rd parameter to the [unqlite_open()] interface
474 * and in the 4th parameter to the xOpen method of the [unqlite_vfs] object.
475 */
476#define UNQLITE_OPEN_READONLY 0x00000001 /* Read only mode. Ok for [unqlite_open] */
477#define UNQLITE_OPEN_READWRITE 0x00000002 /* Ok for [unqlite_open] */
478#define UNQLITE_OPEN_CREATE 0x00000004 /* Ok for [unqlite_open] */
479#define UNQLITE_OPEN_EXCLUSIVE 0x00000008 /* VFS only */
480#define UNQLITE_OPEN_TEMP_DB 0x00000010 /* VFS only */
481#define UNQLITE_OPEN_NOMUTEX 0x00000020 /* Ok for [unqlite_open] */
482#define UNQLITE_OPEN_OMIT_JOURNALING 0x00000040 /* Omit journaling for this database. Ok for [unqlite_open] */
483#define UNQLITE_OPEN_IN_MEMORY 0x00000080 /* An in memory database. Ok for [unqlite_open]*/
484#define UNQLITE_OPEN_MMAP 0x00000100 /* Obtain a memory view of the whole file. Ok for [unqlite_open] */
485/*
486 * Synchronization Type Flags
487 *
488 * When UnQLite invokes the xSync() method of an [unqlite_io_methods] object it uses
489 * a combination of these integer values as the second argument.
490 *
491 * When the UNQLITE_SYNC_DATAONLY flag is used, it means that the sync operation only
492 * needs to flush data to mass storage. Inode information need not be flushed.
493 * If the lower four bits of the flag equal UNQLITE_SYNC_NORMAL, that means to use normal
494 * fsync() semantics. If the lower four bits equal UNQLITE_SYNC_FULL, that means to use
495 * Mac OS X style fullsync instead of fsync().
496 */
497#define UNQLITE_SYNC_NORMAL 0x00002
498#define UNQLITE_SYNC_FULL 0x00003
499#define UNQLITE_SYNC_DATAONLY 0x00010
500/*
501 * File Locking Levels
502 *
503 * UnQLite uses one of these integer values as the second
504 * argument to calls it makes to the xLock() and xUnlock() methods
505 * of an [unqlite_io_methods] object.
506 */
507#define UNQLITE_LOCK_NONE 0
508#define UNQLITE_LOCK_SHARED 1
509#define UNQLITE_LOCK_RESERVED 2
510#define UNQLITE_LOCK_PENDING 3
511#define UNQLITE_LOCK_EXCLUSIVE 4
512/*
513 * CAPIREF: OS Interface: Open File Handle
514 *
515 * An [unqlite_file] object represents an open file in the [unqlite_vfs] OS interface
516 * layer.
517 * Individual OS interface implementations will want to subclass this object by appending
518 * additional fields for their own use. The pMethods entry is a pointer to an
519 * [unqlite_io_methods] object that defines methods for performing
520 * I/O operations on the open file.
521*/
522typedef struct unqlite_file unqlite_file;
523struct unqlite_file {
524 const unqlite_io_methods *pMethods; /* Methods for an open file. MUST BE FIRST */
525};
526/*
527 * CAPIREF: OS Interface: File Methods Object
528 *
529 * Every file opened by the [unqlite_vfs] xOpen method populates an
530 * [unqlite_file] object (or, more commonly, a subclass of the
531 * [unqlite_file] object) with a pointer to an instance of this object.
532 * This object defines the methods used to perform various operations
533 * against the open file represented by the [unqlite_file] object.
534 *
535 * If the xOpen method sets the unqlite_file.pMethods element
536 * to a non-NULL pointer, then the unqlite_io_methods.xClose method
537 * may be invoked even if the xOpen reported that it failed. The
538 * only way to prevent a call to xClose following a failed xOpen
539 * is for the xOpen to set the unqlite_file.pMethods element to NULL.
540 *
541 * The flags argument to xSync may be one of [UNQLITE_SYNC_NORMAL] or
542 * [UNQLITE_SYNC_FULL]. The first choice is the normal fsync().
543 * The second choice is a Mac OS X style fullsync. The [UNQLITE_SYNC_DATAONLY]
544 * flag may be ORed in to indicate that only the data of the file
545 * and not its inode needs to be synced.
546 *
547 * The integer values to xLock() and xUnlock() are one of
548 *
549 * UNQLITE_LOCK_NONE
550 * UNQLITE_LOCK_SHARED
551 * UNQLITE_LOCK_RESERVED
552 * UNQLITE_LOCK_PENDING
553 * UNQLITE_LOCK_EXCLUSIVE
554 *
555 * xLock() increases the lock. xUnlock() decreases the lock.
556 * The xCheckReservedLock() method checks whether any database connection,
557 * either in this process or in some other process, is holding a RESERVED,
558 * PENDING, or EXCLUSIVE lock on the file. It returns true if such a lock exists
559 * and false otherwise.
560 *
561 * The xSectorSize() method returns the sector size of the device that underlies
562 * the file. The sector size is the minimum write that can be performed without
563 * disturbing other bytes in the file.
564 *
565 */
566struct unqlite_io_methods {
567 int iVersion; /* Structure version number (currently 1) */
568 int (*xClose)(unqlite_file*);
569 int (*xRead)(unqlite_file*, void*, unqlite_int64 iAmt, unqlite_int64 iOfst);
570 int (*xWrite)(unqlite_file*, const void*, unqlite_int64 iAmt, unqlite_int64 iOfst);
571 int (*xTruncate)(unqlite_file*, unqlite_int64 size);
572 int (*xSync)(unqlite_file*, int flags);
573 int (*xFileSize)(unqlite_file*, unqlite_int64 *pSize);
574 int (*xLock)(unqlite_file*, int);
575 int (*xUnlock)(unqlite_file*, int);
576 int (*xCheckReservedLock)(unqlite_file*, int *pResOut);
577 int (*xSectorSize)(unqlite_file*);
578};
579/*
580 * CAPIREF: OS Interface Object
581 *
582 * An instance of the unqlite_vfs object defines the interface between
583 * the UnQLite core and the underlying operating system. The "vfs"
584 * in the name of the object stands for "Virtual File System".
585 *
586 * Only a single vfs can be registered within the UnQLite core.
587 * Vfs registration is done using the [unqlite_lib_config()] interface
588 * with a configuration verb set to UNQLITE_LIB_CONFIG_VFS.
589 * Note that Windows and UNIX (Linux, FreeBSD, Solaris, Mac OS X, etc.) users
590 * does not have to worry about registering and installing a vfs since UnQLite
591 * come with a built-in vfs for these platforms that implements most the methods
592 * defined below.
593 *
594 * Clients running on exotic systems (ie: Other than Windows and UNIX systems)
595 * must register their own vfs in order to be able to use the UnQLite library.
596 *
597 * The value of the iVersion field is initially 1 but may be larger in
598 * future versions of UnQLite.
599 *
600 * The szOsFile field is the size of the subclassed [unqlite_file] structure
601 * used by this VFS. mxPathname is the maximum length of a pathname in this VFS.
602 *
603 * At least szOsFile bytes of memory are allocated by UnQLite to hold the [unqlite_file]
604 * structure passed as the third argument to xOpen. The xOpen method does not have to
605 * allocate the structure; it should just fill it in. Note that the xOpen method must
606 * set the unqlite_file.pMethods to either a valid [unqlite_io_methods] object or to NULL.
607 * xOpen must do this even if the open fails. UnQLite expects that the unqlite_file.pMethods
608 * element will be valid after xOpen returns regardless of the success or failure of the
609 * xOpen call.
610 *
611 */
612struct unqlite_vfs {
613 const char *zName; /* Name of this virtual file system [i.e: Windows, UNIX, etc.] */
614 int iVersion; /* Structure version number (currently 1) */
615 int szOsFile; /* Size of subclassed unqlite_file */
616 int mxPathname; /* Maximum file pathname length */
617 int (*xOpen)(unqlite_vfs*, const char *zName, unqlite_file*,unsigned int flags);
618 int (*xDelete)(unqlite_vfs*, const char *zName, int syncDir);
619 int (*xAccess)(unqlite_vfs*, const char *zName, int flags, int *pResOut);
620 int (*xFullPathname)(unqlite_vfs*, const char *zName,int buf_len,char *zBuf);
621 int (*xTmpDir)(unqlite_vfs*,char *zBuf,int buf_len);
622 int (*xSleep)(unqlite_vfs*, int microseconds);
623 int (*xCurrentTime)(unqlite_vfs*,Sytm *pOut);
624 int (*xGetLastError)(unqlite_vfs*, int, char *);
625};
626/*
627 * Flags for the xAccess VFS method
628 *
629 * These integer constants can be used as the third parameter to
630 * the xAccess method of an [unqlite_vfs] object. They determine
631 * what kind of permissions the xAccess method is looking for.
632 * With UNQLITE_ACCESS_EXISTS, the xAccess method
633 * simply checks whether the file exists.
634 * With UNQLITE_ACCESS_READWRITE, the xAccess method
635 * checks whether the named directory is both readable and writable
636 * (in other words, if files can be added, removed, and renamed within
637 * the directory).
638 * The UNQLITE_ACCESS_READWRITE constant is currently used only by the
639 * [temp_store_directory pragma], though this could change in a future
640 * release of UnQLite.
641 * With UNQLITE_ACCESS_READ, the xAccess method
642 * checks whether the file is readable. The UNQLITE_ACCESS_READ constant is
643 * currently unused, though it might be used in a future release of
644 * UnQLite.
645 */
646#define UNQLITE_ACCESS_EXISTS 0
647#define UNQLITE_ACCESS_READWRITE 1
648#define UNQLITE_ACCESS_READ 2
649/*
650 * The type used to represent a page number. The first page in a file
651 * is called page 1. 0 is used to represent "not a page".
652 * A page number is an unsigned 64-bit integer.
653 */
654typedef sxu64 pgno;
655/*
656 * A database disk page is represented by an instance
657 * of the follwoing structure.
658 */
659typedef struct unqlite_page unqlite_page;
660struct unqlite_page
661{
662 unsigned char *zData; /* Content of this page */
663 void *pUserData; /* Extra content */
664 pgno pgno; /* Page number for this page */
665};
666/*
667 * UnQLite handle to the underlying Key/Value Storage Engine (See below).
668 */
669typedef void * unqlite_kv_handle;
670/*
671 * UnQLite pager IO methods.
672 *
673 * An instance of the following structure define the exported methods of the UnQLite pager
674 * to the underlying Key/Value storage engine.
675 */
676typedef struct unqlite_kv_io unqlite_kv_io;
677struct unqlite_kv_io
678{
679 unqlite_kv_handle pHandle; /* UnQLite handle passed as the first parameter to the
680 * method defined below.
681 */
682 unqlite_kv_methods *pMethods; /* Underlying storage engine */
683 /* Pager methods */
684 int (*xGet)(unqlite_kv_handle,pgno,unqlite_page **);
685 int (*xLookup)(unqlite_kv_handle,pgno,unqlite_page **);
686 int (*xNew)(unqlite_kv_handle,unqlite_page **);
687 int (*xWrite)(unqlite_page *);
688 int (*xDontWrite)(unqlite_page *);
689 int (*xDontJournal)(unqlite_page *);
690 int (*xDontMkHot)(unqlite_page *);
691 int (*xPageRef)(unqlite_page *);
692 int (*xPageUnref)(unqlite_page *);
693 int (*xPageSize)(unqlite_kv_handle);
694 int (*xReadOnly)(unqlite_kv_handle);
695 unsigned char * (*xTmpPage)(unqlite_kv_handle);
696 void (*xSetUnpin)(unqlite_kv_handle,void (*xPageUnpin)(void *));
697 void (*xSetReload)(unqlite_kv_handle,void (*xPageReload)(void *));
698 void (*xErr)(unqlite_kv_handle,const char *);
699};
700/*
701 * Key/Value Storage Engine Cursor Object
702 *
703 * An instance of a subclass of the following object defines a cursor
704 * used to scan through a key-value storage engine.
705 */
706typedef struct unqlite_kv_cursor unqlite_kv_cursor;
707struct unqlite_kv_cursor
708{
709 unqlite_kv_engine *pStore; /* Must be first */
710 /* Subclasses will typically add additional fields */
711};
712/*
713 * Possible seek positions.
714 */
715#define UNQLITE_CURSOR_MATCH_EXACT 1
716#define UNQLITE_CURSOR_MATCH_LE 2
717#define UNQLITE_CURSOR_MATCH_GE 3
718/*
719 * Key/Value Storage Engine.
720 *
721 * A Key-Value storage engine is defined by an instance of the following
722 * object.
723 * UnQLite works with run-time interchangeable storage engines (i.e. Hash, B+Tree, R+Tree, LSM, etc.).
724 * The storage engine works with key/value pairs where both the key
725 * and the value are byte arrays of arbitrary length and with no restrictions on content.
726 * UnQLite come with two built-in KV storage engine: A Virtual Linear Hash (VLH) storage
727 * engine is used for persistent on-disk databases with O(1) lookup time and an in-memory
728 * hash-table or Red-black tree storage engine is used for in-memory databases.
729 * Future versions of UnQLite might add other built-in storage engines (i.e. LSM).
730 * Registration of a Key/Value storage engine at run-time is done via [unqlite_lib_config()]
731 * with a configuration verb set to UNQLITE_LIB_CONFIG_STORAGE_ENGINE.
732 */
733struct unqlite_kv_engine
734{
735 const unqlite_kv_io *pIo; /* IO methods: MUST be first */
736 /* Subclasses will typically add additional fields */
737};
738/*
739 * Key/Value Storage Engine Virtual Method Table.
740 *
741 * Key/Value storage engine methods is defined by an instance of the following
742 * object.
743 * Registration of a Key/Value storage engine at run-time is done via [unqlite_lib_config()]
744 * with a configuration verb set to UNQLITE_LIB_CONFIG_STORAGE_ENGINE.
745 */
746struct unqlite_kv_methods
747{
748 const char *zName; /* Storage engine name [i.e. Hash, B+tree, LSM, R-tree, Mem, etc.]*/
749 int szKv; /* 'unqlite_kv_engine' subclass size */
750 int szCursor; /* 'unqlite_kv_cursor' subclass size */
751 int iVersion; /* Structure version, currently 1 */
752 /* Storage engine methods */
753 int (*xInit)(unqlite_kv_engine *,int iPageSize);
754 void (*xRelease)(unqlite_kv_engine *);
755 int (*xConfig)(unqlite_kv_engine *,int op,va_list ap);
756 int (*xOpen)(unqlite_kv_engine *,pgno);
757 int (*xReplace)(
758 unqlite_kv_engine *,
759 const void *pKey,int nKeyLen,
760 const void *pData,unqlite_int64 nDataLen
761 );
762 int (*xAppend)(
763 unqlite_kv_engine *,
764 const void *pKey,int nKeyLen,
765 const void *pData,unqlite_int64 nDataLen
766 );
767 void (*xCursorInit)(unqlite_kv_cursor *);
768 int (*xSeek)(unqlite_kv_cursor *,const void *pKey,int nByte,int iPos); /* Mandatory */
769 int (*xFirst)(unqlite_kv_cursor *);
770 int (*xLast)(unqlite_kv_cursor *);
771 int (*xValid)(unqlite_kv_cursor *);
772 int (*xNext)(unqlite_kv_cursor *);
773 int (*xPrev)(unqlite_kv_cursor *);
774 int (*xDelete)(unqlite_kv_cursor *);
775 int (*xKeyLength)(unqlite_kv_cursor *,int *);
776 int (*xKey)(unqlite_kv_cursor *,int (*xConsumer)(const void *,unsigned int,void *),void *pUserData);
777 int (*xDataLength)(unqlite_kv_cursor *,unqlite_int64 *);
778 int (*xData)(unqlite_kv_cursor *,int (*xConsumer)(const void *,unsigned int,void *),void *pUserData);
779 void (*xReset)(unqlite_kv_cursor *);
780 void (*xCursorRelease)(unqlite_kv_cursor *);
781};
782/*
783 * UnQLite journal file suffix.
784 */
785#ifndef UNQLITE_JOURNAL_FILE_SUFFIX
786#define UNQLITE_JOURNAL_FILE_SUFFIX "_unqlite_journal"
787#endif
788/*
789 * Call Context - Error Message Serverity Level.
790 *
791 * The following constans are the allowed severity level that can
792 * passed as the second argument to the [unqlite_context_throw_error()] or
793 * [unqlite_context_throw_error_format()] interfaces.
794 * Refer to the official documentation for additional information.
795 */
796#define UNQLITE_CTX_ERR 1 /* Call context error such as unexpected number of arguments, invalid types and so on. */
797#define UNQLITE_CTX_WARNING 2 /* Call context Warning */
798#define UNQLITE_CTX_NOTICE 3 /* Call context Notice */
799/*
800 * C-API-REF: Please refer to the official documentation for interfaces
801 * purpose and expected parameters.
802 */
803
804/* Database Engine Handle */
805UNQLITE_APIEXPORT int unqlite_open(unqlite **ppDB,const char *zFilename,unsigned int iMode);
806UNQLITE_APIEXPORT int unqlite_config(unqlite *pDb,int nOp,...);
807UNQLITE_APIEXPORT int unqlite_close(unqlite *pDb);
808
809/* Key/Value (KV) Store Interfaces */
810UNQLITE_APIEXPORT int unqlite_kv_store(unqlite *pDb,const void *pKey,int nKeyLen,const void *pData,unqlite_int64 nDataLen);
811UNQLITE_APIEXPORT int unqlite_kv_append(unqlite *pDb,const void *pKey,int nKeyLen,const void *pData,unqlite_int64 nDataLen);
812UNQLITE_APIEXPORT int unqlite_kv_store_fmt(unqlite *pDb,const void *pKey,int nKeyLen,const char *zFormat,...);
813UNQLITE_APIEXPORT int unqlite_kv_append_fmt(unqlite *pDb,const void *pKey,int nKeyLen,const char *zFormat,...);
814UNQLITE_APIEXPORT int unqlite_kv_fetch(unqlite *pDb,const void *pKey,int nKeyLen,void *pBuf,unqlite_int64 /* in|out */*pBufLen);
815UNQLITE_APIEXPORT int unqlite_kv_fetch_callback(unqlite *pDb,const void *pKey,
816 int nKeyLen,int (*xConsumer)(const void *,unsigned int,void *),void *pUserData);
817UNQLITE_APIEXPORT int unqlite_kv_delete(unqlite *pDb,const void *pKey,int nKeyLen);
818UNQLITE_APIEXPORT int unqlite_kv_config(unqlite *pDb,int iOp,...);
819
820/* Document (JSON) Store Interfaces powered by the Jx9 Scripting Language */
821UNQLITE_APIEXPORT int unqlite_compile(unqlite *pDb,const char *zJx9,int nByte,unqlite_vm **ppOut);
822UNQLITE_APIEXPORT int unqlite_compile_file(unqlite *pDb,const char *zPath,unqlite_vm **ppOut);
823UNQLITE_APIEXPORT int unqlite_vm_config(unqlite_vm *pVm,int iOp,...);
824UNQLITE_APIEXPORT int unqlite_vm_exec(unqlite_vm *pVm);
825UNQLITE_APIEXPORT int unqlite_vm_reset(unqlite_vm *pVm);
826UNQLITE_APIEXPORT int unqlite_vm_release(unqlite_vm *pVm);
827UNQLITE_APIEXPORT int unqlite_vm_dump(unqlite_vm *pVm, int (*xConsumer)(const void *, unsigned int, void *), void *pUserData);
828UNQLITE_APIEXPORT unqlite_value * unqlite_vm_extract_variable(unqlite_vm *pVm,const char *zVarname);
829
830/* Cursor Iterator Interfaces */
831UNQLITE_APIEXPORT int unqlite_kv_cursor_init(unqlite *pDb,unqlite_kv_cursor **ppOut);
832UNQLITE_APIEXPORT int unqlite_kv_cursor_release(unqlite *pDb,unqlite_kv_cursor *pCur);
833UNQLITE_APIEXPORT int unqlite_kv_cursor_seek(unqlite_kv_cursor *pCursor,const void *pKey,int nKeyLen,int iPos);
834UNQLITE_APIEXPORT int unqlite_kv_cursor_first_entry(unqlite_kv_cursor *pCursor);
835UNQLITE_APIEXPORT int unqlite_kv_cursor_last_entry(unqlite_kv_cursor *pCursor);
836UNQLITE_APIEXPORT int unqlite_kv_cursor_valid_entry(unqlite_kv_cursor *pCursor);
837UNQLITE_APIEXPORT int unqlite_kv_cursor_next_entry(unqlite_kv_cursor *pCursor);
838UNQLITE_APIEXPORT int unqlite_kv_cursor_prev_entry(unqlite_kv_cursor *pCursor);
839UNQLITE_APIEXPORT int unqlite_kv_cursor_key(unqlite_kv_cursor *pCursor,void *pBuf,int *pnByte);
840UNQLITE_APIEXPORT int unqlite_kv_cursor_key_callback(unqlite_kv_cursor *pCursor,int (*xConsumer)(const void *,unsigned int,void *),void *pUserData);
841UNQLITE_APIEXPORT int unqlite_kv_cursor_data(unqlite_kv_cursor *pCursor,void *pBuf,unqlite_int64 *pnData);
842UNQLITE_APIEXPORT int unqlite_kv_cursor_data_callback(unqlite_kv_cursor *pCursor,int (*xConsumer)(const void *,unsigned int,void *),void *pUserData);
843UNQLITE_APIEXPORT int unqlite_kv_cursor_delete_entry(unqlite_kv_cursor *pCursor);
844UNQLITE_APIEXPORT int unqlite_kv_cursor_reset(unqlite_kv_cursor *pCursor);
845
846/* Manual Transaction Manager */
847UNQLITE_APIEXPORT int unqlite_begin(unqlite *pDb);
848UNQLITE_APIEXPORT int unqlite_commit(unqlite *pDb);
849UNQLITE_APIEXPORT int unqlite_rollback(unqlite *pDb);
850
851/* Utility interfaces */
852UNQLITE_APIEXPORT int unqlite_util_load_mmaped_file(const char *zFile,void **ppMap,unqlite_int64 *pFileSize);
853UNQLITE_APIEXPORT int unqlite_util_release_mmaped_file(void *pMap,unqlite_int64 iFileSize);
854UNQLITE_APIEXPORT int unqlite_util_random_string(unqlite *pDb,char *zBuf,unsigned int buf_size);
855UNQLITE_APIEXPORT unsigned int unqlite_util_random_num(unqlite *pDb);
856
857/* In-process extending interfaces */
858UNQLITE_APIEXPORT int unqlite_create_function(unqlite_vm *pVm,const char *zName,int (*xFunc)(unqlite_context *,int,unqlite_value **),void *pUserData);
859UNQLITE_APIEXPORT int unqlite_delete_function(unqlite_vm *pVm, const char *zName);
860UNQLITE_APIEXPORT int unqlite_create_constant(unqlite_vm *pVm,const char *zName,void (*xExpand)(unqlite_value *, void *),void *pUserData);
861UNQLITE_APIEXPORT int unqlite_delete_constant(unqlite_vm *pVm, const char *zName);
862
863/* On Demand Object allocation interfaces */
864UNQLITE_APIEXPORT unqlite_value * unqlite_vm_new_scalar(unqlite_vm *pVm);
865UNQLITE_APIEXPORT unqlite_value * unqlite_vm_new_array(unqlite_vm *pVm);
866UNQLITE_APIEXPORT int unqlite_vm_release_value(unqlite_vm *pVm,unqlite_value *pValue);
867UNQLITE_APIEXPORT unqlite_value * unqlite_context_new_scalar(unqlite_context *pCtx);
868UNQLITE_APIEXPORT unqlite_value * unqlite_context_new_array(unqlite_context *pCtx);
869UNQLITE_APIEXPORT void unqlite_context_release_value(unqlite_context *pCtx,unqlite_value *pValue);
870
871/* Dynamically Typed Value Object Management Interfaces */
872UNQLITE_APIEXPORT int unqlite_value_int(unqlite_value *pVal, int iValue);
873UNQLITE_APIEXPORT int unqlite_value_int64(unqlite_value *pVal, unqlite_int64 iValue);
874UNQLITE_APIEXPORT int unqlite_value_bool(unqlite_value *pVal, int iBool);
875UNQLITE_APIEXPORT int unqlite_value_null(unqlite_value *pVal);
876UNQLITE_APIEXPORT int unqlite_value_double(unqlite_value *pVal, double Value);
877UNQLITE_APIEXPORT int unqlite_value_string(unqlite_value *pVal, const char *zString, int nLen);
878UNQLITE_APIEXPORT int unqlite_value_string_format(unqlite_value *pVal, const char *zFormat,...);
879UNQLITE_APIEXPORT int unqlite_value_reset_string_cursor(unqlite_value *pVal);
880UNQLITE_APIEXPORT int unqlite_value_resource(unqlite_value *pVal, void *pUserData);
881UNQLITE_APIEXPORT int unqlite_value_release(unqlite_value *pVal);
882
883/* Foreign Function Parameter Values */
884UNQLITE_APIEXPORT int unqlite_value_to_int(unqlite_value *pValue);
885UNQLITE_APIEXPORT int unqlite_value_to_bool(unqlite_value *pValue);
886UNQLITE_APIEXPORT unqlite_int64 unqlite_value_to_int64(unqlite_value *pValue);
887UNQLITE_APIEXPORT double unqlite_value_to_double(unqlite_value *pValue);
888UNQLITE_APIEXPORT const char * unqlite_value_to_string(unqlite_value *pValue, int *pLen);
889UNQLITE_APIEXPORT void * unqlite_value_to_resource(unqlite_value *pValue);
890UNQLITE_APIEXPORT int unqlite_value_compare(unqlite_value *pLeft, unqlite_value *pRight, int bStrict);
891
892/* Setting The Result Of A Foreign Function */
893UNQLITE_APIEXPORT int unqlite_result_int(unqlite_context *pCtx, int iValue);
894UNQLITE_APIEXPORT int unqlite_result_int64(unqlite_context *pCtx, unqlite_int64 iValue);
895UNQLITE_APIEXPORT int unqlite_result_bool(unqlite_context *pCtx, int iBool);
896UNQLITE_APIEXPORT int unqlite_result_double(unqlite_context *pCtx, double Value);
897UNQLITE_APIEXPORT int unqlite_result_null(unqlite_context *pCtx);
898UNQLITE_APIEXPORT int unqlite_result_string(unqlite_context *pCtx, const char *zString, int nLen);
899UNQLITE_APIEXPORT int unqlite_result_string_format(unqlite_context *pCtx, const char *zFormat, ...);
900UNQLITE_APIEXPORT int unqlite_result_value(unqlite_context *pCtx, unqlite_value *pValue);
901UNQLITE_APIEXPORT int unqlite_result_resource(unqlite_context *pCtx, void *pUserData);
902
903/* Dynamically Typed Value Object Query Interfaces */
904UNQLITE_APIEXPORT int unqlite_value_is_int(unqlite_value *pVal);
905UNQLITE_APIEXPORT int unqlite_value_is_float(unqlite_value *pVal);
906UNQLITE_APIEXPORT int unqlite_value_is_bool(unqlite_value *pVal);
907UNQLITE_APIEXPORT int unqlite_value_is_string(unqlite_value *pVal);
908UNQLITE_APIEXPORT int unqlite_value_is_null(unqlite_value *pVal);
909UNQLITE_APIEXPORT int unqlite_value_is_numeric(unqlite_value *pVal);
910UNQLITE_APIEXPORT int unqlite_value_is_callable(unqlite_value *pVal);
911UNQLITE_APIEXPORT int unqlite_value_is_scalar(unqlite_value *pVal);
912UNQLITE_APIEXPORT int unqlite_value_is_json_array(unqlite_value *pVal);
913UNQLITE_APIEXPORT int unqlite_value_is_json_object(unqlite_value *pVal);
914UNQLITE_APIEXPORT int unqlite_value_is_resource(unqlite_value *pVal);
915UNQLITE_APIEXPORT int unqlite_value_is_empty(unqlite_value *pVal);
916
917/* JSON Array/Object Management Interfaces */
918UNQLITE_APIEXPORT unqlite_value * unqlite_array_fetch(unqlite_value *pArray, const char *zKey, int nByte);
919UNQLITE_APIEXPORT int unqlite_array_walk(unqlite_value *pArray, int (*xWalk)(unqlite_value *, unqlite_value *, void *), void *pUserData);
920UNQLITE_APIEXPORT int unqlite_array_add_elem(unqlite_value *pArray, unqlite_value *pKey, unqlite_value *pValue);
921UNQLITE_APIEXPORT int unqlite_array_add_strkey_elem(unqlite_value *pArray, const char *zKey, unqlite_value *pValue);
922UNQLITE_APIEXPORT int unqlite_array_count(unqlite_value *pArray);
923
924/* Call Context Handling Interfaces */
925UNQLITE_APIEXPORT int unqlite_context_output(unqlite_context *pCtx, const char *zString, int nLen);
926UNQLITE_APIEXPORT int unqlite_context_output_format(unqlite_context *pCtx,const char *zFormat, ...);
927UNQLITE_APIEXPORT int unqlite_context_throw_error(unqlite_context *pCtx, int iErr, const char *zErr);
928UNQLITE_APIEXPORT int unqlite_context_throw_error_format(unqlite_context *pCtx, int iErr, const char *zFormat, ...);
929UNQLITE_APIEXPORT unsigned int unqlite_context_random_num(unqlite_context *pCtx);
930UNQLITE_APIEXPORT int unqlite_context_random_string(unqlite_context *pCtx, char *zBuf, int nBuflen);
931UNQLITE_APIEXPORT void * unqlite_context_user_data(unqlite_context *pCtx);
932UNQLITE_APIEXPORT int unqlite_context_push_aux_data(unqlite_context *pCtx, void *pUserData);
933UNQLITE_APIEXPORT void * unqlite_context_peek_aux_data(unqlite_context *pCtx);
934UNQLITE_APIEXPORT unsigned int unqlite_context_result_buf_length(unqlite_context *pCtx);
935UNQLITE_APIEXPORT const char * unqlite_function_name(unqlite_context *pCtx);
936
937/* Call Context Memory Management Interfaces */
938UNQLITE_APIEXPORT void * unqlite_context_alloc_chunk(unqlite_context *pCtx,unsigned int nByte,int ZeroChunk,int AutoRelease);
939UNQLITE_APIEXPORT void * unqlite_context_realloc_chunk(unqlite_context *pCtx,void *pChunk,unsigned int nByte);
940UNQLITE_APIEXPORT void unqlite_context_free_chunk(unqlite_context *pCtx,void *pChunk);
941
942/* Global Library Management Interfaces */
943UNQLITE_APIEXPORT int unqlite_lib_config(int nConfigOp,...);
944UNQLITE_APIEXPORT int unqlite_lib_init(void);
945UNQLITE_APIEXPORT int unqlite_lib_shutdown(void);
946UNQLITE_APIEXPORT int unqlite_lib_is_threadsafe(void);
947UNQLITE_APIEXPORT const char * unqlite_lib_version(void);
948UNQLITE_APIEXPORT const char * unqlite_lib_signature(void);
949UNQLITE_APIEXPORT const char * unqlite_lib_ident(void);
950UNQLITE_APIEXPORT const char * unqlite_lib_copyright(void);
951#ifdef __cplusplus
952}
953#endif /* __cplusplus */
954#endif /* _UNQLITE_H_ */