]> andersk Git - moira.git/commitdiff
From jrasmuss: Win32 portability changes.
authorzacheiss <zacheiss>
Wed, 18 Jul 2001 02:47:50 +0000 (02:47 +0000)
committerzacheiss <zacheiss>
Wed, 18 Jul 2001 02:47:50 +0000 (02:47 +0000)
lib/mr_connect.c

index 93c3b0cf092c350d11a89d5dc06183cc9012eb66..526a63fa6a1ae1af5602ff7e78d4085b8bc76498 100644 (file)
 
 #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$");
@@ -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;
This page took 0.597489 seconds and 5 git commands to generate.