]> andersk Git - moira.git/blob - clients/moira/lists.c
a3f25c4fb136774845dd59aa97377b45a9e91f56
[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 SMS Client, which allows a nieve
6  *      user to quickly and easily maintain most parts of the SMS 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 <sms.h>
25 #include <menu.h>
26
27 #include "mit-copyright.h"
28 #include "defs.h"
29 #include "f_defs.h"
30 #include "globals.h"
31 #include "infodefs.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_sms_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_sms_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_sms_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_sms_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         newname = Strsave(info[L_NAME]);
194         GetValueFromUser("The new name for this list", &newname);
195     }
196     GetYesNoValueFromUser("Is this an active list", &info[L_ACTIVE]);
197     GetYesNoValueFromUser("Is this a public list", &info[L_PUBLIC]);
198     GetYesNoValueFromUser("Is this a hidden list", &info[L_HIDDEN]);
199     GetYesNoValueFromUser("Is this a maillist", &info[L_MAILLIST]);
200     GetYesNoValueFromUser("Is this a group", &info[L_GROUP]);
201     if (atoi(info[L_GROUP]))
202         GetValueFromUser("What is the GID for this group.", &info[L_GID]);
203
204     GetTypeFromUser("What Type of Administrator", "ace_type",&info[L_ACE_TYPE]);
205     if ( (strcmp(info[L_ACE_TYPE], "USER") == 0) || 
206         (strcmp(info[L_ACE_TYPE], "user") == 0) )
207         GetValueFromUser("Who will be the administrator of this list: ",
208                          &info[L_ACE_NAME]);
209     if ( (strcmp(info[L_ACE_TYPE], "LIST") == 0) ||
210         (strcmp(info[L_ACE_TYPE], "list") == 0) )
211        GetValueFromUser("Which group will be the administrator of this list: ",
212                          &info[L_ACE_NAME]);
213     GetValueFromUser("Description: ", &info[L_DESC]);
214
215     FreeAndClear(&info[L_MODTIME], TRUE);
216     FreeAndClear(&info[L_MODBY], TRUE);
217     FreeAndClear(&info[L_MODWITH], TRUE);
218 /* 
219  * Slide the newname into the #2 slot, this screws up all future references 
220  * to this list.
221  */
222     if (name)                   /* slide the newname into the #2 slot. */
223         SlipInNewName(info, newname);
224
225     return(info);
226 }
227
228 /* -------------- List functions. -------------- */
229
230 /*      Function Name: ShowListInfo.
231  *      Description: shows info on a list.
232  *      Arguments: argc, argv - name of list in argv[1].
233  *      Returns: DM status code.
234  */
235
236 /* ARGSUSED */
237 int
238 ShowListInfo(argc, argv)
239 int argc;
240 char **argv;
241 {
242     struct qelem *top, *list;
243
244     top = list = GetListInfo(LIST, argv[1], (char *) NULL);
245     while (list != NULL) {
246         PrintListInfo( (char **) list->q_data);
247         list = list->q_forw;
248     }
249     
250     FreeQueue(top);
251     return(DM_NORMAL);
252 }
253
254 /*      Function Name: RealUpdateList
255  *      Description: performs the actual update of the list.
256  *      Arguments: info - all information needed to update the list.
257  *                 junk - an UNUSED boolean.
258  *      Returns: none.
259  */
260  
261 /* ARGSUSED */   
262 static void
263 RealUpdateList(info, junk)
264 char ** info;
265 Bool junk;
266 {
267     register int stat;
268     char ** args;
269     
270     args = AskListInfo(info, TRUE);
271     if ( (stat = do_sms_query("update_list", CountArgs(args), args, 
272                            Scream, (char *) NULL)) != SMS_SUCCESS) {
273         com_err(program_name, stat, " in UpdateList."); 
274         Put_message("List ** NOT ** Updated.");
275     }
276     else
277         Put_message("List successfully updated.");
278 }
279
280 /*      Function Name: UpdateList
281  *      Description: updates the information on a list.
282  *      Arguments: argc, argv - name of list in argv[1].
283  *      Returns: DM Status code.
284  */
285
286 /* ARGSUSED */
287 int
288 UpdateList(argc, argv)
289 int argc;
290 char **argv;
291 {
292     struct qelem *top;
293
294     top = GetListInfo(LIST, argv[1], (char *) NULL);
295     QueryLoop(top, NullPrint, RealUpdateList, "Update the list");
296
297     FreeQueue(top);
298     return(DM_NORMAL);
299 }
300
301 /*      Function Name: SetDefaults
302  *      Description: sets defaults for AddList function
303  *      Arguments: info - the array to add them to.
304  *                 name - name of the program to add.
305  *      Returns: defaults - the default information.
306  */
307
308 static char **
309 SetDefaults(info, name)
310 char ** info;
311 char * name;
312 {
313    info[L_NAME] =     Strsave(name);
314    info[L_ACTIVE] =   Strsave(DEFAULT_ACTIVE);
315    info[L_PUBLIC] =   Strsave(DEFAULT_PUBLIC);
316    info[L_HIDDEN] =   Strsave(DEFAULT_HIDDEN);
317    info[L_MAILLIST] = Strsave(DEFAULT_MAILLIST);
318    info[L_GROUP] =    Strsave(DEFAULT_GROUP);
319    info[L_GID] =      Strsave(DEFAULT_GID);
320    info[L_ACE_TYPE] = Strsave(DEFAULT_ACE_TYPE);
321    info[L_ACE_NAME] = Strsave(DEFAULT_ACE_NAME);
322    info[L_DESC] =     Strsave(DEFAULT_DESCRIPTION);
323    info[L_MODTIME] = info[L_MODBY] = info[L_MODWITH] = info[L_END] = NULL;
324    return(info);
325 }
326
327 /*      Function Name: AddList
328  *      Description: 
329  *      Arguments: argc, argv - name of list in argv[1].
330  *      Returns: SUB_ERROR if list not created.
331  */
332
333 /* ARGSUSED */
334 int
335 AddList(argc, argv)
336 int argc;
337 char **argv;
338 {
339     static char *info[MAX_ARGS_SIZE], **add_args;
340     int status, ret_code = SUB_NORMAL;
341
342     status = do_sms_query("get_list_info", 1, argv + 1, NullFunc, 
343                        (char *) NULL);
344     if (status != SMS_NO_MATCH) {
345         if (status == SMS_SUCCESS)
346             Put_message("This list already exists.");
347         else
348             com_err(program_name, status, " in AddList.");      
349         return(SUB_ERROR);
350     }
351
352     add_args = AskListInfo(SetDefaults(info,argv[1]), FALSE);
353
354     if ( (status = do_sms_query("add_list", CountArgs(add_args), add_args,
355                              Scream, (char *) NULL)) != SMS_SUCCESS) {
356         com_err(program_name, status, " in AddList.");  
357         Put_message("List Not Created.");
358         ret_code = SUB_ERROR;
359     }
360
361     FreeInfo(info);
362     return(ret_code);
363 }
364
365 /*      Function Name: Instructions
366  *      Description: This func prints out instruction on manipulating lists.
367  *      Arguments: none
368  *      Returns: DM Status Code.
369  */
370
371 int
372 ListHelp()
373 {
374     static char * message[] = {
375         "Listmaint handles the creation, deletion, and updating of lists.",
376         "A list can be a mailing list, a group list, or both.",
377         "The concept behind lists is that a list has an owner",
378         "- administrator -  and members.",
379         "The administrator of a list may be another list.",
380         "The members of a list can be users (login names), other lists,",
381         "or address strings.",
382         "You can use certain keys to do the following:",
383         "    Refresh the screen - Type ctrl-L.",
384         "    Escape from a function - Type ctrl-C.",
385         "    Suspend the program (temporarily) - Type ctrl-Z.",
386         NULL,
387     };
388
389     return(PrintHelp(message));
390 }
391
392 /*-*-* LISTMAINT UPDATE MENU *-*-*/
393
394 /*      Function Name: ListmaintMemberMenuEntry
395  *      Description: entry routine into the listmaint member menu.
396  *      Arguments: m - the member menu.
397  *                 argc, argv - name of the list in argv[1].
398  *      Returns: none.
399  */
400
401 /* ARGSUSED */
402 int
403 ListmaintMemberMenuEntry(m, argc, argv)
404 Menu *m;
405 int argc;
406 char **argv;
407 {
408     char temp_buf[BUFSIZ];
409     char *list_name = argv[1];
410     register int stat;    
411
412     if (!ValidName(list_name))
413         return(DM_QUIT);
414
415     if (*argv[0] == 'a') {      /* add_list */
416         if (AddList(argc, argv) == SUB_ERROR)
417             return(DM_QUIT);
418         (void) sprintf(temp_buf, "List '%s' created. Do you want to %s",
419                        list_name, "change its membership (y/n)? ");
420         if (YesNoQuestion(temp_buf, TRUE) != TRUE )
421             return(DM_QUIT);
422     }
423     else 
424         /* All we want to know is if it exists. */
425         switch( (stat = do_sms_query("count_members_of_list", 1, argv + 1,
426                                    NullFunc, (char *) NULL))) {
427         case SMS_SUCCESS:
428             break;
429         case SMS_LIST:
430             Put_message("This list does not exist.");
431             return(DM_QUIT);
432         case SMS_PERM:
433             Put_message("You are not allowed to view this list.");
434             break;
435         default:
436             com_err(program_name, stat, " in get_list_info");
437             return(DM_QUIT);
438         }
439
440     (void) sprintf(temp_buf, 
441                    "Change/Display membership of '%s'", list_name);
442     m->m_title = Strsave(temp_buf);
443     strcpy(current_list, list_name);
444     return(DM_NORMAL);
445 }
446
447 /*      Function Name: ListmaintMemberMenuExit
448  *      Description: This is the function called when the member menu is
449  *                   exited, it frees the memory that is storing the name.
450  *      Arguments: m - the menu
451  *      Returns: DM_NORMAL 
452  */
453
454 int
455 ListmaintMemberMenuExit(m)
456 Menu *m;
457 {
458     free(m->m_title);
459     strcpy(current_list, "");
460     return(DM_NORMAL);
461 }
462
463 /*      Function Name: ListMembersByType
464  *      Description: This function lists the users of a list by type.
465  *      Arguments: type - the type of the list "USER", "LIST", or "STRING".
466  *      Returns: none.
467  *      NOTE: if type is NULL, all lists members are listed.
468  */
469
470 int
471 ListMembersByType(type)
472 char * type;
473 {
474     char temp_buf[BUFSIZ];
475     register int status;
476     char * args[10];
477
478     args[0] = current_list;
479     args[1] = NULL;
480
481     found_some = FALSE;
482     if ( (status = do_sms_query("get_members_of_list", CountArgs(args), args, 
483                              PrintByType, type)) != 0) {
484         com_err(program_name, status, " in ListMembersByType");
485         return(DM_NORMAL);
486     }
487     if (!found_some) {
488         if (type == NULL)
489             Put_message("List is empty (no members).");
490         else {
491             sprintf(temp_buf,"No %s Members",type);
492             Put_message(temp_buf);
493         }
494     }
495 }
496
497 /*      Function Name: ListAllMembers
498  *      Description: lists all members of the current list.
499  *      Arguments: 
500  *      Returns: DM_NORMAL
501  */
502
503 int
504 ListAllMembers()
505 {
506     ListMembersByType(NULL);
507     return (DM_NORMAL);
508 }
509
510 /*      Function Name: ListUserMembers
511  *      Description: This function lists all members of a list of type "USER".
512  *      Arguments: none
513  *      Returns: DM_NORMAL.
514  */
515
516 ListUserMembers()
517 {
518     ListMembersByType("USER");
519     return(DM_NORMAL);
520 }
521
522 /*      Function Name: ListListMembers
523  *      Description: This function lists all members of a list of type "LIST".
524  *      Arguments: none
525  *      Returns: DM_NORMAL.
526  */
527
528 ListListMembers()
529 {
530     ListMembersByType("LIST");
531     return(DM_NORMAL);
532 }
533
534 /*      Function Name: ListStringMembers
535  *      Description:This function lists all members of a list of type "STRING".
536  *      Arguments: none
537  *      Returns: DM_NORMAL.
538  */
539
540 ListStringMembers()
541 {
542     ListMembersByType("STRING");
543     return(DM_NORMAL);
544 }
545
546 /*      Function Name: GetMemberInfo
547  *      Description: This function gets the information needed to
548  *                   add or delete a user from a list.
549  *      Arguments: argc, argv - standard.
550  *                 action - name of the action to be performed either
551  *                          "add" or "delete".
552  *                 ret_argc, ret_argv - the returned value of argc and argv.
553  *      Returns: SUB_ERROR or SUB_NORMAL.
554  */
555
556 int
557 GetMemberInfo(action, ret_argv)
558 char *action, **ret_argv;
559 {
560     char temp_buf[BUFSIZ], ret_buf[BUFSIZ];
561
562     ret_argv[LM_LIST] = Strsave(current_list);
563
564     ret_argv[LM_TYPE] = Strsave("user");
565     GetTypeFromUser("Type of member", "member", &ret_argv[LM_TYPE]);
566
567     sprintf(temp_buf,"Name of %s to %s", ret_argv[LM_TYPE], action);
568     ret_argv[LM_MEMBER] = Strsave(user);
569     GetValueFromUser(temp_buf, &ret_argv[LM_MEMBER]);
570     ret_argv[LM_END] = NULL;            /* NULL terminate this list. */
571
572     if (!ValidName( ret_argv[LM_MEMBER] ) ) {
573         FreeInfo(ret_argv);
574         return(SUB_ERROR);
575     }
576     return(SUB_NORMAL);
577 }
578
579 /*      Function Name: AddMember
580  *      Description: This function adds a member to a list.
581  *      Arguments: none.
582  *      Returns: DM_NORMAL.
583  */
584
585 int
586 AddMember()
587 {
588     char *args[10], temp_buf[BUFSIZ];
589     register int status;
590
591     if ( GetMemberInfo("add", args) == SUB_ERROR )
592         return(DM_NORMAL);
593
594     if ( (status = do_sms_query("add_member_to_list", CountArgs(args), args,
595                            Scream, NULL)) != SMS_SUCCESS) {
596         if (status == SMS_EXISTS) {
597             sprintf(temp_buf, "The %s %s is already a member of LIST %s.",
598                     args[LM_TYPE], args[LM_MEMBER], args[LM_LIST]);
599             Put_message(temp_buf);
600         }
601         else 
602             com_err(program_name, status, " in AddMember");
603     }
604
605     FreeInfo(args);
606     return(DM_NORMAL);
607 }
608
609 /*      Function Name: DeleteMember
610  *      Description: This function deletes a member from a list.
611  *      Arguments: none.
612  *      Returns: DM_NORMAL
613  */
614
615 int
616 DeleteMember()
617 {
618     char *args[10];
619     register int status;
620
621     if( GetMemberInfo("delete", args) == SUB_ERROR )
622         return(DM_NORMAL);
623
624     if (Confirm("Are you sure you want to delete this member?") ) {
625         if (status = do_sms_query("delete_member_from_list", CountArgs(args),
626                                args, Scream, NULL))
627             com_err(program_name, status, " in DeleteMember");
628         else
629             Put_message("Deletion Completed.");
630     }
631     else 
632         Put_message("Deletion has been Aborted.");
633
634     FreeInfo(args);
635     return(DM_NORMAL);
636 }
637
638 /*      Function Name: InterRemoveItemFromLists
639  *      Description: This function allows interactive removal of an item
640  *                   (user, string, list) for all list  that it is on.
641  *      Arguments: none.
642  *      Returns: DM_NORMAL.
643  *      NOTES: QueryLoop() does not work here because info does not have
644  *             enough information in it to delete the member from the list.
645  */
646
647 int
648 InterRemoveItemFromLists()
649 {
650     register int status;
651     char type[BUFSIZ], name[BUFSIZ], *args[10], buf[BUFSIZ];
652     struct qelem *top, *elem;
653
654     if ( !(PromptWithDefault("Type of member (user, list, string)", type, 
655                             BUFSIZ, "user")) )
656         return(DM_NORMAL);
657     
658     sprintf(buf, "Name of %s", type);
659     if ( !(PromptWithDefault(buf, name, BUFSIZ, user)) ) {
660         return(DM_NORMAL);
661     }
662
663     if (!ValidName(name))
664         return(DM_NORMAL);
665
666     top = elem = GetListInfo(GLOM, type, name);
667
668     while(elem != NULL) {
669         char line[BUFSIZ];
670         char ** info = (char **) elem->q_data;
671         sprintf(line, "Delete %s %s from the list \"%s\" (y/n/q)? ", type,
672                 name, info[GLOM_NAME]);
673         switch (YesNoQuitQuestion(line, FALSE)) {
674         case TRUE:
675             Put_message("deleting...");
676             args[DM_LIST] = info[GLOM_NAME];
677             args[DM_TYPE] = type;
678             args[DM_MEMBER] = name;
679             if ( (status = do_sms_query("delete_member_from_list", 3, args,
680                                Scream, (char *) NULL)) != 0)
681                 /* should probabally check to delete list. */
682                 com_err(program_name, status, " in delete_member");
683             break;
684         case FALSE:
685             break;
686         default:
687             Put_message("Aborting...");
688             FreeQueue(top);
689             return(DM_NORMAL);
690         }
691         elem = elem->q_forw;
692     }
693     FreeQueue(top);
694     return(DM_NORMAL);
695 }
696
697 /*-*-* LIST MENU *-*-*/
698
699 /*      Function Name: ListByMember
700  *      Description: This gets all lists that a given member is a member of.
701  *      Arguments: none.
702  *      Returns: DM_NORMAL.
703  */
704
705 int
706 ListByMember()
707 {
708     char buf[BUFSIZ], temp_buf[BUFSIZ], *type, *name, **info;
709     Bool maillist, group;
710     struct qelem *top, *elem;
711
712     if ( !(PromptWithDefault("Type of member (user, list, string)", buf, 
713                             BUFSIZ, "user")) )
714         return(DM_NORMAL);
715
716     /* What we really want is a recursive search */
717     sprintf(temp_buf, "R%s", buf); 
718     type = Strsave(temp_buf);
719
720     sprintf(temp_buf, "Name of %s", buf);
721     if ( !(PromptWithDefault(temp_buf, buf, BUFSIZ, user)) ) {
722         free(type);
723         return(DM_NORMAL);
724     }
725     name = Strsave(buf);
726
727     maillist = YesNoQuestion("Show Lists that are Maillists (y/n) ?",
728                              TRUE);
729     group = YesNoQuestion("Show Lists that are Groups (y/n) ?", TRUE);
730
731     elem = top = GetListInfo(GLOM, type, name);
732
733     while (elem != NULL) {
734         info = (char**) elem->q_data;
735         if (maillist != TRUE || !strcmp(info[GLOM_MAILLIST], "1")) 
736             if (group != TRUE || !strcmp(info[GLOM_GROUP], "1")) 
737                 Put_message(info[GLOM_NAME]);
738         elem = elem->q_forw;
739     }
740     FreeQueue(top);
741     return (DM_NORMAL);
742 }
743
744 /*      Function Name: ListByAdministrator
745  *      Description: This function prints all lists which a given user or
746  *                   group administers.
747  *      Arguments: none.
748  *      Returns: DM_NORMAL.
749  */
750
751 int
752 ListByAdministrator()
753 {
754     char buf[BUFSIZ], temp_buf[BUFSIZ], *type, *name;
755     struct qelem *top;
756
757     if ( !(PromptWithDefault("Type of member (user, list, string)", buf, 
758                             BUFSIZ, "user")) )
759         return(DM_NORMAL);
760
761     if ( YesNoQuestion("Do you want a recursive search (y/n)", FALSE) == 1 ) {
762         sprintf(temp_buf, "R%s", buf);  /* "USER" to "RUSER" etc. */
763         type = Strsave(temp_buf);
764     }
765     else 
766         type = Strsave(buf);
767     
768     sprintf(temp_buf, "Name of %s", buf);
769     if ( !(PromptWithDefault(temp_buf, buf, BUFSIZ, user)) ) {
770         free(type);
771         return(DM_NORMAL);
772     }
773     name = Strsave(buf);
774
775     top = GetListInfo(ACE_USE, type, name);
776     Loop(top, PrintListAce);
777
778     FreeQueue(top);
779     return (DM_NORMAL);
780 }
781
782 /*      Function Name: ListAllGroups
783  *      Description: This function lists all visable groups.
784  *      Arguments: none.
785  *      Returns: DM_NORMAL.
786  */
787
788 ListAllGroups()
789 {
790     register int status;
791     static char * args[] = {
792         "TRUE",                 /* active */
793         "DONTCARE",             /* public */
794         "FALSE",                /* hidden */
795         "DONTCARE",             /* maillist */
796         "TRUE",                 /* group. */
797     };
798
799     if (YesNoQuestion("This query will take a while, Do you wish to continue?",
800                        TRUE) == TRUE )
801         if (status = do_sms_query("qualified_get_lists", 5, args,
802                                Print, (char *) NULL) != 0)
803             com_err(program_name, status, " in ListAllGroups");
804     return (DM_NORMAL);
805 }
806
807 /*      Function Name: ListAllMailLists
808  *      Description: This function lists all visable maillists.
809  *      Arguments: none
810  *      Returns: DM_NORMAL.
811  */
812
813 ListAllMailLists()
814 {
815     register int status;
816     static char * args[] = {
817         "TRUE",                 /* active */
818         "DONTCARE",             /* public */
819         "FALSE",                /* hidden */
820         "TRUE",                 /* maillist */
821         "DONTCARE",             /* group. */
822     };
823
824     if (YesNoQuestion("This query will take a while. Do you wish to continue?",
825                        TRUE) == TRUE )
826         if (status = do_sms_query("qualified_get_lists", 5, args,
827                                Print, (char *) NULL) != 0)
828             com_err(program_name, status, " in ListAllGroups");
829
830     return (DM_NORMAL); 
831 }
832
833 /*      Function Name: ListAllPublicMailLists
834  *      Description: This function lists all public mailing lists.
835  *      Arguments: none
836  *      Returns: DM_NORMAL.
837  */
838
839 ListAllPublicMailLists()
840 {
841     register int status;
842     static char * args[] = {
843         "TRUE",                 /* active */
844         "TRUE",                 /* public */
845         "FALSE",                /* hidden */
846         "TRUE",                 /* maillist */
847         "DONTCARE",             /* group. */
848     };
849
850     if (YesNoQuestion("This query will take a while. Do you wish to continue?",
851                        TRUE) == TRUE )
852         if (status = do_sms_query("qualified_get_lists", 5, args,
853                                Print, (char *) NULL) != 0)
854             com_err(program_name, status, " in ListAllGroups");
855
856     return (DM_NORMAL); 
857 }
This page took 0.089632 seconds and 3 git commands to generate.