[1818] in Moira
Win32 changes to mr_connect.c
daemon@ATHENA.MIT.EDU (Jamie Rasmussen)
Tue Jul 17 17:02:08 2001
Message-Id: <4.3.2.7.2.20010717163748.01ad43c0@hesiod>
Date: Tue, 17 Jul 2001 17:00:12 -0400
To: moiradev@MIT.EDU
From: Jamie Rasmussen <jrasmuss@MIT.EDU>
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"; format=flowed
Hello,
Attached are some changes to mr_connect.c that are necessary
for the code to function in the Win32 environment. (These functions
are used by the Win32 port of update_server I've been working on.)
The changes are to use or fallback on Hesiod under Windows. Also,
I set sin.sin_family to AF_INET in one place to make the Winsock
version of bind happy.
I am not on the moiradev list, so please CC me on any replies.
Thank you,
Jamie Rasmussen
Project Pismere
C:\source\pismere\athena\moira\moira\lib>cvs -u diff -u -w mr_connect.c
Index: mr_connect.c
===================================================================
RCS file:
\\afs\all\athena.mit.edu\astaff\project\moiradev\repository/moira/lib/mr_connect.c,v
retrieving revision 1.34
diff -u -w -r1.34 mr_connect.c
--- mr_connect.c 2000/12/14 05:17:19 1.34
+++ mr_connect.c 2001/07/17 20:36:21
@@ -37,6 +37,12 @@
#ifdef HAVE_HESIOD
#include <hesiod.h>
+#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:
\\\\afs\\all\\athena.mit.edu\\astaff\\project\\moiradev\\repository/moira/lib/mr_connect.c,v
1.34 2000/12/14 05:17:19 zacheiss Exp $");
@@ -142,7 +148,11 @@
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 s, on = 1;
memset(&sin, 0, sizeof(sin));
+ sin.sin_family = AF_INET;
if (port[0] == '#')
sin.sin_port = atoi(port + 1);
else
@@ -272,7 +283,17 @@
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);