Qsmtp  0.30dev
Macros | Functions
cdb.c File Reference

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)
 

Detailed Description

functions to read from CDB database

Function Documentation

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

Parameters
fdfile descriptor to search (will be closed)
keykey to search for
lenlength of key
mmbase of mmapped address space
stfile information
Returns
cdb value belonging to that key
Return values
NULLno 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.