ext/sdbm/_sdbm.c File Reference

#include "ruby/config.h"
#include "ruby/defines.h"
#include "sdbm.h"
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>

Include dependency graph for _sdbm.c:

Go to the source code of this file.

Defines

#define BYTESIZ   8
#define SEEDUPS
#define BADMESS
#define debug(x)
#define GET_SHORT(p, i)   ((p)[i])
#define PUT_SHORT(p, i, s)   ((p)[i] = (s))
#define O_BINARY   0
#define EPERM   EACCES
#define NULL   0
#define bad(x)   ((x).dptr == NULL || (x).dsize < 0)
#define exhash(item)   sdbm_hash((item).dptr, (item).dsize)
#define ioerr(db)   ((db)->flags |= DBM_IOERR)
#define OFF_PAG(off)   (long) (off) * PBLKSIZ
#define OFF_DIR(off)   (long) (off) * DBLKSIZ
#define exhash(item)   sdbm_hash((item).dptr, (item).dsize)

Functions

static int fitpair proto ((char *, int))
static void putpair proto ((char *, datum, datum))
static datum getpair proto ((char *, datum))
static int chkpage proto ((char *))
static void splpage proto ((char *, char *, long))
static int getdbit proto ((DBM *, long))
static datum getnext proto ((DBM *))
static int makroom proto ((DBM *, long, int))
DBMsdbm_open (register char *file, register int flags, register int mode)
DBMsdbm_prep (char *dirname, char *pagname, int flags, int mode)
void sdbm_close (register DBM *db)
datum sdbm_fetch (register DBM *db, datum key)
int sdbm_delete (register DBM *db, datum key)
int sdbm_store (register DBM *db, datum key, datum val, int flags)
static int makroom (register DBM *db, long int hash, int need)
datum sdbm_firstkey (register DBM *db)
datum sdbm_nextkey (register DBM *db)
static int getpage (register DBM *db, register long int hash)
static int getdbit (register DBM *db, register long int dbit)
static int setdbit (register DBM *db, register long int dbit)
static datum getnext (register DBM *db)
static int seepair proto ((char *, int, char *, int))
static int fitpair (char *pag, int need)
static void putpair (char *pag, datum key, datum val)
static datum getpair (char *pag, datum key)
static int duppair (char *pag, datum key)
static datum getnkey (char *pag, int num)
static int delpair (char *pag, datum key)
static int seepair (char *pag, register int n, register char *key, register int siz)
static void splpage (char *pag, char *new, long int sbit)
static int chkpage (char *pag)
long sdbm_hash (register char *str, register int len)

Variables

int errno
static long masks []
datum nullitem = {NULL, 0}


Define Documentation

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

#define BADMESS

Definition at line 43 of file _sdbm.c.

#define BYTESIZ   8

Definition at line 29 of file _sdbm.c.

Referenced by getdbit(), sdbm_prep(), and setdbit().

#define debug (  ) 

#define EPERM   EACCES

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

Definition at line 610 of file _sdbm.c.

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

Definition at line 610 of file _sdbm.c.

Referenced by sdbm_delete(), sdbm_fetch(), sdbm_store(), and splpage().

#define GET_SHORT ( p,
 )     ((p)[i])

Definition at line 58 of file _sdbm.c.

Referenced by chkpage(), delpair(), duppair(), fitpair(), getnkey(), getpair(), putpair(), seepair(), and splpage().

#define ioerr ( db   )     ((db)->flags |= DBM_IOERR)

Definition at line 126 of file _sdbm.c.

Referenced by getnext(), sdbm_delete(), sdbm_fetch(), sdbm_firstkey(), and sdbm_store().

#define NULL   0

Definition at line 102 of file _sdbm.c.

#define O_BINARY   0

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

Definition at line 129 of file _sdbm.c.

Referenced by getdbit(), and setdbit().

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

Definition at line 128 of file _sdbm.c.

Referenced by getnext(), getpage(), makroom(), sdbm_delete(), sdbm_firstkey(), and sdbm_store().

#define PUT_SHORT ( p,
i,
 )     ((p)[i] = (s))

Definition at line 59 of file _sdbm.c.

Referenced by delpair(), and putpair().

#define SEEDUPS

Definition at line 42 of file _sdbm.c.


Function Documentation

static int chkpage ( char *  pag  )  [static]

Definition at line 858 of file _sdbm.c.

References GET_SHORT, and PBLKSIZ.

Referenced by getnext(), and getpage().

static int delpair ( char *  pag,
datum  key 
) [static]

