summaryrefslogtreecommitdiff
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
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.
-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 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;
diff --git a/rpmio/rpmpgp.h b/rpmio/rpmpgp.h
index 79f0523c7..d96d11f75 100644
--- a/rpmio/rpmpgp.h
+++ b/rpmio/rpmpgp.h
@@ -913,6 +913,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.
*/
@@ -920,6 +933,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.