diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2021-07-23 16:43:57 +0000 |
---|---|---|
committer | Laurent Bercot <ska@appnovation.com> | 2021-07-23 16:43:57 +0000 |
commit | dd6bb6c6b8298ebeff2d1882becb36580b969d6f (patch) | |
tree | 3d922a5791e7e34e2b041ea5f3489360bfa798e1 /src/include | |
parent | 122f9363682e5de8ce4056c4c05c1eaf8935cf19 (diff) | |
download | skalibs-dd6bb6c6b8298ebeff2d1882becb36580b969d6f.tar.xz |
New 2.11.0.0 branch with several modifications
- libbiguint removed
- cdb_make changed to cdbmake (because different ui)
- cdb redesigned
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/skalibs/cdb.h | 68 | ||||
-rw-r--r-- | src/include/skalibs/cdb_make.h | 27 | ||||
-rw-r--r-- | src/include/skalibs/cdbmake.h | 27 | ||||
-rw-r--r-- | src/include/skalibs/posixplz.h | 1 | ||||
-rw-r--r-- | src/include/skalibs/stddjb.h | 2 |
5 files changed, 62 insertions, 63 deletions
diff --git a/src/include/skalibs/cdb.h b/src/include/skalibs/cdb.h index 20d3903..9b05b22 100644 --- a/src/include/skalibs/cdb.h +++ b/src/include/skalibs/cdb.h @@ -1,50 +1,48 @@ /* ISC license. */ -#ifndef CDB_H -#define CDB_H +#ifndef SKALIBS_CDB_H +#define SKALIBS_CDB_H #include <stdint.h> -#include <skalibs/gccattributes.h> -#define CDB_HASHSTART 5381 -extern uint32_t cdb_hashadd (uint32_t, unsigned char) gccattr_const ; -extern uint32_t cdb_hash (char const *, unsigned int) gccattr_pure ; +#include <skalibs/gccattributes.h> -typedef struct cdb cdb_t, *cdb_t_ref ; -struct cdb +typedef struct cdb_s cdb, *cdb_ref ; +struct cdb_s { - char *map ; - uint32_t size ; /* initialized if map is nonzero */ - uint32_t loop ; /* number of hash slots searched under this key */ - uint32_t khash ; /* initialized if loop is nonzero */ - uint32_t kpos ; /* initialized if loop is nonzero */ - uint32_t hpos ; /* initialized if loop is nonzero */ - uint32_t hslots ; /* initialized if loop is nonzero */ - uint32_t dpos ; /* initialized if cdb_findnext() returns 1 */ - uint32_t dlen ; /* initialized if cdb_findnext() returns 1 */ + char const *map ; + uint32_t size ; } ; +#define CDB_ZERO { .map = 0, .size = 0 } +extern cdb const cdb_zero ; -#define CDB_ZERO { .map = 0, .size = 0, .loop = 0, .khash = 0, .kpos = 0, .hpos = 0, .hslots = 0, .dpos = 0, .dlen = 0 } -extern struct cdb const cdb_zero ; +typedef struct cdb_reader_s cdb_reader, *cdb_reader_ref ; +struct cdb_reader_s +{ + uint32_t loop ; + uint32_t khash ; + uint32_t kpos ; + uint32_t hpos ; + uint32_t hslots ; +} ; +#define CDB_READER_ZERO { .loop = 0, .khash = 0, .kpos = 0, .hpos = 0, .hslots = 0 } +extern cdb_reader const cdb_reader_zero ; -extern void cdb_free (struct cdb *) ; +typedef struct cdb_data_s cdb_data, *cdb_data_ref ; +struct cdb_data_s +{ + char const *s ; + uint32_t len ; +} ; -#define cdb_init_map(c, fd, domap) (!cdb_init(c, fd)) -extern int cdb_init (struct cdb *, int fd) ; -extern int cdb_mapfile (struct cdb *, char const *) ; -extern int cdb_read (struct cdb *, char *, unsigned int, uint32_t) ; -#define cdb_findstart(c) ((c)->loop = 0) -extern int cdb_findnext (struct cdb *, char const *, unsigned int) ; -#define cdb_find(c, s, len) (cdb_findstart(c), cdb_findnext(c, s, len)) +extern void cdb_free (cdb *) ; +extern int cdb_init (cdb *, char const *) ; -#define cdb_datapos(c) ((c)->dpos) -#define cdb_datalen(c) ((c)->dlen) -#define cdb_keypos(c) ((c)->kpos) -#define cdb_keylen(c) ((c)->dpos - (c)->kpos) +#define cdb_findstart(d) ((d)->loop = 0) +extern int cdb_find (cdb const *, cdb_reader *, cdb_data *, char const *, uint32_t) ; -#define cdb_traverse_init(c, kpos) (*(kpos) = 2048) -#define cdb_firstkey(c, kpos) (cdb_traverse_init(c, kpos), cdb_nextkey(c, kpos)) -extern int cdb_nextkey (struct cdb *, uint32_t *) ; -extern int cdb_successor (struct cdb *, char const *, unsigned int) ; +#define CDB_TRAVERSE_INIT() 2048 +#define cdb_traverse_init(pos) (*pos = 2048) +extern int cdb_traverse_next (cdb const *, cdb_data *, cdb_data *, uint32_t *) ; #endif diff --git a/src/include/skalibs/cdb_make.h b/src/include/skalibs/cdb_make.h deleted file mode 100644 index 69e1c68..0000000 --- a/src/include/skalibs/cdb_make.h +++ /dev/null @@ -1,27 +0,0 @@ -/* ISC license. */ - -#ifndef CDB_MAKE_H -#define CDB_MAKE_H - -#include <stdint.h> -#include <skalibs/diuint32.h> -#include <skalibs/allreadwrite.h> -#include <skalibs/genalloc.h> -#include <skalibs/buffer.h> - -typedef struct cdb_make cdb_make, *cdb_make_ref ; -struct cdb_make -{ - genalloc hplist ; /* array of diuint32 */ - uint32_t pos ; - buffer b ; - char buf[BUFFER_OUTSIZE] ; -} ; - -#define CDB_MAKE_ZERO { .hplist = GENALLOC_ZERO, .pos = 2048, .b = BUFFER_INIT(&fd_writev, -1, 0, 0) } - -extern int cdb_make_start (struct cdb_make *, int) ; -extern int cdb_make_add (struct cdb_make *, char const *, unsigned int, char const *, unsigned int) ; -extern int cdb_make_finish (struct cdb_make *) ; - -#endif diff --git a/src/include/skalibs/cdbmake.h b/src/include/skalibs/cdbmake.h new file mode 100644 index 0000000..bf03ad6 --- /dev/null +++ b/src/include/skalibs/cdbmake.h @@ -0,0 +1,27 @@ +/* ISC license. */ + +#ifndef SKALIBS_CDBMAKE_H +#define SKALIBS_CDBMAKE_H + +#include <stdint.h> +#include <skalibs/diuint32.h> +#include <skalibs/allreadwrite.h> +#include <skalibs/genalloc.h> +#include <skalibs/buffer.h> + +typedef struct cdbmaker_s cdbmaker, *cdbmaker_ref ; +struct cdbmaker_s +{ + genalloc hplist ; /* array of diuint32 */ + uint32_t pos ; + buffer b ; + char buf[BUFFER_OUTSIZE] ; +} ; + +#define CDBMAKER_ZERO { .hplist = GENALLOC_ZERO, .pos = 2048, .b = BUFFER_INIT(&fd_writev, -1, 0, 0) } + +extern int cdbmake_start (cdbmaker *, int) ; +extern int cdbmake_add (cdbmaker *, char const *, unsigned int, char const *, unsigned int) ; +extern int cdbmake_finish (cdbmaker *) ; + +#endif diff --git a/src/include/skalibs/posixplz.h b/src/include/skalibs/posixplz.h index 55e03fc..2c972c8 100644 --- a/src/include/skalibs/posixplz.h +++ b/src/include/skalibs/posixplz.h @@ -34,6 +34,7 @@ extern int getpeereid (int, uid_t *, gid_t *) ; extern void execvep (char const *, char const *const *, char const *const *, char const *) ; extern void execvep_loose (char const *, char const *const *, char const *const *, char const *) ; extern void unlink_void (char const *) ; +extern void munmap_void (void *, size_t) ; extern pid_t doublefork (void) ; extern int touch (char const *) ; diff --git a/src/include/skalibs/stddjb.h b/src/include/skalibs/stddjb.h index b15bff3..b2b1d32 100644 --- a/src/include/skalibs/stddjb.h +++ b/src/include/skalibs/stddjb.h @@ -19,7 +19,7 @@ #include <skalibs/bytestr.h> #include <skalibs/cbuffer.h> #include <skalibs/cdb.h> -#include <skalibs/cdb_make.h> +#include <skalibs/cdbmake.h> #include <skalibs/direntry.h> #include <skalibs/diuint32.h> #include <skalibs/diuint.h> |