make gmt_offset portable, make decls and defns consistent..
authorMark Eichin <eichin@mit.edu>
Fri, 1 Jul 1994 18:01:47 +0000 (18:01 +0000)
committerMark Eichin <eichin@mit.edu>
Fri, 1 Jul 1994 18:01:47 +0000 (18:01 +0000)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@3940 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/krb5/asn.1/ChangeLog
src/lib/krb5/asn.1/asn1_decode.c
src/lib/krb5/asn.1/asn1_encode_k.c

index cdf1c392025f7b30879d537f2344a21c762a5235..90e6566cfd840178782045c5003a058178aa8842 100644 (file)
@@ -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,
index 7274ad56bd12c4c5da228ed8c3d67c197d5b9114..9412043f6cf38003c9826481c7b1863e1d453e32 100644 (file)
@@ -2,6 +2,9 @@
 #include "asn1_decode.h"
 #include "asn1_get.h"
 #include <time.h>
+#ifdef USE_SYS_TIME_H
+#include <sys/time.h>
+#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();
 }
index f270e2aed56fda128907bf230c710252ebe9526f..eab8a5fef419998e439391c2a5fbef49e9849374 100644 (file)
   *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: