From: Mark Eichin Date: Fri, 1 Jul 1994 18:01:47 +0000 (+0000) Subject: make gmt_offset portable, make decls and defns consistent.. X-Git-Tag: krb5-1.0-beta4.2~170 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=0495bcf4e2ba2ba83d375e685655656830038993;p=krb5.git make gmt_offset portable, make decls and defns consistent.. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@3940 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/krb5/asn.1/ChangeLog b/src/lib/krb5/asn.1/ChangeLog index cdf1c3920..90e6566cf 100644 --- a/src/lib/krb5/asn.1/ChangeLog +++ b/src/lib/krb5/asn.1/ChangeLog @@ -1,4 +1,18 @@ -Fri Jul 1 13:03:39 1994 Mark Eichin (eichin@tweedledumber.cygnus.com) +Fri Jul 1 13:03:39 1994 Mark Eichin (eichin@cygnus.com) + + * asn1_encode_k.c (asn1_encode_msgtype): comment out krb5_msgtype + decl of val arg, use int (to match prototype in header.) Throw out + OLDDECLARG, DECLARG, and use old-style definition to match style + of the rest of the code. + (asn1_encode_ui_4): comment out krb5_ui_4 decl of val arg, use int + (to match prototype in header.) Also rewrote definition header. + + * asn1_decode.c (asn1_decode_generaltime): tm_gmtoff is *not* in + System V either. The only portable way to find the delta is to + subtract gmtime from localtime at a fixed point (epoch+24hours is + an easy way to simplify the arithmetic.) + HAVE_GMTOFF: might someday be defined, but for now merely labels + what the code original did/was intended to do. * configure.in: redo "autoconf frobbage" since the old way didn't work with srcdir. Now, AC_OUTPUT generates all three Makefiles, diff --git a/src/lib/krb5/asn.1/asn1_decode.c b/src/lib/krb5/asn.1/asn1_decode.c index 7274ad56b..9412043f6 100644 --- a/src/lib/krb5/asn.1/asn1_decode.c +++ b/src/lib/krb5/asn.1/asn1_decode.c @@ -2,6 +2,9 @@ #include "asn1_decode.h" #include "asn1_get.h" #include +#ifdef USE_SYS_TIME_H +#include +#endif #define setup()\ asn1_error_code retval;\ @@ -172,10 +175,25 @@ asn1_error_code asn1_decode_generaltime(DECLARG(asn1buf *, buf), ts.tm_isdst = -1; t = mktime(&ts); if(t == -1) return ASN1_BAD_TIMEFORMAT; + +#ifdef HAVE_GMTOFF t += ts.tm_gmtoff; /* Convert back to UTC timezone */ - /* !!!WARNING!!! tm_gmtoff is non-ANSI, - although it should exist in both - BSD and SYSV. */ +#else + { + struct tm zg, zl; + time_t zero = 24*60*60; /* miss the year boundary */ + long delta; + + zl = *localtime(&zero); + zg = *gmtime(&zero); + + delta = (zl.tm_sec + 60*(zl.tm_min+60*(zl.tm_hour + 24*zl.tm_yday))) + - (zg.tm_sec + 60*(zg.tm_min+60*(zg.tm_hour + 24*zg.tm_yday))); + + t += delta; + } +#endif + *val = t; cleanup(); } diff --git a/src/lib/krb5/asn.1/asn1_encode_k.c b/src/lib/krb5/asn.1/asn1_encode_k.c index f270e2aed..eab8a5fef 100644 --- a/src/lib/krb5/asn.1/asn1_encode_k.c +++ b/src/lib/krb5/asn.1/asn1_encode_k.c @@ -98,23 +98,19 @@ *retlen = sum;\ return 0 -asn1_error_code asn1_encode_ui_4(DECLARG(asn1buf *, buf), - DECLARG(const krb5_ui_4, val), - DECLARG(int *, retlen)) - OLDDECLARG(asn1buf *, buf) - OLDDECLARG(const krb5_ui_4, val) - OLDDECLARG(int *, retlen) +asn1_error_code asn1_encode_ui_4(buf, val, retlen) + asn1buf * buf; + const /*krb5_ui_4*/int val; + int *retlen; { return asn1_encode_unsigned_integer(buf,val,retlen); } -asn1_error_code asn1_encode_msgtype(DECLARG(asn1buf *, buf), - DECLARG(const krb5_msgtype, val), - DECLARG(int *, retlen)) - OLDDECLARG(asn1buf *, buf) - OLDDECLARG(const krb5_msgtype, val) - OLDDECLARG(int *, retlen) +asn1_error_code asn1_encode_msgtype(buf, val, retlen) + asn1buf * buf; + const /*krb5_msgtype*/int val; + int * retlen; { switch(val){ case KRB5_AS_REQ: