1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-11-04 08:17:17 -05:00
elinks/src/protocol
Witold Filipczyk 1544b5f4b9 bug 991: fix crash when the file is already cached
If the user opens the same file again after it is in the cache, then
ELinks does not always open a new connection, so download->conn can be
NULL in init_type_query(), and download->conn->cgi would crash.
Don't read that, then; instead add a new flag cache_entry.cgi, which
http_got_header() sets or clears as soon as possible after the cache
entry has been created.
(cherry picked from commit 81f8ee1fa2)
2008-06-15 13:53:34 +03:00
..
auth Strings corrections from Malcolm Parsons 2008-01-27 04:19:23 +00:00
bittorrent Remove a comment about kill_timer() 2008-06-15 11:41:52 +03:00
file bug 991: Added the bit field cgi to the structs connection and type_query. 2008-06-15 13:07:02 +03:00
finger
fsp Bug 939: Documented the fix. 2008-04-28 11:04:27 +03:00
ftp FTP: Test and fix handling of symbolic link name containing spaces 2008-02-28 23:39:04 +02:00
gopher Trim trailing whitespaces. 2006-07-27 09:51:10 +02:00
http bug 991: fix crash when the file is already cached 2008-06-15 13:53:34 +03:00
nntp NNTP: Improve listing of articles for groups 2007-09-11 17:01:06 +02:00
rewrite Minor fixes and improvements to option strings 2008-03-06 10:31:20 +02:00
smb bug 976: do not use stdout and stderr in a child processing smb:// 2008-03-15 18:09:23 +02:00
test Add tests for cwd-relative file URIs. 2007-09-09 20:06:25 +03:00
about.c about_protocol_handler: Don't define len if CONFIG_SMALL. 2006-12-10 17:16:38 +02:00
about.h
common.c Use add_string_to_string where applicable. 2007-03-18 20:29:08 +02:00
common.h
data.c Cast the NULL argument of straconcat to unsigned char *. 2007-03-11 12:59:11 +02:00
data.h
date.c parse_time: set tm_sec to zero before conditional second parsing 2008-02-28 23:38:42 +02:00
date.h
header.c parse_header_param: better describe behaviour when @ret is NULL 2006-06-23 06:07:22 +00:00
header.h
Makefile Bug 744: Add tests. There are four failures. 2007-07-19 13:46:47 +03:00
protocol.c Bug 744: Make removal of double slashes more protocol specific 2007-09-11 14:14:17 +02:00
protocol.h Bug 744: Make removal of double slashes more protocol specific 2007-09-11 14:14:17 +02:00
proxy.c Cast the NULL argument of string_concat to unsigned char *. 2007-03-11 13:01:50 +02:00
proxy.h Strings corrections from Malcolm Parsons 2008-01-27 04:19:23 +00:00
README.timegm Move README.timegm to the same directory as date.c. 2007-01-13 10:01:51 +02:00
uri.c bug 1000: Do not discard the query part of URI. 2008-03-02 17:45:29 +02:00
uri.h Move is_in_domain from cookies/cookies.c to protocol/uri.c and export 2007-09-14 16:51:04 +02:00
user.c Trim trailing whitespaces. 2007-09-14 15:12:32 +02:00
user.h

This file contains description of our my_timegm() function in date.c. It was
posted as a mail to links-list by Stephane Chazelas, and I thought it may be
interesting for someone, so I decided to include it in the ELinks distribution.




Un explanation for it as one (me to start with) may wonder why
this works.

We first change of calendar. To make things easy, let's say
that 0/0/0 0:0:0 in our new calendar is the Marsh 1st 1968, so
just after a february 29th as 1968 was a leap year.

if y/m/d h:min:s is time in our calendar
and
   Y/M/D h:min:s in the new calendar

M = m - 1 - 2 (+ 12 if m < 3)
Y = y - 68 (-1 if m < 3)
D = d - 1

at Y/0/0 0:0:0, there has been Y / 4 leap years in the past, so
(int) 365 * Y + Y / 4 days have past.

at Y/M/0 0:0:0, lets find how many days have past since Y/0/0:

                   |Mar                                        Feb
                  M| 0   1   2   3   4   5   6   7   8   9  10  11
-------------------+-----------------------------------------------
 days in that month|31  30  31  30  31  31  30  31  30  31  31  28 or 29
-------------------+-----------------------------------------------
  x = days at Y/M/0| 0  31  61  92 122 153 184 214 245 275 306 337
-------------------+-----------------------------------------------
first approximation|
         y = 30 * M| 0  30  60  90 120 150 180 210 240 270 300 330
-------------------+-----------------------------------------------
              x - y| 0   1   1   2   2   3   4   4   5   5   6   7
-------------------+-----------------------------------------------
(M + 4) * 3 / 5 - 2| 0   1   1   2   2   3   4   4   5   5   6   7
-------------------+-----------------------------------------------

x - y = (M + 4) * 3 / 5 - 2

x = 30 * M + (M + 4) * 3 / 5 - 2

x = (153 * M + 2) / 5

So at Y/M/D 0:0:0,

Y * 1461 / 4 + (153 * M + 2) / 5 + D days have past since
the 1st of March of 1968

1st of March of 1968 was 671 days before 1970 Jan 1st (year 0
for unix time())

So
t = s + 60 * (min + 60 * (h + 24 * (Y * 1461 / 4 + (153 * M + 2) / 5 + D - 671)))
t = s + 60 * (min + 60 * (h + 24 * (Y * 1461 / 4 + (153 * M + 2) / 5 + d - 672)))

This shouldn't work past 2100/02/28 23:59:59 as 2100 is not a leap year.

--
St<53>phane