Eliminate use of pgpHashAlgo in rpmio interface arguments

- While its use would seem kinda obvious here, in rpm context this
  information often comes from header tags which are plain integers
  and would require conversion/casting to the enum. What matters is
  the integral value, not it being actual enum.
This commit is contained in:
Panu Matilainen 2010-10-22 12:22:44 +03:00
parent 08b56c5304
commit e104b67237
6 changed files with 19 additions and 21 deletions

View File

@ -21,7 +21,7 @@
struct DIGEST_CTX_s {
rpmDigestFlags flags; /*!< Bit(s) to control digest operation. */
HASHContext *hashctx; /*!< Internal NSS hash context. */
pgpHashAlgo algo; /*!< Used hash algorithm */
int algo; /*!< Used hash algorithm */
};
#define DIGESTS_MAX 11
@ -53,7 +53,7 @@ rpmDigestBundle rpmDigestBundleFree(rpmDigestBundle bundle)
return NULL;
}
int rpmDigestBundleAdd(rpmDigestBundle bundle, pgpHashAlgo algo,
int rpmDigestBundleAdd(rpmDigestBundle bundle, int algo,
rpmDigestFlags flags)
{
DIGEST_CTX ctx = NULL;
@ -90,7 +90,7 @@ int rpmDigestBundleUpdate(rpmDigestBundle bundle, const void *data, size_t len)
}
int rpmDigestBundleFinal(rpmDigestBundle bundle,
pgpHashAlgo algo, void ** datap, size_t * lenp, int asAscii)
int algo, void ** datap, size_t * lenp, int asAscii)
{
int rc = 0;
if (bundle && algo >= bundle->index_min && algo <= bundle->index_max) {
@ -100,7 +100,7 @@ int rpmDigestBundleFinal(rpmDigestBundle bundle,
return rc;
}
DIGEST_CTX rpmDigestBundleDupCtx(rpmDigestBundle bundle, pgpHashAlgo algo)
DIGEST_CTX rpmDigestBundleDupCtx(rpmDigestBundle bundle, int algo)
{
DIGEST_CTX dup = NULL;
if (bundle && algo >= bundle->index_min && algo <= bundle->index_max) {
@ -124,7 +124,7 @@ rpmDigestDup(DIGEST_CTX octx)
}
RPM_GNUC_PURE
static HASH_HashType getHashType(pgpHashAlgo hashalgo)
static HASH_HashType getHashType(int hashalgo)
{
switch (hashalgo) {
case PGPHASHALGO_MD5:
@ -155,13 +155,13 @@ static HASH_HashType getHashType(pgpHashAlgo hashalgo)
}
size_t
rpmDigestLength(pgpHashAlgo hashalgo)
rpmDigestLength(int hashalgo)
{
return HASH_ResultLen(getHashType(hashalgo));
}
DIGEST_CTX
rpmDigestInit(pgpHashAlgo hashalgo, rpmDigestFlags flags)
rpmDigestInit(int hashalgo, rpmDigestFlags flags)
{
HASH_HashType type = getHashType(hashalgo);
HASHContext *hashctx = NULL;

View File

@ -132,7 +132,7 @@ exit:
return fdno;
}
int rpmDoDigest(pgpHashAlgo algo, const char * fn,int asAscii,
int rpmDoDigest(int algo, const char * fn,int asAscii,
unsigned char * digest, rpm_loff_t * fsizep)
{
const char * path;

View File

@ -35,7 +35,7 @@ typedef enum rpmCompressedMagic_e {
* @retval *fsizep file size pointer (or NULL)
* @return 0 on success, 1 on error
*/
int rpmDoDigest(pgpHashAlgo algo, const char * fn,int asAscii,
int rpmDoDigest(int algo, const char * fn,int asAscii,
unsigned char * digest, rpm_loff_t * fsizep);
/** \ingroup rpmfileutil

View File

@ -1883,7 +1883,7 @@ static const struct FDIO_s fpio_s = {
};
static const FDIO_t fpio = &fpio_s ;
void fdInitDigest(FD_t fd, pgpHashAlgo hashalgo, rpmDigestFlags flags)
void fdInitDigest(FD_t fd, int hashalgo, rpmDigestFlags flags)
{
if (fd->digests == NULL) {
fd->digests = rpmDigestBundleNew();
@ -1902,10 +1902,8 @@ static void fdUpdateDigests(FD_t fd, const void * buf, size_t buflen)
}
}
void fdFiniDigest(FD_t fd, pgpHashAlgo hashalgo,
void ** datap,
size_t * lenp,
int asAscii)
void fdFiniDigest(FD_t fd, int hashalgo,
void ** datap, size_t * lenp, int asAscii)
{
if (fd && fd->digests) {
fdstat_enter(fd, FDSTAT_DIGEST);

View File

@ -18,11 +18,11 @@ rpmDigestBundle fdGetBundle(FD_t fd);
/** \ingroup rpmio
* Attach digest to fd.
*/
void fdInitDigest(FD_t fd, pgpHashAlgo hashalgo, rpmDigestFlags flags);
void fdInitDigest(FD_t fd, int hashalgo, rpmDigestFlags flags);
/** \ingroup rpmio
*/
void fdFiniDigest(FD_t fd, pgpHashAlgo hashalgo,
void fdFiniDigest(FD_t fd, int hashalgo,
void ** datap,
size_t * lenp,
int asAscii);

View File

@ -1106,7 +1106,7 @@ DIGEST_CTX rpmDigestDup(DIGEST_CTX octx);
* @param hashalgo type of digest
* @return digest length, zero on invalid algorithm
*/
size_t rpmDigestLength(pgpHashAlgo hashalgo);
size_t rpmDigestLength(int hashalgo);
/** \ingroup rpmpgp
* Initialize digest.
@ -1115,7 +1115,7 @@ size_t rpmDigestLength(pgpHashAlgo hashalgo);
* @param flags bit(s) to control digest operation
* @return digest context
*/
DIGEST_CTX rpmDigestInit(pgpHashAlgo hashalgo, rpmDigestFlags flags);
DIGEST_CTX rpmDigestInit(int hashalgo, rpmDigestFlags flags);
/** \ingroup rpmpgp
* Update context with next plain text buffer.
@ -1161,7 +1161,7 @@ rpmDigestBundle rpmDigestBundleFree(rpmDigestBundle bundle);
* @param flags bit(s) to control digest operation
* @return 0 on success
*/
int rpmDigestBundleAdd(rpmDigestBundle bundle, pgpHashAlgo algo,
int rpmDigestBundleAdd(rpmDigestBundle bundle, int algo,
rpmDigestFlags flags);
/** \ingroup rpmpgp
@ -1184,7 +1184,7 @@ int rpmDigestBundleUpdate(rpmDigestBundle bundle, const void *data, size_t len);
* @return 0 on success
*/
int rpmDigestBundleFinal(rpmDigestBundle bundle,
pgpHashAlgo algo, void ** datap, size_t * lenp, int asAscii);
int algo, void ** datap, size_t * lenp, int asAscii);
/** \ingroup rpmpgp
* Duplicate a digest context from a bundle.
@ -1192,7 +1192,7 @@ int rpmDigestBundleFinal(rpmDigestBundle bundle,
* @param algo type of digest to dup
* @return duplicated digest context
*/
DIGEST_CTX rpmDigestBundleDupCtx(rpmDigestBundle bundle, pgpHashAlgo algo);
DIGEST_CTX rpmDigestBundleDupCtx(rpmDigestBundle bundle, int algo);
#ifdef __cplusplus
}