summaryrefslogtreecommitdiff
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
parenta15a36abd12dba7dcf5cab390100dfcbc16dd6b8 (diff)
downloadlibrpm-tizen-eb0436b4b23ebdc8d18d2745223b6ceaf9e9a94c.tar.gz
librpm-tizen-eb0436b4b23ebdc8d18d2745223b6ceaf9e9a94c.tar.bz2
librpm-tizen-eb0436b4b23ebdc8d18d2745223b6ceaf9e9a94c.zip
Start abstracting compressed I/O.
CVS patchset: 2552 CVS date: 1998/11/22 19:48:48
-rw-r--r--Makefile.am12
-rw-r--r--Makefile.in13
-rw-r--r--Makefile.inc.in2
-rw-r--r--acconfig.h3
-rw-r--r--build/Makefile.in1
-rw-r--r--build/pack.c4
-rw-r--r--configure.in14
-rw-r--r--lib/Makefile.in1
-rw-r--r--lib/cpio.c4
-rw-r--r--lib/cpio.h2
-rw-r--r--lib/header.c20
-rw-r--r--lib/header.h4
-rw-r--r--lib/install.c4
-rw-r--r--lib/rpmio.h179
-rw-r--r--misc/Makefile.in1
-rw-r--r--po/rpm.pot6
-rw-r--r--rpm.spec2
-rw-r--r--rpm2cpio.c35
-rw-r--r--scripts/Makefile.in1
-rw-r--r--tests/Makefile.in1
-rw-r--r--tests/hello-test/Makefile.in1
-rw-r--r--tools/Makefile.in1
22 files changed, 255 insertions, 56 deletions
diff --git a/Makefile.am b/Makefile.am
index 54155e3a0..20faa8776 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -30,12 +30,12 @@ rpm_SOURCES = build.c checksig.c ftp.c install.c rpm.c url.c \
verify.c
rpm_LDADD = -lrpmbuild -lpopt -lrpm @LIBMISC@
-rpm.o: rpm.c
- $(COMPILE) \
- -DLOCALEDIR=\"$(LOCALEDIR)\" \
- -DLIBRPMALIAS_FILENAME=\"$(LIBRPMALIAS_FILENAME)\" \
- -DRPMCONFIGDIR="\"$(RPMCONFIGDIR)"\" \
- -c $<
+#rpm.o: rpm.c
+# $(COMPILE) \
+# -DLOCALEDIR=\"$(LOCALEDIR)\" \
+# -DLIBRPMALIAS_FILENAME=\"$(LIBRPMALIAS_FILENAME)\" \
+# -DRPMCONFIGDIR="\"$(RPMCONFIGDIR)"\" \
+# -c $<
include ./Makefile.inc
diff --git a/Makefile.in b/Makefile.in
index 067658ba7..1b38bca14 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -92,6 +92,7 @@ LIBRPMALIAS_FILENAME = @LIBRPMALIAS_FILENAME@
LIBRPMRC_FILENAME = @LIBRPMRC_FILENAME@
LIBS = @LIBS@
LN_S = @LN_S@
+LOCALEDIR = @LOCALEDIR@
MACROFILES = @MACROFILES@
MAKEINFO = @MAKEINFO@
MISCDIR = @MISCDIR@
@@ -682,12 +683,12 @@ clean-generic maintainer-clean-generic clean mostlyclean distclean \
maintainer-clean
-rpm.o: rpm.c
- $(COMPILE) \
- -DLOCALEDIR=\"$(LOCALEDIR)\" \
- -DLIBRPMALIAS_FILENAME=\"$(LIBRPMALIAS_FILENAME)\" \
- -DRPMCONFIGDIR="\"$(RPMCONFIGDIR)"\" \
- -c $<
+#rpm.o: rpm.c
+# $(COMPILE) \
+# -DLOCALEDIR=\"$(LOCALEDIR)\" \
+# -DLIBRPMALIAS_FILENAME=\"$(LIBRPMALIAS_FILENAME)\" \
+# -DRPMCONFIGDIR="\"$(RPMCONFIGDIR)"\" \
+# -c $<
include ./Makefile.inc
diff --git a/Makefile.inc.in b/Makefile.inc.in
index 5043c838b..8901abf48 100644
--- a/Makefile.inc.in
+++ b/Makefile.inc.in
@@ -14,7 +14,7 @@ LIBRPMRC_FILENAME=$(RPMCONFIGDIR)/rpmrc
LIBRPMALIAS_FILENAME=$(RPMCONFIGDIR)/rpmpopt
MACROFILES=$(RPMCONFIGDIR)/macros
-LOCALEDIR=@datadir@/locale
+LOCALEDIR=@LOCALEDIR@
PACKAGE = @PACKAGE@
VERSION = @VERSION@
diff --git a/acconfig.h b/acconfig.h
index 74182e034..a2f04604a 100644
--- a/acconfig.h
+++ b/acconfig.h
@@ -90,6 +90,9 @@
/* Define this to be whatever root's primary group is, in double quotes */
#undef ROOT_GROUP
+/* Full path to rpm locale directory (usually /usr/share/locale) */
+#undef LOCALEDIR
+
/* Full path to rpm configuration directory (usually /usr/lib/rpm) */
#undef RPMCONFIGDIR
diff --git a/build/Makefile.in b/build/Makefile.in
index f46a9c9fc..1d1396c28 100644
--- a/build/Makefile.in
+++ b/build/Makefile.in
@@ -92,6 +92,7 @@ LIBRPMALIAS_FILENAME = @LIBRPMALIAS_FILENAME@
LIBRPMRC_FILENAME = @LIBRPMRC_FILENAME@
LIBS = @LIBS@
LN_S = @LN_S@
+LOCALEDIR = @LOCALEDIR@
MACROFILES = @MACROFILES@
MAKEINFO = @MAKEINFO@
MISCDIR = @MISCDIR@
diff --git a/build/pack.c b/build/pack.c
index 986456791..40f747c85 100644
--- a/build/pack.c
+++ b/build/pack.c
@@ -394,10 +394,10 @@ static int cpio_gzip(FD_t fdo, CSA_t *csa) {
char *failedFile;
cfd->cpioIoType = cpioIoTypeGzFd;
- cfd->cpioGzFd = gzdopen(dup(fdFileno(fdo)), "w9");
+ cfd->cpioGzFd = gzdFdopen(fdDup(fdFileno(fdo)), "w9");
rc = cpioBuildArchive(cfd, csa->cpioList, csa->cpioCount, NULL, NULL,
&csa->cpioArchiveSize, &failedFile);
- gzclose(cfd->cpioGzFd);
+ gzdClose(cfd->cpioGzFd);
if (rc) {
if (rc & CPIO_CHECK_ERRNO)
diff --git a/configure.in b/configure.in
index e463bd10e..222e31f91 100644
--- a/configure.in
+++ b/configure.in
@@ -320,6 +320,16 @@ for zlib in z gz ; do
)
done
+BZ2LIB=
+for bz2lib in bz2 ; do
+ AC_CHECK_LIB(${bz2lib}, bzread,
+ [LIBS="$LIBS -l${bz2lib}"; break],
+ [if test ${bz2lib} = bz2; then
+ AC_MSG_WARN([missing libbz2.a (from the bzip2 package)])
+ fi]
+ )
+done
+
dnl XXX these are needed only by rpmgettext right now
AM_FUNC_ERROR_AT_LINE
@@ -344,6 +354,7 @@ AC_CHECK_HEADERS(netinet/in_systm.h)
AC_CHECK_HEADERS(machine/types.h)
AC_CHECK_HEADERS(mntent.h sys/mnttab.h sys/systemcfg.h)
AC_CHECK_HEADERS(sys/mount.h sys/mntctl.h sys/vmount.h)
+AC_CHECK_HEADERS(bzlib.h libio.h zlib.h)
AC_C_BIGENDIAN
AC_C_INLINE
@@ -583,6 +594,9 @@ if test -n "$LIBOBJS" ; then
MISCPATH=misc/libmisc.a
fi
+LOCALEDIR="`echo ${prefix}/share/locale`"
+AC_DEFINE_UNQUOTED(LOCALEDIR, "$LOCALEDIR")
+AC_SUBST(LOCALEDIR)
RPMCONFIGDIR="`echo ${prefix}/lib/rpm`"
AC_DEFINE_UNQUOTED(RPMCONFIGDIR, "$RPMCONFIGDIR")
AC_SUBST(RPMCONFIGDIR)
diff --git a/lib/Makefile.in b/lib/Makefile.in
index 2ce9c9943..b142ae896 100644
--- a/lib/Makefile.in
+++ b/lib/Makefile.in
@@ -92,6 +92,7 @@ LIBRPMALIAS_FILENAME = @LIBRPMALIAS_FILENAME@
LIBRPMRC_FILENAME = @LIBRPMRC_FILENAME@
LIBS = @LIBS@
LN_S = @LN_S@
+LOCALEDIR = @LOCALEDIR@
MACROFILES = @MACROFILES@
MAKEINFO = @MAKEINFO@
MISCDIR = @MISCDIR@
diff --git a/lib/cpio.c b/lib/cpio.c
index d808aa346..1f8f835b9 100644
--- a/lib/cpio.c
+++ b/lib/cpio.c
@@ -77,7 +77,7 @@ static inline off_t saferead(CFD_t *cfd, void * vbuf, size_t amount) {
nb *= amount;
break;
case cpioIoTypeGzFd:
- nb = gzread(cfd->cpioGzFd, buf, amount);
+ nb = gzdRead(cfd->cpioGzFd, buf, amount);
break;
}
if (nb <= 0)
@@ -132,7 +132,7 @@ static inline off_t safewrite(CFD_t *cfd, void * vbuf, size_t amount) {
nb *= amount;
break;
case cpioIoTypeGzFd:
- nb = gzwrite(cfd->cpioGzFd, buf, amount);
+ nb = gzdWrite(cfd->cpioGzFd, buf, amount);
break;
}
if (nb <= 0)
diff --git a/lib/cpio.h b/lib/cpio.h
index 558d09811..c5dd963be 100644
--- a/lib/cpio.h
+++ b/lib/cpio.h
@@ -60,7 +60,7 @@ typedef struct CFD {
#define cpioFd _cfdu._cfdu_fd
FILE * _cfdu_fp;
#define cpioFp _cfdu._cfdu_fp
- gzFile _cfdu_gzfd;
+ FD_t _cfdu_gzfd;
#define cpioGzFd _cfdu._cfdu_gzfd
} _cfdu;
int cpioPos;
diff --git a/lib/header.c b/lib/header.c
index 914a39819..dc4d320df 100644
--- a/lib/header.c
+++ b/lib/header.c
@@ -320,7 +320,7 @@ Header headerRead(FD_t fd, int magicp)
return h;
}
-void headerGzWrite(gzFile fd, Header h, int magicp)
+void headerGzWrite(FD_t fd, Header h, int magicp)
{
void * p;
int length;
@@ -329,17 +329,17 @@ void headerGzWrite(gzFile fd, Header h, int magicp)
p = doHeaderUnload(h, &length);
if (magicp) {
- gzwrite(fd, header_magic, sizeof(header_magic));
+ gzdWrite(fd, header_magic, sizeof(header_magic));
l = htonl(0);
- gzwrite(fd, &l, sizeof(l));
+ gzdWrite(fd, &l, sizeof(l));
}
- gzwrite(fd, p, length);
+ gzdWrite(fd, p, length);
free(p);
}
-Header headerGzRead(gzFile fd, int magicp)
+Header headerGzRead(FD_t fd, int magicp)
{
int_32 reserved;
int_32 * p;
@@ -350,24 +350,24 @@ Header headerGzRead(gzFile fd, int magicp)
int totalSize;
if (magicp == HEADER_MAGIC_YES) {
- if (gzread(fd, &magic, sizeof(magic)) != sizeof(magic))
+ if (gzdRead(fd, &magic, sizeof(magic)) != sizeof(magic))
return NULL;
if (memcmp(&magic, header_magic, sizeof(magic))) {
return NULL;
}
- if (gzread(fd, &reserved, sizeof(reserved)) != sizeof(reserved))
+ if (gzdRead(fd, &reserved, sizeof(reserved)) != sizeof(reserved))
return NULL;
}
/* First read the index length (count of index entries) */
- if (gzread(fd, &il, sizeof(il)) != sizeof(il))
+ if (gzdRead(fd, &il, sizeof(il)) != sizeof(il))
return NULL;
il = ntohl(il);
/* Then read the data length (number of bytes) */
- if (gzread(fd, &dl, sizeof(dl)) != sizeof(dl))
+ if (gzdRead(fd, &dl, sizeof(dl)) != sizeof(dl))
return NULL;
dl = ntohl(dl);
@@ -380,7 +380,7 @@ Header headerGzRead(gzFile fd, int magicp)
*p++ = htonl(dl);
totalSize -= sizeof(int_32) + sizeof(int_32);
- if (gzread(fd, p, totalSize) != totalSize)
+ if (gzdRead(fd, p, totalSize) != totalSize)
return NULL;
h = headerLoad(block);
diff --git a/lib/header.h b/lib/header.h
index ee2f5f63c..5c7dd2d28 100644
--- a/lib/header.h
+++ b/lib/header.h
@@ -72,8 +72,8 @@ extern const struct headerSprintfExtension headerDefaultFormats[];
/* read and write a header from a file */
Header headerRead(FD_t fd, int magicp);
void headerWrite(FD_t fd, Header h, int magicp);
-Header headerGzRead(gzFile fd, int magicp);
-void headerGzWrite(gzFile fd, Header h, int magicp);
+Header headerGzRead(FD_t fd, int magicp);
+void headerGzWrite(FD_t fd, Header h, int magicp);
unsigned int headerSizeof(Header h, int magicp);
#define HEADER_MAGIC_NO 0
diff --git a/lib/install.c b/lib/install.c
index 861733bd5..b6f0c8f47 100644
--- a/lib/install.c
+++ b/lib/install.c
@@ -1009,12 +1009,12 @@ static int installArchive(FD_t fd, struct fileInfo * files,
{ CFD_t cfdbuf, *cfd = &cfdbuf;
cfd->cpioIoType = cpioIoTypeGzFd;
- cfd->cpioGzFd = gzdopen(fdFileno(fd), "r");
+ cfd->cpioGzFd = gzdFdopen(fd, "r"); /* XXX cpioGzFd == fd */
rc = cpioInstallArchive(cfd, map, mappedFiles,
((notify && archiveSize) || specFile) ?
callback : NULL,
&info, &failedFile);
- gzclose(cfd->cpioGzFd);
+ gzdClose(cfd->cpioGzFd);
}
if (rc) {
diff --git a/lib/rpmio.h b/lib/rpmio.h
index ebd23495b..bf0324c7c 100644
--- a/lib/rpmio.h
+++ b/lib/rpmio.h
@@ -5,6 +5,9 @@
typedef /*@abstract@*/ struct {
int fd_fd;
+ void * fd_bzd;
+ void * fd_gzd;
+
} *FD_t;
#ifdef __cplusplus
@@ -19,6 +22,8 @@ extern inline /*@null@*/ FD_t fdNew(void) {
if (fd == NULL)
return NULL;
fd->fd_fd = -1;
+ fd->fd_bzd = NULL;
+ fd->fd_gzd = NULL;
return fd;
}
@@ -54,9 +59,9 @@ extern inline /*@null@*/ FD_t fdDup(int fdno) {
return fd;
}
-extern inline ssize_t fdLseek(FD_t fd, off_t off, int op);
-extern inline ssize_t fdLseek(FD_t fd, off_t off, int op) {
- return lseek(fdFileno(fd), off, op);
+extern inline off_t fdLseek(FD_t fd, off_t offset, int whence);
+extern inline off_t fdLseek(FD_t fd, off_t offset, int whence) {
+ return lseek(fdFileno(fd), offset, whence);
}
extern inline ssize_t fdRead(FD_t fd, void * buf, size_t count);
@@ -94,6 +99,174 @@ extern inline /*@shared@*/ FILE *fdFdopen(/*@owned@*/ FD_t fd, const char *mode)
}
/*@=mustfree*/
+/*
+ * Support for GZIP library.
+ */
+#ifdef HAVE_ZLIB_H
+
+#include <zlib.h>
+
+extern inline gzFile * gzdFileno(FD_t fd);
+extern inline gzFile * gzdFileno(FD_t fd) {
+ return (fd != NULL ? ((gzFile *)fd->fd_gzd) : NULL);
+}
+
+extern inline /*@null@*/ FD_t gzdOpen(const char *pathname, const char *mode);
+extern inline /*@null@*/ FD_t gzdOpen(const char *pathname, const char *mode) {
+ FD_t fd;
+ gzFile *gzfile;;
+ if ((gzfile = gzopen(pathname, mode)) == NULL)
+ return NULL;
+ fd = fdNew();
+ fd->fd_gzd = gzfile;
+ return fd;
+}
+
+extern inline /*@shared@*/ FD_t gzdFdopen(FD_t fd, const char *mode);
+extern inline /*@shared@*/ FD_t gzdFdopen(FD_t fd, const char *mode) {
+ gzFile *gzfile = gzdopen(fdFileno(fd), mode);
+ if (gzfile != NULL) {
+ fd->fd_fd = -1;
+ fd->fd_gzd = gzfile;
+ return fd;
+ }
+ return NULL;
+}
+
+extern inline ssize_t gzdRead(FD_t fd, void * buf, size_t count);
+extern inline ssize_t gzdRead(FD_t fd, void * buf, size_t count) {
+ return gzread(gzdFileno(fd), buf, count);
+}
+
+extern inline ssize_t gzdWrite(FD_t fd, const void * buf, size_t count);
+extern inline ssize_t gzdWrite(FD_t fd, const void * buf, size_t count) {
+ return gzwrite(gzdFileno(fd), (void *)buf, count);
+}
+
+extern inline off_t gzdLseek(FD_t fd, off_t offset, int whence);
+extern inline off_t gzdLseek(FD_t fd, off_t offset, int whence) {
+ return gzseek(gzdFileno(fd), offset, whence);
+}
+
+extern inline int gzdFlush(FD_t fd);
+extern inline int gzdFlush(FD_t fd) {
+ return gzflush(gzdFileno(fd), Z_SYNC_FLUSH); /* XXX W2DO? */
+}
+
+extern inline char * gzdStrerror(FD_t fd);
+extern inline char * gzdStrerror(FD_t fd) {
+ static char *zlib_err [] = {
+ "OK"
+ "Errno",
+ "Stream",
+ "Data",
+ "Memory",
+ "Buffer",
+ "Version"
+ };
+
+ int zerror;
+
+ gzerror(gzdFileno(fd), &zerror);
+ switch (zerror) {
+ case Z_ERRNO:
+ return strerror(errno);
+ break;
+ default:
+ break;
+ }
+ return zlib_err[-zerror];
+}
+
+extern inline int gzdClose(/*@only@*/ FD_t fd);
+extern inline int gzdClose(/*@only@*/ FD_t fd) {
+ gzFile *gzfile;
+ int zerror;
+
+ if (fd != NULL && (gzfile = gzdFileno(fd)) != NULL) {
+ fd->fd_fd = -1;
+ fd->fd_bzd = NULL;
+ fd->fd_gzd = NULL;
+ free(fd);
+ zerror = gzclose(gzfile);
+ return 0;
+ }
+ return -2;
+}
+
+#endif /* HAVE_BZLIB_H */
+/*
+ * Support for BZIP2 library.
+ */
+#ifdef HAVE_BZLIB_H
+
+#include <bzlib.h>
+
+extern inline BZFILE * bzdFileno(FD_t fd);
+extern inline BZFILE * bzdFileno(FD_t fd) {
+ return (fd != NULL ? ((BZFILE *)fd->fd_bzd) : NULL);
+}
+
+extern inline /*@null@*/ FD_t bzdOpen(const char *pathname, const char *mode);
+extern inline /*@null@*/ FD_t bzdOpen(const char *pathname, const char *mode) {
+ FD_t fd;
+ BZFILE *bzfile;;
+ if ((bzfile = bzopen(pathname, mode)) == NULL)
+ return NULL;
+ fd = fdNew();
+ fd->fd_bzd = bzfile;
+ return fd;
+}
+
+extern inline /*@shared@*/ FD_t bzdFdopen(FD_t fd, const char *mode);
+extern inline /*@shared@*/ FD_t bzdFdopen(FD_t fd, const char *mode) {
+ BZFILE *bzfile = bzdopen(fdFileno(fd), mode);
+ if (bzfile != NULL) {
+ fd->fd_fd = -1;
+ fd->fd_bzd = bzfile;
+ return fd;
+ }
+ return NULL;
+}
+
+extern inline ssize_t bzdRead(FD_t fd, void * buf, size_t count);
+extern inline ssize_t bzdRead(FD_t fd, void * buf, size_t count) {
+ return bzread(bzdFileno(fd), buf, count);
+}
+
+extern inline ssize_t bzdWrite(FD_t fd, const void * buf, size_t count);
+extern inline ssize_t bzdWrite(FD_t fd, const void * buf, size_t count) {
+ return bzwrite(bzdFileno(fd), (void *)buf, count);
+}
+
+extern inline int bzdFlush(FD_t fd);
+extern inline int bzdFlush(FD_t fd) {
+ return bzflush(bzdFileno(fd));
+}
+
+extern inline char * bzdStrerror(FD_t fd);
+extern inline char * bzdStrerror(FD_t fd) {
+ int bzerr;
+ return (char *)bzerror(bzdFileno(fd), &bzerr);
+}
+
+extern inline int bzdClose(/*@only@*/ FD_t fd);
+extern inline int bzdClose(/*@only@*/ FD_t fd) {
+ BZFILE *bzfile;
+
+ if (fd != NULL && (bzfile = bzdFileno(fd)) != NULL) {
+ fd->fd_fd = -1;
+ fd->fd_bzd = NULL;
+ fd->fd_gzd = NULL;
+ free(fd);
+ bzclose(bzfile);
+ return 0;
+ }
+ return -2;
+}
+
+#endif /* HAVE_BZLIB_H */
+
#ifdef __cplusplus
}
#endif
diff --git a/misc/Makefile.in b/misc/Makefile.in
index ee27310e4..824e91da4 100644
--- a/misc/Makefile.in
+++ b/misc/Makefile.in
@@ -92,6 +92,7 @@ LIBRPMALIAS_FILENAME = @LIBRPMALIAS_FILENAME@
LIBRPMRC_FILENAME = @LIBRPMRC_FILENAME@
LIBS = @LIBS@
LN_S = @LN_S@
+LOCALEDIR = @LOCALEDIR@
MACROFILES = @MACROFILES@
MAKEINFO = @MAKEINFO@
MISCDIR = @MISCDIR@
diff --git a/po/rpm.pot b/po/rpm.pot
index 5dbcbce59..523bf911f 100644
--- a/po/rpm.pot
+++ b/po/rpm.pot
@@ -7,7 +7,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
-"POT-Creation-Date: 1998-11-20 14:56-0500\n"
+"POT-Creation-Date: 1998-11-22 14:35-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -1353,11 +1353,11 @@ msgstr ""
msgid "error looking for package %s\n"
msgstr ""
-#: ../rpm2cpio.c:39
+#: ../rpm2cpio.c:42
msgid "argument is not an RPM package\n"
msgstr ""
-#: ../rpm2cpio.c:42
+#: ../rpm2cpio.c:46
msgid "error reading header from package\n"
msgstr ""
diff --git a/rpm.spec b/rpm.spec
index 10dd58e10..e156b303d 100644
--- a/rpm.spec
+++ b/rpm.spec
@@ -43,7 +43,7 @@ mkdir -p $RPM_BUILD_ROOT/usr/src/redhat/BUILD
mkdir -p $RPM_BUILD_ROOT/usr/src/redhat/RPMS/${RPM_ARCH}
mkdir -p $RPM_BUILD_ROOT/usr/src/redhat/RPMS/noarch
-make installprefix="$RPM_BUILD_ROOT" install
+make DESTDIR="$RPM_BUILD_ROOT" install
%clean
rm -rf $RPM_BUILD_ROOT
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;
}
diff --git a/scripts/Makefile.in b/scripts/Makefile.in
index ae416f418..5d6d1007d 100644
--- a/scripts/Makefile.in
+++ b/scripts/Makefile.in
@@ -92,6 +92,7 @@ LIBRPMALIAS_FILENAME = @LIBRPMALIAS_FILENAME@
LIBRPMRC_FILENAME = @LIBRPMRC_FILENAME@
LIBS = @LIBS@
LN_S = @LN_S@
+LOCALEDIR = @LOCALEDIR@
MACROFILES = @MACROFILES@
MAKEINFO = @MAKEINFO@
MISCDIR = @MISCDIR@
diff --git a/tests/Makefile.in b/tests/Makefile.in
index eeb945561..b7206a9cf 100644
--- a/tests/Makefile.in
+++ b/tests/Makefile.in
@@ -90,6 +90,7 @@ LIBRPMALIAS_FILENAME = @LIBRPMALIAS_FILENAME@
LIBRPMRC_FILENAME = @LIBRPMRC_FILENAME@
LIBS = @LIBS@
LN_S = @LN_S@
+LOCALEDIR = @LOCALEDIR@
MACROFILES = @MACROFILES@
MAKEINFO = @MAKEINFO@
MISCDIR = @MISCDIR@
diff --git a/tests/hello-test/Makefile.in b/tests/hello-test/Makefile.in
index 20db464fe..ba3701094 100644
--- a/tests/hello-test/Makefile.in
+++ b/tests/hello-test/Makefile.in
@@ -90,6 +90,7 @@ LIBRPMALIAS_FILENAME = @LIBRPMALIAS_FILENAME@
LIBRPMRC_FILENAME = @LIBRPMRC_FILENAME@
LIBS = @LIBS@
LN_S = @LN_S@
+LOCALEDIR = @LOCALEDIR@
MACROFILES = @MACROFILES@
MAKEINFO = @MAKEINFO@
MISCDIR = @MISCDIR@
diff --git a/tools/Makefile.in b/tools/Makefile.in
index 010c82666..50603be5b 100644
--- a/tools/Makefile.in
+++ b/tools/Makefile.in
@@ -92,6 +92,7 @@ LIBRPMALIAS_FILENAME = @LIBRPMALIAS_FILENAME@
LIBRPMRC_FILENAME = @LIBRPMRC_FILENAME@
LIBS = @LIBS@
LN_S = @LN_S@
+LOCALEDIR = @LOCALEDIR@
MACROFILES = @MACROFILES@
MAKEINFO = @MAKEINFO@
MISCDIR = @MISCDIR@