📄 cabin.h
字号:
/* Get the list hanele contains all values in a map. `map' specifies a map handle. The return value is the list handle contains all values in the map. Because the handle of the return value is opened with the function `cblistopen', it should be closed with the function `cblistclose' if it is no longer in use. */CBLIST *cbmapvals(CBMAP *map);/* Serialize a map into a byte array. `map' specifies a map handle. `sp' specifies the pointer to a variable to which the size of the region of the return value is assigned. The return value is the pointer to the region of the result serial region. 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 *cbmapdump(CBMAP *map, int *sp);/* Redintegrate a serialized map. `ptr' specifies the pointer to a byte array. `size' specifies the size of the region. The return value is a new map handle. */CBMAP *cbmapload(const char *ptr, int size);/* Allocate a formatted string on memory. `format' specifies a printf-like format string. The conversion character `%' can be used with such flag characters as `d', `o', `u', `x', `X', `e', `E', `f', `g', `G', `c', `s', and `%'. Specifiers of the field length and the precision can be put between the conversion characters and the flag characters. The specifiers consist of decimal characters, `.', `+', `-', and the space character. The other arguments are used according to the format string. The return value is the pointer to the allocated region of the result 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 *cbsprintf(const char *format, ...);/* Replace some patterns in a string. `str' specifies the pointer to a source string. `pairs' specifies the handle of a map composed of pairs of replacement. The key of each pair specifies a pattern before replacement and its value specifies the pattern after replacement. The return value is the pointer to the allocated region of the result 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 *cbreplace(const char *str, CBMAP *pairs);/* Make a list by splitting a serial datum. `ptr' specifies the pointer to the region of the source content. If it is `NULL', an empty datum is created. `size' specifies the size of the region. If it is negative, the size is assigned with `strlen(ptr)'. `dalim' specifies a string containing delimiting characters. If it is `NULL', zero code is used as a delimiter. The return value is a list handle. Because the handle of the return value is opened with the function `cblistopen', it should be closed with the function `cblistclose'. */CBLIST *cbsplit(const char *ptr, int size, const char *delim);/* Read whole data of a file. `name' specifies the name of a file. `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. The return value is the pointer to the allocated region of the read data. 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 *cbreadfile(const char *name, int *sp);/* Read every line of a file. `name' specifies the name of a file. The return value is a list handle of the lines if successful, else it is NULL. Line separators are cut out. */CBLIST *cbreadlines(const char *name);/* Read names of files in a directory. `name' specifies the name of a directory. The return value is a list handle of names if successful, else it is NULL. */CBLIST *cbdirlist(const char *name);/* Get the status of a file or a directory. `name' specifies the name of a file or a directory. `dirp' specifies the pointer to a variable to which whether the file is a directory is assigned. If it is `NULL', it is not used. `sizep' specifies the pointer to a variable to which the size of the file is assigned. If it is `NULL', it is not used. `mtimep' specifies the pointer to a variable to which the last modified time of the file is assigned. If it is `NULL', it is not used. If successful, the return value is true, else, false. False is returned when the file does not exist or the permission is denied. */int cbfilestat(const char *name, int *isdirp, int *sizep, int *mtimep);/* Encode a serial object with URL encoding. `ptr' specifies the pointer to a region. `size' specifies the size of the region. If it is negative, the size is assigned with `strlen(ptr)'. The return value is the pointer to the result 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 *cburlencode(const char *ptr, int size);/* Decode a string encoded with URL encoding. `str' specifies the pointer to an encoded string. `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. The return value is the pointer to the region of the result. 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 *cburldecode(const char *str, int *sp);/* Encode a serial object with Base64 encoding. `ptr' specifies the pointer to a region. `size' specifies the size of the region. If it is negative, the size is assigned with `strlen(ptr)'. The return value is the pointer to the result 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 *cbbaseencode(const char *ptr, int size);/* Decode a string encoded with Base64 encoding. `str' specifies the pointer to an encoded string. `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. The return value is the pointer to the region of the result. 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 *cbbasedecode(const char *str, int *sp);/* Encode a serial object with quoted-printable encoding. `ptr' specifies the pointer to a region. `size' specifies the size of the region. If it is negative, the size is assigned with `strlen(ptr)'. The return value is the pointer to the result 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 *cbquoteencode(const char *ptr, int size);/* Decode a string encoded with quoted-printable encoding. `str' specifies the pointer to an encoded string. `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. The return value is the pointer to the region of the result. 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 *cbquotedecode(const char *str, int *sp);/* Compress a serial object with ZLIB. `ptr' specifies the pointer to a region. `size' specifies the size of the region. If it is negative, the size is assigned with `strlen(ptr)'. `sp' specifies the pointer to a variable to which the size of the region of the return value is assigned. If successful, the return value is the pointer to the result object, 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. This function is available only if QDBM is built with enabling ZLIB. */char *cbdeflate(const char *ptr, int size, int *sp);/* Decompress a serial object compressed with ZLIB. `ptr' specifies the pointer to a region. `size' specifies the size of the region. `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 result object, else, it is `NULL'. 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. This function is available only if QDBM is built with enabling ZLIB. */char *cbinflate(const char *ptr, int size, int *sp);/************************************************************************************************* * Macros for Experts *************************************************************************************************//* Alias of `cbdatumptr'. */#define CB_DATUMPTR(datum) ((const char *)(datum->dptr))/* Alias of `cbdatumsize'. */#define CB_DATUMSIZE(datum) ((int)(datum->dsize))/* Alias of `cblistnum'. */#define CB_LISTNUM(list) ((int)(list->num))/* Alias of `cblistval'. However, `sp' is ignored. */#define CB_LISTVAL(list,index,sp) ((const char *)(list->array[list->start+index].dptr))#endif /* duplication check *//* END OF FILE */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -