]> andersk Git - moira.git/commitdiff
This version while still untested compiles and links almost
authorkit <kit>
Fri, 10 Jun 1988 18:36:10 +0000 (18:36 +0000)
committerkit <kit>
Fri, 10 Jun 1988 18:36:10 +0000 (18:36 +0000)
perfectly under saber C.  Worth saving a copy I think...

12 files changed:
clients/moira/attach.c
clients/moira/cluster.c
clients/moira/delete.c
clients/moira/globals.c
clients/moira/globals.h
clients/moira/lists.c
clients/moira/main.c
clients/moira/menus.c
clients/moira/nfs.c
clients/moira/user.c
clients/moira/utils.c
include/moira_site.h

index 0947fd06307869cc6528010d6770f9f4a780fe21..58522cd18b6d383c4961d42db5b680700f3ce9e8 100644 (file)
  *     see the file mit-copyright.h
  */
 
-#include "mit-copyright.h"
-#include "allmaint.h"
-#include "globals.h"
-#include "infodefs.h"
-
 #include <stdio.h>
 #include <strings.h>
 #include <sms.h>
 #include <menu.h>
 
+#include "mit-copyright.h"
+#include "allmaint.h"
+#include "allmaint_funcs.h"
+#include "globals.h"
+#include "infodefs.h"
+
 #define FS_ALIAS_TYPE "FILESYS"
 
-#define FS_NAME         0
-#define FS_TYPE         1
-#define FS_MACHINE      2
-#define FS_PACK         3
-#define FS_M_POINT      4
-#define FS_ACCESS       5
-#define FS_COMMENTS     6
-#define FS_OWNER        7
-#define FS_OWNERS       8
-#define FS_CREATE       9
-#define FS_L_TYPE       10
-#define FS_MODTIME      11
-#define FS_MODBY        12
-#define FS_MODWITH      13
-
-#define FS_LABEL        14
-/* FS_MACHINE already defined, this is okay, as there is no overlap. */
-#define FS_GROUP        15
+#define LABEL        0
+#define MACHINE      1
+#define GROUP        2
+#define ALIAS        3
 
 /*     Function Name: GetFSInfo
  *     Description: Stores the info in a queue.
@@ -70,32 +57,32 @@ char *name;
     char * args[2];
 
     switch (type) {
-    case FS_LABEL:
+    case LABEL:
        if ( (stat = sms_query("get_filesys_by_label", 1, &name,
                               StoreInfo, &elem)) != 0) {
-           com_err(whoami, stat, NULL);
+           com_err(program_name, stat, NULL);
            return(NULL);
        }
        break;
-    case FS_MACHINE:
-       if ( (stat = sms_query("get_filesys_by_label", 1, &name,
+    case MACHINE:
+       if ( (stat = sms_query("get_filesys_by_machine", 1, &name,
                               StoreInfo, &elem)) != 0) {
-           com_err(whoami, stat, NULL);
+           com_err(program_name, stat, NULL);
            return(NULL);
        }
        break;
-    case FS_GROUP:
-       if ( (stat = sms_query("get_filesys_by_label", 1, &name,
+    case GROUP:
+       if ( (stat = sms_query("get_filesys_by_group", 1, &name,
                               StoreInfo, &elem)) != 0) {
-           com_err(whoami, stat, NULL);
+           com_err(program_name, stat, NULL);
            return(NULL);
        }
        break;
-    case FS_ALIAS:
+    case ALIAS:
        args[0] = name;
        args[1] = FS_ALIAS_TYPE;
        if ( (stat = sms_query("get_alias", 2, args, StoreInfo, &elem)) != 0) {
-           com_err(whoami, stat, " in get_alias.");
+           com_err(program_name, stat, " in get_alias.");
            return(NULL);
        }
     }
@@ -109,7 +96,8 @@ char *name;
  *     Returns: none.
  */
 
-PrintFSInfo(info);
+void
+PrintFSInfo(info)
 char ** info;
 {
     char print_buf[BUFSIZ];
@@ -151,9 +139,9 @@ struct qelem * elem;
     struct qelem * local = elem;       
                                
     while(local != NULL) {
-       char ** info = (char **) local->q_date;
+       char ** info = (char **) local->q_data;
        PrintFSInfo(info);
-       local = local->next;
+       local = local->q_forw;
     }
 }
 
@@ -166,16 +154,14 @@ struct qelem * elem;
  *     Returns: none.
  */
 
