/[james]/httplint/httplint.c
ViewVC logotype

Diff of /httplint/httplint.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 41 by james, Wed Dec 17 17:44:40 2003 UTC revision 42 by james, Wed Dec 17 18:45:44 2003 UTC
# Line 49  void check_status_line(const char *s); Line 49  void check_status_line(const char *s);
49  void check_header(const char *name, const char *value);  void check_header(const char *name, const char *value);
50  bool parse_date(const char *s, struct tm *tm);  bool parse_date(const char *s, struct tm *tm);
51  int month(const char *s);  int month(const char *s);
52    time_t mktime_from_utc(struct tm *t);
53  const char *skip_lws(const char *s);  const char *skip_lws(const char *s);
54  bool parse_list(const char *s, regex_t *preg, unsigned int n, unsigned int m,  bool parse_list(const char *s, regex_t *preg, unsigned int n, unsigned int m,
55      void (*callback)(const char *s, regmatch_t pmatch[]));      void (*callback)(const char *s, regmatch_t pmatch[]));
# Line 411  bool parse_date(const char *s, struct tm Line 412  bool parse_date(const char *s, struct tm
412    int len = strlen(s);    int len = strlen(s);
413    regmatch_t pmatch[20];    regmatch_t pmatch[20];
414    
   tm->tm_wday = 0;  
   tm->tm_yday = 0;  
   tm->tm_isdst = 0;  
   tm->tm_gmtoff = 0;  
   tm->tm_zone = "GMT";  
   
415    if (len == 29) {    if (len == 29) {
416      /* RFC 1123 */      /* RFC 1123 */
417      r = regexec(&re_rfc1123, s, 20, pmatch, 0);      r = regexec(&re_rfc1123, s, 20, pmatch, 0);
# Line 501  int month(const char *s) Line 496  int month(const char *s)
496    
497    
498  /**  /**
499     * UTC version of mktime, from
500     *   http://lists.debian.org/deity/2002/deity-200204/msg00082.html
501     */
502    time_t mktime_from_utc(struct tm *t)
503    {
504      time_t tl, tb;
505      struct tm *tg;
506    
507      tl = mktime (t);
508      if (tl == -1)
509        {
510          t->tm_hour--;
511          tl = mktime (t);
512          if (tl == -1)
513            return -1; /* can't deal with output from strptime */
514          tl += 3600;
515        }
516      tg = gmtime (&tl);
517      tg->tm_isdst = 0;
518      tb = mktime (tg);
519      if (tb == -1)
520        {
521          tg->tm_hour--;
522          tb = mktime (tg);
523          if (tb == -1)
524            return -1; /* can't deal with output from gmtime */
525          tb += 3600;
526        }
527      return (tl - (tb - tl));
528    }
529    
530    
531    /**
532   * Skip optional LWS (linear white space) [2.2]   * Skip optional LWS (linear white space) [2.2]
533   */   */
534  const char *skip_lws(const char *s)  const char *skip_lws(const char *s)
# Line 754  void header_date(const char *s) Line 782  void header_date(const char *s)
782    time0 = time(0);    time0 = time(0);
783    if (!parse_date(s, &tm))    if (!parse_date(s, &tm))
784      return;      return;
785    time1 = mktime(&tm);    time1 = mktime_from_utc(&tm);
786    
787    diff = difftime(time0, time1);    diff = difftime(time0, time1);
788    if (10 < fabs(diff))    if (10 < fabs(diff))

Legend:
Removed from v.41  
changed lines
  Added in v.42

  ViewVC Help
Powered by ViewVC 1.1.26