/* call-seq: * mod.inspect => String * * Produce a concise representation of the Mod object. */ VALUE rb_ldap_mod_inspect (VALUE self) { VALUE str; VALUE hash = rb_hash_new (); char *c; c = rb_obj_classname (self); str = rb_str_new (0, strlen (c) + 10 + 16 + 1); /* 10:tags 16:addr 1:nul */ sprintf (RSTRING (str)->ptr, "#<%s:0x%lx ", c, self); RSTRING (str)->len = strlen (RSTRING (str)->ptr); switch (FIX2INT (rb_ldap_mod_op (self)) & ~LDAP_MOD_BVALUES) { case LDAP_MOD_ADD: rb_str_cat2 (str, "LDAP_MOD_ADD"); break; case LDAP_MOD_DELETE: rb_str_cat2 (str, "LDAP_MOD_DELETE"); break; case LDAP_MOD_REPLACE: rb_str_cat2 (str, "LDAP_MOD_REPLACE"); break; #ifdef LDAP_MOD_INCREMENT case LDAP_MOD_INCREMENT: rb_str_cat2 (str, "LDAP_MOD_INCREMENT"); break; #endif #ifdef LDAP_MOD_OP case LDAP_MOD_OP: rb_str_cat2 (str, "LDAP_MOD_OP"); break; #endif default: /* We shouldn't end up here. */ rb_str_cat2 (str, "unknown"); break; } if (FIX2INT (rb_ldap_mod_op (self)) & LDAP_MOD_BVALUES) rb_str_cat2 (str, "|LDAP_MOD_BVALUES"); rb_str_cat2 (str, "\n"); rb_hash_aset (hash, rb_ldap_mod_type (self), rb_ldap_mod_vals (self)); rb_str_concat (str, rb_inspect (hash)); rb_str_cat2 (str, ">"); return str; }