]> andersk Git - moira.git/blobdiff - clients/moira/cluster.c
Win32 portability mods for Pismere.
[moira.git] / clients / moira / cluster.c
index 23dd92d5627c1c5d5d3c9cc33f4ff200d0896ec9..c4dbaa535b2955f024f10d47223c32d91c98873d 100644 (file)
@@ -1,43 +1,50 @@
-#if (!defined(lint) && !defined(SABER))
-  static char rcsid_module_c[] = "$Header$";
-#endif
-
-/*     This is the file cluster.c for the MOIRA Client, which allows a nieve
- *      user to quickly and easily maintain most parts of the MOIRA database.
+/* $Id$
+ *
+ *     This is the file cluster.c for the Moira Client, which allows users
+ *      to quickly and easily maintain most parts of the Moira database.
  *     It Contains:
  *
  *     Created:        4/22/88
  *     By:             Chris D. Peterson
  *
- *      $Source$
- *      $Author$
- *      $Header$
- *
- *     Copyright 1988 by the Massachusetts Institute of Technology.
- *
- *     For further information on copyright and distribution
- *     see the file mit-copyright.h
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
 /* BTW: for anyone who cares MCD is short for Machine, Cluster, Data. */
 
-#include <stdio.h>
-#include <string.h>
+#include <mit-copyright.h>
 #include <moira.h>
 #include <moira_site.h>
-#include <menu.h>
+
+#include "defs.h"
+#include "f_defs.h"
+#include "globals.h"
+
 #include <sys/types.h>
-#include <sys/socket.h>
+
+#ifdef HAVE_UNAME
+#include <sys/utsname.h>
+#endif
+
+#ifndef _WIN32
 #include <netinet/in.h>
 #include <arpa/inet.h>
-#include <sys/utsname.h>
 #include <netdb.h>
+#endif /* _WIN32 */
+
 #include <ctype.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 
-#include "mit-copyright.h"
-#include "defs.h"
-#include "f_defs.h"
-#include "globals.h"
+void PrintAliases(char **info);
+struct mqelem *GetMCInfo(int type, char *name1, char *name2);
+char **AskMCDInfo(char **info, int type, Bool name);
+int CheckAndRemoveFromCluster(char *name, Bool ask_user);
+int CheckAndRemoveMachines(char *name, Bool ask_first);
+char *partial_canonicalize_hostname(char *s);
 
 #define MACHINE  0
 #define CLUSTER  1
@@ -89,20 +96,20 @@ static char *MacState(int state)
 
 static char **SetMachineDefaults(char **info, char *name)
 {
-  info[M_NAME] = Strsave(name);
-  info[M_VENDOR] = Strsave(M_DEFAULT_TYPE);
-  info[M_MODEL] = Strsave(M_DEFAULT_TYPE);
-  info[M_OS] = Strsave(M_DEFAULT_TYPE);
-  info[M_LOC] = Strsave(M_DEFAULT_TYPE);
-  info[M_CONTACT] = Strsave(M_DEFAULT_TYPE);
-  info[M_USE] = Strsave("0");
-  info[M_STAT] = Strsave("1");
-  info[M_SUBNET] = Strsave("NONE");
-  info[M_ADDR] = Strsave("unique");
-  info[M_OWNER_TYPE] = Strsave("NONE");
-  info[M_OWNER_NAME] = Strsave("NONE");
-  info[M_ACOMMENT] = Strsave("");
-  info[M_OCOMMENT] = Strsave("");
+  info[M_NAME] = strdup(name);
+  info[M_VENDOR] = strdup(M_DEFAULT_TYPE);
+  info[M_MODEL] = strdup(M_DEFAULT_TYPE);
+  info[M_OS] = strdup(M_DEFAULT_TYPE);
+  info[M_LOC] = strdup(M_DEFAULT_TYPE);
+  info[M_CONTACT] = strdup(M_DEFAULT_TYPE);
+  info[M_USE] = strdup("0");
+  info[M_STAT] = strdup("1");
+  info[M_SUBNET] = strdup("NONE");
+  info[M_ADDR] = strdup("unique");
+  info[M_OWNER_TYPE] = strdup("NONE");
+  info[M_OWNER_NAME] = strdup("NONE");
+  info[M_ACOMMENT] = strdup("");
+  info[M_OCOMMENT] = strdup("");
   info[15] = info[16] = NULL;
   return info;
 }
@@ -116,9 +123,9 @@ static char **SetMachineDefaults(char **info, char *name)
 
 static char **SetClusterDefaults(char **info, char *name)
 {
-  info[C_NAME] = Strsave(name);
-  info[C_DESCRIPT] = Strsave(C_DEFAULT_DESCRIPT);
-  info[C_LOCATION] = Strsave(C_DEFAULT_LOCATION);
+  info[C_NAME] = strdup(name);
+  info[C_DESCRIPT] = strdup(C_DEFAULT_DESCRIPT);
+  info[C_LOCATION] = strdup(C_DEFAULT_LOCATION);
   info[C_MODBY] = info[C_MODTIME] = info[C_MODWITH] = info[C_END] = NULL;
   return info;
 }
