summaryrefslogtreecommitdiff
path: root/rpmdb/header_common.c
blob: fe3f4685cc8a3444cccfd0576b8a865c49d433e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
/** \ingroup header
 * \file rpmdb/header_common.c
 */

#include <rpm/header.h>
#include "rpmdb/header_method.h"

/** \ingroup header
 * Header methods for rpm headers.
 */
extern struct HV_s * hdrVec;

/** \ingroup header
 */
static inline HV_t h2hv(Header h)
{
    return ((HV_t)h);
}

Header headerNew(void)
{
    return hdrVec->hdrnew();
}

Header headerFree( Header h)
{
    if (h == NULL) return NULL;
    return (h2hv(h)->hdrfree) (h);
}

Header headerLink(Header h)
{
    return (h2hv(h)->hdrlink) (h);
}

Header headerUnlink(Header h)
{
    if (h == NULL) return NULL;
    return (h2hv(h)->hdrunlink) (h);
}

void headerSort(Header h)
{
/* FIX: add rc */
    (h2hv(h)->hdrsort) (h);
    return;
}

void headerUnsort(Header h)
{
/* FIX: add rc */
    (h2hv(h)->hdrunsort) (h);
    return;
}

unsigned int headerSizeof(Header h, enum hMagic magicp)
{
    if (h == NULL) return 0;
    return (h2hv(h)->hdrsizeof) (h, magicp);
}

void * headerUnload(Header h)
{
    return (h2hv(h)->hdrunload) (h);
}

Header headerReload(Header h, int tag)
{
    return (h2hv(h)->hdrreload) (h, tag);
}

Header headerCopy(Header h)
{
    return (h2hv(h)->hdrcopy) (h);
}

Header headerLoad(void * uh)
{
    return hdrVec->hdrload(uh);
}

Header headerCopyLoad(const void * uh)
{
    return hdrVec->hdrcopyload(uh);
}

Header headerRead(FD_t fd, enum hMagic magicp)
{
    return hdrVec->hdrread(fd, magicp);
}

int headerWrite(FD_t fd, Header h, enum hMagic magicp)
{
    if (h == NULL) return 0;
    return (h2hv(h)->hdrwrite) (fd, h, magicp);
}

int headerIsEntry(Header h, int32_t tag)
{
    if (h == NULL) return 0;
    return (h2hv(h)->hdrisentry) (h, tag);
}

void * headerFreeTag(Header h,
		const void * data, rpmTagType type)
{
    return (h2hv(h)->hdrfreetag) (h, data, type);
}

int headerGetEntry(Header h, int32_t tag,
			hTYP_t type,
			void ** p,
			hCNT_t c)
{
    return (h2hv(h)->hdrget) (h, tag, type, p, c);
}

int headerGetEntryMinMemory(Header h, int32_t tag,
			hTYP_t type,
			hPTR_t * p, 
			hCNT_t c)
{
    return (h2hv(h)->hdrgetmin) (h, tag, type, p, c);
}

int headerAddEntry(Header h, int32_t tag, int32_t type, const void * p, int32_t c)
{
    return (h2hv(h)->hdradd) (h, tag, type, p, c);
}

int headerAppendEntry(Header h, int32_t tag, int32_t type,
		const void * p, int32_t c)
{
    return (h2hv(h)->hdrappend) (h, tag, type, p, c);
}

int headerAddOrAppendEntry(Header h, int32_t tag, int32_t type,
		const void * p, int32_t c)
{
    return (h2hv(h)->hdraddorappend) (h, tag, type, p, c);
}

int headerAddI18NString(Header h, int32_t tag, const char * string,
		const char * lang)
{
    return (h2hv(h)->hdraddi18n) (h, tag, string, lang);
}

int headerModifyEntry(Header h, int32_t tag, int32_t type,
			const void * p, int32_t c)
{
    return (h2hv(h)->hdrmodify) (h, tag, type, p, c);
}

int headerRemoveEntry(Header h, int32_t tag)
{
    return (h2hv(h)->hdrremove) (h, tag);
}

char * headerSprintf(Header h, const char * fmt,
		     const struct headerTagTableEntry_s * tbltags,
		     const struct headerSprintfExtension_s * extensions,
		     errmsg_t * errmsg)
{
    return (h2hv(h)->hdrsprintf) (h, fmt, tbltags, extensions, errmsg);
}

void headerCopyTags(Header headerFrom, Header headerTo, hTAG_t tagstocopy)
{
/* FIX: add rc */
    hdrVec->hdrcopytags(headerFrom, headerTo, tagstocopy);
    return;
}

HeaderIterator headerFreeIterator(HeaderIterator hi)
{
    return hdrVec->hdrfreeiter(hi);
}

HeaderIterator headerInitIterator(Header h)
{
    return hdrVec->hdrinititer(h);
}

int headerNextIterator(HeaderIterator hi,
		hTAG_t tag,
		hTYP_t type,
		hPTR_t * p,
		hCNT_t c)
{
    return hdrVec->hdrnextiter(hi, tag, type, p, c);
}