Use proper types for tag and format extension functions
authorPanu Matilainen <pmatilai@redhat.com>
Tue, 21 Sep 2010 09:23:18 +0000 (12:23 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Tue, 21 Sep 2010 09:23:18 +0000 (12:23 +0300)
- Stuff the tag prototypes into misc.h in lack of better place
- Actually use the headerTagFooFunction prototypes instead of void *

lib/formats.c
lib/header.c
lib/headerfmt.c
lib/misc.h
lib/rpmtd.c
lib/tagexts.c

index 499c5d0..c377370 100644 (file)
 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) {
index 91dd6bd..55b2d17 100644 (file)
@@ -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;
index 453ed02..7e86b97 100644 (file)
@@ -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"
 
 #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 {
index 58a5e70..76c22e1 100644 (file)
@@ -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.
index fc7af73..0d023a2 100644 (file)
@@ -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));
index 78515c7..9249dd0 100644 (file)
 #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) {