* ext/openssl/ruby_missing.c: rid of unnecessary backward

compatibility stuff. and remove DEFINE_ALLOC_WRAPPER from
  all sources.

* ext/openssl/ossl_x509ext.c (X509::Extension.new): new method.

* ext/openssl/ossl_x509ext.c (X509::Extension#oid=): new method.

* ext/openssl/ossl_x509ext.c (X509::Extension#value=): new method.

* ext/openssl/ossl_x509ext.c (X509::Extension#critical=): new method.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4522 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
gotoyuzo 2003-09-06 08:56:09 +00:00
Родитель dc29af2a06
Коммит 256d273e69
17 изменённых файлов: 102 добавлений и 37 удалений

Просмотреть файл

@ -1,3 +1,17 @@
Sat Sep 6 17:40:41 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
* ext/openssl/ruby_missing.c: rid of unnecessary backward
compatibility stuff. and remove DEFINE_ALLOC_WRAPPER from
all sources.
* ext/openssl/ossl_x509ext.c (X509::Extension.new): new method.
* ext/openssl/ossl_x509ext.c (X509::Extension#oid=): new method.
* ext/openssl/ossl_x509ext.c (X509::Extension#value=): new method.
* ext/openssl/ossl_x509ext.c (X509::Extension#critical=): new method.
Sat Sep 6 01:23:22 2003 NAKAMURA Usaku <usa@ruby-lang.org>
* win32/win32.c (CreateChild): need to quote cmd if RUBYSHELL is set.

Просмотреть файл

@ -99,7 +99,6 @@ ossl_bn_alloc(VALUE klass)
return obj;
}
DEFINE_ALLOC_WRAPPER(ossl_bn_alloc)
static VALUE
ossl_bn_initialize(int argc, VALUE *argv, VALUE self)

Просмотреть файл

@ -82,7 +82,6 @@ ossl_cipher_alloc(VALUE klass)
return obj;
}
DEFINE_ALLOC_WRAPPER(ossl_cipher_alloc)
static VALUE
ossl_cipher_initialize(VALUE self, VALUE str)

Просмотреть файл

@ -73,7 +73,6 @@ ossl_digest_alloc(VALUE klass)
return obj;
}
DEFINE_ALLOC_WRAPPER(ossl_digest_alloc)
VALUE ossl_digest_update(VALUE, VALUE);
@ -197,12 +196,7 @@ ossl_digest_hexdigest(VALUE self)
static VALUE
ossl_digest_s_digest(VALUE klass, VALUE str, VALUE data)
{
VALUE obj =
#if HAVE_RB_DEFINE_ALLOC_FUNC
rb_class_new_instance(1, &str, klass);
#else
ossl_digest_alloc_wrapper(1, &str, klass);
#endif
VALUE obj = rb_class_new_instance(1, &str, klass);
ossl_digest_update(obj, data);
@ -212,12 +206,7 @@ ossl_digest_s_digest(VALUE klass, VALUE str, VALUE data)
static VALUE
ossl_digest_s_hexdigest(VALUE klass, VALUE str, VALUE data)
{
VALUE obj =
#if HAVE_RB_DEFINE_ALLOC_FUNC
rb_class_new_instance(1, &str, klass);
#else
ossl_digest_alloc_wrapper(1, &str, klass);
#endif
VALUE obj = rb_class_new_instance(1, &str, klass);
ossl_digest_update(obj, data);

Просмотреть файл

@ -55,7 +55,6 @@ ossl_hmac_alloc(VALUE klass)
return obj;
}
DEFINE_ALLOC_WRAPPER(ossl_hmac_alloc)
static VALUE
ossl_hmac_initialize(VALUE self, VALUE key, VALUE digest)

Просмотреть файл

@ -50,7 +50,6 @@ ossl_spki_alloc(VALUE klass)
return obj;
}
DEFINE_ALLOC_WRAPPER(ossl_spki_alloc)
static VALUE
ossl_spki_initialize(int argc, VALUE *argv, VALUE self)

Просмотреть файл

@ -98,7 +98,6 @@ ossl_ocspreq_alloc(VALUE klass)
return obj;
}
DEFINE_ALLOC_WRAPPER(ossl_ocspreq_alloc)
static VALUE
ossl_ocspreq_initialize(int argc, VALUE *argv, VALUE self)
@ -304,7 +303,6 @@ ossl_ocspres_alloc(VALUE klass)
return obj;
}
DEFINE_ALLOC_WRAPPER(ossl_ocspreq_alloc)
static VALUE
ossl_ocspres_initialize(int argc, VALUE *argv, VALUE self)
@ -395,7 +393,6 @@ ossl_ocspbres_alloc(VALUE klass)
return obj;
}
DEFINE_ALLOC_WRAPPER(ossl_ocspbres_alloc)
static VALUE
ossl_ocspbres_initialize(int argc, VALUE *argv, VALUE self)
@ -617,7 +614,6 @@ ossl_ocspcid_alloc(VALUE klass)
return obj;
}
DEFINE_ALLOC_WRAPPER(ossl_ocspcid_alloc)
static VALUE
ossl_ocspcid_initialize(VALUE self, VALUE subject, VALUE issuer)

