home *** CD-ROM | disk | FTP | other *** search
- /*
- * win32skt.c
- *
- * This contains locking code for WAIS, called from irfiles.c.
- *
- * (C) Copyright 1994 The University Court of the University of Edinburgh
- *
- * Author: Chris Adie <C.J.Adie@ed.ac.uk>
- *
- */
-
- /******************************************************************************/
- /* INCLUDE FILES */
- /******************************************************************************/
-
- #include <windows.h>
- #include <winsock.h>
-
- /******************************************************************************/
- /* CONSTANT DEFINITIONS */
- /******************************************************************************/
-
- /* This section deliberately left blank */
-
- /******************************************************************************/
- /* MACRO FUNCTION DEFINITIONS */
- /******************************************************************************/
-
- /* This section deliberately left blank */
-
- /******************************************************************************/
- /* TYPE DEFINITIONS */
- /******************************************************************************/
-
- /* This section deliberately left blank */
-
- /******************************************************************************/
- /* GLOBAL VARIABLES AND FUNCTIONS IMPORTED */
- /******************************************************************************/
-
- /* This section deliberately left blank */
- /* Consider whether these should appear in a header file */
-
- /******************************************************************************/
- /* GLOBAL VARIABLES EXPORTED */
- /******************************************************************************/
-
- /* This section deliberately left blank */
-
- /******************************************************************************/
- /* VARIABLES PRIVATE TO THIS FILE */
- /******************************************************************************/
-
- static WSADATA wsaData = {0,0,"","",0,0,NULL};
-
- /******************************************************************************/
- /* FUNCTIONS PRIVATE TO THIS FILE */
- /******************************************************************************/
-
- /* This section deliberately left blank */
-
- /******************************************************************************/
- /* GLOBAL FUNCTIONS EXPORTED */
- /******************************************************************************/
-
- /*
- * Return the fully-qualified name of the host, or else its IP address,
- * as a string.
- */
- char *mygethostname(char *hostname,long len) {
- PHOSTENT phe;
- int err;
-
- err = gethostname(hostname,len);
- if (err) return hostname;
- phe = gethostbyname(hostname);
- if (phe!=NULL) strncpy(hostname,phe->h_name,len);
-
- return hostname;
- }
-
- void InitSockets(void) {
- int err;
-
- err = WSAStartup(MAKEWORD(1,1),&wsaData);
- if (err) {
- wsaData.wVersion = 0;
- }
- }
-
- void TermSockets(void) {
- if (wsaData.wVersion!=0) /* Infer a successful call to WSAStartup() */
- WSACleanup();
- }
-