From: zacheiss Date: Wed, 18 Jul 2001 02:47:50 +0000 (+0000) Subject: From jrasmuss: Win32 portability changes. X-Git-Url: http://andersk.mit.edu/gitweb/moira.git/commitdiff_plain/1215e7042db12967fd9d3a50301a9ef787e253c7 From jrasmuss: Win32 portability changes. --- diff --git a/lib/mr_connect.c b/lib/mr_connect.c index 93c3b0cf..526a63fa 100644 --- a/lib/mr_connect.c +++ b/lib/mr_connect.c @@ -37,6 +37,12 @@ #ifdef HAVE_HESIOD #include +#ifdef _WIN32 +/* This is declared in wshelper's resolv.h, but the definition of + * the putlong macro conflicts with Moira's + */ +struct hostent * WINAPI rgethostbyname(char *name); +#endif #endif RCSID("$Header$"); @@ -142,7 +148,11 @@ int mr_connect_internal(char *server, char *port) int ok = 0; int on = 1; /* Value variable for setsockopt() */ +#if defined(_WIN32) && defined(HAVE_HESIOD) + shost = rgethostbyname(server); +#else shost = gethostbyname(server); +#endif if (!shost) goto cleanup; @@ -263,6 +273,7 @@ int mr_listen(char *port) int s, on = 1; memset(&sin, 0, sizeof(sin)); + sin.sin_family = AF_INET; if (port[0] == '#') sin.sin_port = atoi(port + 1); else @@ -272,9 +283,19 @@ int mr_listen(char *port) if (s) sin.sin_port = s->s_port; else +#ifndef HAVE_HESIOD return -1; +#else + { + s = hes_getservbyname(port, "tcp"); + if (s) + sin.sin_port = s->s_port; + else + return -1; + } +#endif /* HAVE_HESIOD */ } - + s = socket(AF_INET, SOCK_STREAM, 0); if (s < 0) return -1;