wok-next annotate module-init-tools/stuff/lzlib.u @ rev 5042

Up: lvm2; split libdevmapper from lvm2 now
author Rohit Joshi <jozee@slitaz.org>
date Thu Mar 04 10:43:49 2010 +0000 (2010-03-04)
parents f0a84dc0a7c2
children d2d594c8804d
rev   line source
rcx@3742 1 --- module-init-tools-3.10/zlibsupport.c
rcx@3742 2 +++ module-init-tools-3.10/zlibsupport.c
pascal@3320 3 @@ -18,60 +18,40 @@
pascal@897 4 #include "testing.h"
pascal@897 5
pascal@897 6 #ifdef CONFIG_USE_ZLIB
pascal@897 7 -#include <zlib.h>
pascal@3320 8 -
pascal@897 9 -void *grab_contents(gzFile *gzfd, unsigned long *size)
pascal@897 10 -{
pascal@897 11 - unsigned int max = 16384;
pascal@3320 12 - void *buffer = NOFAIL(malloc(max));
pascal@897 13 - int ret;
pascal@897 14 -
pascal@897 15 - *size = 0;
pascal@897 16 - while ((ret = gzread(gzfd, buffer + *size, max - *size)) > 0) {
pascal@897 17 - *size += ret;
pascal@3320 18 - if (*size == max)
pascal@3320 19 - buffer = NOFAIL(realloc(buffer, max *= 2));
pascal@897 20 - }
pascal@897 21 - if (ret < 0) {
pascal@897 22 - free(buffer);
pascal@897 23 - buffer = NULL;
pascal@897 24 - }
pascal@3320 25 -
pascal@897 26 - return buffer;
pascal@897 27 -}
pascal@3320 28 +#include <lzlib.h>
pascal@3320 29
pascal@897 30 void *grab_fd(int fd, unsigned long *size)
pascal@897 31 {
pascal@897 32 - gzFile gzfd;
pascal@897 33 + lzFile lzfd;
pascal@897 34
pascal@897 35 - gzfd = gzdopen(fd, "rb");
pascal@3320 36 - if (!gzfd) {
pascal@897 37 + lzfd = lzdopen(fd, "rb");
pascal@3320 38 + if (!lzfd) {
pascal@3320 39 if (errno == ENOMEM)
pascal@3320 40 fatal("Memory allocation failure in gzdopen\n");
pascal@897 41 return NULL;
pascal@3320 42 }
pascal@897 43
pascal@897 44 - /* gzclose(gzfd) would close fd, which would drop locks.
pascal@897 45 + /* lzclose(lzfd) would close fd, which would drop locks.
pascal@897 46 Don't blame zlib: POSIX locking semantics are so horribly
pascal@897 47 broken that they should be ripped out. */
pascal@897 48 - return grab_contents(gzfd, size);
pascal@897 49 + return lzgrab(lzfd, size);
pascal@897 50 }
pascal@897 51
pascal@897 52 /* gzopen handles uncompressed files transparently. */
pascal@897 53 void *grab_file(const char *filename, unsigned long *size)
pascal@897 54 {
pascal@897 55 - gzFile gzfd;
pascal@897 56 + lzFile lzfd;
pascal@897 57 void *buffer;
pascal@897 58
pascal@3320 59 errno = 0;
pascal@897 60 - gzfd = gzopen(filename, "rb");
pascal@3320 61 - if (!gzfd) {
pascal@897 62 + lzfd = lzopen(filename, "rb");
pascal@3320 63 + if (!lzfd) {
pascal@3320 64 if (errno == ENOMEM)
pascal@3320 65 fatal("Memory allocation failure in gzopen\n");
pascal@897 66 return NULL;
pascal@3320 67 }
pascal@897 68 - buffer = grab_contents(gzfd, size);
pascal@897 69 - gzclose(gzfd);
pascal@897 70 + buffer = lzgrab(lzfd, size);
pascal@897 71 + lzclose(lzfd);
pascal@897 72 return buffer;
pascal@897 73 }
pascal@897 74
pascal@3320 75
pascal@3320 76 --- module-init-tools-3.9/configure
pascal@3320 77 +++ module-init-tools-3.9/configure
pascal@3320 78 @@ -2590,7 +2590,7 @@
pascal@897 79 #define CONFIG_USE_ZLIB 1
pascal@897 80 _ACEOF
pascal@897 81
pascal@897 82 - zlib_flags="-Wl,-Bstatic -lz -Wl,-Bdynamic"
pascal@897 83 + zlib_flags="-Wl,-Bdynamic -lz -llz"
pascal@897 84 fi
pascal@3320 85 fi
pascal@897 86
pascal@3320 87 @@ -2602,7 +2602,7 @@
pascal@3320 88 #define CONFIG_USE_ZLIB 1
pascal@3320 89 _ACEOF
pascal@3320 90
pascal@3320 91 - zlib_flags="-lz"
pascal@3320 92 + zlib_flags="-lz -llz"
pascal@3320 93 fi
pascal@3320 94 fi
pascal@3320 95