3 * This is the file lists.c for the Moira Client, which allows users
4 * to quickly and easily maintain most parts of the Moira database.
5 * It Contains: All list manipulation functions, except delete.
8 * By: Chris D. Peterson
10 * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
11 * For copying and distribution information, please see the file
15 #include <mit-copyright.h>
18 #include <moira_site.h>
29 struct mqelem *GetListInfo(int type, char *name1, char *name2);
30 char **AskListInfo(char **info, Bool name);
31 int AddList(int argc, char **argv);
32 void ListMembersByType(char *type, int tags);
33 int GetMemberInfo(char *action, char **ret_argv);
40 #define DEFAULT_ACTIVE DEFAULT_YES
41 #define DEFAULT_PUBLIC DEFAULT_YES
42 #define DEFAULT_HIDDEN DEFAULT_NO
43 #define DEFAULT_MAILLIST DEFAULT_YES
44 #define DEFAULT_GROUP DEFAULT_NO
45 #define DEFAULT_GID UNIQUE_GID
46 #define DEFAULT_NFSGROUP DEFAULT_NO
47 #define DEFAULT_ACE_TYPE "user"
48 #define DEFAULT_ACE_NAME (user)
49 #define DEFAULT_MEMACE_TYPE "NONE"
50 #define DEFAULT_MEMACE_NAME "NONE"
51 #define DEFAULT_DESCRIPTION DEFAULT_COMMENT
53 /* globals only for this file. */
55 static char current_list[BUFSIZ];
58 /* Function Name: PrintListAce
59 * Description: This function prints the list ace information.
60 * Arguments: info - an info structure.
64 static void PrintListAce(char **info)
68 sprintf(buf, "Item: %-20s Name: %s", info[ACE_TYPE], info[ACE_NAME]);
72 /* Function Name: PrintListInfo
73 * Description: This function Prints out the List info in a coherent form.
74 * Arguments: info - the List info.
78 static void PrintListInfo(char **info)
83 sprintf(buf, "%20sList: %s", "", info[L_NAME]);
85 sprintf(buf, "Description: %s", info[L_DESC]);
87 if (atoi(info[L_MAILLIST]))
88 Put_message("This list is a mailing list.");
90 Put_message("This list is NOT a mailing list.");
91 if (atoi(info[L_GROUP]))
93 sprintf(buf, "This list is a Group%s and its ID number is %s",
94 atoi(info[L_NFSGROUP]) ? " and an NFS Group," : "",
99 Put_message("This list is NOT a Group.");
101 if (!strcmp(info[L_ACE_TYPE], "NONE"))
102 Put_message("This list has no Administrator, how strange?!");
105 sprintf(buf, "The Administrator of this list is the %s: %s",
106 info[L_ACE_TYPE], info[L_ACE_NAME]);
110 if (strcmp(info[L_MEMACE_TYPE], "NONE"))
112 sprintf(buf, "The Membership Administrator of this list is the %s: %s",
113 info[L_MEMACE_TYPE], info[L_MEMACE_NAME]);
117 sprintf(buf, "This list is: %s, %s, and %s",
118 atoi(info[L_ACTIVE]) ? "active" : "inactive",
119 atoi(info[L_PUBLIC]) ? "public" : "private",
120 atoi(info[L_HIDDEN]) ? "hidden" : "visible");
122 sprintf(buf, MOD_FORMAT, info[L_MODBY], info[L_MODTIME], info[L_MODWITH]);
126 /* Function Name: GetListInfo
127 * Description: Stores all info about a group of lists in a queue.
128 * Arguments: type - type of info to store.
129 * name - name of the info.
130 * Returns: the first element in the queue.
133 struct mqelem *GetListInfo(int type, char *name1, char *name2)
136 struct mqelem *elem = NULL;
143 if ((status = do_mr_query("get_list_info", 1, args, StoreInfo, &elem)))
145 com_err(program_name, status, " in get_list_info");
151 if ((status = do_mr_query("get_members_of_list", 1, args,
154 com_err(program_name, status, " in get_members_of_list");
161 if (!strcmp(name1, "MACHINE"))
162 args[1] = canonicalize_hostname(strdup(name2));
163 if ((status = do_mr_query("get_lists_of_member", 2, args,
166 com_err(program_name, status, " in get_list_of_members");
173 if ((status = do_mr_query("get_ace_use", 2, args, StoreInfo, &elem)))
175 com_err(program_name, status, " in get_ace_use");
180 return QueueTop(elem);
183 /* Function Name: AskListInfo.
184 * Description: This function askes the user for information about a
185 * machine and saves it into a structure.
186 * Arguments: info - a pointer the the structure to put the
188 * name - add a newname field? (T/F)
189 * Returns: SUB_ERROR or SUB_NORMAL.
192 char **AskListInfo(char **info, Bool name)
194 char temp_buf[BUFSIZ], *newname;
197 sprintf(temp_buf, "Setting information of list %s.", info[L_NAME]);
198 Put_message(temp_buf);
205 newname = strdup(info[L_NAME]);
206 if (GetValueFromUser("The new name for this list", &newname) ==
209 if (ValidName(newname))
213 if (GetYesNoValueFromUser("Is this an active list", &info[L_ACTIVE]) ==
216 if (GetYesNoValueFromUser("Is this a public list", &info[L_PUBLIC]) ==
219 if (GetYesNoValueFromUser("Is this a hidden list", &info[L_HIDDEN]) ==
222 if (GetYesNoValueFromUser("Is this a maillist", &info[L_MAILLIST]) ==
225 if (GetYesNoValueFromUser("Is this a group", &info[L_GROUP]) == SUB_ERROR)
227 if (atoi(info[L_GROUP]))
229 if (GetYesNoValueFromUser("Is this an NFS group", &info[L_NFSGROUP]) ==
232 if (GetValueFromUser("What is the GID for this group.", &info[L_GID]) ==
238 if (GetTypeFromUser("What Type of Administrator", "ace_type",
239 &info[L_ACE_TYPE]) == SUB_ERROR)
241 if (strcasecmp(info[L_ACE_TYPE], "none"))
243 sprintf(temp_buf, "Which %s will be the administrator of this list: ",
245 if (GetValueFromUser(temp_buf, &info[L_ACE_NAME]) == SUB_ERROR)
250 Put_message("Setting the administrator of this list to 'NONE'");
251 Put_message("will make you unable to further modify the list.");
252 if (YesNoQuestion("Do you really want to do this?", FALSE) == TRUE)
255 } while (!strcasecmp(info[L_ACE_TYPE], "none"));
257 if (!strcasecmp(info[L_ACE_TYPE], "kerberos"))
261 mrcl_validate_kerberos_member(info[L_ACE_NAME], &canon);
262 if (mrcl_get_message())
263 Put_message(mrcl_get_message());
264 free(info[L_ACE_NAME]);
265 info[L_ACE_NAME] = canon;
267 if (GetTypeFromUser("What Type of Membership Administrator", "ace_type",
268 &info[L_MEMACE_TYPE]) == SUB_ERROR)
270 if (strcasecmp(info[L_MEMACE_TYPE], "none"))
272 sprintf(temp_buf, "Which %s will be the membership administrator of this list: ",
273 info[L_MEMACE_TYPE]);
274 if (GetValueFromUser(temp_buf, &info[L_MEMACE_NAME]) == SUB_ERROR)
277 if (!strcasecmp(info[L_MEMACE_TYPE], "kerberos"))
281 mrcl_validate_kerberos_member(info[L_MEMACE_NAME], &canon);
282 if (mrcl_get_message())
283 Put_message(mrcl_get_message());
284 free(info[L_MEMACE_NAME]);
285 info[L_MEMACE_NAME] = canon;
287 if (GetValueFromUser("Description: ", &info[L_DESC]) == SUB_ERROR)
290 FreeAndClear(&info[L_MODTIME], TRUE);
291 FreeAndClear(&info[L_MODBY], TRUE);
292 FreeAndClear(&info[L_MODWITH], TRUE);
294 * Slide the newname into the #2 slot, this screws up all future references
297 if (name) /* slide the newname into the #2 slot. */
298 SlipInNewName(info, newname);
303 /* -------------- List functions. -------------- */
305 /* Function Name: ShowListInfo.
306 * Description: shows info on a list.
307 * Arguments: argc, argv - name of list in argv[1].
308 * Returns: DM status code.
311 int ShowListInfo(int argc, char **argv)
313 struct mqelem *top, *list;
315 top = list = GetListInfo(LIST, argv[1], NULL);
318 PrintListInfo(list->q_data);
326 /* Function Name: RealUpdateList
327 * Description: performs the actual update of the list.
328 * Arguments: info - all information needed to update the list.
329 * junk - an UNUSED boolean.
333 static void RealUpdateList(char **info, Bool junk)
337 struct mqelem *elem = NULL;
339 if (!(args = AskListInfo(info, TRUE)))
341 Put_message("Aborted.");
346 * If the new list name is less than 8 characters, make sure it doesn't
347 * collide with a username.
349 if ((strlen(args[2]) <= 8) &&
350 do_mr_query("get_user_account_by_login", 1, args + 1,
351 StoreInfo, &elem) != MR_NO_MATCH)
355 sprintf(buf, "\nA user by the name `%s' already exists in the database.",
358 Loop(QueueTop(elem), FreeInfo);
360 if (YesNoQuestion("Do you still want to rename this list to that name",
363 Put_message("List ** NOT ** Updated.");
368 if ((stat = do_mr_query("update_list", CountArgs(args), args,
369 NULL, NULL)) != MR_SUCCESS)
371 com_err(program_name, stat, " in UpdateList.");
372 Put_message("List ** NOT ** Updated.");
375 Put_message("List successfully updated.");
378 /* Function Name: UpdateList
379 * Description: updates the information on a list.
380 * Arguments: argc, argv - name of list in argv[1].
381 * Returns: DM Status code.
384 int UpdateList(int argc, char **argv)
388 top = GetListInfo(LIST, argv[1], (char *) NULL);
389 QueryLoop(top, NullPrint, RealUpdateList, "Update the list");
395 /* Function Name: SetDefaults
396 * Description: sets defaults for AddList function
397 * Arguments: info - the array to add them to.
398 * name - name of the program to add.
399 * Returns: defaults - the default information.
402 static char **SetDefaults(char **info, char *name)
404 info[L_NAME] = strdup(name);
405 info[L_ACTIVE] = strdup(DEFAULT_ACTIVE);
406 info[L_PUBLIC] = strdup(DEFAULT_PUBLIC);
407 info[L_HIDDEN] = strdup(DEFAULT_HIDDEN);
408 info[L_MAILLIST] = strdup(DEFAULT_MAILLIST);
409 info[L_GROUP] = strdup(DEFAULT_GROUP);
410 info[L_GID] = strdup(DEFAULT_GID);
411 info[L_NFSGROUP] = strdup(DEFAULT_NFSGROUP);
412 info[L_ACE_TYPE] = strdup(DEFAULT_ACE_TYPE);
413 info[L_ACE_NAME] = strdup(DEFAULT_ACE_NAME);
414 info[L_MEMACE_TYPE] = strdup(DEFAULT_MEMACE_TYPE);
415 info[L_MEMACE_NAME] = strdup(DEFAULT_MEMACE_NAME);
416 info[L_DESC] = strdup(DEFAULT_DESCRIPTION);
417 info[L_MODTIME] = info[L_MODBY] = info[L_MODWITH] = info[L_END] = NULL;
421 /* Function Name: AddList
423 * Arguments: argc, argv - name of list in argv[1].
424 * Returns: SUB_ERROR if list not created.
427 int AddList(int argc, char **argv)
429 static char *info[MAX_ARGS_SIZE], **add_args;
430 int status, ret_code = SUB_NORMAL;
431 struct mqelem *elem = NULL;
433 if (!ValidName(argv[1]))
435 status = do_mr_query("get_list_info", 1, argv + 1, NULL, NULL);
436 if (status != MR_NO_MATCH)
438 if (status == MR_SUCCESS)
439 Put_message("This list already exists.");
441 com_err(program_name, status, " in AddList.");
446 * If the listname is less than 8 characters, make sure it doesn't
447 * collide with a username.
449 if ((strlen(argv[1]) <= 8) &&
450 do_mr_query("get_user_account_by_login", 1, argv + 1,
451 StoreInfo, &elem) != MR_NO_MATCH)
455 sprintf(buf, "\nA user by the name `%s' already exists in the database.",
458 Loop(QueueTop(elem), FreeInfo);
460 if (YesNoQuestion("Create a list with the same name", FALSE) != TRUE)
464 if (!(add_args = AskListInfo(SetDefaults(info, argv[1]), FALSE)))
466 Put_message("Aborted.");
470 if ((status = do_mr_query("add_list", CountArgs(add_args), add_args,
471 NULL, NULL)) != MR_SUCCESS)
473 com_err(program_name, status, " in AddList.");
474 Put_message("List Not Created.");
475 ret_code = SUB_ERROR;
482 /* Function Name: Instructions
483 * Description: This func prints out instruction on manipulating lists.
485 * Returns: DM Status Code.
488 int ListHelp(int argc, char **argv)
490 static char *message[] = {
491 "Listmaint handles the creation, deletion, and updating of lists.",
492 "A list can be a mailing list, a group list, or both.",
493 "The concept behind lists is that a list has an owner",
494 "- administrator - and members.",
495 "The administrator of a list may be another list.",
496 "The members of a list can be users (login names), other lists,",
497 "or address strings.",
498 "You can use certain keys to do the following:",
499 " Refresh the screen - Type ctrl-L.",
500 " Escape from a function - Type ctrl-C.",
501 " Suspend the program (temporarily) - Type ctrl-Z.",
505 return PrintHelp(message);
508 /*-*-* LISTMAINT UPDATE MENU *-*-*/
510 /* Function Name: ListmaintMemberMenuEntry
511 * Description: entry routine into the listmaint member menu.
512 * Arguments: m - the member menu.
513 * argc, argv - name of the list in argv[1].
517 int ListmaintMemberMenuEntry(Menu *m, int argc, char **argv)
519 char temp_buf[BUFSIZ];
520 char *list_name = argv[1];
523 if (!ValidName(list_name))
528 if (AddList(argc, argv) == SUB_ERROR)
530 sprintf(temp_buf, "List '%s' created. Do you want to %s", list_name,
531 "change its membership (y/n)? ");
532 if (YesNoQuestion(temp_buf, TRUE) != TRUE)
536 /* All we want to know is if it exists. */
537 switch ((stat = do_mr_query("count_members_of_list", 1, argv + 1,
543 Put_message("This list does not exist.");
546 Put_message("You are not allowed to view this list.");
549 com_err(program_name, stat, " in get_list_info");
553 sprintf(temp_buf, "Change/Display membership of '%s'", list_name);
554 m->m_title = strdup(temp_buf);
555 strcpy(current_list, list_name);
559 /* Function Name: ListmaintMemberMenuExit
560 * Description: This is the function called when the member menu is
561 * exited, it frees the memory that is storing the name.
562 * Arguments: m - the menu
566 int ListmaintMemberMenuExit(Menu *m)
569 strcpy(current_list, "");
573 /* Function Name: ListMembersByType
574 * Description: This function lists the users of a list by type.
575 * Arguments: type - the type of the list "USER", "LIST", or "STRING".
576 * tags - whether or not to display tags
578 * NOTE: if type is NULL, all lists members are listed.
581 void ListMembersByType(char *type, int tags)
583 char temp_buf[BUFSIZ];
587 args[0] = current_list;
591 if ((status = do_mr_query(tags ? "get_tagged_members_of_list" :
592 "get_members_of_list", CountArgs(args),
593 args, PrintByType, type)))
594 com_err(program_name, status, " in ListMembersByType");
598 Put_message("List is empty (no members).");
601 sprintf(temp_buf, "No %s Members", type);
602 Put_message(temp_buf);
607 /* Function Name: ListAllMembers
608 * Description: lists all members of the current list.
613 int ListAllMembers(int argc, char **argv)
615 ListMembersByType(NULL, 0);
619 /* Function Name: ListUserMembers
620 * Description: This function lists all members of a list of type "USER".
622 * Returns: DM_NORMAL.
625 int ListUserMembers(int argc, char **argv)
627 ListMembersByType("USER", 0);
631 /* Function Name: ListListMembers
632 * Description: This function lists all members of a list of type "LIST".
634 * Returns: DM_NORMAL.
637 int ListListMembers(int argc, char **argv)
639 ListMembersByType("LIST", 0);
643 /* Function Name: ListStringMembers
644 * Description:This function lists all members of a list of type "STRING".
646 * Returns: DM_NORMAL.
649 int ListStringMembers(int argc, char **argv)
651 ListMembersByType("STRING", 0);
655 /* Function Name: GetMemberInfo
656 * Description: This function gets the information needed to
657 * add or delete a user from a list.
658 * Arguments: argc, argv - standard.
659 * action - name of the action to be performed either
661 * ret_argc, ret_argv - the returned value of argc and argv.
662 * Returns: SUB_ERROR or SUB_NORMAL.
665 int GetMemberInfo(char *action, char **ret_argv)
667 char temp_buf[BUFSIZ];
669 ret_argv[LM_LIST] = strdup(current_list);
671 ret_argv[LM_TYPE] = strdup("user");
672 if (GetTypeFromUser("Type of member", "member", &ret_argv[LM_TYPE]) ==
676 sprintf(temp_buf, "Name of %s to %s", ret_argv[LM_TYPE], action);
677 ret_argv[LM_MEMBER] = strdup(user);
678 if (GetValueFromUser(temp_buf, &ret_argv[LM_MEMBER]) == SUB_ERROR)
680 ret_argv[LM_END] = NULL; /* NULL terminate this list. */
682 if (strcasecmp(ret_argv[LM_TYPE], "string") &&
683 !ValidName(ret_argv[LM_MEMBER]))
691 /* Function Name: AddMember
692 * Description: This function adds a member to a list.
694 * Returns: DM_NORMAL.
697 int AddMember(int argc, char **argv)
699 char *args[10], temp_buf[BUFSIZ], *p;
701 struct mqelem *mailhubs, *elem;
703 if (GetMemberInfo("add", args) == SUB_ERROR)
706 if (!strcmp(args[LM_TYPE], "STRING"))
708 status = mrcl_validate_string_member(args[LM_MEMBER]);
709 if (status != MRCL_SUCCESS)
710 Put_message(mrcl_get_message());
711 if (status == MRCL_REJECT)
714 else if (!strcmp(args[LM_TYPE], "KERBEROS"))
718 mrcl_validate_kerberos_member(args[LM_MEMBER], &canon);
719 if (mrcl_get_message())
720 Put_message(mrcl_get_message());
721 free(args[LM_MEMBER]);
722 args[LM_MEMBER] = canon;
724 else if (!strcmp(args[LM_TYPE], "MACHINE"))
727 canon = canonicalize_hostname(strdup(args[LM_MEMBER]));
728 free(args[LM_MEMBER]);
729 args[LM_MEMBER] = canon;
732 if ((status = do_mr_query("add_member_to_list", CountArgs(args), args,
733 NULL, NULL)) != MR_SUCCESS)
735 if (status == MR_EXISTS)
737 sprintf(temp_buf, "The %s %s is already a member of LIST %s.",
738 args[LM_TYPE], args[LM_MEMBER], args[LM_LIST]);
739 Put_message(temp_buf);
742 com_err(program_name, status, " in AddMember");
749 /* Function Name: DeleteMember
750 * Description: This function deletes a member from a list.
755 int DeleteMember(int argc, char **argv)
760 if (GetMemberInfo("delete", args) == SUB_ERROR)
763 if (Confirm("Are you sure you want to delete this member?"))
765 if ((status = do_mr_query("delete_member_from_list", CountArgs(args),
768 if ((status == MR_STRING || status == MR_NO_MATCH) &&
769 !strcmp(args[LM_TYPE], "KERBEROS"))
772 mrcl_validate_kerberos_member(args[LM_MEMBER], &canon);
773 if (mrcl_get_message())
775 free(args[LM_MEMBER]);
776 args[LM_MEMBER] = canon;
777 if (do_mr_query("delete_member_from_list", CountArgs(args),
778 args, NULL, NULL) == MR_SUCCESS)
780 Put_message(mrcl_get_message());
785 else if ((status == MR_MACHINE || status == MR_NO_MATCH) &&
786 !strcmp(args[LM_TYPE], "MACHINE"))
789 canon = canonicalize_hostname(args[LM_MEMBER]);
790 free(args[LM_MEMBER]);
791 args[LM_MEMBER] = canon;
792 if (do_mr_query("delete_member_from_list", CountArgs(args),
793 args, NULL, NULL) == MR_SUCCESS)
798 com_err(program_name, status, " in DeleteMember");
800 Put_message("Deletion Completed.");
803 Put_message("Deletion has been Aborted.");
809 /* Function Name: TagMember
810 * Description: Add a tag to a list member
815 int TagMember(int argc, char **argv)
820 if (GetMemberInfo("tag", args) == SUB_ERROR)
823 args[LM_TAG] = strdup("");
824 if (GetValueFromUser("Tag" , &args[LM_TAG]) == SUB_ERROR)
826 Put_message("Aborted.");
829 args[LM_TAG_END] = NULL; /* NULL terminate this list. */
831 if ((status = do_mr_query("tag_member_of_list", CountArgs(args),
833 com_err(program_name, status, " in TagMember");
839 /* Function Name: ListAllMembers
840 * Description: lists all members of the current list.
845 int ListMembersWithTags(int argc, char **argv)
847 ListMembersByType(NULL, 1);
851 /* Function Name: InterRemoveItemFromLists
852 * Description: This function allows interactive removal of an item
853 * (user, string, list) for all list that it is on.
855 * Returns: DM_NORMAL.
856 * NOTES: QueryLoop() does not work here because info does not have
857 * enough information in it to delete the member from the list.
860 int InterRemoveItemFromLists(int argc, char **argv)
863 char *type, *name, *args[10], buf[BUFSIZ];
864 struct mqelem *top, *elem;
866 type = strdup("USER");
867 if (GetTypeFromUser("Type of member", "member", &type) == SUB_ERROR)
870 sprintf(buf, "Name of %s", type);
872 if (GetValueFromUser(buf, &name) == SUB_ERROR)
875 if (!ValidName(name))
878 top = elem = GetListInfo(GLOM, type, name);
883 char **info = elem->q_data;
884 sprintf(line, "Delete %s %s from the list \"%s\" (y/n/q)? ", type,
885 name, info[GLOM_NAME]);
886 switch (YesNoQuitQuestion(line, FALSE))
889 Put_message("deleting...");
890 args[DM_LIST] = info[GLOM_NAME];
891 args[DM_TYPE] = type;
892 args[DM_MEMBER] = name;
893 if (!strcmp("MACHINE", type))
894 args[DM_MEMBER] = canonicalize_hostname(strdup(name));
895 if ((status = do_mr_query("delete_member_from_list", 3, args,
898 /* should probabally check to delete list. */
899 com_err(program_name, status, " in delete_member");
905 Put_message("Aborting...");
915 /*-*-* LIST MENU *-*-*/
917 /* Function Name: ListByMember
918 * Description: This gets all lists that a given member is a member of.
920 * Returns: DM_NORMAL.
923 int ListByMember(int argc, char **argv)
925 char buf[BUFSIZ], temp_buf[BUFSIZ], *type, *name, **info;
926 Bool maillist, group, neither;
927 struct mqelem *top, *elem;
929 type = strdup("USER");
930 if (GetTypeFromUser("Type of member", "member", &type) == SUB_ERROR)
933 sprintf(buf, "Name of %s", type);
935 if (GetValueFromUser(buf, &name) == SUB_ERROR)
938 switch (YesNoQuestion("Do you want a recursive search (y/n)", TRUE))
941 sprintf(temp_buf, "R%s", type); /* "USER" to "RUSER" etc. */
943 type = strdup(temp_buf);
951 if ((maillist = YesNoQuestion("Show Lists that are Maillists (y/n) ?",
954 if ((group = YesNoQuestion("Show Lists that are Groups (y/n) ?",
958 if ((neither = YesNoQuestion("Show Lists that are neither Maillists nor Groups (y/n) ?",
962 elem = top = GetListInfo(GLOM, type, name);
967 if ((maillist == TRUE && !strcmp(info[GLOM_MAILLIST], "1")) ||
968 (group == TRUE && !strcmp(info[GLOM_GROUP], "1")))
969 Put_message(info[GLOM_NAME]);
970 if (neither == TRUE && !strcmp(info[GLOM_MAILLIST], "0") &&
971 !strcmp(info[GLOM_GROUP], "0"))
972 Put_message(info[GLOM_NAME]);
979 /* Function Name: ListByAdministrator
980 * Description: This function prints all lists which a given user or
983 * Returns: DM_NORMAL.
986 int ListByAdministrator(int argc, char **argv)
988 char buf[BUFSIZ], temp_buf[BUFSIZ], *type, *name;
991 type = strdup("USER");
992 if (GetTypeFromUser("Type of member", "member", &type) == SUB_ERROR)
995 sprintf(buf, "Name of %s", type);
997 if (GetValueFromUser(buf, &name) == SUB_ERROR)
1000 switch (YesNoQuestion("Do you want a recursive search (y/n)", FALSE))
1003 sprintf(temp_buf, "R%s", type); /* "USER" to "RUSER" etc. */
1005 type = strdup(temp_buf);
1013 top = GetListInfo(ACE_USE, type, name);
1014 Loop(top, PrintListAce);
1020 /* Function Name: ListAllPublicMailLists
1021 * Description: This function lists all public mailing lists.
1023 * Returns: DM_NORMAL.
1026 int ListAllPublicMailLists(int argc, char **argv)
1029 static char *args[] = {
1030 "TRUE", /* active */
1031 "TRUE", /* public */
1032 "FALSE", /* hidden */
1033 "TRUE", /* maillist */
1034 "DONTCARE", /* group. */
1037 if (YesNoQuestion("This query will take a while. Do you wish to continue?",
1040 if ((status = do_mr_query("qualified_get_lists", 5, args,
1041 Print, NULL)) != MR_SUCCESS)
1042 com_err(program_name, status, " in ListAllGroups");