Qsmtp
0.30dev
|
functions to read from CDB database More...
#include <cdb.h>
#include <errno.h>
#include <stdint.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
Macros | |
#define | CDB_HASHSTART 5381 |
Functions | |
static uint32_t | cdb_hash (const char *buf, unsigned int len) |
static uint32_t | cdb_unpack (const char *buf) |
const char * | cdb_seekmm (int fd, const char *key, unsigned int len, char **mm, const struct stat *st) |
functions to read from CDB database
const char* cdb_seekmm | ( | int | fd, |
const char * | key, | ||
unsigned int | len, | ||
char ** | mm, | ||
const struct stat * | st | ||
) |
perform cdb search on the given file
fd | file descriptor to search (will be closed) |
key | key to search for |
len | length of key |
mm | base of mmapped address space |
st | file information |
NULL | no key found in database or error |
If the function returns NULL and errno is 0 everything worked fine but there is no entry for key in the file. On error errno is set.
The file is mmaped into memory, the result pointer will point inside that memory. The caller must munmap() the value returned in mm if the function does not return NULL. fd will be closed before the function returns.