]> andersk Git - moira.git/blobdiff - clients/moira/lists.c
fixed capitalization of a message, and make recursive not the default
[moira.git] / clients / moira / lists.c
index 70bdc212818202a10fca954695fb1a55ef3f48e5..e41d8bc473b84594b23da1a53c8fb1c483c0039c 100644 (file)
@@ -1,19 +1,19 @@
-#ifndef lint
+#if (!defined(lint) && !defined(SABER))
   static char rcsid_module_c[] = "$Header$";
 #endif lint
 
-/*     This is the file lists.c for allmaint, the SMS client that allows
- *      a user to maintaint most important parts of the SMS database.
- *     It Contains: 
+/*     This is the file lists.c for the SMS Client, which allows a nieve
+ *      user to quickly and easily maintain most parts of the SMS database.
+ *     It Contains: All list manipulation functions, except delete.
  *     
- *     Borrowed from listmaint code:   4/12/88
- *     By:                             Chris D. Peterson
+ *     Created:        4/12/88
+ *     By:             Chris D. Peterson
  *
  *      $Source$
  *      $Author$
  *      $Header$
  *     
- *     Copyright 1987, 1988 by the Massachusetts Institute of Technology.
+ *     Copyright 1988 by the Massachusetts Institute of Technology.
  *
  *     For further information on copyright and distribution 
  *     see the file mit-copyright.h
 #include <menu.h>
 
 #include "mit-copyright.h"
-#include "allmaint.h"
+#include "defs.h"
+#include "f_defs.h"
 #include "globals.h"
 #include "infodefs.h"
 
 #define LIST    0
 #define MEMBERS 1
 #define GLOM    2
-#define ACL_USE 3
+#define ACE_USE 3
+
+#define DEFAULT_ACTIVE      DEFAULT_YES
+#define DEFAULT_PUBLIC      DEFAULT_YES
+#define DEFAULT_HIDDEN      DEFAULT_NO
+#define DEFAULT_MAILLIST    DEFAULT_YES
+#define DEFAULT_GROUP       DEFAULT_NO
+#define DEFAULT_GID         UNIQUE_GID
+#define DEFAULT_ACE_TYPE    "user"
+#define DEFAULT_ACE_NAME    (user)
+#define DEFAULT_DESCRIPTION DEFAULT_COMMENT
+
+/* globals only for this file. */
+
+static char current_list[BUFSIZ];
+
+/*     Function Name: PrintListAce
+ *     Description: This function prints the list ace information.
+ *     Arguments: info - an info structure.
+ *     Returns: none.
+ */
+
+static void
+PrintListAce(info)
+char ** info;
+{
+    char buf[BUFSIZ];
+
+    Put_message(" ");
+    sprintf(buf, "Item Administered: %-20s Name: %s", info[ACE_TYPE], 
+           info[ACE_NAME]);
+    Put_message(buf);
+}
 
 /*     Function Name: PrintListInfo
  *     Description: This function Prints out the List info in a coherent form.
  *     Returns: none.
  */
 
-void
+static void
 PrintListInfo(info)
 char ** info;
 {
     char buf[BUFSIZ];
 
-    (void) sprintf(buf, "List: %s",info[L_NAME]);
+    Put_message(" ");
+    (void) sprintf(buf, "%20sList: %s", "", info[L_NAME]);
     (void) Put_message(buf);
-    (void) sprintf(buf, "\nDescription: %s", info[L_DESC]);
+    (void) sprintf(buf, "Description: %s", info[L_DESC]);
     (void) Put_message(buf);
     if ( atoi(info[L_MAILLIST]))
        Put_message("This list is a mailing list.");
@@ -60,23 +94,22 @@ char ** info;
        Put_message(buf);
     }
     else
-       Put_message("This is NOT a Group.");
+       Put_message("This list is NOT a Group.");
 
-    if (strcmp(info[L_ACL_TYPE],"NONE") == 0)
+    if (strcmp(info[L_ACE_TYPE],"NONE") == 0)
        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]);
