#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 | 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)) |
| DBM * | sdbm_open (register char *file, register int flags, register int mode) |
| DBM * | sdbm_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 | |
| static long | masks [] |
| datum | nullitem = {NULL, 0} |
| #define bad | ( | x | ) | ((x).dptr == NULL || (x).dsize < 0) |
Definition at line 129 of file _sdbm.c.
Referenced by get_addr(), getaddrinfo(), rb_cstr_to_dbl(), rb_cstr_to_inum(), sdbm_delete(), sdbm_fetch(), sdbm_store(), and syck_hdlr_add_anchor().
| #define BYTESIZ 8 |
Definition at line 29 of file _sdbm.c.
Referenced by getdbit(), sdbm_prep(), and setdbit().
| #define debug | ( | x | ) |
Definition at line 56 of file _sdbm.c.
Referenced by delpair(), fitpair(), getdbit(), getpage(), Init_syslog(), kanji_convert(), load_encoding(), makroom(), set_iconv(), setdbit(), and splpage().
| #define EPERM EACCES |
Definition at line 98 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) |
| #define exhash | ( | item | ) | sdbm_hash((item).dptr, (item).dsize) |
Definition at line 615 of file _sdbm.c.
Referenced by sdbm_delete(), sdbm_fetch(), sdbm_store(), and splpage().
| #define GET_SHORT | ( | p, | |||
| i | ) | ((p)[(i)]) |
| #define ioerr | ( | db | ) | ((db)->flags |= DBM_IOERR) |
Definition at line 131 of file _sdbm.c.
Referenced by getnext(), sdbm_delete(), sdbm_fetch(), sdbm_firstkey(), and sdbm_store().
| #define O_BINARY 0 |
Definition at line 93 of file _sdbm.c.
Referenced by copy_stream_body(), do_writeconv(), 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_socketpair(), rb_w32_wopen(), sdbm_prep(), and set_binary_mode_with_seek_cur().
| #define OFF_DIR | ( | off | ) | (long) (off) * DBLKSIZ |
| #define OFF_PAG | ( | off | ) | (long) (off) * PBLKSIZ |
Definition at line 133 of file _sdbm.c.
Referenced by getnext(), getpage(), makroom(), sdbm_delete(), sdbm_firstkey(), and sdbm_store().
| #define PUT_SHORT | ( | p, | |||
| i, | |||||
| s | ) | ((p)[(i)] = (s)) |
| static int chkpage | ( | char * | pag | ) | [static] |
| static int delpair | ( | char * | pag, | |
| datum | key | |||
| ) | [static] |
Definition at line 736 of file _sdbm.c.
References debug, datum::dptr, datum::dsize, GET_SHORT, 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 708 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] |
| static int getdbit | ( | register DBM * | db, | |
| register long int | dbit | |||
| ) | [static] |
Definition at line 568 of file _sdbm.c.
References DBM::blkptr, chkpage(), datum::dptr, getnkey(), ioerr, DBM::keyptr, NULL, OFF_PAG, DBM::pagbno, DBM::pagbuf, DBM::pagf, PBLKSIZ, and SEEK_SET.
Referenced by sdbm_firstkey(), and sdbm_nextkey().
| static datum getnkey | ( | char * | pag, | |
| int | num | |||
| ) | [static] |
Definition at line 717 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] |
Definition at line 471 of file _sdbm.c.
References chkpage(), DBM::curbit, debug, getdbit(), DBM::hmask, long, OFF_PAG, DBM::pagbno, DBM::pagbuf, DBM::pagf, PBLKSIZ, and SEEK_SET.
Referenced by sdbm_delete(), sdbm_fetch(), and sdbm_store().
Definition at line 688 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] |
Definition at line 344 of file _sdbm.c.
References DBM::curbit, debug, fitpair(), DBM::hmask, OFF_PAG, DBM::pagbno, DBM::pagbuf, DBM::pagf, 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 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 datum getnkey proto | ( | (char *, int) | ) | [static] |
Definition at line 660 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 238 of file _sdbm.c.
References DBM::dirf, free, NULL, and DBM::pagf.
Referenced by free_sdbm(), and fsdbm_close().
Definition at line 262 of file _sdbm.c.
References bad, delpair(), EPERM, exhash, getpage(), ioerr, NULL, OFF_PAG, DBM::pagbno, DBM::pagbuf, DBM::pagf, PBLKSIZ, sdbm_rdonly, and SEEK_SET.
Referenced by fsdbm_clear(), fsdbm_delete(), fsdbm_delete_if(), and fsdbm_shift().
Definition at line 250 of file _sdbm.c.
References bad, exhash, getpage(), getpair(), ioerr, NULL, and DBM::pagbuf.
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().
Definition at line 441 of file _sdbm.c.
References DBM::blkptr, getnext(), ioerr, DBM::keyptr, NULL, OFF_PAG, DBM::pagbno, DBM::pagbuf, DBM::pagf, 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().
Definition at line 460 of file _sdbm.c.
References getnext(), and NULL.
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 153 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 182 of file _sdbm.c.
References DBM::blkptr, BYTESIZ, DBLKSIZ, DBM_RDONLY, DBM::dirbno, DBM::dirbuf, DBM::dirf, DBM::flags, free, fstat, DBM::hmask, DBM::keyptr, long, malloc, DBM::maxbno, NULL, O_BINARY, open, DBM::pagbno, DBM::pagbuf, DBM::pagf, PBLKSIZ, and stat.
Referenced by sdbm_open().
Definition at line 286 of file _sdbm.c.
References bad, DBM_REPLACE, delpair(), datum::dsize, duppair(), EPERM, exhash, fitpair(), getpage(), ioerr, makroom(), NULL, OFF_PAG, DBM::pagbno, DBM::pagbuf, DBM::pagf, 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] |
| static int setdbit | ( | register DBM * | db, | |
| register long int | dbit | |||
| ) | [static] |
Definition at line 534 of file _sdbm.c.
References BYTESIZ, DBLKSIZ, debug, DBM::dirbno, DBM::dirbuf, DBM::dirf, long, DBM::maxbno, OFF_DIR, and SEEK_SET.
Referenced by makroom().
| static void splpage | ( | char * | pag, | |
| char * | new, | |||
| long int | sbit | |||
| ) | [static] |
Definition at line 822 of file _sdbm.c.
References debug, datum::dptr, datum::dsize, exhash, GET_SHORT, PBLKSIZ, and putpair().
Referenced by makroom().
long masks[] [static] |
{
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
}
1.6.1