]> andersk Git - moira.git/blame - clients/moira/lists.c
sms -> moira
[moira.git] / clients / moira / lists.c
CommitLineData
402461ad 1#if (!defined(lint) && !defined(SABER))
08345b74 2 static char rcsid_module_c[] = "$Header$";
3#endif lint
4
8defc06b 5/* This is the file lists.c for the MOIRA Client, which allows a nieve
6 * user to quickly and easily maintain most parts of the MOIRA database.
0a2c64cb 7 * It Contains: All list manipulation functions, except delete.
08345b74 8 *
0a2c64cb 9 * Created: 4/12/88
10 * By: Chris D. Peterson
08345b74 11 *
12 * $Source$
13 * $Author$
14 * $Header$
15 *
0a2c64cb 16 * Copyright 1988 by the Massachusetts Institute of Technology.
08345b74 17 *
18 * For further information on copyright and distribution
19 * see the file mit-copyright.h
20 */
21
22#include <stdio.h>
23#include <strings.h>
8defc06b 24#include <moira.h>
25#include <moira_site.h>
08345b74 26#include <menu.h>
27
28#include "mit-copyright.h"
0a2c64cb 29#include "defs.h"
30#include "f_defs.h"
08345b74 31#include "globals.h"
08345b74 32
33#define LIST 0
34#define MEMBERS 1
35#define GLOM 2
075fe5bb 36#define ACE_USE 3
08345b74 37
85ca828a 38#define DEFAULT_ACTIVE DEFAULT_YES
39#define DEFAULT_PUBLIC DEFAULT_YES
40#define DEFAULT_HIDDEN DEFAULT_NO
41#define DEFAULT_MAILLIST DEFAULT_YES
42#define DEFAULT_GROUP DEFAULT_NO
43#define DEFAULT_GID UNIQUE_GID
075fe5bb 44#define DEFAULT_ACE_TYPE "user"
45#define DEFAULT_ACE_NAME (user)
85ca828a 46#define DEFAULT_DESCRIPTION DEFAULT_COMMENT
47
461c03b6 48/* globals only for this file. */
49
85ca828a 50static char current_list[BUFSIZ];
461c03b6 51
075fe5bb 52/* Function Name: PrintListAce
53 * Description: This function prints the list ace information.
402461ad 54 * Arguments: info - an info structure.
55 * Returns: none.
56 */
57
58static void
075fe5bb 59PrintListAce(info)
402461ad 60char ** info;
61{
62 char buf[BUFSIZ];
63
6d9ec158 64 sprintf(buf, "Item: %-20s Name: %s", info[ACE_TYPE],
075fe5bb 65 info[ACE_NAME]);
402461ad 66 Put_message(buf);
67}
68
08345b74 69/* Function Name: PrintListInfo
70 * Description: This function Prints out the List info in a coherent form.
71 * Arguments: info - the List info.
72 * Returns: none.
73 */
74
402461ad 75static void
08345b74 76PrintListInfo(info)
77char ** info;
78{
79 char buf[BUFSIZ];
80
402461ad 81 Put_message(" ");
82 (void) sprintf(buf, "%20sList: %s", "", info[L_NAME]);
08345b74 83 (void) Put_message(buf);
85ca828a 84 (void) sprintf(buf, "Description: %s", info[L_DESC]);
08345b74 85 (void) Put_message(buf);
86 if ( atoi(info[L_MAILLIST]))
87 Put_message("This list is a mailing list.");
88 else
89 Put_message("This list is NOT a mailing list.");
90 if ( atoi(info[L_GROUP]) ) {
589fdf24 91 (void) sprintf(buf,"This list is a Group and its ID number is %s",
08345b74 92 info[L_GID]);
93 Put_message(buf);
94 }
95 else
402461ad 96 Put_message("This list is NOT a Group.");
08345b74 97
075fe5bb 98 if (strcmp(info[L_ACE_TYPE],"NONE") == 0)
08345b74 99 Put_message("This list has no Administrator, how strange?!");
100 else {
402461ad 101 sprintf(buf, "The Administrator of this list is the %s: %s",
075fe5bb 102 info[L_ACE_TYPE], info[L_ACE_NAME]);
08345b74 103 Put_message(buf);
104 }
105
106 (void) sprintf(buf, "This list is: %s, %s, and %s",
85ca828a 107 atoi(info[L_ACTIVE]) ? "active" : "inactive",
108 atoi(info[L_PUBLIC]) ? "public" : "private",
109 atoi(info[L_HIDDEN]) ? "hidden" : "visible");
08345b74 110 (void) Put_message(buf);
075fe5bb 111 sprintf(buf, MOD_FORMAT, info[L_MODBY], info[L_MODTIME], info[L_MODWITH]);
08345b74 112 (void) Put_message(buf);
113}
114
115/* Function Name: GetListInfo
116 * Description: Stores all info about a group of lists in a queue.
117 * Arguments: type - type of info to store.
118 * name - name of the info.
119 * Returns: the first element in the queue.
120 */
121
122/* ARGSUSED */
123struct qelem *
124GetListInfo(type, name1, name2)
125int type;
461c03b6 126char * name1, *name2;
08345b74 127{
128 char *args[2];
461c03b6 129 struct qelem * elem = NULL;
130 register int status;
08345b74 131
132 switch(type) {
133 case LIST:
134 args[0] = name1;
8defc06b 135 if ( (status = do_mr_query("get_list_info", 1, args,
08345b74 136 StoreInfo, (char *) &elem)) != 0) {
85ca828a 137 com_err(program_name, status, " in get_list_info");
08345b74 138 return (NULL);
139 }
140 break;
141 case MEMBERS:
142 args[0] = name1;
8defc06b 143 if ( (status = do_mr_query("get_members_of_list", 1, args,
08345b74 144 StoreInfo, (char *) &elem)) != 0) {
85ca828a 145 com_err(program_name, status, " in get_members_of_list");
08345b74 146 return (NULL);
147 }
148 break;
149 case GLOM:
150 args[0] = name1;
151 args[1] = name2;
8defc06b 152 if ( (status = do_mr_query("get_lists_of_member", 2, args,
08345b74 153 StoreInfo, (char *) &elem)) != 0) {
85ca828a 154 com_err(program_name, status, " in get_list_of_members");
08345b74 155 return (NULL);
156 }
157 break;
075fe5bb 158 case ACE_USE:
08345b74 159 args[0] = name1;
160 args[1] = name2;
8defc06b 161 if ( (status = do_mr_query("get_ace_use", 2, args,
08345b74 162 StoreInfo, (char *) &elem)) != 0) {
075fe5bb 163 com_err(program_name, status, " in get_ace_use");
08345b74 164 return (NULL);
165 }
166 break;
167 }
168 return( QueueTop(elem) );
169}
170
171/* Function Name: AskListInfo.
172 * Description: This function askes the user for information about a
173 * machine and saves it into a structure.
174 * Arguments: info - a pointer the the structure to put the
175 * info into.
176 * name - add a newname field? (T/F)
177 * Returns: SUB_ERROR or SUB_NORMAL.
178 */
179
180char **
461c03b6 181AskListInfo(info, name)
08345b74 182char ** info;
183Bool name;
184{
461c03b6 185 char temp_buf[BUFSIZ], *newname;
08345b74 186
402461ad 187 Put_message(" ");
188 sprintf(temp_buf,"Setting information of list %s.",info[L_NAME]);
08345b74 189 Put_message(temp_buf);
402461ad 190 Put_message(" ");
08345b74 191
192 if (name) {
5df6f171 193 while (1) {
194 newname = Strsave(info[L_NAME]);
195 GetValueFromUser("The new name for this list", &newname);
196 if (ValidName(newname))
197 break;
198 }
08345b74 199 }
075fe5bb 200 GetYesNoValueFromUser("Is this an active list", &info[L_ACTIVE]);
201 GetYesNoValueFromUser("Is this a public list", &info[L_PUBLIC]);
202 GetYesNoValueFromUser("Is this a hidden list", &info[L_HIDDEN]);
203 GetYesNoValueFromUser("Is this a maillist", &info[L_MAILLIST]);
ba62b427 204 GetYesNoValueFromUser("Is this a group", &info[L_GROUP]);
85ca828a 205 if (atoi(info[L_GROUP]))
206 GetValueFromUser("What is the GID for this group.", &info[L_GID]);
207
31791cff 208 GetTypeFromUser("What Type of Administrator", "ace_type",&info[L_ACE_TYPE]);
20b2d2f0 209 if ((strcasecmp(info[L_ACE_TYPE], "NONE") != 0) &&
210 (strcasecmp(info[L_ACE_TYPE], "none") != 0)) {
211 sprintf(temp_buf, "Which %s will be the administrator of this list: ",
212 info[L_ACE_TYPE]);
213 GetValueFromUser(temp_buf, &info[L_ACE_NAME]);
214 }
08345b74 215 GetValueFromUser("Description: ", &info[L_DESC]);
216
217 FreeAndClear(&info[L_MODTIME], TRUE);
218 FreeAndClear(&info[L_MODBY], TRUE);
219 FreeAndClear(&info[L_MODWITH], TRUE);
220/*
221 * Slide the newname into the #2 slot, this screws up all future references
222 * to this list.
223 */
224 if (name) /* slide the newname into the #2 slot. */
225 SlipInNewName(info, newname);
226
227 return(info);
228}
229
230/* -------------- List functions. -------------- */
231
232/* Function Name: ShowListInfo.
233 * Description: shows info on a list.
461c03b6 234 * Arguments: argc, argv - name of list in argv[1].
08345b74 235 * Returns: DM status code.
236 */
237
85ca828a 238/* ARGSUSED */
08345b74 239int
240ShowListInfo(argc, argv)
241int argc;
242char **argv;
243{
244 struct qelem *top, *list;
245
461c03b6 246 top = list = GetListInfo(LIST, argv[1], (char *) NULL);
08345b74 247 while (list != NULL) {
248 PrintListInfo( (char **) list->q_data);
249 list = list->q_forw;
250 }
251
252 FreeQueue(top);
253 return(DM_NORMAL);
254}
255
402461ad 256/* Function Name: RealUpdateList
257 * Description: performs the actual update of the list.
258 * Arguments: info - all information needed to update the list.
259 * junk - an UNUSED boolean.
260 * Returns: none.
261 */
262
263/* ARGSUSED */
264static void
265RealUpdateList(info, junk)
266char ** info;
267Bool junk;
268{
269 register int stat;
270 char ** args;
271
272 args = AskListInfo(info, TRUE);
8defc06b 273 if ( (stat = do_mr_query("update_list", CountArgs(args), args,
274 Scream, (char *) NULL)) != MR_SUCCESS) {
402461ad 275 com_err(program_name, stat, " in UpdateList.");
276 Put_message("List ** NOT ** Updated.");
277 }
278 else
279 Put_message("List successfully updated.");
280}
281
08345b74 282/* Function Name: UpdateList
85ca828a 283 * Description: updates the information on a list.
08345b74 284 * Arguments: argc, argv - name of list in argv[1].
285 * Returns: DM Status code.
286 */
287
85ca828a 288/* ARGSUSED */
08345b74 289int
290UpdateList(argc, argv)
291int argc;
292char **argv;
293{
402461ad 294 struct qelem *top;
295
296 top = GetListInfo(LIST, argv[1], (char *) NULL);
297 QueryLoop(top, NullPrint, RealUpdateList, "Update the list");
08345b74 298
08345b74 299 FreeQueue(top);
300 return(DM_NORMAL);
301}
302
85ca828a 303/* Function Name: SetDefaults
304 * Description: sets defaults for AddList function
305 * Arguments: info - the array to add them to.
306 * name - name of the program to add.
307 * Returns: defaults - the default information.
308 */
309
310static char **
311SetDefaults(info, name)
312char ** info;
313char * name;
314{
315 info[L_NAME] = Strsave(name);
316 info[L_ACTIVE] = Strsave(DEFAULT_ACTIVE);
317 info[L_PUBLIC] = Strsave(DEFAULT_PUBLIC);
318 info[L_HIDDEN] = Strsave(DEFAULT_HIDDEN);
319 info[L_MAILLIST] = Strsave(DEFAULT_MAILLIST);
320 info[L_GROUP] = Strsave(DEFAULT_GROUP);
321 info[L_GID] = Strsave(DEFAULT_GID);
075fe5bb 322 info[L_ACE_TYPE] = Strsave(DEFAULT_ACE_TYPE);
323 info[L_ACE_NAME] = Strsave(DEFAULT_ACE_NAME);
85ca828a 324 info[L_DESC] = Strsave(DEFAULT_DESCRIPTION);
325 info[L_MODTIME] = info[L_MODBY] = info[L_MODWITH] = info[L_END] = NULL;
326 return(info);
327}
328
08345b74 329/* Function Name: AddList
330 * Description:
331 * Arguments: argc, argv - name of list in argv[1].
402461ad 332 * Returns: SUB_ERROR if list not created.
08345b74 333 */
334
85ca828a 335/* ARGSUSED */
08345b74 336int
337AddList(argc, argv)
338int argc;
339char **argv;
340{
341 static char *info[MAX_ARGS_SIZE], **add_args;
402461ad 342 int status, ret_code = SUB_NORMAL;
08345b74 343
5df6f171 344 if (!ValidName(argv[1]))
345 return(DM_NORMAL);
8defc06b 346 status = do_mr_query("get_list_info", 1, argv + 1, NullFunc,
461c03b6 347 (char *) NULL);
8defc06b 348 if (status != MR_NO_MATCH) {
349 if (status == MR_SUCCESS)
08345b74 350 Put_message("This list already exists.");
351 else
461c03b6 352 com_err(program_name, status, " in AddList.");
402461ad 353 return(SUB_ERROR);
08345b74 354 }
355
85ca828a 356 add_args = AskListInfo(SetDefaults(info,argv[1]), FALSE);
08345b74 357
8defc06b 358 if ( (status = do_mr_query("add_list", CountArgs(add_args), add_args,
359 Scream, (char *) NULL)) != MR_SUCCESS) {
461c03b6 360 com_err(program_name, status, " in AddList.");
08345b74 361 Put_message("List Not Created.");
402461ad 362 ret_code = SUB_ERROR;
08345b74 363 }
364
365 FreeInfo(info);
402461ad 366 return(ret_code);
08345b74 367}
368
369/* Function Name: Instructions
370 * Description: This func prints out instruction on manipulating lists.
371 * Arguments: none
372 * Returns: DM Status Code.
373 */
374
375int
461c03b6 376ListHelp()
08345b74 377{
378 static char * message[] = {
402461ad 379 "Listmaint handles the creation, deletion, and updating of lists.",
380 "A list can be a mailing list, a group list, or both.",
08345b74 381 "The concept behind lists is that a list has an owner",
402461ad 382 "- administrator - and members.",
383 "The administrator of a list may be another list.",
08345b74 384 "The members of a list can be users (login names), other lists,",
402461ad 385 "or address strings.",
08345b74 386 "You can use certain keys to do the following:",
402461ad 387 " Refresh the screen - Type ctrl-L.",
388 " Escape from a function - Type ctrl-C.",
389 " Suspend the program (temporarily) - Type ctrl-Z.",
08345b74 390 NULL,
461c03b6 391 };
08345b74 392
393 return(PrintHelp(message));
394}
395
396/*-*-* LISTMAINT UPDATE MENU *-*-*/
397
398/* Function Name: ListmaintMemberMenuEntry
399 * Description: entry routine into the listmaint member menu.
400 * Arguments: m - the member menu.
401 * argc, argv - name of the list in argv[1].
402 * Returns: none.
403 */
404
405/* ARGSUSED */
406int
407ListmaintMemberMenuEntry(m, argc, argv)
408Menu *m;
409int argc;
410char **argv;
411{
461c03b6 412 char temp_buf[BUFSIZ];
08345b74 413 char *list_name = argv[1];
075fe5bb 414 register int stat;
415
402461ad 416 if (!ValidName(list_name))
417 return(DM_QUIT);
08345b74 418
419 if (*argv[0] == 'a') { /* add_list */
402461ad 420 if (AddList(argc, argv) == SUB_ERROR)
08345b74 421 return(DM_QUIT);
422 (void) sprintf(temp_buf, "List '%s' created. Do you want to %s",
402461ad 423 list_name, "change its membership (y/n)? ");
08345b74 424 if (YesNoQuestion(temp_buf, TRUE) != TRUE )
425 return(DM_QUIT);
426 }
075fe5bb 427 else
428 /* All we want to know is if it exists. */
8defc06b 429 switch( (stat = do_mr_query("count_members_of_list", 1, argv + 1,
075fe5bb 430 NullFunc, (char *) NULL))) {
8defc06b 431 case MR_SUCCESS:
075fe5bb 432 break;
8defc06b 433 case MR_LIST:
075fe5bb 434 Put_message("This list does not exist.");
435 return(DM_QUIT);
8defc06b 436 case MR_PERM:
075fe5bb 437 Put_message("You are not allowed to view this list.");
31791cff 438 break;
075fe5bb 439 default:
440 com_err(program_name, stat, " in get_list_info");
441 return(DM_QUIT);
442 }
08345b74 443
444 (void) sprintf(temp_buf,
445 "Change/Display membership of '%s'", list_name);
446 m->m_title = Strsave(temp_buf);
447 strcpy(current_list, list_name);
448 return(DM_NORMAL);
449}
450
451/* Function Name: ListmaintMemberMenuExit
452 * Description: This is the function called when the member menu is
453 * exited, it frees the memory that is storing the name.
454 * Arguments: m - the menu
455 * Returns: DM_NORMAL
456 */
457
458int
459ListmaintMemberMenuExit(m)
460Menu *m;
461{
462 free(m->m_title);
463 strcpy(current_list, "");
464 return(DM_NORMAL);
465}
466
467/* Function Name: ListMembersByType
468 * Description: This function lists the users of a list by type.
469 * Arguments: type - the type of the list "USER", "LIST", or "STRING".
470 * Returns: none.
471 * NOTE: if type is NULL, all lists members are listed.
472 */
473
84b46f02 474int
461c03b6 475ListMembersByType(type)
08345b74 476char * type;
477{
478 char temp_buf[BUFSIZ];
461c03b6 479 register int status;
402461ad 480 char * args[10];
481
482 args[0] = current_list;
483 args[1] = NULL;
08345b74 484
485 found_some = FALSE;
8defc06b 486 if ( (status = do_mr_query("get_members_of_list", CountArgs(args), args,
a42a06d7 487 PrintByType, type)) != 0) {
402461ad 488 com_err(program_name, status, " in ListMembersByType");
a42a06d7 489 return(DM_NORMAL);
490 }
08345b74 491 if (!found_some) {
492 if (type == NULL)
493 Put_message("List is empty (no members).");
494 else {
495 sprintf(temp_buf,"No %s Members",type);
496 Put_message(temp_buf);
497 }
498 }
499}
500
501/* Function Name: ListAllMembers
502 * Description: lists all members of the current list.
503 * Arguments:
504 * Returns: DM_NORMAL
505 */
506
507int
508ListAllMembers()
509{
510 ListMembersByType(NULL);
511 return (DM_NORMAL);
512}
513
514/* Function Name: ListUserMembers
515 * Description: This function lists all members of a list of type "USER".
516 * Arguments: none
517 * Returns: DM_NORMAL.
518 */
519
520ListUserMembers()
521{
522 ListMembersByType("USER");
523 return(DM_NORMAL);
524}
525
526/* Function Name: ListListMembers
527 * Description: This function lists all members of a list of type "LIST".
528 * Arguments: none
529 * Returns: DM_NORMAL.
530 */
531
532ListListMembers()
533{
534 ListMembersByType("LIST");
535 return(DM_NORMAL);
536}
537
538/* Function Name: ListStringMembers
539 * Description:This function lists all members of a list of type "STRING".
540 * Arguments: none
541 * Returns: DM_NORMAL.
542 */
543
544ListStringMembers()
545{
546 ListMembersByType("STRING");
547 return(DM_NORMAL);
548}
549
550/* Function Name: GetMemberInfo
551 * Description: This function gets the information needed to
552 * add or delete a user from a list.
553 * Arguments: argc, argv - standard.
554 * action - name of the action to be performed either
555 * "add" or "delete".
556 * ret_argc, ret_argv - the returned value of argc and argv.
557 * Returns: SUB_ERROR or SUB_NORMAL.
558 */
559
560int
561GetMemberInfo(action, ret_argv)
562char *action, **ret_argv;
563{
564 char temp_buf[BUFSIZ], ret_buf[BUFSIZ];
565
566 ret_argv[LM_LIST] = Strsave(current_list);
08345b74 567
31791cff 568 ret_argv[LM_TYPE] = Strsave("user");
569 GetTypeFromUser("Type of member", "member", &ret_argv[LM_TYPE]);
0a2c64cb 570
402461ad 571 sprintf(temp_buf,"Name of %s to %s", ret_argv[LM_TYPE], action);
31791cff 572 ret_argv[LM_MEMBER] = Strsave(user);
573 GetValueFromUser(temp_buf, &ret_argv[LM_MEMBER]);
402461ad 574 ret_argv[LM_END] = NULL; /* NULL terminate this list. */
575
68c57b15 576 if (strcasecmp(ret_argv[LM_TYPE], "string") &&
577 !ValidName( ret_argv[LM_MEMBER] ) ) {
402461ad 578 FreeInfo(ret_argv);
579 return(SUB_ERROR);
580 }
08345b74 581 return(SUB_NORMAL);
582}
583
584/* Function Name: AddMember
585 * Description: This function adds a member to a list.
586 * Arguments: none.
587 * Returns: DM_NORMAL.
588 */
589
590int
591AddMember()
592{
402461ad 593 char *args[10], temp_buf[BUFSIZ];
461c03b6 594 register int status;
08345b74 595
402461ad 596 if ( GetMemberInfo("add", args) == SUB_ERROR )
08345b74 597 return(DM_NORMAL);
598
8defc06b 599 if ( (status = do_mr_query("add_member_to_list", CountArgs(args), args,
600 Scream, NULL)) != MR_SUCCESS) {
601 if (status == MR_EXISTS) {
402461ad 602 sprintf(temp_buf, "The %s %s is already a member of LIST %s.",
603 args[LM_TYPE], args[LM_MEMBER], args[LM_LIST]);
604 Put_message(temp_buf);
605 }
606 else
607 com_err(program_name, status, " in AddMember");
608 }
08345b74 609
610 FreeInfo(args);
402461ad 611 return(DM_NORMAL);
08345b74 612}
613
614/* Function Name: DeleteMember
615 * Description: This function deletes a member from a list.
616 * Arguments: none.
617 * Returns: DM_NORMAL
618 */
619
620int
621DeleteMember()
622{
623 char *args[10];
461c03b6 624 register int status;
08345b74 625
626 if( GetMemberInfo("delete", args) == SUB_ERROR )
627 return(DM_NORMAL);
628
629 if (Confirm("Are you sure you want to delete this member?") ) {
8defc06b 630 if (status = do_mr_query("delete_member_from_list", CountArgs(args),
08345b74 631 args, Scream, NULL))
402461ad 632 com_err(program_name, status, " in DeleteMember");
08345b74 633 else
634 Put_message("Deletion Completed.");
635 }
636 else
637 Put_message("Deletion has been Aborted.");
638
639 FreeInfo(args);
640 return(DM_NORMAL);
641}
642
08345b74 643/* Function Name: InterRemoveItemFromLists
644 * Description: This function allows interactive removal of an item
645 * (user, string, list) for all list that it is on.
646 * Arguments: none.
647 * Returns: DM_NORMAL.
402461ad 648 * NOTES: QueryLoop() does not work here because info does not have
649 * enough information in it to delete the member from the list.
08345b74 650 */
651
652int
653InterRemoveItemFromLists()
654{
461c03b6 655 register int status;
402461ad 656 char type[BUFSIZ], name[BUFSIZ], *args[10], buf[BUFSIZ];
461c03b6 657 struct qelem *top, *elem;
08345b74 658
402461ad 659 if ( !(PromptWithDefault("Type of member (user, list, string)", type,
08345b74 660 BUFSIZ, "user")) )
661 return(DM_NORMAL);
662
402461ad 663 sprintf(buf, "Name of %s", type);
664 if ( !(PromptWithDefault(buf, name, BUFSIZ, user)) ) {
08345b74 665 return(DM_NORMAL);
666 }
667
402461ad 668 if (!ValidName(name))
669 return(DM_NORMAL);
670
08345b74 671 top = elem = GetListInfo(GLOM, type, name);
672
673 while(elem != NULL) {
402461ad 674 char line[BUFSIZ];
461c03b6 675 char ** info = (char **) elem->q_data;
402461ad 676 sprintf(line, "Delete %s %s from the list \"%s\" (y/n/q)? ", type,
677 name, info[GLOM_NAME]);
678 switch (YesNoQuitQuestion(line, FALSE)) {
679 case TRUE:
08345b74 680 Put_message("deleting...");
461c03b6 681 args[DM_LIST] = info[GLOM_NAME];
08345b74 682 args[DM_TYPE] = type;
683 args[DM_MEMBER] = name;
8defc06b 684 if ( (status = do_mr_query("delete_member_from_list", 3, args,
08345b74 685 Scream, (char *) NULL)) != 0)
402461ad 686 /* should probabally check to delete list. */
461c03b6 687 com_err(program_name, status, " in delete_member");
08345b74 688 break;
402461ad 689 case FALSE:
690 break;
691 default:
692 Put_message("Aborting...");
693 FreeQueue(top);
694 return(DM_NORMAL);
08345b74 695 }
696 elem = elem->q_forw;
697 }
698 FreeQueue(top);
699 return(DM_NORMAL);
700}
701
702/*-*-* LIST MENU *-*-*/
703
704/* Function Name: ListByMember
705 * Description: This gets all lists that a given member is a member of.
461c03b6 706 * Arguments: none.
08345b74 707 * Returns: DM_NORMAL.
708 */
709
710int
461c03b6 711ListByMember()
08345b74 712{
402461ad 713 char buf[BUFSIZ], temp_buf[BUFSIZ], *type, *name, **info;
461c03b6 714 Bool maillist, group;
715 struct qelem *top, *elem;
08345b74 716
402461ad 717 if ( !(PromptWithDefault("Type of member (user, list, string)", buf,
08345b74 718 BUFSIZ, "user")) )
719 return(DM_NORMAL);
720
402461ad 721 /* What we really want is a recursive search */
722 sprintf(temp_buf, "R%s", buf);
723 type = Strsave(temp_buf);
724
725 sprintf(temp_buf, "Name of %s", buf);
726 if ( !(PromptWithDefault(temp_buf, buf, BUFSIZ, user)) ) {
08345b74 727 free(type);
728 return(DM_NORMAL);
729 }
730 name = Strsave(buf);
731
d27e2367 732 maillist = YesNoQuestion("Show Lists that are Maillists (y/n) ?",
08345b74 733 TRUE);
d27e2367 734 group = YesNoQuestion("Show Lists that are Groups (y/n) ?", TRUE);
08345b74 735
736 elem = top = GetListInfo(GLOM, type, name);
737
738 while (elem != NULL) {
739 info = (char**) elem->q_data;
5151666e 740 if ((maillist == TRUE && !strcmp(info[GLOM_MAILLIST], "1")) ||
741 (group == TRUE && !strcmp(info[GLOM_GROUP], "1")))
08345b74 742 Put_message(info[GLOM_NAME]);
743 elem = elem->q_forw;
744 }
745 FreeQueue(top);
746 return (DM_NORMAL);
747}
748
749/* Function Name: ListByAdministrator
750 * Description: This function prints all lists which a given user or
751 * group administers.
461c03b6 752 * Arguments: none.
08345b74 753 * Returns: DM_NORMAL.
754 */
755
756int
461c03b6 757ListByAdministrator()
08345b74 758{
402461ad 759 char buf[BUFSIZ], temp_buf[BUFSIZ], *type, *name;
760 struct qelem *top;
08345b74 761
402461ad 762 if ( !(PromptWithDefault("Type of member (user, list, string)", buf,
08345b74 763 BUFSIZ, "user")) )
764 return(DM_NORMAL);
765
ba62b427 766 if ( YesNoQuestion("Do you want a recursive search (y/n)", FALSE) == 1 ) {
402461ad 767 sprintf(temp_buf, "R%s", buf); /* "USER" to "RUSER" etc. */
768 type = Strsave(temp_buf);
769 }
770 else
771 type = Strsave(buf);
08345b74 772
402461ad 773 sprintf(temp_buf, "Name of %s", buf);
774 if ( !(PromptWithDefault(temp_buf, buf, BUFSIZ, user)) ) {
08345b74 775 free(type);
776 return(DM_NORMAL);
777 }
778 name = Strsave(buf);
779
075fe5bb 780 top = GetListInfo(ACE_USE, type, name);
781 Loop(top, PrintListAce);
402461ad 782
08345b74 783 FreeQueue(top);
784 return (DM_NORMAL);
785}
786
787/* Function Name: ListAllGroups
788 * Description: This function lists all visable groups.
789 * Arguments: none.
790 * Returns: DM_NORMAL.
791 */
792
793ListAllGroups()
794{
461c03b6 795 register int status;
08345b74 796 static char * args[] = {
797 "TRUE", /* active */
798 "DONTCARE", /* public */
799 "FALSE", /* hidden */
800 "DONTCARE", /* maillist */
801 "TRUE", /* group. */
461c03b6 802 };
08345b74 803
804 if (YesNoQuestion("This query will take a while, Do you wish to continue?",
461c03b6 805 TRUE) == TRUE )
8defc06b 806 if (status = do_mr_query("qualified_get_lists", 5, args,
08345b74 807 Print, (char *) NULL) != 0)
402461ad 808 com_err(program_name, status, " in ListAllGroups");
08345b74 809 return (DM_NORMAL);
810}
811
812/* Function Name: ListAllMailLists
813 * Description: This function lists all visable maillists.
814 * Arguments: none
815 * Returns: DM_NORMAL.
816 */
817
818ListAllMailLists()
819{
461c03b6 820 register int status;
08345b74 821 static char * args[] = {
822 "TRUE", /* active */
823 "DONTCARE", /* public */
824 "FALSE", /* hidden */
825 "TRUE", /* maillist */
826 "DONTCARE", /* group. */
461c03b6 827 };
08345b74 828
829 if (YesNoQuestion("This query will take a while. Do you wish to continue?",
461c03b6 830 TRUE) == TRUE )
8defc06b 831 if (status = do_mr_query("qualified_get_lists", 5, args,
08345b74 832 Print, (char *) NULL) != 0)
402461ad 833 com_err(program_name, status, " in ListAllGroups");
08345b74 834
835 return (DM_NORMAL);
836}
837
838/* Function Name: ListAllPublicMailLists
839 * Description: This function lists all public mailing lists.
840 * Arguments: none
841 * Returns: DM_NORMAL.
842 */
843
844ListAllPublicMailLists()
845{
461c03b6 846 register int status;
08345b74 847 static char * args[] = {
848 "TRUE", /* active */
849 "TRUE", /* public */
850 "FALSE", /* hidden */
851 "TRUE", /* maillist */
852 "DONTCARE", /* group. */
461c03b6 853 };
08345b74 854
855 if (YesNoQuestion("This query will take a while. Do you wish to continue?",
461c03b6 856 TRUE) == TRUE )
8defc06b 857 if (status = do_mr_query("qualified_get_lists", 5, args,
08345b74 858 Print, (char *) NULL) != 0)
402461ad 859 com_err(program_name, status, " in ListAllGroups");
08345b74 860
861 return (DM_NORMAL);
862}
This page took 0.20129 seconds and 5 git commands to generate.