+       sprintf(buf, "The Administrator of this list is the %s: %s",
+               info[L_ACE_TYPE], info[L_ACE_NAME]);
        Put_message(buf);
     }
 
     (void) sprintf(buf, "This list is: %s, %s, and %s",
-                  info[L_ACTIVE] ? "active" : "inactive",
-                  info[L_PUBLIC] ? "public" : "private",
-                  info[L_HIDDEN] ? "hidden" : "visible");
+                  atoi(info[L_ACTIVE]) ? "active" : "inactive",
+                  atoi(info[L_PUBLIC]) ? "public" : "private",
+                  atoi(info[L_HIDDEN]) ? "hidden" : "visible");
     (void) Put_message(buf);
-    (void) sprintf(buf, "Last modification at %s, by %s using the program %s",
-                  info[L_MODTIME], info[L_MODBY], info[L_MODWITH]);
+    sprintf(buf, MOD_FORMAT, info[L_MODBY], info[L_MODTIME], info[L_MODWITH]);
     (void) Put_message(buf);
 }
 
@@ -91,17 +124,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_list_info");
            return (NULL);
        }
        break;
@@ -109,25 +143,25 @@ 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_members_of_list");
            return (NULL);
        }
        break;
     case GLOM:
        args[0] = name1;        
        args[1] = name2;        
