Adding encryption support

This commit is contained in:
Hamdy Khalil 2011-08-17 01:31:29 +03:00
parent ee355fe03b
commit 720a7f1aea

View file

@ -2873,6 +2873,30 @@ VALUE env_set_verbose(VALUE obj, VALUE which, VALUE onoff)
return Qtrue; return Qtrue;
} }
/*
* call-seq:
* env.set_encrypt(passwd)
*
* set encrypt
*/
VALUE env_set_encrypt(VALUE obj, VALUE vpasswd)
{
t_envh *eh;
const char *passwd;
int rv;
passwd = StringValueCStr(vpasswd);
Data_Get_Struct(obj, t_envh, eh);
u_int32_t flags=0x00000001; //DB_ENCRYPT_AES
rv = eh->env->set_encrypt(eh->env, passwd, flags);
if ( rv != 0 ) {
raise_error(rv, "env_set_encrypt: %s",db_strerror(rv));
}
return vpasswd;
}
/* /*
* call-seq: * call-seq:
* env.rep_priority = int * env.rep_priority = int
@ -3387,6 +3411,9 @@ EXCEPTIONS_CREATE
rb_define_method(cEnv,"home",env_get_home,0); rb_define_method(cEnv,"home",env_get_home,0);
rb_define_method(cEnv,"set_verbose",env_set_verbose,2); rb_define_method(cEnv,"set_verbose",env_set_verbose,2);
rb_define_method(cEnv,"encrypt=",env_set_encrypt,1);
//rb_define_method(cEnv,"encrypt",env_get_encrypt,0);
rb_define_method(cEnv,"rep_priority=", env_rep_set_priority, 1); rb_define_method(cEnv,"rep_priority=", env_rep_set_priority, 1);
rb_define_method(cEnv,"rep_priority", env_rep_get_priority, 0); rb_define_method(cEnv,"rep_priority", env_rep_get_priority, 0);
rb_define_method(cEnv,"rep_nsites=", env_rep_set_nsites, 1); rb_define_method(cEnv,"rep_nsites=", env_rep_set_nsites, 1);