Ruby 2.0.0p353(2013-11-22revision43784)

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

Data Structures | Macros | Functions | Variables
init.c File Reference
`#include "ruby.h"`
`#include "sdbm.h"`
`#include <fcntl.h>`
`#include <errno.h>`
Include dependency graph for init.c:

Go to the source code of this file.

## Data Structures
struct | dbmdata

## Macros
#define | GetDBM(obj, dbmp)
#define | GetDBM2(obj, data, dbm)

## Functions
static void | closed_sdbm ()
static void | free_sdbm (struct dbmdata *dbmp)
static VALUE | fsdbm_close (VALUE obj)
static VALUE | fsdbm_closed (VALUE obj)
static VALUE | fsdbm_alloc (VALUE klass)
static VALUE | fsdbm_initialize (int argc, VALUE *argv, VALUE obj)
static VALUE | fsdbm_s_open (int argc, VALUE *argv, VALUE klass)
static VALUE | fsdbm_fetch (VALUE obj, VALUE keystr, VALUE ifnone)
static VALUE | fsdbm_aref (VALUE obj, VALUE keystr)
static VALUE | fsdbm_fetch_m (int argc, VALUE *argv, VALUE obj)
static VALUE | fsdbm_key (VALUE obj, VALUE valstr)
static VALUE | fsdbm_index (VALUE hash, VALUE value)
static VALUE | fsdbm_select (VALUE obj)
static VALUE | fsdbm_values_at (int argc, VALUE *argv, VALUE obj)
static void | fdbm_modify (VALUE obj)
static VALUE | fsdbm_delete (VALUE obj, VALUE keystr)
static VALUE | fsdbm_shift (VALUE obj)
static VALUE | fsdbm_delete_if (VALUE obj)
static VALUE | fsdbm_clear (VALUE obj)
static VALUE | fsdbm_invert (VALUE obj)
static VALUE | fsdbm_store (VALUE obj, VALUE keystr, VALUE valstr)
static VALUE | update_i (VALUE pair, VALUE dbm)
static VALUE | fsdbm_update (VALUE obj, VALUE other)
static VALUE | fsdbm_replace (VALUE obj, VALUE other)
static VALUE | fsdbm_length (VALUE obj)
static VALUE | fsdbm_empty_p (VALUE obj)
static VALUE | fsdbm_each_value (VALUE obj)
static VALUE | fsdbm_each_key (VALUE obj)
static VALUE | fsdbm_each_pair (VALUE obj)
static VALUE | fsdbm_keys (VALUE obj)
static VALUE | fsdbm_values (VALUE obj)
static VALUE | fsdbm_has_key (VALUE obj, VALUE keystr)
static VALUE | fsdbm_has_value (VALUE obj, VALUE valstr)
static VALUE | fsdbm_to_a (VALUE obj)
static VALUE | fsdbm_to_hash (VALUE obj)
static VALUE | fsdbm_reject (VALUE obj)
void | Init_sdbm ()

## Variables
static VALUE | rb_cDBM
static VALUE | rb_eDBMError

## Macro Definition Documentation

#define GetDBM | ( |  | obj,
|  |  | dbmp
| ) |  |

Value:
{\
Data_Get_Struct((obj), struct dbmdata, (dbmp));\
if ((dbmp) == 0) closed_sdbm();\
if ((dbmp)->di_dbm == 0) closed_sdbm();\
}
dbmdata
Definition: dbm.c:37
obj
static VALUE VALUE obj
Definition: tcltklib.c:3158
closed_sdbm
static void closed_sdbm()
Definition: init.c:75
if
if(RB_TYPE_P(r, T_FLOAT))
Definition: bigdecimal.c:1186
Data_Get_Struct
#define Data_Get_Struct(obj, type, sval)

Definition at line 80 of file init.c.

Referenced by fsdbm_close(), and fsdbm_empty_p().

#define GetDBM2 | ( |  | obj,
|  |  | data,
|  |  | dbm
| ) |  |

Value:
{\
GetDBM((obj), (data));\
(dbm) = dbmp->di_dbm;\
}
data
VALUE data
Definition: tcltklib.c:3368
obj
static VALUE VALUE obj
Definition: tcltklib.c:3158
GetDBM
#define GetDBM(obj, dbmp)
Definition: init.c:80

Definition at line 86 of file init.c.

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

## Function Documentation

static void closed_sdbm | ( |  | ) |
| static

Definition at line 75 of file init.c.

References rb_eDBMError, and rb_raise().

static void fdbm_modify | ( | VALUE | obj | ) |
| static

Definition at line 397 of file init.c.

References OBJ_FROZEN, rb_error_frozen(), and rb_secure().

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

static void free_sdbm | ( | struct dbmdata * | dbmp | ) |
| static