@@ -134,19 +141,19 @@ static char **SetSubnetDefaults(char **info, char *name)
 {
   char buf[256];
 
-  info[C_NAME] = Strsave(name);
-  info[SN_DESC] = Strsave("");
+  info[C_NAME] = strdup(name);
+  info[SN_DESC] = strdup("");
   sprintf(buf, "%ld", ntohl(inet_addr("18.255.0.0")));
-  info[SN_ADDRESS] = Strsave(buf);
+  info[SN_ADDRESS] = strdup(buf);
   sprintf(buf, "%ld", ntohl(inet_addr("255.255.0.0")));
-  info[SN_MASK] = Strsave(buf);
+  info[SN_MASK] = strdup(buf);
   sprintf(buf, "%ld", ntohl(inet_addr(S_DEFAULT_LOW)));
-  info[SN_LOW] = Strsave(buf);
+  info[SN_LOW] = strdup(buf);
   sprintf(buf, "%ld", ntohl(inet_addr(S_DEFAULT_HIGH)));
-  info[SN_HIGH] = Strsave(buf);
-  info[SN_PREFIX] = Strsave("");
-  info[SN_ACE_TYPE] = Strsave("LIST");
-  info[SN_ACE_NAME] = Strsave("network");
+  info[SN_HIGH] = strdup(buf);
+  info[SN_PREFIX] = strdup("");
+  info[SN_ACE_TYPE] = strdup("LIST");
+  info[SN_ACE_NAME] = strdup("network");
   info[SN_MODBY] = info[SN_MODTIME] = info[SN_MODWITH] = info[SN_END] = NULL;
   return info;
 }
@@ -155,7 +162,7 @@ static char **SetSubnetDefaults(char **info, char *name)
 
 static char aliasbuf[256];
 
