summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2010-09-21 12:23:18 +0300
committerPanu Matilainen <pmatilai@redhat.com>2010-09-21 12:23:18 +0300
commitb0d62148a9090fb442fc7bf993f5ef3253c4b0fe (patch)
treedb3b04e0b36eaed55d2b611170c00105d7b82bbe
parent147f41bcc150d674ad86c714208c9a1f82218683 (diff)
downloadlibrpm-tizen-b0d62148a9090fb442fc7bf993f5ef3253c4b0fe.tar.gz
librpm-tizen-b0d62148a9090fb442fc7bf993f5ef3253c4b0fe.tar.bz2
librpm-tizen-b0d62148a9090fb442fc7bf993f5ef3253c4b0fe.zip
Use proper types for tag and format extension functions
- Stuff the tag prototypes into misc.h in lack of better place - Actually use the headerTagFooFunction prototypes instead of void *
-rw-r--r--lib/formats.c13
-rw-r--r--lib/header.c14
-rw-r--r--lib/headerfmt.c14
-rw-r--r--lib/misc.h14
-rw-r--r--lib/rpmtd.c5
-rw-r--r--lib/tagexts.c9
6 files changed, 26 insertions, 43 deletions
diff --git a/lib/formats.c b/lib/formats.c
index 499c5d081..c377370f4 100644
--- a/lib/formats.c
+++ b/lib/formats.c
@@ -26,15 +26,12 @@
struct headerFormatFunc_s {
rpmtdFormats fmt; /*!< Value of extension */
const char *name; /*!< Name of extension. */
- void *func; /*!< Pointer to formatter function. */
+ headerTagFormatFunction func; /*!< Pointer to formatter function. */
};
/* forward declarations */
static const struct headerFormatFunc_s rpmHeaderFormats[];
-void *rpmHeaderFormatFuncByName(const char *fmt);
-void *rpmHeaderFormatFuncByValue(rpmtdFormats fmt);
-
/**
* barebones string representation with no extra formatting
* @param td tag data container
@@ -655,10 +652,10 @@ static char * expandFormat(rpmtd td, char * formatPrefix)
return val;
}
-void *rpmHeaderFormatFuncByName(const char *fmt)
+headerTagFormatFunction rpmHeaderFormatFuncByName(const char *fmt)
{
const struct headerFormatFunc_s * ext;
- void *func = NULL;
+ headerTagFormatFunction func = NULL;
for (ext = rpmHeaderFormats; ext->name != NULL; ext++) {
if (rstreq(ext->name, fmt)) {
@@ -669,10 +666,10 @@ void *rpmHeaderFormatFuncByName(const char *fmt)
return func;
}
-void *rpmHeaderFormatFuncByValue(rpmtdFormats fmt)
+headerTagFormatFunction rpmHeaderFormatFuncByValue(rpmtdFormats fmt)
{
const struct headerFormatFunc_s * ext;
- void *func = NULL;
+ headerTagFormatFunction func = NULL;
for (ext = rpmHeaderFormats; ext->name != NULL; ext++) {
if (fmt == ext->fmt) {
diff --git a/lib/header.c b/lib/header.c
index 91dd6bd57..55b2d17d2 100644
--- a/lib/header.c
+++ b/lib/header.c
@@ -13,6 +13,7 @@
#include <rpm/rpmtypes.h>
#include <rpm/rpmstring.h>
#include "lib/header_internal.h"
+#include "lib/misc.h" /* tag function proto */
#include "debug.h"
@@ -99,19 +100,6 @@ static const size_t headerMaxbytes = (32*1024*1024);
(((_e)->info.tag >= RPMTAG_HEADERIMAGE) && ((_e)->info.tag < RPMTAG_HEADERREGIONS))
#define ENTRY_IN_REGION(_e) ((_e)->info.offset < 0)
-/** \ingroup header
- * HEADER_EXT_TAG format function prototype.
- * This is allowed to fail, which indicates the tag doesn't exist.
- *
- * @param h header
- * @retval td tag data container
- * @param flags modifier flags
- * @return 0 on success
- */
-typedef int (*headerTagTagFunction) (Header h, rpmtd td, headerGetFlags hgflags);
-
-extern void *rpmHeaderTagFunc(rpmTag tag);
-
/* Convert a 64bit value to network byte order. */
static uint64_t htonll( uint64_t n ) {
uint32_t *i = (uint32_t*)&n;
diff --git a/lib/headerfmt.c b/lib/headerfmt.c
index 453ed02b8..7e86b970d 100644
--- a/lib/headerfmt.c
+++ b/lib/headerfmt.c
@@ -8,6 +8,7 @@
#include <rpm/rpmtag.h>
#include <rpm/rpmstring.h>
#include <rpm/rpmpgp.h>
+#include "lib/misc.h" /* format function protos */
#include "debug.h"
@@ -16,19 +17,6 @@
#define PARSER_IN_EXPR 2
/** \ingroup header
- * HEADER_EXT_FORMAT format function prototype.
- * This will only ever be passed RPM_INT32_TYPE or RPM_STRING_TYPE to
- * help keep things simple.
- *
- * @param td tag data container
- * @param formatPrefix
- * @return formatted string
- */
-typedef char * (*headerTagFormatFunction) (rpmtd td, char * formatPrefix);
-
-extern void *rpmHeaderFormatFuncByName(const char *fmt);
-
-/** \ingroup header
*/
typedef struct sprintfTag_s * sprintfTag;
struct sprintfTag_s {
diff --git a/lib/misc.h b/lib/misc.h
index 58a5e708c..76c22e177 100644
--- a/lib/misc.h
+++ b/lib/misc.h
@@ -8,6 +8,7 @@
#include <string.h>
#include <rpm/rpmtypes.h>
+#include <rpm/header.h> /* for headerGetFlags typedef, duh.. */
#ifdef __cplusplus
extern "C" {
@@ -25,6 +26,19 @@ char * rpmFFlagsString(uint32_t fflags, const char *pad);
RPM_GNUC_INTERNAL
unsigned int hashFunctionString(const char * string);
+
+typedef char * (*headerTagFormatFunction) (rpmtd td, char * formatPrefix);
+typedef int (*headerTagTagFunction) (Header h, rpmtd td, headerGetFlags hgflags);
+
+RPM_GNUC_INTERNAL
+headerTagTagFunction rpmHeaderTagFunc(rpmTag tag);
+
+RPM_GNUC_INTERNAL
+headerTagFormatFunction rpmHeaderFormatFuncByName(const char *fmt);
+
+RPM_GNUC_INTERNAL
+headerTagFormatFunction rpmHeaderFormatFuncByValue(rpmtdFormats fmt);
+
/*
* These may be called w/ a NULL argument to flush the cache -- they return
* -1 if the user can't be found.
diff --git a/lib/rpmtd.c b/lib/rpmtd.c
index fc7af7378..0d023a230 100644
--- a/lib/rpmtd.c
+++ b/lib/rpmtd.c
@@ -3,13 +3,10 @@
#include <rpm/rpmtd.h>
#include <rpm/rpmstring.h>
#include <rpm/rpmpgp.h>
+#include "lib/misc.h" /* format function prototypes */
#include "debug.h"
-typedef char * (*headerTagFormatFunction) (rpmtd td, char *formatPrefix);
-
-extern void *rpmHeaderFormatFuncByValue(rpmtdFormats fmt);
-
rpmtd rpmtdNew(void)
{
rpmtd td = xmalloc(sizeof(*td));
diff --git a/lib/tagexts.c b/lib/tagexts.c
index 78515c752..9249dd04f 100644
--- a/lib/tagexts.c
+++ b/lib/tagexts.c
@@ -10,19 +10,18 @@
#include <rpm/rpmfi.h>
#include <rpm/rpmstring.h>
#include <rpm/rpmlog.h>
+#include "lib/misc.h" /* tag function proto */
#include "debug.h"
struct headerTagFunc_s {
rpmTag tag; /*!< Tag of extension. */
- void *func; /*!< Pointer to formatter function. */
+ headerTagTagFunction func; /*!< Pointer to formatter function. */
};
/* forward declarations */
static const struct headerTagFunc_s rpmHeaderTagExtensions[];
-void *rpmHeaderTagFunc(rpmTag tag);
-
/** \ingroup rpmfi
* Retrieve file names from header.
*
@@ -716,10 +715,10 @@ static int filestatusTag(Header h, rpmtd td, headerGetFlags hgflags)
return (fc > 0);
}
-void *rpmHeaderTagFunc(rpmTag tag)
+headerTagTagFunction rpmHeaderTagFunc(rpmTag tag)
{
const struct headerTagFunc_s * ext;
- void *func = NULL;
+ headerTagTagFunction func = NULL;
for (ext = rpmHeaderTagExtensions; ext->func != NULL; ext++) {
if (ext->tag == tag) {