summaryrefslogtreecommitdiff
path: root/rpm2cpio.c
diff options
context:
space:
mode:
authorjbj <devnull@localhost>1998-11-22 19:48:48 +0000
committerjbj <devnull@localhost>1998-11-22 19:48:48 +0000
commiteb0436b4b23ebdc8d18d2745223b6ceaf9e9a94c (patch)
tree002437098b7dd9b121a90da5fceeb805fd348b77 /rpm2cpio.c
parenta15a36abd12dba7dcf5cab390100dfcbc16dd6b8 (diff)
downloadrpm-eb0436b4b23ebdc8d18d2745223b6ceaf9e9a94c.tar.gz
rpm-eb0436b4b23ebdc8d18d2745223b6ceaf9e9a94c.tar.bz2
rpm-eb0436b4b23ebdc8d18d2745223b6ceaf9e9a94c.zip
Start abstracting compressed I/O.
CVS patchset: 2552 CVS date: 1998/11/22 19:48:48
Diffstat (limited to 'rpm2cpio.c')
-rw-r--r--rpm2cpio.c35
1 files changed, 18 insertions, 17 deletions
diff --git a/rpm2cpio.c b/rpm2cpio.c
index f4b359298..4f444c473 100644
--- a/rpm2cpio.c
+++ b/rpm2cpio.c
@@ -20,7 +20,7 @@ int main(int argc, char **argv)
int rc, isSource;
char buffer[1024];
int ct;
- gzFile stream;
+ FD_t gzdi;
if (argc == 1) {
fdi = fdDup(STDIN_FILENO);
@@ -35,32 +35,33 @@ int main(int argc, char **argv)
fdo = fdDup(STDOUT_FILENO);
rc = rpmReadPackageHeader(fdi, &hd, &isSource, NULL, NULL);
- if (rc == 1) {
+ switch (rc) {
+ case 0:
+ break;
+ case 1:
fprintf(stderr, _("argument is not an RPM package\n"));
exit(EXIT_FAILURE);
- } else if (rc) {
+ break;
+ default:
fprintf(stderr, _("error reading header from package\n"));
exit(EXIT_FAILURE);
+ break;
}
- stream = gzdopen(fdFileno(fdi), "r");
+ gzdi = gzdFdopen(fdi, "r"); /* XXX gzdi == fdi */
- while ((ct = gzread(stream, &buffer, 1024)) > 0) {
+ while ((ct = gzdRead(gzdi, &buffer, sizeof(buffer))) > 0) {
fdWrite(fdo, &buffer, ct);
}
- if (ct < 0){
- int zerror;
-
- gzerror (stream, &zerror);
- if (zerror == Z_ERRNO){
- perror ("While uncompressing");
- gzclose(stream);
- return 1;
- }
- fprintf (stderr, "rpm2cpio: zlib: %s error\n", zlib_err [-zerror - 1]);
+
+ if (ct < 0) {
+ fprintf (stderr, "rpm2cpio: zlib: %s\n", gzdStrerror(gzdi));
+ rc = EXIT_FAILURE;
+ } else {
+ rc = EXIT_SUCCESS;
}
- gzclose(stream);
+ gzdClose(gzdi);
- return 0;
+ return rc;
}