Просмотреть файл

@ -252,7 +252,6 @@ ossl_pkcs7_alloc(VALUE klass)
return obj;
}
DEFINE_ALLOC_WRAPPER(ossl_pkcs7_alloc)
static VALUE
ossl_pkcs7_initialize(int argc, VALUE *argv, VALUE self)
@ -651,7 +650,6 @@ ossl_pkcs7si_alloc(VALUE klass)
return obj;
}
DEFINE_ALLOC_WRAPPER(ossl_pkcs7si_alloc)
static VALUE
ossl_pkcs7si_initialize(VALUE self, VALUE cert, VALUE key, VALUE digest)

Просмотреть файл

@ -119,7 +119,6 @@ ossl_pkey_alloc(VALUE klass)
return obj;
}
DEFINE_ALLOC_WRAPPER(ossl_pkey_alloc)
static VALUE
ossl_pkey_initialize(VALUE self)

Просмотреть файл

@ -107,7 +107,6 @@ ossl_sslctx_s_alloc(VALUE klass)
SSL_CTX_set_options(ctx, SSL_OP_ALL);
return Data_Wrap_Struct(klass, 0, ossl_sslctx_free, ctx);
}
DEFINE_ALLOC_WRAPPER(ossl_sslctx_s_alloc)
static VALUE
ossl_sslctx_initialize(int argc, VALUE *argv, VALUE self)
@ -365,7 +364,6 @@ ossl_ssl_s_alloc(VALUE klass)
{
return Data_Wrap_Struct(klass, 0, ossl_ssl_free, NULL);
}
DEFINE_ALLOC_WRAPPER(ossl_ssl_s_alloc)
static VALUE
ossl_ssl_initialize(int argc, VALUE *argv, VALUE self)

Просмотреть файл

@ -124,7 +124,6 @@ ossl_x509_alloc(VALUE klass)
return obj;
}
DEFINE_ALLOC_WRAPPER(ossl_x509_alloc)
static VALUE
ossl_x509_initialize(int argc, VALUE *argv, VALUE self)

Просмотреть файл

@ -86,7 +86,6 @@ ossl_x509crl_alloc(VALUE klass)
return obj;
}
DEFINE_ALLOC_WRAPPER(ossl_x509crl_alloc)
static VALUE
ossl_x509crl_initialize(int argc, VALUE *argv, VALUE self)

Просмотреть файл

