summaryrefslogtreecommitdiff
path: root/rpm2cpio.c
diff options
context:
space:
mode:
authorjbj <devnull@localhost>1999-11-14 19:15:18 +0000
committerjbj <devnull@localhost>1999-11-14 19:15:18 +0000
commit4e62a322a266e9d95007540d10e67fc75bf80aa7 (patch)
treef1ba2b2704bf0397cc7d0bac2b323480aed56a8a /rpm2cpio.c
parent471ba3b2386a15b5cd0ad202238dd38161788416 (diff)
downloadrpm-4e62a322a266e9d95007540d10e67fc75bf80aa7.tar.gz
rpm-4e62a322a266e9d95007540d10e67fc75bf80aa7.tar.bz2
rpm-4e62a322a266e9d95007540d10e67fc75bf80aa7.zip
lib/rpmio.c: Implement per-fd layers as a stack, add fdPush/fdPop.
lib/rpmio.c: Add fd{Get,Set}{Io,Fp,Fdno} abstraction wrappers. lib/rpmio.c: Start rationalizing debug output by using fdbg to display the fd layer stack. rpm.c: Add --nolibio to disable libio if desired. rpm2cpio.c: Use Fdopen(..., gzdio) and ufdCopy(). build/build.c: Use Fdopen(..., fpio) rather than fdio. build/files.c: Use Fdopen(..., fpio) rather than ufdio. build/parseSpec.c: ditto. lib/macro.c: ditto. lib/rpmrc.c: ditto lib/macro.c: Use Fopen(..., ufdio) in isCompressed() rather that fdOpen(). lib/misc.c: ditto. lib/misc.c: Avoid fstat by using Stat. build/pack.c: Add persist fdLink() and use fdFree() in package{Sources,Binaries} build/pack.c: Try to remove the fdDup before cpioBuildArchive() call. build/pack.c: Use rpmGenPath with %{_builddir}. build/parsePreamble.c: Use fdSize rather than Stat to get icon file size. lib/rpmrc.c: ditto lib/ftp.c: start capturing ufdio layer syserrno/errcookie. CVS patchset: 3424 CVS date: 1999/11/14 19:15:18
Diffstat (limited to 'rpm2cpio.c')
-rw-r--r--rpm2cpio.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/rpm2cpio.c b/rpm2cpio.c
index 8c256355d..7bf8ca7be 100644
--- a/rpm2cpio.c
+++ b/rpm2cpio.c
@@ -7,10 +7,8 @@
int main(int argc, char **argv)
{
FD_t fdi, fdo;
- Header hd;
+ Header h;
int rc, isSource;
- char buffer[1024];
- int ct;
FD_t gzdi;
setprogname(argv[0]); /* Retrofit glibc __progname */
@@ -20,13 +18,13 @@ int main(int argc, char **argv)
fdi = Fopen(argv[1], "r.ufdio");
}
- if (Fileno(fdi) < 0) {
- perror("cannot open package");
+ if (fdi == NULL || Ferror(fdi)) {
+ fprintf(stderr, _("cannot open package: %s\n"), Fstrerror(fdi));
exit(EXIT_FAILURE);
}
fdo = fdDup(STDOUT_FILENO);
- rc = rpmReadPackageHeader(fdi, &hd, &isSource, NULL, NULL);
+ rc = rpmReadPackageHeader(fdi, &h, &isSource, NULL, NULL);
switch (rc) {
case 0:
break;
@@ -40,12 +38,15 @@ int main(int argc, char **argv)
break;
}
-#ifdef DYING
- gzdi = gzdFdopen(fdi, "r"); /* XXX gzdi == fdi */
-#else
gzdi = Fdopen(fdi, "r.gzdio"); /* XXX gzdi == fdi */
-#endif
+ if (gzdi == NULL || Ferror(gzdi)) {
+ fprintf(stderr, _("cannot re-open payload: %s\n"), Fstrerror(gzdi));
+ exit(EXIT_FAILURE);
+ }
+#ifdef DYING
+ { char buffer[BUFSIZ];
+ int ct;
while ((ct = Fread(buffer, sizeof(buffer[0]), sizeof(buffer), gzdi)) > 0) {
Fwrite(buffer, sizeof(buffer[0]), ct, fdo);
}
@@ -56,6 +57,12 @@ int main(int argc, char **argv)
} else {
rc = EXIT_SUCCESS;
}
+ }
+#else
+ rc = ufdCopy(gzdi, fdo);
+ rc = (rc <= 0) ? EXIT_FAILURE : EXIT_SUCCESS;
+ Fclose(fdo);
+#endif
Fclose(gzdi); /* XXX gzdi == fdi */