summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/o_time.c
diff options
context:
space:
mode:
authorbeck <>2014-04-13 22:11:45 +0000
committerbeck <>2014-04-13 22:11:45 +0000
commitc07bea4706cfb2e50753f5af01364a2dd815689e (patch)
tree454ebecbf6e32e2986dd1082a857080004b5370c /src/lib/libcrypto/o_time.c
parent3d8036a72e4d1e91fc354eb6336d3459e1ee7c9c (diff)
downloadopenbsd-c07bea4706cfb2e50753f5af01364a2dd815689e.tar.gz
openbsd-c07bea4706cfb2e50753f5af01364a2dd815689e.tar.bz2
openbsd-c07bea4706cfb2e50753f5af01364a2dd815689e.zip
Remove vms support stuff.
ok deraadt@
Diffstat (limited to 'src/lib/libcrypto/o_time.c')
-rw-r--r--src/lib/libcrypto/o_time.c144
1 files changed, 1 insertions, 143 deletions
diff --git a/src/lib/libcrypto/o_time.c b/src/lib/libcrypto/o_time.c
index 9030fdef7a..5fb5d4e6d7 100644
--- a/src/lib/libcrypto/o_time.c
+++ b/src/lib/libcrypto/o_time.c
@@ -63,21 +63,6 @@
63#include <string.h> 63#include <string.h>
64#include "o_time.h" 64#include "o_time.h"
65 65
66#ifdef OPENSSL_SYS_VMS
67# if __CRTL_VER >= 70000000 && \
68 (defined _POSIX_C_SOURCE || !defined _ANSI_C_SOURCE)
69# define VMS_GMTIME_OK
70# endif
71# ifndef VMS_GMTIME_OK
72# include <libdtdef.h>
73# include <lib$routines.h>
74# include <lnmdef.h>
75# include <starlet.h>
76# include <descrip.h>
77# include <stdlib.h>
78# endif /* ndef VMS_GMTIME_OK */
79#endif
80
81struct tm *OPENSSL_gmtime(const time_t *timer, struct tm *result) 66struct tm *OPENSSL_gmtime(const time_t *timer, struct tm *result)
82 { 67 {
83 struct tm *ts = NULL; 68 struct tm *ts = NULL;
@@ -87,7 +72,7 @@ struct tm *OPENSSL_gmtime(const time_t *timer, struct tm *result)
87 so we don't even look at the return value */ 72 so we don't even look at the return value */
88 gmtime_r(timer,result); 73 gmtime_r(timer,result);
89 ts = result; 74 ts = result;
90#elif !defined(OPENSSL_SYS_VMS) || defined(VMS_GMTIME_OK) 75#else
91 ts = gmtime(timer); 76 ts = gmtime(timer);
92 if (ts == NULL) 77 if (ts == NULL)
93 return NULL; 78 return NULL;
@@ -95,133 +80,6 @@ struct tm *OPENSSL_gmtime(const time_t *timer, struct tm *result)
95 memcpy(result, ts, sizeof(struct tm)); 80 memcpy(result, ts, sizeof(struct tm));
96 ts = result; 81 ts = result;
97#endif 82#endif
98#if defined( OPENSSL_SYS_VMS) && !defined( VMS_GMTIME_OK)
99 if (ts == NULL)
100 {
101 static $DESCRIPTOR(tabnam,"LNM$DCL_LOGICAL");
102 static $DESCRIPTOR(lognam,"SYS$TIMEZONE_DIFFERENTIAL");
103 char logvalue[256];
104 unsigned int reslen = 0;
105 struct {
106 short buflen;
107 short code;
108 void *bufaddr;
109 unsigned int *reslen;
110 } itemlist[] = {
111 { 0, LNM$_STRING, 0, 0 },
112 { 0, 0, 0, 0 },
113 };
114 int status;
115 time_t t;
116
117 /* Get the value for SYS$TIMEZONE_DIFFERENTIAL */
118 itemlist[0].buflen = sizeof(logvalue);
119 itemlist[0].bufaddr = logvalue;
120 itemlist[0].reslen = &reslen;
121 status = sys$trnlnm(0, &tabnam, &lognam, 0, itemlist);
122 if (!(status & 1))
123 return NULL;
124 logvalue[reslen] = '\0';
125
126 t = *timer;
127
128/* The following is extracted from the DEC C header time.h */
129/*
130** Beginning in OpenVMS Version 7.0 mktime, time, ctime, strftime
131** have two implementations. One implementation is provided
132** for compatibility and deals with time in terms of local time,
133** the other __utc_* deals with time in terms of UTC.
134*/
135/* We use the same conditions as in said time.h to check if we should
136 assume that t contains local time (and should therefore be adjusted)
137 or UTC (and should therefore be left untouched). */
138#if __CRTL_VER < 70000000 || defined _VMS_V6_SOURCE
139 /* Get the numerical value of the equivalence string */
140 status = atoi(logvalue);
141
142 /* and use it to move time to GMT */
143 t -= status;
144#endif
145
146 /* then convert the result to the time structure */
147
148 /* Since there was no gmtime_r() to do this stuff for us,
149 we have to do it the hard way. */
150 {
151 /* The VMS epoch is the astronomical Smithsonian date,
152 if I remember correctly, which is November 17, 1858.
153 Furthermore, time is measure in thenths of microseconds
154 and stored in quadwords (64 bit integers). unix_epoch
155 below is January 1st 1970 expressed as a VMS time. The
156 following code was used to get this number:
157
158 #include <stdio.h>
159 #include <stdlib.h>
160 #include <lib$routines.h>
161 #include <starlet.h>
162
163 main()
164 {
165 unsigned long systime[2];
166 unsigned short epoch_values[7] =
167 { 1970, 1, 1, 0, 0, 0, 0 };
168
169 lib$cvt_vectim(epoch_values, systime);
170
171 printf("%u %u", systime[0], systime[1]);
172 }
173 */
174 unsigned long unix_epoch[2] = { 1273708544, 8164711 };
175 unsigned long deltatime[2];
176 unsigned long systime[2];
177 struct vms_vectime
178 {
179 short year, month, day, hour, minute, second,
180 centi_second;
181 } time_values;
182 long operation;
183
184 /* Turn the number of seconds since January 1st 1970 to
185 an internal delta time.
186 Note that lib$cvt_to_internal_time() will assume
187 that t is signed, and will therefore break on 32-bit
188 systems some time in 2038.
189 */
190 operation = LIB$K_DELTA_SECONDS;
191 status = lib$cvt_to_internal_time(&operation,
192 &t, deltatime);
193
194 /* Add the delta time with the Unix epoch and we have
195 the current UTC time in internal format */
196 status = lib$add_times(unix_epoch, deltatime, systime);
197
198 /* Turn the internal time into a time vector */
199 status = sys$numtim(&time_values, systime);
200
201 /* Fill in the struct tm with the result */
202 result->tm_sec = time_values.second;
203 result->tm_min = time_values.minute;
204 result->tm_hour = time_values.hour;
205 result->tm_mday = time_values.day;
206 result->tm_mon = time_values.month - 1;
207 result->tm_year = time_values.year - 1900;
208
209 operation = LIB$K_DAY_OF_WEEK;
210 status = lib$cvt_from_internal_time(&operation,
211 &result->tm_wday, systime);
212 result->tm_wday %= 7;
213
214 operation = LIB$K_DAY_OF_YEAR;
215 status = lib$cvt_from_internal_time(&operation,
216 &result->tm_yday, systime);
217 result->tm_yday--;
218
219 result->tm_isdst = 0; /* There's no way to know... */
220
221 ts = result;
222 }
223 }
224#endif
225 return ts; 83 return ts;
226 } 84 }
227 85