-       if ( (status =  sms_query("get_list_of_member", 2, args,
+       if ( (status =  sms_query("get_lists_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_list_of_members");
            return (NULL);
        }
        break;
-    case ACL_USE:
+    case ACE_USE:
        args[0] = name1;        
        args[1] = name2;        
-       if ( (status =  sms_query("get_acl_use", 2, args,
+       if ( (status =  sms_query("get_ace_use", 2, args,
                               StoreInfo, (char *) &elem)) != 0) {
-           com_err(whoami, status, " in get_nfs_quotas_by_user");
+           com_err(program_name, status, " in get_ace_use");
            return (NULL);
        }
        break;
@@ -145,37 +179,38 @@ 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(" ");
+    sprintf(temp_buf,"Setting information of list %s.",info[L_NAME]);
     Put_message(temp_buf);
+    Put_message(" ");
 
     if (name) {
        newname = Strsave(info[L_NAME]);
-       GetValueFromUser("The new name for this list.", &newname);
+       GetValueFromUser("The new name for this list", &newname);
     }
-    GetValueFromUser("Is this list active (1/0): ", &info[L_ACTIVE]);
-    GetValueFromUser("Is this list public (1/0): ", &info[L_PUBLIC]);
-    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]);
-    GetValueFromUser("What Type of Administrator (none, user, list): ",
-                    &info[L_ACL_TYPE]);
-    if ( strcmp(info[L_ACL_TYPE],"USER") == 0) 
+    GetYesNoValueFromUser("Is this an active list", &info[L_ACTIVE]);
+    GetYesNoValueFromUser("Is this a public list", &info[L_PUBLIC]);
+    GetYesNoValueFromUser("Is this a hidden list", &info[L_HIDDEN]);
+    GetYesNoValueFromUser("Is this a maillist", &info[L_MAILLIST]);
+    GetYesNoValueFromUser("Is this a group", &info[L_GROUP]);
+    if (atoi(info[L_GROUP]))
+       GetValueFromUser("What is the GID for this group.", &info[L_GID]);
+
+    GetTypeFromUser("What Type of Administrator", "ace_type",&info[L_ACE_TYPE]);
+    if ( (strcmp(info[L_ACE_TYPE], "USER") == 0) || 
+       (strcmp(info[L_ACE_TYPE], "user") == 0) )
        GetValueFromUser("Who will be the administrator of this list: ",
-                        &info[L_ACL_NAME]);
-    if ( strcmp(info[L_ACL_TYPE],"USER") == 0) 
+                        &info[L_ACE_NAME]);
+    if ( (strcmp(info[L_ACE_TYPE], "LIST") == 0) ||
+       (strcmp(info[L_ACE_TYPE], "list") == 0) )
        GetValueFromUser("Which group will be the administrator of this list: ",
-                        &info[L_ACL_NAME]);
+                        &info[L_ACE_NAME]);
     GetValueFromUser("Description: ", &info[L_DESC]);
 
     FreeAndClear(&info[L_MODTIME], TRUE);
@@ -195,10 +230,11 @@ 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.
  */
 
+/* ARGSUSED */
 int
 ShowListInfo(argc, argv)
 int argc;
@@ -206,7 +242,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;
@@ -216,77 +252,115 @@ char **argv;
     return(DM_NORMAL);
 }
 
+/*     Function Name: RealUpdateList
+ *     Description: performs the actual update of the list.
+ *     Arguments: info - all information needed to update the list.
+ *                 junk - an UNUSED boolean.
+ *     Returns: none.
+ */
+/* ARGSUSED */   
+static void
+RealUpdateList(info, junk)
+char ** info;
+Bool junk;
+{
+    register int stat;
+    char ** args;
+    
+    args = AskListInfo(info, TRUE);
+    if ( (stat = sms_query("update_list", CountArgs(args), args, 
+                          Scream, (char *) NULL)) != SMS_SUCCESS) {
+       com_err(program_name, stat, " in UpdateList."); 
+       Put_message("List ** NOT ** Updated.");
+    }
+    else
+       Put_message("List successfully updated.");
+}
+
 /*     Function Name: UpdateList
- *     Description: 
+ *     Description: updates the information on a list.
  *     Arguments: argc, argv - name of list in argv[1].
  *     Returns: DM Status code.
  */
 
+/* ARGSUSED */
 int
 UpdateList(argc, argv)
 int argc;
 char **argv;
 {
-    char **info, **up_args;
-    struct qelem *top, *list;
-    int status;
+    struct qelem *top;
 
-    list = top = GetListInfo(LIST, argv[1], (char *) NULL);
-    
-    while (list != NULL) {
-       info = (char **) list->q_data;
-       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."); 
-           Put_message("List Not Updated.");
-           list = list->q_forw;
-       }
-    }
+    top = GetListInfo(LIST, argv[1], (char *) NULL);
+    QueryLoop(top, NullPrint, RealUpdateList, "Update the list");
 
     FreeQueue(top);
     return(DM_NORMAL);
 }
 
+/*     Function Name: SetDefaults
+ *     Description: sets defaults for AddList function
+ *     Arguments: info - the array to add them to.
+ *                 name - name of the program to add.
+ *     Returns: defaults - the default information.
+ */
+
+static char **
+SetDefaults(info, name)
+char ** info;
+char * name;
+{
+   info[L_NAME] =     Strsave(name);
+   info[L_ACTIVE] =   Strsave(DEFAULT_ACTIVE);
+   info[L_PUBLIC] =   Strsave(DEFAULT_PUBLIC);
+   info[L_HIDDEN] =   Strsave(DEFAULT_HIDDEN);
+   info[L_MAILLIST] = Strsave(DEFAULT_MAILLIST);
+   info[L_GROUP] =    Strsave(DEFAULT_GROUP);
+   info[L_GID] =      Strsave(DEFAULT_GID);
+   info[L_ACE_TYPE] = Strsave(DEFAULT_ACE_TYPE);
+   info[L_ACE_NAME] = Strsave(DEFAULT_ACE_NAME);
+   info[L_DESC] =     Strsave(DEFAULT_DESCRIPTION);
+   info[L_MODTIME] = info[L_MODBY] = info[L_MODWITH] = info[L_END] = NULL;
+   return(info);
+}
+
 /*     Function Name: AddList
  *     Description: 
  *     Arguments: argc, argv - name of list in argv[1].
- *     Returns: DM Status code.
+ *     Returns: SUB_ERROR if list not created.
  */
 
+/* ARGSUSED */
 int
 AddList(argc, argv)
 int argc;
 char **argv;
 {
     static char *info[MAX_ARGS_SIZE], **add_args;
-    struct qelem *top, *list;
-    int status;
+    int status, ret_code = SUB_NORMAL;
 
-    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)
+       if (status == SMS_SUCCESS)
            Put_message("This list already exists.");
        else
-           com_err(whoami, status, " in AddList.");    
-       return(DM_QUIT);
+           com_err(program_name, status, " in AddList.");      
+       return(SUB_ERROR);
     }
 
