version 1.7 | | version 1.8 |
---|
| | |
/* | | /* |
* static char *rcsid_metaserver_c = | | * static char *rcsid_metaserver_c = |
* "$Id: metaserver.c,v 1.7 2001/04/06 00:43:52 michtoen Exp $"; | | * "$Id: metaserver.c,v 1.8 2001/04/06 19:08:13 michtoen Exp $"; |
*/ | | */ |
| | |
/* | | /* |
| | |
*/ | | */ |
#include <global.h> | | #include <global.h> |
| | |
#ifndef WIN32 //---win32 exclude unix header files | | #ifndef WIN32 /* ---win32 exclude unix header files */ |
#include <sys/types.h> | | #include <sys/types.h> |
#include <sys/socket.h> | | #include <sys/socket.h> |
#include <netinet/in.h> | | #include <netinet/in.h> |
| | |
#include <arpa/inet.h> | | #include <arpa/inet.h> |
| | |
#include <version.h> | | #include <version.h> |
#endif // end win32 | | #endif /* end win32 */ |
| | |
static int metafd=-1; | | static int metafd=-1; |
static struct sockaddr_in sock; | | static struct sockaddr_in sock; |
| | |
void metaserver_init() | | void metaserver_init() |
{ | | { |
| | |
#ifdef WIN32 // ***win32 metaserver_init(): init win32 socket | | #ifdef WIN32 /* ***win32 metaserver_init(): init win32 socket */ |
struct hostent *hostbn; | | struct hostent *hostbn; |
int temp = 1; | | int temp = 1; |
#endif | | #endif |
| | |
} | | } |
memcpy(&sock.sin_addr, hostbn->h_addr, hostbn->h_length); | | memcpy(&sock.sin_addr, hostbn->h_addr, hostbn->h_length); |
} | | } |
#ifdef WIN32 // ***win32 metaserver_init(): init win32 socket | | #ifdef WIN32 /* ***win32 metaserver_init(): init win32 socket */ |
ioctlsocket(metafd, FIONBIO , &temp); | | ioctlsocket(metafd, FIONBIO , &temp); |
#else | | #else |
fcntl(metafd, F_SETFL, O_NONBLOCK); | | fcntl(metafd, F_SETFL, O_NONBLOCK); |
| | |
return; | | return; |
} | | } |
| | |
#ifdef WIN32 // ***win32 metaserver_init(): gethostbyname! | | #ifdef WIN32 /* ***win32 metaserver_init(): gethostbyname! */ |
hostbn = gethostbyname(hostname); | | hostbn = gethostbyname(hostname); |
if (hostbn != (struct hostent *) NULL) // quick hack | | if (hostbn != (struct hostent *) NULL) /* quick hack */ |
memcpy(domain, hostbn->h_addr, hostbn->h_length); | | memcpy(domain, hostbn->h_addr, hostbn->h_length); |
| | |
if (hostbn == (struct hostent *) NULL) { | | if (hostbn == (struct hostent *) NULL) { |
#else | | #else |
if (getdomainname(domain, MAX_BUF-1)) { | | if (getdomainname(domain, MAX_BUF-1)) { |
#endif // win32 | | #endif /* win32 */ |
LOG(llevDebug,"metaserver_init: getdomainname failed - will not report hostname\n"); | | LOG(llevDebug,"metaserver_init: getdomainname failed - will not report hostname\n"); |
return; | | return; |
} | | } |
| | |
| | |
sprintf(data,"%s|%d|%s|%s", settings.meta_host, num_players, VERSION, | | sprintf(data,"%s|%d|%s|%s", settings.meta_host, num_players, VERSION, |
settings.meta_comment); | | settings.meta_comment); |
#ifdef WIN32 // ---win32 metaserver_init(): this removes a warning | | #ifdef WIN32 /* ---win32 metaserver_init(): this removes a warning */ |
if (sendto(metafd, data, strlen(data), 0, (struct sockaddr *)&sock, sizeof(sock))<0) { | | if (sendto(metafd, data, strlen(data), 0, (struct sockaddr *)&sock, sizeof(sock))<0) { |
#else | | #else |
if (sendto(metafd, data, strlen(data), 0, &sock, sizeof(sock))<0) { | | if (sendto(metafd, data, strlen(data), 0, &sock, sizeof(sock))<0) { |