~ubuntu-branches/ubuntu/edgy/curl/edgy

« back to all changes in this revision

Viewing changes to lib/parsedate.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2005-07-26 19:03:01 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20050726190301-x2m2vmjgc8fwnic5
Tags: 7.14.0-2ubuntu1
Synchronize with Debian.

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 *                            | (__| |_| |  _ <| |___
6
6
 *                             \___|\___/|_| \_\_____|
7
7
 *
8
 
 * Copyright (C) 1998 - 2004, Daniel Stenberg, <daniel@haxx.se>, et al.
 
8
 * Copyright (C) 1998 - 2005, Daniel Stenberg, <daniel@haxx.se>, et al.
9
9
 *
10
10
 * This software is licensed as described in the file COPYING, which
11
11
 * you should have received as part of this distribution. The terms
18
18
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19
19
 * KIND, either express or implied.
20
20
 *
21
 
 * $Id: parsedate.c,v 1.11 2004/11/29 08:10:10 bagder Exp $
 
21
 * $Id: parsedate.c,v 1.16 2005/04/26 13:08:49 bagder Exp $
22
22
 ***************************************************************************/
23
23
/*
24
24
  A brief summary of the date string formats this parser groks:
86
86
 
87
87
static time_t Curl_parsedate(const char *date);
88
88
 
89
 
static const char *wkday[] = {"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"};
90
 
static const char *weekday[] = { "Monday", "Tuesday", "Wednesday", "Thursday",
91
 
                                 "Friday", "Saturday", "Sunday" };
92
 
static const char *month[]= { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul",
93
 
                              "Aug", "Sep", "Oct", "Nov", "Dec" };
 
89
const char * const Curl_wkday[] =
 
90
{"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"};
 
91
static const char * const weekday[] =
 
92
{ "Monday", "Tuesday", "Wednesday", "Thursday",
 
93
  "Friday", "Saturday", "Sunday" };
 
94
const char * const Curl_month[]=
 
95
{ "Jan", "Feb", "Mar", "Apr", "May", "Jun",
 
96
  "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
94
97
 
95
98
struct tzinfo {
96
99
  const char *name;
153
156
static int checkday(char *check, size_t len)
154
157
{
155
158
  int i;
156
 
  const char **what;
 
159
  const char * const *what;
157
160
  bool found= FALSE;
158
161
  if(len > 3)
159
162
    what = &weekday[0];
160
163
  else
161
 
    what = &wkday[0];
 
164
    what = &Curl_wkday[0];
162
165
  for(i=0; i<7; i++) {
163
166
    if(curl_strequal(check, what[0])) {
164
167
      found=TRUE;
172
175
static int checkmonth(char *check)
173
176
{
174
177
  int i;
175
 
  const char **what;
 
178
  const char * const *what;
176
179
  bool found= FALSE;
177
180
 
178
 
  what = &month[0];
 
181
  what = &Curl_month[0];
179
182
  for(i=0; i<12; i++) {
180
183
    if(curl_strequal(check, what[0])) {
181
184
      found=TRUE;
366
369
  tm.tm_yday = 0;
367
370
  tm.tm_isdst = 0;
368
371
 
 
372
  /* mktime() returns a time_t. time_t is often 32 bits, even on many
 
373
     architectures that feature 64 bit 'long'.
 
374
 
 
375
     Some systems have 64 bit time_t and deal with years beyond 2038. However,
 
376
     even some of the systems with 64 bit time_t returns -1 for dates beyond
 
377
     03:14:07 UTC, January 19, 2038. (Such as AIX 5100-06)
 
378
  */
369
379
  t = mktime(&tm);
370
380
 
371
381
  /* time zone adjust */
372
 
  {
 
382
  if(-1 != t) {
373
383
    struct tm *gmt;
374
384
    long delta;
375
385
    time_t t2;
388
398
 
389
399
    /* Add the time zone diff (between the given timezone and GMT) and the
390
400
       diff between the local time zone and GMT. */
391
 
    delta = (tzoff!=-1?tzoff:0) + (t - t2);
 
401
    delta = (long)((tzoff!=-1?tzoff:0) + (t - t2));
392
402
 
393
403
    if((delta>0) && (t + delta < t))
394
404
      return -1; /* time_t overflow */