Correct incorrect type-punning fixes
[openafs.git] / src / util / winsock_nt.c
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  */
9
10 /* winsock.c contains winsock related routines. */
11
12 #include <afsconfig.h>
13 #include <afs/param.h>
14
15
16 #ifdef AFS_NT40_ENV
17 #include <winsock2.h>
18 #include <sys/timeb.h>
19 #include <afs/afsutil.h>
20
21 /* afs_wsInit - LWP version
22  * Initialize the winsock 2 environment.
23  * 
24  * Returns 0 on success, -1 on error.
25  */
26 int
27 afs_winsockInit(void)
28 {
29         int code;
30         WSADATA data;
31         WORD sockVersion;
32
33         sockVersion = 2;
34         code = WSAStartup(sockVersion, &data);
35         if (code)
36             return -1;
37
38         if (data.wVersion != 2)
39             return -1;
40     return 0;
41 }
42
43 void
44 afs_winsockCleanup(void)
45 {
46     WSACleanup();
47 }
48
49 /* This function will begin to fail in the year 2038 */
50 int
51 afs_gettimeofday(struct timeval *tv, struct timezone *tz)
52 {
53     struct _timeb myTime;
54
55     _ftime(&myTime);
56     tv->tv_sec = myTime.time;
57     tv->tv_usec = myTime.millitm * 1000;
58     if (tz) {
59         tz->tz_minuteswest = myTime.timezone;
60         tz->tz_dsttime = myTime.dstflag;
61     }
62     return 0;
63 }
64 #endif