-    add_args = AskListInfo(info, FALSE);
+    add_args = AskListInfo(SetDefaults(info,argv[1]), FALSE);
 
     if ( (status = sms_query("add_list", CountArgs(add_args), add_args,
-                            Scream, (char *) NULL)) != 0) {
-       com_err(whoami, status, " in AddList.");        
+                            Scream, (char *) NULL)) != SMS_SUCCESS) {
+       com_err(program_name, status, " in AddList.");  
        Put_message("List Not Created.");
-       list = list->q_forw;
+       ret_code = SUB_ERROR;
     }
 
     FreeInfo(info);
-    return(DM_NORMAL);
+    return(ret_code);
 }
 
 /*     Function Name: Instructions
@@ -296,22 +370,22 @@ 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",
+       "Listmaint handles the creation, deletion, and updating of lists.",
+       "A list can be a mailing list, a group list, or both.",
        "The concept behind lists is that a list has an owner",
-       "- administrator -  and members.\n";
-       "The administrator of a list may be another list.\n",
+       "- administrator -  and members.",
+       "The administrator of a list may be another list.",
        "The members of a list can be users (login names), other lists,",
-       "or address strings.\n",
+       "or address strings.",
        "You can use certain keys to do the following:",
-       "    Refresh the screen - Type ctrl-L.\n",
-       "    Escape from a function - Type ctrl-C.\n",
-       "    Suspend the program (temporarily) - Type ctrl-Z.\n",
+       "    Refresh the screen - Type ctrl-L.",
+       "    Escape from a function - Type ctrl-C.",
+       "    Suspend the program (temporarily) - Type ctrl-Z.",
        NULL,
-    }
+    };
 
     return(PrintHelp(message));
 }
@@ -332,25 +406,37 @@ Menu *m;
 int argc;
 char **argv;
 {
-    char buf[BUFSIZ], temp_buf[BUFSIZ];
+    char temp_buf[BUFSIZ];
     char *list_name = argv[1];
+    register int stat;    
+
+    if (!ValidName(list_name))
+       return(DM_QUIT);
 
     if (*argv[0] == 'a') {     /* add_list */
-       /* actually, AddList no longer returns DM_QUIT.
-        * Maybe later, when com_err no longer blows out there.
-        */
-       if (AddList(argc, argv) == DM_QUIT)
+       if (AddList(argc, argv) == SUB_ERROR)
            return(DM_QUIT);
        (void) sprintf(temp_buf, "List '%s' created. Do you want to %s",
-                      list_name, "change its membership?");
+                      list_name, "change its membership (y/n)? ");
        if (YesNoQuestion(temp_buf, TRUE) != TRUE )
            return(DM_QUIT);
     }
-    else if (!ValidName(list_name)) {
-       (void) sprintf(temp_buf, "Bad list: '%s'", list_name);
-       Put_message(temp_buf);
-    return(DM_QUIT);
-    }
+    else 
+       /* All we want to know is if it exists. */
+       switch( (stat = sms_query("count_members_of_list", 1, argv + 1,
+                                  NullFunc, (char *) NULL))) {
+       case SMS_SUCCESS:
+           break;
+       case SMS_LIST:
+           Put_message("This list does not exist.");
+           return(DM_QUIT);
+       case SMS_PERM:
+           Put_message("You are not allowed to view this list.");
+           break;
+       default:
+           com_err(program_name, stat, " in get_list_info");
+           return(DM_QUIT);
+       }
 
     (void) sprintf(temp_buf, 
                   "Change/Display membership of '%s'", list_name);
@@ -383,15 +469,20 @@ Menu *m;
  */
 
 void
