Fix some of the things that break compilation on Windows.
[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 RCSID("$Header$");
16
17 #ifdef AFS_NT40_ENV
18 #include <winsock2.h>
19 #include <sys/timeb.h>
20 #include <afs/afsutil.h>
21
22 /* afs_wsInit - LWP version
23  * Initialize the winsock 2 environment.
24  * 
25  * Returns 0 on success, -1 on error.
26  */
27 int afs_winsockInit(void)
28 {
29     static int once = 1;
30
31     if (once) {
32         int code ;
33         WSADATA data;
34         WORD sockVersion;
35
36         once = 0;
37
38         sockVersion = 2;
39         code = WSAStartup(sockVersion, &data);
40         if (code)
41             return -1;
42
43         if (data.wVersion != 2)
44             return -1;
45     }
46     return 0;
47 }
48
49 int afs_gettimeofday(struct timeval *tv, struct timezone *tz)
50 {
51     struct _timeb myTime;
52
53     _ftime(&myTime);
54     tv->tv_sec = myTime.time;
55     tv->tv_usec = myTime.millitm * 1000;
56     if (tz) {
57         tz->tz_minuteswest = myTime.timezone;
58         tz->tz_dsttime = myTime.dstflag;
59     }
60     return 0;
61 }
62 #endif