3 * This is the file user.c for the Moira Client, which allows users
4 * to quickly and easily maintain most parts of the Moira database.
5 * It Contains: Functions for manipulating user information.
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>
17 #include <moira_site.h>
32 void CorrectCapitalization(char **name);
33 char **AskUserInfo(char **info, Bool name);
34 struct mqelem *GetUserInfo(int type, char *name1, char *name2);
43 #define DEFAULT_SHELL "/bin/athena/tcsh"
45 #define DEFAULT_SHELL "/bin/csh"
47 #define DEFAULT_CLASS "?"
49 #define DEFAULT_WINCONSOLESHELL "cmd"
51 /* Function Name: UserState
52 * Description: Convert a numeric state into a descriptive string.
53 * Arguments: state value
54 * Returns: pointer to statically allocated string.
57 static char *states[] = {
60 "Half Registered (2)",
62 "Not registerable (4)",
63 "Enrolled/Registerable (5)",
64 "Enrolled/Not Registerable (6)",
66 "Registerable, Kerberos only (8)",
67 "Active, Kerberos only (9)"
70 static char *UserState(int state)
72 static char buf[BUFSIZ];
74 if (state < 0 || state >= US_END)
76 sprintf(buf, "Unknown (%d)", state);
83 /* Function Name: PrintUserName
84 * Description: Print name of a user.
85 * Arguments: info - the information about a user.
89 static void PrintUserName(char **info)
91 char buf[BUFSIZ], print_buf[BUFSIZ];
92 sprintf(buf, "%s, %s %s", info[U_LAST], info[U_FIRST], info[U_MIDDLE]);
93 sprintf(print_buf, "%-40s User Name: %s", buf, info[U_NAME]);
94 Put_message(print_buf);
97 /* Function Name: PrintUserInfo
98 * Description: Prints Information about a user.
99 * Arguments: info - an argument list with the user information
104 static void PrintUserInfo(char **info)
106 char name[BUFSIZ], buf[BUFSIZ];
109 sprintf(name, "%s, %s %s", info[U_LAST], info[U_FIRST], info[U_MIDDLE]);
110 sprintf(buf, "Login name: %-20s Full name: %s", info[U_NAME], name);
112 sprintf(buf, "User id: %-23s Login shell: %-10s",
113 info[U_UID], info[U_SHELL]);
115 sprintf(buf, "Class: %-25s Windows Console Shell: %-10s",
116 info[U_CLASS], info[U_WINCONSOLESHELL]);
118 sprintf(buf, "Account is: %-20s MIT ID number: %s",
119 UserState(atoi(info[U_STATE])), info[U_MITID]);
121 status = atoi(info[U_STATE]);
122 if (status == 0 || status == 2)
124 sprintf(buf, "User %s secure Account Coupon to register",
125 atoi(info[U_SECURE]) ? "needs" : "does not need");
128 sprintf(buf, "Comments: %s", info[U_COMMENT]);
130 sprintf(buf, "Created by %s on %s.", info[U_CREATOR], info[U_CREATED]);
132 sprintf(buf, MOD_FORMAT, info[U_MODBY], info[U_MODTIME], info[U_MODWITH]);
136 /* Function Name: SetUserDefaults
137 * Description: Sets the default values for add user.
138 * Arguments: info - a blank user info array of char *'s.
139 * Returns: args - the filled info structure.
142 static char **SetUserDefaults(char **info)
144 info[U_NAME] = strdup(UNIQUE_LOGIN);
145 info[U_UID] = strdup(UNIQUE_UID);
146 info[U_SHELL] = strdup(DEFAULT_SHELL);
147 info[U_WINCONSOLESHELL] = strdup(DEFAULT_WINCONSOLESHELL);
148 info[U_LAST] = strdup(DEFAULT_NONE);
149 info[U_FIRST] = strdup(DEFAULT_NONE);
150 info[U_MIDDLE] = strdup(DEFAULT_NONE);
151 info[U_STATE] = strdup(DEFAULT_NO);
152 info[U_MITID] = strdup(DEFAULT_NONE);
153 info[U_CLASS] = strdup(DEFAULT_CLASS);
154 info[U_COMMENT] = strdup("");
155 info[U_SIGNATURE] = strdup("");
156 info[U_SECURE] = strdup("0");
157 info[U_MODTIME] = info[U_MODBY] = info[U_MODWITH] = info[U_END] = NULL;
158 info[U_CREATED] = info[U_CREATOR] = NULL;
163 /* Check that the supplied name follows the capitalization rules, and
164 * offer to correct it if not.
167 void CorrectCapitalization(char **name)
169 char temp_buf[BUFSIZ], fixname[BUFSIZ];
171 strcpy(fixname, *name);
173 if (strcmp(fixname, *name))
175 Put_message("You entered a name which does not follow the capitalization conventions.");
176 sprintf(temp_buf, "Correct it to \"%s\"", fixname);
177 if (YesNoQuestion(temp_buf, 0) == TRUE)
180 *name = strdup(fixname);
186 /* Function Name: AskUserInfo.
187 * Description: This function askes the user for information about a
188 * machine and saves it into a structure.
189 * Arguments: info - a pointer the the structure to put the info into.
190 * flags - Flags asking us which info we want.
191 * Returns: the args to pass to the query.
192 * NOTES: the return args are not necessarily in the correct order to
193 * use the #defined names (e.g args[UID] is not the uid anymore).
196 char **AskUserInfo(char **info, Bool name)
199 char temp_buf[BUFSIZ], *newname;
203 sprintf(temp_buf, "\nChanging Attributes of user %s.\n", info[U_NAME]);
204 Put_message(temp_buf);
208 struct mqelem *elem = NULL;
211 if (GetValueFromUser("User's last name", &info[U_LAST]) == SUB_ERROR)
213 CorrectCapitalization(&info[U_LAST]);
214 if (GetValueFromUser("User's first name", &info[U_FIRST]) == SUB_ERROR)
216 CorrectCapitalization(&info[U_FIRST]);
217 if (GetValueFromUser("User's middle name", &info[U_MIDDLE]) == SUB_ERROR)
219 CorrectCapitalization(&info[U_MIDDLE]);
220 argv[0] = info[U_FIRST];
221 argv[1] = info[U_LAST];
222 if (do_mr_query("get_user_account_by_name", 2, argv,
223 StoreInfo, &elem) == MR_SUCCESS)
225 Put_message("A user by that name already exists in the database.");
226 Loop(QueueTop(elem), PrintUserInfo);
227 Loop(QueueTop(elem), FreeInfo);
229 if (YesNoQuestion("Add new user anyway", TRUE) != TRUE)
235 newname = strdup(info[U_NAME]);
236 if (GetValueFromUser("The new login name for this user", &newname) ==
240 else if (GetValueFromUser("Login name for this user", &info[U_NAME]) ==
244 strcpy(temp_buf, info[U_UID]);
245 if (GetValueFromUser("User's UID", &info[U_UID]) == SUB_ERROR)
247 if (strcmp(info[U_UID], UNIQUE_UID) && strcmp(info[U_UID], temp_buf))
249 struct mqelem *elem = NULL;
250 if (do_mr_query("get_user_account_by_uid", 1, &info[U_UID],
251 StoreInfo, &elem) == MR_SUCCESS)
253 Put_message("A user with that uid already exists in the database.");
254 Loop(QueueTop(elem), PrintUserInfo);
255 Loop(QueueTop(elem), FreeInfo);
257 if (YesNoQuestion("Add new user anyway", TRUE) != TRUE)
262 if (GetValueFromUser("User's shell", &info[U_SHELL]) == SUB_ERROR)
264 if (GetValueFromUser("Windows console shell", &info[U_WINCONSOLESHELL])
269 if (GetValueFromUser("User's last name", &info[U_LAST]) == SUB_ERROR)
271 CorrectCapitalization(&info[U_LAST]);
272 if (GetValueFromUser("User's first name", &info[U_FIRST]) == SUB_ERROR)
274 CorrectCapitalization(&info[U_FIRST]);
275 if (GetValueFromUser("User's middle name", &info[U_MIDDLE]) == SUB_ERROR)
277 CorrectCapitalization(&info[U_MIDDLE]);
282 if (GetValueFromUser("User's status (? for help)", &info[U_STATE]) ==
285 if (isdigit(info[U_STATE][0]))
287 Put_message("Valid status numbers:");
288 for (i = 0; i < US_END; i++)
290 sprintf(temp_buf, " %d: %s", i, states[i]);
291 Put_message(temp_buf);
294 if (GetValueFromUser("User's MIT ID number", &info[U_MITID]) == SUB_ERROR)
296 RemoveHyphens(info[U_MITID]);
297 if (GetTypeFromUser("User's MIT Year (class)", "class", &info[U_CLASS]) ==
300 if (GetValueFromUser("Comments", &info[U_COMMENT]) == SUB_ERROR)
303 state = atoi(info[U_STATE]);
304 if (!name || state == 0 || state == 2)
306 if (YesNoQuestion("User needs secure Account Coupon to register",
307 atoi(info[U_SECURE]) ? TRUE : FALSE) == FALSE)
309 free(info[U_SECURE]);
310 info[U_SECURE] = strdup("0");
314 free(info[U_SECURE]);
315 info[U_SECURE] = strdup("1");
319 info[U_SIGNATURE] = strdup("");
321 FreeAndClear(&info[U_MODTIME], TRUE);
322 FreeAndClear(&info[U_MODBY], TRUE);
323 FreeAndClear(&info[U_MODWITH], TRUE);
326 * Slide the newname into the #2 slot, this screws up all future references
327 * to this list, since we slip the pointer into a info list it gets freed
328 * when the rest of the list gets freed.
331 SlipInNewName(info, newname);
336 /* Function Name: GetUserInfo
337 * Description: Stores the user information in a queue.
338 * Arguments: type - type of field given to get info, one of:
339 * LOGIN, UID, BY_NAME, CLASS.
340 * name1 - name of thing specified by type (wildcards okay)
341 * name2 - other name, only used in get user by first and last.
343 * Returns: the first element of the queue containing the user info.
347 struct mqelem *GetUserInfo(int type, char *name1, char *name2)
351 struct mqelem *elem = NULL;
357 if ((status = do_mr_query("get_user_account_by_login", 1, args,
360 com_err(program_name, status,
361 " when attempting to get_user_account_by_login.");
367 if ((status = do_mr_query("get_user_account_by_uid", 1, args,
370 com_err(program_name, status,
371 " when attempting to get_user_account_by_uid.");
378 if ((status = do_mr_query("get_user_account_by_name", 2, args,
381 com_err(program_name, status,
382 " when attempting to get_user_account_by_name.");
388 if ((status = do_mr_query("get_user_account_by_class", 1, args,
391 com_err(program_name, status,
392 " when attempting to get_user_account_by_class.");
398 if ((status = do_mr_query("get_user_account_by_id", 1, args,
401 com_err(program_name, status,
402 " when attempting to get_user_account_by_id.");
407 return QueueTop(elem) ;
410 /* Function Name: AddNewUser
411 * Description: Adds a new user to the database.
413 * Returns: DM_NORMAL.
416 int AddNewUser(int argc, char **argv)
419 char **args, *info[MAX_ARGS_SIZE];
421 if (!(args = AskUserInfo(SetUserDefaults(info), FALSE)))
423 Put_message("Aborted.");
426 if ((status = do_mr_query("add_user_account", CountArgs(args),
428 com_err(program_name, status, " in add_user_account");
430 Put_message("New user added to database.");
436 /* Function Name: GetLoginName
437 * Description: Asks the user for a login name and reserves
440 * Returns: a malloced login name for the user.
443 static char *GetLoginName(void)
448 if (GetValueFromUser("Login name for this user? ", &name) == SUB_ERROR)
450 Put_message("KERBEROS code not added, did not reserve name with kerberos.");
455 /* Function Name: ChooseUser
456 * Description: Choose a user from a list and return the uid.
457 * Arguments: top - a queue of user information.
458 * Returns: uid - the malloced uid of the user that was chosen.
461 static char *ChooseUser(struct mqelem *elem)
465 char **info = elem->q_data;
467 switch (YesNoQuitQuestion("Is this the user you want (y/n/q)", FALSE))
470 return strdup(info[U_UID]);
473 default: /* quit or ^C. */
481 /* Function Name: GetUidNumberFromName
482 * Description: Gets the users uid number, from the name.
484 * Returns: uid - a malloced string containing the uid.
487 static char *GetUidNumberFromName(void)
489 char *args[5], *uid, first[BUFSIZ], last[BUFSIZ];
491 struct mqelem *top = NULL;
493 if (!Prompt_input("First Name: ", first, BUFSIZ))
495 if (!Prompt_input("Last Name: ", last, BUFSIZ))
503 switch ((status = do_mr_query("get_user_account_by_name", 2, args,
509 Put_message("There is no user in the database with that name.");
512 com_err(program_name, status, " in get_account_user_by_name.");
517 if (QueueCount(top) == 1) /* This is a unique name. */
519 char **info = top->q_data;
520 Put_message("User ID Number retrieved for the user: ");
523 uid = strdup(info[U_UID]);
528 Put_message("That name is not unique, choose the user that you want.");
529 uid = ChooseUser(top);
534 /* Function Name: SetUserPassword
535 * Description: Set the new kerberos password for this user.
536 * Arguments: name - kerberos principle name for this user, (login name).
540 static void SetUserPassword(char *name)
542 name = name; /* make saber happy. */
543 Put_message("Kerberos password not changed, code non-existant.");
544 /* clever message to call account_admin, if this fails. */
547 /* Function Name: GiveBackLogin
548 * Description: Gives back previously reserved kerberous principle.
549 * Arguments: name - principle to give back.
553 static void GiveBackLogin(char *name)
555 name = name; /* make saber happy. */
556 Put_message("kerberos code not implemented, name not given back.");
557 /* send mail to db maintainer if this fails. */
560 /* Function Name: RegisterUser
561 * Description: This function registers a user.
563 * Returns: DM_NORMAL.
566 int RegisterUser(int argc, char **argv)
568 char *args[MAX_ARGS_SIZE];
569 char *login, *potype = NULL;
570 char temp_buf[BUFSIZ];
573 for (i = 0; i < MAX_ARGS_SIZE; i++)
576 Put_message("This function has NO kerberos support, so strange things");
577 Put_message("may happen if you use it to register a user.");
579 switch (YesNoQuestion("Do you know the users UID Number (y/n)", FALSE))
582 Prompt_input("What is the UID number of the user? ", temp_buf, BUFSIZ);
583 args[0] = strdup(temp_buf);
586 if (!(args[0] = GetUidNumberFromName()))
593 sprintf(temp_buf, "u%s", args[0]);
594 login = strdup(temp_buf);
595 if (GetValueFromUser("Login name for this user? ", &login) == SUB_ERROR)
598 FreeInfo(args); /* This work because the NULL temination is ok. */
601 Put_message("KERBEROS code not added, did not reserve name with kerberos.");
604 sprintf(temp_buf, "IMAP");
605 potype = strdup(temp_buf);
606 if (GetValueFromUser("P.O. Box Type for this user? ", &potype) == SUB_ERROR)
612 if (strcmp(potype, "POP") && strcmp(potype, "IMAP"))
614 sprintf(temp_buf, "Unknown P.O. Box type.");
615 Put_message(temp_buf);
622 switch ((status = do_mr_query("register_user", CountArgs(args),
626 sprintf(temp_buf, "User %s successfully registered.", login);
627 Put_message(temp_buf);
628 SetUserPassword(login);
631 GiveBackLogin(login);
632 sprintf(temp_buf, "The username %s is already in use.", login);
633 Put_message(temp_buf);
636 com_err(program_name, status, " in register_user");
643 /* Function Name: RealUpdateUser
644 * Description: actuall updates the user information.
645 * Arguments: info - all current information for the user fields.
646 * junk - an UNUSED boolean.
650 static void RealUpdateUser(char **info, Bool junk)
653 char error_buf[BUFSIZ];
654 char **args = AskUserInfo(info, TRUE);
658 Put_message("Aborted.");
661 if ((status = do_mr_query("update_user_account", CountArgs(args),
664 com_err(program_name, status, " in ModifyFields");
665 sprintf(error_buf, "User %s not updated due to errors.", info[NAME]);
666 Put_message(error_buf);
670 /* Function Name: UpdateUser
671 * Description: Modify some of the information about a user.
672 * Arguments: argc, argv - login name of the user in argv[1].
673 * Returns: DM_NORMAL.
676 int UpdateUser(int argc, char **argv)
680 elem = GetUserInfo(LOGIN, argv[1], NULL);
681 QueryLoop(elem, NullPrint, RealUpdateUser, "Update the user");
687 /* Function Name: RealDeactivateUser
688 * Description: sets the user's status to 3.
689 * Arguments: info - all current information for the user fields
690 * one_item - indicates the user hasn't been queried yet
694 static void RealDeactivateUser(char **info, Bool one_item)
697 char txt_buf[BUFSIZ];
698 char *qargs[2], **args;
699 struct mqelem *elem = NULL;
703 sprintf(txt_buf, "Deactivate user %s (y/n)", info[NAME]);
704 if (YesNoQuestion(txt_buf, FALSE) != TRUE)
708 qargs[0] = info[NAME];
710 if ((status = do_mr_query("update_user_status", 2, qargs, NULL, NULL)))
712 com_err(program_name, status, " in update_user_status");
713 sprintf(txt_buf, "User %s not deactivated due to errors.", info[NAME]);
714 Put_message(txt_buf);
716 else if (YesNoQuestion("Also deactivate matching list and filesystem (y/n)",
719 status = do_mr_query("get_list_info", 1, &(info[NAME]), StoreInfo,
721 if (status == MR_SUCCESS)
723 args = QueueTop(elem)->q_data;
724 free(args[L_ACTIVE]);
725 args[L_ACTIVE] = strdup("0");
726 FreeAndClear(&args[L_MODTIME], TRUE);
727 FreeAndClear(&args[L_MODBY], TRUE);
728 FreeAndClear(&args[L_MODWITH], TRUE);
729 SlipInNewName(args, strdup(args[L_NAME]));
730 if ((status = do_mr_query("update_list", CountArgs(args), args,
733 com_err(program_name, status, " updating list, "
734 "not deactivating list or filesystem");
743 else if (status != MR_NO_MATCH)
745 com_err(program_name, status, " getting list info, "
746 "not deactivating list or filesystem");
750 if ((status = do_mr_query("get_filesys_by_label", 1, &(info[NAME]),
753 com_err(program_name, status, " getting filsys info, "
754 "not deactivating filesystem");
757 args = QueueTop(elem)->q_data;
759 args[FS_TYPE] = strdup("ERR");
760 free(args[FS_COMMENTS]);
761 args[FS_COMMENTS] = strdup("Locker disabled; call 3-1325 for help");
762 FreeAndClear(&args[FS_MODTIME], TRUE);
763 FreeAndClear(&args[FS_MODBY], TRUE);
764 FreeAndClear(&args[FS_MODWITH], TRUE);
765 SlipInNewName(args, strdup(args[FS_NAME]));
766 if ((status = do_mr_query("update_filesys", CountArgs(args), args,
769 com_err(program_name, status, " updating filesystem, "
770 "not deactivating filesystem");
781 /* Function Name: DeactivateUser
782 * Description: sets the user's status to 3.
783 * Arguments: argc, argv - login name of the user in argv[1].
784 * Returns: DM_NORMAL.
787 int DeactivateUser(int argc, char **argv)
791 elem = GetUserInfo(LOGIN, argv[1], NULL);
792 QueryLoop(elem, NullPrint, RealDeactivateUser, "Deactivate user");
799 /* ------------------------- Top Menu ------------------------- */
801 /* DeleteUser() in delete.c */
803 /* Function Name: DeleteUserByUid
804 * Description: Deletes the user given a uid number.
805 * Arguments: argc, argv - uid if user in argv[1].
806 * Returns: DM_NORMAL.
807 * NOTES: This just gets the username from the mr server
808 * and performs a DeleteUser().
811 int DeleteUserByUid(int argc, char **argv)
814 struct mqelem *elem = NULL;
817 if (!ValidName(argv[1]))
820 if ((status = do_mr_query("get_user_account_by_uid", 1, argv + 1, StoreInfo,
822 com_err(program_name, status, " in get_user_account_by_uid");
825 argv[1] = info[U_NAME];
827 DeleteUser(argc, argv);
831 /* ------------------------- Show User Information ------------------------- */
833 /* Function Name: ShowUserByLogin
834 * Description: Shows user information given a login name.
835 * Arguments: argc, argv - login name in argv[1].
839 int ShowUserByLogin(int argc, char *argv[])
841 struct mqelem *top, *elem;
843 elem = top = GetUserInfo(LOGIN, argv[1], NULL);
844 Loop(elem, PrintUserInfo);
850 /* Function Name: RetrieveUserByName
851 * Description: Show information on a user give fist and/or last name.
852 * Arguments: argc, argv - argv[1] - first name.
853 * argv[2] - last name.
854 * Returns: DM_NORMAL.
857 int ShowUserByName(int argc, char *argv[])
862 top = GetUserInfo(BY_NAME, argv[1], argv[2]);
864 if (!top) /* if there was an error then return. */
867 if (!PromptWithDefault("Print full information, or just the names (f/n)?",
875 Loop(top, PrintUserInfo);
879 Loop(top, PrintUserName);
887 /* Function Name: ShowUserByClass
888 * Description: Shows real and login names of all users in class.
889 * Arguments: argc, argv - argv[1] contains the class.
893 int ShowUserByClass(int argc, char **argv)
897 if (YesNoQuestion("This will take a long time. Are you sure", 0) == FALSE)
899 top = GetUserInfo(CLASS, argv[1], NULL);
900 Loop(top, PrintUserName);
907 /* Function Name: ShowUserById
908 * Description: Shows user information given an ID number.
909 * Arguments: argc, argv - ID number in argv[1].
913 int ShowUserById(int argc, char *argv[])
915 struct mqelem *top, *elem;
917 elem = top = GetUserInfo(ID, argv[1], NULL);
918 Loop(elem, PrintUserInfo);
925 /* Function Name: GetKrbmap
926 * Description: Shows user <-> Kerberos mappings
927 * Arguments: argc, argv - argv[1] contains the user login name,
928 * argv[2] contains the principal
932 int GetKrbmap(int argc, char **argv)
935 struct mqelem *elem = NULL, *top;
938 if ((stat = do_mr_query("get_kerberos_user_map", 2, &argv[1],
941 com_err(program_name, stat, " in GetKrbMap.");
945 top = elem = QueueTop(elem);
949 char **info = elem->q_data;
950 sprintf(buf, "User: %-9s Principal: %s",
951 info[KMAP_USER], info[KMAP_PRINCIPAL]);
956 FreeQueue(QueueTop(top));
961 /* Function Name: AddKrbmap
962 * Description: Add a new user <-> Kerberos mapping
963 * Arguments: argc, argv - argv[1] contains the user login name,
964 * argv[2] contains the principal
968 int AddKrbmap(int argc, char **argv)
972 if (!strchr(argv[KMAP_PRINCIPAL + 1], '@'))
974 Put_message("Please specify a realm for the kerberos principal.");
977 if ((stat = do_mr_query("add_kerberos_user_map", 2, &argv[1],
980 com_err(program_name, stat, " in AddKrbMap.");
981 if (stat == MR_EXISTS)
982 Put_message("No user or principal may have more than one mapping.");
988 /* Function Name: DeleteKrbmap
989 * Description: Remove a user <-> Kerberos mapping
990 * Arguments: argc, argv - argv[1] contains the user login name,
991 * argv[2] contains the principal
995 int DeleteKrbmap(int argc, char **argv)
999 if ((stat = do_mr_query("delete_kerberos_user_map", 2, &argv[1],
1001 com_err(program_name, stat, " in DeleteKrbMap.");
1005 int GetUserReservations(int argc, char **argv)
1008 struct mqelem *elem = NULL, *top;
1011 if ((stat = do_mr_query("get_user_reservations", 1, &argv[1],
1014 com_err(program_name, stat, " in GetUserReservations.");
1018 top = elem = QueueTop(elem);
1021 Put_message("No reservations for that user.");
1024 char **info = elem->q_data;
1025 sprintf(buf, "Reservation: %s", info[0]);
1027 elem = elem->q_forw;
1030 FreeQueue(QueueTop(top));
1034 int AddUserReservation(int argc, char **argv)
1039 switch (stat = do_mr_query("add_user_reservation", 2, &argv[1],
1045 sprintf(buf, "The reservation %s is not valid.", argv[2]);
1047 PrintReservationTypes();
1050 com_err(program_name, stat, " in AddUserReservation.");
1057 int DelUserReservation(int argc, char **argv)
1062 switch (stat = do_mr_query("delete_user_reservation", 2, &argv[1],
1068 sprintf(buf, "The reservation %s is not valid.", argv[2]);
1070 PrintReservationTypes();
1073 com_err(program_name, stat, " in DelUserReservation.");
1080 int GetUserByReservation(int argc, char **argv)
1083 struct mqelem *elem = NULL, *top;
1086 switch (stat = do_mr_query("get_user_by_reservation", 1, &argv[1],
1092 sprintf(buf, "The reservation %s is not valid.", argv[1]);
1094 PrintReservationTypes();
1097 com_err(program_name, stat, " in GetUserByReservation.");
1101 top = elem = QueueTop(elem);
1105 char **info = elem->q_data;
1106 sprintf(buf, "User: %s", info[0]);
1108 elem = elem->q_forw;
1111 FreeQueue(QueueTop(top));
1115 void PrintReservationTypes(void)
1118 struct mqelem *elem = NULL, *top;
1122 Put_message("Valid types of reservations are: ");
1125 qargs[1] = "RESERVE";
1127 if ((stat = do_mr_query("get_alias", 3, &qargs[0],
1130 com_err(program_name, stat, "in PrintReservationTypes.");
1132 top = elem = QueueTop(elem);
1135 char **info = elem->q_data;
1136 sprintf(buf, "%s", info[2]);
1138 elem = elem->q_forw;
1141 FreeQueue(QueueTop(top));