Definition at line 92 of file init.c.

References dbmdata::di_dbm, ruby_xfree(), and sdbm_close().

Referenced by fsdbm_alloc(), and fsdbm_s_open().

static VALUE fsdbm_alloc | ( | VALUE | klass | ) |
| static

Definition at line 140 of file init.c.

References Data_Wrap_Struct(), and free_sdbm().

Referenced by Init_sdbm().

static VALUE fsdbm_aref | ( | VALUE | obj,
|  | VALUE | keystr
| ) |  |
| static

Definition at line 264 of file init.c.

References fsdbm_fetch(), and Qnil.

Referenced by Init_sdbm().

static VALUE fsdbm_clear | ( | VALUE | obj | ) |
| static

Definition at line 534 of file init.c.

References dbmdata::di_size, datum::dptr, fdbm_modify(), GetDBM2, key, obj, rb_eDBMError, rb_raise(), sdbm_delete(), and sdbm_firstkey().

Referenced by fsdbm_replace(), and Init_sdbm().

static VALUE fsdbm_close | ( | VALUE | obj | ) |
| static

Definition at line 108 of file init.c.

References dbmdata::di_dbm, GetDBM, Qnil, and sdbm_close().

Referenced by fsdbm_s_open(), and Init_sdbm().

static VALUE fsdbm_closed | ( | VALUE | obj | ) |
| static

Definition at line 126 of file init.c.

References Data_Get_Struct, dbmdata::di_dbm, Qfalse, and Qtrue.

Referenced by Init_sdbm().

static VALUE fsdbm_delete | ( | VALUE | obj,
|  | VALUE | keystr
| ) |  |
| static

Definition at line 416 of file init.c.

References dbmdata::di_size, datum::dptr, datum::dsize, ExportStringValue, fdbm_modify(), GetDBM2, key, Qnil, rb_block_given_p(), rb_eDBMError, rb_external_str_new(), rb_raise(), rb_yield(), RSTRING_LENINT, RSTRING_PTR, sdbm_delete(), sdbm_fetch(), and value.

Referenced by fsdbm_store(), and Init_sdbm().

static VALUE fsdbm_delete_if | ( | VALUE | obj | ) |
| static

Definition at line 489 of file init.c.

References ary, dbmdata::di_size, datum::dptr, datum::dsize, ExportStringValue, fdbm_modify(), GetDBM2, i, key, n, obj, RARRAY_LEN, RARRAY_LENINT, RARRAY_PTR(), rb_ary_new(), rb_ary_push(), rb_assoc_new(), rb_eDBMError, rb_external_str_new(), rb_jump_tag(), rb_protect(), rb_raise(), rb_str_dup(), rb_yield(), ret, RSTRING_LENINT, RSTRING_PTR, RTEST, sdbm_delete(), sdbm_fetch(), sdbm_firstkey(), sdbm_nextkey(), status, and val.

Referenced by Init_sdbm().

static VALUE fsdbm_each_key | ( | VALUE | obj | ) |
| static

Definition at line 770 of file init.c.

References datum::dptr, datum::dsize, GetDBM2, key, obj, rb_external_str_new(), rb_yield(), RETURN_ENUMERATOR, sdbm_firstkey(), and sdbm_nextkey().

Referenced by Init_sdbm().

static VALUE fsdbm_each_pair | ( | VALUE | obj | ) |
| static

Definition at line 798 of file init.c.

References datum::dptr, datum::dsize, GetDBM2, key, obj, rb_assoc_new(), rb_external_str_new(), rb_yield(), RETURN_ENUMERATOR, sdbm_fetch(), sdbm_firstkey(), sdbm_nextkey(), and val.

Referenced by Init_sdbm().

static VALUE fsdbm_each_value | ( | VALUE | obj | ) |
| static

Definition at line 743 of file init.c.

References datum::dptr, datum::dsize, GetDBM2, key, obj, rb_external_str_new(), rb_yield(), RETURN_ENUMERATOR, sdbm_fetch(), sdbm_firstkey(), sdbm_nextkey(), and val.

Referenced by Init_sdbm().

static VALUE fsdbm_empty_p | ( | VALUE | obj | ) |
| static

Definition at line 712 of file init.c.

References dbmdata::di_dbm, dbmdata::di_size, datum::dptr, GetDBM, key, Qfalse, Qtrue, sdbm_firstkey(), and sdbm_nextkey().

Referenced by Init_sdbm().

static VALUE fsdbm_fetch | ( | VALUE | obj,
|  | VALUE | keystr,
|  | VALUE | ifnone
| ) |  |
| static

Definition at line 235 of file init.c.

References datum::dptr, datum::dsize, ExportStringValue, GetDBM2, key, Qnil, rb_block_given_p(), rb_external_str_new(), rb_yield(), RSTRING_LENINT, RSTRING_PTR, sdbm_fetch(), and value.

