wok-4.x annotate module-init-tools/stuff/lzlib.u @ rev 1245

perdition: describe known bugs
author Pascal Bellard <pascal.bellard@slitaz.org>
date Tue Aug 12 07:24:16 2008 +0000 (2008-08-12)
parents
children f0a84dc0a7c2
rev   line source
pascal@897 1 --- module-init-tools-3.2/zlibsupport.c
pascal@897 2 +++ module-init-tools-3.2/zlibsupport.c
pascal@897 3 @@ -16,58 +16,33 @@
pascal@897 4 #include "testing.h"
pascal@897 5
pascal@897 6 #ifdef CONFIG_USE_ZLIB
pascal@897 7 -#include <zlib.h>
pascal@897 8 +#include <lzlib.h>
pascal@897 9
pascal@897 10 -void *grab_contents(gzFile *gzfd, unsigned long *size)
pascal@897 11 -{
pascal@897 12 - unsigned int max = 16384;
pascal@897 13 - void *buffer = malloc(max);
pascal@897 14 - int ret;
pascal@897 15 -
pascal@897 16 - if (!buffer)
pascal@897 17 - return NULL;
pascal@897 18 -
pascal@897 19 - *size = 0;
pascal@897 20 - while ((ret = gzread(gzfd, buffer + *size, max - *size)) > 0) {
pascal@897 21 - *size += ret;
pascal@897 22 - if (*size == max) {
pascal@897 23 - buffer = realloc(buffer, max *= 2);
pascal@897 24 - if (!buffer)
pascal@897 25 - return NULL;
pascal@897 26 - }
pascal@897 27 - }
pascal@897 28 - if (ret < 0) {
pascal@897 29 - free(buffer);
pascal@897 30 - buffer = NULL;
pascal@897 31 - }
pascal@897 32 - return buffer;
pascal@897 33 -}
pascal@897 34 -
pascal@897 35 void *grab_fd(int fd, unsigned long *size)
pascal@897 36 {
pascal@897 37 - gzFile gzfd;
pascal@897 38 + lzFile lzfd;
pascal@897 39
pascal@897 40 - gzfd = gzdopen(fd, "rb");
pascal@897 41 - if (!gzfd)
pascal@897 42 + lzfd = lzdopen(fd, "rb");
pascal@897 43 + if (!lzfd)
pascal@897 44 return NULL;
pascal@897 45
pascal@897 46 - /* gzclose(gzfd) would close fd, which would drop locks.
pascal@897 47 + /* lzclose(lzfd) would close fd, which would drop locks.
pascal@897 48 Don't blame zlib: POSIX locking semantics are so horribly
pascal@897 49 broken that they should be ripped out. */
pascal@897 50 - return grab_contents(gzfd, size);
pascal@897 51 + return lzgrab(lzfd, size);
pascal@897 52 }
pascal@897 53
pascal@897 54 /* gzopen handles uncompressed files transparently. */
pascal@897 55 void *grab_file(const char *filename, unsigned long *size)
pascal@897 56 {
pascal@897 57 - gzFile gzfd;
pascal@897 58 + lzFile lzfd;
pascal@897 59 void *buffer;
pascal@897 60
pascal@897 61 - gzfd = gzopen(filename, "rb");
pascal@897 62 - if (!gzfd)
pascal@897 63 + lzfd = lzopen(filename, "rb");
pascal@897 64 + if (!lzfd)
pascal@897 65 return NULL;
pascal@897 66 - buffer = grab_contents(gzfd, size);
pascal@897 67 - gzclose(gzfd);
pascal@897 68 + buffer = lzgrab(lzfd, size);
pascal@897 69 + lzclose(lzfd);
pascal@897 70 return buffer;
pascal@897 71 }
pascal@897 72
pascal@897 73 --- module-init-tools-3.2/configure
pascal@897 74 +++ module-init-tools-3.2/configure
pascal@897 75 @@ -1741,7 +1741,7 @@
pascal@897 76 #define CONFIG_USE_ZLIB 1
pascal@897 77 _ACEOF
pascal@897 78
pascal@897 79 - zlib_flags="-Wl,-Bstatic -lz -Wl,-Bdynamic"
pascal@897 80 + zlib_flags="-Wl,-Bdynamic -lz -llz"
pascal@897 81 fi
pascal@897 82 fi;
pascal@897 83