@ -116,7 +116,6 @@ ossl_x509extfactory_alloc(VALUE klass)
return obj;
}
DEFINE_ALLOC_WRAPPER(ossl_x509extfactory_alloc)
static VALUE
ossl_x509extfactory_set_issuer_cert(VALUE self, VALUE cert)
@ -244,6 +243,87 @@ ossl_x509extfactory_create_ext_from_array(VALUE self, VALUE ary)
/*
* Ext
*/
static VALUE
ossl_x509ext_alloc(VALUE klass)
{
X509_EXTENSION *ext;
VALUE obj;
if(!(ext = X509_EXTENSION_new())){
ossl_raise(eX509ExtError, NULL);
}
WrapX509Ext(klass, obj, ext);
return obj;
}
static VALUE
ossl_x509ext_initialize(int argc, VALUE *argv, VALUE self)
{
VALUE oid, value, critical;
rb_scan_args(argc, argv, "21", &oid, &value, &critical);
rb_funcall(self, rb_intern("oid="), 1, oid);
rb_funcall(self, rb_intern("value="), 1, value);
if(argc > 2) rb_funcall(self, rb_intern("critical="), 1, critical);
return self;
}
static VALUE
ossl_x509ext_set_oid(VALUE self, VALUE oid)
{
X509_EXTENSION *ext;
ASN1_OBJECT *obj;
char *s;
GetX509Ext(self, ext);
s = StringValuePtr(oid);
obj = OBJ_txt2obj(s, 0);
if(!obj) obj = OBJ_txt2obj(s, 1);
if(!obj) ossl_raise(eX509ExtError, NULL);
X509_EXTENSION_set_object(ext, obj);
return oid;
}
static VALUE
ossl_x509ext_set_value(VALUE self, VALUE data)
{
X509_EXTENSION *ext;
ASN1_OCTET_STRING *asn1s;
char *s;
GetX509Ext(self, ext);
StringValue(data);
if(!(s = OPENSSL_malloc(RSTRING(data)->len)))
ossl_raise(eX509ExtError, "malloc error");
memcpy(s, RSTRING(data)->ptr, RSTRING(data)->len);
if(!(asn1s = ASN1_OCTET_STRING_new())){
free(s);
ossl_raise(eX509ExtError, NULL);
}
if(!M_ASN1_OCTET_STRING_set(asn1s, s, RSTRING(data)->len)){
free(s);
ASN1_OCTET_STRING_free(asn1s);
ossl_raise(eX509ExtError, NULL);
}
X509_EXTENSION_set_data(ext, asn1s);
return data;
}
static VALUE
ossl_x509ext_set_critical(VALUE self, VALUE flag)
{
X509_EXTENSION *ext;
GetX509Ext(self, ext);
X509_EXTENSION_set_critical(ext, RTEST(flag) ? 1 : 0);
return flag;
}
static VALUE
ossl_x509ext_get_oid(VALUE obj)
{
@ -335,9 +415,11 @@ Init_ossl_x509ext()
rb_define_method(cX509ExtFactory, "create_ext_from_array", ossl_x509extfactory_create_ext_from_array, 1);
cX509Ext = rb_define_class_under(mX509, "Extension", rb_cObject);
rb_undef_method(CLASS_OF(cX509Ext), "new");
/* rb_define_alloc_func(cX509Ext, ossl_x509ext_alloc); */
/* rb_define_method(cX509Ext, "initialize", ossl_x509ext_initialize, -1); */
rb_define_alloc_func(cX509Ext, ossl_x509ext_alloc);
rb_define_method(cX509Ext, "initialize", ossl_x509ext_initialize, -1);
rb_define_method(cX509Ext, "oid=", ossl_x509ext_set_oid, 1);
rb_define_method(cX509Ext, "value=", ossl_x509ext_set_value, 1);
rb_define_method(cX509Ext, "critical=", ossl_x509ext_set_critical, 1);
rb_define_method(cX509Ext, "oid", ossl_x509ext_get_oid, 0);
rb_define_method(cX509Ext, "value", ossl_x509ext_get_value, 0);
rb_define_method(cX509Ext, "critical?", ossl_x509ext_get_critical, 0);

Просмотреть файл

@ -82,7 +82,6 @@ ossl_x509name_alloc(VALUE klass)
return obj;
}
DEFINE_ALLOC_WRAPPER(ossl_x509name_alloc)
static VALUE
ossl_x509name_initialize(int argc, VALUE *argv, VALUE self)

Просмотреть файл

@ -84,7 +84,6 @@ ossl_x509req_alloc(VALUE klass)
return obj;
}
DEFINE_ALLOC_WRAPPER(ossl_x509req_alloc)
static VALUE
ossl_x509req_initialize(int argc, VALUE *argv, VALUE self)

Просмотреть файл

@ -84,7 +84,6 @@ ossl_x509revoked_alloc(VALUE klass)
return obj;
}
DEFINE_ALLOC_WRAPPER(ossl_x509revoked_alloc)
static VALUE
ossl_x509revoked_initialize(int argc, VALUE *argv, VALUE self)

Просмотреть файл

@ -102,7 +102,6 @@ ossl_x509store_alloc(VALUE klass)
return obj;
}
DEFINE_ALLOC_WRAPPER(ossl_x509store_alloc)
/*
* General callback for OpenSSL verify
@ -329,7 +328,6 @@ ossl_x509stctx_alloc(VALUE klass)
return obj;
}
DEFINE_ALLOC_WRAPPER(ossl_x509stctx_alloc)
static VALUE
ossl_x509stctx_initialize(int argc, VALUE *argv, VALUE self)