Structs

@brief File data events listener.

@brief Auto-expandable file.

@brief IWFS_EXT file options. @see iwrc iwfs_exfile_open(IWFS_EXT *f, const IWFS_EXT_OPTS *opts)

@struct IWFS_EXT_STATE @brief IWFS_EXT file state info. @see IWFS_EXT::state

@struct IWFS_FILE @brief Simple file implementation.

@brief IWFS_FILE file options. @see iwrc iwfs_file_open(IWFS_FILE *f, const IWFS_FILE_OPTS *opts)

@brief IWFS_FILE file state info. @see IWFS_FILE::state

@brief Auto-expandable file with support of reader/writer address space locking and free space blocks management using bitmaps.

@brief IWFS_FSM file options. @see iwfs_fsmfile_open(IWFS_FSM *f, const IWFS_FSM_OPTS *opts)

@brief IWFS_FSM file state container. @see IWFS_FSM::state

@brief IWKV storage open options.

@brief Write ahead log (WAL) options.

@brief Data container for key/value.

@brief Options for the default logging function. @see iwlog_set_logfn_opts(void*)

@brief File info.

@brief A rational number.

@brief Database handler.

@brief Document representation as result of query execution. @see ejdb_exec()

@brief Query execution context. Passed to ejdb_exec() to execute database query.

@brief EJDB HTTP/Websocket Server options.

@brief Query result as list. Used as result of ejdb_list() query functions.

@brief EJDB open options.

@brief Cursor opaque handler.

@brief JSON document in compact binary format Binn

@brief JSON document as in-memory tree (DOM tree).

@brief JSON patch specification

@brief JSON pointer rfc6901 @see jbl_ptr_alloc()

@brief JBL_NODE visitor context

Constants

< Set cursor to position after last record

< Set cursor to position before first record

< Set cursor to the specified key value

< Set cursor to the key which greater or equal key specified

< Move cursor to the next record

< Move cursor to the previous record

< Invalid collection index metadata

< Invalid index mode specified

< Index exists but mismatched uniqueness constraint

< Patch JSON must be an object (map)

< Memory allocation failed.

< Resource is already opened.

< Generic assertion error.

< Error with expected errno status set.

< Unspecified error.

< Request rejection/false response.

< Invalid function arguments.

< Invalid HANDLE value.

< Illegal state error.

< IO error with expected errno status set.

< Argument is not aligned properly.

< Action is not allowed. (IW_ERROR_NOT_ALLOWED)

< Resource is not exists.

< Method is not implemented.

< Invalid bounds specified.

< Resource is readonly.

< Threading error.

< Threading error with errno status set.

< Unexpected response (IW_ERROR_UNEXPECTED_RESPONSE)

< Unsupported opration. (IW_ERROR_UNSUPPORTED)

< No error.

< Maximum file offset reached.

< Region is mmaped already, mmaping overlaps

< Invalid result of resize policy function.

< Free-space map segmentation error

< Invalid block size specified

< Backup operation in progress. (IWKV_ERROR_BACKUP_IN_PROGRESS)

< Database file invalid or corrupted (IWKV_ERROR_CORRUPTED)

< Corrupted WAL file (IWKV_ERROR_CORRUPTED_WAL_FILE)

< Incorpatible database open mode (IWKV_ERROR_INCOMPATIBLE_DB_MODE)

< Key already exists (IWKV_ERROR_KEY_EXISTS)

< Key not found (IWKV_ERROR_NOTFOUND)

< Other file types, eg soc, block, pipe..

< Cannot create JBL object (JBL_ERROR_CREATION)

< Invalid JBL object (JBL_ERROR_INVALID)

< Invalid JBL buffer (JBL_ERROR_INVALID_BUFFER)

< Invalid JSON pointer (rfc6901) path (JBL_ERROR_JSON_POINTER)

< JBL is not an object (JBL_ERROR_NOT_AN_OBJECT)

< Invalid utf8 string (JBL_ERROR_PARSE_INVALID_UTF8)

< Failed to parse JSON string (JBL_ERROR_PARSE_JSON)

< Unquoted JSON string (JBL_ERROR_PARSE_UNQUOTED_STRING)

< Invalid JSON patch specified (JBL_ERROR_PATCH_INVALID)

< Invalid JSON patch operation specified (JBL_ERROR_PATCH_INVALID_OP)

