📄 villa.h
字号:
/* Delete all records corresponding a key. `villa' specifies a database handle connected as a writer. `kbuf' specifies the pointer to the region of a key. `ksiz' specifies the size of the region of the key. If it is negative, the size is assigned with `strlen(kbuf)'. If successful, the return value is true, else, it is false. False is returned when no record corresponds to the specified key. The cursor becomes unavailable due to updating database. */int vloutlist(VILLA *villa, const char *kbuf, int ksiz);/* Retrieve values of all records corresponding a key. `villa' specifies a database handle. `kbuf' specifies the pointer to the region of a key. `ksiz' specifies the size of the region of the key. If it is negative, the size is assigned with `strlen(kbuf)'. If successful, the return value is a list handle of the values of the corresponding records, else, it is `NULL'. `NULL' is returned when no record corresponds to the specified key. */CBLIST *vlgetlist(VILLA *villa, const char *kbuf, int ksiz);/* Move the cursor to the first record. `villa' specifies a database handle. If successful, the return value is true, else, it is false. False is returned if there is no record in the database. */int vlcurfirst(VILLA *villa);/* Move the cursor to the last record. `villa' specifies a database handle. If successful, the return value is true, else, it is false. False is returned if there is no record in the database. */int vlcurlast(VILLA *villa);/* Move the cursor to the previous record. `villa' specifies a database handle. If successful, the return value is true, else, it is false. False is returned if there is no previous record. */int vlcurprev(VILLA *villa);/* Move the cursor to the next record. `villa' specifies a database handle. If successful, the return value is true, else, it is false. False is returned if there is no next record. */int vlcurnext(VILLA *villa);/* Move the cursor to positon around a record. `villa' specifies a database handle. `kbuf' specifies the pointer to the region of a key. `ksiz' specifies the size of the region of the key. If it is negative, the size is assigned with `strlen(kbuf)'. `jmode' specifies detail adjustment: `VL_JFORWARD', which means that the cursor is set to the first record of the same key and that the cursor is set to the next substitute if completely matching record does not exist, `VL_JBACKWARD', which means that the cursor is set to the last record of the same key and that the cursor is set to the previous substitute if completely matching record does not exist. If successful, the return value is true, else, it is false. False is returned if there is no record corresponding the condition. */int vlcurjump(VILLA *villa, const char *kbuf, int ksiz, int jmode);/* Get the key of the record where the cursor is. `villa' specifies a database handle. `sp' specifies the pointer to a variable to which the size of the region of the return value is assigned. If it is `NULL', it is not used. If successful, the return value is the pointer to the region of the key of the corresponding record, else, it is `NULL'. `NULL' is returned when no record corresponds to the cursor. Because an additional zero code is appended at the end of the region of the return value, the return value can be treated as a character string. Because the region of the return value is allocated with the `malloc' call, it should be released with the `free' call if it is no longer in use. */char *vlcurkey(VILLA *villa, int *sp);/* Get the value of the record where the cursor is. `villa' specifies a database handle. `sp' specifies the pointer to a variable to which the size of the region of the return value is assigned. If it is `NULL', it is not used. If successful, the return value is the pointer to the region of the value of the corresponding record, else, it is `NULL'. `NULL' is returned when no record corresponds to the cursor. Because an additional zero code is appended at the end of the region of the return value, the return value can be treated as a character string. Because the region of the return value is allocated with the `malloc' call, it should be released with the `free' call if it is no longer in use. */char *vlcurval(VILLA *villa, int *sp);/* Set the tuning parameters for performance. `villa' specifies a database handle. `lrecmax' specifies the max number of records in a leaf node of B+ tree. If it is not more than 0, the default value is specified. `nidxmax' specifies the max number of indexes in a non-leaf node of B+ tree. If it is not more than 0, the default value is specified. `lcnum' specifies the max number of caching leaf nodes. If it is not more than 0, the default value is specified. `ncnum' specifies the max number of caching non-leaf nodes. If it is not more than 0, the default value is specified. The default setting is equivalent to `vlsettuning(49, 192, 1024, 512)'. Because tuning paremeters are not saved in a database, you should specify them every opening a database. */void vlsettuning(VILLA *villa, int lrecmax, int nidxmax, int lcnum, int ncnum);/* Synchronize updating contents with the file and the device. `villa' specifies a database handle connected as a writer. If successful, the return value is true, else, it is false. This function is useful when another process uses the connected database file. This function shuold not be used while the transaction is activated. */int vlsync(VILLA *villa);/* Optimize a database. `villa' specifies a database handle connected as a writer. If successful, the return value is true, else, it is false. In an alternating succession of deleting and storing with overwrite or concatenate, dispensable regions accumulate. This function is useful to do away with them. This function shuold not be used while the transaction is activated. */int vloptimize(VILLA *villa);/* Get the name of a database. `villa' specifies a database handle. If successful, the return value is the pointer to the region of the name of the database, else, it is `NULL'. Because the region of the return value is allocated with the `malloc' call, it should be released with the `free' call if it is no longer in use. */char *vlname(VILLA *villa);/* Get the size of a database file. `villa' specifies a database handle. If successful, the return value is the size of the database file, else, it is -1. Because of the I/O buffer, the return value may be less than the real size. */int vlfsiz(VILLA *villa);/* Get the number of the leaf nodes of B+ tree. `villa' specifies a database handle. If successful, the return value is the number of the leaf nodes, else, it is -1. */int vllnum(VILLA *villa);/* Get the number of the non-leaf nodes of B+ tree. `villa' specifies a database handle. If successful, the return value is the number of the non-leaf nodes, else, it is -1. */int vlnnum(VILLA *villa);/* Get the number of the records stored in a database. `villa' specifies a database handle. If successful, the return value is the number of the records stored in the database, else, it is -1. */int vlrnum(VILLA *villa);/* Check whether a database handle is a writer or not. `villa' specifies a database handle. The return value is true if the handle is a writer, false if not. */int vlwritable(VILLA *villa);/* Check whether a database has a fatal error or not. `villa' specifies a database handle. The return value is true if the database has a fatal error, false if not. */int vlfatalerror(VILLA *villa);/* Get the inode number of a database file. `villa' specifies a database handle. The return value is the inode number of the database file. */int vlinode(VILLA *villa);/* Begin the transaction. `villa' specifies a database handle connected as a writer. If successful, the return value is true, else, it is false. Because this function does not perform mutual excrusion control in multi-thread, the application is responsible for it. Only one transaction can be activated with a database handle at the same time. */int vltranbegin(VILLA *villa);/* Commit the transaction. `villa' specifies a database handle connected as a writer. If successful, the return value is true, else, it is false. Updating a database in the transaction is fixed when it is committed successfully. */int vltrancommit(VILLA *villa);/* Abort the transaction. `villa' specifies a database handle connected as a writer. If successful, the return value is true, else, it is false. Updating a database in the transaction is discarded when it is aborted. The state of the database is rollbacked to before transaction. */int vltranabort(VILLA *villa);/* Remove a database file. `name' specifies the name of a database file. If successful, the return value is true, else, it is false. */int vlremove(const char *name);#endif /* duplication check *//* END OF FILE */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -