]> git.pld-linux.org Git - packages/links2.git/blame - links2-gzip_fallback.patch
- updated for 2.1pre15pre2
[packages/links2.git] / links2-gzip_fallback.patch
CommitLineData
2486fcc9 1--- links-0.97/configure.in Mon May 6 01:07:42 2002
2+++ links-0.97/configure.in.new Wed Jul 3 10:43:47 2002
3@@ -138,6 +138,9 @@
4 fi
5 AC_MSG_RESULT($cf_result)
6
7+AC_CHECK_HEADERS(zlib.h)
8+AC_CHECK_LIB(z, gzdopen)
9+
10 AC_CHECK_LIB(dl, dlopen)
11 #ifdef HAVE_SSL
12 AC_ARG_WITH(ssl, [ --without-ssl disable SSL support], [if test "$withval" = no; then disable_ssl=yes; fi])
13--- links-0.97/file.c Wed Jan 30 14:53:48 2002
14+++ links-0.97/file.c.new Wed Jul 3 10:44:03 2002
15@@ -203,9 +203,14 @@
16 if (!(name = get_filename(c->url))) {
17 setcstate(c, S_OUT_OF_MEM); abort_connection(c); return;
18 }
19+opening:
20 if ((h = open(name, O_RDONLY | O_NOCTTY)) == -1) {
21 int er = errno;
22 if ((d = opendir(name))) goto dir;
23+ if (strncmp(name + strlen(name) - 3, ".gz", 3) != 0) {
24+ add_to_strn(&name, ".gz");
25+ goto opening;
26+ }
27 mem_free(name);
28 setcstate(c, -er); abort_connection(c); return;
29 }
77333e22 30@@ -339,21 +344,52 @@
2486fcc9 31 close(h);
32 setcstate(c, S_FILE_TYPE); abort_connection(c); return;
33 } else {
34- mem_free(name);
35+#ifdef HAVE_ZLIB_H
36+ if (strncmp(name + strlen(name) - 3, ".gz", 3) == 0) {
37+ /* decompression */
38+ gzFile gh = gzdopen(h, "r");
39+ fl = 0;
40+ mem_free(name);
41+ if (!gh) {
42+ close(h);
43+ setcstate(c, S_OUT_OF_MEM); abort_connection(c); return;
44+ }
45+ if (!(file = mem_alloc(stt.st_size + 1))) {
46+ gzclose(gh);
47+ setcstate(c, S_OUT_OF_MEM); abort_connection(c); return;
48+ }
49+ while ((r = gzread(gh, file+fl, stt.st_size)) > 0) {
50+ fl += r;
51+ file = mem_realloc(file, fl + stt.st_size);
52+ if (!file) {
53+ gzclose(gh);
54+ setcstate(c, S_OUT_OF_MEM);
55+ abort_connection(c);
56+ return;
57+ }
58+ }
59+ gzclose(gh);
60+ head = stracpy("");
61+ }
62+ else
63+#endif
64+ {
77333e22 65+ mem_free(name);
2486fcc9 66 /* + 1 is there because of bug in Linux. Read returns -EACCES when
67 reading 0 bytes to invalid address */
68- if (!(file = mem_alloc(stt.st_size + 1))) {
69+ if (!(file = mem_alloc(stt.st_size + 1))) {
70+ close(h);
71+ setcstate(c, S_OUT_OF_MEM); abort_connection(c); return;
72+ }
73+ if ((r = read(h, file, stt.st_size)) != stt.st_size) {
74+ mem_free(file); close(h);
75+ setcstate(c, r == -1 ? -errno : S_FILE_ERROR);
76+ abort_connection(c); return;
77+ }
78 close(h);
79- setcstate(c, S_OUT_OF_MEM); abort_connection(c); return;
80- }
81- if ((r = read(h, file, stt.st_size)) != stt.st_size) {
82- mem_free(file); close(h);
83- setcstate(c, r == -1 ? -errno : S_FILE_ERROR);
84- abort_connection(c); return;
85+ fl = stt.st_size;
86+ head = stracpy("");
87 }
88- close(h);
89- fl = stt.st_size;
90- head = stracpy("");
91 }
92 if (get_cache_entry(c->url, &e)) {
93 mem_free(file);
94--- links-0.97/links.h Wed Jul 3 10:36:17 2002
95+++ links-0.97/links.h.new Wed Jul 3 10:44:18 2002
96@@ -97,6 +97,10 @@
97 #include <openssl/ssl.h>
98 #endif
99
100+#ifdef HAVE_ZLIB_H
101+#include <zlib.h>
102+#endif
103+
104 #include "os_depx.h"
105
106 #include "setup.h"
This page took 0.033883 seconds and 4 git commands to generate.