diff options
author | Michal Rokos <m.rokos@sh.cvut.cz> | 2002-03-11 17:20:04 +0000 |
---|---|---|
committer | Michal Rokos <m.rokos@sh.cvut.cz> | 2002-03-11 17:20:04 +0000 |
commit | 7ed17afc8c327bc88d1510255d284487d06f226c (patch) | |
tree | 52aa2aed34535a040ba155fef373e4394449dd33 /ossl_x509attr.c | |
parent | 91e607a11b3862c0aa966712149b2afd2a00d90d (diff) | |
download | ruby-openssl-history-7ed17afc8c327bc88d1510255d284487d06f226c.tar.gz |
* Big internal cleanup (all structs with only 1 member rearranged)
* improved getting time_t from cTime
Diffstat (limited to 'ossl_x509attr.c')
-rw-r--r-- | ossl_x509attr.c | 57 |
1 files changed, 15 insertions, 42 deletions
diff --git a/ossl_x509attr.c b/ossl_x509attr.c index 66f5a55..67eecd3 100644 --- a/ossl_x509attr.c +++ b/ossl_x509attr.c @@ -10,14 +10,8 @@ */ #include "ossl.h" -#define MakeX509Attr(obj, attrp) {\ - obj = Data_Make_Struct(cX509Attribute, ossl_x509attr, 0, ossl_x509attr_free, attrp);\ -} - -#define GetX509Attr(obj, attrp) {\ - Data_Get_Struct(obj, ossl_x509attr, attrp);\ - if (!attrp->attribute) rb_raise(eX509AttributeError, "not initialized!");\ -} +#define WrapX509Attr(obj, attr) obj = Data_Wrap_Struct(cX509Attribute, 0, X509_ATTRIBUTE_free, attr) +#define GetX509Attr(obj, attr) Data_Get_Struct(obj, X509_ATTRIBUTE, attr) /* * Classes @@ -26,30 +20,11 @@ VALUE cX509Attribute; VALUE eX509AttributeError; /* - * Struct - */ -typedef struct ossl_x509attr_st { - X509_ATTRIBUTE *attribute; -} ossl_x509attr; - - -static void -ossl_x509attr_free(ossl_x509attr *attrp) -{ - if (attrp) { - if (attrp->attribute) X509_ATTRIBUTE_free(attrp->attribute); - attrp->attribute = NULL; - free(attrp); - } -} - -/* - * public + * Public */ VALUE ossl_x509attr_new(X509_ATTRIBUTE *attr) { - ossl_x509attr *attrp = NULL; X509_ATTRIBUTE *new = NULL; VALUE obj; @@ -59,9 +34,8 @@ ossl_x509attr_new(X509_ATTRIBUTE *attr) if (!new) OSSL_Raise(eX509AttributeError, ""); - - MakeX509Attr(obj, attrp); - attrp->attribute = new; + + WrapX509Attr(obj, new); return obj; } @@ -69,25 +43,25 @@ ossl_x509attr_new(X509_ATTRIBUTE *attr) X509_ATTRIBUTE * ossl_x509attr_get_X509_ATTRIBUTE(VALUE obj) { - ossl_x509attr *attrp = NULL; - X509_ATTRIBUTE *attr = NULL; + X509_ATTRIBUTE *attr = NULL, *new; - OSSL_Check_Type(obj, cX509Attribute); - GetX509Attr(obj, attrp); + OSSL_Check_Type(obj, cX509Attribute); + + GetX509Attr(obj, attr); - if (!(attr = X509_ATTRIBUTE_dup(attrp->attribute))) + if (!(new = X509_ATTRIBUTE_dup(attr))) { OSSL_Raise(eX509AttributeError, ""); - - return attr; + } + + return new; } /* - * private + * Private */ static VALUE ossl_x509attr_s_new_from_array(VALUE klass, VALUE ary) { - ossl_x509attr *attrp = NULL; X509_ATTRIBUTE *attr = NULL; int nid = NID_undef; VALUE item, obj; @@ -112,8 +86,7 @@ ossl_x509attr_s_new_from_array(VALUE klass, VALUE ary) if (!(attr = X509_ATTRIBUTE_create(nid, MBSTRING_ASC, RSTRING(item)->ptr))) OSSL_Raise(eX509AttributeError, ""); - MakeX509Attr(obj, attrp); - attrp->attribute = attr; + WrapX509Attr(obj, attr); return obj; } |