Support custom primitive type printing routines and add one to LONG type.
authorDr. Stephen Henson <steve@openssl.org>
Fri, 8 Feb 2008 13:07:04 +0000 (13:07 +0000)
committerDr. Stephen Henson <steve@openssl.org>
Fri, 8 Feb 2008 13:07:04 +0000 (13:07 +0000)
crypto/asn1/asn1t.h
crypto/asn1/tasn_prn.c
crypto/asn1/x_long.c

index fc7ea0d1b281b9f8121432ee8b4f7817c8ac1674..fff8030f7daa4373b9dc7c592177cced2d92ab6d 100644 (file)
@@ -654,6 +654,7 @@ typedef int ASN1_ex_print_func(BIO *out, ASN1_VALUE **pval,
 
 typedef int ASN1_primitive_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype, const ASN1_ITEM *it);
 typedef int ASN1_primitive_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, int utype, char *free_cont, const ASN1_ITEM *it);
+typedef int ASN1_primitive_print(BIO *out, ASN1_VALUE **pval, const ASN1_ITEM *it, int indent, const ASN1_PCTX *pctx);
 
 typedef struct ASN1_COMPAT_FUNCS_st {
        ASN1_new_func *asn1_new;
@@ -680,6 +681,7 @@ typedef struct ASN1_PRIMITIVE_FUNCS_st {
        ASN1_ex_free_func *prim_clear;
        ASN1_primitive_c2i *prim_c2i;
        ASN1_primitive_i2c *prim_i2c;
+       ASN1_primitive_print *prim_print;
 } ASN1_PRIMITIVE_FUNCS;
 
 /* This is the ASN1_AUX structure: it handles various
index d9f32bd890685e902a71b2eff8e92adc1304ba15..d2830a5eaddeb3368414ff78329f18f94167b5f7 100644 (file)
@@ -522,8 +522,12 @@ static int asn1_primitive_print(BIO *out, ASN1_VALUE **fld,
        ASN1_STRING *str;
        int ret = 1, needlf = 1;
        const char *pname;
+       const ASN1_PRIMITIVE_FUNCS *pf;
+       pf = it->funcs;
        if (!asn1_print_fsname(out, indent, fname, sname, pctx))
                        return 0;
+       if (pf && pf->prim_print)
+               return pf->prim_print(out, fld, it, indent, pctx);
        str = (ASN1_STRING *)*fld;
        if (it->itype == ASN1_ITYPE_MSTRING)
                utype = str->type & ~V_ASN1_NEG;
index 0db233cb95f6596f415b184bbf6cff48e566c0da..6c7fc2213f652363613fd3807e16009e2096d3f4 100644 (file)
@@ -71,6 +71,7 @@ static void long_free(ASN1_VALUE **pval, const ASN1_ITEM *it);
 
 static int long_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype, const ASN1_ITEM *it);
 static int long_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, int utype, char *free_cont, const ASN1_ITEM *it);
+static int long_print(BIO *out, ASN1_VALUE **pval, const ASN1_ITEM *it, int indent, const ASN1_PCTX *pctx);
 
 static ASN1_PRIMITIVE_FUNCS long_pf = {
        NULL, 0,
@@ -78,7 +79,8 @@ static ASN1_PRIMITIVE_FUNCS long_pf = {
        long_free,
        long_free,      /* Clear should set to initial value */
        long_c2i,
-       long_i2c
+       long_i2c,
+       long_print
 };
 
 ASN1_ITEM_start(LONG)
@@ -169,3 +171,9 @@ static int long_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len,
        memcpy(cp, &ltmp, sizeof(long));
        return 1;
 }
+
+static int long_print(BIO *out, ASN1_VALUE **pval, const ASN1_ITEM *it,
+                       int indent, const ASN1_PCTX *pctx)
+       {
+       return BIO_printf(out, "%ld\n", *(long *)pval);
+       }