Various fixes...
[oweals/openssl.git] / crypto / asn1 / x_exten.c
index 54ffe2f00b24cd77903bd223c8ddb056686df301..fbfd963b4063900686d83fa98fdf0c75134614a9 100644 (file)
 
 #include <stdio.h>
 #include "cryptlib.h"
-#include "objects.h"
-#include "asn1_mac.h"
+#include <openssl/objects.h>
+#include <openssl/asn1_mac.h>
+#include <openssl/x509.h>
 
-/*
- * ASN1err(ASN1_F_D2I_X509_EXTENSION,ASN1_R_LENGTH_MISMATCH);
- * ASN1err(ASN1_F_X509_EXTENSION_NEW,ASN1_R_LENGTH_MISMATCH);
- */
-
-int i2d_X509_EXTENSION(a,pp)
-X509_EXTENSION *a;
-unsigned char **pp;
+int i2d_X509_EXTENSION(X509_EXTENSION *a, unsigned char **pp)
        {
        int k=0;
        int r=0,ret=0;
@@ -96,10 +90,8 @@ unsigned char **pp;
                }
        }
 
-X509_EXTENSION *d2i_X509_EXTENSION(a,pp,length)
-X509_EXTENSION **a;
-unsigned char **pp;
-long length;
+X509_EXTENSION *d2i_X509_EXTENSION(X509_EXTENSION **a, unsigned char **pp,
+            long length)
        {
        int i;
        M_ASN1_D2I_vars(a,X509_EXTENSION *,X509_EXTENSION_new);
@@ -108,10 +100,6 @@ long length;
        M_ASN1_D2I_start_sequence();
        M_ASN1_D2I_get(ret->object,d2i_ASN1_OBJECT);
 
-       if ((ret->argp != NULL) && (ret->ex_free != NULL))
-               ret->ex_free(ret);
-       ret->argl=0;
-       ret->argp=NULL;
        ret->netscape_hack=0;
        if ((c.slen != 0) &&
                (M_ASN1_next == (V_ASN1_UNIVERSAL|V_ASN1_BOOLEAN)))
@@ -127,30 +115,25 @@ long length;
        M_ASN1_D2I_Finish(a,X509_EXTENSION_free,ASN1_F_D2I_X509_EXTENSION);
        }
 
-X509_EXTENSION *X509_EXTENSION_new()
+X509_EXTENSION *X509_EXTENSION_new(void)
        {
        X509_EXTENSION *ret=NULL;
+       ASN1_CTX c;
 
        M_ASN1_New_Malloc(ret,X509_EXTENSION);
-       M_ASN1_New(ret->object,ASN1_OBJECT_new);
-       M_ASN1_New(ret->value,ASN1_OCTET_STRING_new);
+       ret->object=OBJ_nid2obj(NID_undef);
+       M_ASN1_New(ret->value,M_ASN1_OCTET_STRING_new);
        ret->critical=0;
        ret->netscape_hack=0;
-       ret->argl=0L;
-       ret->argp=NULL;
-       ret->ex_free=NULL;
        return(ret);
        M_ASN1_New_Error(ASN1_F_X509_EXTENSION_NEW);
        }
        
-void X509_EXTENSION_free(a)
-X509_EXTENSION *a;
+void X509_EXTENSION_free(X509_EXTENSION *a)
        {
        if (a == NULL) return;
-       if ((a->argp != NULL) && (a->ex_free != NULL))
-               a->ex_free(a);
        ASN1_OBJECT_free(a->object);
-       ASN1_OCTET_STRING_free(a->value);
-       Free((char *)a);
+       M_ASN1_OCTET_STRING_free(a->value);
+       OPENSSL_free(a);
        }