mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
ossl_ssl_session.c: typed data
* ext/openssl/ossl_ssl_session.c (ossl_ssl_session_type): use typed data. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48799 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
457cd40f30
commit
d064e7c857
2 changed files with 17 additions and 15 deletions
|
@ -16,7 +16,7 @@
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define GetSSLSession(obj, sess) do { \
|
#define GetSSLSession(obj, sess) do { \
|
||||||
Data_Get_Struct((obj), SSL_SESSION, (sess)); \
|
TypedData_Get_Struct((obj), SSL_SESSION, &ossl_ssl_session_type, (sess)); \
|
||||||
if (!(sess)) { \
|
if (!(sess)) { \
|
||||||
ossl_raise(rb_eRuntimeError, "SSL Session wasn't initialized."); \
|
ossl_raise(rb_eRuntimeError, "SSL Session wasn't initialized."); \
|
||||||
} \
|
} \
|
||||||
|
@ -27,6 +27,7 @@
|
||||||
GetSSLSession((obj), (sess)); \
|
GetSSLSession((obj), (sess)); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
extern const rb_data_type_t ossl_ssl_session_type;
|
||||||
extern VALUE mSSL;
|
extern VALUE mSSL;
|
||||||
extern VALUE eSSLError;
|
extern VALUE eSSLError;
|
||||||
extern VALUE cSSLSocket;
|
extern VALUE cSSLSocket;
|
||||||
|
|
|
@ -4,25 +4,26 @@
|
||||||
|
|
||||||
#include "ossl.h"
|
#include "ossl.h"
|
||||||
|
|
||||||
#define GetSSLSession(obj, sess) do { \
|
|
||||||
Data_Get_Struct((obj), SSL_SESSION, (sess)); \
|
|
||||||
if (!(sess)) { \
|
|
||||||
ossl_raise(rb_eRuntimeError, "SSL Session wasn't initialized."); \
|
|
||||||
} \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define SafeGetSSLSession(obj, sess) do { \
|
|
||||||
OSSL_Check_Kind((obj), cSSLSession); \
|
|
||||||
GetSSLSession((obj), (sess)); \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
|
|
||||||
VALUE cSSLSession;
|
VALUE cSSLSession;
|
||||||
static VALUE eSSLSession;
|
static VALUE eSSLSession;
|
||||||
|
|
||||||
|
static void
|
||||||
|
ossl_ssl_session_free(void *ptr)
|
||||||
|
{
|
||||||
|
SSL_SESSION_free(ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
const rb_data_type_t ossl_ssl_session_type = {
|
||||||
|
"OpenSSL/SSL/Session",
|
||||||
|
{
|
||||||
|
0, ossl_ssl_session_free,
|
||||||
|
},
|
||||||
|
0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
|
||||||
|
};
|
||||||
|
|
||||||
static VALUE ossl_ssl_session_alloc(VALUE klass)
|
static VALUE ossl_ssl_session_alloc(VALUE klass)
|
||||||
{
|
{
|
||||||
return Data_Wrap_Struct(klass, 0, SSL_SESSION_free, NULL);
|
return TypedData_Wrap_Struct(klass, &ossl_ssl_session_type, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue