summaryrefslogtreecommitdiff
path: root/rpmio/rpmpgp.c
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2010-05-19 15:32:54 +0300
committerPanu Matilainen <pmatilai@redhat.com>2010-05-19 15:32:54 +0300
commit2be413810cd78b0a503699ceca3f8e1505f1b425 (patch)
tree307cad8d530727a5e9283db60e09a4bb46391379 /rpmio/rpmpgp.c
parent072815887faa202a60b5ca310e6e5cbfbfbeac5d (diff)
downloadlibrpm-tizen-2be413810cd78b0a503699ceca3f8e1505f1b425.tar.gz
librpm-tizen-2be413810cd78b0a503699ceca3f8e1505f1b425.tar.bz2
librpm-tizen-2be413810cd78b0a503699ceca3f8e1505f1b425.zip
Add public pgpValString() function + enum for the various types
- The equivalent used to be possible in 4.4.x era as the value tables were all exported, but this way we need to export far less and the implementation details stay internal.
Diffstat (limited to 'rpmio/rpmpgp.c')
-rw-r--r--rpmio/rpmpgp.c34
1 files changed, 26 insertions, 8 deletions
diff --git a/rpmio/rpmpgp.c b/rpmio/rpmpgp.c
index 24e1caa75..0863a056d 100644
--- a/rpmio/rpmpgp.c
+++ b/rpmio/rpmpgp.c
@@ -207,14 +207,7 @@ static void pgpPrtStr(const char *pre, const char *s)
fprintf(stderr, " %s", s);
}
-/** \ingroup rpmpgp
- * Return string representation of am OpenPGP value.
- * @param vs table of (string,value) pairs
- * @param val byte value to lookup
- * @return string value of byte
- */
-static inline
-const char * pgpValStr(pgpValTbl vs, uint8_t val)
+static const char * pgpValStr(pgpValTbl vs, uint8_t val)
{
do {
if (vs->val == val)
@@ -223,6 +216,31 @@ const char * pgpValStr(pgpValTbl vs, uint8_t val)
return vs->str;
}
+static pgpValTbl pgpValTable(pgpValType type)
+{
+ switch (type) {
+ case PGPVAL_TAG: return pgpTagTbl;
+ case PGPVAL_ARMORBLOCK: return pgpArmorTbl;
+ case PGPVAL_ARMORKEY: return pgpArmorKeyTbl;
+ case PGPVAL_SIGTYPE: return pgpSigTypeTbl;
+ case PGPVAL_SUBTYPE: return pgpSubTypeTbl;
+ case PGPVAL_PUBKEYALGO: return pgpPubkeyTbl;
+ case PGPVAL_SYMKEYALGO: return pgpSymkeyTbl;
+ case PGPVAL_COMPRESSALGO: return pgpCompressionTbl;
+ case PGPVAL_HASHALGO: return pgpHashTbl;
+ case PGPVAL_SERVERPREFS: return pgpKeyServerPrefsTbl;
+ default:
+ break;
+ }
+ return NULL;
+}
+
+const char * pgpValString(pgpValType type, uint8_t val)
+{
+ pgpValTbl tbl = pgpValTable(type);
+ return (tbl != NULL) ? pgpValStr(tbl, val) : NULL;
+}
+
static void pgpPrtHex(const char *pre, const uint8_t *p, size_t plen)
{
char *hex = NULL;