rpm
5.2.1
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
lib
formats.c
Go to the documentation of this file.
1
5
#include "
system.h
"
6
7
#include <
rpmio.h
>
8
#include <
rpmiotypes.h
>
/* XXX fnpyKey */
9
#include <
rpmmacro.h
>
/* XXX for %_i18ndomains */
10
11
#define _RPMTAG_INTERNAL
12
#include <
rpmtag.h
>
13
#include <
rpmtypes.h
>
14
15
#define _RPMEVR_INTERNAL
16
#include <
rpmds.h
>
17
#include <
rpmfi.h
>
18
19
#include "
legacy.h
"
20
#include "
manifest.h
"
21
#include "
argv.h
"
22
#include "
fs.h
"
23
24
#include "
debug.h
"
25
26
/*@access headerSprintfExtension @*/
27
34
static
int
fsnamesTag
(
/*@unused@*/
Header
h,
HE_t
he)
35
/*@globals fileSystem, internalState @*/
36
/*@modifies he, fileSystem, internalState @*/
37
{
38
const
char
** list;
39
40
if
(
rpmGetFilesystemList
(&list, &he->
c
))
41
return
1;
42
43
he->
t
=
RPM_STRING_ARRAY_TYPE
;
44
he->
p
.
argv
= list;
45
he->
freeData
= 0;
46
47
return
0;
48
}
49
56
static
int
fssizesTag
(
Header
h,
HE_t
he)
57
/*@globals rpmGlobalMacroContext, h_errno,
58
fileSystem, internalState @*/
59
/*@modifies he, rpmGlobalMacroContext,
60
fileSystem, internalState @*/
61
{
62
rpmTagData
fnames = { .
ptr
= NULL };
63
rpmTagData
fsizes = { .
ptr
= NULL };
64
rpmTagData
p;
65
rpmuint64_t
*usages;
66
int
numFiles;
67
int
rc = 1;
/* assume error */
68
int
xx, yy;
69
70
p.
ptr
= he->
p
.
ptr
;
71
he->
tag
=
RPMTAG_FILESIZES
;
72
xx =
headerGet
(h, he, 0);
73
fsizes.
ptr
= he->
p
.
ptr
;
74
he->
tag
=
RPMTAG_FILEPATHS
;
75
yy =
headerGet
(h, he, 0);
76
fnames.
ptr
= he->
p
.
ptr
;
77
numFiles = he->
c
;
78
he->
p
.
ptr
= p.
ptr
;
79
if
(!xx || !yy) {
80
numFiles = 0;
81
fsizes.
ui32p
=
_free
(fsizes.
ui32p
);
82
fnames.
argv
=
_free
(fnames.
argv
);
83
}
84
85
if
(
rpmGetFilesystemList
(NULL, &he->
c
))
86
goto
exit;
87
88
he->
t
=
RPM_UINT64_TYPE
;
89
he->
freeData
= 1;
90
91
if
(fnames.
ptr
== NULL)
92
usages =
xcalloc
(he->
c
,
sizeof
(*usages));
93
else
94
if
(
rpmGetFilesystemUsage
(fnames.
argv
, fsizes.
ui32p
, numFiles, &usages, 0))
95
goto
exit;
96
97
he->
p
.
ui64p
= usages;
98
rc = 0;
99
100
exit:
101
fnames.
ptr
=
_free
(fnames.
ptr
);
102
fsizes.
ptr
=
_free
(fsizes.
ptr
);
103
104
return
rc;
105
}
106
113
static
int
fileclassTag
(
Header
h,
HE_t
he)
114
/*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
115
/*@modifies h, he,
116
rpmGlobalMacroContext, fileSystem, internalState @*/
117
{
118
he->
t
=
RPM_STRING_ARRAY_TYPE
;
119
rpmfiBuildFClasses
(h, &he->
p
.
argv
, &he->
c
);
120
he->
freeData
= 1;
121
return
0;
122
}
123
130
static
int
filecontextsTag
(
Header
h,
HE_t
he)
131
/*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
132
/*@modifies h, he,
133
rpmGlobalMacroContext, fileSystem, internalState @*/
134
{
135
he->
t
=
RPM_STRING_ARRAY_TYPE
;
136
rpmfiBuildFContexts
(h, &he->
p
.
argv
, &he->
c
);
137
he->
freeData
= 1;
138
return
0;
139
}
140
147
static
int
fscontextsTag
(
Header
h,
HE_t
he)
148
/*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
149
/*@modifies h, he,
150
rpmGlobalMacroContext, fileSystem, internalState @*/
151
{
152
he->
t
=
RPM_STRING_ARRAY_TYPE
;
153
rpmfiBuildFSContexts
(h, &he->
p
.
argv
, &he->
c
);
154
he->
freeData
= 1;
155
return
0;
156
}
157
164
static
int
recontextsTag
(
Header
h,
HE_t
he)
165
/*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
166
/*@modifies h, he,
167
rpmGlobalMacroContext, fileSystem, internalState @*/
168
{
169
he->
t
=
RPM_STRING_ARRAY_TYPE
;
170
rpmfiBuildREContexts
(h, &he->
p
.
argv
, &he->
c
);
171
he->
freeData
= 1;
172
return
0;
173
}
174
181
static
int
fileprovideTag
(
Header
h,
HE_t
he)
182
/*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
183
/*@modifies h, he,
184
rpmGlobalMacroContext, fileSystem, internalState @*/
185
{
186
he->
t
=
RPM_STRING_ARRAY_TYPE
;
187
rpmfiBuildFDeps
(h,
RPMTAG_PROVIDENAME
, &he->
p
.
argv
, &he->
c
);
188
he->
freeData
= 1;
189
return
0;
190
}
191
198
static
int
filerequireTag
(
Header
h,
HE_t
he)
199
/*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
200
/*@modifies h, he,
201
rpmGlobalMacroContext, fileSystem, internalState @*/
202
{
203
he->
t
=
RPM_STRING_ARRAY_TYPE
;
204
rpmfiBuildFDeps
(h,
RPMTAG_REQUIRENAME
, &he->
p
.
argv
, &he->
c
);
205
he->
freeData
= 1;
206
return
0;
207
}
208
215
static
int
missingokTag
(
Header
h,
HE_t
he)
216
/*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
217
/*@modifies h, he,
218
rpmGlobalMacroContext, fileSystem, internalState @*/
219
{
220
rpmds
ds =
rpmdsNew
(h,
RPMTAG_REQUIRENAME
, 0);
221
ARGV_t
av = NULL;
222
ARGV_t
argv;
223
int
argc = 0;
224
char
* t;
225
size_t
nb = 0;
226
int
i;
227
228
if
(ds == NULL)
229
return
1;
230
231
/* Collect dependencies marked as hints. */
232
ds =
rpmdsInit
(ds);
233
if
(ds != NULL)
234
while
(
rpmdsNext
(ds) >= 0) {
235
int
Flags =
rpmdsFlags
(ds);
236
const
char
* DNEVR;
237
if
(!(Flags & RPMSENSE_MISSINGOK))
238
continue
;
239
DNEVR =
rpmdsDNEVR
(ds);
240
if
(DNEVR == NULL)
241
continue
;
242
nb +=
sizeof
(*argv) + strlen(DNEVR+2) + 1;
243
(void)
argvAdd
(&av, DNEVR+2);
244
argc++;
245
}
246
nb +=
sizeof
(*argv);
/* final argv NULL */
247
248
/* Create contiguous header string array. */
249
argv = (
ARGV_t
)
xcalloc
(nb, 1);
250
t = (
char
*)(argv + argc);
251
for
(i = 0; i < argc; i++) {
252
argv[i] = t;
253
t =
stpcpy
(t, av[i]);
254
*t++ =
'\0'
;
255
}
256
av =
argvFree
(av);
257
(void)
rpmdsFree
(ds);
258
ds = NULL;
259
260
he->
t
=
RPM_STRING_ARRAY_TYPE
;
261
he->
p
.
argv
= argv;
262
he->
c
= argc;
263
he->
freeData
= 1;
264
return
0;
265
}
266
267
/*@-type@*/
/* FIX: cast? */
268
static
struct
headerSprintfExtension_s
_rpmHeaderFormats
[] = {
269
{ HEADER_EXT_TAG,
"RPMTAG_ENHANCES"
,
270
{ .tagFunction =
missingokTag
} },
271
{ HEADER_EXT_TAG,
"RPMTAG_FILECLASS"
,
272
{ .tagFunction =
fileclassTag
} },
273
{ HEADER_EXT_TAG,
"RPMTAG_FILECONTEXTS"
,
274
{ .tagFunction =
filecontextsTag
} },
275
{ HEADER_EXT_TAG,
"RPMTAG_FILEPROVIDE"
,
276
{ .tagFunction =
fileprovideTag
} },
277
{ HEADER_EXT_TAG,
"RPMTAG_FILEREQUIRE"
,
278
{ .tagFunction =
filerequireTag
} },
279
{ HEADER_EXT_TAG,
"RPMTAG_FSCONTEXTS"
,
280
{ .tagFunction =
fscontextsTag
} },
281
{ HEADER_EXT_TAG,
"RPMTAG_FSNAMES"
,
282
{ .tagFunction =
fsnamesTag
} },
283
{ HEADER_EXT_TAG,
"RPMTAG_FSSIZES"
,
284
{ .tagFunction =
fssizesTag
} },
285
{ HEADER_EXT_TAG,
"RPMTAG_RECONTEXTS"
,
286
{ .tagFunction =
recontextsTag
} },
287
{ HEADER_EXT_TAG,
"RPMTAG_SUGGESTS"
,
288
{ .tagFunction =
missingokTag
} },
289
{ HEADER_EXT_MORE, NULL, { (
void
*) &
headerCompoundFormats
} }
290
} ;
291
/*@=type@*/
292
293
headerSprintfExtension
rpmHeaderFormats
= &
_rpmHeaderFormats
[0];
Generated on Mon Sep 23 2013 04:05:12 for rpm by
1.8.3.1