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>

Go to the source code of this file.

Defines

#define BYTESIZ   8
#define SEEDUPS   1
#define BADMESS   1
#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)
static int fd_set_cloexec (int fd)
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)

Definition at line 125 of file _sdbm.c.

Referenced by get_addr(), rb_cstr_to_dbl(), rb_cstr_to_inum(), sdbm_delete(), sdbm_fetch(), sdbm_store(), and str2big_scan_digits().

#define BADMESS   1

Definition at line 42 of file _sdbm.c.

#define BYTESIZ   8

Definition at line 25 of file _sdbm.c.

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

#define debug (  ) 

Definition at line 52 of file _sdbm.c.

Referenced by delpair(), fitpair(), get_line_info(), getdbit(), getpage(), Init_syslog(), kanji_convert(), load_encoding(), makroom(), set_iconv(), setdbit(), and splpage().

#define EPERM   EACCES

Definition at line 94 of file _sdbm.c.

Referenced by fdbm_store(), fgdbm_store(), fsdbm_store(), kill(), p_gid_change_privilege(), p_gid_switch(), p_uid_change_privilege(), p_uid_switch(), sdbm_delete(), and sdbm_store().

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

Definition at line 639 of file _sdbm.c.

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

Definition at line 639 of file _sdbm.c.

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

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

Definition at line 59 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 127 of file _sdbm.c.

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

#define NULL   0

Definition at line 103 of file _sdbm.c.

#define O_BINARY   0

Definition at line 89 of file _sdbm.c.

Referenced by do_writeconv(), Init_File(), Init_IO(), init_stdhandle(), io_s_write(), load_file_internal(), prep_io(), rb_io_binmode(), rb_io_extract_modeenc(), rb_io_fmode_oflags(), rb_io_oflags_fmode(), rb_io_s_pipe(), rb_w32_accept(), rb_w32_open(), rb_w32_socket(), rb_w32_wopen(), sdbm_prep(), and socketpair().

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

Definition at line 130 of file _sdbm.c.

Referenced by getdbit(), and setdbit().

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

Definition at line 129 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 60 of file _sdbm.c.

Referenced by delpair(), and putpair().

#define SEEDUPS   1

Definition at line 39 of file _sdbm.c.


Function Documentation

static int chkpage ( char *  pag  )  [static]

Definition at line 887 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 760 of file _sdbm.c.

References debug, GET_SHORT, key, memmove(), PBLKSIZ, PRIdPTRDIFF, PUT_SHORT, and seepair().

Referenced by sdbm_delete(), and sdbm_store().

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

Definition at line 732 of file _sdbm.c.

References GET_SHORT, key, and seepair().

Referenced by sdbm_store().

static int fd_set_cloexec ( int  fd  )  [static]

Definition at line 178 of file _sdbm.c.

References fcntl().

Referenced by sdbm_prep().

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

Definition at line 667 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 541 of file _sdbm.c.

References BYTESIZ, DBLKSIZ, debug, OFF_DIR, and SEEK_SET.

Referenced by getpage().

static datum getnext ( register DBM db  )  [static]

Definition at line 596 of file _sdbm.c.

References chkpage(), getnkey(), if(), key, NULL, OFF_PAG, PBLKSIZ, and SEEK_SET.

Referenced by sdbm_firstkey(), and sdbm_nextkey().

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

Definition at line 741 of file _sdbm.c.

References GET_SHORT, key, nullitem, and PBLKSIZ.

Referenced by getnext().

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

Definition at line 499 of file _sdbm.c.

References chkpage(), debug, getdbit(), long, OFF_PAG, PBLKSIZ, and SEEK_SET.

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

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

Definition at line 712 of file _sdbm.c.

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

Referenced by sdbm_fetch().

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

Definition at line 372 of file _sdbm.c.

References debug, fitpair(), OFF_PAG, PBLKSIZ, SEEK_END, SEEK_SET, setdbit(), splpage(), and SPLTMAX.