Definition at line 731 of file _sdbm.c.

References debug, datum::dptr, datum::dsize, GET_SHORT, memmove(), PBLKSIZ, PUT_SHORT, and seepair().

Referenced by sdbm_delete(), and sdbm_store().

static int duppair ( char *  pag,
datum  key 
) [static]

Definition at line 703 of file _sdbm.c.

References datum::dptr, datum::dsize, GET_SHORT, and seepair().

Referenced by sdbm_store().

static int fitpair ( char *  pag,
int  need 
) [static]

Definition at line 638 of file _sdbm.c.

References debug, free, GET_SHORT, and PBLKSIZ.

Referenced by makroom(), and sdbm_store().

static int getdbit ( register DBM db,
register long int  dbit 
) [static]

Definition at line 508 of file _sdbm.c.

References BYTESIZ, DBLKSIZ, debug, DBM::dirbno, DBM::dirbuf, DBM::dirf, OFF_DIR, and SEEK_SET.

Referenced by getpage().

static datum getnext ( register DBM db  )  [static]

static datum getnkey ( char *  pag,
int  num 
) [static]

Definition at line 712 of file _sdbm.c.

References datum::dptr, datum::dsize, GET_SHORT, and PBLKSIZ.

Referenced by getnext().

static int getpage ( register DBM db,
register long int  hash 
) [static]

static datum getpair ( char *  pag,
datum  key 
) [static]

Definition at line 683 of file _sdbm.c.

References datum::dptr, datum::dsize, GET_SHORT, and seepair().

Referenced by sdbm_fetch().

static int makroom ( register DBM db,
long int  hash,
int  need 
) [static]

static int seepair proto ( (char *, int, char *, int)   )  [static]

static int makroom proto ( (DBM *, long, int)   )  [static]

static datum getnext proto ( (DBM *)   )  [static]

static int getpage proto ( (DBM *, long)   )  [static]

static void splpage proto ( (char *, char *, long)   )  [static]

static int chkpage proto ( (char *)   )  [static]

