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)",
68 static char *UserState(int state)
70 static char buf[BUFSIZ];
72 if (state < 0 || state >= US_END)
74 sprintf(buf, "Unknown (%d)", state);
81 /* Function Name: PrintUserName
82 * Description: Print name of a user.
83 * Arguments: info - the information about a user.
87 static void PrintUserName(char **info)
89 char buf[BUFSIZ], print_buf[BUFSIZ];
90 sprintf(buf, "%s, %s %s", info[U_LAST], info[U_FIRST], info[U_MIDDLE]);
91 sprintf(print_buf, "%-40s User Name: %s", buf, info[U_NAME]);
92 Put_message(print_buf);
95 /* Function Name: PrintUserInfo
96 * Description: Prints Information about a user.
97 * Arguments: info - an argument list with the user information
102 static void PrintUserInfo(char **info)
104 char name[BUFSIZ], buf[BUFSIZ];
107 sprintf(name, "%s, %s %s", info[U_LAST], info[U_FIRST], info[U_MIDDLE]);
108 sprintf(buf, "Login name: %-20s Full name: %s", info[U_NAME], name);
110 sprintf(buf, "User id: %-23s Login shell: %-10s",
111 info[U_UID], info[U_SHELL]);
113 sprintf(buf, "Class: %-25s Windows Console Shell: %-10s",
114 info[U_CLASS], info[U_WINCONSOLESHELL]);
116 sprintf(buf, "Account is: %-20s MIT ID number: %s",
117 UserState(atoi(info[U_STATE])), info[U_MITID]);
119 status = atoi(info[U_STATE]);
120 if (status == 0 || status == 2)
122 sprintf(buf, "User %s secure Account Coupon to register",
123 atoi(info[U_SECURE]) ? "needs" : "does not need");
126 sprintf(buf, "Comments: %s", info[U_COMMENT]);
128 sprintf(buf, "Created by %s on %s.", info[U_CREATOR], info[U_CREATED]);
130 sprintf(buf, MOD_FORMAT, info[U_MODBY], info[U_MODTIME], info[U_MODWITH]);
134 /* Function Name: SetUserDefaults
135 * Description: Sets the default values for add user.
136 * Arguments: info - a blank user info array of char *'s.
137 * Returns: args - the filled info structure.
140 static char **SetUserDefaults(char **info)
142 info[U_NAME] = strdup(UNIQUE_LOGIN);
143 info[U_UID] = strdup(UNIQUE_UID);
144 info[U_SHELL] = strdup(DEFAULT_SHELL);
145 info[U_WINCONSOLESHELL] = strdup(DEFAULT_WINCONSOLESHELL);
146 info[U_LAST] = strdup(DEFAULT_NONE);
147 info[U_FIRST] = strdup(DEFAULT_NONE);
148 info[U_MIDDLE] = strdup(DEFAULT_NONE);
149 info[U_STATE] = strdup(DEFAULT_NO);
150 info[U_MITID] = strdup(DEFAULT_NONE);
151 info[U_CLASS] = strdup(DEFAULT_CLASS);
152 info[U_COMMENT] = strdup("");
153 info[U_SIGNATURE] = strdup("");
154 info[U_SECURE] = strdup("0");
155 info[U_MODTIME] = info[U_MODBY] = info[U_MODWITH] = info[U_END] = NULL;
156 info[U_CREATED] = info[U_CREATOR] = NULL;
161 /* Check that the supplied name follows the capitalization rules, and
162 * offer to correct it if not.
165 void CorrectCapitalization(char **name)
167 char temp_buf[BUFSIZ], fixname[BUFSIZ];
169 strcpy(fixname, *name);
171 if (strcmp(fixname, *name))
173 Put_message("You entered a name which does not follow the capitalization conventions.");
174 sprintf(temp_buf, "Correct it to \"%s\"", fixname);
175 if (YesNoQuestion(temp_buf, 0) == TRUE)
178 *name = strdup(fixname);
184 /* Function Name: AskUserInfo.
185 * Description: This function askes the user for information about a
186 * machine and saves it into a structure.
187 * Arguments: info - a pointer the the structure to put the info into.
188 * flags - Flags asking us which info we want.
189 * Returns: the args to pass to the query.
190 * NOTES: the return args are not necessarily in the correct order to
191 * use the #defined names (e.g args[UID] is not the uid anymore).
194 char **AskUserInfo(char **info, Bool name)
197 char temp_buf[BUFSIZ], *newname;
201 sprintf(temp_buf, "\nChanging Attributes of user %s.\n", info[U_NAME]);
202 Put_message(temp_buf);
206 struct mqelem *elem = NULL;
209 if (GetValueFromUser("User's last name", &info[U_LAST]) == SUB_ERROR)
211 CorrectCapitalization(&info[U_LAST]);
212 if (GetValueFromUser("User's first name", &info[U_FIRST]) == SUB_ERROR)
214 CorrectCapitalization(&info[U_FIRST]);
215 if (GetValueFromUser("User's middle name", &info[U_MIDDLE]) == SUB_ERROR)
217 CorrectCapitalization(&info[U_MIDDLE]);
218 argv[0] = info[U_FIRST];
219 argv[1] = info[U_LAST];
220 if (do_mr_query("get_user_account_by_name", 2, argv,
221 StoreInfo, &elem) == MR_SUCCESS)
223 Put_message("A user by that name already exists in the database.");
224 Loop(QueueTop(elem), PrintUserInfo);
225 Loop(QueueTop(elem), FreeInfo);
227 if (YesNoQuestion("Add new user anyway", TRUE) != TRUE)
233 newname = strdup(info[U_NAME]);
234 if (GetValueFromUser("The new login name for this user", &newname) ==
238 else if (GetValueFromUser("Login name for this user", &info[U_NAME]) ==
242 strcpy(temp_buf, info[U_UID]);
243 if (GetValueFromUser("User's UID", &info[U_UID]) == SUB_ERROR)
245 if (strcmp(info[U_UID], UNIQUE_UID) && strcmp(info[U_UID], temp_buf))
247 struct mqelem *elem = NULL;
248 if (do_mr_query("get_user_account_by_uid", 1, &info[U_UID],
249 StoreInfo, &elem) == MR_SUCCESS)
251 Put_message("A user with that uid already exists in the database.");
252 Loop(QueueTop(elem), PrintUserInfo);
253 Loop(QueueTop(elem), FreeInfo);
255 if (YesNoQuestion("Add new user anyway", TRUE) != TRUE)
260 if (GetValueFromUser("User's shell", &info[U_SHELL]) == SUB_ERROR)
262 if (GetValueFromUser("Windows console shell", &info[U_WINCONSOLESHELL])
267 if (GetValueFromUser("User's last name", &info[U_LAST]) == SUB_ERROR)
269 CorrectCapitalization(&info[U_LAST]);
270 if (GetValueFromUser("User's first name", &info[U_FIRST]) == SUB_ERROR)
272 CorrectCapitalization(&info[U_FIRST]);
273 if (GetValueFromUser("User's middle name", &info[U_MIDDLE]) == SUB_ERROR)
275 CorrectCapitalization(&info[U_MIDDLE]);
280 if (GetValueFromUser("User's status (? for help)", &info[U_STATE]) ==
283 if (isdigit(info[U_STATE][0]))
285 Put_message("Valid status numbers:");
286 for (i = 0; i < US_END; i++)
288 sprintf(temp_buf, " %d: %s", i, states[i]);
289 Put_message(temp_buf);
292 if (GetValueFromUser("User's MIT ID number", &info[U_MITID]) == SUB_ERROR)
294 RemoveHyphens(info[U_MITID]);
295 if (GetTypeFromUser("User's MIT Year (class)", "class", &info[U_CLASS]) ==
298 if (GetValueFromUser("Comments", &info[U_COMMENT]) == SUB_ERROR)
301 state = atoi(info[U_STATE]);
302 if (!name || state == 0 || state == 2)
304 if (YesNoQuestion("User needs secure Account Coupon to register",
305 atoi(info[U_SECURE]) ? TRUE : FALSE) == FALSE)
307 free(info[U_SECURE]);
308 info[U_SECURE] = strdup("0");
312 free(info[U_SECURE]);
313 info[U_SECURE] = strdup("1");
317 info[U_SIGNATURE] = strdup("");
319 FreeAndClear(&info[U_MODTIME], TRUE);
320 FreeAndClear(&info[U_MODBY], TRUE);
321 FreeAndClear(&info[U_MODWITH], TRUE);
324 * Slide the newname into the #2 slot, this screws up all future references
325 * to this list, since we slip the pointer into a info list it gets freed
326 * when the rest of the list gets freed.
329 SlipInNewName(info, newname);
334 /* Function Name: GetUserInfo
335 * Description: Stores the user information in a queue.
336 * Arguments: type - type of field given to get info, one of:
337 * LOGIN, UID, BY_NAME, CLASS.
338 * name1 - name of thing specified by type (wildcards okay)
339 * name2 - other name, only used in get user by first and last.
341 * Returns: the first element of the queue containing the user info.
345 struct mqelem *GetUserInfo(int type, char *name1, char *name2)
349 struct mqelem *elem = NULL;
355 if ((status = do_mr_query("get_user_account_by_login", 1, args,
358 com_err(program_name, status,
359 " when attempting to get_user_account_by_login.");
365 if ((status = do_mr_query("get_user_account_by_uid", 1, args,
368 com_err(program_name, status,
369 " when attempting to get_user_account_by_uid.");
376 if ((status = do_mr_query("get_user_account_by_name", 2, args,
379 com_err(program_name, status,
380 " when attempting to get_user_account_by_name.");
386 if ((status = do_mr_query("get_user_account_by_class", 1, args,
389 com_err(program_name, status,
390 " when attempting to get_user_account_by_class.");
396 if ((status = do_mr_query("get_user_account_by_id", 1, args,
399 com_err(program_name, status,
400 " when attempting to get_user_account_by_id.");
405 return QueueTop(elem) ;
408 /* Function Name: AddNewUser
409 * Description: Adds a new user to the database.
411 * Returns: DM_NORMAL.
414 int AddNewUser(int argc, char **argv)
417 char **args, *info[MAX_ARGS_SIZE];
419 if (!(args = AskUserInfo(SetUserDefaults(info), FALSE)))
421 Put_message("Aborted.");
424 if ((status = do_mr_query("add_user_account", CountArgs(args),
426 com_err(program_name, status, " in add_user_account");
428 Put_message("New user added to database.");
434 /* Function Name: GetLoginName
435 * Description: Asks the user for a login name and reserves
438 * Returns: a malloced login name for the user.
441 static char *GetLoginName(void)
446 if (GetValueFromUser("Login name for this user? ", &name) == SUB_ERROR)
448 Put_message("KERBEROS code not added, did not reserve name with kerberos.");
453 /* Function Name: ChooseUser
454 * Description: Choose a user from a list and return the uid.
455 * Arguments: top - a queue of user information.
456 * Returns: uid - the malloced uid of the user that was chosen.
459 static char *ChooseUser(struct mqelem *elem)
463 char **info = elem->q_data;
465 switch (YesNoQuitQuestion("Is this the user you want (y/n/q)", FALSE))
468 return strdup(info[U_UID]);
471 default: /* quit or ^C. */
479 /* Function Name: GetUidNumberFromName
480 * Description: Gets the users uid number, from the name.
482 * Returns: uid - a malloced string containing the uid.
485 static char *GetUidNumberFromName(void)
487 char *args[5], *uid, first[BUFSIZ], last[BUFSIZ];
489 struct mqelem *top = NULL;
491 if (!Prompt_input("First Name: ", first, BUFSIZ))
493 if (!Prompt_input("Last Name: ", last, BUFSIZ))
501 switch ((status = do_mr_query("get_user_account_by_name", 2, args,
507 Put_message("There is no user in the database with that name.");
510 com_err(program_name, status, " in get_account_user_by_name.");
515 if (QueueCount(top) == 1) /* This is a unique name. */
517 char **info = top->q_data;
518 Put_message("User ID Number retrieved for the user: ");
521 uid = strdup(info[U_UID]);
526 Put_message("That name is not unique, choose the user that you want.");
527 uid = ChooseUser(top);
532 /* Function Name: SetUserPassword
533 * Description: Set the new kerberos password for this user.
534 * Arguments: name - kerberos principle name for this user, (login name).
538 static void SetUserPassword(char *name)
540 name = name; /* make saber happy. */
541 Put_message("Kerberos password not changed, code non-existant.");
542 /* clever message to call account_admin, if this fails. */
545 /* Function Name: GiveBackLogin
546 * Description: Gives back previously reserved kerberous principle.
547 * Arguments: name - principle to give back.
551 static void GiveBackLogin(char *name)
553 name = name; /* make saber happy. */
554 Put_message("kerberos code not implemented, name not given back.");
555 /* send mail to db maintainer if this fails. */
558 /* Function Name: RegisterUser
559 * Description: This function registers a user.
561 * Returns: DM_NORMAL.
564 int RegisterUser(int argc, char **argv)
566 char *args[MAX_ARGS_SIZE];
567 char *login, *potype = NULL;
568 char temp_buf[BUFSIZ];
571 for (i = 0; i < MAX_ARGS_SIZE; i++)
574 Put_message("This function has NO kerberos support, so strange things");
575 Put_message("may happen if you use it to register a user.");
577 switch (YesNoQuestion("Do you know the users UID Number (y/n)", FALSE))
580 Prompt_input("What is the UID number of the user? ", temp_buf, BUFSIZ);
581 args[0] = strdup(temp_buf);
584 if (!(args[0] = GetUidNumberFromName()))
591 sprintf(temp_buf, "u%s", args[0]);
592 login = strdup(temp_buf);
593 if (GetValueFromUser("Login name for this user? ", &login) == SUB_ERROR)
596 FreeInfo(args); /* This work because the NULL temination is ok. */
599 Put_message("KERBEROS code not added, did not reserve name with kerberos.");
602 sprintf(temp_buf, "IMAP");
603 potype = strdup(temp_buf);
604 if (GetValueFromUser("P.O. Box Type for this user? ", &potype) == SUB_ERROR)
610 if (strcmp(potype, "POP") && strcmp(potype, "IMAP"))
612 sprintf(temp_buf, "Unknown P.O. Box type.");
613 Put_message(temp_buf);
620 switch ((status = do_mr_query("register_user", CountArgs(args),
624 sprintf(temp_buf, "User %s successfully registered.", login);
625 Put_message(temp_buf);
626 SetUserPassword(login);
629 GiveBackLogin(login);
630 sprintf(temp_buf, "The username %s is already in use.", login);
631 Put_message(temp_buf);
634 com_err(program_name, status, " in register_user");
641 /* Function Name: RealUpdateUser
642 * Description: actuall updates the user information.
643 * Arguments: info - all current information for the user fields.
644 * junk - an UNUSED boolean.
648 static void RealUpdateUser(char **info, Bool junk)
651 char error_buf[BUFSIZ];
652 char **args = AskUserInfo(info, TRUE);
656 Put_message("Aborted.");
659 if ((status = do_mr_query("update_user_account", CountArgs(args),
662 com_err(program_name, status, " in ModifyFields");
663 sprintf(error_buf, "User %s not updated due to errors.", info[NAME]);
664 Put_message(error_buf);
668 /* Function Name: UpdateUser
669 * Description: Modify some of the information about a user.
670 * Arguments: argc, argv - login name of the user in argv[1].
671 * Returns: DM_NORMAL.
674 int UpdateUser(int argc, char **argv)
678 elem = GetUserInfo(LOGIN, argv[1], NULL);
679 QueryLoop(elem, NullPrint, RealUpdateUser, "Update the user");
685 /* Function Name: RealDeactivateUser
686 * Description: sets the user's status to 3.
687 * Arguments: info - all current information for the user fields
688 * one_item - indicates the user hasn't been queried yet
692 static void RealDeactivateUser(char **info, Bool one_item)
695 char txt_buf[BUFSIZ];
696 char *qargs[2], **args;
697 struct mqelem *elem = NULL;
701 sprintf(txt_buf, "Deactivate user %s (y/n)", info[NAME]);
702 if (YesNoQuestion(txt_buf, FALSE) != TRUE)
706 qargs[0] = info[NAME];
708 if ((status = do_mr_query("update_user_status", 2, qargs, NULL, NULL)))
710 com_err(program_name, status, " in update_user_status");
711 sprintf(txt_buf, "User %s not deactivated due to errors.", info[NAME]);
712 Put_message(txt_buf);
714 else if (YesNoQuestion("Also deactivate matching list and filesystem (y/n)",
717 status = do_mr_query("get_list_info", 1, &(info[NAME]), StoreInfo,
719 if (status == MR_SUCCESS)
721 args = QueueTop(elem)->q_data;
722 free(args[L_ACTIVE]);
723 args[L_ACTIVE] = strdup("0");
724 FreeAndClear(&args[L_MODTIME], TRUE);
725 FreeAndClear(&args[L_MODBY], TRUE);
726 FreeAndClear(&args[L_MODWITH], TRUE);
727 SlipInNewName(args, strdup(args[L_NAME]));
728 if ((status = do_mr_query("update_list", CountArgs(args), args,
731 com_err(program_name, status, " updating list, "
732 "not deactivating list or filesystem");
741 else if (status != MR_NO_MATCH)
743 com_err(program_name, status, " getting list info, "
744 "not deactivating list or filesystem");
748 if ((status = do_mr_query("get_filesys_by_label", 1, &(info[NAME]),
751 com_err(program_name, status, " getting filsys info, "
752 "not deactivating filesystem");
755 args = QueueTop(elem)->q_data;
757 args[FS_TYPE] = strdup("ERR");
758 free(args[FS_COMMENTS]);
759 args[FS_COMMENTS] = strdup("Locker disabled; call 3-1325 for help");
760 FreeAndClear(&args[FS_MODTIME], TRUE);
761 FreeAndClear(&args[FS_MODBY], TRUE);
762 FreeAndClear(&args[FS_MODWITH], TRUE);
763 SlipInNewName(args, strdup(args[FS_NAME]));
764 if ((status = do_mr_query("update_filesys", CountArgs(args), args,
767 com_err(program_name, status, " updating filesystem, "
768 "not deactivating filesystem");
779 /* Function Name: DeactivateUser
780 * Description: sets the user's status to 3.
781 * Arguments: argc, argv - login name of the user in argv[1].
782 * Returns: DM_NORMAL.
785 int DeactivateUser(int argc, char **argv)
789 elem = GetUserInfo(LOGIN, argv[1], NULL);
790 QueryLoop(elem, NullPrint, RealDeactivateUser, "Deactivate user");
797 /* ------------------------- Top Menu ------------------------- */
799 /* DeleteUser() in delete.c */
801 /* Function Name: DeleteUserByUid
802 * Description: Deletes the user given a uid number.
803 * Arguments: argc, argv - uid if user in argv[1].
804 * Returns: DM_NORMAL.
805 * NOTES: This just gets the username from the mr server
806 * and performs a DeleteUser().
809 int DeleteUserByUid(int argc, char **argv)
812 struct mqelem *elem = NULL;
815 if (!ValidName(argv[1]))
818 if ((status = do_mr_query("get_user_account_by_uid", 1, argv + 1, StoreInfo,
820 com_err(program_name, status, " in get_user_account_by_uid");
823 argv[1] = info[U_NAME];
825 DeleteUser(argc, argv);
829 /* ------------------------- Show User Information ------------------------- */
831 /* Function Name: ShowUserByLogin
832 * Description: Shows user information given a login name.
833 * Arguments: argc, argv - login name in argv[1].
837 int ShowUserByLogin(int argc, char *argv[])
839 struct mqelem *top, *elem;
841 elem = top = GetUserInfo(LOGIN, argv[1], NULL);
842 Loop(elem, PrintUserInfo);
848 /* Function Name: RetrieveUserByName
849 * Description: Show information on a user give fist and/or last name.
850 * Arguments: argc, argv - argv[1] - first name.
851 * argv[2] - last name.
852 * Returns: DM_NORMAL.
855 int ShowUserByName(int argc, char *argv[])
860 top = GetUserInfo(BY_NAME, argv[1], argv[2]);
862 if (!top) /* if there was an error then return. */
865 if (!PromptWithDefault("Print full information, or just the names (f/n)?",
873 Loop(top, PrintUserInfo);
877 Loop(top, PrintUserName);
885 /* Function Name: ShowUserByClass
886 * Description: Shows real and login names of all users in class.
887 * Arguments: argc, argv - argv[1] contains the class.
891 int ShowUserByClass(int argc, char **argv)
895 if (YesNoQuestion("This will take a long time. Are you sure", 0) == FALSE)
897 top = GetUserInfo(CLASS, argv[1], NULL);
898 Loop(top, PrintUserName);
905 /* Function Name: ShowUserById
906 * Description: Shows user information given an ID number.
907 * Arguments: argc, argv - ID number in argv[1].
911 int ShowUserById(int argc, char *argv[])
913 struct mqelem *top, *elem;
915 elem = top = GetUserInfo(ID, argv[1], NULL);
916 Loop(elem, PrintUserInfo);
923 /* Function Name: GetKrbmap
924 * Description: Shows user <-> Kerberos mappings
925 * Arguments: argc, argv - argv[1] contains the user login name,
926 * argv[2] contains the principal
930 int GetKrbmap(int argc, char **argv)
933 struct mqelem *elem = NULL, *top;
936 if ((stat = do_mr_query("get_kerberos_user_map", 2, &argv[1],
939 com_err(program_name, stat, " in GetKrbMap.");
943 top = elem = QueueTop(elem);
947 char **info = elem->q_data;
948 sprintf(buf, "User: %-9s Principal: %s",
949 info[KMAP_USER], info[KMAP_PRINCIPAL]);
954 FreeQueue(QueueTop(top));
959 /* Function Name: AddKrbmap
960 * Description: Add a new user <-> Kerberos mapping
961 * Arguments: argc, argv - argv[1] contains the user login name,
962 * argv[2] contains the principal
966 int AddKrbmap(int argc, char **argv)
970 if (!strchr(argv[KMAP_PRINCIPAL + 1], '@'))
972 Put_message("Please specify a realm for the kerberos principal.");
975 if ((stat = do_mr_query("add_kerberos_user_map", 2, &argv[1],
978 com_err(program_name, stat, " in AddKrbMap.");
979 if (stat == MR_EXISTS)
980 Put_message("No user or principal may have more than one mapping.");
986 /* Function Name: DeleteKrbmap
987 * Description: Remove a user <-> Kerberos mapping
988 * Arguments: argc, argv - argv[1] contains the user login name,
989 * argv[2] contains the principal
993 int DeleteKrbmap(int argc, char **argv)
997 if ((stat = do_mr_query("delete_kerberos_user_map", 2, &argv[1],
999 com_err(program_name, stat, " in DeleteKrbMap.");
1003 int GetUserReservations(int argc, char **argv)
1006 struct mqelem *elem = NULL, *top;
1009 if ((stat = do_mr_query("get_user_reservations", 1, &argv[1],
1012 com_err(program_name, stat, " in GetUserReservations.");
1016 top = elem = QueueTop(elem);
1019 Put_message("No reservations for that user.");
1022 char **info = elem->q_data;
1023 sprintf(buf, "Reservation: %s", info[0]);
1025 elem = elem->q_forw;
1028 FreeQueue(QueueTop(top));
1032 int AddUserReservation(int argc, char **argv)
1037 switch (stat = do_mr_query("add_user_reservation", 2, &argv[1],
1043 sprintf(buf, "The reservation %s is not valid.", argv[2]);
1045 PrintReservationTypes();
1048 com_err(program_name, stat, " in AddUserReservation.");
1055 int DelUserReservation(int argc, char **argv)
1060 switch (stat = do_mr_query("delete_user_reservation", 2, &argv[1],
1066 sprintf(buf, "The reservation %s is not valid.", argv[2]);
1068 PrintReservationTypes();
1071 com_err(program_name, stat, " in DelUserReservation.");
1078 int GetUserByReservation(int argc, char **argv)
1081 struct mqelem *elem = NULL, *top;
1084 switch (stat = do_mr_query("get_user_by_reservation", 1, &argv[1],
1090 sprintf(buf, "The reservation %s is not valid.", argv[1]);
1092 PrintReservationTypes();
1095 com_err(program_name, stat, " in GetUserByReservation.");
1099 top = elem = QueueTop(elem);
1103 char **info = elem->q_data;
1104 sprintf(buf, "User: %s", info[0]);
1106 elem = elem->q_forw;
1109 FreeQueue(QueueTop(top));
1113 void PrintReservationTypes(void)
1116 struct mqelem *elem = NULL, *top;
1120 Put_message("Valid types of reservations are: ");
1123 qargs[1] = "RESERVE";
1125 if ((stat = do_mr_query("get_alias", 3, &qargs[0],
1128 com_err(program_name, stat, "in PrintReservationTypes.");
1130 top = elem = QueueTop(elem);
1133 char **info = elem->q_data;
1134 sprintf(buf, "%s", info[2]);
1136 elem = elem->q_forw;
1139 FreeQueue(QueueTop(top));