[pisa-src] r2919 - trunk/community-operator/client/pisa-cert-info.c

Author: nikou
Date: Mon Mar 12 21:28:40 2012
New Revision: 2919

Log:
pisa-cert-info: move repeating output pattern to a seperate function

Modified:
   trunk/community-operator/client/pisa-cert-info.c

Modified: trunk/community-operator/client/pisa-cert-info.c
==============================================================================
--- trunk/community-operator/client/pisa-cert-info.c    Mon Mar 12 20:24:21 
2012        (r2918)
+++ trunk/community-operator/client/pisa-cert-info.c    Mon Mar 12 21:28:40 
2012        (r2919)
@@ -33,6 +33,14 @@
     BIO_write(bp, "</td></tr>\n", 11);
 }
 
+static void tout(BIO *bp, const char *string, int length)
+{
+    topen(bp);
+    if (BIO_write(bp, string, length) <= 0) {
+        fprintf(stderr, "error writing value");
+    }
+    tnext(bp);
+};
 
 
 int X509_print_fp_cop(FILE *fp, X509 *x)
@@ -79,12 +87,7 @@
         goto err;
     }
 
-    topen(bp);
-    if (BIO_write(bp, "Serial Number", 13) <= 0) {
-        goto err;
-    }
-    tnext(bp);
-
+    tout(bp, "Serial Number", 13);
     bs = X509_get_serialNumber(x);
     if (bs->length <= 4) {
         serial = ASN1_INTEGER_get(bs);
@@ -119,42 +122,22 @@
                    (id == NID_undef) ? "UNKNOWN" : OBJ_nid2ln(id)) <= 0) {
         goto err;
     }
-
-    topen(bp);
-    if (BIO_write(bp, "Issuer", 6) <= 0) {
-        goto err;
-    }
-    tnext(bp);
+    tout(bp, "Issuer", 6);
     if (!X509_NAME_print(bp, X509_get_issuer_name(x), 16)) {
         goto err;
     }
     tclose(bp);
-
-    topen(bp);
-    if (BIO_write(bp, "Valid Not Before", 16) <= 0) {
-        goto err;
-    }
-    tnext(bp);
+    tout(bp, "Valid Not Before", 16);
     if (!ASN1_TIME_print(bp, X509_get_notBefore(x))) {
         goto err;
     }
     tclose(bp);
-
-    topen(bp);
-    if (BIO_write(bp, "Valid Not After", 15) <= 0) {
-        goto err;
-    }
-    tnext(bp);
+    tout(bp, "Valid Not After", 15);
     if (!ASN1_TIME_print(bp, X509_get_notAfter(x))) {
         goto err;
     }
     tclose(bp);
-
-    topen(bp);
-    if (BIO_write(bp, "Subject", 7) <= 0) {
-        goto err;
-    }
-    tnext(bp);
+    tout(bp, "Subject", 7);
     if (!X509_NAME_print(bp, X509_get_subject_name(x), 16)) {
         goto err;
     }
@@ -222,7 +205,9 @@
 
     /* print signature algorithm */
     id = OBJ_obj2nid(x->sig_alg->algorithm);
-    if (BIO_printf(bp, "<tr><td>Signature Algorithm</td><td>%s<br>\n",
+    tout(bp, "Signature Algorithm", 19);
+
+    if (BIO_printf(bp, "%s<br>\n",
                    (id == NID_undef) ? "UNKNOWN" : OBJ_nid2ln(id)) <= 0) {
         goto err;
     }
-- 
This is the pisa developer mailing list. Please also subscribe to the main pisa 
list at:
http://www.freelists.org/list/pisa

Other related posts:

  • » [pisa-src] r2919 - trunk/community-operator/client/pisa-cert-info.c - Nikou Gholizadeh