httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@ast.cam.ac.uk (David Robinson)
Subject Re: Additional port for Apache-1.0.0 (fwd)
Date Fri, 22 Dec 1995 14:43:00 GMT
> Date: Tue, 19 Dec 95 18:24 PST
> From: swatt@Lynx.COM (Steven Watt -- KD6GGD)
> To: apache-bugs@mail.apache.org
> Subject: Additional port for Apache-1.0.0
> 
> Greetings!
> 
> I've ported Apache-1.0 to LynxOS version 2.3 (and later -- it should still
> work).
> 
> I think I've come up with a more-or-less standard way to figure out the
> GMT offset -- see the patch.
> 
> Thanks for a great piece of code!
> 
> Here's the patch file I generated (unidiffs):
> --------------------Cut here--------------------
> --- apache_1.0.0/src/util.c   Sat Nov 18 08:23:01 1995
> +++ apache_1.0.0-lynx/src/util.c      Tue Dec 19 17:36:01 1995
> @@ -129,7 +129,27 @@
>      return ht_time(p, sec, HTTP_TIME_FORMAT, 1);
>  }
>  
> +#if defined(LYNXOS)
> +/* This code ought to work for any system that has mktime, localtime, and
> + * gmtime from the ANSI C spec */
> +
> +struct tm *get_gmtoff(long *tz) {
> +    time_t tt;
> +    struct tm *loc_t;
> +    struct tm *gmt_t;
> +    
> +    tt = time(NULL);
> +    loc_t = localtime(&tt);
> +    gmt_t = gmtime(&tt);
> +    
> +    *tz = mktime(loc_t) - mktime(gmt_t);
> +    
> +    return loc_t;
> +}
> +
> +#else
>  /* What a pain in the ass. */
> +
>  struct tm *get_gmtoff(long *tz) {
>      time_t tt;
>      struct tm *t;
> @@ -146,6 +166,7 @@
>      return t;
>  }
>  
> +#endif       /* LYNXOS */
>  
>...

Firstly, I note that this code is pretty unlikely to work; the time routines
return pointers to static arrays, so you can't call them more than once
and use the result of an earlier call. 

Secondly, as his code is the ANSI way of finding the timezone,  it shouldn't
be #ifdef LYNXOS.

Finally, the original code is buggy in assuming that daylight saving is
always 1 hour.

 David.

Mime
View raw message