📄 tcfdb.h
字号:
/* Get range matching decimal keys with strings in a fixed-length database object. `fdb' specifies the fixed-length database object. `lstr' specifies the string of the lower key. If it is "min", the minimum ID number of existing records is specified. `ustr' specifies the string of the upper key. If it is "max", the maximum ID number of existing records is specified. `max' specifies the maximum number of keys to be fetched. If it is negative, no limit is specified. The return value is a list object of the corresponding decimal keys. This function does never fail and return an empty list even if no key corresponds. Because the object of the return value is created with the function `tclistnew', it should be deleted with the function `tclistdel' when it is no longer in use. Note that this function may be very slow because every key in the database is scanned. */TCLIST *tcfdbrange3(TCFDB *fdb, const char *lstr, const char *ustr, int max);/* Get keys with an interval notation in a fixed-length database object. `fdb' specifies the fixed-length database object. `ibuf' specifies the pointer to the region of the interval notation. `isiz' specifies the size of the region of the interval notation. `max' specifies the maximum number of keys to be fetched. If it is negative, no limit is specified. The return value is a list object of the corresponding decimal keys. This function does never fail and return an empty list even if no key corresponds. Because the object of the return value is created with the function `tclistnew', it should be deleted with the function `tclistdel' when it is no longer in use. Note that this function may be very slow because every key in the database is scanned. */TCLIST *tcfdbrange4(TCFDB *fdb, const void *ibuf, int isiz, int max);/* Get keys with an interval notation string in a fixed-length database object. `fdb' specifies the fixed-length database object. `istr' specifies the pointer to the region of the interval notation string. `max' specifies the maximum number of keys to be fetched. If it is negative, no limit is specified. The return value is a list object of the corresponding decimal keys. This function does never fail and return an empty list even if no key corresponds. Because the object of the return value is created with the function `tclistnew', it should be deleted with the function `tclistdel' when it is no longer in use. Note that this function may be very slow because every key in the database is scanned. */TCLIST *tcfdbrange5(TCFDB *fdb, const void *istr, int max);/* Add an integer to a record in a fixed-length database object. `fdb' specifies the fixed-length database object connected as a writer. `id' specifies the ID number. It should be more than 0. If it is `FDBIDMIN', the minimum ID number of existing records is specified. If it is `FDBIDPREV', the number less by one than the minimum ID number of existing records is specified. If it is `FDBIDMAX', the maximum ID number of existing records is specified. If it is `FDBIDNEXT', the number greater by one than the maximum ID number of existing records is specified. `num' specifies the additional value. If successful, the return value is the summation value, else, it is `INT_MIN'. If the corresponding record exists, the value is treated as an integer and is added to. If no record corresponds, a new record of the additional value is stored. */int tcfdbaddint(TCFDB *fdb, int64_t id, int num);/* Add a real number to a record in a fixed-length database object. `fdb' specifies the fixed-length database object connected as a writer. `id' specifies the ID number. It should be more than 0. If it is `FDBIDMIN', the minimum ID number of existing records is specified. If it is `FDBIDPREV', the number less by one than the minimum ID number of existing records is specified. If it is `FDBIDMAX', the maximum ID number of existing records is specified. If it is `FDBIDNEXT', the number greater by one than the maximum ID number of existing records is specified. `num' specifies the additional value. If successful, the return value is the summation value, else, it is `NAN'. If the corresponding record exists, the value is treated as a real number and is added to. If no record corresponds, a new record of the additional value is stored. */double tcfdbadddouble(TCFDB *fdb, int64_t id, double num);/* Synchronize updated contents of a fixed-length database object with the file and the device. `fdb' specifies the fixed-length database object connected as a writer. If successful, the return value is true, else, it is false. This function is useful when another process connects to the same database file. */bool tcfdbsync(TCFDB *fdb);/* Optimize the file of a fixed-length database object. `fdb' specifies the fixed-length database object connected as a writer. `width' specifies the width of the value of each record. If it is not more than 0, the current setting is not changed. `limsiz' specifies the limit size of the database file. If it is not more than 0, the current setting is not changed. If successful, the return value is true, else, it is false. */bool tcfdboptimize(TCFDB *fdb, int32_t width, int64_t limsiz);/* Remove all records of a fixed-length database object. `fdb' specifies the fixed-length database object connected as a writer. If successful, the return value is true, else, it is false. */bool tcfdbvanish(TCFDB *fdb);/* Copy the database file of a fixed-length database object. `fdb' specifies the fixed-length database object. `path' specifies the path of the destination file. If it begins with `@', the trailing substring is executed as a command line. If successful, the return value is true, else, it is false. False is returned if the executed command returns non-zero code. The database file is assured to be kept synchronized and not modified while the copying or executing operation is in progress. So, this function is useful to create a backup file of the database file. */bool tcfdbcopy(TCFDB *fdb, const char *path);/* Get the file path of a fixed-length database object. `fdb' specifies the fixed-length database object. The return value is the path of the database file or `NULL' if the object does not connect to any database file. */const char *tcfdbpath(TCFDB *fdb);/* Get the number of records of a fixed-length database object. `fdb' specifies the fixed-length database object. The return value is the number of records or 0 if the object does not connect to any database file. */uint64_t tcfdbrnum(TCFDB *fdb);/* Get the size of the database file of a fixed-length database object. `fdb' specifies the fixed-length database object. The return value is the size of the database file or 0 if the object does not connect to any database file. */uint64_t tcfdbfsiz(TCFDB *fdb);/************************************************************************************************* * features for experts *************************************************************************************************//* Set the error code of a fixed-length database object. `fdb' specifies the fixed-length database object. `ecode' specifies the error code. `file' specifies the file name of the code. `line' specifies the line number of the code. `func' specifies the function name of the code. */void tcfdbsetecode(TCFDB *fdb, int ecode, const char *filename, int line, const char *func);/* Set the file descriptor for debugging output. `fdb' specifies the fixed-length database object. `fd' specifies the file descriptor for debugging output. */void tcfdbsetdbgfd(TCFDB *fdb, int fd);/* Get the file descriptor for debugging output. `fdb' specifies the fixed-length database object. The return value is the file descriptor for debugging output. */int tcfdbdbgfd(TCFDB *fdb);/* Synchronize updating contents on memory of a fixed-length database object. `fdb' specifies the fixed-length database object connected as a writer. `phys' specifies whether to synchronize physically. If successful, the return value is true, else, it is false. */bool tcfdbmemsync(TCFDB *fdb, bool phys);/* Get the minimum ID number of records of a fixed-length database object. `fdb' specifies the fixed-length database object. The return value is the minimum ID number of records or 0 if the object does not connect to any database file. */uint64_t tcfdbmin(TCFDB *fdb);/* Get the maximum ID number of records of a fixed-length database object. `fdb' specifies the fixed-length database object. The return value is the maximum ID number of records or 0 if the object does not connect to any database file. */uint64_t tcfdbmax(TCFDB *fdb);/* Get the width of the value of each record of a fixed-length database object. `fdb' specifies the fixed-length database object. The return value is the width of the value of each record or 0 if the object does not connect to any database file. */uint64_t tcfdbwidth(TCFDB *fdb);/* Get the limit file size of a fixed-length database object. `fdb' specifies the fixed-length database object. The return value is the limit file size or 0 if the object does not connect to any database file. */uint64_t tcfdblimsiz(TCFDB *fdb);/* Get the limit ID number of a fixed-length database object. `fdb' specifies the fixed-length database object. The return value is the limit ID number or 0 if the object does not connect to any database file. */uint64_t tcfdblimid(TCFDB *fdb);/* Get the inode number of the database file of a fixed-length database object. `fdb' specifies the fixed-length database object. The return value is the inode number of the database file or 0 the object does not connect to any database file. */uint64_t tcfdbinode(TCFDB *fdb);/* Get the modification time of the database file of a fixed-length database object. `fdb' specifies the fixed-length database object. The return value is the inode number of the database file or 0 the object does not connect to any database file. */time_t tcfdbmtime(TCFDB *fdb);/* Get the connection mode of a fixed-length database object. `fdb' specifies the fixed-length database object. The return value is the connection mode. */int tcfdbomode(TCFDB *fdb);/* Get the database type of a fixed-length database object. `fdb' specifies the fixed-length database object. The return value is the database type. */uint8_t tcfdbtype(TCFDB *fdb);/* Get the additional flags of a fixed-length database object. `fdb' specifies the fixed-length database object. The return value is the additional flags. */uint8_t tcfdbflags(TCFDB *fdb);/* Get the pointer to the opaque field of a fixed-length database object. `fdb' specifies the fixed-length database object. The return value is the pointer to the opaque field whose size is 128 bytes. */char *tcfdbopaque(TCFDB *fdb);/* Generate the ID number from arbitrary binary data. `kbuf' specifies the pointer to the region of the key. `ksiz' specifies the size of the region of the key. The return value is the ID number. */int64_t tcfdbkeytoid(const char *kbuf, int ksiz);__TCFDB_CLINKAGEEND#endif /* duplication check *//* END OF FILE */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -