7418b7524bb7953e07782f4694c52949457dbf3e
[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 #include <roken.h>
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
28 afs_winsockInit(void)
29 {
30         int code;
31         WSADATA data;
32         WORD sockVersion;
33
34         sockVersion = 2;
35         code = WSAStartup(sockVersion, &data);
36         if (code)
37             return -1;
38
39         if (data.wVersion != 2)
40             return -1;
41     return 0;
42 }
43
44 void
45 afs_winsockCleanup(void)
46 {
47     WSACleanup();
48 }
49
50 /* exported from libafsauthent.dll */
51 int
52 afs_gettimeofday(struct timeval *tv, struct timezone *tz)
53 {
54     return rk_gettimeofday(tv, tz);
55 }
56 #endif