blob: a7cfc8f2a21dc55d95407048e986da6099833925 (
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
|
/* rpmarchive: spit out the main archive portion of a package */
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <zlib.h>
#include "lib/package.h"
#include "rpmlib.h"
int main(int argc, char **argv)
{
int fd;
Header hd;
int rc, isSource;
char buffer[1024];
int ct;
gzFile stream;
if (argc == 1) {
fd = 0;
} else {
fd = open(argv[1], O_RDONLY, 0644);
}
if (fd < 0) {
perror("cannot open package");
exit(1);
}
rc = pkgReadHeader(fd, &hd, &isSource);
if (rc == 1) {
fprintf(stderr, "argument is not an RPM package\n");
exit(1);
} else if (rc) {
fprintf(stderr, "error reading header from package\n");
exit(1);
}
stream = gzdopen(fd, "r");
while ((ct = gzread(stream, &buffer, 1024))) {
write(1, &buffer, ct);
}
return 0;
}
|