Use pgpValString() for :pgpsig header formatting (RhBug:587755)
authorPanu Matilainen <pmatilai@redhat.com>
Wed, 19 May 2010 12:33:52 +0000 (15:33 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Wed, 19 May 2010 12:33:52 +0000 (15:33 +0300)
- instead of copy-slopping (and forgetting to do so whenever something
  changes) just use the values we know from pgpVals..

lib/formats.c

index 0700955..3113c80 100644 (file)
@@ -517,33 +517,11 @@ static char * pgpsigFormat(rpmtd td, char * formatPrefix)
            nb += 100;
            val = t = xrealloc(val, nb + 1);
 
-           switch (sigp->pubkey_algo) {
-           case PGPPUBKEYALGO_DSA:
-               t = stpcpy(t, "DSA");
-               break;
-           case PGPPUBKEYALGO_RSA:
-               t = stpcpy(t, "RSA");
-               break;
-           default:
-               (void) snprintf(t, nb - (t - val), "%d", sigp->pubkey_algo);
-               t += strlen(t);
-               break;
-           }
+           t = stpcpy(t, pgpValString(PGPVAL_PUBKEYALGO, sigp->pubkey_algo));
            if (t + 5 >= val + nb)
                goto again;
            *t++ = '/';
-           switch (sigp->hash_algo) {
-           case PGPHASHALGO_MD5:
-               t = stpcpy(t, "MD5");
-               break;
-           case PGPHASHALGO_SHA1:
-               t = stpcpy(t, "SHA1");
-               break;
-           default:
-               (void) snprintf(t, nb - (t - val), "%d", sigp->hash_algo);
-               t += strlen(t);
-               break;
-           }
+           t = stpcpy(t, pgpValString(PGPVAL_HASHALGO, sigp->hash_algo));
            if (t + strlen (", ") + 1 >= val + nb)
                goto again;