-void
-AskFSInfo(info, flags);
+char **
+AskFSInfo(info, name)
 char ** info;
 Bool name;
 {
-    char * temp_buf, *newname;
-    char *ret_args[100];
-    int counter;
+    char temp_buf[BUFSIZ], *newname;
 
-    sprintf(temp_buf,"\nChanging Attributes of user %s.\n",info[NAME]);
+    sprintf(temp_buf, "\nChanging Attributes of user %s.\n", info[FS_NAME]);
     Put_message(temp_buf);
 
     if (name) {
@@ -222,7 +208,7 @@ char **argv;
 {
     struct qelem *elem;
 
-    elem = GetFSInfo();        /* get info. */
+    elem = GetFSInfo(LABEL, argv[1]); /* get info. */
     PrintAllFSInfo(elem);      /* print it all. */
     FreeQueue(elem);           /* clean the queue. */
     return (DM_NORMAL);
@@ -241,11 +227,12 @@ DeleteFS(argc, argv)
 int argc;
 char **argv;
 {
-    int stat, answer, delete, number;
+    int stat, answer, delete;
+    Bool one_filsys;
     struct qelem *elem, *temp_elem;
     
-    if ( (temp_elem = elem = GetFSInfo(FS_LABEL, argv[1],
-                            (char *) NULL) ) == NULL ) /* get info. */
+    if ( (temp_elem = elem = GetFSInfo(LABEL, argv[1])) == 
+                                         (struct qelem *) NULL )
        return(DM_NORMAL);
 /* 
  * 1) If there is no (zero) match then we exit immediately.
@@ -255,11 +242,11 @@ char **argv;
  *    about each one, and delete on yes only, and about if the user hits
  *    quit.
  */
-    number = QueueCount(elem);
+    one_filsys = (QueueCount(elem) == 1);
     while (temp_elem != NULL) {
        char **info = (char **) temp_elem->q_data;
        
-       if (number != 1) {
+       if (one_filsys) {
            PrintFSInfo(info);
        
            answer = YesNoQuitQuestion("\nDelete this filesys?", FALSE); 
@@ -278,21 +265,21 @@ char **argv;
        }
        else
            delete = 
-            Confirm("Are you sure that you want to delete this filsystem.")) 
+            Confirm("Are you sure that you want to delete this filsystem."); 
 /* 
  * Deletetions are  performed if the user hits 'y' on a list of multiple 
  * filesystem, or if the user confirms on a unique alias.
  */
        if (delete) {
-           if ( (status = sms_query("delete_filesys", 1,
-                                    &name, NullFunc, NULL)) != 0)
-               com_err(whoami, stat, " filesystem not deleted.");
+           if ( (stat = sms_query("delete_filesys", 1,
+                                    &info[FS_NAME], Scream, NULL)) != 0)
+               com_err(program_name, stat, " filesystem not deleted.");
            else
                Put_message("Filesystem deleted.");
        }
        else 
            Put_message("Filesystem not deleted.");
-       temp_elem = temp_elem->next;
+       temp_elem = temp_elem->q_forw;
     }
 
     FreeQueue(elem);           /* free all members of the queue. */
@@ -311,20 +298,21 @@ ChangeFS(argc, argv)
 char **argv;
 int argc;
 {
-    FS_info *info;
-    struct qelem * elem, temp_elem;
+    struct qelem *elem, *temp_elem;
     int update, stat, answer;
+    Bool one_filsys;
+    char buf[BUFSIZ];
     
-    elem = temp_elem = GetFSInfo(FS_LABEL, argv[1], (char *) NULL);
+    elem = temp_elem = GetFSInfo(LABEL, argv[1]);
 
 /* 
  * This uses the same basic method as the deletion routine above.
  */
 
-    number = QueueCount(elem);
+    one_filsys = (QueueCount(elem) == 1);
     while (temp_elem != NULL) {
        char ** info = (char **) temp_elem->q_data;
-       if (number != 1) {
+       if (one_filsys) {
            sprintf(buf, "%s %s %s (y/n/q)? ", "Would you like to change the",
                    "information about the filesystem:", 
                    info[FS_NAME]);
@@ -332,10 +320,10 @@ int argc;
            answer = YesNoQuitQuestion(buf, FALSE);
            switch(answer) {
            case TRUE:
-               update = TRUE
+               update = TRUE;
                break;
            case FALSE:
-               upadate = FALSE;
+               update = FALSE;
                break;
            default:
                Put_message("Aborting Operation.");
@@ -347,11 +335,10 @@ int argc;
            update = TRUE;
 
        if (update) {
-           char * args;
-           args = AskFSInfo(info, TRUE);
-           if ( (stat = sms_query("update_filesys", num_args, 
+           char ** args = AskFSInfo(info, TRUE);
+           if ( (stat = sms_query("update_filesys", CountArgs(args), 
                                   args, NullFunc, NULL)) != 0)
-               com_err(whoami, stat, " in filesystem not updated");
+               com_err(program_name, stat, " in filesystem not updated");
            else
                Put_message("filesystem sucessfully updated.");
        }
@@ -383,18 +370,18 @@ int argc;
                           NullFunc, NULL)) == 0) {
        Put_message ("A Filesystem by that name already exists.");
        return(DM_NORMAL);
-    } else if (status != SMS_NOMATCH) {
-       com_err(whoami, stat, " in AddFS");
+    } else if (stat != SMS_NO_MATCH) {
+       com_err(program_name, stat, " in AddFS");
        return(DM_NORMAL);
     } 
 
-    while (count = 0; count < 100; count++)
+    for (count = 0; count < 100; count++)
        info[count] = NULL;
     args = AskFSInfo(info, FALSE );
-    
+
     if (stat = sms_query("add_filesys", CountArgs(args), args, 
                         NullFunc, NULL) != 0)
-       com_err(whoami, stat, " in AddFS");
+       com_err(program_name, stat, " in AddFS");
 
     FreeInfo(info);
     return (DM_NORMAL);
@@ -416,16 +403,16 @@ GetFSAlias(argc, argv)
 int argc;
 char **argv;
 {
-    register int stat = 0;
     char **info, buf[BUFSIZ];
     struct qelem *top, *elem;
 
-    top = elem = GetFSInfo(FS_ALIAS, argv[1]);
+    top = elem = GetFSInfo(ALIAS, argv[1]);
 
     while (elem != NULL) {
        info = (char **) elem->q_data;
-       sprintf(buf,"Alias: %s\tFilesystem: %s",info[NAME], info[ALIAS_TRANS]);
-       putmessage(buf);
+       sprintf(buf,"Alias: %s\tFilesystem: %s",info[ALIAS_NAME], 
+               info[ALIAS_TRANS]);
+       Put_message(buf);
        elem = elem->q_forw;
     }
 
@@ -447,18 +434,17 @@ CreateFSAlias(argc, argv)
 int argc;
 char **argv;
 {
-    register int stat = 0;
+    register int stat;
     struct qelem *elem, *top;
-    char *args[3], buf[BUFSIZ], **info;
-    int num_args;
+    char *args[MAX_ARGS_SIZE], buf[BUFSIZ], **info;
 
     elem = NULL;
 
     if (!ValidName(argv[1]))
        return(DM_NORMAL);
 
-    args[0] = argv[1];
-    args[1] = FS_ALIAS_TYPE;
+    args[ALIAS_NAME] = Strsave(argv[1]);
+    args[ALIAS_TYPE] = Strsave(FS_ALIAS_TYPE);
 
 /*
  * Check to see if this alias already exists in the database, if so then
@@ -470,7 +456,7 @@ char **argv;
        while (elem != NULL) {
            info = (char **) elem->q_data;          
            sprintf(buf,"The alias: %s\tcurrently describes the filesystem %s",
-                   info[NAME], info[ALIAS_TRANS]);
+                   info[ALIAS_NAME], info[ALIAS_TRANS]);
            Put_message(buf);
            elem = elem->q_forw;
        }
@@ -478,18 +464,18 @@ char **argv;
        return(DM_NORMAL);
     }
     else if ( stat != SMS_NO_MATCH) {
-       com_err(whoami, stat, " in CreateFSAlias.");
+       com_err(program_name, stat, " in CreateFSAlias.");
         return(DM_NORMAL);
     }
 
-    args[ALIAS_TRANS] = NULL;  /* set to zero */
+    args[ALIAS_TRANS]= args[ALIAS_END] = NULL; /* set to NULL initially. */
     GetValueFromUser("Which filesystem will this alias point to?",
-                    args[ALIAS_TRANS]);
+                    &args[ALIAS_TRANS]);
 
     if ( (stat = sms_query("add_alias", 3, args, NullFunc, NULL)) != 0)
-       com_err(whoami, stat, " in CreateFSAlias.");
+       com_err(program_name, stat, " in CreateFSAlias.");
 
-    free(args[ALIAS_TRANS]);
+    FreeInfo(args);
     return (DM_NORMAL);
 }
 
@@ -508,14 +494,14 @@ int argc;
 char **argv;
 {
     register int stat;
-    char *args[3], buf[BUFSIZ], **info;
-    int num_args, delete;
+    char buf[BUFSIZ];
     struct qelem *elem, *top;
+    Bool one_alias, delete;
 
     if (!ValidName(argv[1]))
        return(DM_NORMAL);
 
-    top = elem = GetFSInfo(FS_ALIAS, argv[1]);
+    top = elem = GetFSInfo(ALIAS, argv[1]);
 
 /* 
  * 1) If there are no (zero) match in elements then we exit immediately.
@@ -525,18 +511,19 @@ char **argv;
  *    about each one, and delete on yes only, and about if the user hits
  *    quit.
  */
-    number = QueueCount(top);
+    one_alias = ( QueueCount(top) == 1 );
     while (elem != NULL) {
        char **info = (char **) elem->q_data;
 
-       if (number != 1) {
-           sprintf(buf, "%s %s for the filesystem %s.",
+       if (one_alias) {
+           int answer;
+
+           sprintf(buf, "%s %s for the filesystem %s? (y/n)",
                    "Confirm that you want to delete\n the alias",
-                   info[NAME], info[ALIAS_TRANS]);
+                   info[ALIAS_NAME], info[ALIAS_TRANS]);
            Put_message(buf);
            
-           answer = YesNoQuitQuestion("\nDelete this filesystem alias?", 
-                                      FALSE); 
+           answer = YesNoQuitQuestion(buf, FALSE); 
            switch(answer) {
            case TRUE:
                delete = TRUE;
@@ -560,9 +547,9 @@ char **argv;
  * filesystem aliases, or if the user confirms on a unique alias.
  */
        if (delete) {
-           if ( (status = sms_query("delete_filesys", 1,
-                                    &name, NullFunc, NULL)) != 0)
-               com_err(whoami, stat, " filesystem alias not deleted.");
+           if ( (stat = sms_query("delete_filesys", 1,
+                                    &info[ALIAS_NAME], Scream, NULL)) != 0)
+               com_err(program_name, stat, " filesystem alias not deleted.");
            else
                Put_message("Filesystem alias deleted.");
        }
@@ -571,7 +558,7 @@ char **argv;
        elem = elem->q_forw;
     }
 
-    FreeQueue(Top);
+    FreeQueue(top);
     return (DM_NORMAL);
 }
 
index 8d967ba32e84b5fdf265ea3f13a9cb0a8ce0ba94..7452c89c7025e52a9fb36dd471da4b91c21e5ba7 100644 (file)
 
 /* BTW: for anyone who cares MCD is short for Machine, Cluster, Data. */
 
-#include "mit-copyright.h"
-#include "allmaint.h"
-#include "globals.h"
-#include "infodefs.h"
-
 #include <stdio.h>
 #include <strings.h>
 #include <sms.h>
 #include <menu.h>
 
-#define MCD_MACHINE  0
-#define MCD_CLUSTER  1
-#define MCD_DATA     2
-#define MCD_MAP      3
+#include "mit-copyright.h"
+#include "allmaint.h"
+#include "allmaint_funcs.h"
+#include "globals.h"
+#include "infodefs.h"
 
-extern char *whoami;
-extern char * CanonicalizeHostname();
+#define MACHINE  0
+#define CLUSTER  1
+#define DATA     2
+#define MAP      3
 
 /*     Function Name: PrintMachInfo
  *     Description: This function Prints out the Machine info in 
@@ -74,7 +72,7 @@ char ** info;
     char buf[BUFSIZ];
 
     sprintf(buf, "Cluster: %s", info[C_NAME]);
-    Put_Message(buf);
+    Put_message(buf);
     sprintf(buf,"Description: %-20s, Location: %-20s", info[C_DESCRIPT], 
            info[C_LOCATION]);
     Put_message(buf);
@@ -94,11 +92,27 @@ PrintClusterData(info)
 char ** info;
 {
     char buf[BUFSIZ];
-    sprintf(buf, "Cluster: %-30s, Label: %-20s, Data: %-20s",
+    sprintf(buf, "Cluster: %-30s Label: %-20s Data: %-20s",
            info[CD_NAME], info[CD_LABEL], info[CD_DATA]);
     Put_message(buf);
 }
 
+/*     Function Name: PrintMCMap
+ *     Description: Prints the data about a machine to cluster mapping.
+ *     Arguments: info a pointer to the data array.
+ *     Returns: none
+ */
+
+void
+PrintMCMap(info)
+char ** info;
+{
+    char buf[BUFSIZ];
+    sprintf(buf, "Cluster: %-30s Machine: %-20s",
+           info[MAP_CLUSTER], info[MAP_MACHINE]);
+    Put_message(buf);
+}
+
 /*     Function Name: GetMCInfo.
  *     Description: This function stores info about a machine.
  *                   type - type of data we are trying to retrieve.
@@ -108,7 +122,7 @@ char ** info;
  */
 
 struct qelem *
-StoreMCInfo(type, name1, name2)
+GetMCInfo(type, name1, name2)
 int type;
 char * name1, *name2;
 {
@@ -118,70 +132,70 @@ char * name1, *name2;
     char * args[2];
 
     switch (type) {
-    case MCD_MACHINE:
+    case MACHINE:
        if ( (stat = sms_query("get_machine", 1, &name1,
                               StoreInfo, &elem)) != 0) {
-           com_err(whoami, stat, " in get_machine.");
+           com_err(program_name, stat, " in get_machine.");
            return(NULL);
        }
        break;
-    case MCD_CLUSTER:
+    case CLUSTER:
        if ( (stat = sms_query("get_cluster",  1, &name1,
                               StoreInfo, &elem)) != 0) {
-           com_err(whoami, stat, " in get_cluster.");
+           com_err(program_name, stat, " in get_cluster.");
            return(NULL);
        }
        break;
-    case MCD_MAP:
-       args[0] = name1;
-       args[1] = name2;
+    case MAP:
+       args[MAP_MACHINE] = name1;
+       args[MAP_CLUSTER] = name2;
        if ( (stat = sms_query("get_machine_to_cluster_map", 2, args,
                               StoreInfo, &elem)) != 0) {
-           com_err(whoami, stat, " in get_machine_to_cluster_map.");
+           com_err(program_name, stat, " in get_machine_to_cluster_map.");
            return(NULL);
        }
        break;
-    case MCD_DATA:
-       args[0] = name1;
-       args[1] = name2;
+    case DATA:
+       args[CD_NAME] = name1;
+       args[CD_LABEL] = name2;
        if ( (stat = sms_query("get_cluster_data", 2, args,
                               StoreInfo, &elem)) != 0) {
-           com_err(whoami, stat, " in get_cluster_data.");
+           com_err(program_name, stat, " in get_cluster_data.");
            return(NULL);
        }
     }
     return(QueueTop(elem));
 }
 
-/*     Function Name: AskInfo.
+/*     Function Name: AskMCDInfo.
  *     Description: This function askes the user for information about a 
  *                   machine and saves it into a structure.
  *     Arguments: info - a pointer the information to ask about
- *                 type - type of information - MCD_MACHINE
- *                                              MCD_CLUSTER
- *                                              MCD_DATA
+ *                 type - type of information - MACHINE
+ *                                              CLUSTER
+ *                                              DATA
  *                 name - T/F : change the name of this type.
  *     Returns: none.
  */
 
-void
-AskInfo(mcs_info, type, name);
-char ** mcs_info;
+char **
+AskMCDInfo(info, type, name)
+char ** info;
 int type;
 Bool name;
 {
-    char * temp_buf;
+    char temp_buf[BUFSIZ], *newname;
 
     switch (type) {
-    case MCD_MACHINE:
+    case MACHINE:
        sprintf(temp_buf, "Changing the information for the Machine %s.",
                name);
        break;
-    case MCD_CLUSTER:
+    case CLUSTER:
        sprintf(temp_buf, "Changing the information for the Cluster %s.",
                name);
        break;
-    case MCD_DATA:
+    case DATA:
        sprintf(temp_buf, "Changing the Data for the Cluster %s.",
                name);
        break;
@@ -189,39 +203,40 @@ Bool name;
     Put_message(temp_buf);
 
     if (name) {
-       info[NEWNAME] = Strsave(info->name);
        switch (type) {
-       case MCD_MACHINE:
+       case MACHINE:
+           newname = Strsave(info[M_NAME]);
            GetValueFromUser("The new name for this machine? ",
-                            info[M_NEWNAME]);
+                            &newname);
            break;
-       case MCD_CLUSTER:
+       case CLUSTER:
+           newname = Strsave(info[C_NAME]);
            GetValueFromUser("The new name for this cluster? ",
-                            info[C_NEWNAME]);
+                            &newname);
            break;
        default:
-           Put_message("Unknown type in AskInfo, programmer botch");
-           return;
+           Put_message("Unknown type in AskMCDInfo, programmer botch");
+           return(NULL);
        }
     }
 
     switch(type) {
-    case MCD_MACHINE:
-       GetValueFromUser("Machine's Type:",info[M_TYPE]);
+    case MACHINE:
+       GetValueFromUser("Machine's Type:", &info[M_TYPE]);
        FreeAndClear(&info[M_MODTIME], TRUE);
        FreeAndClear(&info[M_MODBY], TRUE);
        FreeAndClear(&info[M_MODWITH], TRUE);
        break;
-    case MCD_CLUSTER:
-       GetValueFromUser("Cluster's Description:",info[C_DESCRIPT]);
-       GetValueFromUser("Cluster's Location:",info[C_LOCATION]);
+    case CLUSTER:
+       GetValueFromUser("Cluster's Description:", &info[C_DESCRIPT]);
+       GetValueFromUser("Cluster's Location:", &info[C_LOCATION]);
        FreeAndClear(&info[C_MODTIME], TRUE);
        FreeAndClear(&info[C_MODBY], TRUE);
        FreeAndClear(&info[C_MODWITH], TRUE);
        break;
-    case MCD_DATA:
-       GetValueFromUser("Label defining this data?",info[CD_LABEL]);
-       GetValueFromUser("The data itself ? ",info[CD_DATA]);
+    case DATA:
+       GetValueFromUser("Label defining this data?", &info[CD_LABEL]);
+       GetValueFromUser("The data itself ? ", &info[CD_DATA]);
        break;
     }
 
@@ -252,7 +267,8 @@ char **argv;
     char **info;
     struct qelem *elem, *top;
 
-    top = elem = GetMCInfo(  CanonicalizeHostname(argv[1]), MCD_MACHINE);
+    top = elem = GetMCInfo(MACHINE, CanonicalizeHostname(argv[1]),
+                          (char *) NULL);
 
     while (elem != NULL) {
        info = (char **) elem->q_data;
@@ -287,21 +303,21 @@ char **argv;
        Put_message("This machine already exists.");
        return(DM_NORMAL);
     }
-    else if (stat != SMS_NOMATCH) {
-       com_err(whoami, status, " in AddMachine.");
+    else if (stat != SMS_NO_MATCH) {
+       com_err(program_name, stat, " in AddMachine.");
        return(DM_NORMAL);
     }
 
     info[0] = name;
-    args = AskMCDInfo(info, MCD_MACHINE, FALSE);
+    args = AskMCDInfo(info, MACHINE, FALSE);
 
 /*
  * Actually create the new Machine.
  */
     
     if ( (stat = sms_query("add_machine", CountArgs(args), 
-                          args, NullFunc, NULL)) != 0)
-       com_err(whoami, status, " in AddMachine.");
+                          args, Scream, NULL)) != 0)
+       com_err(program_name, stat, " in AddMachine.");
 
     FreeInfo(info);
     return(DM_NORMAL);
@@ -319,17 +335,19 @@ UpdateMachine(argc, argv)
 int argc;
 char **argv;
 {
-    char **args, **info;
+    struct qelem *elem, *top;
     int stat;
     
-    elem = top = GetMCDInfo( MCD_MACHINE,  CanonicalizeHostname(argv[1]) );
+    elem = top = GetMCInfo( MACHINE,  CanonicalizeHostname(argv[1]),
+                          (char *) NULL);
 
     while (elem != NULL) {
-       info = (char **) elem->q_data;
-       args = AskMCDInfo(info, MCD_MACHINE, TRUE);
+       char ** args;
+       char ** info = (char **) elem->q_data;
+       args = AskMCDInfo(info, MACHINE, TRUE);
        if ( (stat = sms_query("update_machine", CountArgs(args), 
                               args, Scream, NULL)) != 0)
-           com_err(whoami, status, " in UpdateMachine.");
+           com_err(program_name, stat, " in UpdateMachine.");
        elem = elem->q_forw;
     }
 
@@ -345,38 +363,50 @@ char **argv;
 
 /* ARGSUSED */
 int
-DeleteMachine(argc,argv)
+DeleteMachine(argc, argv)
 int argc;
 char **argv;
 {
     int stat;
-    char * args[2], *name;
+    char * args[2], *name, temp_buf[BUFSIZ];
+    struct qelem *top, *elem = NULL;
 
     name =  CanonicalizeHostname(argv[1]);
 
 /* Should probabally check for wildcards, none allowed. */
 /* Perhaps we should remove the cluster if it has no machine now. */
 
-    args[0] = argv[1];
+    args[0] = name;
     args[1] = "*";
-    stat = sms_query("get_machine_to_cluster_map", 2, args, Null, NULL);
-    if (stat != SMS_NO_MATCH) {
-       sprintf(temp_buf, "%s is assigned to cluster %s.",args[0], args[1]);
-       Put_message(temp_buf);
-       if ( YesNoQuestion("Would you like to remove it from this cluster?",
-                          FALSE)) {
-           if ( (stat = sms_query( "delete_machine_from_cluster",
-                                1, args, Null, NULL)) != 0)
-               com_err(whoami, status, " in DeleteMachine.");
-       }
-       else {
-           Put_message("Aborting...");
-           return(DM_NORMAL);
+    stat = sms_query("get_machine_to_cluster_map", 2, args, StoreInfo, &elem);
+    if (stat && stat != SMS_NO_MATCH) {
+       com_err(program_name, stat, " in DeleteMachine.");
+       return(DM_NORMAL);
+    }
+    if (stat == 0) {
+       top = elem;
+       while (elem != NULL) {
+           sprintf(temp_buf, "%s is assigned to cluster %s.",
+                   args[0], args[1]);
+           Put_message(temp_buf);
+           if ( YesNoQuestion(
+                 "Would you like to remove it from this cluster?", FALSE)) {
+               if ( (stat = sms_query( "delete_machine_from_cluster",
+                                      1, args, Scream, NULL)) != 0)
+                   com_err(program_name, stat, 
+                           " in delete_machine_from_cluster.");
+               else {
+                   Put_message("Aborting...");
+                   FreeQueue(top);
+                   return(DM_NORMAL);
+               }
+           }
+           elem = elem->q_forw;
        }
     }
     if(Confirm("Are you sure that you want to delete this machine?")) {
-       if ( (stat = sms_query("delete_machine", 1, &name, Null, NULL)) != 0)
-           com_err(whoami, status, " in DeleteMachine.");
+       if ( (stat = sms_query("delete_machine", 1, &name, Scream, NULL)) != 0)
+           com_err(program_name, stat, " in DeleteMachine.");
     }
     else 
        Put_message("Operation aborted.");
@@ -399,9 +429,9 @@ char ** argv;
 {
     int stat;
 
-    if ( (stat = sms_query("add_machine_to_cluster", 2, args + 1,
+    if ( (stat = sms_query("add_machine_to_cluster", 2, argv + 1,
                                  Scream, NULL) != 0))
-       com_err(whoami, status, " in AddMachineToCluster.");
+       com_err(program_name, stat, " in AddMachineToCluster.");
 
     return(DM_NORMAL);
 }
@@ -420,13 +450,13 @@ char ** argv;
 {
     int stat, ans;
     struct qelem *elem, *top;
-    char ** info;
+    char ** info, buf[BUFSIZ];
     
-    elem = top = GetMCDInfo(MCD_CLUSTER,  CanonicalizeHostname(argv[1]), "*");
+    elem = top = GetMCInfo(CLUSTER,  CanonicalizeHostname(argv[1]), "*");
 
     Put_message("This machine is the following clusters:");
     while (elem != NULL) {
-       info = (char *) elem->q_data;
+       info = (char **) elem->q_data;
        Put_message(info[MAP_CLUSTER]);
        elem = elem->q_forw;
     }
@@ -434,23 +464,23 @@ char ** argv;
 
     if ( Confirm("Remove this machine from ** ALL ** these clusters?") ) {
        while (elem != NULL) {  /* delete all */
-           info = (char *) elem->q_data;        
+           info = (char **) elem->q_data;       
            if ( (stat =sms_query("delete_machine_from_cluster", 2, 
                                  info, Scream, NULL)) != 0 )
-               com_err(whoami, stat, " in delete_machine_from_cluster");
+               com_err(program_name, stat, " in delete_machine_from_cluster");
            elem = elem->q_forw;
        }
     }
     else 
        while (elem != NULL) {  /* query delete. */
-           info = (char *) elem->q_data;       
+           info = (char **) elem->q_data;      
            sprintf(buf, "Remove %13s from the cluster %30s? (y/n/q)", 
                    info[MAP_MACHINE], info[MAP_CLUSTER]);
            ans = YesNoQuitQuestion(buf, FALSE);
            if (ans == TRUE) 
                if ( (stat =sms_query("delete_machine_from_cluster", 2, 
                                      info, Scream, NULL)) != 0 )
-                   com_err(whoami, stat, " in delete_machine_from_cluster");
+                   com_err(program_name, stat, " in delete_machine_from_cluster");
            else if (ans != FALSE) /* quit. or ^C */
                break;
            elem = elem->q_forw;
@@ -470,14 +500,15 @@ char ** argv;
 
 /* ARGSUSED */
 int
-ShowClusterInfo(argc, argv);
+ShowClusterInfo(argc, argv)
 int argc;
 char ** argv;
 {
     char **info;
     struct qelem *elem, *top;
 
-    top = elem = GetMCInfo(argv[1], MCD_MACHINE);
+    top = elem = GetMCInfo( MACHINE, CanonicalizeHostname(argv[1]),
+                          (char *) NULL);
     while (elem != NULL) {
        info = (char **) elem->q_data;
        PrintClusterInfo(info);
@@ -510,13 +541,13 @@ char ** argv;
        Put_message("This cluster already exists.");
        return(DM_NORMAL);
     }
-    else if (stat != SMS_NOMATCH) {
-       com_err(whoami, status, " in AddCluster.");
+    else if (stat != SMS_NO_MATCH) {
+       com_err(program_name, stat, " in AddCluster.");
        return(DM_NORMAL);
     }
 
     info[0] = name;
-    args = AskMCDInfo(info, MCD_CLUSTER, FALSE);
+    args = AskMCDInfo(info, CLUSTER, FALSE);
 
 /*
  * Actually create the new Cluster.
@@ -524,7 +555,7 @@ char ** argv;
     
     if ( (stat = sms_query("add_cluster", CountArgs(args), 
                           args, Scream, NULL)) != 0)
-       com_err(whoami, status, " in AddCluster.");
+       com_err(program_name, stat, " in AddCluster.");
 
     FreeInfo(info);
     return(DM_NORMAL);
@@ -546,14 +577,14 @@ char ** argv;
     char **args, **info;
     int stat;
     
-    elem = top = GetMCDInfo( MCD_Cluster, argv[1], (char *) NULL );
+    elem = top = GetMCInfo( CLUSTER, argv[1], (char *) NULL );
 
     while (elem != NULL) {
        info = (char **) elem->q_data;
-       args = AskMCDInfo(info, MCD_CLUSTER, TRUE);
+       args = AskMCDInfo(info, CLUSTER, TRUE);
        if ( (stat = sms_query("update_cluter", CountArgs(args), 
                               args, Scream, NULL)) != 0)
-           com_err(whoami, status, " in UpdateCluster.");
+           com_err(program_name, stat, " in UpdateCluster.");
        elem = elem->q_forw;
     }
 
@@ -569,22 +600,28 @@ char ** argv;
 
 /* ARGSUSED */
 int
-DeleteCluster(argc, argv);
+DeleteCluster(argc, argv)
 int argc;
 char ** argv;
 {
-    char * args[3];
+    char * args[3], temp_buf[BUFSIZ];
+    int stat;
 
 /* Should probabally check for wildcards, none allowed. */
 
     args[MAP_MACHINE] = "*";
     args[MAP_CLUSTER] = argv[1];
 
-    stat = sms_query("get_machine_to_cluster_map", 2, args, NullFunc, NULL);
+    stat = sms_query("get_machine_to_cluster_map", 2, args, 
+                    NullFunc, (char *) NULL);
+    if (stat & stat != SMS_NO_MATCH) {
+       com_err(program_name, stat, " in DeleteCluster.");
+       return(DM_NORMAL);
+    }
     if (stat != SMS_NO_MATCH) {
-       sprintf(temp_buf, "Cluster %s still has machines in it.",args[0]);
+       sprintf(temp_buf, "Cluster %s still has machines in it.",argv[1]);
        Put_message(temp_buf);
-       if ( YesNoQuestion("Would you like a list? (y/n)") == TRUE ) {
+       if ( YesNoQuestion("Would you like a list? (y/n)", TRUE) == TRUE ) {
            args[0] = "foo";    /* not used. */
            args[1] = "*";
            args[2] = argv[1];
@@ -595,7 +632,7 @@ char ** argv;
     if(Confirm("Are you sure that you want to delete this cluster? ")) {
        if ( (stat = sms_query("delete_cluster", 
                               1, &args[MAP_CLUSTER], Scream, NULL)) != 0)
-           com_err(whoami, status, " in DeleteCluster.");
+           com_err(program_name, stat, " in DeleteCluster.");
     }
     else 
        Put_message("Operation aborted.");
@@ -608,7 +645,7 @@ char ** argv;
 /*     Function Name: ShowClusterData
  *     Description: This function shows the services for one cluster.
  *     Arguments: argc, argv - The name of the cluster is argv[1].
- *                              The name of the data in argv[2].
+ *                              The label of the data in argv[2].
  *     Returns: DM_NORMAL.
  */
 
@@ -620,11 +657,11 @@ char ** argv;
     struct qelem *elem, *top;
     char **info;
 
-    top = elem = GetMCDInfo(MCD_DATA, argv[1], argv[2]);
+    top = elem = GetMCInfo(DATA, argv[1], argv[2]);
     while (elem != NULL) {
        info = (char **) elem->q_data;
        PrintClusterData(info);
-       elem = elem->data;
+       elem = elem->q_forw;
     }
     FreeQueue(top);
     return(DM_NORMAL);
@@ -644,14 +681,16 @@ AddClusterData(argc, argv)
 int argc; 
 char ** argv; 
 { 
+    int stat;
+
     if( (stat = sms_query("add_cluster_data", 3, argv + 1,
                          Scream, (char *) NULL)) != 0)
-       com_err(whoami, status, " in AddClusterData.");
+       com_err(program_name, stat, " in AddClusterData.");
 
 }
 
-/*     Function Name: DeleteClusterData
- *     Description: This function deletes a service
+/*     Function Name: RemoveClusterData
+ *     Description: This function removes data on a given cluster.
  *     Arguments: argv, argc:   argv[1] - the name of the cluster.
  *                               argv[2] - the label of the data.
  *                               argv[3] - the data.
@@ -659,7 +698,8 @@ char ** argv;
  */
 
 /* ARGSUSED */
-int DeleteClusterData(argc, argv)
+int 
+RemoveClusterData(argc, argv)
 int argc; 
 char ** argv; 
 {
@@ -668,7 +708,7 @@ char ** argv;
     if(Confirm("Do you really want to delete this data?")) {
        if( (stat = sms_query("delete_cluster_data", 3, argv + 1,
                              Scream, (char *) NULL)) != 0)
-           com_err(whoami, status, " in DeleteClusterData.");
+           com_err(program_name, stat, " in DeleteClusterData.");
     } else 
        Put_message("Operation aborted.\n");
 
@@ -690,15 +730,37 @@ MachineToClusterMap(argc,argv)
 int argc;
 char **argv;
 {
-  int stat;
+    struct qelem *elem, *top;
 
-  argv[1] =  CanonicalizeHostname(argv[1]);
+    top = elem = GetMCInfo(MAP, CanonicalizeHostname(argv[1]), argv[2]);
   
-  if (stat = sms_query("get_machine_to_cluster_map", 
-                   argc-1, argv+1, Print, NULL) != 0)
-      com_err(whoami, qstat, NULL);
+    while (elem != NULL) {
+       char ** info = (char **) elem->q_data;
+       PrintMCMap(info);
+       elem = elem->q_forw;
+    }
+
+    FreeQueue(top);
+    return(DM_NORMAL);
+}
 
-  return(DM_NORMAL);
+/*     Function Name: MachinesInCluster
+ *     Description: Shows all machines in a give cluster.
+ *     Arguments: argv, argc - name of cluster in argv[1].
+ *     Returns: DM_NORMAL;
+ */
+
+/* ARGSUSED */
+int
+MachinesInCluster(argv,argc)
+int argc;
+char **argv;
+{
+    char *info[10];
+    info[0] = argv[0];
+    info[2] = argv[1];
+    info[1] = "*";
+    return(MachineToClusterMap(3, info));
 }
 
 /* 
index 7d67cb84f65f379f9a86298c1e03aff019d9543d..ef25d034cbe75f29b44583ad1519167ce279d29a 100644 (file)
  *     see the file mit-copyright.h
  */
 
-#include "mit-copyright.h"
-#include "allmaint.h"
-#include "globals.h"
-#include "infodefs.h"
-
 #include <stdio.h>
 #include <strings.h>
 #include <sms.h>
 #include <menu.h>
 
-int DeleteList(), DeleteUser();
-static int RealDeleteList() RealDeleteUser();
+#include "mit-copyright.h"
+#include "allmaint.h"
+#include "allmaint_funcs.h"
+#include "globals.h"
+#include "infodefs.h"
+
+static int RealDeleteList(), RealDeleteUser();
 
 /*     Function Name: CheckListForDeletion
  *     Description: Check one of the lists in which we just removed a member.
@@ -45,26 +45,32 @@ CheckListForDeletion(name, verbose)
 char * name;
 Bool verbose;
 {
-    qelem *elem = NULL;
-    int status;
-    char *args[2], buf[BUFSIZ];
+    struct qelem *elem = NULL;
+    int status, ans;
+    char *args[2], buf[BUFSIZ], **info;
 
     if ( (status = sms_query("count_members_of_list", 1, &name, StoreInfo,
                             (char *) &elem)) != 0) {
-       com_err(whoami, status, " in DeleteList (count_members_of_list).");
-       return();
+       com_err(program_name, status, 
+               " in DeleteList (count_members_of_list).");
+       return;
     }
-    if (verbose) {
-       sprintf(buf, "Delete the empty list %s? ",name);
-       ans = YesNoQuestion(buf, TRUE);
-       if (ans != TRUE) {
-           Put_message("Aborting Deletion!");
-           return();
+    info = (char **) elem->q_data;
+    if (info[0] == 0) {
+       if (verbose) {
+           sprintf(buf, "Delete the empty list %s? ", name);
+           ans = YesNoQuestion(buf, TRUE);
+           if (ans != TRUE) {
+               Put_message("Aborting Deletion!");
+               FreeQueue(elem);
+               return; 
+           }
        }
+       args[0] = "foo";                /* not used. */
+       args[1] = name;
+       DeleteList(2, args);
     }
-    args[0] = "foo";           /* not used. */
-    args[1] = name;
-    DeleteList(2, args);
+    FreeQueue(elem);
 }
 
 /*     Function Name: CheckAcl
@@ -81,22 +87,24 @@ char * type, *name;
 Bool verbose;
 {
     char *args[2], buf[BUFSIZ];
+    int status, ans;
 
-    if ( strcmp(type,"LIST") != 0 ) 
-       return();               /* If the acl is not a list the ignore it. */
+    if ( strcmp(type, "LIST") != 0 ) 
+       return;         /* If the acl is not a list the ignore it. */
  
     args[0] = type;
     args[1] = name;
     status = sms_query("get_acl_use", 2, args, NullFunc,  (char *) NULL);
     if (status != SMS_NO_MATCH)
-       return();               /* if this query fails the acl will
-                                not be deleted even if it is empty. */
+       return;                 /* If this query fails the acl will
+                                  not be deleted even if it is empty. */
     if (verbose) {
        sprintf(buf, "Delete the unused Access Control List (ACL) %s? ", name);
        ans = YesNoQuestion(buf, TRUE);
        if (ans != TRUE) {
-       Put_message("Aborting Deletion!");
-           return();
+           Put_message("Aborting Deletion!");
+           return;
+       }
     }
 /*
  * Delete the ACL.
@@ -118,11 +126,12 @@ Bool verbose;
 
 int
 CheckIfAcl(name, type, verbose)
-char * name, type;
+char * name, type;
 Bool verbose;
 {
     char * args[2], buf[BUFSIZ];
-    qelem *elem, *local;
+    struct qelem *elem, *local;
+    int status;
     elem = NULL;
 
     args[0] = type;
@@ -133,17 +142,17 @@ Bool verbose;
        return(SUB_NORMAL);
 
     if (status != 0) {
-       com_err(whoami, status, " in CheckIfAcl (get_acl_use).");
+       com_err(program_name, status, " in CheckIfAcl (get_acl_use).");
        return(SUB_ERROR);
     }  
     if (verbose) {
-       sprintf(buf, "%s %s %s %s", type, list_name,
+       sprintf(buf, "%s %s %s %s", type, name,
                "is the Access Control List (ACL) for the following data",
                "objects:\n");
        Put_message(buf);
        local = elem;
        while (local != NULL) {
-           info = (char **) local->q_data;
+           char ** info = (char **) local->q_data;
            Print( QueueCount(elem), info, NULL);
            local = local->q_forw;
        }
@@ -153,7 +162,6 @@ Bool verbose;
     }
     FreeQueue(elem);
     return(SUB_ERROR);
-    }
 }
 
 /*     Function Name: RemoveItemFromLists
@@ -166,12 +174,14 @@ Bool verbose;
  */
 
 int
-RemoveItemFromLists(name, type, elem, verbose);
-char * name, type;
-qelem ** elem;
+RemoveItemFromLists(name, type, elem, verbose)
+char * name, *type;
+struct qelem ** elem;
 int verbose;
 {
-    char *args[2];
+    struct qelem *local;
+    char *args[2], temp_buf[BUFSIZ];
+    int status, ans;
     
     args[0] = type;
     args[1] = name;
@@ -188,7 +198,7 @@ int verbose;
        return(SUB_NORMAL);
 
     if (status != 0) { 
-       com_err(whoami, status, " in DeleteList (get_lists_of_member).");
+       com_err(program_name, status, " in DeleteList (get_lists_of_member).");
        return(SUB_ERROR);
     }
 
@@ -199,17 +209,17 @@ int verbose;
 
     if (verbose) {
        sprintf(temp_buf, "%s %s is a member of %d other list(s).\n", type,
-               name, QueueCount(member_of) );
-       Put_message(buf);
+               name, QueueCount(*elem) );
+       Put_message(temp_buf);
        local = *elem;
        while (local != NULL) {
-           info = (char **) local->q_data;
+           char ** info = (char **) local->q_data;
            Print( CountArgs(info), info, NULL);
            local = local->q_forw;
        }
-       sprintf(buf,"Remove %s %s from these lists? ", type, name);
-       ans = YesNoQuestion(buf, TRUE);
-       if (ans < 0 || answer == FALSE) {
+       sprintf(temp_buf,"Remove %s %s from these lists? ", type, name);
+       ans = YesNoQuestion(temp_buf, TRUE);
+       if (ans < 0 || ans == FALSE) {
            Put_message("Aborting...");
            FreeQueue(*elem);
            return(SUB_ERROR);
@@ -224,11 +234,11 @@ int verbose;
     args[1] = name;
     args[2] = type;
     while (local != NULL) {
-       info = (char **) local->q_data;
+       char ** info = (char **) local->q_data;
        args[0] = info[0];
        if ( (status = sms_query("delete_member_from_list",
                                 3, args, Scream, NULL)) != 0) {
-           com_err(whoami, status, " in delete_member\nAborting\n");
+           com_err(program_name, status, " in delete_member\nAborting\n");
            FreeQueue(*elem);
            return(SUB_ERROR);
        }
@@ -245,25 +255,25 @@ int verbose;
  */
 
 int
-RemoveMembersOfList(name, verbose);
+RemoveMembersOfList(name, verbose)
 char * name;
 Bool verbose;
 {
-    char buf[BUFSIZ], **info;
-    qelem *local, *elem;
+    char buf[BUFSIZ], *args[10];
+    struct qelem *local, *elem = NULL;
+    int status, ans;
 
 /* 
  * Get the members of this list.
  */
 
-    *elem = NULL;
     status = sms_query("get_members_of_list", 1, &name, StoreInfo,
                       (char *) &elem);
-    if (status == SMS_NOMATCH) 
-       return(SUB_NORM);
+    if (status == SMS_NO_MATCH) 
+       return(SUB_NORMAL);
 
     if (status != 0) { 
-       com_err(whoami, status, " in DeleteList (get_members_of_list).");
+       com_err(program_name, status, " in DeleteList (get_members_of_list).");
        return(SUB_ERROR);
     }
 
@@ -272,19 +282,19 @@ Bool verbose;
  */
 
     if (verbose) {
-       sprintf(buf, "List %s has %d member(s):", name, QueueCount(members) );
+       sprintf(buf, "List %s has %d member(s):", name, QueueCount(elem) );
        Put_message(buf);
        local = elem;
        while (local != NULL) {
-           info = (char **) local->q_data;
+           char ** info = (char **) local->q_data;
            Print( CountArgs(info), info, NULL);
            local = local->q_forw;
        }
        sprintf(buf, "Remove these member(s) from list %s? ", name);
-       ans = YesNoQuestion(temp_buf, TRUE);
-       if (ans < 0 || answer == FALSE) {
+       ans = YesNoQuestion(buf, TRUE);
+       if (ans < 0 || ans == FALSE) {
            Put_message("Aborting...");
-           FreeQueue(elem)
+           FreeQueue(elem);
            return(SUB_ERROR);
        }
     }
@@ -296,12 +306,12 @@ Bool verbose;
     local = elem;
     args[0] = name; 
     while (local != NULL) {
-       info = (char **) local->q_data;
+       char ** info = (char **) local->q_data;
        args[1] = info[0];
        args[2] = info[1];
        if ( (status = sms_query("delete_member_from_list",
                                 3, args, Scream, NULL)) != 0) {
-           com_err(whoami, status, " in delete_member\nAborting\n");
+           com_err(program_name, status, " in delete_member\nAborting\n");
            FreeQueue(elem);
            return(SUB_ERROR);
        }
@@ -326,7 +336,7 @@ char * name;
 Bool verbose;
 {
     int status, ans;
-    char buf[BUFSIZ];
+    char buf[BUFSIZ], *args[10];
 
     status = sms_query("get_list_info", 1, &name, NullFunc, (char *) NULL);
     if (status == 0) {
@@ -335,7 +345,7 @@ Bool verbose;
            ans = YesNoQuestion(buf, TRUE);
            if (ans == FALSE) {
                Put_message("Leaving group alone.");
-               return(SBU_NORMAL);
+               return(SUB_NORMAL);
            }
            if (ans < 0) {
                Put_message("Aborting...\n");
@@ -348,9 +358,10 @@ Bool verbose;
            DeleteList(2, args);
     }
     else if (status != SMS_NO_MATCH) {
-       com_err(whoami, status, " Aborting Delete User.");      
+       com_err(program_name, status, " Aborting Delete User.");        
        return(SUB_ERROR);
     }
+    return(SUB_NORMAL);
 }
 
 /*     Function Name: DeleteHomeFilesys
@@ -370,7 +381,7 @@ Bool verbose;
     
     status = sms_query("get_filesystem_by_label", 1, &name, NullFunc, 
                       (char *) NULL);
-    if (status == SMS_NOMATCH)
+    if (status == SMS_NO_MATCH)
        return(SUB_NORMAL);
     if (status == 0) {
        if (verbose) {
@@ -378,17 +389,17 @@ Bool verbose;
            ans = YesNoQuestion(buf, TRUE);
            if (ans != TRUE) {
                Put_message("Filesystem Not Deleted, aborting...\n\n");
-               return(SMS_ERROR);
+               return(SUB_ERROR);
            }
        }
        if ( (status = sms_query("delete_filesystem", 1, &name, Scream,
                                 (char *) NULL) ) != 0) {
-           com_err(whoami, status, " in delete_filesystem).");
+           com_err(program_name, status, " in delete_filesystem).");
            return(SUB_ERROR);
        }
        return(SUB_NORMAL);
     }
-    com_err(whoami, status, " in get_filesystem_by_label).");
+    com_err(program_name, status, " in get_filesystem_by_label).");
     return(SUB_ERROR);
 }
 
@@ -405,15 +416,15 @@ char * name;
 int verbose;
 {
     int status, ans;
-    char buf[BUFSIZ];
-    struct qelem *;
+    char buf[BUFSIZ], *args[10];
+    struct qelem *local, *elem = NULL;
     
     status = sms_query("get_nfs_quotas_by_user", 1, &name, StoreInfo, 
                       (char *) &elem);
     if (status == SMS_NO_MATCH)
        return(SUB_NORMAL);
     if (status != 0) {
-       com_err(whoami, status, " in delete_filesystem.");
+       com_err(program_name, status, " in delete_filesystem.");
        return(SUB_ERROR);
     }
     if (verbose) {
@@ -421,7 +432,7 @@ int verbose;
        Put_message(buf);
        local = elem;
        while (local != NULL) {
-           info = (char **) local->q_data;
+           char ** info = (char **) local->q_data;
            sprintf(buf, "Filesystem:\t%s\t\tQuota(in Kb):\t%s",
                    info[0], info[4]);
            Put_message(buf);
@@ -437,7 +448,7 @@ int verbose;
     local = elem;
     args[1] = name;
     while (local != elem) {
-       info = (char **) local->q_data;
+       char ** info = (char **) local->q_data;
        args[0] = info[0];
        status = sms_query("delete_nfs_quota", 2, args, Scream, (char *) NULL);
        if (status != 0 && status != SMS_NO_MATCH) {
@@ -445,11 +456,11 @@ int verbose;
                    "Could not remove quota on filesystem %s. ** ABORTING **",
                    args[0]);
            Put_message(buf);
-           com_err(whoami, status, (char *) NULL);
+           com_err(program_name, status, (char *) NULL);
            FreeQueue(elem);
            return(SUB_ERROR);
        }
-       local = local->normal;
+       local = local->q_forw;
     }
     FreeQueue(elem);
     return(SUB_NORMAL);
@@ -466,9 +477,9 @@ DeleteList(argc, argv)
 int argc;
 char *argv[];
 {
-    char buf[BUFSIZ], *args[2], *list;
-    struct qelem *elem, *local, *member_of, *list_info;
-    int ans, status;
+    char *list, **info;
+    struct qelem *local, *member_of, *list_info;
+    int status;
 
     member_of = list_info = NULL;
 
@@ -480,7 +491,7 @@ char *argv[];
  */
     if ( (status = sms_query("get_list_info", 1, &list, StoreInfo, 
                       (char *) &list_info)) != 0) {
-       com_err(whoami, status, " in DeleteList (delete_list).");
+       com_err(program_name, status,   " in DeleteList (delete_list).");
        return(DM_NORMAL);
     }
 
@@ -493,7 +504,7 @@ char *argv[];
 
     status = sms_query("delete_list", 1, &list, Scream, (char *) NULL);
     if (status != SMS_IN_USE && status != 0) {
-       com_err(whoami, status, " in DeleteList (delete_list).");
+       com_err(program_name, status,   " in DeleteList (delete_list).");
        return(DM_NORMAL);
     }
     if (status == 0) {
@@ -519,12 +530,12 @@ char *argv[];
     }
 
     info = (char **) list_info->q_data;
-    CheckAcl(info[ACL_TYPE], info[ACL_NAME], TRUE);
+    CheckAcl(info[L_ACL_TYPE], info[L_ACL_NAME], TRUE);
 
     local = member_of;
     while (local != NULL) {
        info = (char **) local->q_data;
-       CheckListForDeletion(info[0], TRUE);
+       CheckListForDeletion(info[LM_LIST], TRUE);
        local = local->q_forw;
     }
 
@@ -540,7 +551,7 @@ char *argv[];
  */
 
 static int
-RealDeleteList(name);
+RealDeleteList(name)
 char * name;
 {
     char buf[BUFSIZ];
@@ -548,12 +559,12 @@ char * name;
 
     if ( (status = sms_query("delete_list", 1, &name, Scream, 
                             (char *) NULL)) == NULL) {
-       com_err(whoami, status, ": list not deleted");
+       com_err(program_name, status, ": list not deleted");
        return(SUB_ERROR);
     }
     (void) sprintf(buf, "List %s deleted./n", name);
     Put_message(buf);
-    return(SUB_NORM);
+    return(SUB_NORMAL);
 }
 
 /*     Function Name: DeleteUser
@@ -570,14 +581,14 @@ char ** argv;
     int status;
     char buf[BUFSIZ];
     char * name = argv[1];     /* name of the user we are deleting. */
-    qelem *local, *member_of = NULL;
+    struct qelem *local, *member_of = NULL;
 
     if (!Confirm("Are you sure that you want to delete this user?"))
        return(DM_NORMAL);
 
-    status = sms_query("delete_user", 1, &name, NullFunc, (char *) NULL);
+    status = sms_query("delete_user", 1, &name, Scream, (char *) NULL);
     if (status != SMS_IN_USE && status != 0) {
-       com_err(whoami, status, ": list not deleted");  
+       com_err(program_name, status, ": list not deleted");    
        return(DM_NORMAL);
     }
     if (status == 0) {
@@ -596,8 +607,8 @@ char ** argv;
  * If all these have been accomplished, then attempt to delete the user again.
  */
        if ( (CheckIfAcl(name, "user", TRUE) == SUB_ERROR) ||
-            (DeleteHomeFilsys(name, TRUE) == SUB_ERROR) ||
-            (DeleteQuotas(name, TRUE) == SUB_ERROR) ||
+            (DeleteHomeFilesys(name, TRUE) == SUB_ERROR) ||
+            (DeleteAllUserQuotas(name, TRUE) == SUB_ERROR) ||
             (RemoveItemFromLists(name, "user",
                                  &member_of, TRUE) == SUB_ERROR) ||
             (RealDeleteUser(name) == SUB_ERROR) ) {
@@ -611,16 +622,16 @@ char ** argv;
  * Query - Delete all empty lists created by removing this user from them.
  */
 
-    if (DeleteUserGroup(name) == SUB_ERROR) {
+    if (DeleteUserGroup(name, TRUE) == SUB_ERROR) {
        FreeQueue(member_of);
        return(DM_NORMAL);
     }
 
     local = member_of;
     while (local != NULL) {
-       info = (char **) local->q_data;
+       char ** info = (char **) local->q_data;
        CheckListForDeletion(info[0], TRUE);
-       local->local->q_forw;
+       local = local->q_forw;
     }
 
     FreeQueue(member_of);      /* Free memory and return. */
@@ -634,7 +645,7 @@ char ** argv;
  */
 
 static int
-RealDeleteUser(name);
+RealDeleteUser(name)
 char * name;
 {
     char buf[BUFSIZ];
@@ -642,12 +653,12 @@ char * name;
 
     if ( (status = sms_query("delete_user", 1, &name, Scream, 
                             (char *) NULL)) == NULL) {
-       com_err(whoami, status, ": user not deleted");
+       com_err(program_name, status, ": user not deleted");
        return(SUB_ERROR);
     }
     (void) sprintf(buf, "User %s deleted./n", name);
     Put_message(buf);
-    return(SUB_NORM);
+    return(SUB_NORMAL);
 }
 
     
index a8e68187fb9613ee37ea38f8ecaabe91302db94b..ec16936682c7621be67bcc7f563eaf63c0c50b12 100644 (file)
@@ -22,6 +22,9 @@
 #include "mit-copyright.h"
 #include "allmaint.h"
 
-char *user                     /* The name of the user executing allmaint. */
+Bool verbose;                  /* TRUE if verbose mode is active (default). */
+Bool found_some;               /* used by lists.c for determining if there 
+                                  are any members of a given type. */
+char *user;                    /* The name of the user executing allmaint. */
 char *program_name;            /* The name of this instance of the program. */
 
index 9d582a27530c46164eef5e28449982464248ab2f..a9c4b05d4564a929be0e0d5ba9a21354f5810323 100644 (file)
 #ifndef _allmaint_globals_
 #define _allmaint_globals_
 
-extern char *user              /* The name of the user executing allmaint. */
+extern Bool verbose;           /* TRUE if verbose mode is active (default). */
+extern Bool found_some;                /* used by lists.c for determining if there 
+                                are any members of a given type. */
+extern char *user;             /* The name of the user executing allmaint. */
 extern char *program_name;     /* The name of this instance of the program. */
 
 #endif _allmaint_globals_      /* Do Not Add Anything After This Line */
index 70bdc212818202a10fca954695fb1a55ef3f48e5..732ff53f1f62796664ad0138a9c41955c4307dec 100644 (file)
@@ -26,6 +26,7 @@
 
 #include "mit-copyright.h"
 #include "allmaint.h"
+#include "allmaint_funcs.h"
 #include "globals.h"
 #include "infodefs.h"
 
 #define GLOM    2
 #define ACL_USE 3
 
+/* globals only for this file. */
+
+static char * current_list;
+
 /*     Function Name: PrintListInfo
  *     Description: This function Prints out the List info in a coherent form.
  *     Arguments: info - the List info.
@@ -66,7 +71,7 @@ char ** info;
        Put_message("This list has no Administrator, how strange?!");
     else {
        sprintf(buf, "The List Administrator of this list is the %s: %s",
-               info[L_ACL_TYPE], info[ACL_NAME]);
+               info[L_ACL_TYPE], info[L_ACL_NAME]);
        Put_message(buf);
     }
 
@@ -91,17 +96,18 @@ char ** info;
 struct qelem *
 GetListInfo(type, name1, name2)
 int type;
-char * name;
+char * name1, *name2;
 {
     char *args[2];
-    struct quelem * elem = NULL;
+    struct qelem * elem = NULL;
+    register int status;
 
     switch(type) {
     case LIST:
        args[0] = name1;
        if ( (status = sms_query("get_list_info", 1, args,
                               StoreInfo, (char *) &elem)) != 0) {
-           com_err(whoami, status, " in get_nfs_quotas_by_user");
+           com_err(program_name, status, " in get_nfs_quotas_by_user");
            return (NULL);
        }
        break;
@@ -109,7 +115,7 @@ char * name;
        args[0] = name1;
        if ( (status = sms_query("get_members_of_list", 1, args,
                               StoreInfo, (char *) &elem)) != 0) {
-           com_err(whoami, status, " in get_nfs_quotas_by_user");
+           com_err(program_name, status, " in get_nfs_quotas_by_user");
            return (NULL);
        }
        break;
@@ -118,7 +124,7 @@ char * name;
        args[1] = name2;        
        if ( (status =  sms_query("get_list_of_member", 2, args,
                               StoreInfo, (char *) &elem)) != 0) {
-           com_err(whoami, status, " in get_nfs_quotas_by_user");
+           com_err(program_name, status, " in get_nfs_quotas_by_user");
            return (NULL);
        }
        break;
@@ -127,7 +133,7 @@ char * name;
        args[1] = name2;        
        if ( (status =  sms_query("get_acl_use", 2, args,
                               StoreInfo, (char *) &elem)) != 0) {
-           com_err(whoami, status, " in get_nfs_quotas_by_user");
+           com_err(program_name, status, " in get_nfs_quotas_by_user");
            return (NULL);
        }
        break;
@@ -145,13 +151,11 @@ char * name;
  */
 
 char **
-AskListInfo(info, name);
+AskListInfo(info, name)
 char ** info;
 Bool name;
 {
-    char * temp_buf, *newname;
-    char *ret_args[100];
-    int counter;
+    char temp_buf[BUFSIZ], *newname;
 
     sprintf(temp_buf,"\nChanging Attributes of list %s.\n",info[L_NAME]);
     Put_message(temp_buf);
@@ -165,15 +169,19 @@ Bool name;
     GetValueFromUser("Is this list hidden (1/0): ", &info[L_HIDDEN]);
     GetValueFromUser("Is this a maillist  (1/0): ", &info[L_MAILLIST]);
     GetValueFromUser("is this a group     (1/0): ", &info[L_GROUP]);
-    if (atoi(info[L_GROUP])) 
-       GetValueFromUser("What is the Gid for this group '#' get unique gid:".
-                        &info[L_GID]);
+    if (atoi(info[L_GROUP])) {
+       sprintf(temp_buf, "What is the Gid for this group, %s",
+               "'#' gets unique gid:");
+       GetValueFromUser(temp_buf, &info[L_GID]);
+    }
     GetValueFromUser("What Type of Administrator (none, user, list): ",
                     &info[L_ACL_TYPE]);
-    if ( strcmp(info[L_ACL_TYPE],"USER") == 0) 
+    if ( (strcmp(info[L_ACL_TYPE], "USER") == 0) || 
+       (strcmp(info[L_ACL_TYPE], "user") == 0) )
        GetValueFromUser("Who will be the administrator of this list: ",
                         &info[L_ACL_NAME]);
-    if ( strcmp(info[L_ACL_TYPE],"USER") == 0) 
+    if ( (strcmp(info[L_ACL_TYPE], "LIST") == 0) ||
+       (strcmp(info[L_ACL_TYPE], "list") == 0) )
        GetValueFromUser("Which group will be the administrator of this list: ",
                         &info[L_ACL_NAME]);
     GetValueFromUser("Description: ", &info[L_DESC]);
@@ -195,7 +203,7 @@ Bool name;
 
 /*     Function Name: ShowListInfo.
  *     Description: shows info on a list.
- *     Arguments: argc, argv - standard SMS argc and argv.
+ *     Arguments: argc, argv - name of list in argv[1].
  *     Returns: DM status code.
  */
 
@@ -206,7 +214,7 @@ char **argv;
 {
     struct qelem *top, *list;
 
-    top = list = StoreListInfo(LIST, argv[1], (char *) NULL);
+    top = list = GetListInfo(LIST, argv[1], (char *) NULL);
     while (list != NULL) {
        PrintListInfo( (char **) list->q_data);
        list = list->q_forw;
@@ -238,7 +246,7 @@ char **argv;
        up_args = AskListInfo(info, TRUE);
        if ( (status = sms_query("update_list", CountArgs(up_args), up_args,
                                 Scream, (char *) NULL)) != 0) {
-           com_err(whoami, status, " in UpdateList."); 
+           com_err(program_name, status, " in UpdateList.");   
            Put_message("List Not Updated.");
            list = list->q_forw;
        }
@@ -260,19 +268,18 @@ int argc;
 char **argv;
 {
     static char *info[MAX_ARGS_SIZE], **add_args;
-    struct qelem *top, *list;
     int status;
 
     if (!ValidName(argv[1])) /* Check if list name is valid. */
        return(DM_QUIT);
     
     status = sms_query("get_list_info", 1, argv + 1, NullFunc, 
-                      (caddr_t) NULL);
+                      (char *) NULL);
     if (status != SMS_NO_MATCH) {
        if (status == 0)
            Put_message("This list already exists.");
        else
-           com_err(whoami, status, " in AddList.");    
+           com_err(program_name, status, " in AddList.");      
        return(DM_QUIT);
     }
 
@@ -280,9 +287,8 @@ char **argv;
 
     if ( (status = sms_query("add_list", CountArgs(add_args), add_args,
                             Scream, (char *) NULL)) != 0) {
-       com_err(whoami, status, " in AddList.");        
+       com_err(program_name, status, " in AddList.");  
        Put_message("List Not Created.");
-       list = list->q_forw;
     }
 
     FreeInfo(info);
@@ -296,13 +302,13 @@ char **argv;
  */
 
 int
-Instructions()
+ListHelp()
 {
     static char * message[] = {
        "Listmaint handles the creation, deletion, and updating of lists.\n",
        "A list can be a mailing list, a group list, or both.\n",
        "The concept behind lists is that a list has an owner",
-       "- administrator -  and members.\n";
+       "- administrator -  and members.\n",
        "The administrator of a list may be another list.\n",
        "The members of a list can be users (login names), other lists,",
        "or address strings.\n",
@@ -311,7 +317,7 @@ Instructions()
        "    Escape from a function - Type ctrl-C.\n",
        "    Suspend the program (temporarily) - Type ctrl-Z.\n",
        NULL,
-    }
+    };
 
     return(PrintHelp(message));
 }
@@ -332,7 +338,7 @@ Menu *m;
 int argc;
 char **argv;
 {
-    char buf[BUFSIZ], temp_buf[BUFSIZ];
+    char temp_buf[BUFSIZ];
     char *list_name = argv[1];
 
     if (*argv[0] == 'a') {     /* add_list */
@@ -383,15 +389,16 @@ Menu *m;
  */
 
 void
-ListMembersByType(type);
+ListMembersByType(type)
 char * type;
 {
     char temp_buf[BUFSIZ];
+    register int status;
 
     found_some = FALSE;
-    if (status = sms_query("get_members_of_list", 1, &current_list, 
-                          PrintByType, type))
-       com_err(whoami, status, " in ListMembersByType\n");
+    if ( (status = sms_query("get_members_of_list", 1, &current_list, 
+                          PrintByType, type)) != 0)
+       com_err(program_name, status, " in ListMembersByType\n");
     if (!found_some) {
        if (type == NULL)
            Put_message("List is empty (no members).");
@@ -466,6 +473,7 @@ GetMemberInfo(action, ret_argv)
 char *action, **ret_argv;
 {
     char temp_buf[BUFSIZ], ret_buf[BUFSIZ];
+    register int status;
 
     ret_argv[LM_LIST] = Strsave(current_list);
     ret_argv[LM_MEMBER] = "nobody";
@@ -479,13 +487,13 @@ char *action, **ret_argv;
        Put_message("\"type\" must be one of 'STRING', 'LIST', or 'USER'.");
        return(SUB_ERROR);
     } else if (status) {
-       com_err(whoami, status, NULL);
+       com_err(program_name, status, NULL);
     }
 
     sprintf(temp_buf,"Name of member to %s", action);
     PromptWithDefault(temp_buf, ret_buf, BUFSIZ, user);
     ret_argv[LM_MEMBER] = Strsave(ret_buf);
-    ret-args[LM_END] = NULL;           /* null terminat this list. */
+    ret_argv[LM_END] = NULL;           /* null terminat this list. */
     return(SUB_NORMAL);
 }
 
@@ -499,13 +507,14 @@ int
 AddMember()
 {
     char *args[10];
+    register int status;
 
     if( GetMemberInfo("add", args) == SUB_ERROR )
        return(DM_NORMAL);
 
     if (status = sms_query("add_member_to_list", CountArgs(args), args,
                           Scream, NULL) != 0)
-       com_err(whoami, status, " in AddMember\n");
+       com_err(program_name, status, " in AddMember\n");
 
     FreeInfo(args);
     return (DM_NORMAL);
@@ -521,6 +530,7 @@ int
 DeleteMember()
 {
     char *args[10];
+    register int status;
 
     if( GetMemberInfo("delete", args) == SUB_ERROR )
        return(DM_NORMAL);
@@ -528,7 +538,7 @@ DeleteMember()
     if (Confirm("Are you sure you want to delete this member?") ) {
        if (status = sms_query("delete_member_from_list", CountArgs(args),
                               args, Scream, NULL))
-           com_err(whoami, status, " in DeleteMember\n");
+           com_err(program_name, status, " in DeleteMember\n");
        else
            Put_message("Deletion Completed.");
     }
@@ -550,8 +560,9 @@ DeleteMember()
 int
 InterRemoveItemFromLists()
 {
-    char type[BUFSIZ], name[BUFSIZ], args[10];
-    qelem *top, *elem;
+    register int status;
+    char type[BUFSIZ], name[BUFSIZ], *args[10];
+    struct qelem *top, *elem;
 
     if ( !(PromptWithDefault("Type of member (user, list, string)? ", type, 
                            BUFSIZ, "user")) )
@@ -564,19 +575,20 @@ InterRemoveItemFromLists()
     top = elem = GetListInfo(GLOM, type, name);
 
     while(elem != NULL) {
-       info = (char **) elem->q_data;
+       char line[BUFSIZ], buf[BUFSIZ];
+       char ** info = (char **) elem->q_data;
        sprintf(line, "Delete %s from the list \"%s\" [Y/N/Q]? ", name,
                info[0]);
        PromptWithDefault(line, buf, BUFSIZ, "N" );
        if (buf[0] == 'y' || buf[0] == 'Y') {
            Put_message("deleting...");
-           args[DM_LIST] = info[0];
+           args[DM_LIST] = info[GLOM_NAME];
            args[DM_TYPE] = type;
            args[DM_MEMBER] = name;
            if ( (status = sms_query("delete_member_from_list", 3, args,
                               Scream, (char *) NULL)) != 0)
                /* should check to delete list. */
-               com_err(whoami, status, " in delete_member");
+               com_err(program_name, status, " in delete_member");
        } 
        else if (buf[0] == 'q' || buf[0] == 'Q') {
            Put_message("Quitting.");
@@ -592,17 +604,16 @@ InterRemoveItemFromLists()
 
 /*     Function Name: ListByMember
  *     Description: This gets all lists that a given member is a member of.
- *     Arguments: argc, argv - agrv[1] contains the type.
- *                              argv[2] contains the name of the member.
+ *     Arguments: none.
  *     Returns: DM_NORMAL.
  */
 
 int
-ListByMember(argc, argv)
-int argc;
-char **argv;
+ListByMember()
 {
     char buf[BUFSIZ], *type, *name, **info;
+    Bool maillist, group;
+    struct qelem *top, *elem;
 
     if ( !(PromptWithDefault("Type of member (user, list, string)? ", buf, 
                            BUFSIZ, "user")) )
@@ -637,17 +648,15 @@ char **argv;
 /*     Function Name: ListByAdministrator
  *     Description: This function prints all lists which a given user or
  *                   group administers.
- *     Arguments: argc, argv - type of the acl in argc[1].
- *                              name of the acl in argc[2].
+ *     Arguments: none.
  *     Returns: DM_NORMAL.
  */
 
 int
-ListByAdministrator(argc, argv)
-int argc;
-char **argv;
+ListByAdministrator()
 {
-    char buf[BUFSIZ], *type, *name, **info;
+    char buf[BUFSIZ], *type, *name;
+    struct qelem *top, *elem;
 
     if ( !(PromptWithDefault("Type of member (user, list, string)? ", buf, 
                            BUFSIZ, "user")) )
@@ -665,7 +674,7 @@ char **argv;
 
     top = elem = GetListInfo(ACL_USE, type, name);
     while (elem != NULL) {
-       info = (char **) elem->q_data;
+       char ** info = (char **) elem->q_data;
        sprintf(buf, "Type: %s,\tName: %s", info[0], info[1]);
        Put_message(buf);
        elem = elem->q_forw;
@@ -682,19 +691,20 @@ char **argv;
 
 ListAllGroups()
 {
+    register int status;
     static char * args[] = {
        "TRUE",                 /* active */
        "DONTCARE",             /* public */
        "FALSE",                /* hidden */
        "DONTCARE",             /* maillist */
        "TRUE",                 /* group. */
-    }
+    };
 
     if (YesNoQuestion("This query will take a while, Do you wish to continue?",
-                      TRUE) )
+                      TRUE) == TRUE )
        if (status = sms_query("qualified_get_lists", 5, args,
                               Print, (char *) NULL) != 0)
-           com_err(whoami, status, " in ListAllGroups\n");
+           com_err(program_name, status, " in ListAllGroups\n");
     return (DM_NORMAL);
 }
 
@@ -706,19 +716,20 @@ ListAllGroups()
 
 ListAllMailLists()
 {
+    register int status;
     static char * args[] = {
        "TRUE",                 /* active */
        "DONTCARE",             /* public */
        "FALSE",                /* hidden */
        "TRUE",                 /* maillist */
        "DONTCARE",             /* group. */
-    }
+    };
 
     if (YesNoQuestion("This query will take a while. Do you wish to continue?",
-                      TRUE) )
+                      TRUE) == TRUE )
        if (status = sms_query("qualified_get_lists", 5, args,
                               Print, (char *) NULL) != 0)
-           com_err(whoami, status, " in ListAllGroups\n");
+           com_err(program_name, status, " in ListAllGroups\n");
 
     return (DM_NORMAL);        
 }
@@ -731,19 +742,20 @@ ListAllMailLists()
 
 ListAllPublicMailLists()
 {
+    register int status;
     static char * args[] = {
        "TRUE",                 /* active */
        "TRUE",                 /* public */
        "FALSE",                /* hidden */
        "TRUE",                 /* maillist */
        "DONTCARE",             /* group. */
-    }
+    };
 
     if (YesNoQuestion("This query will take a while. Do you wish to continue?",
-                      TRUE) )
+                      TRUE) == TRUE )
        if (status = sms_query("qualified_get_lists", 5, args,
                               Print, (char *) NULL) != 0)
-           com_err(whoami, status, " in ListAllGroups\n");
+           com_err(program_name, status, " in ListAllGroups\n");
 
     return (DM_NORMAL);        
 }
index f970811c095c3130351b99e7343f02f3f35e859a..abe0d8087a2ecba14841405beaa3cf642e202a5c 100644 (file)
 #include <signal.h>
 #include <stdio.h>
 #include <strings.h>
+#include <sys/types.h>
 #include <sms.h>
 #include <menu.h>
 
 #include "mit-copyright.h"
 #include "allmaint.h"
+#include "allmaint_funcs.h"
 #include "globals.h"
 
-static void init_listmaint(), error_exit(), usage();
-void Put_message();
+extern Menu allmaint_top_menu;
+static void ErrorExit(), Usage(), SignalHandler();
 char *getlogin();
 uid_t getuid();
 struct passwd *getpwuid();
@@ -49,7 +51,7 @@ main(argc, argv)
     int argc;
     char ** argv;
 {
-    char buf[BUFSIZ];
+    int status;
 
     if ((user = getlogin()) == NULL) 
        user = getpwuid((int) getuid())->pw_name;
@@ -57,13 +59,14 @@ main(argc, argv)
 
     init_sms_err_tbl();
     init_krb_err_tbl();
+    verbose = TRUE;
 
     switch (argc) {
     case 2:
       if (strcmp(argv[1], "-nomenu") == 0)
        use_menu = FALSE;
-      else
-       usage();
+      else 
+       Usage();
                                /* Fall Through. */
     case 1:
       if ((program_name = rindex(argv[0], '/')) == NULL)
@@ -72,23 +75,23 @@ main(argc, argv)
        program_name++;
       break;
     default:
-      usage();
+      Usage();
       break;
     }
     
     if ( status = sms_connect() ) 
-       error_exit("\nConnection to SMS server failed", status);
+       ErrorExit("\nConnection to SMS server failed", status);
 
-    if ( status = sms_auth(argv[0]) ) 
-       error_exit("\nAuthorization failed -- please run kinit", status);
+    if ( status = sms_auth(program_name) ) 
+       ErrorExit("\nAuthorization failed -- please run kinit", status);
 
 /*
  * These signals should not be set until just before we fire up the menu
  * system. 
  */
-    (void) signal(SIGHUP, signal_handler);
-    (void) signal(SIGINT, signal_handler);
-    (void) signal(SIGQUIT, signal_handler);
+    (void) signal(SIGHUP, SignalHandler);
+    (void) signal(SIGINT, SignalHandler);
+    (void) signal(SIGQUIT, SignalHandler);
 
     if (use_menu) {            /* Start menus that execute program */
         Start_paging();
@@ -102,7 +105,7 @@ main(argc, argv)
     exit(0);
 }
 
-/*     Function Name: error_exit
+/*     Function Name: ErrorExit
  *     Description: This function does the error handling and exits.
  *     Arguments: buf - the error message to print.
  *                 status - the error code.
@@ -110,9 +113,9 @@ main(argc, argv)
  */
 
 static void
-error_exit(buf,status);
+ErrorExit(buf,status)
 int status;
-char * whoami, *buf;    
+char * buf;    
 {
     com_err(program_name, status, buf);
     sms_disconnect();
@@ -126,20 +129,20 @@ char * whoami, *buf;
  */
 
 static void
-usage()
+Usage()
 {
     fprintf(stderr, "Usage: %s [-nomenu]\n", program_name);
     exit(1);
 }
 
-/*     Function Name: signal_handler
+/*     Function Name: SignalHandler
  *     Description: This function cleans up from a signal interrupt.
  *     Arguments: none.
  *     Returns: doesn't
  */
 
-static int *
-signal_handler()
+void
+SignalHandler()
 {
     Put_message("Signal caught - exiting");
     if (use_menu)
index 96b5f8245ad9bde6e828d6e6b282cb3bf02d555d..c572ea8822ab7d443c160517a8e2b8adf774d14b 100644 (file)
 
 #include <stdio.h>
 #include <menu.h>
+
 #include "mit-copyright.h"
 #include "allmaint.h"
+#include "allmaint_funcs.h"
+#include "globals.h"
 
 /*
  * Attachmaint Menus
@@ -32,7 +35,7 @@ Menu attachmaint_filemenu = {
   NULLFUNC, 
   NULLFUNC, 
   "Filesystem Maintenance",
-  5,
+  4,
   {
     { GetFS, NULLMENU, 2, {
       {"get", "Get Filesystem Name Information"},
@@ -46,10 +49,6 @@ Menu attachmaint_filemenu = {
       {"change", "Update Filesystem Information"},
       {"name", "name: "},
     } },
-    { RenameFS, NULLMENU, 2, {
-      {"rename", "Rename Filesystem"},
-      {"name", "Current (Old)  Name: "},
-    } },
     { DeleteFS, NULLMENU, 2, {
       {"delete", "Delete Filesystem"},
       {"name", "Filesystem Name: "}
@@ -63,7 +62,7 @@ Menu attachmaint_top_menu = {
   "Attach/Filesystem Maintenance", 
   7,
   {
-    SUBMENU("filesystem", "Filesystem Work", &filemenu),
+    SUBMENU("filesystem", "Filesystem Work", &attachmaint_filemenu),
     { GetFSAlias, NULLMENU, 2, {
       {"check", "Check An Association."},
       {"name", "name (user/group/course): "}
@@ -89,36 +88,36 @@ Menu clustermaint_machine_menu = {
   NULLFUNC,
   NULLFUNC,
   "Machine Maintenence",
-  7,
+  6,
   {
     { ShowMachineInfo, NULLMENU, 2, {
-      {"ShowMachineInfo","Get machine information."},
+      {"Show","Get machine information."},
       {"name","Machine's Name: "}
     } },
     { AddMachine, NULLMENU, 2, {
-      {"AddMachine","Add a new machine."},
+      {"Add","Add a new machine."},
       {"name","Machine's Name: "},
     } },
     { UpdateMachine, NULLMENU, 2, {
-      {"UpdateMachine","Update machine information."},
+      {"Update","Update machine information."},
       {"name","Machine's Name: "},
     } },
-    { ChangeMachineName,  NULLMENU, 2, {
-      {"ChangeMachineName", "Change the name of machine"},
-      {"old", "Current (old) Machine's Name: "},
-    } },
     { DeleteMachine, NULLMENU, 2, {
-      {"DeleteMachine","Delete this machine."},
+      {"Delete","Delete this machine."},
       {"name","Machine's Name: "}
     } },
+    { MachineToClusterMap, NULLMENU, 3, {
+      {"Map", "Show Machine to cluster mapping."},
+      {"name", "Machine's Name:"},
+      {"cluster", "Cluster's Name:"},
+    } },
     { AddMachineToCluster, NULLMENU, 3, {
-      {"AddMachineToCluster","Add this machine to a cluster."},
+      {"AddCluster","Add this machine to a cluster."},
       {"name","Machine's Name: "},
-      {"cluster","Name of the Cluster: "}
+      {"cluster", "Cluster's Name:"},
     } },
-    { DeleteMachineFromAllClusters, NULLMENU, 2, {
-      {"DeleteMachineFromAllClusters",
-        "Delete this machine from all clusters."},
+    { RemoveMachineFromCluster, NULLMENU, 2, {
+      {"RemoveCluster", "Remove this machine from a cluster."},
       {"name","Machine's Name: "},
     } },
   }
@@ -128,16 +127,16 @@ Menu clustermaint_cluster_menu = {
   NULLFUNC,
   NULLFUNC,
   "Cluster Information",
-  6,
+  5,
   {
     { ShowClusterInfo, NULLMENU, 2, {
-      {"info", "Get cluster information."},
+      {"Show", "Get cluster information."},
       {"name", "Cluster's Name: "}
     } },
     { MachinesInCluster, NULLMENU, 2, {
-      {"machines", "List all machines in this cluster."},
+      {"Machines", "List all machines in a cluster."},
       {"clus", "Cluster's Name: "}
-    } }
+    } },
     { AddCluster, NULLMENU, 2, {
       {"add", "Add a new cluster."},
       {"name","Cluster's Name: "},
@@ -146,10 +145,6 @@ Menu clustermaint_cluster_menu = {
       {"update", "Update cluster information."},
       {"name","Cluster's Name: "},
     } },
-    { ChangeClusterName,  NULLMENU, 2, {
-      {"cname", "Change the name of this cluster."},
-      {"old", "Current (old) Cluster's Name: "},
-    } },
     { DeleteCluster, NULLMENU, 2, {
       {"delete", "Delete this cluster."},
       {"name", "Cluster's Name: "}
@@ -157,28 +152,33 @@ Menu clustermaint_cluster_menu = {
   }
 };
 
-Menu clustermaint_service_menu= {
+Menu clustermaint_data_menu= {
   NULLFUNC,
   NULLFUNC,
-  "Service Cluster Maintenence",
+  "Cluster Data Maintenence",
   3,
   {
-    { ShowServicesForCluster, NULLMENU, 2, {
-      {"show_one", "Show a Service Cluster"},
-      {"clus", "Cluster's Name: "}
+    { ShowClusterData, NULLMENU, 3, {
+      {"show_one", "Show Data on a given Cluster"},
+      {"clus", "Cluster's Name: "},
+      {"label", "Label Identifing the data"},
     } },
-    { AddService, NULLMENU, 2, {
-      {"add", "Add a Service to a Cluster"},
+    { AddClusterData, NULLMENU, 4, {
+      {"add", "Add Data to a given Cluster"},
       {"clus", "Cluster Name: "},
+      {"label", "Label Identifing the data"},
+      {"data", "The data to be added"},
     } },
-    { DeleteService, NULLMENU, 2, {
-      {"delete", "Delete a Service from a Cluster"},
+    { RemoveClusterData, NULLMENU, 4, {
+      {"delete", "Remove Data to a given Cluster"},
       {"clus", "Cluster's Name: "},
+      {"label", "Label Identifing the data"},
+      {"data", "The data to be removed"},
     } } 
   }
 };
 
-Menu clusetermaint_top_menu = {
+Menu clustermaint_top_menu = {
   NULLFUNC,
   NULLFUNC,
   "Cluster Maintenence",
@@ -186,7 +186,7 @@ Menu clusetermaint_top_menu = {
   {
     SUBMENU("machine", "Work on Machines", &clustermaint_machine_menu),
     SUBMENU("cluster", "Work on Clusters", &clustermaint_cluster_menu),
-    SUBMENU("service", "Service Clusters", &clustermaint_service_menu),
+    SUBMENU("service", "Service Clusters", &clustermaint_data_menu),
     {MachineToClusterMap, NULLMENU, 3, {
       {"map", "Machine to Cluster Mapping"},
       {"machine", "Machine Name: "},
@@ -285,8 +285,8 @@ Menu listmaint_list_menu = {
 };
 
 Menu listmaint_member_menu = {
-    MemberMenuEntry,
-    MemberMenuExit,
+    ListmaintMemberMenuEntry,
+    ListmaintMemberMenuExit,
     NULL,
     6,
     {
@@ -295,7 +295,7 @@ Menu listmaint_member_menu = {
        SIMPLEFUNC("delete", "Delete a member from the list",
                   DeleteMember),
        SIMPLEFUNC("all", "Show the members of the list",
-                  ListMembers),
+                  ListAllMembers),
        SIMPLEFUNC("user", "Show the members of type USER",
                   ListUserMembers),
        SIMPLEFUNC("list", "Show the members of type LIST",
@@ -323,7 +323,7 @@ Menu listmaint_top_menu = {
            {"show", "Display information about a list"},
            {"list name", "Name of list: "}
        } },
-       { UpdateListInfo, NULLMENU, 2, {
+       { UpdateList, NULLMENU, 2, {
            {"update", "Update characteristics of a list"},
            {"list name", "Name of list: "}
        } },
@@ -331,13 +331,12 @@ Menu listmaint_top_menu = {
            {"members", "Change/Display the membership of a list"},
            {"list name", "Name of list: "}
        } },
-       { DeleteUserFromLists, NULLMENU, 2, {
-           { "deluser", "Interactively query/delete user from all lists"},
-           { "user name", "Login name of user: "}
-       } },
+       SIMPLEFUNC("query_remove",
+                  "Interactively remove an item from all lists",
+                  InterRemoveItemFromLists),
        SUBMENU("list_lists", "Display inventory of lists",
                &listmaint_list_menu),
-       SIMPLEFUNC("help", "How to use this program", Instructions)
+       SIMPLEFUNC("help", "How to use this program", ListHelp)
     } 
 };
 
@@ -349,30 +348,30 @@ Menu nfsmaint_top_menu = {
   NULLFUNC,
   NULLFUNC,
   "NFS Maintenence",
-  6,
+  5,
   {
     { ShowNFSService, NULLMENU, 3, {
       { "show", "Show an NFS server " },
       { "machine", "Machine Name: "},
-      { "device", "Device: "}
+      { "device", "Directory: "}
     } },
     { AddNFSService, NULLMENU, 3, {
       { "add", "Add NFS server" },
       { "machine", "Machine Name: "},
-      { "device", "Device: "}
+      { "device", "Directory: "}
     } },
     { UpdateNFSService, NULLMENU, 3, {
       { "update", "Update NFS server"},
       { "machine", "Machine Name: "},
-      { "device", "Device: "}
+      { "device", "Directory: "}
     } },
     { DeleteNFSService, NULLMENU, 3, {
       { "delete", "Delete NFS server"},
       {"machine", "Machine Name: "},
-      {"device", "Device: "}
+      {"device", "Directory: "}
     } },
     SIMPLEFUNC("verbose", "Toggle Verbosity of Delete", ToggleVerboseMode),
-    SIMPLEFUNC("help", "Help", NFSHelp),
+/*    SIMPLEFUNC("help", "Help", NFSHelp), */
   }
 };
 
@@ -459,11 +458,11 @@ Menu usermaint_quota_menu = {
       {"create", "Create a quota & locker for a user"},
       {"login", "User's login name: "},
       {"machine", "Server host name: "},
-      {"device", "Physical device on host: "},
+      {"device", "Directory on host: /[dir]/[login] "},
       {"quota", "Quota in KB: "}
     } },
     {DeleteUserLocker, NULLMENU, 2, {
-      {"del", "Delete a user's quota & locker"},
+      {"del", "Delete a user's quota & locker - BROKEN 6/10/88 CDP"},
       {"login", "User's login: "}
     } }
   } 
@@ -480,12 +479,12 @@ Menu usermaint_top_menu = {
        {"login name", "Desired login name: "}
      } },
     {ShowUserByName, NULLMENU, 3, {
-      {"full", "Show user information by name (use * for wildcard)."},
+      {"full", "Show user information by name."},
       {"first", "First name: "},
       {"last", "Last name: "}
     } },
     {ShowUserByClass, NULLMENU, 2, {
-       {"login", "Show names of users in a give class."},
+       {"login", "Show names of users in a given class."},
        {"login name", "Desired class: "}
      } },    
     {ModifyUser, NULLMENU, 2, {
index 14750e325c81859043121f29a1ecb5c9f5f28b3d..f20e092d968fc461cc19776ed6469d550508c3e8 100644 (file)
  *     see the file mit-copyright.h
  */
 
-#include "mit-copyright.h"
-#include "allmaint.h"
-#include "globals.h"
-#include "infodefs.h"
-
 #include <stdio.h>
 #include <strings.h>
 #include <sms.h>
 #include <menu.h>
 
+#include "mit-copyright.h"
+#include "allmaint.h"
+#include "allmaint_funcs.h"
+#include "globals.h"
+#include "infodefs.h"
+
 /* #include <sys/types.h> */
 
 #define TYPE_NFS    "NFS"
@@ -58,7 +59,7 @@ char ** info;
            status ? "Active" : "Inactive", info[NFS_ALLOC], info[NFS_SIZE]);
     Put_message(temp_buf);
     sprintf(temp_buf, "Last Modification by %s at %s with %s.",
-                  answer[U_MODBY], answer[U_MODTIME], answer[U_MODWITH]);
+                  info[U_MODBY], info[U_MODTIME], info[U_MODWITH]);
     Put_message(temp_buf);
 }
 /*     Function Name: AskNFSInfo.
@@ -70,7 +71,7 @@ char ** info;
  */
 
 char **
-AskNFSInfo(info);
+AskNFSInfo(info)
 char ** info;
 {
     /* Also need name of the machine in this structure. */
@@ -89,13 +90,13 @@ char ** info;
     FreeAndClear(&info[NFS_MODBY], TRUE);
     FreeAndClear(&info[NFS_MODWITH], TRUE);
     
-    return(info)
+    return(info);
 }
 
 /*     Function Name: ShowNFSService
  *     Description: This function prints all exported partitions.
- *     Arguments: argc, argv - argv[1] - name of filesysytem.
- *                              argv[2] - name of filesystem device.
+ *     Arguments: argc, argv - argv[1] - name of machine.
+ *                              argv[2] - name of directroy.
  *     Returns: DM_NORMAL.
  */
 
@@ -109,11 +110,11 @@ char **argv;
     
     if ( (stat = sms_query("get_nfsphys", 2, argv + 1, 
                           StoreInfo, (char *)  &elem)) != 0)
-       com_err(whoami, stat, " in ShowNFSServices.");
+       com_err(program_name, stat, " in ShowNFSServices.");
 
     top = elem;
     while (elem != NULL) {
-       info = (char **) elem->q_data;
+       char ** info = (char **) elem->q_data;
        PrintNFSInfo(info);
        elem = elem->q_forw;
     }
@@ -125,7 +126,7 @@ char **argv;
  *     Description: Adds a new partition to the nfsphys relation
  *     Arguments: arc, argv - 
  *                             argv[1] - machine name.
- *                             argv[2] - device
+ *                             argv[2] - directory.
  *     Returns: DM_NORMAL.
  */
 
@@ -142,7 +143,7 @@ int argc;
                           NullFunc, (char *) NULL)) == 0) {
        Put_message("This service already exists.");
        if (stat != SMS_NO_MATCH) 
-           com_err(whoami, stat, " in get_nfsphys.");
+           com_err(program_name, stat, " in get_nfsphys.");
     }
     
     if ( (info[NFS_NAME] = CanonicalizeHostname(argv[1])) == NULL) {
@@ -162,7 +163,7 @@ int argc;
     
     if ((stat = sms_query("add_nfsphys", CountArgs(args), args,
                           Scream, (char *) NULL)) != 0) 
-       com_err(whoami, stat, " in AdsNFSService");
+       com_err(program_name, stat, " in AdsNFSService");
     
     FreeInfo(info);
     return (DM_NORMAL);
@@ -172,7 +173,7 @@ int argc;
  *     Description: Update the values for an nfsphys entry.
  *     Arguments: argc, argv -
  *                             argv[1] - machine name.
- *                             argv[2] - device
+ *                             argv[2] - directory.
  *     Returns: DM_NORMAL.
  */
 
@@ -195,7 +196,7 @@ int argc;
 
     if ( (stat = sms_query("get_nfsphys", 2, argv + 1,
                           StoreInfo, (char *) &elem)) != 0) {
-       com_err(whoami, stat, " in UpdateNFSService.");
+       com_err(program_name, stat, " in UpdateNFSService.");
        return (DM_NORMAL);
     }
 
@@ -213,11 +214,10 @@ int argc;
            case FALSE:
                update = FALSE;
                break;
-           case QUIT:
+           default:
                FreeQueue(top);
                Put_message("Aborting update.");
-               Return(DM_NORMAL);
-               break;
+               return(DM_NORMAL);
            }
        }
        else
@@ -225,39 +225,17 @@ int argc;
 
        if (update) {           /* actually perform update */
            args = AskNFSInfo(info);
-           if ((stat = sms_query("update_nfsphys", num_args, args,
-                                 abort, (char *)NULL)) != 0) 
-               com_err(whoami, stat, (char *) NULL);
+           if ((stat = sms_query("update_nfsphys", CountArgs(args), args,
+                                 Scream, (char *)NULL)) != 0) 
+               com_err(program_name, stat, (char *) NULL);
        }
-       elem = elem->q_next;
+       elem = elem->q_forw;
     }
 
     FreeQueue(top);
     return (DM_NORMAL);
 }
 
-/* stop CDP 6/7/88 */
-
-/*     Function Name: DeleteCheck
- *     Description: This checks to see if we should delete this nfs
- *     Arguments: argc, argv - 
- *                              argv[0] - name of file system.
- *                              argv[1] - type of file system.
- *                              argv[3] - packname of fulsys
- *                data - a filled info structure.
- *     Returns: SMS_CONT.
- */
-
-DeleteCheck(argc, argv, date)
-int argc;
-char **argv, *data;
-{
-    char buf[BUFSIZ];
-    NFS_info *info = (NFS_info *) data;
-
-    return(SMS_CONT);
-}
-
 /*     Function Name: DeleteNFSService
  *     Description: Delete an nfsphys entry.
  *     Arguments: argc, argv - name of file system in argv[1].
@@ -272,12 +250,11 @@ int argc;
 char **argv;
 {
     register int stat;
-    struct qelem *elem, *top;
+    struct qelem *top, *elem = NULL;
     char * dir = argv[2];
     int length;
     Bool delete_ok = TRUE;
 
-    elem = NULL;
     argv[1] = CanonicalizeHostname(argv[1]);
 
     stat = sms_query("get_nfsphys", 2, argv + 1, NullFunc, (char *) NULL);
@@ -286,19 +263,20 @@ char **argv;
        return(DM_NORMAL);
     }
     if (stat) {
-       com_err(whoami, stat, " in DeleteNFSService");
+       com_err(program_name, stat, " in DeleteNFSService");
        return(DM_NORMAL);
     }
     
     stat = sms_query("get_filesys_by_machine", 1, argv + 1, StoreInfo, 
                     &elem);
     if (stat && stat != SMS_NO_MATCH)
-       com_err(whoami, stat, " while checking usage of partition");
+       com_err(program_name, stat, " while checking usage of partition");
 
     length = strlen( dir );
     top = elem;
     while (elem != NULL) {
-       info = (char ** ) elem->q_data;
+       char buf[BUFSIZ];
+       char ** info = (char ** ) elem->q_data;
        if ( (strcmp(info[FS_TYPE], TYPE_NFS) == 0) && 
             (strcmp(info[FS_PACK], dir, length) == 0) ) {
            sprintf(buf, "Filesystem %s uses that partition", info[FS_NAME]);
@@ -312,7 +290,7 @@ char **argv;
        Confirm("Do you really want to delete this Filesystem? (y/n) ")) {
        if ( (stat = sms_query("delete_nfsphys", 2, argv + 1,
                               Scream, (char *) NULL )) !=0 )
-           com_err(whoami, stat, " in DeleteNFSService");
+           com_err(program_name, stat, " in DeleteNFSService");
     }
     else
        Put_message("Operation Aborted.\n");
index f3484b2a813b142c8fe8c716a2279931520bcb18..78701088fc2237d73db80b7b414306c3a834322d 100644 (file)
@@ -1,4 +1,4 @@
-ifndef lint
+#ifndef lint
   static char rcsid_module_c[] = "$Header$";
 #endif lint
 
@@ -19,26 +19,28 @@ ifndef lint
  *     see the file mit-copyright.h
  */
 
-#include "mit-copyright.h"
-#include "allmaint.h"
-#include "infodefs.h"
-
 #include <stdio.h>
 #include <strings.h>
 #include <ctype.h>
-
-/* SMS includes */
-
 #include <sms.h>
-#include <sms_app.h>
 #include <menu.h>
 
+#include "mit-copyright.h"
+#include "allmaint.h"
+#include "allmaint_funcs.h"
+#include "globals.h"
+#include "infodefs.h"
+
 #define LOGIN 0
 #define UID   1
 #define NAME  2
 #define QUOTA 3
 #define CLASS 4
 
+static void PrintQuota();      /* prints Quota info. */
+static void PrintUserInfo();   /* prints User info. */
+static int PrintPOBoxes();     /* prints PO Box information. */
+
 /*     Function Name: AskUserInfo.
  *     Description: This function askes the user for information about a 
  *                   machine and saves it into a structure.
@@ -49,14 +51,12 @@ ifndef lint
  *             use the #defined names (e.g args[UID] is not the uid anymore).
  */
 
-void
-AskUserInfo(info, name);
+char **
+AskUserInfo(info, name)
 char ** info;
 Bool name;
 {
-    char * temp_buf, *newname;
-
-    int counter;
+    char temp_buf[BUFSIZ], *newname;
 
     sprintf(temp_buf,"\nChanging Attributes of user %s.\n",info[NAME]);
     Put_message(temp_buf);
@@ -101,27 +101,29 @@ Bool name;
  */
 
 struct qelem *
-GetUserInfo(type, name1, name2);
+GetUserInfo(type, name1, name2)
 int type;
 char *name1, *name2;
 {
     char * args[2];
-    struct quelem * elem = NULL;
+    register int status;
+    struct qelem * elem = NULL;
 
     switch(type) {
     case LOGIN:
        args[0] = name1;
        if ( (status = sms_query("get_user_by_login", 1, args,
-                              StoreInfo, (caddr_t) &elem)) != 0) {
-           com_err(whoami, status, " when attempting to get_use_by_login.");
+                              StoreInfo, (char *) &elem)) != 0) {
+           com_err(program_name, status, " when attempting to get_use_by_login.");
            return (NULL);               
        }
        break;
     case UID:
        args[0] = name1;
        if ( (status = sms_query("get_user_by_uid", 1, args,
-                              StoreInfo, (caddr_t) &elem)) != 0) {
-           com_err(whoami, status, " when attempting to get_use_by_uid.");
+                              StoreInfo, (char *) &elem)) != 0) {
+           com_err(program_name, status, 
+                   " when attempting to get_use_by_uid.");
            return (NULL);      
        }
        break;
@@ -129,16 +131,18 @@ char *name1, *name2;
        args[0] = name1;
        args[1] = name2;    
        if ( (status = sms_query("get_user_by_name", 1, args,
-                              StoreInfo, (caddr_t) &elem)) != 0) {
-           com_err(whoami, status, " when attempting to get_use_by_name.");
+                              StoreInfo, (char *) &elem)) != 0) {
+           com_err(program_name, status, 
+                   " when attempting to get_use_by_name.");
            return (NULL);      
        }
        break;
     case CLASS:
        args[0] = name1;
        if ( (status = sms_query("get_user_by_class", 1, args,
-                              StoreInfo, (caddr_t) &elem)) != 0) {
-           com_err(whoami, status, " when attempting to get_use_by_class.");
+                              StoreInfo, (char *) &elem)) != 0) {
+           com_err(program_name, status, 
+                   " when attempting to get_use_by_class.");
            return (NULL);      
        }
        break;
@@ -146,7 +150,7 @@ char *name1, *name2;
        args[0] = name1;
        if ( (status = sms_query("get_nquotas_by_user", 1, args,
                               StoreInfo, (char *) &elem)) != 0) {
-           com_err(whoami, status, " in get_nfs_quotas_by_user");
+           com_err(program_name, status, " in get_nfs_quotas_by_user");
            return (DM_NORMAL);
        }
        break;
@@ -168,23 +172,20 @@ ModifyUser(argc, argv)
 int argc;
 char **argv;
 {
-    int num_args;
-    char ** info;
-    char *temp_buf;
-    struct qelem * user, * local;
+    int status;
+    char *temp_buf, error_buf[BUFSIZ];
+    struct qelem * elem, * local;
 
-    user = GetUserInfo(LOGIN, argv[1], (char *) NULL);
+    local = elem = GetUserInfo(LOGIN, argv[1], (char *) NULL);
 
-    local = user;
     while (local != NULL) {
-       info = (char **) local->q_data;
-       info = AskUserInfo(info, TRUE);
-       num_args = CountArgs(info);
+       char ** info = (char **) local->q_data;
+       char ** args = AskUserInfo(info, TRUE);
 
-       if ( (status = sms_query("update_user", 
-                                num_args, info, Scream, NULL)) != 0) {
-           com_err(whoami, status, " in ModifyFields");
-           if (local->next == NULL)
+       if ( (status = sms_query("update_user", CountArgs(args), 
+                                args, Scream, NULL)) != 0) {
+           com_err(program_name, status, " in ModifyFields");
+           if (local->q_forw == NULL)
                temp_buf = "";
            else
                temp_buf = ", Continuing to next user";
@@ -192,9 +193,9 @@ char **argv;
                    info[NAME], temp_buf);
            Put_message(error_buf);
        }
-       local = local->next;
+       local = local->q_forw;
     }
-    FreeQueue(user);
+    FreeQueue(elem);
     return(DM_NORMAL);
 }
 
@@ -215,18 +216,17 @@ char *machine;
     char * type;
     struct qelem *top, *elem = NULL;
 
-    match = 0;
     type = "pop";
     status = sms_query("get_server_locations", 1, &type,
                       StoreInfo, &elem);
     if (status && (status != SMS_NO_MATCH)) {
-       com_err(whoami, status, (char *) NULL);
+       com_err(program_name, status, (char *) NULL);
        return( (char *) NULL);
     }
 
     top = elem;
     while (elem != NULL) {
-       info = (char **) elem->q_data;
+       char ** info = (char **) elem->q_data;
        if (strcmp (info[1], machine) == 0) {
            FreeQueue(top);
            return( Strsave("POP") );
@@ -249,9 +249,9 @@ ChangeUserPOBox(argc, argv)
 int argc;
 char **argv;
 {
+    register int status;
     struct qelem * poqueue, *local;
-    char *type, buf[BUFSIZ];
-    extern int po_callbk(), PrintPOBoxes();
+    char *type, buf[BUFSIZ], *pohost;
     static char *po[4];
     poqueue = NULL;
 
@@ -259,7 +259,7 @@ char **argv;
     Put_message(buf);
     status = sms_query("get_pobox", 1, argv + 1, PrintPOBoxes, NULL);
     if (status != SMS_NO_MATCH && status != 0) {
-       com_err(whoami, status, "in ChangeUserPOBox.");
+       com_err(program_name, status, "in ChangeUserPOBox.");
         return(DM_NORMAL);
     }
     else if (status == SMS_NO_MATCH) 
@@ -268,28 +268,29 @@ char **argv;
     if (YesNoQuestion("Shall we use the least loaded Post Office?", TRUE)) {
        po[0] = "pop";
        po[1] = "*";
-       post_office.host = NULL;
-       post_office.least_full = -1;
        if ( status = sms_query ("get_server_host_info", 2, po,
-                                StoreInfo, (caddr_t) &poqueue) != 0) {
-           com_err(whoami, status, 
+                                StoreInfo, (char *) &poqueue) != 0) {
+           com_err(program_name, status, 
                    " in ChangeUserPOBox (get_server_host_info).");
            return(DM_NORMAL);
        }
        local = poqueue;
        while (local != NULL) {
-           if ( !isdigit(*argv[6]) || !isdigit(*argv[7]) )
-               put_message(
-                   "non-digit value in server_host_info, this is a bug");
+           char ** args = (char **) local->q_data;
+           int new_space, old_space = -1 ;
+           if ( !isdigit(*args[6]) || !isdigit(*args[7]) )
+               Put_message(
+                   "non-digit value in server_host_info, this is a bug.");
            else {
-               new_space = atoi(argv[7]) - atoi(argv[6]);
-               if ( new_space < old_space ) {
+               new_space = atoi(argv[7]) - atoi(args[6]);
+               if ( (new_space < old_space) || (old_space == -1) ) {
                    old_space = new_space;
-               pohost = argv[1];
+                   strcpy(buf, args[1]);
                }
            }
-           local = local->next;
+           local = local->q_forw;
        }
+       pohost = Strsave(buf);
        FreeQueue(poqueue);
        type = "POP";
        (void) sprintf(buf, "The Post Office %s was chosen.",
@@ -314,9 +315,9 @@ char **argv;
        po[2] = pohost;
        po[3] = po[0];
        if (status = sms_query("set_pobox", 4, po, Scream, NULL) != 0 )
-           com_err(whoami, status, " in ChangeUserPOBox");
+           com_err(program_name, status, " in ChangeUserPOBox");
     } else 
-       PutMessage("Operation Aborted.");
+       Put_message("Operation Aborted.");
 
     return (DM_NORMAL);
 }
@@ -337,10 +338,12 @@ DeleteUserByUid(argc, argv)
 int argc;
 char **argv;
 {
+    int status;
+
     if (Confirm("Are you sure you want to remove this user"))
        if ( (status = sms_query("delete_user_by_uid", 1, argv+1, Scream,
                               (char * ) NULL)) != 0)
-           com_err(whoami, status, " in DeleteUserByUid");
+           com_err(program_name, status, " in DeleteUserByUid");
 
     return(DM_NORMAL);
 } 
@@ -356,11 +359,11 @@ char **argv;
 int
 ShowDefaultQuota()
 {
-    extern int printit();
+    int status;
     static char *val[] = {"def_quota"};
 
     if (status = sms_query("get_value", 1, val, Print, (char *) NULL) != 0)
-       com_err(whoami, status, " in ShowDefaultQuota");
+       com_err(program_name, status, " in ShowDefaultQuota");
 
     return (DM_NORMAL);
 }
@@ -377,12 +380,15 @@ ShowUserQuota(argc, argv)
 int argc;
 char **argv;
 {
-    extern int PrintQuota();
-
-    if (status = sms_query("get_nfs_quotas_by_user", 1, argv+1, PrintQuota,
-                      (char *) NULL) != 0)
-       com_err(whoami, status, " in ShowUserQuota);
-
+    struct qelem *elem, *top;
+    top = elem = GetUserInfo(QUOTA, argv[1], (char *) NULL);
+    
+    while (elem != NULL) {
+       char ** info = (char **) elem->q_data;
+       PrintQuota(info);
+       elem = elem->q_forw;
+    }
+    FreeQueue(top);
     return (DM_NORMAL);
 }
 
@@ -398,17 +404,19 @@ ChangeDefaultQuota(argc, argv)
 int argc;
 char *argv[];
 {
+    char buf[BUFSIZ];
+    int status;
     static char *newval[] = {
        "update_value", "def_quota", NULL,
     };
 
     sprintf(buf,"%s%s",
            "Are you sure that you want to change the default quota\n"
-           "for all new users");
+           "for all new users? (y/n) ");
     if(!Confirm(buf)) {
        newval[2] = argv[1];
        if (status = sms_query("update_value", 3, newval, Scream, NULL) != 0)
-           com_err(whoami, status, " in update_value");
+           com_err(program_name, status, " in update_value");
     }
     else
        Put_message("Quota not changed.");
@@ -423,7 +431,7 @@ char *argv[];
  *     Arguments: arc, argv - 
  *                             argv[1] login name of user.
  *                             argv[2] server host name.
- *                             argv[3] physical device on host.
+ *                             argv[3] Directory on host.
  *                             argv[4] quota in Kb.
  *     Returns: DM_NORMAL.
  */
@@ -434,8 +442,8 @@ AddUserLocker(argc, argv)
 int argc;
 char **argv;
 {
-    extern char *CanonicalizeHostname();
-    char *tuple[4];
+    int status;
+    char *args[4];
 
     args[0] = argv[1];
     args[2] = argv[3];
@@ -448,11 +456,13 @@ char **argv;
     }
     
     if (status = sms_query("add_locker", 4, args, Scream, NULL) != 0)
-       com_err(whoami, status, " in add_user_locker");
+       com_err(program_name, status, " in add_user_locker");
 
     return(DM_NORMAL);
 }
 
+/* needs to be fixed - CDP 6/10/88 */
+
 /*     Function Name: DeleteUserLocker
  *     Description: Deletes a locker - BOOM.
  *     Arguments: arc, argv - the name of the locker in argv[1]/
@@ -465,9 +475,10 @@ DeleteUserLocker(argc, argv)
 int argc;
 char **argv;
 {
+    int status;
     if (status = sms_query("delete_locker", 1, argv + 1,
-                          scream, (char *)NULL) != 0) 
-           com_err(whoami, status, " in delete_locker");
+                          Scream, (char *)NULL) != 0) 
+           com_err(program_name, status, " in delete_locker");
 
     return(DM_NORMAL);
 }
@@ -484,28 +495,24 @@ ChangeUserQuota(argc, argv)
 int argc;
 char *argv[];
 {
-    int i;
+    int status;
+    char error_buf[BUFSIZ];
     struct qelem *elem, *local;
     
     elem = GetUserInfo(QUOTA, argv[1], (char *) NULL);
 
     local = elem;
     while (local != NULL) {
-       char *info[4], buf[BUFSIZ];
+       char **info;
        info = (char **) local->q_data;
        PrintQuota(info);
-       if( !PromptWithDefault("New quota (in KB): ", buf, sizeof(buf), 
-                              quot_array[2]) )
-           return(DM_NORMAL);
+       GetValueFromUser("New quota (in KB): ", &info[Q_QUOTA]);
        
-       /* Reorganize for update nfs_quota. */
-       info[3] = info[2];
-       info[2] = argv[1];
-    
-       if (status = sms_query("update_nfs_quota", 4, info,
+       if (status = sms_query("update_nfs_quota", 3, info,
                               Scream, (char *) NULL) != 0) {
-           com_err(whoami, status, " in update_nfs_quota");
-           sprintf(error_buf,"Could not perform quota change on %s",info[0]); 
+           com_err(program_name, status, " in update_nfs_quota");
+           sprintf(error_buf,"Could not perform quota change on %s",
+                   info[Q_FILESYS]); 
            Put_message(error_buf);
        }
        local = local->q_forw;
@@ -552,7 +559,7 @@ int argc;
 char *argv[];
 {
     struct qelem *top, *elem;
-    char buf, temp_buf[BUFSIZ];
+    char buf;
 
     elem = top = GetUserInfo(NAME, argv[1], argv[2]);
 
@@ -568,10 +575,10 @@ char *argv[];
            break;
        case 'N':
        case 'n':
-           break;
            PrintUserInfo( (char **) elem->q_data, TRUE);
+           break;
        }
-       elem = elem->q_next;
+       elem = elem->q_forw;
     }
 
     FreeQueue(top);
@@ -590,13 +597,12 @@ int argc;
 char **argv;
 {
     struct qelem *top, *elem;
-    char buf, temp_buf[BUFSIZ];
 
     elem = top = GetUserInfo(CLASS, argv[1], (char *) NULL);
 
     while (elem != NULL) {
        PrintUserInfo( (char **) elem->q_data, TRUE);
-       elem = elem->q_next;
+       elem = elem->q_forw;
     }
 
     FreeQueue(top);
@@ -614,8 +620,10 @@ static void
 PrintQuota(info)
 char ** info;
 {
-    sprintf(buf, "Machine: %s\t\tDevice: %s\t\tQuota: %s",
-                  info[Q_MACHINE], info[Q_DEVICE], info[Q_QUOTA]);
+    char buf[BUFSIZ];
+
+    sprintf(buf, "Machine: %s\t\tDirectory: %s\t\tQuota: %s",
+                  info[Q_MACHINE], info[Q_DIRECTORY], info[Q_QUOTA]);
     Put_message(buf);
 }
 
@@ -635,8 +643,9 @@ int
 PrintPOBoxes(argc, argv, junk)
 int argc;
 char **argv;
-caddr_t junk;
+char * junk;
 {
+    char buf[BUFSIZ];
     /* no newline 'cause Put_message adds one */
 
     (void) sprintf(buf, "Address: %s@%s\t\tType: %s", argv[PO_BOX],
@@ -648,39 +657,42 @@ caddr_t junk;
 
 /*     Function Name: PrintUserInfo
  *     Description: Prints Information about a user.
- *     Arguments: answer - an argument list with the user information
+ *     Arguments: info - an argument list with the user information
  *                          in it.
  *                 name_only - if TRUE then print only the users name.
  *     Returns: none
  */
 
 void
-PrintUserInfo(answer, name_only)
-char ** answer;
+PrintUserInfo(info, name_only)
+char ** info;
 Bool name_only;
 {
+    char buf[BUFSIZ];
+
     if (name_only) {
-       sprintf(temp_buf, "%s, %s %s", info[U_LAST],
+       sprintf(buf, "%s, %s %s", info[U_LAST],
                info[U_FIRST], info[U_MIDDLE]);
-       sprintf(temp_buf, "%-40s/tUser Name: %s", temp_buf, info[U_NAME]);
-       Put_message(temp_buf);
+       sprintf(buf, "%-40s/tUser Name: %s", buf, info[U_NAME]);
+       Put_message(buf);
     }
     else {
-       (void) sprintf(temp_buf, 
+       (void) sprintf(buf, 
                       "Login name: %-10s/tUser id: %-10s\tLogin shell %s",
-                      answer[U_NAME], answer[U_UID], answer[U_SHELL]);
-       (void) Put_message(temp_buf);
-       (void) sprintf(temp_buf, "Full name: %s %s %s\tClass: %s", 
-                      answer[U_FIRST], answer[U_MIDDLE], 
-                      answer[U_LAST], answer[U_CLASS]);
-       (void) Put_message(temp_buf);
-       (void) sprintf(temp_buf,
-                      "Account status: %2s\tEncrypted MIT ID number: %s",
-                      answer[U_STATUS], answer[U_MITID]);
-       (void) Put_message(temp_buf);
-       (void) sprintf(temp_buf, "Last Modification by %s at %s with %s.",
-                      answer[U_MODBY], answer[U_MODTIME], answer[U_MODWITH]);
-       (void) Put_message(temp_buf);
+                      info[U_NAME], info[U_UID], info[U_SHELL]);
+       (void) Put_message(buf);
+       (void) sprintf(buf, "Full name: %s %s %s\tClass: %s", 
+                      info[U_FIRST], info[U_MIDDLE], 
+                      info[U_LAST], info[U_CLASS]);
+       (void) Put_message(buf);
+       (void) sprintf(buf,
+                      "Account status: %s\tEncrypted MIT ID number: %s",
+                      atoi(info[U_STATE]) ? "active" : "inactive",
+                      info[U_MITID]);
+       (void) Put_message(buf);
+       (void) sprintf(buf, "Last Modification by %s at %s with %s.",
+                      info[U_MODBY], info[U_MODTIME], info[U_MODWITH]);
+       (void) Put_message(buf);
     }
 }
 
index a3ab665a7a4a4266e4a6d7c573c14f02231fe76f..d6e6b9dce8552f66411a28da364561ded75d85be 100644 (file)
@@ -27,6 +27,7 @@
 
 #include "mit-copyright.h"
 #include "allmaint.h"
+#include "allmaint_funcs.h"
 #include "globals.h"
 #include "infodefs.h"
 
@@ -50,6 +51,43 @@ char ** info;
        free(pointer++);
 }
 
+/*     Function Name: FreeAndClear        - I couldn't resist the name.
+ *     Description: Clears pointer and optionially frees it.
+ *     Arguments: pointer - pointer to work with.
+ *                 free_it - if TRUE then free pointer.
+ *     Returns: none.
+ */
+
+void
+FreeAndClear(pointer, free_it)
+char ** pointer;
+Bool free_it;
+{
+    if (*pointer == NULL)
+       return;
+    else if (free_it)
+       free(*pointer);
+    *pointer = NULL;
+}
+
+/*     Function Name: QueueTop
+ *     Description: returns a qelem pointer that points to the top of
+ *                   a queue.
+ *     Arguments: elem - any element of a queue.
+ *     Returns: top element of a queue.
+ */
+    
+struct qelem * 
+QueueTop(elem)
+struct qelem * elem;
+{
+    if (elem == NULL)          /* NULL returns NULL.  */
+       return(NULL);
+    while (elem->q_back != NULL) 
+       elem = elem->q_back;
+    return(elem);
+}
+
 /*     Function Name: FreeQueueElem
  *     Description: Frees one element of the queue.
  *     Arguments: elem - the elem to free.
@@ -58,13 +96,15 @@ char ** info;
 
 void
 FreeQueueElem(elem)
-struct queue * elem;
+struct qelem * elem;
 {
-    if (elem->q_data != (char *) NULL) {
-       FreeInfo( (char **) elem->q_data); /* free info fields */
+    char ** info = (char **) elem->q_data;
+
+    if (info != (char **) NULL) {
+       FreeInfo( info ); /* free info fields */
        free(elem->q_data);             /* free info array itself. */
     }
-    rmqueue(elem);             /* remove this element from the queue */
+    remque(elem);              /* remove this element from the queue */
     free(elem);                        /* free its space. */
 }
 
@@ -76,9 +116,9 @@ struct queue * elem;
 
 void
 FreeQueue(elem)
-struct queue * elem;
+struct qelem * elem;
 {
-    struct queue *temp, *local = QueueTop(elem); 
+    struct qelem *temp, *local = QueueTop(elem); 
 
     while(local != NULL) {
        temp = local->q_forw;
@@ -106,30 +146,12 @@ struct qelem * elem;
     return(count);
 }
 
-/*     Function Name: QueueTop
- *     Description: returns a qelem pointer that points to the top of
- *                   a queue.
- *     Arguments: elem - any element of a queue.
- *     Returns: top element of a queue.
- */
-    
-struct qelem * 
-QueueTop(elem)
-struct qelem * elem;
-{
-    if (elem == NULL)          /* NULL returns NULL.  */
-       return(NULL);
-    while (elem->q_back != NULL) 
-       elem = elem->q_back;
-    return(elem);
-}
-
 /* ARGSUSED */
 int
 StoreInfo(argc, argv, data)
 int argc;
 char ** argv;
-caddr_t data;
+char * data;
 {
     char ** info = (char **) malloc( MAX_ARGS_SIZE * sizeof(char *) );
     struct qelem ** old_elem = (struct qelem **) data;
@@ -140,7 +162,7 @@ caddr_t data;
        info[count] = Strsave(argv[count]);
     info[count] = NULL;                /* NULL terminate this sucker. */
 
-    if (* old_elem == (struct qelem **) NULL) {         /* first elem. */
+    if (*old_elem == (struct qelem *) NULL) {   /* first elem. */
        new_elem->q_data = (char *) info;
        new_elem->q_forw = new_elem->q_back = (struct qelem *) NULL;
     }
@@ -161,13 +183,15 @@ caddr_t data;
  */
 
 int
-CountArgs(info);
+CountArgs(info)
 char ** info;
 {
     int number = 0;
     
-    while (*info != NULL)
+    while (*info != NULL) {
        number++;
+       info++;
+    }
 
     return(number);
 }    
@@ -179,57 +203,15 @@ char ** info;
  *     Returns: doesn't exit.
  */
 
-static int
+int
 Scream()
 {
-    com_err(whoami, status,
+    com_err(program_name, 0,
            "\nAn SMS update returned a value -- programmer botch\n");
     sms_disconnect();
     exit(1);
 }
 
-/*     Function Name: BoolAnswer
- *     Description: returns TRUE or FALSE in arg, depending upon
- *                   the value of the string in argv[0].
- *     Arguments: argc, argv - argv[0] contains "true" or "false".
- *     Returns: SMS_CONT.
- */
-
-/*ARGSUSED*/
-static int 
-BoolAnswer(argc, argv, arg)
-int argc;
-char *argv[];
-caddr_t arg;
-
-{
-    int *result = (int *) arg;
-
-    if (strcmp(argv[0], "true") == 0)
-       *result = TRUE;
-    else 
-       *result = FALSE;
-    return(SMS_CONT);
-}
-
-/*     Function Name: BoolQuery
- *     Description: This function makes the query, but returns TRUE or FALSE
- *                   instead of SMS_CONT or SMS_QUIT.
- *     Arguments: name - name of query
- *                 argc, argv - args to pass to query.
- *     Returns: TRUE or FALSE.
- */
-
-Bool
-BoolQuery(name, argc, argv)
-char *name;
-int argc;
-char *argv[];
-{
-    sms_query(name, argc, argv, BoolAnswer, (caddr_t) & result);
-    return(result);
-}
-
 /*     Function Name: PromptWithDefault
  *     Description: allows a user to be prompted for input, and given a 
  *                   default choice.
@@ -277,11 +259,9 @@ int bool_def;
        case 'n':
        case 'N':
            return(FALSE);
-           break;
        case 'y':
        case 'Y':
            return(TRUE);
-           break;
        default:
            Put_message("Please answer 'y' or 'n'.");
            break;
@@ -299,7 +279,7 @@ int bool_def;
  */
 
 Bool
-YesNoQuestion(prompt, bool_def)
+YesNoQuitQuestion(prompt, bool_def)
 char *prompt;
 int bool_def;
 {
@@ -312,15 +292,12 @@ int bool_def;
        case 'n':
        case 'N':
            return(FALSE);
-           break;
        case 'y':
        case 'Y':
            return(TRUE);
-           break;
        case 'q':
        case 'Q':
            return(-1);
-           break;
        default:
            Put_message("Please answer 'y', 'n' or 'q'.");
            break;
@@ -335,7 +312,7 @@ int bool_def;
  *     Returns:   TRUE/FALSE - wether or not the confirmation occured.
  */
 
-static int
+int
 Confirm(prompt)
 char * prompt;
 {
@@ -371,13 +348,13 @@ int
 ToggleVerboseMode()
 {
 
-  if(verbose)
-    Put_message("Delete functions will be silent\n");
-  else {
-    Put_message("Delete functions will first confirm\n");
-
-  verbose ~= verbose;
+  verbose = ~verbose;
 
+  if (verbose)
+    Put_message("Delete functions will first confirm\n");
+  else
+    Put_message("Delete functions will be silent\n");
+    
   return(DM_NORMAL);
 }
 
@@ -403,9 +380,8 @@ NullFunc()
  *             big way.
  */
 
-SlipInNewName(info, name);
+SlipInNewName(info, name)
 char ** info;
-
 char * name;
 {
     register int i;
@@ -417,25 +393,6 @@ char * name;
     info[1] = Strsave(name);   /* now slip in the name. */
 }
 
-/*     Function Name: FreeAndClear        - I couldn't resist the name.
- *     Description: Clears pointer and optionially frees it.
- *     Arguments: pointer - pointer to work with.
- *                 free - if TRUE then free pointer.
- *     Returns: none.
- */
-
-FreeAndClear(pointer, free)
-caddr_t pointer;
-Bool free;
-{
-    if (pointer == NULL)
-       return();
-    else if (free)
-       free(pointer);
-
-    pointer = NULL;
-}
-
 /*     Function Name: GetValueFromUser
  *     Description: This function gets a value from a user for the field
  *                   specified.
@@ -447,14 +404,14 @@ Bool free;
 
 void
 GetValueFromUser(prompt, pointer)
-char * prompt, * pointer;
+char * prompt, ** pointer;
 {
     char buf[BUFSIZ];
 
-    PromptWithDefault(prompt, buf, BUFSIZ, pointer);
+    PromptWithDefault(prompt, buf, BUFSIZ, *pointer);
     if ( pointer != NULL)
-       free(pointer);
-    pointer = Strsave(buf);
+       free(*pointer);
+    *pointer = Strsave(buf);
 }
 
 /*     Function Name: CanonicalizeHostname
@@ -553,6 +510,7 @@ int argc;
 char **argv, *callback;
 {
     char buf[BUFSIZ];
+    register int i;
 
     found_some = TRUE;
     (void) strcpy(buf,argv[0]);        /* no newline 'cause Put_message adds one */
@@ -593,7 +551,7 @@ char **argv, *callback;
  */
 
 int
-PrintHelp(message);
+PrintHelp(message)
 char ** message;
 {
     Print(CountArgs(message), message, (char *) NULL);
index 39c9ff527cdd02394b94ed8667bf7d1ff034eeca..7975e1f5e369cb129bb31019fe1ff16a5778f2ba 100644 (file)
 
 #include "mit-copyright.h"
 
+/* alias queries. */
 
-/* Machine information queries */
-
-#define M_NAME       0
-#define M_TYPE       1
-#define M_MODTIME    2
-#define M_MODBY      3
-#define M_MODWITH    4
-#define M_END        5
-
-/*  Machine to Cluster mapping */
-
-#define MAP_MACHINE  0
-#define MAP_CLUSTER  1
-#define MAP_END      2
+#define ALIAS_NAME  0
+#define ALIAS_TYPE  1
+#define ALIAS_TRANS 2
+#define ALIAS_END   3
 
 /* Cluster information queries */
 
 #define CD_DATA      2
 #define CD_END       3
 
+/* Delete Member from list queries. */
+
+#define DM_LIST      0
+#define DM_TYPE      1
+#define DM_MEMBER    2
+#define DM_END       3
+
+/* Filesys queries (attachmaint) */
+
+#define FS_NAME         0
+#define FS_TYPE         1
+#define FS_MACHINE      2
+#define FS_PACK         3
+#define FS_M_POINT      4
+#define FS_ACCESS       5
+#define FS_COMMENTS     6
+#define FS_OWNER        7
+#define FS_OWNERS       8
+#define FS_CREATE       9
+#define FS_L_TYPE       10
+#define FS_MODTIME      11
+#define FS_MODBY        12
+#define FS_MODWITH      13
+#define FS_END          14
+
+/* Get List Of Member queries. */
+
+#define GLOM_NAME     0
+#define GLOM_ACTIVE   1
+#define GLOM_PUBLIC   2
+#define GLOM_HIDDEN   3
+#define GLOM_MAILLIST 4
+#define GLOM_GROUP    5
+#define GLOM_END      6
+
 /* General List information Queries. */
 
 #define L_NAME     0
 #define L_ACL_NAME 8
 #define L_DESC     9
 #define L_MODTIME  10
-#define L_MODWHO   11
+#define L_MODBY   11
 #define L_MODWITH  12
 #define L_END      13
 
-/* Get List Of Member queries. */
-
-#define GLOM_NAME     0
-#define GLOM_ACTIVE   1
-#define GLOM_PUBLIC   2
-#define GLOM_HIDDEN   3
-#define GLOM_MAILLIST 4
-#define GLOM_GROUP    5
-#define GLOM_END         6
-
 /* List Member information queries. */
 
 #define LM_LIST   0
 #define LM_TYPE   1
 #define LM_MEMBER 2
 #define LM_END    3
-#define LM_END     4
+
+/* Machine information queries */
+
+#define M_NAME       0
+#define M_TYPE       1
+#define M_MODTIME    2
+#define M_MODBY      3
+#define M_MODWITH    4
+#define M_END        5
+
+/*  Machine to Cluster mapping */
+
+#define MAP_MACHINE  0
+#define MAP_CLUSTER  1
+#define MAP_END      2
 
 /*  NFS phys. queries. */
 
 #define NFS_MODWITH 8
 #define NFS_END     9
 
-/* Quota queries */
-
-#define Q_MACHINE 0 
-#define Q_DEVICE  1
-#define Q_QUOTA   2
-#define Q_END     3
-
 /* PO box infomarion queries */
 
 #define PO_NAME    0
 #define PO_BOX     3
 #define PO_END     4
 
+/* Quota queries */
+
+#define Q_FILESYS   0
+#define Q_LOGIN     1
+#define Q_QUOTA     2
+#define Q_DIRECTORY 3  
+#define Q_MACHINE   4
+#define Q_MODTIME   5
+#define Q_MODBY     6
+#define Q_MODWITH   7
+#define Q_END       8
+
 /* User Information queries */
 
 #define U_NAME    0
This page took 0.223559 seconds and 5 git commands to generate.