aboutsummaryrefslogtreecommitdiffstats
path: root/rpm5compat.h
diff options
context:
space:
mode:
authorPer Øyvind Karlsen <peroyvind@mandriva.org>2008-03-02 18:18:14 +0000
committerPer Øyvind Karlsen <peroyvind@mandriva.org>2008-03-02 18:18:14 +0000
commit7b438cda34f0e96ef927d86c2abdc1c47f691aaf (patch)
tree8fe012f64956ad50435b34f5de0fe0f71afd3c7f /rpm5compat.h
parent6c14a9b66694bc2ef9d6a61bdf98b3ed02659fe5 (diff)
downloadperl-URPM-7b438cda34f0e96ef927d86c2abdc1c47f691aaf.tar
perl-URPM-7b438cda34f0e96ef927d86c2abdc1c47f691aaf.tar.gz
perl-URPM-7b438cda34f0e96ef927d86c2abdc1c47f691aaf.tar.bz2
perl-URPM-7b438cda34f0e96ef927d86c2abdc1c47f691aaf.tar.xz
perl-URPM-7b438cda34f0e96ef927d86c2abdc1c47f691aaf.zip
make C++ compliant
add som function wrappers for apt-get
Diffstat (limited to 'rpm5compat.h')
-rw-r--r--rpm5compat.h58
1 files changed, 38 insertions, 20 deletions
diff --git a/rpm5compat.h b/rpm5compat.h
index 76cc1bf..a32eff9 100644
--- a/rpm5compat.h
+++ b/rpm5compat.h
@@ -4,19 +4,32 @@
* $Id$
*/
+#ifndef H_RPM4COMPAT
+#define H_RPM4COMPAT 1
+
#define RPM_NULL_TYPE 0
#define RPM_CHAR_TYPE RPM_UINT8_TYPE
#define RPM_INT8_TYPE RPM_UINT8_TYPE
#define RPM_INT16_TYPE RPM_UINT16_TYPE
#define RPM_INT32_TYPE RPM_UINT32_TYPE
+#include <fcntl.h>
+#include <unistd.h>
+#include <stdint.h>
+#include <stdio.h>
+
#define WITH_DB
+#define _RPMPS_INTERNAL
+#define _RPMEVR_INTERNAL
+#define _RPMTAG_INTERNAL
+#include <rpm/rpmlib.h>
#include <rpm/rpmevr.h>
#include <rpm/rpmio.h>
#include <rpm/pkgio.h>
#include <rpm/rpmcb.h>
#include <rpm/rpmts.h>
#include <rpm/rpmmacro.h>
+#include <rpm/rpmpgp.h>
enum hMagic {
HEADER_MAGIC_NO = 0,
@@ -29,6 +42,7 @@ typedef uint32_t * hTYP_t;
typedef const void * hPTR_t;
typedef uint32_t * hCNT_t;
typedef uint32_t int_32;
+typedef uint32_t uint_32;
typedef uint16_t uint_16;
typedef uint8_t byte;
@@ -43,13 +57,15 @@ typedef union hRET_s {
uint8_t * i8p;
} * hRET_t;
+typedef enum pgpVSFlags_e rpmVSFlags_e;
+
static inline int headerGetEntry(Header h, int_32 tag, hTYP_t type, void ** p, hCNT_t c){
- HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he));
+ HE_t he = (HE_s*)memset(alloca(sizeof(*he)), 0, sizeof(*he));
int rc;
/* Always ensure to initialize */
*(void **)p = NULL;
- he->tag = tag;
+ he->tag = (rpmTag)tag;
rc = headerGet(h, he, tag);
if (rc) {
if (type) *type = he->t;
@@ -61,37 +77,37 @@ static inline int headerGetEntry(Header h, int_32 tag, hTYP_t type, void ** p, h
}
static int headerAddEntry(Header h, int_32 tag, int_32 type, const void * p, int_32 c) {
- HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he));
+ HE_t he = (HE_s*)memset(alloca(sizeof(*he)), 0, sizeof(*he));
- he->tag = tag;
- he->t = type;
- he->p.str = p;
- he->c = c;
+ he->tag = (rpmTag)tag;
+ he->t = (rpmTagType)type;
+ he->p.str = (const char*)p;
+ he->c = (rpmTagCount)c;
return headerPut(h, he, 0);
}
static int headerRemoveEntry(Header h, int_32 tag) {
- HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he));
+ HE_t he = (HE_s*)memset(alloca(sizeof(*he)), 0, sizeof(*he));
- he->tag = tag;
+ he->tag = (rpmTag)tag;
return headerDel(h, he, 0);
}
int headerModifyEntry(Header h, int_32 tag, int_32 type, const void * p, int_32 c) {
- HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he));
+ HE_t he = (HE_s*)memset(alloca(sizeof(*he)), 0, sizeof(*he));
- he->tag = tag;
- he->t = type;
- he->p.str = p;
- he->c = c;
+ he->tag = (rpmTag)tag;
+ he->t = (rpmTagType)type;
+ he->p.str = (const char*)p;
+ he->c = (rpmTagCount)c;
return headerMod(h, he, 0);
}
static int headerNextIterator(HeaderIterator hi, hTAG_t tag, hTYP_t type, hPTR_t * p, hCNT_t c) {
- HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he));
+ HE_t he = (HE_s*)memset(alloca(sizeof(*he)), 0, sizeof(*he));
- he->tag = (rpmTag)tag;
+ he->tag = *(rpmTag*)tag;
return headerNext(hi, he, 0);
}
@@ -112,12 +128,12 @@ void * headerFreeData(const void * data, rpmTagType type) {
static int headerWrite(void * _fd, Header h, enum hMagic magicp) {
const char item[] = "Header";
const char * msg = NULL;
- rpmRC rc = rpmpkgWrite(item, _fd, h, &msg);
+ rpmRC rc = rpmpkgWrite(item, (FD_t)_fd, h, &msg);
if (rc != RPMRC_OK) {
rpmlog(RPMLOG_ERR, "%s: %s: %s\n", "headerWrite", item, msg);
rc = RPMRC_FAIL;
}
- msg = _free(msg);
+ msg = (const char*)_free(msg);
return rc;
}
@@ -125,7 +141,7 @@ static inline Header headerRead(void * _fd, enum hMagic magicp) {
const char item[] = "Header";
Header h = NULL;
const char * msg = NULL;
- rpmRC rc = rpmpkgRead(item, _fd, &h, &msg);
+ rpmRC rc = rpmpkgRead(item, (FD_t)_fd, &h, &msg);
switch (rc) {
default:
rpmlog(RPMLOG_ERR, "%s: %s: %s\n", "headerRead", item, msg);
@@ -134,7 +150,7 @@ static inline Header headerRead(void * _fd, enum hMagic magicp) {
case RPMRC_OK:
break;
}
- msg = _free(msg);
+ msg = (const char*)_free(msg);
return h;
}
@@ -145,3 +161,5 @@ int rpmMachineScore(int type, const char * name) {
_free(platform);
return score;
}
+#endif /* rpm4compat.h */
+