< Invalid value specified by patch (JBL_ERROR_PATCH_INVALID_VALUE)

< No value specified in JSON patch (JBL_ERROR_PATCH_NOVALUE)

< JSON patch test operation failed (JBL_ERROR_PATCH_TEST_FAILED)

< JSON object not matched the path specified (JBL_ERROR_PATH_NOTFOUND)

< Create intermediate object nodes for missing path segments

< Value increment

< Swap values of two nodes

< Invalid placeholder position (JQL_ERROR_INVALID_PLACEHOLDER)

< Limit clause already specified (JQL_ERROR_SKIP_ALREADY_SET)

< No collection specified in query (JQL_ERROR_NO_COLLECTION)

< Query parsing error (JQL_ERROR_QUERY_PARSE)

< Invalid regular expression (JQL_ERROR_REGEXP_INVALID)

< Skip clause already specified (JQL_ERROR_SKIP_ALREADY_SET)

< Found unset placeholder (JQL_ERROR_UNSET_PLACEHOLDER)

Statics

Functions

@brief Closes storage and frees up all resources. @param [in,out] ejdbp Pointer to storage handle, will set to zero oncompletion.

@brief Executes a given query q then returns count of matched documents.

@brief Executes a given query q then returns count of matched documents.

@brief Remove document identified by given id from collection coll.

@brief Create collection with given name if it has not existed before

@brief Create index with specified parameters if it has not existed before.

@brief Executes a query.

@brief Retrieve document identified by given id from collection coll.

@brief Get access to underlying IWKV storage. Use it with caution.

@brief Returns JSON document describind database structure. @note Returned jblp must be disposed by jbl_destroy()

@brief Return \0 terminated ejdb2 source GIT revision hash.

@brief ejdb2 initialization routine. @note Must be called before using any of ejdb API function.

@brief Executes a given query and builds a query result as linked list of documents.

@brief Executes a given query and builds a result as linked list of documents.

@brief Executes a given query and builds a result as linked list of documents.

@brief Executes a given query q and builds a result as linked list of documents (listp).

@brief Destroy query result set and set listp to zero. @param [in,out] listp Can be zero.

@brief Apply JSON merge patch (rfc7396) to the document identified by id or insert new document under specified id. @note This is an atomic operation.

@brief Apply JSON merge patch (rfc7396) to the document identified by id or insert new document under specified id. @note This is an atomic operation.

@brief Apply JSON merge patch (rfc7396) to the document identified by id or insert new document under specified id. @note This is an atomic operation.

Creates an online database backup image and copies it into the specified target_file. During online backup phase read/write database operations are allowed and not blocked for significant amount of time. Backup finish time is placed into ts as number of milliseconds since epoch.

@brief Open storage file.

@brief Apply rfc6902/rfc7396 JSON patch to the document identified by id.

@brief Apply rfc6902/rfc7396 JSON patch to the document identified by id.

@brief Apply rfc6902/rfc7396 JSON patch to the document identified by id.

@brief Save a given jbl document under specified id.

@brief Save a given jbn document under specified id.

@brief Save a document into coll under new identifier.

@brief Save a document into coll under new identifier.

@brief Remove collection under the given name coll.

@brief Remove index if it has existed before.

@brief Rename collection coll to new_coll.

@brief Executes update query assuming that query object contains apply clause. Similar to ejdb_count.

@brief Executes update query assuming that query object contains apply clause. Similar to ejdb_count.

@brief Return \0 terminated EJDB version string.

@brief Return major library version.

@brief Return minor library version.

@brief Return patch library version.

@brief Fibonacci resize file policy.

@brief Rational number IW_RNUM file size multiplication policy.

@brief Init iowow subsystem. @return 0 on success or error code.

@brief Init iwexfile submodule.

@brief Open exfile.

@brief Init iwfile submodule.

@brief Open file and initialize a given @a f structure.

@brief Init iwfsmfile submodule.

@brief Open IWFS_FSM file.

@brief Close iwkv storage. @details Upon successfull call of iwkv_close() no farther operations on storage or any of its databases are allowed.

@brief Close cursor object. @param cur Opened cursor

@brief Copy key data to the specified buffer at the current cursor position. @note At most of bufsz bytes will be copied into kbuf.

