]> andersk Git - moira.git/blobdiff - clients/moira/cluster.c
Win32 portability mods for Pismere.
[moira.git] / clients / moira / cluster.c
index 0047b6774ea8e8bfce30b1b6cba6d3c2c7bfbb7c..c4dbaa535b2955f024f10d47223c32d91c98873d 100644 (file)
 #include "globals.h"
 
 #include <sys/types.h>
+
+#ifdef HAVE_UNAME
 #include <sys/utsname.h>
+#endif
 
+#ifndef _WIN32
 #include <netinet/in.h>
 #include <arpa/inet.h>
 #include <netdb.h>
+#endif /* _WIN32 */
 
 #include <ctype.h>
 #include <stdio.h>
@@ -196,7 +201,7 @@ static char *PrintMachInfo(char **info)
   else
     {
       aliasbuf[0] = 0;
-      Loop(QueueTop(elem), (void *) PrintAliases);
+      Loop(QueueTop(elem), (void (*)(char **)) PrintAliases);
       FreeQueue(elem);
       Put_message(aliasbuf);
     }
@@ -584,7 +589,7 @@ char **AskMCDInfo(char **info, int type, Bool name)
        return NULL;
       if (GetAddressFromUser("Network mask", &info[SN_MASK]) == SUB_ERROR)
        return NULL;
-      if (atoi(info[SN_LOW]) == ntohl(inet_addr(S_DEFAULT_LOW)))
+      if (atoi(info[SN_LOW]) == (int)ntohl(inet_addr(S_DEFAULT_LOW)))
        {
          struct in_addr low;
          unsigned long mask, addr;
@@ -600,7 +605,7 @@ char **AskMCDInfo(char **info, int type, Bool name)
       if (GetAddressFromUser("Lowest assignable address", &info[SN_LOW]) ==
          SUB_ERROR)
        return NULL;
-      if (atoi(info[SN_HIGH]) == ntohl(inet_addr(S_DEFAULT_HIGH)))
+      if (atoi(info[SN_HIGH]) == (int)ntohl(inet_addr(S_DEFAULT_HIGH)))
        {
          struct in_addr high;
          unsigned long mask, addr;
@@ -673,7 +678,7 @@ int ShowMachineInfo(int argc, char **argv)
 
   tmpname = canonicalize_hostname(strdup(argv[1]));
   top = GetMCInfo(MACHINE, tmpname, NULL);
-  Loop(top, ((void *) PrintMachInfo));
+  Loop(top, ((void (*)(char **)) PrintMachInfo));
   FreeQueue(top);
   return DM_NORMAL;
 }
@@ -729,7 +734,7 @@ int ShowMachineQuery(int argc, char **argv)
       return DM_NORMAL;
     }
   top = QueueTop(elem);
-  Loop(top, ((void *) PrintMachInfo));
+  Loop(top, ((void (*)(char **)) PrintMachInfo));
   FreeQueue(top);
   return DM_NORMAL;
 }
@@ -886,7 +891,7 @@ int CheckAndRemoveFromCluster(char *name, Bool ask_user)
        {
          sprintf(temp_buf, "%s is assigned to the following clusters.", name);
          Put_message(temp_buf);
-         Loop(top, (void *) PrintMCMap);
+         Loop(top, (void (*)(char **)) PrintMCMap);
          ptr = "Remove this machine from ** ALL ** these clusters?";
          if (YesNoQuestion(ptr, FALSE) == TRUE) /* may return -1. */
            delete_it = TRUE;
@@ -997,10 +1002,16 @@ char *partial_canonicalize_hostname(char *s)
       else
        {
          struct hostent *hp;
+#ifdef HAVE_UNAME
          struct utsname name;
-
          uname(&name);
          hp = gethostbyname(name.nodename);
+#else
+         char  name[256];
+         gethostname(name, sizeof(name));
+         name[sizeof(name)-1] = 0;
+         hp = gethostbyname(name);
+#endif /* HAVE_UNAME */
          cp = strchr(hp->h_name, '.');
          if (cp)
            def_domain = strdup(++cp);
@@ -1032,7 +1043,7 @@ int ShowCname(int argc, char **argv)
   tmpname = canonicalize_hostname(strdup(argv[2]));
   top = GetMCInfo(CNAME, tmpalias, tmpname);
   Put_message("");             /* blank line on screen */
-  Loop(top, ((void *) PrintCname));
+  Loop(top, ((void (*)(char **)) PrintCname));
   FreeQueue(top);
   return DM_NORMAL;
 }
@@ -1257,7 +1268,7 @@ int ShowSubnetInfo(int argc, char **argv)
   struct mqelem *top;
 
   top = GetMCInfo(SUBNET, argv[1], (char *) NULL);
-  Loop(top, (void *) PrintSubnetInfo);
+  Loop(top, (void (*)(char **)) PrintSubnetInfo);
   FreeQueue(top);
   return DM_NORMAL;
 }
@@ -1407,7 +1418,7 @@ int ShowClusterInfo(int argc, char **argv)
   struct mqelem *top;
 
   top = GetMCInfo(CLUSTER, argv[1], NULL);
-  Loop(top, (void *) PrintClusterInfo);
+  Loop(top, (void (*)(char **)) PrintClusterInfo);
   FreeQueue(top);
   return DM_NORMAL;
 }
This page took 0.038553 seconds and 4 git commands to generate.