Ruby 2.7.0p0(2019-12-25revision647ee6f091eafcce70ffb75ddf7e121e192ab217)

Macros | Functions | Variables
_sdbm.c File Reference
`#include "ruby/ruby.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.

## Macros
#define | BYTESIZ 8
#define | SEEDUPS 1 /* always detect duplicates */
#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
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)
datum | sdbm_firstkey (register DBM *db)
datum | sdbm_nextkey (register DBM *db)
long | sdbm_hash (register char *str, register int len)

## Variables
int | errno
datum | nullitem = {NULL, 0}

## Macro Definition Documentation

## ◆ bad

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

Definition at line 123 of file _sdbm.c.

## ◆ BADMESS

#define BADMESS

Value:
1 /* generate a message for worst case:
cannot make room after SPLTMAX splits */

Definition at line 41 of file _sdbm.c.

## ◆ BYTESIZ

#define BYTESIZ 8

Definition at line 24 of file _sdbm.c.

## ◆ debug

#define debug | ( |  | x | ) |

Definition at line 50 of file _sdbm.c.

## ◆ EPERM

#define EPERM EACCES

Definition at line 92 of file _sdbm.c.

## ◆ exhash [1/2]

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

Definition at line 637 of file _sdbm.c.

## ◆ exhash [2/2]

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

Definition at line 637 of file _sdbm.c.

## ◆ GET_SHORT

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

Definition at line 57 of file _sdbm.c.

## ◆ ioerr

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

Definition at line 125 of file _sdbm.c.

## ◆ NULL

#define NULL 0

Definition at line 101 of file _sdbm.c.

## ◆ O_BINARY

#define O_BINARY 0

Definition at line 87 of file _sdbm.c.

## ◆ OFF_DIR

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

Definition at line 128 of file _sdbm.c.

## ◆ OFF_PAG

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

Definition at line 127 of file _sdbm.c.

## ◆ PUT_SHORT

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

Definition at line 58 of file _sdbm.c.

## ◆ SEEDUPS

#define SEEDUPS 1 /* always detect duplicates */

Definition at line 38 of file _sdbm.c.

## Function Documentation

## ◆ sdbm_close()

void sdbm_close | ( | register DBM * | db | ) |

Definition at line 264 of file _sdbm.c.

References close(), DBM::dirf, EINVAL, errno, free, NULL, DBM::pagf, and void.

## ◆ sdbm_delete()

int sdbm_delete | ( | register DBM * | db,
|  | datum | key
| ) |  |

Definition at line 288 of file _sdbm.c.

References bad, EINVAL, EPERM, errno, key, NULL, and sdbm_rdonly.

## ◆ sdbm_fetch()

datum sdbm_fetch | ( | register DBM * | db,
|  | datum | key
| ) |  |

Definition at line 276 of file _sdbm.c.

References bad, EINVAL, errno, key, NULL, and nullitem.

## ◆ sdbm_firstkey()

datum sdbm_firstkey | ( | register DBM * | db | ) |

Definition at line 467 of file _sdbm.c.

References DBM::blkptr, EINVAL, errno, ioerr, DBM::keyptr, lseek(), memset(), NULL, nullitem, OFF_PAG, DBM::pagbno, DBM::pagbuf, DBM::pagf, PBLKSIZ, read(), SEEK_SET, and void.

## ◆ sdbm_hash()

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

Definition at line 925 of file _sdbm.c.

References L, len, n, and str.

## ◆ sdbm_nextkey()

datum sdbm_nextkey | ( | register DBM * | db | ) |

Definition at line 486 of file _sdbm.c.

References EINVAL, errno, NULL, and nullitem.

## ◆ sdbm_open()

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

Definition at line 147 of file _sdbm.c.

References DIRFEXT, EINVAL, ENOMEM, errno, free, malloc(), n, NULL, PAGFEXT, sdbm_prep(), strcat(), strcpy(), and strlen().

## ◆ sdbm_prep()

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

Definition at line 199 of file _sdbm.c.

References DBM::blkptr, DBM_RDONLY, DBM::dirf, ENOMEM, err, errno, DBM::flags, DBM::hmask, DBM::keyptr, malloc(), NULL, O_BINARY, O_CLOEXEC, and DBM::pagf.

Referenced by sdbm_open().

## ◆ sdbm_store()

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

Definition at line 312 of file _sdbm.c.

## Variable Documentation

## ◆ errno

int errno

Referenced by atanh(), clock_getres(), dup2(), fchmod(), fcntl(), gmtime_r(), ioctl(), kill(), lgamma_r(), localtime_r(), rb_cloexec_dup2(), rb_cloexec_fcntl_dupfd(), rb_cloexec_pipe(), rb_exec_async_signal_safe(), rb_fdopen(), rb_freopen(), rb_grantpt(), rb_maygvl_fd_fix_cloexec(), rb_pipe(), rb_sys_enc_warning(), rb_sys_warning(), rb_threadptr_root_fiber_setup(), rb_w32_access(), rb_w32_bind(), rb_w32_close(), rb_w32_connect(), rb_w32_fclose(), 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_getsockopt(), rb_w32_ioctlsocket(), rb_w32_isatty(), rb_w32_listen(), rb_w32_pipe(), rb_w32_select_with_thread(), rb_w32_setsockopt(), rb_w32_shutdown(), rb_w32_uaccess(), rb_w32_write(), rsock_detect_cloexec(), rsock_raise_socket_error(), 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_getcwd(), ruby_getpeername(), ruby_getsockname(), ruby_is_fd_loadable(), ruby_shutdown(), ruby_strtoul(), sdbm_close(), sdbm_delete(), sdbm_fetch(), sdbm_firstkey(), sdbm_nextkey(), sdbm_open(), sdbm_prep(), strtod(), and tgamma().

## ◆ nullitem

datum nullitem = {NULL, 0}

Definition at line 144 of file _sdbm.c.

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