@brief Copy value data to the specified buffer at the current cursor position. @note At most of bufsz bytes will be copied into vbuf.

@brief Remove record value at current cursor position. @param cur Opened cursor object

@brief Get key and value at current cursor position. @note Data stored in okey/oval containers must be freed with iwkv_val_dispose().

@brief Get key at current cursor position. @note Data stored in okey container must be freed with iwkv_val_dispose().

@brief Open database cursor.

@brief Set record value at current cursor position. @note This is equivalent to iwkv_put() operation.

@brief Move cursor to the next position.

@brief Move cursor to the next position.

@brief Get value at current cursor position. @note Data stored in oval container must be freed with iwkv_val_dispose(). @param cur Opened cursor object @param oval Value holder to be initialized by value at current position

@brief Get iwkv database handler identified by specified dbid number. @details In the case if no database matched dbid a new database will be created using specified function arguments.

@brief Frees memory resources used by database cache until to next database access operation (get/put/cursor). Typicaly it will free ~130Kb of memory per database in use.

@brief Destroy(drop) existing database and cleanup all of its data.

@brief Get arbitrary data associated with database. @param db Database handler @param buf Output buffer @param sz Size of target buffer @param [out] rsz Number of bytes read actually

@brief Set arbitrary data associated with database. Database write lock will acquired for this operation.

@brief Remove record identified by key.

@brief Get value for given key.

@brief Get value for given key and copy it into provided vbuf using up to vbufsz bytes.

@brief Initialize iwkv storage. @details This method must be called before using of any iwkv public API function. @note iwkv implicitly initialized by iw_init()

@brief Dispose data containers for key and value respectively.

@brief Create new database with next available database id. @see iwrc iwkv_db()

Creates an online database backup image and copies it into the specified target_file. During online backup phase read/write database operations are not blocked for significant amount of time. Backup finish time is placed into ts as number of milliseconds since epoch. Online backup guaranties what all records before ts timestamp will be stored in backup image. Later, online backup image can be opened as ordinary database file.

@brief Open iwkv storage. @code {.c} IWKV iwkv; IWKV_OPTS opts = { .path = “mystore.db” }; iwrc rc = iwkv_open(&opts, &iwkv); @endcode @note Any opened iwkv storage must be closed by iwkv_close() after usage. @param opts Database open options. @param [out] iwkvp Pointer to @ref IWKV structure.

@brief Store record in database.

@brief Store record in database. @see iwkv_put()

@brief Get database file status info. @note Database should be in opened state.

@brief Sync iwkv storage state with disk.

@brief Destroy key/value data container.

@brief Logs a message. @param lvl Logging level. @param ecode Error code or zero. @param file Module file, can be NULL @param line Line in module. @param fmt Printf like message format. @return

@brief Returns string representation of a given error code. @param ecode Error code @return

@brief Get a default logging function.

@brief Initiate this submodule. @return 0 on success or error code.

@brief Register error code explanation function. @note Up to 128 @a fp functions can be registered. @param fp @return 0 on success or error code.

@brief Sets current logging function. @warning Not thread safe.

@brief Minimal address space aligment for memory mapping.

Allocates unique temp file path. Caller should use free() to release path buffer. @return Zero on error.

Portable version of int clock_gettime(clockid_t clk_id, struct timespec *tp)

@brief Close the specified file handle (File descriptor). @param fh File handle.

@brief Copy data within a file @param off Data offset @param siz Data size @param noff New data offset

@brief Get current time in milliseconds.

@brief Get executable path for the current process. It will be writein into @a opath @param opath Allocated buffer at least PATH_MAX length

@brief Allocate extra space for a file. @param fh File handle @param len New file size @return 0 on sucess or error code.

@brief Lock the file.

@brief Stat the file specified by @a path.

@brief Truncate a file specified by @a fh to a size of @a len bytes @param fh File handle @param len File size @return 0 on sucess or error code.

@brief Init iwp module. @return 0 on success or error code.

@brief Make directory specified by path as well as all parent directories.

@brief Return number of CPU cores.

@brief Get system page size.

@brief Read @a siz bytes from file @a fh into @a buf at the specified offset @a off.

@brief Write @a siz bytes into file @a fh at the specified offset @a off from buffer @a buf.

@brief Recursive directory removal specified by @a path. @param path Directory path

Set name of the current thread. On some platforms thread name canot be longer than 16 bytes including zero terminator.

