Apache HTTPD
Macros | Functions | Variables
sdbm.c File Reference
#include "apr.h"
#include "apr_file_io.h"
#include "apr_strings.h"
#include "apr_errno.h"
#include "apr_sdbm.h"
#include "sdbm_tune.h"
#include "sdbm_pair.h"
#include "sdbm_private.h"
#include <string.h>
#include <stdlib.h>

Go to the source code of this file.

Macros

#define bad(x)   ((x).dptr == NULL || (x).dsize <= 0)
 
#define exhash(item)   sdbm_hash((item).dptr, (item).dsize)
 
#define OFF_PAG(off)   (apr_off_t) (off) * PBLKSIZ
 
#define OFF_DIR(off)   (apr_off_t) (off) * DBLKSIZ
 

Functions

static int getdbit (apr_sdbm_t *, long)
 
static apr_status_t setdbit (apr_sdbm_t *, long)
 
static apr_status_t getpage (apr_sdbm_t *db, long, int, int)
 
static apr_status_t getnext (apr_sdbm_datum_t *key, apr_sdbm_t *db)
 
static apr_status_t makroom (apr_sdbm_t *, long, int)
 
static apr_status_t database_cleanup (void *data)
 
static apr_status_t prep (apr_sdbm_t **pdb, const char *dirname, const char *pagname, apr_int32_t flags, apr_fileperms_t perms, apr_pool_t *p)
 
 APU_DECLARE (apr_status_t)
 
static apr_status_t write_page (apr_sdbm_t *db, const char *buf, long pagno)
 
static apr_status_t read_from (apr_file_t *f, void *buf, apr_off_t off, apr_size_t len, int create)
 

Variables

static const long masks []
 
const apr_sdbm_datum_t apu__sdbm_nullitem = { NULL, 0 }
 

Macro Definition Documentation

◆ bad

#define bad (   x)    ((x).dptr == NULL || (x).dsize <= 0)

Definition at line 50 of file sdbm.c.

◆ exhash

#define exhash (   item)    sdbm_hash((item).dptr, (item).dsize)

Definition at line 51 of file sdbm.c.

◆ OFF_DIR

#define OFF_DIR (   off)    (apr_off_t) (off) * DBLKSIZ

Definition at line 54 of file sdbm.c.

◆ OFF_PAG

#define OFF_PAG (   off)    (apr_off_t) (off) * PBLKSIZ

Definition at line 53 of file sdbm.c.

Function Documentation

◆ APU_DECLARE()

APU_DECLARE ( int  )

Most DBM libraries take a POSIX mode for creating files. Don't trust the mode_t type, some platforms may not support it, int is safe.

< Shared lock. More than one process or thread can hold a shared lock at any given time. Essentially, this is a "read lock", preventing writers from establishing an exclusive lock.

< Exclusive lock. Only one process may hold an exclusive lock at any given time. This is analogous to a "write lock".

< Exclusive lock. Only one process may hold an exclusive lock at any given time. This is analogous to a "write lock".

< Replace

< Insert with duplicates

< Shared lock. More than one process or thread can hold a shared lock at any given time. Essentially, this is a "read lock", preventing writers from establishing an exclusive lock.

< Shared lock. More than one process or thread can hold a shared lock at any given time. Essentially, this is a "read lock", preventing writers from establishing an exclusive lock.

Definition at line 171 of file sdbm.c.

◆ database_cleanup()

static apr_status_t database_cleanup ( void *  data)
static

Definition at line 69 of file sdbm.c.

◆ getdbit()

static int getdbit ( apr_sdbm_t db,
long  dbit 
)
static

Definition at line 493 of file sdbm.c.

◆ getnext()

static apr_status_t getnext ( apr_sdbm_datum_t key,
apr_sdbm_t db 
)
static

Definition at line 552 of file sdbm.c.

◆ getpage()

static apr_status_t getpage ( apr_sdbm_t db,
long  hash,
int  by_num,
int  create 
)
static

Definition at line 445 of file sdbm.c.

◆ makroom()

static apr_status_t makroom ( apr_sdbm_t db,
long  hash,
int  need 
)
static

Definition at line 303 of file sdbm.c.

◆ prep()

static apr_status_t prep ( apr_sdbm_t **  pdb,
const char dirname,
const char pagname,
apr_int32_t  flags,
apr_fileperms_t  perms,
apr_pool_t p 
)
static

< Open the file for writing

< Platform dependent support for higher level locked read/write access to support writes across process/machines

< Platform dependent support for higher level locked read/write access to support writes across process/machines

< Open the file in binary mode (This flag is ignored on UNIX because it has no meaning)

< Open the file for reading

< Shared lock. More than one process or thread can hold a shared lock at any given time. Essentially, this is a "read lock", preventing writers from establishing an exclusive lock.

< Exclusive lock. Only one process may hold an exclusive lock at any given time. This is analogous to a "write lock".

Definition at line 86 of file sdbm.c.

◆ read_from()

static apr_status_t read_from ( apr_file_t f,
void *  buf,
apr_off_t  off,
apr_size_t  len,
int  create 
)
static

Definition at line 383 of file sdbm.c.

◆ setdbit()

static apr_status_t setdbit ( apr_sdbm_t db,
long  dbit 
)
static

Definition at line 515 of file sdbm.c.

◆ write_page()

static apr_status_t write_page ( apr_sdbm_t db,
const char buf,
long  pagno 
)
static

Definition at line 207 of file sdbm.c.

Variable Documentation

◆ apu__sdbm_nullitem

const apr_sdbm_datum_t apu__sdbm_nullitem = { NULL, 0 }

Definition at line 67 of file sdbm.c.

◆ masks

const long masks[]
static
Initial value:
= {
000000000000, 000000000001, 000000000003, 000000000007,
000000000017, 000000000037, 000000000077, 000000000177,
000000000377, 000000000777, 000000001777, 000000003777,
000000007777, 000000017777, 000000037777, 000000077777,
000000177777, 000000377777, 000000777777, 000001777777,
000003777777, 000007777777, 000017777777, 000037777777,
000077777777, 000177777777, 000377777777, 000777777777,
001777777777, 003777777777, 007777777777, 017777777777
}

Definition at line 56 of file sdbm.c.