|
|
@ -82,6 +82,14 @@ static void grpc_rb_server_credentials_mark(void *p) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static const rb_data_type_t grpc_rb_server_credentials_data_type = { |
|
|
|
|
|
|
|
"grpc_server_credentials", |
|
|
|
|
|
|
|
{grpc_rb_server_credentials_mark, grpc_rb_server_credentials_free, |
|
|
|
|
|
|
|
GRPC_RB_MEMSIZE_UNAVAILABLE}, |
|
|
|
|
|
|
|
NULL, NULL, |
|
|
|
|
|
|
|
RUBY_TYPED_FREE_IMMEDIATELY |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
/* Allocates ServerCredential instances.
|
|
|
|
/* Allocates ServerCredential instances.
|
|
|
|
|
|
|
|
|
|
|
|
Provides safe initial defaults for the instance fields. */ |
|
|
|
Provides safe initial defaults for the instance fields. */ |
|
|
@ -89,8 +97,8 @@ static VALUE grpc_rb_server_credentials_alloc(VALUE cls) { |
|
|
|
grpc_rb_server_credentials *wrapper = ALLOC(grpc_rb_server_credentials); |
|
|
|
grpc_rb_server_credentials *wrapper = ALLOC(grpc_rb_server_credentials); |
|
|
|
wrapper->wrapped = NULL; |
|
|
|
wrapper->wrapped = NULL; |
|
|
|
wrapper->mark = Qnil; |
|
|
|
wrapper->mark = Qnil; |
|
|
|
return Data_Wrap_Struct(cls, grpc_rb_server_credentials_mark, |
|
|
|
return TypedData_Wrap_Struct(cls, &grpc_rb_server_credentials_data_type, |
|
|
|
grpc_rb_server_credentials_free, wrapper); |
|
|
|
wrapper); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* Clones ServerCredentials instances.
|
|
|
|
/* Clones ServerCredentials instances.
|
|
|
@ -112,8 +120,10 @@ static VALUE grpc_rb_server_credentials_init_copy(VALUE copy, VALUE orig) { |
|
|
|
rb_obj_classname(grpc_rb_cServerCredentials)); |
|
|
|
rb_obj_classname(grpc_rb_cServerCredentials)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Data_Get_Struct(orig, grpc_rb_server_credentials, orig_ch); |
|
|
|
TypedData_Get_Struct(orig, grpc_rb_server_credentials, |
|
|
|
Data_Get_Struct(copy, grpc_rb_server_credentials, copy_ch); |
|
|
|
&grpc_rb_server_credentials_data_type, orig_ch); |
|
|
|
|
|
|
|
TypedData_Get_Struct(copy, grpc_rb_server_credentials, |
|
|
|
|
|
|
|
&grpc_rb_server_credentials_data_type, copy_ch); |
|
|
|
|
|
|
|
|
|
|
|
/* use ruby's MEMCPY to make a byte-for-byte copy of the server_credentials
|
|
|
|
/* use ruby's MEMCPY to make a byte-for-byte copy of the server_credentials
|
|
|
|
wrapper object. */ |
|
|
|
wrapper object. */ |
|
|
@ -149,7 +159,8 @@ static VALUE grpc_rb_server_credentials_init(VALUE self, VALUE pem_root_certs, |
|
|
|
grpc_rb_server_credentials *wrapper = NULL; |
|
|
|
grpc_rb_server_credentials *wrapper = NULL; |
|
|
|
grpc_server_credentials *creds = NULL; |
|
|
|
grpc_server_credentials *creds = NULL; |
|
|
|
grpc_ssl_pem_key_cert_pair key_cert_pair = {NULL, NULL}; |
|
|
|
grpc_ssl_pem_key_cert_pair key_cert_pair = {NULL, NULL}; |
|
|
|
Data_Get_Struct(self, grpc_rb_server_credentials, wrapper); |
|
|
|
TypedData_Get_Struct(self, grpc_rb_server_credentials, |
|
|
|
|
|
|
|
&grpc_rb_server_credentials_data_type, wrapper); |
|
|
|
if (pem_cert_chain == Qnil) { |
|
|
|
if (pem_cert_chain == Qnil) { |
|
|
|
rb_raise(rb_eRuntimeError, |
|
|
|
rb_raise(rb_eRuntimeError, |
|
|
|
"could not create a server credential: nil pem_cert_chain"); |
|
|
|
"could not create a server credential: nil pem_cert_chain"); |
|
|
@ -206,6 +217,7 @@ void Init_grpc_server_credentials() { |
|
|
|
/* Gets the wrapped grpc_server_credentials from the ruby wrapper */ |
|
|
|
/* Gets the wrapped grpc_server_credentials from the ruby wrapper */ |
|
|
|
grpc_server_credentials *grpc_rb_get_wrapped_server_credentials(VALUE v) { |
|
|
|
grpc_server_credentials *grpc_rb_get_wrapped_server_credentials(VALUE v) { |
|
|
|
grpc_rb_server_credentials *wrapper = NULL; |
|
|
|
grpc_rb_server_credentials *wrapper = NULL; |
|
|
|
Data_Get_Struct(v, grpc_rb_server_credentials, wrapper); |
|
|
|
TypedData_Get_Struct(v, grpc_rb_server_credentials, |
|
|
|
|
|
|
|
&grpc_rb_server_credentials_data_type, wrapper); |
|
|
|
return wrapper->wrapped; |
|
|
|
return wrapper->wrapped; |
|
|
|
} |
|
|
|
} |
|
|
|