-static char *PrintAliases(char **info)
+void PrintAliases(char **info)
 {
   if (strlen(aliasbuf) == 0)
     sprintf(aliasbuf, "Aliases:  %s", info[0]);
@@ -178,7 +185,7 @@ static char *PrintMachInfo(char **info)
 {
   char buf[BUFSIZ], tbuf[256];
   char *args[3];
-  struct qelem *elem = NULL;
+  struct mqelem *elem = NULL;
   int stat;
 
   Put_message("");
@@ -186,7 +193,7 @@ static char *PrintMachInfo(char **info)
   Put_message(buf);
   args[0] = "*";
   args[1] = info[M_NAME];
-  if ((stat = do_mr_query("get_hostalias", 2, args, StoreInfo, (char *)&elem)))
+  if ((stat = do_mr_query("get_hostalias", 2, args, StoreInfo, &elem)))
     {
       if (stat != MR_NO_MATCH)
        com_err(program_name, stat, " looking up aliases");
@@ -194,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);
     }
@@ -347,10 +354,10 @@ static char *PrintSubnetInfo(char **info)
  *     Returns: the top element of a queue containing the data or NULL.
  */
 
-struct qelem *GetMCInfo(int type, char *name1, char *name2)
+struct mqelem *GetMCInfo(int type, char *name1, char *name2)
 {
   int stat;
-  struct qelem *elem = NULL;
+  struct mqelem *elem = NULL;
   char *args[5];
 
   switch (type)
@@ -358,8 +365,7 @@ struct qelem *GetMCInfo(int type, char *name1, char *name2)
     case MACHINE:
       args[0] = name1;
       args[1] = args[2] = args[3] = "*";
-      if ((stat = do_mr_query("get_host", 4, args,
-                             StoreInfo, (char *)&elem)))
+      if ((stat = do_mr_query("get_host", 4, args, StoreInfo, &elem)))
        {
          if (stat == MR_NO_MATCH)
            {
@@ -375,16 +381,14 @@ struct qelem *GetMCInfo(int type, char *name1, char *name2)
     case CNAME:
       args[0] = name1;
       args[1] = name2;
-      if ((stat = do_mr_query("get_hostalias", 2, args,
-                             StoreInfo, (char *)&elem)))
+      if ((stat = do_mr_query("get_hostalias", 2, args, StoreInfo, &elem)))
        {
          com_err(program_name, stat, " in get_hostalias.");
          return NULL;
        }
       break;
     case SUBNET:
-      if ((stat = do_mr_query("get_subnet", 1, &name1,
-                             StoreInfo, (char *)&elem)))
+      if ((stat = do_mr_query("get_subnet", 1, &name1, StoreInfo, &elem)))
        {
          if (stat == MR_NO_MATCH)
            {
@@ -398,8 +402,7 @@ struct qelem *GetMCInfo(int type, char *name1, char *name2)
        }
       break;
     case CLUSTER:
-      if ((stat = do_mr_query("get_cluster", 1, &name1,
-                             StoreInfo, (char *)&elem)))
+      if ((stat = do_mr_query("get_cluster", 1, &name1, StoreInfo, &elem)))
        {
          com_err(program_name, stat, " in get_cluster.");
          return NULL;
@@ -409,7 +412,7 @@ struct qelem *GetMCInfo(int type, char *name1, char *name2)
       args[MAP_MACHINE] = name1;
       args[MAP_CLUSTER] = name2;
       if ((stat = do_mr_query("get_machine_to_cluster_map", 2, args,
-                             StoreInfo, (char *)&elem)))
+                             StoreInfo, &elem)))
        {
          com_err(program_name, stat, " in get_machine_to_cluster_map.");
          return NULL;
@@ -418,8 +421,7 @@ struct qelem *GetMCInfo(int type, char *name1, char *name2)
     case DATA:
       args[CD_NAME] = name1;
       args[CD_LABEL] = name2;
-      if ((stat = do_mr_query("get_cluster_data", 2, args,
-                             StoreInfo, (char *)&elem)))
+      if ((stat = do_mr_query("get_cluster_data", 2, args, StoreInfo, &elem)))
        {
          com_err(program_name, stat, " in get_cluster_data.");
          return NULL;
@@ -469,11 +471,11 @@ char **AskMCDInfo(char **info, int type, Bool name)
       switch (type)
        {
        case MACHINE:
-         newname = Strsave(info[M_NAME]);
+         newname = strdup(info[M_NAME]);
          if (GetValueFromUser("The new name for this machine? ", &newname) ==
              SUB_ERROR)
            return NULL;
-         oldnewname = Strsave(newname);
+         oldnewname = strdup(newname);
          newname = canonicalize_hostname(newname);
          if (strcasecmp(newname, oldnewname) && *oldnewname != '"')
            {
@@ -484,13 +486,13 @@ char **AskMCDInfo(char **info, int type, Bool name)
          free(oldnewname);
          break;
        case SUBNET:
-         newname = Strsave(info[SN_NAME]);
+         newname = strdup(info[SN_NAME]);
          if (GetValueFromUser("The new name for this network? ", &newname) ==
              SUB_ERROR)
            return NULL;
          break;
        case CLUSTER:
-         newname = Strsave(info[C_NAME]);
+         newname = strdup(info[C_NAME]);
          if (GetValueFromUser("The new name for this cluster? ", &newname) ==
              SUB_ERROR)
            return NULL;
@@ -587,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;
@@ -597,13 +599,13 @@ char **AskMCDInfo(char **info, int type, Bool name)
          low.s_addr = atoi(info[SN_LOW]);
          low.s_addr = (low.s_addr & ~mask) | (addr & mask);
          free(info[SN_LOW]);
-         sprintf(temp_buf, "%d", low.s_addr);
-         info[SN_LOW] = strsave(temp_buf);
+         sprintf(temp_buf, "%ld", low.s_addr);
+         info[SN_LOW] = strdup(temp_buf);
        }
       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;
@@ -613,8 +615,8 @@ char **AskMCDInfo(char **info, int type, Bool name)
          high.s_addr = atoi(info[SN_HIGH]);
          high.s_addr = (high.s_addr & ~mask) | (addr & mask);
          free(info[SN_HIGH]);
-         sprintf(temp_buf, "%d", high.s_addr);
-         info[SN_HIGH] = strsave(temp_buf);
+         sprintf(temp_buf, "%ld", high.s_addr);
+         info[SN_HIGH] = strdup(temp_buf);
        }
       if (GetAddressFromUser("Highest assignable address", &info[SN_HIGH]) ==
          SUB_ERROR)
@@ -671,12 +673,12 @@ char **AskMCDInfo(char **info, int type, Bool name)
 
 int ShowMachineInfo(int argc, char **argv)
 {
-  struct qelem *top;
+  struct mqelem *top;
   char *tmpname;
 
-  tmpname = canonicalize_hostname(strsave(argv[1]));
+  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;
 }
@@ -696,7 +698,7 @@ int ShowMachineInfo(int argc, char **argv)
 int ShowMachineQuery(int argc, char **argv)
 {
   int stat;
-  struct qelem *top, *elem = NULL;
+  struct mqelem *top, *elem = NULL;
   char *args[5];
 
   if (!strcmp(argv[1], "") && !strcmp(argv[2], "") &&
@@ -707,7 +709,7 @@ int ShowMachineQuery(int argc, char **argv)
     }
 
   if (*argv[1])
-    args[0] = canonicalize_hostname(strsave(argv[1]));
+    args[0] = canonicalize_hostname(strdup(argv[1]));
   else
     args[0] = "*";
   if (*argv[2])
@@ -723,8 +725,7 @@ int ShowMachineQuery(int argc, char **argv)
   else
     args[3] = "*";
 
-  if ((stat = do_mr_query("get_host", 4, args, StoreInfo,
-                         (char *)&elem)))
+  if ((stat = do_mr_query("get_host", 4, args, StoreInfo, &elem)))
     {
       if (stat == MR_NO_MATCH)
        Put_message("No machine(s) found matching query in the database.");
@@ -733,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;
 }
@@ -748,7 +749,7 @@ int AddMachine(int argc, char **argv)
 {
   char **args, *info[MAX_ARGS_SIZE], *name, buf[256], *xargs[5];
   char **rinfo;
-  struct qelem *elem = NULL;
+  struct mqelem *elem = NULL;
   int stat;
 
   if (!ValidName(argv[1]))     /* Checks for wildcards. */
@@ -759,8 +760,7 @@ int AddMachine(int argc, char **argv)
    */
 
   if (strcasecmp(argv[1], "none") &&
-      (stat = do_mr_query("get_subnet", 1, &argv[1],
-                         StoreInfo, (char *)&elem)))
+      (stat = do_mr_query("get_subnet", 1, &argv[1], StoreInfo, &elem)))
     {
       if (stat == MR_NO_MATCH)
        {
@@ -776,15 +776,15 @@ int AddMachine(int argc, char **argv)
    * Check to see if this machine already exists.
    */
 
-  name = strsave(""); /* want to put prefix here */
+  name = strdup(""); /* want to put prefix here */
   if (GetValueFromUser("Machine name", &name) == SUB_ERROR)
     return 0;
 
-  name = canonicalize_hostname(strsave(name));
+  name = canonicalize_hostname(strdup(name));
 
   xargs[0] = name;
   xargs[1] = xargs[2] = xargs[3] = "*";
-  if (!(stat = do_mr_query("get_host", 4, xargs, NullFunc, NULL)))
+  if (!(stat = do_mr_query("get_host", 4, xargs, NULL, NULL)))
     {
       sprintf(buf, "The machine '%s' already exists.", name);
       Put_message(buf);
@@ -799,7 +799,7 @@ int AddMachine(int argc, char **argv)
       return DM_NORMAL;
     }
   rinfo = SetMachineDefaults(info, name);
-  rinfo[M_SUBNET] = strsave(argv[1]);
+  rinfo[M_SUBNET] = strdup(argv[1]);
   if (!(args = AskMCDInfo(rinfo, MACHINE, FALSE)))
     {
       Put_message("Aborted.");
@@ -810,8 +810,7 @@ int AddMachine(int argc, char **argv)
    * Actually create the new Machine.
    */
 
-  if ((stat = do_mr_query("add_host", CountArgs(args),
-                         args, Scream, NULL)))
+  if ((stat = do_mr_query("add_host", CountArgs(args), args, NULL, NULL)))
     com_err(program_name, stat, " in AddMachine.");
 
   FreeInfo(info);
@@ -835,8 +834,7 @@ static void RealUpdateMachine(char **info, Bool junk)
       Put_message("Aborted.");
       return;
     }
-  if ((stat = do_mr_query("update_host", CountArgs(args),
-                         args, Scream, NULL)))
+  if ((stat = do_mr_query("update_host", CountArgs(args), args, NULL, NULL)))
     com_err(program_name, stat, " in UpdateMachine.");
   else
     Put_message("Machine successfully updated.");
@@ -850,10 +848,10 @@ static void RealUpdateMachine(char **info, Bool junk)
 
 int UpdateMachine(int argc, char **argv)
 {
-  struct qelem *top;
+  struct mqelem *top;
   char *tmpname;
 
-  tmpname = canonicalize_hostname(strsave(argv[1]));
+  tmpname = canonicalize_hostname(strdup(argv[1]));
   top = GetMCInfo(MACHINE, tmpname, NULL);
   QueryLoop(top, NullPrint, RealUpdateMachine, "Update the machine");
 
@@ -875,13 +873,12 @@ int CheckAndRemoveFromCluster(char *name, Bool ask_user)
   int stat, ret_value;
   Bool delete_it;
   char *args[10], temp_buf[BUFSIZ], *ptr;
-  struct qelem *top, *elem = NULL;
+  struct mqelem *top, *elem = NULL;
 
   ret_value = SUB_NORMAL;      /* initialize ret_value. */
   args[0] = name;
   args[1] = "*";
-  stat = do_mr_query("get_machine_to_cluster_map", 2, args,
-                    StoreInfo, (char *)&elem);
+  stat = do_mr_query("get_machine_to_cluster_map", 2, args, StoreInfo, &elem);
   if (stat && stat != MR_NO_MATCH)
     {
       com_err(program_name, stat, " in get_machine_to_cluster_map.");
@@ -894,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;
@@ -912,9 +909,9 @@ int CheckAndRemoveFromCluster(char *name, Bool ask_user)
        {
          while (elem)
            {
-             char **info = (char **) elem->q_data;
+             char **info = elem->q_data;
              if ((stat = do_mr_query("delete_machine_from_cluster",
-                                      2, info, Scream, NULL)))
+                                      2, info, NULL, NULL)))
                {
                  ret_value = SUB_ERROR;
                  com_err(program_name, stat,
@@ -951,7 +948,7 @@ static void RealDeleteMachine(char **info, Bool one_machine)
       if (CheckAndRemoveFromCluster(info[M_NAME], TRUE) != SUB_ERROR)
        {
          if ((stat = do_mr_query("delete_host", 1,
-                                 &info[M_NAME], Scream, NULL)))
+                                 &info[M_NAME], NULL, NULL)))
            {
              com_err(program_name, stat, " in DeleteMachine.");
              sprintf(temp_buf, "%s ** NOT ** deleted.",
@@ -977,10 +974,10 @@ static void RealDeleteMachine(char **info, Bool one_machine)
 
 int DeleteMachine(int argc, char **argv)
 {
-  struct qelem *top;
+  struct mqelem *top;
   char *tmpname;
 
-  tmpname = canonicalize_hostname(strsave(argv[1]));
+  tmpname = canonicalize_hostname(strdup(argv[1]));
   top = GetMCInfo(MACHINE, tmpname, (char *) NULL);
   QueryLoop(top, PrintMachInfo, RealDeleteMachine, "Delete the machine");
   FreeQueue(top);
@@ -993,17 +990,33 @@ char *partial_canonicalize_hostname(char *s)
 {
   char buf[256], *cp;
   static char *def_domain = NULL;
-  struct hostent *hp;
-  struct utsname name;
 
   if (!def_domain)
     {
-      uname(&name);
-      hp = gethostbyname(name.nodename);
-      cp = strchr(hp->h_name, '.');
-      if (cp)
-       def_domain = strsave(++cp);
+      if (mr_host(buf, sizeof(buf)) == MR_SUCCESS)
+       {
+         cp = strchr(buf, '.');
+         if (cp)
+           def_domain = strdup(++cp);
+       }
       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);
+       }
+      if (!def_domain)
        def_domain = "";
     }
 
@@ -1011,7 +1024,7 @@ char *partial_canonicalize_hostname(char *s)
     return s;
   sprintf(buf, "%s.%s", s, def_domain);
   free(s);
-  return strsave(buf);
+  return strdup(buf);
 }
 
 
@@ -1023,14 +1036,14 @@ char *partial_canonicalize_hostname(char *s)
 
 int ShowCname(int argc, char **argv)
 {
-  struct qelem *top;
+  struct mqelem *top;
   char *tmpalias, *tmpname;
 
-  tmpalias = partial_canonicalize_hostname(strsave(argv[1]));
-  tmpname = canonicalize_hostname(strsave(argv[2]));
+  tmpalias = partial_canonicalize_hostname(strdup(argv[1]));
+  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;
 }
@@ -1041,9 +1054,9 @@ int AddCname(int argc, char **argv)
   int stat;
   char *args[10];
 
-  args[0] = partial_canonicalize_hostname(strsave(argv[1]));
-  args[1] = canonicalize_hostname(strsave(argv[2]));
-  stat = do_mr_query("add_hostalias", 2, args, Scream, NULL);
+  args[0] = partial_canonicalize_hostname(strdup(argv[1]));
+  args[1] = canonicalize_hostname(strdup(argv[2]));
+  stat = do_mr_query("add_hostalias", 2, args, NULL, NULL);
   switch (stat)
     {
     case MR_SUCCESS:
@@ -1065,13 +1078,11 @@ int AddCname(int argc, char **argv)
 int DeleteCname(int argc, char **argv)
 {
   int stat;
-  char *machine, *cluster, temp_buf[BUFSIZ], *args[10];
-  Bool add_it, one_machine, one_cluster;
-  struct qelem *melem, *mtop, *celem, *ctop;
+  char *args[10];
 
-  args[0] = partial_canonicalize_hostname(strsave(argv[1]));
-  args[1] = canonicalize_hostname(strsave(argv[2]));
-  stat = do_mr_query("delete_hostalias", 2, args, Scream, NULL);
+  args[0] = partial_canonicalize_hostname(strdup(argv[1]));
+  args[1] = canonicalize_hostname(strdup(argv[2]));
+  stat = do_mr_query("delete_hostalias", 2, args, NULL, NULL);
   if (stat)
     com_err(program_name, stat, " in delete_hostalias");
   return DM_NORMAL;
@@ -1090,9 +1101,9 @@ int AddMachineToCluster(int argc, char **argv)
   int stat;
   char *machine, *cluster, temp_buf[BUFSIZ], *args[10];
   Bool add_it, one_machine, one_cluster;
-  struct qelem *melem, *mtop, *celem, *ctop;
+  struct mqelem *melem, *mtop, *celem, *ctop;
 
-  machine = canonicalize_hostname(strsave(argv[1]));
+  machine = canonicalize_hostname(strdup(argv[1]));
   if (strcasecmp(machine, argv[1]) && *argv[1] != '"')
     {
       sprintf(temp_buf, "Warning: '%s' canonicalized to '%s'.",
@@ -1112,10 +1123,10 @@ int AddMachineToCluster(int argc, char **argv)
 
   while (melem)
     {
-      char **minfo = (char **) melem->q_data;
+      char **minfo = melem->q_data;
       while (celem)
        {
-         char **cinfo = (char **) celem->q_data;
+         char **cinfo = celem->q_data;
          if (one_machine && one_cluster)
            add_it = TRUE;
          else
@@ -1142,7 +1153,7 @@ int AddMachineToCluster(int argc, char **argv)
              args[0] = minfo[M_NAME];
              args[1] = cinfo[C_NAME];
              stat = do_mr_query("add_machine_to_cluster", 2, args,
-                                Scream, NULL);
+                                NULL, NULL);
              switch (stat)
                {
                case MR_SUCCESS:
@@ -1186,7 +1197,7 @@ static void RealRemoveMachineFromCluster(char **info, Bool one_map)
   if (!one_map || Confirm(temp_buf))
     {
       if ((stat = do_mr_query("delete_machine_from_cluster", 2,
-                             info, Scream, NULL)))
+                             info, NULL, NULL)))
        com_err(program_name, stat, " in delete_machine_from_cluster");
       else
        {
@@ -1208,11 +1219,11 @@ static void RealRemoveMachineFromCluster(char **info, Bool one_map)
 
 int RemoveMachineFromCluster(int argc, char **argv)
 {
-  struct qelem *elem = NULL;
+  struct mqelem *elem = NULL;
   char buf[BUFSIZ], * args[10];
   int stat;
 
-  args[MAP_MACHINE] = canonicalize_hostname(strsave(argv[1]));
+  args[MAP_MACHINE] = canonicalize_hostname(strdup(argv[1]));
   if (strcasecmp(args[MAP_MACHINE], argv[1]) && *argv[1] != '"')
     {
       sprintf(buf, "Warning: '%s' canonicalized to '%s'.",
@@ -1223,7 +1234,7 @@ int RemoveMachineFromCluster(int argc, char **argv)
   args[MAP_END] = NULL;
 
   stat = do_mr_query("get_machine_to_cluster_map", CountArgs(args), args,
-                    StoreInfo, (char *)&elem);
+                    StoreInfo, &elem);
   if (stat == MR_NO_MATCH)
     {
       sprintf(buf, "The machine %s is not is the cluster %s.",
@@ -1254,10 +1265,10 @@ int RemoveMachineFromCluster(int argc, char **argv)
 
 int ShowSubnetInfo(int argc, char **argv)
 {
-  struct qelem *top;
+  struct mqelem *top;
 
   top = GetMCInfo(SUBNET, argv[1], (char *) NULL);
-  Loop(top, (void *) PrintSubnetInfo);
+  Loop(top, (void (*)(char **)) PrintSubnetInfo);
   FreeQueue(top);
   return DM_NORMAL;
 }
@@ -1279,8 +1290,7 @@ int AddSubnet(int argc, char **argv)
   if (!ValidName(name))
     return DM_NORMAL;
 
-  if ((stat = do_mr_query("get_subnet", 1, &name,
-                         NullFunc, NULL)) == MR_SUCCESS)
+  if ((stat = do_mr_query("get_subnet", 1, &name, NULL, NULL)) == MR_SUCCESS)
     {
       Put_message("This subnet already exists.");
       return DM_NORMAL;
@@ -1300,8 +1310,7 @@ int AddSubnet(int argc, char **argv)
   /*
    * Actually create the new Subnet.
    */
-  if ((stat = do_mr_query("add_subnet", CountArgs(args),
-                         args, Scream, NULL)))
+  if ((stat = do_mr_query("add_subnet", CountArgs(args), args, NULL, NULL)))
     com_err(program_name, stat, " in AddSubnet.");
 
   FreeInfo(info);
@@ -1324,8 +1333,7 @@ static void RealUpdateSubnet(char **info, Bool junk)
       Put_message("Aborted.");
       return;
     }
-  if ((stat = do_mr_query("update_subnet", CountArgs(args),
-                         args, Scream, NULL)))
+  if ((stat = do_mr_query("update_subnet", CountArgs(args), args, NULL, NULL)))
     com_err(program_name, stat, " in UpdateSubnet.");
   else
     Put_message("Subnet successfully updated.");
@@ -1339,7 +1347,7 @@ static void RealUpdateSubnet(char **info, Bool junk)
 
 int UpdateSubnet(int argc, char **argv)
 {
-  struct qelem *top;
+  struct mqelem *top;
   top = GetMCInfo(SUBNET, argv[1], NULL);
   QueryLoop(top, NullPrint, RealUpdateSubnet, "Update the subnet");
 
@@ -1365,8 +1373,7 @@ static void RealDeleteSubnet(char **info, Bool one_subnet)
          info[C_NAME]);
   if (!one_subnet || Confirm(temp_buf))
     {
-      if ((stat = do_mr_query("delete_subnet", 1,
-                             &info[C_NAME], Scream, NULL)))
+      if ((stat = do_mr_query("delete_subnet", 1, &info[C_NAME], NULL, NULL)))
        {
          com_err(program_name, stat, " in delete_subnet.");
          sprintf(temp_buf, "Subnet %s ** NOT ** deleted.", info[C_NAME]);
@@ -1389,7 +1396,7 @@ static void RealDeleteSubnet(char **info, Bool one_subnet)
 
 int DeleteSubnet(int argc, char **argv)
 {
-  struct qelem *top;
+  struct mqelem *top;
 
   top = GetMCInfo(SUBNET, argv[1], NULL);
   QueryLoop(top, PrintSubnetInfo, RealDeleteSubnet, "Delete the subnet");
@@ -1408,10 +1415,10 @@ int DeleteSubnet(int argc, char **argv)
 
 int ShowClusterInfo(int argc, char **argv)
 {
-  struct qelem *top;
+  struct mqelem *top;
 
   top = GetMCInfo(CLUSTER, argv[1], NULL);
-  Loop(top, (void *) PrintClusterInfo);
+  Loop(top, (void (*)(char **)) PrintClusterInfo);
   FreeQueue(top);
   return DM_NORMAL;
 }
@@ -1433,8 +1440,7 @@ int AddCluster(int argc, char **argv)
   if (!ValidName(name))
     return DM_NORMAL;
 
-  if ((stat = do_mr_query("get_cluster", 1, &name,
-                         NullFunc, NULL)) == MR_SUCCESS)
+  if ((stat = do_mr_query("get_cluster", 1, &name, NULL, NULL)) == MR_SUCCESS)
     {
       Put_message("This cluster already exists.");
       return DM_NORMAL;
@@ -1454,8 +1460,7 @@ int AddCluster(int argc, char **argv)
   /*
    * Actually create the new Cluster.
    */
-  if ((stat = do_mr_query("add_cluster", CountArgs(args),
-                         args, Scream, NULL)))
+  if ((stat = do_mr_query("add_cluster", CountArgs(args), args, NULL, NULL)))
     com_err(program_name, stat, " in AddCluster.");
 
   FreeInfo(info);
@@ -1480,7 +1485,7 @@ static void RealUpdateCluster(char **info, Bool junk)
       return;
     }
   if ((stat = do_mr_query("update_cluster", CountArgs(args),
-                         args, Scream, NULL)))
+                         args, NULL, NULL)))
     com_err(program_name, stat, " in UpdateCluster.");
   else
     Put_message("Cluster successfully updated.");
@@ -1494,7 +1499,7 @@ static void RealUpdateCluster(char **info, Bool junk)
 
 int UpdateCluster(int argc, char **argv)
 {
-  struct qelem *top;
+  struct mqelem *top;
   top = GetMCInfo(CLUSTER, argv[1], NULL);
   QueryLoop(top, NullPrint, RealUpdateCluster, "Update the cluster");
 
@@ -1516,13 +1521,12 @@ int CheckAndRemoveMachines(char *name, Bool ask_first)
   int stat, ret_value;
   Bool delete_it;
   char *args[10], temp_buf[BUFSIZ], *ptr;
-  struct qelem *top, *elem = NULL;
+  struct mqelem *top, *elem = NULL;
 
   ret_value = SUB_NORMAL;
   args[MAP_MACHINE] = "*";
   args[MAP_CLUSTER] = name;
-  stat = do_mr_query("get_machine_to_cluster_map", 2, args,
-                    StoreInfo, (char *)&elem);
+  stat = do_mr_query("get_machine_to_cluster_map", 2, args, StoreInfo, &elem);
   if (stat && stat != MR_NO_MATCH)
     {
       com_err(program_name, stat, " in get_machine_to_cluster_map.");
@@ -1538,7 +1542,7 @@ int CheckAndRemoveMachines(char *name, Bool ask_first)
          Put_message(temp_buf);
          while (elem)
            {
-             char **info = (char **) elem->q_data;
+             char **info = elem->q_data;
              Print(1, &info[MAP_MACHINE], (char *) NULL);
              elem = elem->q_forw;
            }
@@ -1561,9 +1565,9 @@ int CheckAndRemoveMachines(char *name, Bool ask_first)
          elem = top;
          while (elem)
            {
-             char **info = (char **) elem->q_data;
+             char **info = elem->q_data;
              if ((stat = do_mr_query("delete_machine_from_cluster",
-                                     2, info, Scream, NULL)))
+                                     2, info, NULL, NULL)))
                {
                  ret_value = SUB_ERROR;
                  com_err(program_name, stat,
@@ -1601,7 +1605,7 @@ static void RealDeleteCluster(char **info, Bool one_cluster)
       if (CheckAndRemoveMachines(info[C_NAME], TRUE) != SUB_ERROR)
        {
          if ((stat = do_mr_query("delete_cluster", 1,
-                                 &info[C_NAME], Scream, NULL)))
+                                 &info[C_NAME], NULL, NULL)))
            {
              com_err(program_name, stat, " in delete_cluster.");
              sprintf(temp_buf, "Cluster %s ** NOT ** deleted.", info[C_NAME]);
@@ -1625,7 +1629,7 @@ static void RealDeleteCluster(char **info, Bool one_cluster)
 
 int DeleteCluster(int argc, char **argv)
 {
-  struct qelem *top;
+  struct mqelem *top;
 
   top = GetMCInfo(CLUSTER, argv[1], NULL);
   QueryLoop(top, PrintClusterInfo, RealDeleteCluster, "Delete the cluster");
@@ -1645,13 +1649,13 @@ int DeleteCluster(int argc, char **argv)
 
 int ShowClusterData(int argc, char **argv)
 {
-  struct qelem *elem, *top;
+  struct mqelem *elem, *top;
   char **info;
 
   top = elem = GetMCInfo(DATA, argv[1], argv[2]);
   while (elem)
     {
-      info = (char **) elem->q_data;
+      info = elem->q_data;
       PrintClusterData(info);
       elem = elem->q_forw;
     }
@@ -1671,8 +1675,7 @@ int AddClusterData(int argc, char **argv)
 {
   int stat;
 
-  if ((stat = do_mr_query("add_cluster_data", 3, argv + 1,
-                         Scream, (char *) NULL)))
+  if ((stat = do_mr_query("add_cluster_data", 3, argv + 1, NULL, NULL)))
     com_err(program_name, stat, " in AddClusterData.");
   return DM_NORMAL;
 }
@@ -1696,8 +1699,7 @@ static void RealRemoveClusterData(char **info, Bool one_item)
   PrintClusterData(info);
   if (!one_item || Confirm(temp_ptr))
     {
-      if ((stat = do_mr_query("delete_cluster_data", 3, info,
-                             Scream, (char *) NULL)))
+      if ((stat = do_mr_query("delete_cluster_data", 3, info, NULL, NULL)))
        {
          com_err(program_name, stat, " in DeleteClusterData.");
          Put_message("Data not removed.");
@@ -1717,7 +1719,7 @@ static void RealRemoveClusterData(char **info, Bool one_item)
 
 int RemoveClusterData(int argc, char **argv)
 {
-  struct qelem *top;
+  struct mqelem *top;
 
   top = GetMCInfo(DATA, argv[1], argv[2]);
   QueryLoop(top, PrintClusterData, RealRemoveClusterData,
@@ -1736,10 +1738,10 @@ int RemoveClusterData(int argc, char **argv)
 
 int MachineToClusterMap(int argc, char **argv)
 {
-  struct qelem *elem, *top;
+  struct mqelem *elem, *top;
   char *tmpname, temp_buf[256];
 
-  tmpname = canonicalize_hostname(strsave(argv[1]));
+  tmpname = canonicalize_hostname(strdup(argv[1]));
   if (strcasecmp(tmpname, argv[1]) && *argv[1] != '"')
     {
       sprintf(temp_buf, "Warning: '%s' canonicalized to '%s'.",
@@ -1751,7 +1753,7 @@ int MachineToClusterMap(int argc, char **argv)
   Put_message("");             /* blank line on screen */
   while (elem)
     {
-      char **info = (char **) elem->q_data;
+      char **info = elem->q_data;
       PrintMCMap(info);
       elem = elem->q_forw;
     }
This page took 0.078729 seconds and 4 git commands to generate.