1 #if (!defined(lint) && !defined(SABER))
2 static char rcsid_module_c[] = "$Header$";
5 /* This is the file pobox.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: Functions for handling the poboxes.
10 * By: Chris D. Peterson
16 * Copyright 1988 by the Massachusetts Institute of Technology.
18 * For further information on copyright and distribution
19 * see the file mit-copyright.h
28 #include "mit-copyright.h"
34 #define FOREIGN_BOX ("SMTP")
35 #define LOCAL_BOX ("POP")
37 /* Function Name: PrintPOBox
38 * Description: Yet another specialized print function.
39 * Arguments: info - all info about this PO_box.
49 sprintf(buf, "Address: %-10s Box: %-35s Type: %s", info[PO_NAME],
50 info[PO_BOX], info[PO_TYPE]);
54 /* Function Name: RealPrintPOMachines
55 * Description: Actually does the printing for PrintPOMachines.
56 * Arguments: info, - name of machines in info[1].
61 RealPrintPOMachines(info)
64 Print(1, info + 1, (char *) NULL);
67 /* Function Name: PrintPOMachines
68 * Description: Prints all current post offices.
70 * Returns: SUB_ERROR if the machines could not be printed.
77 static char * args[] = {"pop", NULL};
78 struct qelem * top = NULL;
80 if ( (status = sms_query("get_server_locations", CountArgs(args), args,
81 StoreInfo, &top)) != SMS_SUCCESS) {
82 com_err(program_name, status, " in get_server_locations.");
87 Loop(top, RealPrintPOMachines);
92 /* Function Name: GetUserPOBox
93 * Description: prints the users POBox information.
94 * Arguments: argc, argv - name of the user in argv[1].
100 GetUserPOBox(argc, argv)
105 struct qelem * top = NULL;
108 if (!ValidName(argv[1]))
111 switch (status = sms_query("get_pobox", 1, argv + 1, StoreInfo, &top)) {
113 Put_message("This user has no P.O. Box.");
116 sprintf(buf,"Current pobox for user %s: \n", argv[1]);
119 Loop(top, PrintPOBox); /* should only return 1 box. */
123 com_err(program_name, status, "in get_pobox.");
128 /* Function Name: GetNewLocalPOBox
129 * Description: get the machine for a new local pop Box for the user.
130 * Arguments: local_user - name of the local user.
131 * Returns: machine - name of the machine for then new pop box, or NULL.
135 GetNewLocalPOBox(local_user)
138 char temp_buf[BUFSIZ];
140 sprintf(temp_buf, "%s did not have a previous local PO Box.", local_user);
141 Put_message(temp_buf);
142 sprintf(temp_buf,"%s %s", "Pick one of the following",
143 "machines for this user's Post Office.");
144 Put_message(temp_buf);
146 if (PrintPOMachines() == SUB_NORMAL) {
148 Prompt_input("Which Machine? ", temp_buf, BUFSIZ);
149 return( Strsave(temp_buf) );
151 Put_message("Could not get machines to choose from, quitting.");
155 /* Function Name: SetUserPOBox
156 * Description: Addes or Chnages the P.O. Box for a user.
157 * Arguments: argc, argv - the login name of the user in argv[1].
158 * Returns: DM_NORMAL.
162 SetUserPOBox(argc, argv)
167 char *type, temp_buf[BUFSIZ], *local_user, *args[10], box[BUFSIZ];
169 local_user = argv[1];
171 if (!ValidName(local_user))
174 (void) GetUserPOBox(argc, argv); /* print current info. */
176 sprintf(temp_buf, "Assign %s a local PO Box (y/n)", local_user);
177 switch (YesNoQuestion(temp_buf, TRUE)) {
180 switch (YesNoQuestion("Use Previous Local Box (y/n)", TRUE)) {
182 switch (status = sms_query("set_pobox_pop", 1,
183 &local_user, Scream, NULL)) {
187 if ( (temp_box = GetNewLocalPOBox(local_user)) == SUB_NORMAL) {
188 strcpy(box, temp_box);
195 com_err(program_name, status, "in set_pobox_pop.");
199 if ( (temp_box = GetNewLocalPOBox(local_user)) == SUB_NORMAL) {
200 strcpy(box, temp_box);
212 sprintf(temp_buf, "Set up a foreign PO Box for %s (y/n)", local_user);
213 switch( YesNoQuestion(temp_buf, TRUE)) {
215 if (!Prompt_input("Foreign PO Box for this user? ", box, BUFSIZ))
220 return(DM_NORMAL); /* ^C hit. */
223 args[PO_NAME] = local_user;
224 args[PO_TYPE] = type;
227 if ( (status = sms_query("set_pobox", CountArgs(args), args,
228 Scream, NULL)) != SMS_SUCCESS )
229 com_err(program_name, status, " in ChangeUserPOBox");
231 Put_message("PO Box assigned.");
232 default: /* ^C hit. */
238 /* Function Name: RemoveUserPOBox
239 * Description: Removes this users POBox.
240 * Arguments: argc, argv - name of user in argv[1].
241 * Returns: DM_NORMAL.
246 RemoveUserPOBox(argc, argv)
251 char temp_buf[BUFSIZ];
253 if (!ValidName(argv[1]))
257 "Are you sure that you want to remove %s's PO Box (y/n)", argv[1]);
259 if (Confirm(temp_buf)) {
260 if ( (status = sms_query("delete_pobox", 1, argv + 1, Scream, NULL)) !=
262 com_err(program_name, status, "in delete_pobox.");
264 Put_message("PO Box removed.");
273 * c-continued-statement-offset: 4
275 * c-argdecl-indent: 4