int admin() { int choice; printf("What function do you want?\n(1)add book\n(2)remove book\n(3)add member\n(4)remove member\n(5)member list\n(6)book list\n(7)exit\n"); scanf("%d",&choice); switch(choice) { case 1: add_book(); break; case 2: remove_book(); break; case 3: add_member(); break; case 4: remove_member(); break; case 5: member_list(); break; case 6: book_list(); break; case 7: exit(0); } return 1; }
/**Function******************************************************************** Synopsis Removes the first book in the list with the given id, or does nothing if there is no book with the given id. SideEffects May remove a book from the list ******************************************************************************/ struct book_node *remove_first_with_id(struct book_node *head, long id) { struct book *to_remove = find_by_id(head, id); if (to_remove != NULL) { return remove_book(head, to_remove); } return NULL; }
//int* adduser(int booknum); //int userexist (); int main() { struct library *library = alloc_library(); if (!library){ printf("Failed to allocate library"); return -1; } char input[80]; char input2[80]; int exit = 0; int ret; int menu; //i=0,booknum=0; while (!exit){ printf("CHOOSE AN OPTION\n"); scanf("%d",&menu); switch (menu) { case 1: scanf("%s", input); ret = add_user(library, input); if (ret < 0){ printf("Failed to allocate memory\n"); exit = 1; break; } if (ret == 1){ printf("ERROR\n"); break; } printf("User added\n"); break; case 2: scanf("%s", input); ret = add_book(library, input); if (ret < 0){ printf("Failed to allocate memory\n"); exit = 1; break; } if (ret == 1){ printf("ERROR\n"); break; } printf("Book added\n"); break; case 3: scanf("%s", input); ret = remove_book(library, input); if (ret == 1){ printf("error\n"); break; } printf("removed\n"); break; case 4: scanf("%s", input); scanf("%s", input2); ret = take_book(library, input, input2); switch (ret){ case -1: printf("Failed to allocate memory\n"); exit = 1; break; case 1: case 2: printf("ERROR\n"); break; case 3: printf("IN USE\n"); break; default: printf("SUCESS\n"); break; } break; case 5: scanf("%s", input); scanf("%s", input2); ret = return_book(library, input, input2); switch (ret){ case 1: case 2: printf("ERROR\n"); break; case 3: printf("NOT IN YOUR USE\n"); break; default: printf("SUCESS\n"); } break; case 6: scanf("%s", input); ret = print_user_info(library, input); if (ret == 1){ printf("ERROR\n"); } break; case 7: exit = 1; printf("BYE\n"); break; } } free_library(library); return 0; }