67 static VALUE rb_cDBM, rb_eDBMError;
77 rb_raise(rb_eDBMError,
"closed SDBM file");
80 #define GetDBM(obj, dbmp) do {\ 81 TypedData_Get_Struct((obj), struct dbmdata, &sdbm_type, (dbmp));\ 82 if ((dbmp) == 0) closed_sdbm();\ 83 if ((dbmp)->di_dbm == 0) closed_sdbm();\ 86 #define GetDBM2(obj, dbmp, dbm) do {\ 87 GetDBM((obj), (dbmp));\ 88 (dbm) = (dbmp)->di_dbm;\ 101 memsize_dbm(
const void *ptr)
104 const struct dbmdata *dbmp = ptr;
106 size +=
sizeof(*dbmp);
114 {0, free_sdbm, memsize_dbm,},
128 fsdbm_close(
VALUE obj)
146 fsdbm_closed(
VALUE obj)
160 fsdbm_alloc(
VALUE klass)
190 else if (
NIL_P(vmode)) {
207 if (mode == -1)
return Qnil;
240 VALUE obj = fsdbm_alloc(klass);
266 if (value.
dptr == 0) {
285 return fsdbm_fetch(obj, keystr,
Qnil);
305 VALUE keystr, valstr, ifnone;
308 valstr = fsdbm_fetch(obj, keystr, ifnone);
350 rb_warn(
"SDBM#index is deprecated; use SDBM#key");
351 return fsdbm_key(hash, value);
374 fsdbm_select(
VALUE obj)
408 for (i=0; i<
argc; i++) {
416 fdbm_modify(
VALUE obj)
450 if (value.
dptr == 0) {
460 rb_raise(rb_eDBMError,
"dbm_delete failed");
476 fsdbm_shift(
VALUE obj)
481 VALUE keystr, valstr;
507 fsdbm_delete_if(
VALUE obj)
512 VALUE keystr, valstr;
526 if (status != 0)
break;
537 rb_raise(rb_eDBMError,
"sdbm_delete failed");
553 fsdbm_clear(
VALUE obj)
564 rb_raise(rb_eDBMError,
"sdbm_delete failed");
589 fsdbm_invert(
VALUE obj)
594 VALUE keystr, valstr;
626 if (valstr ==
Qnil) {
627 fsdbm_delete(obj, keystr);
644 #ifdef HAVE_DBM_CLAERERR 648 rb_raise(rb_eDBMError,
"sdbm_store failed");
663 fsdbm_store(dbm, ptr[0], ptr[1]);
708 fsdbm_length(
VALUE obj)
733 fsdbm_empty_p(
VALUE obj)
764 fsdbm_each_value(
VALUE obj)
791 fsdbm_each_key(
VALUE obj)
819 fsdbm_each_pair(
VALUE obj)
824 VALUE keystr, valstr;
847 fsdbm_keys(
VALUE obj)
870 fsdbm_values(
VALUE obj)
958 fsdbm_to_a(
VALUE obj)
983 fsdbm_to_hash(
VALUE obj)
1010 fsdbm_reject(
VALUE obj)
VALUE rb_protect(VALUE(*proc)(VALUE), VALUE data, int *pstate)
Protects a function call from potential global escapes from the function.
void rb_warn(const char *fmt,...)
#define RUBY_TYPED_FREE_IMMEDIATELY
void rb_define_singleton_method(VALUE obj, const char *name, VALUE(*func)(ANYARGS), int argc)
Defines a singleton method for obj.
int rb_block_given_p(void)
Determines if the current method is given a block.
void rb_raise(VALUE exc, const char *fmt,...)
void rb_jump_tag(int tag)
Continues the exception caught by rb_protect() and rb_eval_string_protect().
#define TypedData_Wrap_Struct(klass, data_type, sval)
#define TypedData_Get_Struct(obj, type, data_type, sval)
VALUE rb_ary_push(VALUE ary, VALUE item)
void rb_define_alloc_func(VALUE, rb_alloc_func_t)
void rb_include_module(VALUE klass, VALUE module)
VALUE rb_block_call(VALUE, ID, int, const VALUE *, rb_block_call_func_t, VALUE)
VALUE rb_ensure(VALUE(*b_proc)(ANYARGS), VALUE data1, VALUE(*e_proc)(ANYARGS), VALUE data2)
An equivalent to ensure clause.
#define RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg)
void sdbm_close(register DBM *db)
DBM * sdbm_open(register char *file, register int flags, register int mode)
VALUE rb_hash_aset(VALUE hash, VALUE key, VALUE val)
RUBY_EXTERN VALUE rb_cObject
VALUE rb_define_class(const char *name, VALUE super)
Defines a top-level class.
datum sdbm_firstkey(register DBM *db)
VALUE rb_external_str_new(const char *, long)
void rb_error_frozen(const char *what)
void rb_sys_fail(const char *mesg)
#define RARRAY_CONST_PTR(a)
int rb_scan_args(int argc, const VALUE *argv, const char *fmt,...)
VALUE rb_assoc_new(VALUE car, VALUE cdr)
int memcmp(const void *s1, const void *s2, size_t len)
#define sdbm_clearerr(db)
#define RARRAY_LENINT(ary)
int sdbm_store(register DBM *db, datum key, datum val, int flags)
#define ExportStringValue(v)
#define RARRAY_AREF(a, i)
#define GetDBM(obj, dbmp)
#define GetDBM2(obj, dbmp, dbm)
#define RETURN_ENUMERATOR(obj, argc, argv)
datum sdbm_nextkey(register DBM *db)
#define RSTRING_LENINT(str)
VALUE rb_hash_delete_if(VALUE hash)
int sdbm_delete(register DBM *db, datum key)
datum sdbm_fetch(register DBM *db, datum key)
void rb_sys_fail_str(VALUE mesg)
void rb_define_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)