~ubuntu-branches/ubuntu/lucid/curl/lucid-201101212007

« back to all changes in this revision

Viewing changes to lib/parsedate.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2008-02-08 11:20:41 UTC
  • mto: (3.1.1 lenny) (1.2.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 26.
  • Revision ID: james.westby@ubuntu.com-20080208112041-hed7sb5r6ghmjf8v
Tags: upstream-7.18.0
ImportĀ upstreamĀ versionĀ 7.18.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 *                            | (__| |_| |  _ <| |___
6
6
 *                             \___|\___/|_| \_\_____|
7
7
 *
8
 
 * Copyright (C) 1998 - 2006, Daniel Stenberg, <daniel@haxx.se>, et al.
 
8
 * Copyright (C) 1998 - 2008, 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.23 2006-12-05 14:57:43 bagder Exp $
 
21
 * $Id: parsedate.c,v 1.27 2008-01-06 10:50:57 bagder Exp $
22
22
 ***************************************************************************/
23
23
/*
24
24
  A brief summary of the date string formats this parser groks:
84
84
 
85
85
#include <curl/curl.h>
86
86
 
87
 
static time_t Curl_parsedate(const char *date);
 
87
static time_t parsedate(const char *date);
88
88
 
89
89
const char * const Curl_wkday[] =
90
90
{"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"};
154
154
   0 monday - 6 sunday
155
155
*/
156
156
 
157
 
static int checkday(char *check, size_t len)
 
157
static int checkday(const char *check, size_t len)
158
158
{
159
159
  int i;
160
160
  const char * const *what;
173
173
  return found?i:-1;
174
174
}
175
175
 
176
 
static int checkmonth(char *check)
 
176
static int checkmonth(const char *check)
177
177
{
178
178
  int i;
179
179
  const char * const *what;
193
193
/* return the time zone offset between GMT and the input one, in number
194
194
   of seconds or -1 if the timezone wasn't found/legal */
195
195
 
196
 
static int checktz(char *check)
 
196
static int checktz(const char *check)
197
197
{
198
198
  unsigned int i;
199
199
  const struct tzinfo *what;
223
223
  DATE_TIME
224
224
};
225
225
 
226
 
static time_t Curl_parsedate(const char *date)
 
226
static time_t parsedate(const char *date)
227
227
{
228
228
  time_t t = 0;
229
229
  int wdaynum=-1;  /* day of the week number, 0-6 (mon-sun) */
289
289
 
290
290
        if((tzoff == -1) &&
291
291
           ((end - date) == 4) &&
292
 
           (val < 1300) &&
 
292
           (val <= 1400) &&
293
293
           (indate< date) &&
294
294
           ((date[-1] == '+' || date[-1] == '-'))) {
295
 
          /* four digits and a value less than 1300 and it is preceeded with
296
 
             a plus or minus. This is a time zone indication. */
 
295
          /* four digits and a value less than or equal to 1400 (to take into
 
296
             account all sorts of funny time zone diffs) and it is preceeded
 
297
             with a plus or minus. This is a time zone indication.  1400 is
 
298
             picked since +1300 is frequently used and +1400 is mentioned as
 
299
             an edge number in the document "ISO C 200X Proposal: Timezone
 
300
             Functions" at http://david.tribble.com/text/c0xtimezone.html If
 
301
             anyone has a more authoritative source for the exact maximum time
 
302
             zone offsets, please speak up! */
297
303
          found = TRUE;
298
304
          tzoff = (val/100 * 60 + val%100)*60;
299
305
 
325
331
          yearnum = val;
326
332
          found = TRUE;
327
333
          if(yearnum < 1900) {
328
 
            if (yearnum > 70)
 
334
            if(yearnum > 70)
329
335
              yearnum += 1900;
330
336
            else
331
337
              yearnum += 2000;
421
427
time_t curl_getdate(const char *p, const time_t *now)
422
428
{
423
429
  (void)now;
424
 
  return Curl_parsedate(p);
 
430
  return parsedate(p);
425
431
}