Referenced by fsdbm_aref(), fsdbm_fetch_m(), and fsdbm_values_at().

static VALUE fsdbm_fetch_m | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | obj
| ) |  |
| static

Definition at line 284 of file init.c.

References fsdbm_fetch(), NIL_P(), rb_block_given_p(), rb_eIndexError, rb_raise(), and rb_scan_args().

Referenced by Init_sdbm().

static VALUE fsdbm_has_key | ( | VALUE | obj,
|  | VALUE | keystr
| ) |  |
| static

Definition at line 876 of file init.c.

References datum::dptr, datum::dsize, ExportStringValue, GetDBM2, key, Qfalse, Qtrue, RSTRING_LENINT, RSTRING_PTR, sdbm_fetch(), and val.

Referenced by Init_sdbm().

static VALUE fsdbm_has_value | ( | VALUE | obj,
|  | VALUE | valstr
| ) |  |
| static

Definition at line 900 of file init.c.

References datum::dptr, datum::dsize, ExportStringValue, GetDBM2, key, memcmp(), Qfalse, Qtrue, RSTRING_LENINT, RSTRING_PTR, sdbm_fetch(), sdbm_firstkey(), sdbm_nextkey(), and val.

Referenced by Init_sdbm().

static VALUE fsdbm_index | ( | VALUE | hash,
|  | VALUE | value
| ) |  |
| static

Definition at line 329 of file init.c.

References fsdbm_key(), and rb_warn().

Referenced by Init_sdbm().

static VALUE fsdbm_initialize | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | obj
| ) |  |
| static

Definition at line 160 of file init.c.

References ALLOC, DATA_PTR(), dbmdata::di_dbm, dbmdata::di_size, FilePathValue, mode, NIL_P(), NUM2INT, obj, Qnil, rb_scan_args(), rb_sys_fail_str(), RSTRING_PTR, and sdbm_open().

Referenced by fsdbm_s_open(), and Init_sdbm().

static VALUE fsdbm_invert | ( | VALUE | obj | ) |
| static

Definition at line 570 of file init.c.

References datum::dptr, datum::dsize, GetDBM2, hash, key, rb_external_str_new(), rb_hash_aset(), rb_hash_new(), sdbm_fetch(), sdbm_firstkey(), sdbm_nextkey(), and val.

Referenced by Init_sdbm().

static VALUE fsdbm_key | ( | VALUE | obj,
|  | VALUE | valstr
| ) |  |
| static

Definition at line 305 of file init.c.

References datum::dptr, datum::dsize, ExportStringValue, GetDBM2, key, memcmp(), Qnil, rb_external_str_new(), RSTRING_LEN, RSTRING_LENINT, RSTRING_PTR, sdbm_fetch(), sdbm_firstkey(), sdbm_nextkey(), and val.

Referenced by fsdbm_index(), and Init_sdbm().

static VALUE fsdbm_keys | ( | VALUE | obj | ) |
| static

Definition at line 826 of file init.c.

References ary, datum::dptr, datum::dsize, GetDBM2, key, rb_ary_new(), rb_ary_push(), rb_external_str_new(), sdbm_firstkey(), and sdbm_nextkey().

Referenced by Init_sdbm().

static VALUE fsdbm_length | ( | VALUE | obj | ) |
| static

Definition at line 687 of file init.c.

References dbmdata::di_size, datum::dptr, GetDBM2, i, INT2FIX, key, sdbm_firstkey(), and sdbm_nextkey().

Referenced by Init_sdbm().

static VALUE fsdbm_reject | ( | VALUE | obj | ) |
| static

Definition at line 989 of file init.c.

References fsdbm_to_hash(), and rb_hash_delete_if().

Referenced by Init_sdbm().

static VALUE fsdbm_replace | ( | VALUE | obj,
|  | VALUE | other
| ) |  |
| static

Definition at line 672 of file init.c.

References fsdbm_clear(), obj, rb_block_call(), rb_intern, and update_i().

Referenced by Init_sdbm().

static VALUE fsdbm_s_open | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | klass
| ) |  |
| static

Definition at line 219 of file init.c.

References Data_Wrap_Struct(), free_sdbm(), fsdbm_close(), fsdbm_initialize(), NIL_P(), obj, Qnil, rb_block_given_p(), rb_ensure(), and rb_yield().

Referenced by Init_sdbm().

static VALUE fsdbm_select | ( | VALUE | obj | ) |
| static

Definition at line 355 of file init.c.

References assoc, datum::dptr, datum::dsize, GetDBM2, key, rb_ary_new(), rb_ary_push(), rb_assoc_new(), rb_external_str_new(), rb_yield(), RTEST, sdbm_fetch(), sdbm_firstkey(), sdbm_nextkey(), v, and val.

