summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2010-05-19 15:32:54 +0300
committerPanu Matilainen <pmatilai@redhat.com>2010-06-11 10:29:25 +0300
commitae66316c2cf9a49a804369fc1629eda426fa0ecd (patch)
treea12ac0f84211b20492390afed7a9215e4d75d660
parent6b38fba9bc6ea85e36bb2140cce1a895cfa28537 (diff)
downloadrpm-ae66316c2cf9a49a804369fc1629eda426fa0ecd.tar.gz
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. (cherry picked from commit 2be413810cd78b0a503699ceca3f8e1505f1b425)
-rw-r--r--rpmio/rpmpgp.c34
-rw-r--r--rpmio/rpmpgp.h20
2 files changed, 46 insertions, 8 deletions
diff --git a/rpmio/rpmpgp.c b/rpmio/rpmpgp.c
index 854174e3c..f4d68c1c2 100644
--- a/rpmio/rpmpgp.c
+++ b/rpmio/rpmpgp.c
@@ -202,14 +202,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)
@@ -218,6 +211,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;
diff --git a/rpmio/rpmpgp.h b/rpmio/rpmpgp.h
index c8876b3d1..5d3bc6209 100644
--- a/rpmio/rpmpgp.h
+++ b/rpmio/rpmpgp.h
@@ -920,6 +920,19 @@ typedef enum pgpArmorKey_e {
PGPARMORKEY_CHARSET = 5 /*!< Charset: */
} pgpArmorKey;
+typedef enum pgpValType_e {
+ PGPVAL_TAG = 1,
+ PGPVAL_ARMORBLOCK = 2,
+ PGPVAL_ARMORKEY = 3,
+ PGPVAL_SIGTYPE = 4,
+ PGPVAL_SUBTYPE = 5,
+ PGPVAL_PUBKEYALGO = 6,
+ PGPVAL_SYMKEYALGO = 7,
+ PGPVAL_COMPRESSALGO = 8,
+ PGPVAL_HASHALGO = 9,
+ PGPVAL_SERVERPREFS = 10,
+} pgpValType;
+
/** \ingroup rpmpgp
* Bit(s) to control digest operation.
*/
@@ -927,6 +940,13 @@ typedef enum rpmDigestFlags_e {
RPMDIGEST_NONE = 0
} rpmDigestFlags;
+/** \ingroup rpmpgp
+ * Return string representation of am OpenPGP value.
+ * @param type type of value
+ * @param val byte value to lookup
+ * @return string value of byte
+ */
+const char * pgpValString(pgpValType type, uint8_t val);
/** \ingroup rpmpgp
* Return (native-endian) integer from big-endian representation.