Referenced by sdbm_store().

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 684 of file _sdbm.c.

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

Referenced by sdbm_store(), and splpage().

void sdbm_close ( register DBM db  ) 

Definition at line 266 of file _sdbm.c.

References free, and NULL.

Referenced by free_sdbm(), and fsdbm_close().

int sdbm_delete ( register DBM db,
datum  key 
)

Definition at line 290 of file _sdbm.c.

References bad, delpair(), EPERM, exhash, getpage(), ioerr, key, NULL, OFF_PAG, PBLKSIZ, sdbm_rdonly, and SEEK_SET.

Referenced by fsdbm_clear(), fsdbm_delete(), fsdbm_delete_if(), and fsdbm_shift().

datum sdbm_fetch ( register DBM db,
datum  key 
)

Definition at line 278 of file _sdbm.c.

References bad, exhash, getpage(), getpair(), ioerr, key, NULL, and nullitem.

Referenced by fsdbm_delete(), fsdbm_delete_if(), fsdbm_each_pair(), fsdbm_each_value(), fsdbm_fetch(), fsdbm_has_key(), fsdbm_has_value(), fsdbm_invert(), fsdbm_key(), fsdbm_select(), fsdbm_shift(), fsdbm_to_a(), fsdbm_to_hash(), and fsdbm_values().

datum sdbm_firstkey ( register DBM db  ) 

Definition at line 469 of file _sdbm.c.

References getnext(), ioerr, NULL, nullitem, OFF_PAG, PBLKSIZ, and SEEK_SET.

Referenced by fsdbm_clear(), fsdbm_delete_if(), fsdbm_each_key(), fsdbm_each_pair(), fsdbm_each_value(), fsdbm_empty_p(), fsdbm_has_value(), fsdbm_invert(), fsdbm_key(), fsdbm_keys(), fsdbm_length(), fsdbm_select(), fsdbm_shift(), fsdbm_to_a(), fsdbm_to_hash(), and fsdbm_values().

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

Definition at line 927 of file _sdbm.c.

datum sdbm_nextkey ( register DBM db  ) 

Definition at line 488 of file _sdbm.c.

References getnext(), NULL, and nullitem.

Referenced by fsdbm_delete_if(), fsdbm_each_key(), fsdbm_each_pair(), fsdbm_each_value(), fsdbm_empty_p(), fsdbm_has_value(), fsdbm_invert(), fsdbm_key(), fsdbm_keys(), fsdbm_length(), fsdbm_select(), fsdbm_to_a(), fsdbm_to_hash(), and fsdbm_values().

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

Definition at line 149 of file _sdbm.c.

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

Referenced by fsdbm_initialize().

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

Definition at line 201 of file _sdbm.c.

References DBM::blkptr, BYTESIZ, DBLKSIZ, DBM_RDONLY, DBM::dirbno, DBM::dirbuf, DBM::dirf, err, fd_set_cloexec(), DBM::flags, free, fstat, DBM::hmask, DBM::keyptr, long, malloc, DBM::maxbno, NULL, O_BINARY, O_CLOEXEC, DBM::pagbno, DBM::pagbuf, DBM::pagf, PBLKSIZ, and stat.

Referenced by sdbm_open().

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

Definition at line 314 of file _sdbm.c.

References bad, DBM_REPLACE, delpair(), datum::dsize, duppair(), EPERM, exhash, fitpair(), getpage(), hash(), ioerr, key, makroom(), NULL, OFF_PAG, PAIRMAX, PBLKSIZ, putpair(), sdbm_rdonly, and SEEK_SET.

Referenced by fsdbm_store().

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

Definition at line 830 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 562 of file _sdbm.c.

References BYTESIZ, DBLKSIZ, debug, long, OFF_DIR, and SEEK_SET.

Referenced by makroom().

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

Definition at line 846 of file _sdbm.c.

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

Referenced by makroom().


Variable Documentation

int errno

