summaryrefslogtreecommitdiff
path: root/build/parsePreamble.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 /build/parsePreamble.c
parent471ba3b2386a15b5cd0ad202238dd38161788416 (diff)
downloadlibrpm-tizen-4e62a322a266e9d95007540d10e67fc75bf80aa7.tar.gz
librpm-tizen-4e62a322a266e9d95007540d10e67fc75bf80aa7.tar.bz2
librpm-tizen-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 'build/parsePreamble.c')
-rw-r--r--build/parsePreamble.c29
1 files changed, 21 insertions, 8 deletions
diff --git a/build/parsePreamble.c b/build/parsePreamble.c
index ec9486620..d4ed8e51d 100644
--- a/build/parsePreamble.c
+++ b/build/parsePreamble.c
@@ -229,22 +229,24 @@ static int readIcon(Header h, const char *file)
{
const char *fn = NULL;
char *icon;
+#ifdef DYING
struct stat statbuf;
+#endif
FD_t fd;
int rc = 0;
- int nb;
+ off_t size;
+ size_t nb, iconsize;
/* XXX use rpmGenPath(rootdir, "%{_sourcedir}/", file) for icon path. */
fn = rpmGetPath("%{_sourcedir}/", file, NULL);
+#ifdef DYING
if (Stat(fn, &statbuf)) {
rpmError(RPMERR_BADSPEC, _("Unable to stat icon: %s"), fn);
rc = RPMERR_BADSPEC;
goto exit;
}
-
- icon = xmalloc(statbuf.st_size);
- *icon = '\0';
+#endif
fd = Fopen(fn, "r.ufdio");
if (fd == NULL || Ferror(fd)) {
@@ -253,8 +255,19 @@ static int readIcon(Header h, const char *file)
rc = RPMERR_BADSPEC;
goto exit;
}
- nb = Fread(icon, sizeof(char), statbuf.st_size, fd);
- if (nb != statbuf.st_size) {
+ size = fdSize(fd);
+ iconsize = (size >= 0 ? size : (8 * BUFSIZ));
+ if (iconsize == 0) {
+ Fclose(fd);
+ rc = 0;
+ goto exit;
+ }
+
+ icon = xmalloc(iconsize + 1);
+ *icon = '\0';
+
+ nb = Fread(icon, sizeof(char), iconsize, fd);
+ if (Ferror(fd) || (size >= 0 && nb != size)) {
rpmError(RPMERR_BADSPEC, _("Unable to read icon %s: %s"),
fn, Fstrerror(fd));
rc = RPMERR_BADSPEC;
@@ -264,9 +277,9 @@ static int readIcon(Header h, const char *file)
goto exit;
if (! strncmp(icon, "GIF", sizeof("GIF")-1)) {
- headerAddEntry(h, RPMTAG_GIF, RPM_BIN_TYPE, icon, statbuf.st_size);
+ headerAddEntry(h, RPMTAG_GIF, RPM_BIN_TYPE, icon, iconsize);
} else if (! strncmp(icon, "/* XPM", sizeof("/* XPM")-1)) {
- headerAddEntry(h, RPMTAG_XPM, RPM_BIN_TYPE, icon, statbuf.st_size);
+ headerAddEntry(h, RPMTAG_XPM, RPM_BIN_TYPE, icon, iconsize);
} else {
rpmError(RPMERR_BADSPEC, _("Unknown icon type: %s"), file);
rc = RPMERR_BADSPEC;