diff options
Diffstat (limited to 'common/unqlite/jx9.h')
-rw-r--r-- | common/unqlite/jx9.h | 462 |
1 files changed, 462 insertions, 0 deletions
diff --git a/common/unqlite/jx9.h b/common/unqlite/jx9.h new file mode 100644 index 0000000..399cd9c --- /dev/null +++ b/common/unqlite/jx9.h | |||
@@ -0,0 +1,462 @@ | |||
1 | /* This file was automatically generated. Do not edit (except for compile time directive)! */ | ||
2 | #ifndef _JX9H_ | ||
3 | #define _JX9H_ | ||
4 | /* | ||
5 | * Symisc Jx9: A Highly Efficient Embeddable Scripting Engine Based on JSON. | ||
6 | * Copyright (C) 2012-2013, Symisc Systems http://jx9.symisc.net/ | ||
7 | * Version 1.7.2 | ||
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://jx9.symisc.net/ | ||
15 | */ | ||
16 | /* | ||
17 | * Copyright (C) 2012, 2013 Symisc Systems. All rights reserved. | ||
18 | * | ||
19 | * Redistribution and use in source and binary forms, with or without | ||
20 | * modification, are permitted provided that the following conditions | ||
21 | * are met: | ||
22 | * 1. Redistributions of source code must retain the above copyright | ||
23 | * notice, this list of conditions and the following disclaimer. | ||
24 | * 2. Redistributions in binary form must reproduce the above copyright | ||
25 | * notice, this list of conditions and the following disclaimer in the | ||
26 | * documentation and/or other materials provided with the distribution. | ||
27 | * 3. Redistributions in any form must be accompanied by information on | ||
28 | * how to obtain complete source code for the JX9 engine and any | ||
29 | * accompanying software that uses the JX9 engine software. | ||
30 | * The source code must either be included in the distribution | ||
31 | * or be available for no more than the cost of distribution plus | ||
32 | * a nominal fee, and must be freely redistributable under reasonable | ||
33 | * conditions. For an executable file, complete source code means | ||
34 | * the source code for all modules it contains.It does not include | ||
35 | * source code for modules or files that typically accompany the major | ||
36 | * components of the operating system on which the executable file runs. | ||
37 | * | ||
38 | * THIS SOFTWARE IS PROVIDED BY SYMISC SYSTEMS ``AS IS'' AND ANY EXPRESS | ||
39 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
40 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR | ||
41 | * NON-INFRINGEMENT, ARE DISCLAIMED. IN NO EVENT SHALL SYMISC SYSTEMS | ||
42 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
43 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
44 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR | ||
45 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | ||
46 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE | ||
47 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN | ||
48 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
49 | */ | ||
50 | /* $SymiscID: jx9.h v2.1 UNIX|WIN32/64 2012-09-15 09:43 stable <chm@symisc.net> $ */ | ||
51 | #include "unqlite.h" | ||
52 | /* | ||
53 | * Compile time engine version, signature, identification in the symisc source tree | ||
54 | * and copyright notice. | ||
55 | * Each macro have an equivalent C interface associated with it that provide the same | ||
56 | * information but are associated with the library instead of the header file. | ||
57 | * Refer to [jx9_lib_version()], [jx9_lib_signature()], [jx9_lib_ident()] and | ||
58 | * [jx9_lib_copyright()] for more information. | ||
59 | */ | ||
60 | /* | ||
61 | * The JX9_VERSION C preprocessor macroevaluates to a string literal | ||
62 | * that is the jx9 version in the format "X.Y.Z" where X is the major | ||
63 | * version number and Y is the minor version number and Z is the release | ||
64 | * number. | ||
65 | */ | ||
66 | #define JX9_VERSION "1.7.2" | ||
67 | /* | ||
68 | * The JX9_VERSION_NUMBER C preprocessor macro resolves to an integer | ||
69 | * with the value (X*1000000 + Y*1000 + Z) where X, Y, and Z are the same | ||
70 | * numbers used in [JX9_VERSION]. | ||
71 | */ | ||
72 | #define JX9_VERSION_NUMBER 1007002 | ||
73 | /* | ||
74 | * The JX9_SIG C preprocessor macro evaluates to a string | ||
75 | * literal which is the public signature of the jx9 engine. | ||
76 | * This signature could be included for example in a host-application | ||
77 | * generated Server MIME header as follows: | ||
78 | * Server: YourWebServer/x.x Jx9/x.x.x \r\n | ||
79 | */ | ||
80 | #define JX9_SIG "Jx9/1.7.2" | ||
81 | /* | ||
82 | * JX9 identification in the Symisc source tree: | ||
83 | * Each particular check-in of a particular software released | ||
84 | * by symisc systems have an unique identifier associated with it. | ||
85 | * This macro hold the one associated with jx9. | ||
86 | */ | ||
87 | #define JX9_IDENT "jx9:d217a6e8c7f10fb35a8becb2793101fd2036aeb7" | ||
88 | /* | ||
89 | * Copyright notice. | ||
90 | * If you have any questions about the licensing situation, please | ||
91 | * visit http://jx9.symisc.net/licensing.html | ||
92 | * or contact Symisc Systems via: | ||
93 | * legal@symisc.net | ||
94 | * licensing@symisc.net | ||
95 | * contact@symisc.net | ||
96 | */ | ||
97 | #define JX9_COPYRIGHT "Copyright (C) Symisc Systems 2012-2013, http://jx9.symisc.net/" | ||
98 | |||
99 | /* Forward declaration to public objects */ | ||
100 | typedef struct jx9_io_stream jx9_io_stream; | ||
101 | typedef struct jx9_context jx9_context; | ||
102 | typedef struct jx9_value jx9_value; | ||
103 | typedef struct jx9_vfs jx9_vfs; | ||
104 | typedef struct jx9_vm jx9_vm; | ||
105 | typedef struct jx9 jx9; | ||
106 | |||
107 | #include "unqlite.h" | ||
108 | |||
109 | #if !defined( UNQLITE_ENABLE_JX9_HASH_FUNC ) | ||
110 | #define JX9_DISABLE_HASH_FUNC | ||
111 | #endif /* UNQLITE_ENABLE_JX9_HASH_FUNC */ | ||
112 | #ifdef UNQLITE_ENABLE_THREADS | ||
113 | #define JX9_ENABLE_THREADS | ||
114 | #endif /* UNQLITE_ENABLE_THREADS */ | ||
115 | /* Standard JX9 return values */ | ||
116 | #define JX9_OK SXRET_OK /* Successful result */ | ||
117 | /* beginning-of-error-codes */ | ||
118 | #define JX9_NOMEM UNQLITE_NOMEM /* Out of memory */ | ||
119 | #define JX9_ABORT UNQLITE_ABORT /* Foreign Function request operation abort/Another thread have released this instance */ | ||
120 | #define JX9_IO_ERR UNQLITE_IOERR /* IO error */ | ||
121 | #define JX9_CORRUPT UNQLITE_CORRUPT /* Corrupt pointer/Unknown configuration option */ | ||
122 | #define JX9_LOOKED UNQLITE_LOCKED /* Forbidden Operation */ | ||
123 | #define JX9_COMPILE_ERR UNQLITE_COMPILE_ERR /* Compilation error */ | ||
124 | #define JX9_VM_ERR UNQLITE_VM_ERR /* Virtual machine error */ | ||
125 | /* end-of-error-codes */ | ||
126 | /* | ||
127 | * If compiling for a processor that lacks floating point | ||
128 | * support, substitute integer for floating-point. | ||
129 | */ | ||
130 | #ifdef JX9_OMIT_FLOATING_POINT | ||
131 | typedef sxi64 jx9_real; | ||
132 | #else | ||
133 | typedef double jx9_real; | ||
134 | #endif | ||
135 | typedef sxi64 jx9_int64; | ||
136 | /* | ||
137 | * Engine Configuration Commands. | ||
138 | * | ||
139 | * The following set of constants are the available configuration verbs that can | ||
140 | * be used by the host-application to configure the JX9 engine. | ||
141 | * These constants must be passed as the second argument to the [jx9_config()] | ||
142 | * interface. | ||
143 | * Each options require a variable number of arguments. | ||
144 | * The [jx9_config()] interface will return JX9_OK on success, any other | ||
145 | * return value indicates failure. | ||
146 | * For a full discussion on the configuration verbs and their expected | ||
147 | * parameters, please refer to this page: | ||
148 | * http://jx9.symisc.net/c_api_func.html#jx9_config | ||
149 | */ | ||
150 | #define JX9_CONFIG_ERR_ABORT 1 /* RESERVED FOR FUTURE USE */ | ||
151 | #define JX9_CONFIG_ERR_LOG 2 /* TWO ARGUMENTS: const char **pzBuf, int *pLen */ | ||
152 | /* | ||
153 | * Virtual Machine Configuration Commands. | ||
154 | * | ||
155 | * The following set of constants are the available configuration verbs that can | ||
156 | * be used by the host-application to configure the JX9 Virtual machine. | ||
157 | * These constants must be passed as the second argument to the [jx9_vm_config()] | ||
158 | * interface. | ||
159 | * Each options require a variable number of arguments. | ||
160 | * The [jx9_vm_config()] interface will return JX9_OK on success, any other return | ||
161 | * value indicates failure. | ||
162 | * There are many options but the most importants are: JX9_VM_CONFIG_OUTPUT which install | ||
163 | * a VM output consumer callback, JX9_VM_CONFIG_HTTP_REQUEST which parse and register | ||
164 | * a HTTP request and JX9_VM_CONFIG_ARGV_ENTRY which populate the $argv array. | ||
165 | * For a full discussion on the configuration verbs and their expected parameters, please | ||
166 | * refer to this page: | ||
167 | * http://jx9.symisc.net/c_api_func.html#jx9_vm_config | ||
168 | */ | ||
169 | #define JX9_VM_CONFIG_OUTPUT UNQLITE_VM_CONFIG_OUTPUT /* TWO ARGUMENTS: int (*xConsumer)(const void *pOut, unsigned int nLen, void *pUserData), void *pUserData */ | ||
170 | #define JX9_VM_CONFIG_IMPORT_PATH UNQLITE_VM_CONFIG_IMPORT_PATH /* ONE ARGUMENT: const char *zIncludePath */ | ||
171 | #define JX9_VM_CONFIG_ERR_REPORT UNQLITE_VM_CONFIG_ERR_REPORT /* NO ARGUMENTS: Report all run-time errors in the VM output */ | ||
172 | #define JX9_VM_CONFIG_RECURSION_DEPTH UNQLITE_VM_CONFIG_RECURSION_DEPTH /* ONE ARGUMENT: int nMaxDepth */ | ||
173 | #define JX9_VM_OUTPUT_LENGTH UNQLITE_VM_OUTPUT_LENGTH /* ONE ARGUMENT: unsigned int *pLength */ | ||
174 | #define JX9_VM_CONFIG_CREATE_VAR UNQLITE_VM_CONFIG_CREATE_VAR /* TWO ARGUMENTS: const char *zName, jx9_value *pValue */ | ||
175 | #define JX9_VM_CONFIG_HTTP_REQUEST UNQLITE_VM_CONFIG_HTTP_REQUEST /* TWO ARGUMENTS: const char *zRawRequest, int nRequestLength */ | ||
176 | #define JX9_VM_CONFIG_SERVER_ATTR UNQLITE_VM_CONFIG_SERVER_ATTR /* THREE ARGUMENTS: const char *zKey, const char *zValue, int nLen */ | ||
177 | #define JX9_VM_CONFIG_ENV_ATTR UNQLITE_VM_CONFIG_ENV_ATTR /* THREE ARGUMENTS: const char *zKey, const char *zValue, int nLen */ | ||
178 | #define JX9_VM_CONFIG_EXEC_VALUE UNQLITE_VM_CONFIG_EXEC_VALUE /* ONE ARGUMENT: jx9_value **ppValue */ | ||
179 | #define JX9_VM_CONFIG_IO_STREAM UNQLITE_VM_CONFIG_IO_STREAM /* ONE ARGUMENT: const jx9_io_stream *pStream */ | ||
180 | #define JX9_VM_CONFIG_ARGV_ENTRY UNQLITE_VM_CONFIG_ARGV_ENTRY /* ONE ARGUMENT: const char *zValue */ | ||
181 | #define JX9_VM_CONFIG_EXTRACT_OUTPUT UNQLITE_VM_CONFIG_EXTRACT_OUTPUT /* TWO ARGUMENTS: const void **ppOut, unsigned int *pOutputLen */ | ||
182 | /* | ||
183 | * Global Library Configuration Commands. | ||
184 | * | ||
185 | * The following set of constants are the available configuration verbs that can | ||
186 | * be used by the host-application to configure the whole library. | ||
187 | * These constants must be passed as the first argument to the [jx9_lib_config()] | ||
188 | * interface. | ||
189 | * Each options require a variable number of arguments. | ||
190 | * The [jx9_lib_config()] interface will return JX9_OK on success, any other return | ||
191 | * value indicates failure. | ||
192 | * Notes: | ||
193 | * The default configuration is recommended for most applications and so the call to | ||
194 | * [jx9_lib_config()] is usually not necessary. It is provided to support rare | ||
195 | * applications with unusual needs. | ||
196 | * The [jx9_lib_config()] interface is not threadsafe. The application must insure that | ||
197 | * no other [jx9_*()] interfaces are invoked by other threads while [jx9_lib_config()] | ||
198 | * is running. Furthermore, [jx9_lib_config()] may only be invoked prior to library | ||
199 | * initialization using [jx9_lib_init()] or [jx9_init()] or after shutdown | ||
200 | * by [jx9_lib_shutdown()]. If [jx9_lib_config()] is called after [jx9_lib_init()] | ||
201 | * or [jx9_init()] and before [jx9_lib_shutdown()] then it will return jx9LOCKED. | ||
202 | * For a full discussion on the configuration verbs and their expected parameters, please | ||
203 | * refer to this page: | ||
204 | * http://jx9.symisc.net/c_api_func.html#Global_Library_Management_Interfaces | ||
205 | */ | ||
206 | #define JX9_LIB_CONFIG_USER_MALLOC 1 /* ONE ARGUMENT: const SyMemMethods *pMemMethods */ | ||
207 | #define JX9_LIB_CONFIG_MEM_ERR_CALLBACK 2 /* TWO ARGUMENTS: int (*xMemError)(void *), void *pUserData */ | ||
208 | #define JX9_LIB_CONFIG_USER_MUTEX 3 /* ONE ARGUMENT: const SyMutexMethods *pMutexMethods */ | ||
209 | #define JX9_LIB_CONFIG_THREAD_LEVEL_SINGLE 4 /* NO ARGUMENTS */ | ||
210 | #define JX9_LIB_CONFIG_THREAD_LEVEL_MULTI 5 /* NO ARGUMENTS */ | ||
211 | #define JX9_LIB_CONFIG_VFS 6 /* ONE ARGUMENT: const jx9_vfs *pVfs */ | ||
212 | /* | ||
213 | * Call Context - Error Message Serverity Level. | ||
214 | */ | ||
215 | #define JX9_CTX_ERR UNQLITE_CTX_ERR /* Call context error such as unexpected number of arguments, invalid types and so on. */ | ||
216 | #define JX9_CTX_WARNING UNQLITE_CTX_WARNING /* Call context Warning */ | ||
217 | #define JX9_CTX_NOTICE UNQLITE_CTX_NOTICE /* Call context Notice */ | ||
218 | /* Current VFS structure version*/ | ||
219 | #define JX9_VFS_VERSION 2 | ||
220 | /* | ||
221 | * JX9 Virtual File System (VFS). | ||
222 | * | ||
223 | * An instance of the jx9_vfs object defines the interface between the JX9 core | ||
224 | * and the underlying operating system. The "vfs" in the name of the object stands | ||
225 | * for "virtual file system". The vfs is used to implement JX9 system functions | ||
226 | * such as mkdir(), chdir(), stat(), get_user_name() and many more. | ||
227 | * The value of the iVersion field is initially 2 but may be larger in future versions | ||
228 | * of JX9. | ||
229 | * Additional fields may be appended to this object when the iVersion value is increased. | ||
230 | * Only a single vfs can be registered within the JX9 core. Vfs registration is done | ||
231 | * using the jx9_lib_config() interface with a configuration verb set to JX9_LIB_CONFIG_VFS. | ||
232 | * Note that Windows and UNIX (Linux, FreeBSD, Solaris, Mac OS X, etc.) users does not have to | ||
233 | * worry about registering and installing a vfs since JX9 come with a built-in vfs for these | ||
234 | * platforms which implement most the methods defined below. | ||
235 | * Host-application running on exotic systems (ie: Other than Windows and UNIX systems) must | ||
236 | * register their own vfs in order to be able to use and call JX9 system functions. | ||
237 | * Also note that the jx9_compile_file() interface depend on the xMmap() method of the underlying | ||
238 | * vfs which mean that this method must be available (Always the case using the built-in VFS) | ||
239 | * in order to use this interface. | ||
240 | * Developers wishing to implement their own vfs an contact symisc systems to obtain | ||
241 | * the JX9 VFS C/C++ Specification manual. | ||
242 | */ | ||
243 | struct jx9_vfs | ||
244 | { | ||
245 | const char *zName; /* Underlying VFS name [i.e: FreeBSD/Linux/Windows...] */ | ||
246 | int iVersion; /* Current VFS structure version [default 2] */ | ||
247 | /* Directory functions */ | ||
248 | int (*xChdir)(const char *); /* Change directory */ | ||
249 | int (*xChroot)(const char *); /* Change the root directory */ | ||
250 | int (*xGetcwd)(jx9_context *); /* Get the current working directory */ | ||
251 | int (*xMkdir)(const char *, int, int); /* Make directory */ | ||
252 | int (*xRmdir)(const char *); /* Remove directory */ | ||
253 | int (*xIsdir)(const char *); /* Tells whether the filename is a directory */ | ||
254 | int (*xRename)(const char *, const char *); /* Renames a file or directory */ | ||
255 | int (*xRealpath)(const char *, jx9_context *); /* Return canonicalized absolute pathname*/ | ||
256 | /* Systems functions */ | ||
257 | int (*xSleep)(unsigned int); /* Delay execution in microseconds */ | ||
258 | int (*xUnlink)(const char *); /* Deletes a file */ | ||
259 | int (*xFileExists)(const char *); /* Checks whether a file or directory exists */ | ||
260 | int (*xChmod)(const char *, int); /* Changes file mode */ | ||
261 | int (*xChown)(const char *, const char *); /* Changes file owner */ | ||
262 | int (*xChgrp)(const char *, const char *); /* Changes file group */ | ||
263 | jx9_int64 (*xFreeSpace)(const char *); /* Available space on filesystem or disk partition */ | ||
264 | jx9_int64 (*xTotalSpace)(const char *); /* Total space on filesystem or disk partition */ | ||
265 | jx9_int64 (*xFileSize)(const char *); /* Gets file size */ | ||
266 | jx9_int64 (*xFileAtime)(const char *); /* Gets last access time of file */ | ||
267 | jx9_int64 (*xFileMtime)(const char *); /* Gets file modification time */ | ||
268 | jx9_int64 (*xFileCtime)(const char *); /* Gets inode change time of file */ | ||
269 | int (*xStat)(const char *, jx9_value *, jx9_value *); /* Gives information about a file */ | ||
270 | int (*xlStat)(const char *, jx9_value *, jx9_value *); /* Gives information about a file */ | ||
271 | int (*xIsfile)(const char *); /* Tells whether the filename is a regular file */ | ||
272 | int (*xIslink)(const char *); /* Tells whether the filename is a symbolic link */ | ||
273 | int (*xReadable)(const char *); /* Tells whether a file exists and is readable */ | ||
274 | int (*xWritable)(const char *); /* Tells whether the filename is writable */ | ||
275 | int (*xExecutable)(const char *); /* Tells whether the filename is executable */ | ||
276 | int (*xFiletype)(const char *, jx9_context *); /* Gets file type [i.e: fifo, dir, file..] */ | ||
277 | int (*xGetenv)(const char *, jx9_context *); /* Gets the value of an environment variable */ | ||
278 | int (*xSetenv)(const char *, const char *); /* Sets the value of an environment variable */ | ||
279 | int (*xTouch)(const char *, jx9_int64, jx9_int64); /* Sets access and modification time of file */ | ||
280 | int (*xMmap)(const char *, void **, jx9_int64 *); /* Read-only memory map of the whole file */ | ||
281 | void (*xUnmap)(void *, jx9_int64); /* Unmap a memory view */ | ||
282 | int (*xLink)(const char *, const char *, int); /* Create hard or symbolic link */ | ||
283 | int (*xUmask)(int); /* Change the current umask */ | ||
284 | void (*xTempDir)(jx9_context *); /* Get path of the temporary directory */ | ||
285 | unsigned int (*xProcessId)(void); /* Get running process ID */ | ||
286 | int (*xUid)(void); /* user ID of the process */ | ||
287 | int (*xGid)(void); /* group ID of the process */ | ||
288 | void (*xUsername)(jx9_context *); /* Running username */ | ||
289 | int (*xExec)(const char *, jx9_context *); /* Execute an external program */ | ||
290 | }; | ||
291 | /* Current JX9 IO stream structure version. */ | ||
292 | #define JX9_IO_STREAM_VERSION 1 | ||
293 | /* | ||
294 | * Possible open mode flags that can be passed to the xOpen() routine | ||
295 | * of the underlying IO stream device . | ||
296 | * Refer to the JX9 IO Stream C/C++ specification manual (http://jx9.symisc.net/io_stream_spec.html) | ||
297 | * for additional information. | ||
298 | */ | ||
299 | #define JX9_IO_OPEN_RDONLY 0x001 /* Read-only open */ | ||
300 | #define JX9_IO_OPEN_WRONLY 0x002 /* Write-only open */ | ||
301 | #define JX9_IO_OPEN_RDWR 0x004 /* Read-write open. */ | ||
302 | #define JX9_IO_OPEN_CREATE 0x008 /* If the file does not exist it will be created */ | ||
303 | #define JX9_IO_OPEN_TRUNC 0x010 /* Truncate the file to zero length */ | ||
304 | #define JX9_IO_OPEN_APPEND 0x020 /* Append mode.The file offset is positioned at the end of the file */ | ||
305 | #define JX9_IO_OPEN_EXCL 0x040 /* Ensure that this call creates the file, the file must not exist before */ | ||
306 | #define JX9_IO_OPEN_BINARY 0x080 /* Simple hint: Data is binary */ | ||
307 | #define JX9_IO_OPEN_TEMP 0x100 /* Simple hint: Temporary file */ | ||
308 | #define JX9_IO_OPEN_TEXT 0x200 /* Simple hint: Data is textual */ | ||
309 | /* | ||
310 | * JX9 IO Stream Device. | ||
311 | * | ||
312 | * An instance of the jx9_io_stream object defines the interface between the JX9 core | ||
313 | * and the underlying stream device. | ||
314 | * A stream is a smart mechanism for generalizing file, network, data compression | ||
315 | * and other IO operations which share a common set of functions using an abstracted | ||
316 | * unified interface. | ||
317 | * A stream device is additional code which tells the stream how to handle specific | ||
318 | * protocols/encodings. For example, the http device knows how to translate a URL | ||
319 | * into an HTTP/1.1 request for a file on a remote server. | ||
320 | * JX9 come with two built-in IO streams device: | ||
321 | * The file:// stream which perform very efficient disk IO and the jx9:// stream | ||
322 | * which is a special stream that allow access various I/O streams (See the JX9 official | ||
323 | * documentation for more information on this stream). | ||
324 | * A stream is referenced as: scheme://target | ||
325 | * scheme(string) - The name of the wrapper to be used. Examples include: file, http, https, ftp, | ||
326 | * ftps, compress.zlib, compress.bz2, and jx9. If no wrapper is specified, the function default | ||
327 | * is used (typically file://). | ||
328 | * target - Depends on the device used. For filesystem related streams this is typically a path | ||
329 | * and filename of the desired file.For network related streams this is typically a hostname, often | ||
330 | * with a path appended. | ||
331 | * IO stream devices are registered using a call to jx9_vm_config() with a configuration verb | ||
332 | * set to JX9_VM_CONFIG_IO_STREAM. | ||
333 | * Currently the JX9 development team is working on the implementation of the http:// and ftp:// | ||
334 | * IO stream protocols. These devices will be available in the next major release of the JX9 engine. | ||
335 | * Developers wishing to implement their own IO stream devices must understand and follow | ||
336 | * The JX9 IO Stream C/C++ specification manual (http://jx9.symisc.net/io_stream_spec.html). | ||
337 | */ | ||
338 | struct jx9_io_stream | ||
339 | { | ||
340 | const char *zName; /* Underlying stream name [i.e: file/http/zip/jx9, ..] */ | ||
341 | int iVersion; /* IO stream structure version [default 1]*/ | ||
342 | int (*xOpen)(const char *, int, jx9_value *, void **); /* Open handle*/ | ||
343 | int (*xOpenDir)(const char *, jx9_value *, void **); /* Open directory handle */ | ||
344 | void (*xClose)(void *); /* Close file handle */ | ||
345 | void (*xCloseDir)(void *); /* Close directory handle */ | ||
346 | jx9_int64 (*xRead)(void *, void *, jx9_int64); /* Read from the open stream */ | ||
347 | int (*xReadDir)(void *, jx9_context *); /* Read entry from directory handle */ | ||
348 | jx9_int64 (*xWrite)(void *, const void *, jx9_int64); /* Write to the open stream */ | ||
349 | int (*xSeek)(void *, jx9_int64, int); /* Seek on the open stream */ | ||
350 | int (*xLock)(void *, int); /* Lock/Unlock the open stream */ | ||
351 | void (*xRewindDir)(void *); /* Rewind directory handle */ | ||
352 | jx9_int64 (*xTell)(void *); /* Current position of the stream read/write pointer */ | ||
353 | int (*xTrunc)(void *, jx9_int64); /* Truncates the open stream to a given length */ | ||
354 | int (*xSync)(void *); /* Flush open stream data */ | ||
355 | int (*xStat)(void *, jx9_value *, jx9_value *); /* Stat an open stream handle */ | ||
356 | }; | ||
357 | /* | ||
358 | * C-API-REF: Please refer to the official documentation for interfaces | ||
359 | * purpose and expected parameters. | ||
360 | */ | ||
361 | /* Engine Handling Interfaces */ | ||
362 | JX9_PRIVATE int jx9_init(jx9 **ppEngine); | ||
363 | /*JX9_PRIVATE int jx9_config(jx9 *pEngine, int nConfigOp, ...);*/ | ||
364 | JX9_PRIVATE int jx9_release(jx9 *pEngine); | ||
365 | /* Compile Interfaces */ | ||
366 | JX9_PRIVATE int jx9_compile(jx9 *pEngine, const char *zSource, int nLen, jx9_vm **ppOutVm); | ||
367 | JX9_PRIVATE int jx9_compile_file(jx9 *pEngine, const char *zFilePath, jx9_vm **ppOutVm); | ||
368 | /* Virtual Machine Handling Interfaces */ | ||
369 | JX9_PRIVATE int jx9_vm_config(jx9_vm *pVm, int iConfigOp, ...); | ||
370 | /*JX9_PRIVATE int jx9_vm_exec(jx9_vm *pVm, int *pExitStatus);*/ | ||
371 | /*JX9_PRIVATE jx9_value * jx9_vm_extract_variable(jx9_vm *pVm,const char *zVarname);*/ | ||
372 | /*JX9_PRIVATE int jx9_vm_reset(jx9_vm *pVm);*/ | ||
373 | JX9_PRIVATE int jx9_vm_release(jx9_vm *pVm); | ||
374 | /*JX9_PRIVATE int jx9_vm_dump_v2(jx9_vm *pVm, int (*xConsumer)(const void *, unsigned int, void *), void *pUserData);*/ | ||
375 | /* In-process Extending Interfaces */ | ||
376 | JX9_PRIVATE int jx9_create_function(jx9_vm *pVm, const char *zName, int (*xFunc)(jx9_context *, int, jx9_value **), void *pUserData); | ||
377 | /*JX9_PRIVATE int jx9_delete_function(jx9_vm *pVm, const char *zName);*/ | ||
378 | JX9_PRIVATE int jx9_create_constant(jx9_vm *pVm, const char *zName, void (*xExpand)(jx9_value *, void *), void *pUserData); | ||
379 | /*JX9_PRIVATE int jx9_delete_constant(jx9_vm *pVm, const char *zName);*/ | ||
380 | /* Foreign Function Parameter Values */ | ||
381 | JX9_PRIVATE int jx9_value_to_int(jx9_value *pValue); | ||
382 | JX9_PRIVATE int jx9_value_to_bool(jx9_value *pValue); | ||
383 | JX9_PRIVATE jx9_int64 jx9_value_to_int64(jx9_value *pValue); | ||
384 | JX9_PRIVATE double jx9_value_to_double(jx9_value *pValue); | ||
385 | JX9_PRIVATE const char * jx9_value_to_string(jx9_value *pValue, int *pLen); | ||
386 | JX9_PRIVATE void * jx9_value_to_resource(jx9_value *pValue); | ||
387 | JX9_PRIVATE int jx9_value_compare(jx9_value *pLeft, jx9_value *pRight, int bStrict); | ||
388 | /* Setting The Result Of A Foreign Function */ | ||
389 | JX9_PRIVATE int jx9_result_int(jx9_context *pCtx, int iValue); | ||
390 | JX9_PRIVATE int jx9_result_int64(jx9_context *pCtx, jx9_int64 iValue); | ||
391 | JX9_PRIVATE int jx9_result_bool(jx9_context *pCtx, int iBool); | ||
392 | JX9_PRIVATE int jx9_result_double(jx9_context *pCtx, double Value); | ||
393 | JX9_PRIVATE int jx9_result_null(jx9_context *pCtx); | ||
394 | JX9_PRIVATE int jx9_result_string(jx9_context *pCtx, const char *zString, int nLen); | ||
395 | JX9_PRIVATE int jx9_result_string_format(jx9_context *pCtx, const char *zFormat, ...); | ||
396 | JX9_PRIVATE int jx9_result_value(jx9_context *pCtx, jx9_value *pValue); | ||
397 | JX9_PRIVATE int jx9_result_resource(jx9_context *pCtx, void *pUserData); | ||
398 | /* Call Context Handling Interfaces */ | ||
399 | JX9_PRIVATE int jx9_context_output(jx9_context *pCtx, const char *zString, int nLen); | ||
400 | /*JX9_PRIVATE int jx9_context_output_format(jx9_context *pCtx, const char *zFormat, ...);*/ | ||
401 | JX9_PRIVATE int jx9_context_throw_error(jx9_context *pCtx, int iErr, const char *zErr); | ||
402 | JX9_PRIVATE int jx9_context_throw_error_format(jx9_context *pCtx, int iErr, const char *zFormat, ...); | ||
403 | JX9_PRIVATE unsigned int jx9_context_random_num(jx9_context *pCtx); | ||
404 | JX9_PRIVATE int jx9_context_random_string(jx9_context *pCtx, char *zBuf, int nBuflen); | ||
405 | JX9_PRIVATE void * jx9_context_user_data(jx9_context *pCtx); | ||
406 | JX9_PRIVATE int jx9_context_push_aux_data(jx9_context *pCtx, void *pUserData); | ||
407 | JX9_PRIVATE void * jx9_context_peek_aux_data(jx9_context *pCtx); | ||
408 | JX9_PRIVATE void * jx9_context_pop_aux_data(jx9_context *pCtx); | ||
409 | JX9_PRIVATE unsigned int jx9_context_result_buf_length(jx9_context *pCtx); | ||
410 | JX9_PRIVATE const char * jx9_function_name(jx9_context *pCtx); | ||
411 | /* Call Context Memory Management Interfaces */ | ||
412 | JX9_PRIVATE void * jx9_context_alloc_chunk(jx9_context *pCtx, unsigned int nByte, int ZeroChunk, int AutoRelease); | ||
413 | JX9_PRIVATE void * jx9_context_realloc_chunk(jx9_context *pCtx, void *pChunk, unsigned int nByte); | ||
414 | JX9_PRIVATE void jx9_context_free_chunk(jx9_context *pCtx, void *pChunk); | ||
415 | /* On Demand Dynamically Typed Value Object allocation interfaces */ | ||
416 | JX9_PRIVATE jx9_value * jx9_new_scalar(jx9_vm *pVm); | ||
417 | JX9_PRIVATE jx9_value * jx9_new_array(jx9_vm *pVm); | ||
418 | JX9_PRIVATE int jx9_release_value(jx9_vm *pVm, jx9_value *pValue); | ||
419 | JX9_PRIVATE jx9_value * jx9_context_new_scalar(jx9_context *pCtx); | ||
420 | JX9_PRIVATE jx9_value * jx9_context_new_array(jx9_context *pCtx); | ||
421 | JX9_PRIVATE void jx9_context_release_value(jx9_context *pCtx, jx9_value *pValue); | ||
422 | /* Dynamically Typed Value Object Management Interfaces */ | ||
423 | JX9_PRIVATE int jx9_value_int(jx9_value *pVal, int iValue); | ||
424 | JX9_PRIVATE int jx9_value_int64(jx9_value *pVal, jx9_int64 iValue); | ||
425 | JX9_PRIVATE int jx9_value_bool(jx9_value *pVal, int iBool); | ||
426 | JX9_PRIVATE int jx9_value_null(jx9_value *pVal); | ||
427 | JX9_PRIVATE int jx9_value_double(jx9_value *pVal, double Value); | ||
428 | JX9_PRIVATE int jx9_value_string(jx9_value *pVal, const char *zString, int nLen); | ||
429 | JX9_PRIVATE int jx9_value_string_format(jx9_value *pVal, const char *zFormat, ...); | ||
430 | JX9_PRIVATE int jx9_value_reset_string_cursor(jx9_value *pVal); | ||
431 | JX9_PRIVATE int jx9_value_resource(jx9_value *pVal, void *pUserData); | ||
432 | JX9_PRIVATE int jx9_value_release(jx9_value *pVal); | ||
433 | /* JSON Array/Object Management Interfaces */ | ||
434 | JX9_PRIVATE jx9_value * jx9_array_fetch(jx9_value *pArray, const char *zKey, int nByte); | ||
435 | JX9_PRIVATE int jx9_array_walk(jx9_value *pArray, int (*xWalk)(jx9_value *, jx9_value *, void *), void *pUserData); | ||
436 | JX9_PRIVATE int jx9_array_add_elem(jx9_value *pArray, jx9_value *pKey, jx9_value *pValue); | ||
437 | JX9_PRIVATE int jx9_array_add_strkey_elem(jx9_value *pArray, const char *zKey, jx9_value *pValue); | ||
438 | JX9_PRIVATE unsigned int jx9_array_count(jx9_value *pArray); | ||
439 | /* Dynamically Typed Value Object Query Interfaces */ | ||
440 | JX9_PRIVATE int jx9_value_is_int(jx9_value *pVal); | ||
441 | JX9_PRIVATE int jx9_value_is_float(jx9_value *pVal); | ||
442 | JX9_PRIVATE int jx9_value_is_bool(jx9_value *pVal); | ||
443 | JX9_PRIVATE int jx9_value_is_string(jx9_value *pVal); | ||
444 | JX9_PRIVATE int jx9_value_is_null(jx9_value *pVal); | ||
445 | JX9_PRIVATE int jx9_value_is_numeric(jx9_value *pVal); | ||
446 | JX9_PRIVATE int jx9_value_is_callable(jx9_value *pVal); | ||
447 | JX9_PRIVATE int jx9_value_is_scalar(jx9_value *pVal); | ||
448 | JX9_PRIVATE int jx9_value_is_json_array(jx9_value *pVal); | ||
449 | JX9_PRIVATE int jx9_value_is_json_object(jx9_value *pVal); | ||
450 | JX9_PRIVATE int jx9_value_is_resource(jx9_value *pVal); | ||
451 | JX9_PRIVATE int jx9_value_is_empty(jx9_value *pVal); | ||
452 | /* Global Library Management Interfaces */ | ||
453 | /*JX9_PRIVATE int jx9_lib_init(void);*/ | ||
454 | JX9_PRIVATE int jx9_lib_config(int nConfigOp, ...); | ||
455 | JX9_PRIVATE int jx9_lib_shutdown(void); | ||
456 | /*JX9_PRIVATE int jx9_lib_is_threadsafe(void);*/ | ||
457 | /*JX9_PRIVATE const char * jx9_lib_version(void);*/ | ||
458 | JX9_PRIVATE const char * jx9_lib_signature(void); | ||
459 | /*JX9_PRIVATE const char * jx9_lib_ident(void);*/ | ||
460 | /*JX9_PRIVATE const char * jx9_lib_copyright(void);*/ | ||
461 | |||
462 | #endif /* _JX9H_ */ | ||