@brief Pause execution of current thread to the specified @a ms time in milliseconds. @param ms Thread pause time

Write system tmp directory path into provided out buffer. Write at most len bytes not including terminating NULL char. @return Number of bytes writen. Zero on error.

@brief Unlock the file specified by @a fh @param fh File handle @return 0 on sucess or error code.

@brief Allocates buffer of specified size.

@brief Returns number of bytes allocated for this memory pool.

@brief Allocates zero initialized memory buffer and initializes allocated buffer with zeroes.

@brief Creates memory pool and preallocate initial buffer of size siz bytes. In the case if siz is zero then size of initial memory buffer will be IWPOOL_POOL_SIZ bytes.

@brief Create empty pool with no preallocated buffer. @return Pointer to the new pool or zero if allocation is failed.

@brief Destroys a given memory pool and frees its resources.

@brief Dispose function for IWPOOL stored as user data.

@brief Do fprintf into string allocated in this memory pool.

@brief Copy a given zero terminated char buffer into memory pool.

@brief Copy a given str of size len into memory pool.

@brief Returns number of bytes actually used for allocated buffers.

@brief Reset user data free function for current user data stored in pool.

@brief Returns pointer to user data associated with this pool. Or zero.

@brief Sets arbitrary user data associated with this pool. User data will be freed on pool destroy or new user data set.

@brief Attach the specified @a errno_code code into @a rc code @param rc IOWOW error code @param errno_code Error code will be embedded into. @return Updated rc code

@brief Remove embedded @a errno code from the passed @a rc @param [in,out] rc

@brief Strip the attached errno code from the specified @a rc and return errno code.

@brief Returns allocated size of @a xstr buffer.

Returns actual size of data stored in @a xstr buffer.

@brief Represent jbl document as raw data buffer.

@brief Prints JBL document as JSON string.

@brief Finds value in jbl document pointed by rfc6901 path and store it into res.

@brief @brief Finds value in jbl document pointed by jp structure and store it into res.

@brief Clones the given src JBL object into newly allocated targetp object.

@brief Clones a given src JBL object and stores it in memory allocated from pool.

@brief Same as jbl_get_str() but copies at most bufsz into target buf. Target buffer not touched if jbl value cannot be converted.

@brief Get number of child elements in jbl container (object/array) or zero.

@brief Just counts bytes in JSON text. @param op int* Pointer to counter number.

@brief Create empty binary JSON array.

@brief Create empty binary JSON object.

@brief Initializes placeholder for jbl iteration. Must be freed by jbl_destroy() after iteration. @param [out] jblp Pointer to be initialized by new object.

@brief Destroys JBL document and releases its heap resources. @note Will set jblp to zero. @param jblp Pointer holder of JBL document. Not zero.

@brief Fill jbl document by data from node.

@brief Initialize new JBL document by binn data from buffer. @note Created document will be allocated by malloc() and should be destroyed by jbl_destroy().

@brief Constructs new JBL object from JSON string. @note jblp should be disposed by jbl_destroy() @param [out] jblp Pointer initialized by created JBL document. Not zero. @param jsonstr JSON string to be converted

@brief Converts node object into JBL form.

@brief JSON printer to stdlib FILE*pointer. Eg: stderr, stdout @param op FILE* pointer

@brief Interpret jbl value as double value. Returns zero if value cannot be converted.

@brief Interpret jbl value as int32_t. Returns zero if value cannot be converted.

@brief Interpret jbl value as int64_t. Returns zero if value cannot be converted.

@brief Interpret jbl value as \0 terminated character array. Returns zero if value cannot be converted.

@brief Returns user data associated with given jbl container.

@brief Initialize allocated iterator over given jbl object.

@brief Get next value from JBL_iterator. Returns false if iteration is over.

@brief Copy all keys from src object into target object. @note Function does not care about keys duplication.

@brief Parses rfc6901 JSON path. @note jpp structure should be disposed by free().

@brief Parses rfc6901 JSON path.

@brief Compare JSON pointers.

@brief Serialize JSON pointer to as text. @param ptr JSON pointer. Not zero. @param xstr Output string buffer. Not zero.

@brief Set bool JBL object property value or add a new entry to end of array JBL object.

@brief Set double JBL object property value or add a new entry to end of array JBL object.

