diff options
Diffstat (limited to 'ext/openssl/ossl_x509attr.c')
-rw-r--r-- | ext/openssl/ossl_x509attr.c | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/ext/openssl/ossl_x509attr.c b/ext/openssl/ossl_x509attr.c index 7b88e294a9..ca1c59aba9 100644 --- a/ext/openssl/ossl_x509attr.c +++ b/ext/openssl/ossl_x509attr.c @@ -84,6 +84,10 @@ ossl_x509attr_alloc(VALUE klass) return obj; } +/* + * call-seq: + * Attribute.new(oid [, value]) => attr + */ static VALUE ossl_x509attr_initialize(int argc, VALUE *argv, VALUE self) { @@ -95,9 +99,9 @@ ossl_x509attr_initialize(int argc, VALUE *argv, VALUE self) if(rb_scan_args(argc, argv, "11", &oid, &value) == 1){ oid = ossl_to_der_if_possible(oid); StringValue(oid); - p = RSTRING(oid)->ptr; + p = RSTRING_PTR(oid); if(!d2i_X509_ATTRIBUTE((X509_ATTRIBUTE**)&DATA_PTR(self), - &p, RSTRING(oid)->len)){ + &p, RSTRING_LEN(oid))){ ossl_raise(eX509AttrError, NULL); } return self; @@ -108,6 +112,10 @@ ossl_x509attr_initialize(int argc, VALUE *argv, VALUE self) return self; } +/* + * call-seq: + * attr.oid = string => string + */ static VALUE ossl_x509attr_set_oid(VALUE self, VALUE oid) { @@ -125,6 +133,10 @@ ossl_x509attr_set_oid(VALUE self, VALUE oid) return oid; } +/* + * call-seq: + * attr.oid => string + */ static VALUE ossl_x509attr_get_oid(VALUE self) { @@ -156,6 +168,10 @@ ossl_x509attr_get_oid(VALUE self) # define OSSL_X509ATTR_SET_SINGLE(attr) ((attr)->set = 0) #endif +/* + * call-seq: + * attr.value = asn1 => asn1 + */ static VALUE ossl_x509attr_set_value(VALUE self, VALUE value) { @@ -179,6 +195,10 @@ ossl_x509attr_set_value(VALUE self, VALUE value) return value; } +/* + * call-seq: + * attr.value => asn1 + */ static VALUE ossl_x509attr_get_value(VALUE self) { @@ -192,7 +212,7 @@ ossl_x509attr_get_value(VALUE self) if(OSSL_X509ATTR_IS_SINGLE(attr)){ length = i2d_ASN1_TYPE(attr->value.single, NULL); str = rb_str_new(0, length); - p = RSTRING(str)->ptr; + p = RSTRING_PTR(str); i2d_ASN1_TYPE(attr->value.single, &p); ossl_str_adjust(str, p); } @@ -200,7 +220,7 @@ ossl_x509attr_get_value(VALUE self) length = i2d_ASN1_SET_OF_ASN1_TYPE(attr->value.set, NULL, i2d_ASN1_TYPE, V_ASN1_SET, V_ASN1_UNIVERSAL, 0); str = rb_str_new(0, length); - p = RSTRING(str)->ptr; + p = RSTRING_PTR(str); i2d_ASN1_SET_OF_ASN1_TYPE(attr->value.set, &p, i2d_ASN1_TYPE, V_ASN1_SET, V_ASN1_UNIVERSAL, 0); ossl_str_adjust(str, p); @@ -210,6 +230,10 @@ ossl_x509attr_get_value(VALUE self) return asn1; } +/* + * call-seq: + * attr.to_der => string + */ static VALUE ossl_x509attr_to_der(VALUE self) { @@ -222,10 +246,10 @@ ossl_x509attr_to_der(VALUE self) if((len = i2d_X509_ATTRIBUTE(attr, NULL)) <= 0) ossl_raise(eX509AttrError, NULL); str = rb_str_new(0, len); - p = RSTRING(str)->ptr; + p = RSTRING_PTR(str); if(i2d_X509_ATTRIBUTE(attr, &p) <= 0) ossl_raise(eX509AttrError, NULL); - RSTRING(str)->len = p - (unsigned char*)RSTRING(str)->ptr; + rb_str_set_len(str, p - (unsigned char*)RSTRING_PTR(str)); return str; } |