#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "cdb.h"
#include "sdb_private.h"
Go to the source code of this file.
|
bool | cdb_getkvlen (struct cdb *c, ut32 *klen, ut32 *vlen, ut32 pos) |
|
void | cdb_free (struct cdb *c) |
|
void | cdb_findstart (struct cdb *c) |
|
bool | cdb_init (struct cdb *c, int fd) |
|
bool | cdb_read (struct cdb *c, char *buf, ut32 len, ut32 pos) |
|
static int | match (struct cdb *c, const char *key, ut32 len, ut32 pos) |
|
int | cdb_findnext (struct cdb *c, ut32 u, const char *key, ut32 len) |
|
◆ cdb_findnext()
Definition at line 132 of file cdb.c.
142 const int bufsz = ((u + 1) & 0xFF) ?
sizeof(
buf) :
sizeof(
buf) / 2;
148 if (bufsz ==
sizeof(
buf)) {
156 c->hslots = (
pos -
c->hpos) / (2 *
sizeof(
ut32));
161 u = ((u >> 8) %
c->hslots) << 3;
162 c->kpos =
c->hpos + u;
164 while (
c->loop <
c->hslots) {
173 c->kpos +=
sizeof(
buf);
174 if (
c->kpos ==
c->hpos + (
c->hslots << 3)) {
bool cdb_getkvlen(struct cdb *c, ut32 *klen, ut32 *vlen, ut32 pos)
static int match(struct cdb *c, const char *key, ut32 len, ut32 pos)
bool cdb_read(struct cdb *c, char *buf, ut32 len, ut32 pos)
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len key
static void ut32_unpack(char s[4], ut32 *u)
References c, cdb_getkvlen(), cdb_read(), key, KVLSZ, len, regress::m, match(), pos, and ut32_unpack().
Referenced by sdb_const_get_len(), sdb_exists(), sdb_expire_set(), and sdb_set_internal().
◆ cdb_findstart()
void cdb_findstart |
( |
struct cdb * |
c | ) |
|
Definition at line 42 of file cdb.c.
44 #if !HAVE_HEADER_SYS_MMAN_H
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep lseek
References c, lseek, and SEEK_SET.
Referenced by cdb_init(), sdb_const_get_len(), sdb_exists(), sdb_expire_set(), and sdb_set_internal().
◆ cdb_free()
void cdb_free |
( |
struct cdb * |
c | ) |
|
Definition at line 30 of file cdb.c.
34 #if HAVE_HEADER_SYS_MMAN_H
RZ_API void Ht_() free(HtName_(Ht) *ht)
static const void static count static fd struct stat static buf struct pollfd unsigned static timeout void static offset munmap
References c, free(), munmap, and NULL.
Referenced by sdb_fini().
◆ cdb_getkvlen()
◆ cdb_init()
Definition at line 51 of file cdb.c.
53 if (
fd !=
c->fd &&
c->fd != -1) {
59 #if HAVE_HEADER_SYS_MMAN_H
61 if (
x == MAP_FAILED) {
62 eprintf(
"Cannot mmap %d\n", (
int)st.st_size);
69 char *
x =
calloc(1, st.st_size);
71 eprintf(
"Cannot malloc %d\n", (
int)st.st_size);
75 if (
read(
fd,
x, st.st_size) != st.st_size) {
void cdb_findstart(struct cdb *c)
static static fork const void static count close
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset fstat
void * calloc(size_t number, size_t size)
static static fork const void static count static fd const char const char static newpath char char char static envp time_t static t const char static mode static whence const char static dir time_t static t unsigned static seconds const char struct utimbuf static buf static inc static sig const char static mode static oldfd struct tms static buf static getgid static geteuid const char static filename static arg static mask struct ustat static ubuf static getppid static setsid static egid sigset_t static set struct timeval struct timezone static tz fd_set fd_set fd_set struct timeval static timeout const char char static bufsiz const char static swapflags mmap
static const z80_opcode fd[]
int read(izstream &zs, T *x, Items items)
References c, calloc(), cdb_findstart(), close, eprintf, fd, free(), fstat, MAP_SHARED, mmap, munmap, NULL, PROT_READ, read(), UT64_MAX, and x.
Referenced by sdb_disk_finish(), sdb_new(), and sdb_open().
◆ cdb_read()
Definition at line 89 of file cdb.c.
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
static int seek_set(int fd, off_t pos)
References c, int, len, memcpy(), pos, r, read(), and seek_set().
Referenced by cdb_findnext(), cdb_getkvlen(), getbytes(), match(), sdb_exists(), and sdb_expire_set().
◆ match()