]> andersk Git - moira.git/blob - clients/moira/lists.c
sms -> moira
[moira.git] / clients / moira / lists.c
1 #if (!defined(lint) && !defined(SABER))
2   static char rcsid_module_c[] = "$Header$";
3 #endif lint
4
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.
7  *      It Contains: All list manipulation functions, except delete.
8  *      
9  *      Created:        4/12/88
10  *      By:             Chris D. Peterson
11  *
12  *      $Source$
13  *      $Author$
14  *      $Header$
15  *      
16  *      Copyright 1988 by the Massachusetts Institute of Technology.
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>
24 #include <moira.h>
25 #include <moira_site.h>
26 #include <menu.h>
27
28 #include "mit-copyright.h"
29 #include "defs.h"
30 #include "f_defs.h"
31 #include "globals.h"
32
33 #define LIST    0
34 #define MEMBERS 1
35 #define GLOM    2
36 #define ACE_USE 3
37
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
44 #define DEFAULT_ACE_TYPE    "user"
45 #define DEFAULT_ACE_NAME    (user)
46 #define DEFAULT_DESCRIPTION DEFAULT_COMMENT
47
48 /* globals only for this file. */
49
50 static char current_list[BUFSIZ];
51
52 /*      Function Name: PrintListAce
53  *      Description: This function prints the list ace information.
54  *      Arguments: info - an info structure.
55  *      Returns: none.
56  */
57
58 static void
59 PrintListAce(info)
60 char ** info;
61 {
62     char buf[BUFSIZ];
63
64     sprintf(buf, "Item: %-20s Name: %s", info[ACE_TYPE], 
65             info[ACE_NAME]);
66     Put_message(buf);
67 }
68
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
75 static void
76 PrintListInfo(info)
77 char ** info;
78 {
79     char buf[BUFSIZ];
80
81     Put_message(" ");
82     (void) sprintf(buf, "%20sList: %s", "", info[L_NAME]);
83     (void) Put_message(buf);
84     (void) sprintf(buf, "Description: %s", info[L_DESC]);
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]) ) {
91         (void) sprintf(buf,"This list is a Group and its ID number is %s",
92                        info[L_GID]);
93         Put_message(buf);
94     }
95     else
96         Put_message("This list is NOT a Group.");
97
98     if (strcmp(info[L_ACE_TYPE],"NONE") == 0)
99         Put_message("This list has no Administrator, how strange?!");
100     else {
101         sprintf(buf, "The Administrator of this list is the %s: %s",
102                 info[L_ACE_TYPE], info[L_ACE_NAME]);
103         Put_message(buf);
104     }
105
106     (void) sprintf(buf, "This list is: %s, %s, and %s",
107                    atoi(info[L_ACTIVE]) ? "active" : "inactive",
108                    atoi(info[L_PUBLIC]) ? "public" : "private",
109                    atoi(info[L_HIDDEN]) ? "hidden" : "visible");
110     (void) Put_message(buf);
111     sprintf(buf, MOD_FORMAT, info[L_MODBY], info[L_MODTIME], info[L_MODWITH]);
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 */
123 struct qelem *
124 GetListInfo(type, name1, name2)
125 int type;
126 char * name1, *name2;
127 {
128     char *args[2];
129     struct qelem * elem = NULL;
130     register int status;
131
132     switch(type) {
133     case LIST:
134         args[0] = name1;
135         if ( (status = do_mr_query("get_list_info", 1, args,
136                                StoreInfo, (char *) &elem)) != 0) {
137             com_err(program_name, status, " in get_list_info");
138             return (NULL);
139         }
140         break;
141     case MEMBERS:
142         args[0] = name1;
143         if ( (status = do_mr_query("get_members_of_list", 1, args,
144                                StoreInfo, (char *) &elem)) != 0) {
145             com_err(program_name, status, " in get_members_of_list");
146             return (NULL);
147         }
148         break;
149     case GLOM:
150         args[0] = name1;        
151         args[1] = name2;        
152         if ( (status =  do_mr_query("get_lists_of_member", 2, args,
153                                StoreInfo, (char *) &elem)) != 0) {
154             com_err(program_name, status, " in get_list_of_members");
155             return (NULL);
156         }
157         break;
158     case ACE_USE:
159         args[0] = name1;        
160         args[1] = name2;        
161         if ( (status =  do_mr_query("get_ace_use", 2, args,
162                                StoreInfo, (char *) &elem)) != 0) {
163             com_err(program_name, status, " in get_ace_use");
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
180 char **
181 AskListInfo(info, name)
182 char ** info;
183 Bool name;
184 {
185     char temp_buf[BUFSIZ], *newname;
186
187     Put_message(" ");
188     sprintf(temp_buf,"Setting information of list %s.",info[L_NAME]);
189     Put_message(temp_buf);
190     Put_message(" ");
191
192     if (name) {
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         }
199     }
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]);
204     GetYesNoValueFromUser("Is this a group", &info[L_GROUP]);
205     if (atoi(info[L_GROUP]))
206         GetValueFromUser("What is the GID for this group.", &info[L_GID]);
207
208     GetTypeFromUser("What Type of Administrator", "ace_type",&info[L_ACE_TYPE]);
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     }
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.
234  *      Arguments: argc, argv - name of list in argv[1].
235  *      Returns: DM status code.
236  */
237
238 /* ARGSUSED */
239 int
240 ShowListInfo(argc, argv)
241 int argc;
242 char **argv;
243 {
244     struct qelem *top, *list;
245
246     top = list = GetListInfo(LIST, argv[1], (char *) NULL);
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
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 */   
264 static void
265 RealUpdateList(info, junk)
266 char ** info;
267 Bool junk;
268 {
269     register int stat;
270     char ** args;
271     
272     args = AskListInfo(info, TRUE);
273     if ( (stat = do_mr_query("update_list", CountArgs(args), args, 
274                            Scream, (char *) NULL)) != MR_SUCCESS) {
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
282 /*      Function Name: UpdateList
283  *      Description: updates the information on a list.
284  *      Arguments: argc, argv - name of list in argv[1].
285  *      Returns: DM Status code.
286  */
287
288 /* ARGSUSED */
289 int
290 UpdateList(argc, argv)
291 int argc;
292 char **argv;
293 {
294     struct qelem *top;
295
296     top = GetListInfo(LIST, argv[1], (char *) NULL);
297     QueryLoop(top, NullPrint, RealUpdateList, "Update the list");
298
299     FreeQueue(top);
300     return(DM_NORMAL);
301 }
302
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
310 static char **
311 SetDefaults(info, name)
312 char ** info;
313 char * 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);
322    info[L_ACE_TYPE] = Strsave(DEFAULT_ACE_TYPE);
323    info[L_ACE_NAME] = Strsave(DEFAULT_ACE_NAME);
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
329 /*      Function Name: AddList
330  *      Description: 
331  *      Arguments: argc, argv - name of list in argv[1].
332  *      Returns: SUB_ERROR if list not created.
333  */
334
335 /* ARGSUSED */
336 int
337 AddList(argc, argv)
338 int argc;
339 char **argv;
340 {
341     static char *info[MAX_ARGS_SIZE], **add_args;
342     int status, ret_code = SUB_NORMAL;
343
344     if (!ValidName(argv[1]))
345       return(DM_NORMAL);
346     status = do_mr_query("get_list_info", 1, argv + 1, NullFunc, 
347                        (char *) NULL);
348     if (status != MR_NO_MATCH) {
349         if (status == MR_SUCCESS)
350             Put_message("This list already exists.");
351         else
352             com_err(program_name, status, " in AddList.");      
353         return(SUB_ERROR);
354     }
355
356     add_args = AskListInfo(SetDefaults(info,argv[1]), FALSE);
357
358     if ( (status = do_mr_query("add_list", CountArgs(add_args), add_args,
359                              Scream, (char *) NULL)) != MR_SUCCESS) {
360         com_err(program_name, status, " in AddList.");  
361         Put_message("List Not Created.");
362         ret_code = SUB_ERROR;
363     }
364
365     FreeInfo(info);
366     return(ret_code);
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
375 int
376 ListHelp()
377 {
378     static char * message[] = {
379         "Listmaint handles the creation, deletion, and updating of lists.",
380         "A list can be a mailing list, a group list, or both.",
381         "The concept behind lists is that a list has an owner",
382         "- administrator -  and members.",
383         "The administrator of a list may be another list.",
384         "The members of a list can be users (login names), other lists,",
385         "or address strings.",
386         "You can use certain keys to do the following:",
387         "    Refresh the screen - Type ctrl-L.",
388         "    Escape from a function - Type ctrl-C.",
389         "    Suspend the program (temporarily) - Type ctrl-Z.",
390         NULL,
391     };
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 */
406 int
407 ListmaintMemberMenuEntry(m, argc, argv)
408 Menu *m;
409 int argc;
410 char **argv;
411 {
412     char temp_buf[BUFSIZ];
413     char *list_name = argv[1];
414     register int stat;    
415
416     if (!ValidName(list_name))
417         return(DM_QUIT);
418
419     if (*argv[0] == 'a') {      /* add_list */
420         if (AddList(argc, argv) == SUB_ERROR)
421             return(DM_QUIT);
422         (void) sprintf(temp_buf, "List '%s' created. Do you want to %s",
423                        list_name, "change its membership (y/n)? ");
424         if (YesNoQuestion(temp_buf, TRUE) != TRUE )
425             return(DM_QUIT);
426     }
427     else 
428         /* All we want to know is if it exists. */
429         switch( (stat = do_mr_query("count_members_of_list", 1, argv + 1,
430                                    NullFunc, (char *) NULL))) {
431         case MR_SUCCESS:
432             break;
433         case MR_LIST:
434             Put_message("This list does not exist.");
435             return(DM_QUIT);
436         case MR_PERM:
437             Put_message("You are not allowed to view this list.");
438             break;
439         default:
440             com_err(program_name, stat, " in get_list_info");
441             return(DM_QUIT);
442         }
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
458 int
459 ListmaintMemberMenuExit(m)
460 Menu *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
474 int
475 ListMembersByType(type)
476 char * type;
477 {
478     char temp_buf[BUFSIZ];
479     register int status;
480     char * args[10];
481
482     args[0] = current_list;
483     args[1] = NULL;
484
485     found_some = FALSE;
486     if ( (status = do_mr_query("get_members_of_list", CountArgs(args), args, 
487                              PrintByType, type)) != 0) {
488         com_err(program_name, status, " in ListMembersByType");
489         return(DM_NORMAL);
490     }
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
507 int
508 ListAllMembers()
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
520 ListUserMembers()
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
532 ListListMembers()
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
544 ListStringMembers()
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
560 int
561 GetMemberInfo(action, ret_argv)
562 char *action, **ret_argv;
563 {
564     char temp_buf[BUFSIZ], ret_buf[BUFSIZ];
565
566     ret_argv[LM_LIST] = Strsave(current_list);
567
568     ret_argv[LM_TYPE] = Strsave("user");
569     GetTypeFromUser("Type of member", "member", &ret_argv[LM_TYPE]);
570
571     sprintf(temp_buf,"Name of %s to %s", ret_argv[LM_TYPE], action);
572     ret_argv[LM_MEMBER] = Strsave(user);
573     GetValueFromUser(temp_buf, &ret_argv[LM_MEMBER]);
574     ret_argv[LM_END] = NULL;            /* NULL terminate this list. */
575
576     if (strcasecmp(ret_argv[LM_TYPE], "string") &&
577         !ValidName( ret_argv[LM_MEMBER] ) ) {
578         FreeInfo(ret_argv);
579         return(SUB_ERROR);
580     }
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
590 int
591 AddMember()
592 {
593     char *args[10], temp_buf[BUFSIZ];
594     register int status;
595
596     if ( GetMemberInfo("add", args) == SUB_ERROR )
597         return(DM_NORMAL);
598
599     if ( (status = do_mr_query("add_member_to_list", CountArgs(args), args,
600                            Scream, NULL)) != MR_SUCCESS) {
601         if (status == MR_EXISTS) {
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     }
609
610     FreeInfo(args);
611     return(DM_NORMAL);
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
620 int
621 DeleteMember()
622 {
623     char *args[10];
624     register int status;
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?") ) {
630         if (status = do_mr_query("delete_member_from_list", CountArgs(args),
631                                args, Scream, NULL))
632             com_err(program_name, status, " in DeleteMember");
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
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.
648  *      NOTES: QueryLoop() does not work here because info does not have
649  *             enough information in it to delete the member from the list.
650  */
651
652 int
653 InterRemoveItemFromLists()
654 {
655     register int status;
656     char type[BUFSIZ], name[BUFSIZ], *args[10], buf[BUFSIZ];
657     struct qelem *top, *elem;
658
659     if ( !(PromptWithDefault("Type of member (user, list, string)", type, 
660                             BUFSIZ, "user")) )
661         return(DM_NORMAL);
662     
663     sprintf(buf, "Name of %s", type);
664     if ( !(PromptWithDefault(buf, name, BUFSIZ, user)) ) {
665         return(DM_NORMAL);
666     }
667
668     if (!ValidName(name))
669         return(DM_NORMAL);
670
671     top = elem = GetListInfo(GLOM, type, name);
672
673     while(elem != NULL) {
674         char line[BUFSIZ];
675         char ** info = (char **) elem->q_data;
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:
680             Put_message("deleting...");
681             args[DM_LIST] = info[GLOM_NAME];
682             args[DM_TYPE] = type;
683             args[DM_MEMBER] = name;
684             if ( (status = do_mr_query("delete_member_from_list", 3, args,
685                                Scream, (char *) NULL)) != 0)
686                 /* should probabally check to delete list. */
687                 com_err(program_name, status, " in delete_member");
688             break;
689         case FALSE:
690             break;
691         default:
692             Put_message("Aborting...");
693             FreeQueue(top);
694             return(DM_NORMAL);
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.
706  *      Arguments: none.
707  *      Returns: DM_NORMAL.
708  */
709
710 int
711 ListByMember()
712 {
713     char buf[BUFSIZ], temp_buf[BUFSIZ], *type, *name, **info;
714     Bool maillist, group;
715     struct qelem *top, *elem;
716
717     if ( !(PromptWithDefault("Type of member (user, list, string)", buf, 
718                             BUFSIZ, "user")) )
719         return(DM_NORMAL);
720
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)) ) {
727         free(type);
728         return(DM_NORMAL);
729     }
730     name = Strsave(buf);
731
732     maillist = YesNoQuestion("Show Lists that are Maillists (y/n) ?",
733                              TRUE);
734     group = YesNoQuestion("Show Lists that are Groups (y/n) ?", TRUE);
735
736     elem = top = GetListInfo(GLOM, type, name);
737
738     while (elem != NULL) {
739         info = (char**) elem->q_data;
740         if ((maillist == TRUE && !strcmp(info[GLOM_MAILLIST], "1")) ||
741             (group == TRUE && !strcmp(info[GLOM_GROUP], "1")))
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.
752  *      Arguments: none.
753  *      Returns: DM_NORMAL.
754  */
755
756 int
757 ListByAdministrator()
758 {
759     char buf[BUFSIZ], temp_buf[BUFSIZ], *type, *name;
760     struct qelem *top;
761
762     if ( !(PromptWithDefault("Type of member (user, list, string)", buf, 
763                             BUFSIZ, "user")) )
764         return(DM_NORMAL);
765
766     if ( YesNoQuestion("Do you want a recursive search (y/n)", FALSE) == 1 ) {
767         sprintf(temp_buf, "R%s", buf);  /* "USER" to "RUSER" etc. */
768         type = Strsave(temp_buf);
769     }
770     else 
771         type = Strsave(buf);
772     
773     sprintf(temp_buf, "Name of %s", buf);
774     if ( !(PromptWithDefault(temp_buf, buf, BUFSIZ, user)) ) {
775         free(type);
776         return(DM_NORMAL);
777     }
778     name = Strsave(buf);
779
780     top = GetListInfo(ACE_USE, type, name);
781     Loop(top, PrintListAce);
782
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
793 ListAllGroups()
794 {
795     register int status;
796     static char * args[] = {
797         "TRUE",                 /* active */
798         "DONTCARE",             /* public */
799         "FALSE",                /* hidden */
800         "DONTCARE",             /* maillist */
801         "TRUE",                 /* group. */
802     };
803
804     if (YesNoQuestion("This query will take a while, Do you wish to continue?",
805                        TRUE) == TRUE )
806         if (status = do_mr_query("qualified_get_lists", 5, args,
807                                Print, (char *) NULL) != 0)
808             com_err(program_name, status, " in ListAllGroups");
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
818 ListAllMailLists()
819 {
820     register int status;
821     static char * args[] = {
822         "TRUE",                 /* active */
823         "DONTCARE",             /* public */
824         "FALSE",                /* hidden */
825         "TRUE",                 /* maillist */
826         "DONTCARE",             /* group. */
827     };
828
829     if (YesNoQuestion("This query will take a while. Do you wish to continue?",
830                        TRUE) == TRUE )
831         if (status = do_mr_query("qualified_get_lists", 5, args,
832                                Print, (char *) NULL) != 0)
833             com_err(program_name, status, " in ListAllGroups");
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
844 ListAllPublicMailLists()
845 {
846     register int status;
847     static char * args[] = {
848         "TRUE",                 /* active */
849         "TRUE",                 /* public */
850         "FALSE",                /* hidden */
851         "TRUE",                 /* maillist */
852         "DONTCARE",             /* group. */
853     };
854
855     if (YesNoQuestion("This query will take a while. Do you wish to continue?",
856                        TRUE) == TRUE )
857         if (status = do_mr_query("qualified_get_lists", 5, args,
858                                Print, (char *) NULL) != 0)
859             com_err(program_name, status, " in ListAllGroups");
860
861     return (DM_NORMAL); 
862 }
This page took 0.116949 seconds and 5 git commands to generate.