-ListMembersByType(type);
+ListMembersByType(type)
 char * type;
 {
     char temp_buf[BUFSIZ];
+    register int status;
+    char * args[10];
+
+    args[0] = current_list;
+    args[1] = NULL;
 
     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", CountArgs(args), args
+                            PrintByType, type)) != 0)
+       com_err(program_name, status, " in ListMembersByType");
     if (!found_some) {
        if (type == NULL)
            Put_message("List is empty (no members).");
@@ -468,24 +559,19 @@ char *action, **ret_argv;
     char temp_buf[BUFSIZ], ret_buf[BUFSIZ];
 
     ret_argv[LM_LIST] = Strsave(current_list);
-    ret_argv[LM_MEMBER] = "nobody";
 
-    PromptWithDefault("Type of member (USER, LIST, or STRING)",
-                       ret_buf, BUFSIZ, "USER");
-    ret_argv[LM_TYPE]= Strsave(ret_buf);
+    ret_argv[LM_TYPE] = Strsave("user");
+    GetTypeFromUser("Type of member", "member", &ret_argv[LM_TYPE]);
 
-    status = sms_access("add_member_to_list", 3, ret_argv);
-    if (status == SMS_TYPE) {
-       Put_message("\"type\" must be one of 'STRING', 'LIST', or 'USER'.");
+    sprintf(temp_buf,"Name of %s to %s", ret_argv[LM_TYPE], action);
+    ret_argv[LM_MEMBER] = Strsave(user);
+    GetValueFromUser(temp_buf, &ret_argv[LM_MEMBER]);
+    ret_argv[LM_END] = NULL;           /* NULL terminate this list. */
+
+    if (!ValidName( ret_argv[LM_MEMBER] ) ) {
+       FreeInfo(ret_argv);
        return(SUB_ERROR);
-    } else if (status) {
-       com_err(whoami, 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. */
     return(SUB_NORMAL);
 }
 
@@ -498,17 +584,25 @@ char *action, **ret_argv;
 int
 AddMember()
 {
-    char *args[10];
+    char *args[10], temp_buf[BUFSIZ];
+    register int status;
 
-    if( GetMemberInfo("add", args) == SUB_ERROR )
+    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");
+    if ( (status = sms_query("add_member_to_list", CountArgs(args), args,
+                          Scream, NULL)) != SMS_SUCCESS) {
+       if (status == SMS_EXISTS) {
+           sprintf(temp_buf, "The %s %s is already a member of LIST %s.",
+                   args[LM_TYPE], args[LM_MEMBER], args[LM_LIST]);
+           Put_message(temp_buf);
+       }
+       else 
+           com_err(program_name, status, " in AddMember");
+    }
 
     FreeInfo(args);
-    return (DM_NORMAL);
+    return(DM_NORMAL);
 }
 
 /*     Function Name: DeleteMember
@@ -521,6 +615,7 @@ int
 DeleteMember()
 {
     char *args[10];
+    register int status;
 
     if( GetMemberInfo("delete", args) == SUB_ERROR )
        return(DM_NORMAL);
@@ -528,7 +623,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");
        else
            Put_message("Deletion Completed.");
     }
@@ -539,48 +634,58 @@ DeleteMember()
     return(DM_NORMAL);
 }
 
-
 /*     Function Name: InterRemoveItemFromLists
  *     Description: This function allows interactive removal of an item
  *                   (user, string, list) for all list  that it is on.
  *     Arguments: none.
  *     Returns: DM_NORMAL.
+ *      NOTES: QueryLoop() does not work here because info does not have
+ *             enough information in it to delete the member from the list.
  */
 
 int
 InterRemoveItemFromLists()
 {
-    char type[BUFSIZ], name[BUFSIZ], args[10];
-    qelem *top, *elem;
+    register int status;
+    char type[BUFSIZ], name[BUFSIZ], *args[10], buf[BUFSIZ];
+    struct qelem *top, *elem;
 
-    if ( !(PromptWithDefault("Type of member (user, list, string)", type, 
+    if ( !(PromptWithDefault("Type of member (user, list, string)", type, 
                            BUFSIZ, "user")) )
        return(DM_NORMAL);
     
-    if ( !(PromptWithDefault("Name of member? ", name, BUFSIZ, user)) ) {
+    sprintf(buf, "Name of %s", type);
+    if ( !(PromptWithDefault(buf, name, BUFSIZ, user)) ) {
        return(DM_NORMAL);
     }
 
+    if (!ValidName(name))
+       return(DM_NORMAL);
+
     top = elem = GetListInfo(GLOM, type, name);
 
     while(elem != NULL) {
-       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') {
+       char line[BUFSIZ];
+       char ** info = (char **) elem->q_data;
+       sprintf(line, "Delete %s %s from the list \"%s\" (y/n/q)? ", type,
+               name, info[GLOM_NAME]);
+       switch (YesNoQuitQuestion(line, FALSE)) {
+       case TRUE:
            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");
-       } 
-       else if (buf[0] == 'q' || buf[0] == 'Q') {
-           Put_message("Quitting.");
+               /* should probabally check to delete list. */
+               com_err(program_name, status, " in delete_member");
            break;
+       case FALSE:
+           break;
+       default:
+           Put_message("Aborting...");
+           FreeQueue(top);
+           return(DM_NORMAL);
        }
        elem = elem->q_forw;
     }
@@ -592,26 +697,27 @@ 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;
+    char buf[BUFSIZ], temp_buf[BUFSIZ], *type, *name, **info;
+    Bool maillist, group;
+    struct qelem *top, *elem;
 
-    if ( !(PromptWithDefault("Type of member (user, list, string)", buf, 
+    if ( !(PromptWithDefault("Type of member (user, list, string)", buf, 
                            BUFSIZ, "user")) )
        return(DM_NORMAL);
 
-    sprintf(buf, "R%s", buf);  /* What we really want is a recursive search */
-    type = Strsave(buf);
-    
-    if ( !(PromptWithDefault("Name of member? ", buf, BUFSIZ, user)) ) {
+    /* What we really want is a recursive search */
+    sprintf(temp_buf, "R%s", buf); 
+    type = Strsave(temp_buf);
+
+    sprintf(temp_buf, "Name of %s", buf);
+    if ( !(PromptWithDefault(temp_buf, buf, BUFSIZ, user)) ) {
        free(type);
        return(DM_NORMAL);
     }
@@ -637,39 +743,37 @@ 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], temp_buf[BUFSIZ], *type, *name;
+    struct qelem *top;
 
-    if ( !(PromptWithDefault("Type of member (user, list, string)", buf, 
+    if ( !(PromptWithDefault("Type of member (user, list, string)", buf, 
                            BUFSIZ, "user")) )
        return(DM_NORMAL);
 
-    if ( YesNoQuestion("Do you want a recursive search?",TRUE) == 1 )
-       sprintf(buf,"R%s",buf); /* "USER" to "RUSER" etc. */
-    type = Strsave(buf);
+    if ( YesNoQuestion("Do you want a recursive search (y/n)", FALSE) == 1 ) {
+       sprintf(temp_buf, "R%s", buf);  /* "USER" to "RUSER" etc. */
+       type = Strsave(temp_buf);
+    }
+    else 
+       type = Strsave(buf);
     
-    if ( !(PromptWithDefault("Name of member? ", buf, BUFSIZ, user)) ) {
+    sprintf(temp_buf, "Name of %s", buf);
+    if ( !(PromptWithDefault(temp_buf, buf, BUFSIZ, user)) ) {
        free(type);
        return(DM_NORMAL);
     }
     name = Strsave(buf);
 
-    top = elem = GetListInfo(ACL_USE, type, name);
-    while (elem != NULL) {
-       info = (char **) elem->q_data;
-       sprintf(buf, "Type: %s,\tName: %s", info[0], info[1]);
-       Put_message(buf);
-       elem = elem->q_forw;
-    }
+    top = GetListInfo(ACE_USE, type, name);
+    Loop(top, PrintListAce);
+
     FreeQueue(top);
     return (DM_NORMAL);
 }
@@ -682,19 +786,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");
     return (DM_NORMAL);
 }
 
@@ -706,19 +811,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");
 
     return (DM_NORMAL);        
 }
@@ -731,19 +837,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");
 
     return (DM_NORMAL);        
 }
This page took 0.0741 seconds and 4 git commands to generate.