aboutsummaryrefslogtreecommitdiffstats
path: root/rpm2header.c
diff options
context:
space:
mode:
authorFrederic Lepied <flepied@mandriva.com>2000-02-18 17:19:40 +0000
committerFrederic Lepied <flepied@mandriva.com>2000-02-18 17:19:40 +0000
commit1ab1ac710b440b016419cf06e9f18a2df979a24e (patch)
tree938b666bae5d8540851aaa4a23ffbb15a89ffd02 /rpm2header.c
parentc278da3908fc84567530937725b16c81a3a887c7 (diff)
downloadrpmtools-1ab1ac710b440b016419cf06e9f18a2df979a24e.tar
rpmtools-1ab1ac710b440b016419cf06e9f18a2df979a24e.tar.gz
rpmtools-1ab1ac710b440b016419cf06e9f18a2df979a24e.tar.bz2
rpmtools-1ab1ac710b440b016419cf06e9f18a2df979a24e.tar.xz
rpmtools-1ab1ac710b440b016419cf06e9f18a2df979a24e.zip
* close files !
* don't dup many times.
Diffstat (limited to 'rpm2header.c')
-rw-r--r--rpm2header.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/rpm2header.c b/rpm2header.c
index 32ace46..0cf6d6b 100644
--- a/rpm2header.c
+++ b/rpm2header.c
@@ -23,19 +23,24 @@ int_32 FD_size(FD_t fd) {
int main(int argc, char **argv) {
int i;
+ FD_t fout;
if (argc < 2) {
fprintf(stderr, "usage: rpm2header <rpms>\n");
exit(1);
}
+ fout = fdDup(1 /*stdout*/);
+
for (i = 1; i < argc; i++) {
FD_t fd;
Header h;
int isSource;
int_32 size;
const char *name = basename(argv[i]);
-
+
+ fprintf(stderr, "%s\n", argv[i]);
+
if (!(fd = fdOpen(argv[i], O_RDONLY, 0666))) {
perror("open");
exit(1);
@@ -70,9 +75,10 @@ int main(int argc, char **argv) {
headerRemoveEntry(h, RPMTAG_VERIFYSCRIPT);
headerAddEntry(h, FILENAME_TAG, RPM_STRING_TYPE, name, 1);
headerAddEntry(h, FILESIZE_TAG, RPM_INT32_TYPE, &size, 1);
- headerWrite(fdDup(1 /*stdout*/), h, HEADER_MAGIC_YES);
+ headerWrite(fout, h, HEADER_MAGIC_YES);
headerFree(h);
}
+ fdClose(fd);
}
return 0;
}