static int duppair proto ( (char *, datum  )  [static]

static void putpair proto ( (char *, datum, datum  )  [static]

static datum getnkey proto ( (char *, int)   )  [static]

static void putpair ( char *  pag,
datum  key,
datum  val 
) [static]

Definition at line 655 of file _sdbm.c.

References datum::dptr, datum::dsize, GET_SHORT, PBLKSIZ, and PUT_SHORT.

Referenced by sdbm_store(), and splpage().

void sdbm_close ( register DBM db  ) 

Definition at line 233 of file _sdbm.c.

References DBM::dirf, free, NULL, and DBM::pagf.

Referenced by free_sdbm(), and fsdbm_close().

int sdbm_delete ( register DBM db,
datum  key 
)

datum sdbm_fetch ( register DBM db,
datum  key 
)

datum sdbm_firstkey ( register DBM db  ) 

long sdbm_hash ( register char *  str,
register int  len 
)

Definition at line 898 of file _sdbm.c.

datum sdbm_nextkey ( register DBM db  ) 

DBM* sdbm_open ( register char *  file,
register int  flags,
register int  mode 
)

Definition at line 148 of file _sdbm.c.

References DIRFEXT, free, malloc, NULL, PAGFEXT, and sdbm_prep().

Referenced by fsdbm_initialize().

DBM* sdbm_prep ( char *  dirname,
char *  pagname,
int  flags,
int  mode 
)

int sdbm_store ( register DBM db,
datum  key,
datum  val,
int  flags 
)

static int seepair ( char *  pag,
register int  n,
register char *  key,
register int  siz 
) [static]

Definition at line 801 of file _sdbm.c.

References GET_SHORT, memcmp(), and PBLKSIZ.

Referenced by delpair(), duppair(), and getpair().

static int setdbit ( register DBM db,
register long int  dbit 
) [static]

Definition at line 529 of file _sdbm.c.

References BYTESIZ, DBLKSIZ, debug, DBM::dirbno, DBM::dirbuf, DBM::dirf, DBM::maxbno, OFF_DIR, and SEEK_SET.

Referenced by makroom().

static void splpage ( char *  pag,
char *  new,
long int  sbit 
) [static]

Definition at line 817 of file _sdbm.c.

References debug, datum::dptr, datum::dsize, exhash, GET_SHORT, PBLKSIZ, and putpair().

Referenced by makroom().


Variable Documentation

int errno

Referenced by argf_next_argv(), atanh(), BigDecimal_to_f(), call_asynchronous(), check_spawn_mode(), copy_stream_finalize(), CreateChild(), dir_initialize(), dir_read(), dln_load(), do_lstat(), do_opendir(), do_select(), do_stat(), dup2(), fcntl(), fdbm_store(), fgdbm_store(), finish_writeconv(), flock_winnt(), flush_before_seek(), fptr_finalize(), fsdbm_store(), function_call(), iconv_create(), iconv_try(), io_binwrite(), io_flush_buffer_sync(), io_getpartial(), io_reopen(), io_unread(), ioctl(), kill(), lgamma_r(), make_errno_exc(), maygvl_copy_stream_read(), maygvl_copy_stream_wait_read(), nogvl_copy_stream_read_write(), nogvl_copy_stream_wait_write(), nogvl_copy_stream_write(), open_dir_handle(), opendir_internal(), ossl_pkey_new_from_file(), ossl_ssl_write_internal(), ossl_start_ssl(), ossl_x509_new_from_file(), overlapped_socket_io(), p_gid_change_privilege(), p_gid_switch(), p_uid_change_privilege(), p_uid_switch(), pack_pack(), pack_unpack(), parser_yylex(), pipe_open(), poll_child_status(), proc_exec_v(), proc_waitall(), rb_chsize(), rb_cstr_to_dbl(), rb_dlcfunc_call(), rb_fdopen(), rb_file_flock(), rb_file_s_rename(), rb_iconv_sys_fail(), rb_io_each_byte(), rb_io_rewind(), rb_io_seek(), rb_io_set_pos(), rb_io_sysseek(), rb_io_tell(), rb_io_wait_readable(), rb_io_wait_writable(), rb_io_write_nonblock(), rb_load_fail(), rb_pipe(), rb_proc_exec(), rb_strftime_alloc(), rb_strftime_with_timespec(), rb_sys_warning(), rb_sysopen(), rb_syswait(), rb_thread_blocking_region(), rb_thread_blocking_region_end(), rb_thread_flock(), rb_w32_accept(), rb_w32_access(), rb_w32_asynchronize(), rb_w32_bind(), rb_w32_close(), rb_w32_connect(), rb_w32_fclose(), rb_w32_getc(), rb_w32_getcwd(), rb_w32_gethostbyaddr(), rb_w32_gethostbyname(), rb_w32_gethostname(), rb_w32_getpeername(), rb_w32_getprotobyname(), rb_w32_getprotobynumber(), rb_w32_getservbyname(), rb_w32_getservbyport(), rb_w32_getsockname(), rb_w32_getsockopt(), rb_w32_ioctlsocket(), rb_w32_isatty(), rb_w32_listen(), rb_w32_open_osfhandle(), rb_w32_opendir(), rb_w32_pipe(), rb_w32_read(), rb_w32_select(), rb_w32_setsockopt(), rb_w32_shutdown(), rb_w32_socket(), rb_w32_uaccess(), rb_w32_wopen(), rb_w32_write(), rb_waitpid(), readline_readline(), realpath_rec(), recvmsg(), rsock_connect(), rsock_s_accept(), rsock_s_accept_nonblock(), rsock_s_recvfrom_nonblock(), rsock_socket(), ruby_close(), ruby_dup(), ruby_getcwd(), ruby_getpeername(), ruby_getsockname(), ruby_setenv(), ruby_shutdown(), ruby_strtod(), ruby_strtoul(), save_redirect_fd(), sendmsg(), sock_connect_nonblock(), socketpair_internal(), strio_init(), tgamma(), truncate(), unixtime_to_filetime(), wait_connectable0(), waitpid(), winnt_stat(), wlink(), wmkdir(), wrename(), wrmdir(), wstati64(), wunlink(), and wutime().

long masks[] [static]

Initial value:

 {
        000000000000L, 000000000001L, 000000000003L,
        000000000007L, 000000000017L, 000000000037L,
        000000000077L, 000000000177L, 000000000377L,
        000000000777L, 000000001777L, 000000003777L,
        000000007777L, 000000017777L, 000000037777L,
        000000077777L, 000000177777L, 000000377777L,
        000000777777L, 000001777777L, 000003777777L,
        000007777777L, 000017777777L, 000037777777L,
        000077777777L, 000177777777L, 000377777777L,
        000777777777L, 001777777777L, 003777777777L,
        007777777777L, 017777777777L
}

Definition at line 131 of file _sdbm.c.

datum nullitem = {NULL, 0}

Definition at line 145 of file _sdbm.c.


doxygen