Referenced by argf_next_argv(), atanh(), BigDecimal_to_f(), call_asynchronous(), call_without_gvl(), check_if_wdir(), check_spawn_mode(), check_valid_dir(), clock_getres(), clock_gettime(), cloexec_accept(), copy_stream_finalize(), CreateChild(), date_strftime_with_tmx(), dir_initialize(), dir_read(), dln_load(), do_opendir(), do_select(), do_stat(), dup2(), dupfd(), establishShell(), fcntl(), fdbm_store(), fgdbm_store(), fill_standard_fds(), finish_overlapped_socket(), finish_writeconv(), flock_winnt(), flush_before_seek(), fptr_finalize(), fsdbm_store(), function_call(), get_wsa_extension_function(), getifaddrs(), gmtime_r(), io_binwrite(), io_flush_buffer_async2(), io_flush_buffer_sync(), io_getpartial(), io_reopen(), io_unread(), io_write_nonblock(), ioctl(), kill(), lgamma_r(), load_file_internal(), localtime_r(), make_errno_exc(), make_errno_exc_str(), maygvl_copy_stream_continue_p(), maygvl_copy_stream_read(), maygvl_copy_stream_wait_read(), nogvl_copy_stream_read_write(), nogvl_copy_stream_wait_write(), nogvl_copy_stream_write(), nogvl_getaddrinfo(), 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_unpack(), parser_yylex(), pipe_open(), poll_child_status(), proc_exec_cmd(), proc_exec_sh(), proc_exec_v(), proc_waitall(), rb_chsize(), rb_clock_getres(), rb_clock_gettime(), rb_cloexec_dup2(), rb_cloexec_fcntl_dupfd(), rb_cloexec_pipe(), rb_cstr_to_dbl(), rb_dlcfunc_call(), rb_fdopen(), rb_file_flock(), rb_file_s_rename(), rb_io_each_byte(), rb_io_reopen(), 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_maygvl_fd_fix_cloexec(), rb_pipe(), rb_readwrite_sys_fail(), rb_strftime_alloc(), rb_strftime_with_timespec(), rb_sys_warning(), rb_sysopen(), rb_thread_blocking_region_end(), rb_thread_flock(), rb_thread_io_blocking_region(), rb_update_max_fd(), 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(), rb_w32_open_osfhandle(), rb_w32_pipe(), rb_w32_read(), rb_w32_select_with_thread(), rb_w32_setsockopt(), rb_w32_shutdown(), rb_w32_socket(), rb_w32_truncate(), rb_w32_uaccess(), rb_w32_wopen(), rb_w32_wrap_io_handle(), rb_w32_write(), rb_wait_for_single_fd(), rb_waitpid(), readline_s_set_input(), readline_s_set_output(), realpath_rec(), recvmsg(), rsock_connect(), rsock_s_accept(), rsock_s_accept_nonblock(), rsock_s_recvfrom_nonblock(), rsock_socket(), rsock_socket0(), rsock_sys_fail_host_port(), rsock_sys_fail_path(), rsock_sys_fail_raddrinfo(), rsock_sys_fail_raddrinfo_or_sockaddr(), rsock_sys_fail_sockaddr(), ruby_close(), ruby_dup(), ruby_getcwd(), ruby_getpeername(), ruby_getsockname(), ruby_shutdown(), ruby_strtod(), ruby_strtoul(), save_redirect_fd(), select_single(), sendmsg(), setfl(), setup_overlapped(), sock_connect_nonblock(), sock_s_getnameinfo(), socketpair_internal(), strio_init(), sys_warning_1(), tgamma(), ttymode(), w32_aspawn_flags(), w32_spawn(), wait_connectable(), 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 132 of file _sdbm.c.

datum nullitem = {NULL, 0}

Definition at line 146 of file _sdbm.c.

Referenced by getnkey(), getpair(), sdbm_fetch(), sdbm_firstkey(), and sdbm_nextkey().


Generated on 19 Jul 2016 for Ruby by  doxygen 1.4.7