@brief Set integer JBL object property value or add a new entry to end of array JBL object.

@brief Set nested JBL object property value or add a new entry to end of array JBL object.

@brief Set null JBL object property value or add a new entry to end of array JBL object.

@brief Set string JBL object property value or add a new entry to end of array JBL object.

@brief Sets arbitrary user data associated with JBL object.

@brief Get size of undelying data buffer of jbl value passed.

@brief Returns size of JBL underlying data structure

@brief Converts jbl value to JBL_NODE tree. @note node resources will be released when pool destroyed.

@brief Get type of jbl value.

@brief JSON printer to extended string buffer IWXSTR @param op IWXSTR* pointer

@brief Add item to the parent container.

@brief Add nested array under the given key

@brief Adds boolean JSON node to the given parent node.

@brief Adds fp number JSON node to the given parent node.

@brief Adds integer JSON node to the given parent node.

@brief Adds null JSON value to the given parent node.

@brief Add nested object under the given key

@brief Adds string JSON node to the given parent node. Key and value are copied into allocated node.

@brief Assign a JSON node value from from node into target node. Context elements of target node: parent, next are not touched.

@brief Prints JBL_NODE document as JSON string.

@brief Clones the given src JBL_NODE object into new targetp instance. Memory allocateted by given memor pool instance.

@brief Compares JSON tree nodes.

@brief Copies JSON subtree under given src_path into target object under target_path. If some tree exists under target_path it will be replaced by copied subtree.

@brief Copies a set of values pointed by paths zero terminated array of src object into respective paths of target object.

@brief Reset tree node data.

@brief Remove subtree from target node pointed by path

@brief Converts json text to JBL_NODE tree. @note node resources will be released when pool destroyed.

@brief Returns number of child elements of given node.

@brief Add item from the parent container.

@brief Create query object from specified text query. @param qptr Pointer to resulting query object @param coll Optional collection name used to execute query @param query Query text

@brief Bind JSON node data to query placeholder. @warning Value JSON data is not copied and used as is. Caller is responsible to maintain val availability during execution of query. @see jql_set_json2()

@brief Bind regexp data string to query placeholder. @warning Value string data is not copied and used as is. Caller is responsible to maintain val availability during execution of query. @see jql_set_regexp2()

@brief Bind string data to query placeholder. @warning Value string data is not copied and used as is. Caller is responsible to maintain val availability during execution of query. @see jql_set_str2()

Type Definitions

@brief Document representation as result of query execution. @see ejdb_exec()

@brief Query execution context. Passed to ejdb_exec() to execute database query.

@brief Visitor for matched documents during query execution.

@brief EJDB HTTP/Websocket Server options.

@brief Query result as list. Used as result of ejdb_list() query functions.

@brief EJDB open options.

@brief Intercepts old(replaced) value in put operation. @note If oldval is not zero IWKV_PUT_HANDLER responsive for releasing it using iwkv_val_dispose() @warning Use IWKV_PUT_HANDLER with caution: mind deadlocks.

@brief Database cursor operations and position flags.

@brief Return the locale aware error code explanation message.

@brief Logging function pointer.

@brief File resize policy function type.

@brief JSON document as in-memory tree (DOM tree).

@brief JSON patch specification

@brief JSON pointer rfc6901 @see jbl_ptr_alloc()

@brief JBL_NODE visitor context

Call with lvl: -1 means end of visiting whole object tree.

@brief EJDB error codes.

Index creation mode

@enum iw_ecode @brief Common used error codes.

Database initialization modes

@enum iwfs_ext_ecode @brief Error codes specific to this module.

Free space allocation flags @see IWFS_FSM::allocate

File cleanup flags used in IWFS_FSM::clear

@brief Error codes specific to IWFS_FSM.

IWFS_FSM file open modes used in IWFS_FSM_OPTS

File open mode

Status of an open file operation

Sync file data options

@brief IWKV error codes.

Database file open modes.

Record store modes used in iwkv_put() and iwkv_cursor_set() functions.

@enum iwlog_lvl @brief Available logging vebosity levels.

@enum iwp_ecode @brief Error codes.

@enum iwp_file_type @brief File type.

File locking mode acquired by process opened this file.

@brief The operation result status code.

Prints JSON to some oputput specified by op

@brief JSON Patch operation according to rfc6902

Unions