Referenced by Init_sdbm().

static VALUE fsdbm_shift | ( | VALUE | obj | ) |
| static

Definition at line 458 of file init.c.

References dbmdata::di_size, datum::dptr, datum::dsize, fdbm_modify(), GetDBM2, key, Qnil, rb_assoc_new(), rb_external_str_new(), sdbm_delete(), sdbm_fetch(), sdbm_firstkey(), and val.

Referenced by Init_sdbm().

static VALUE fsdbm_store | ( | VALUE | obj,
|  | VALUE | keystr,
|  | VALUE | valstr
| ) |  |
| static

Definition at line 601 of file init.c.

References DBM_REPLACE, dbmdata::di_size, datum::dptr, datum::dsize, EPERM, errno, ExportStringValue, fdbm_modify(), fsdbm_delete(), GetDBM2, key, Qnil, rb_eDBMError, rb_raise(), rb_sys_fail(), RSTRING_LENINT, RSTRING_PTR, sdbm_clearerr, sdbm_store(), and val.

Referenced by Init_sdbm(), and update_i().

static VALUE fsdbm_to_a | ( | VALUE | obj | ) |
| static

Definition at line 937 of file init.c.

References ary, datum::dptr, datum::dsize, GetDBM2, key, rb_ary_new(), rb_ary_push(), rb_assoc_new(), rb_external_str_new(), sdbm_fetch(), sdbm_firstkey(), sdbm_nextkey(), and val.

Referenced by Init_sdbm().

static VALUE fsdbm_to_hash | ( | VALUE | obj | ) |
| static

Definition at line 962 of file init.c.

References datum::dptr, datum::dsize, GetDBM2, hash, key, rb_external_str_new(), rb_hash_aset(), rb_hash_new(), sdbm_fetch(), sdbm_firstkey(), sdbm_nextkey(), and val.

Referenced by fsdbm_reject(), and Init_sdbm().

static VALUE fsdbm_update | ( | VALUE | obj,
|  | VALUE | other
| ) |  |
| static

Definition at line 656 of file init.c.

References obj, rb_block_call(), rb_intern, and update_i().

Referenced by Init_sdbm().

static VALUE fsdbm_values | ( | VALUE | obj | ) |
| static

Definition at line 849 of file init.c.

References ary, datum::dptr, datum::dsize, GetDBM2, key, rb_ary_new(), rb_ary_push(), rb_external_str_new(), sdbm_fetch(), sdbm_firstkey(), sdbm_nextkey(), and val.

Referenced by Init_sdbm().

static VALUE fsdbm_values_at | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | obj
| ) |  |
| static

Definition at line 384 of file init.c.

References argc, fsdbm_fetch(), i, Qnil, rb_ary_new2(), and rb_ary_push().

Referenced by Init_sdbm().

void Init_sdbm | ( |  | ) |

Definition at line 995 of file init.c.

References fsdbm_alloc(), fsdbm_aref(), fsdbm_clear(), fsdbm_close(), fsdbm_closed(), fsdbm_delete(), fsdbm_delete_if(), fsdbm_each_key(), fsdbm_each_pair(), fsdbm_each_value(), fsdbm_empty_p(), fsdbm_fetch_m(), fsdbm_has_key(), fsdbm_has_value(), fsdbm_index(), fsdbm_initialize(), fsdbm_invert(), fsdbm_key(), fsdbm_keys(), fsdbm_length(), fsdbm_reject(), fsdbm_replace(), fsdbm_s_open(), fsdbm_select(), fsdbm_shift(), fsdbm_store(), fsdbm_to_a(), fsdbm_to_hash(), fsdbm_update(), fsdbm_values(), fsdbm_values_at(), rb_cDBM, rb_cObject, rb_define_alloc_func(), rb_define_class(), rb_define_method(), rb_define_singleton_method(), rb_eDBMError, rb_eStandardError, rb_include_module(), and rb_mEnumerable.

static VALUE update_i | ( | VALUE | pair,
|  | VALUE | dbm
| ) |  |
| static

Definition at line 636 of file init.c.

References Check_Type, fsdbm_store(), Qnil, RARRAY_LEN, RARRAY_PTR(), rb_eArgError, rb_raise(), and T_ARRAY.

Referenced by fsdbm_replace(), and fsdbm_update().

## Variable Documentation

VALUE rb_cDBM
| static

Definition at line 67 of file init.c.

Referenced by Init_sdbm().

VALUE rb_eDBMError
| static

Definition at line 67 of file init.c.

Referenced by closed_sdbm(), fsdbm_clear(), fsdbm_delete(), fsdbm_delete_if(), fsdbm_store(), and Init_sdbm().