int main_loop(Goods **m_t, pall **m_p){ printf("\n\n========Warehouse1337 v1.0========\n"); printf("Choose what action to perform;\n"); printf("(A)dd an item.\n"); printf("(R)emove an item.\n"); printf("(L)ist all the items currently in the warehouse.\n"); printf("(E)dit an item in the warehouse.\n"); printf("(P)ut something in basket\n"); printf("E(x)it the program.\n"); char action; scanf("%s", &action); if (action == 'a' || action == 'A'){ add_action(m_t); return main_loop(m_t, m_p); } if (action == 'r' || action == 'R'){ puts("You've chosen to Remove an item. To proceed, please;"); remove_action(m_t); return main_loop(m_t, m_p); } if (action == 'l' || action == 'L'){ list_action(*m_t, 1); return main_loop(m_t, m_p); } if (action == 'e' || action == 'E'){ edit_action(m_t); return main_loop(m_t, m_p); } if (action == 'p' || action == 'P'){ pal_action(m_t, m_p); return main_loop(m_t, m_p); } if ((action == 'x' || action == 'X') && (quit_action() == false)){ printf("Thank you for using the warehouse1337 v1.2 software.\n"); free_loop(*m_t); free_loop_pall(*m_p); return 0; } else { puts("\nThat's not a valid option, please try again."); return main_loop(m_t, m_p); } return 0; }
int main(int argc, char** argv) { cmdline_t options; exittype_t exit_type; parser_t* ctx = NULL; bool_t success = 0; // Parse the command line. fetchdeps_cmdline_init(&options, argc, argv); exit_type = fetchdeps_cmdline_parse(&options); if (exit_type == EXIT_FAIL) goto failure; if (exit_type == EXIT_OK) { fetchdeps_cmdline_cleanup(&options); exit(0); } // If no fname was given try to find the default deps file. if (!options.fname) options.fname = fetchdeps_filesys_default_deps_file(); if (!options.fname) { fetchdeps_errors_set(ERR_NO_DEPS); goto failure; } switch (options.action) { case ACTION_HELP: success = help_action(&options); break; case ACTION_INIT: success = init_action(&options); break; case ACTION_GET: success = get_action(&options); break; case ACTION_LIST: success = list_action(&options); break; case ACTION_INSTALL: success = install_action(&options); break; case ACTION_UNINSTALL: success = uninstall_action(&options); break; case ACTION_DELETE: success = delete_action(&options); break; case ACTION_VARS: success = vars_action(&options); break; default: success = 0; break; } if (!success) goto failure; // Clean up. fetchdeps_cmdline_cleanup(&options); return 0; failure: fetchdeps_errors_print(stderr); fetchdeps_cmdline_cleanup(&options); if (ctx) fetchdeps_parser_free(ctx); return 1; }