diff options
author | Michal Rokos <m.rokos@sh.cvut.cz> | 2002-09-05 12:10:30 +0000 |
---|---|---|
committer | Michal Rokos <m.rokos@sh.cvut.cz> | 2002-09-05 12:10:30 +0000 |
commit | 8180cad0265fed9e11b3fbef6451cd034ec3e47a (patch) | |
tree | bbfca87582e9ec471de04ddd569720617659c527 /ossl_cipher.c | |
parent | f6480baf63bfbe2f9801a3dfff3b4c73af908dcc (diff) | |
download | ruby-openssl-history-8180cad0265fed9e11b3fbef6451cd034ec3e47a.tar.gz |
implement #become for Ruby 1.7.3 dup, clone interface
Diffstat (limited to 'ossl_cipher.c')
-rw-r--r-- | ossl_cipher.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/ossl_cipher.c b/ossl_cipher.c index 6e24189..51d3938 100644 --- a/ossl_cipher.c +++ b/ossl_cipher.c @@ -96,6 +96,22 @@ ossl_cipher_initialize(VALUE self, VALUE str) } return self; } +static VALUE +ossl_cipher_become(VALUE self, VALUE other) +{ + ossl_cipher *ciphp1, *ciphp2; + + rb_check_frozen(self); + + if (self == other) return self; + + GetCipher(self, ciphp1); + SafeGetCipher(other, ciphp2); + + ciphp1->cipher = ciphp2->cipher; + + return self; +} static VALUE ossl_cipher_encrypt(int argc, VALUE *argv, VALUE self) @@ -284,7 +300,8 @@ Init_ossl_cipher(void) rb_define_singleton_method(cCipher, "allocate", ossl_cipher_s_allocate, 0); rb_define_method(cCipher, "initialize", ossl_cipher_initialize, 1); - + + rb_define_method(cCipher, "become", ossl_cipher_become, 1); rb_define_method(cCipher, "encrypt", ossl_cipher_encrypt, -1); rb_define_method(cCipher, "decrypt", ossl_cipher_decrypt, -1); rb_define_method(cCipher, "update", ossl_cipher_update, 1); |