httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ben Laurie <...@gonzo.ben.algroup.co.uk>
Subject Re: Additional port for Apache-1.0.0 (fwd)
Date Fri, 22 Dec 1995 19:36:08 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. 

Maybe true (though they're likely to return statics which are local to the
functions, so its probably OK), but the principle is neat, it sidesteps all
OS dependencies. Of course, the objection is easily fixed.

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

localtime and gmtime are so widely supported that this could justifiably be
described as the C way of finding the timezone.

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

Christmas cheers,

Ben.

-- 
Ben Laurie                  Phone: +44 (181) 994 6435
Freelance Consultant        Fax:   +44 (181) 994 6472
and Technical Director      Email: ben@algroup.co.uk
A.L. Digital Ltd,           URL: http://www.algroup.co.uk
London, England.

Mime
View raw message