Пример #1
0
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;
}
Пример #2
0
static void
free_stmt(PLpgSQL_stmt *stmt)
{
	switch ((enum PLpgSQL_stmt_types) stmt->cmd_type)
	{
		case PLPGSQL_STMT_BLOCK:
			free_block((PLpgSQL_stmt_block *) stmt);
			break;
		case PLPGSQL_STMT_ASSIGN:
			free_assign((PLpgSQL_stmt_assign *) stmt);
			break;
		case PLPGSQL_STMT_IF:
			free_if((PLpgSQL_stmt_if *) stmt);
			break;
		case PLPGSQL_STMT_CASE:
			free_case((PLpgSQL_stmt_case *) stmt);
			break;
		case PLPGSQL_STMT_LOOP:
			free_loop((PLpgSQL_stmt_loop *) stmt);
			break;
		case PLPGSQL_STMT_WHILE:
			free_while((PLpgSQL_stmt_while *) stmt);
			break;
		case PLPGSQL_STMT_FORI:
			free_fori((PLpgSQL_stmt_fori *) stmt);
			break;
		case PLPGSQL_STMT_FORS:
			free_fors((PLpgSQL_stmt_fors *) stmt);
			break;
		case PLPGSQL_STMT_FORC:
			free_forc((PLpgSQL_stmt_forc *) stmt);
			break;
		case PLPGSQL_STMT_FOREACH_A:
			free_foreach_a((PLpgSQL_stmt_foreach_a *) stmt);
			break;
		case PLPGSQL_STMT_EXIT:
			free_exit((PLpgSQL_stmt_exit *) stmt);
			break;
		case PLPGSQL_STMT_RETURN:
			free_return((PLpgSQL_stmt_return *) stmt);
			break;
		case PLPGSQL_STMT_RETURN_NEXT:
			free_return_next((PLpgSQL_stmt_return_next *) stmt);
			break;
		case PLPGSQL_STMT_RETURN_QUERY:
			free_return_query((PLpgSQL_stmt_return_query *) stmt);
			break;
		case PLPGSQL_STMT_RAISE:
			free_raise((PLpgSQL_stmt_raise *) stmt);
			break;
		case PLPGSQL_STMT_ASSERT:
			free_assert((PLpgSQL_stmt_assert *) stmt);
			break;
		case PLPGSQL_STMT_EXECSQL:
			free_execsql((PLpgSQL_stmt_execsql *) stmt);
			break;
		case PLPGSQL_STMT_DYNEXECUTE:
			free_dynexecute((PLpgSQL_stmt_dynexecute *) stmt);
			break;
		case PLPGSQL_STMT_DYNFORS:
			free_dynfors((PLpgSQL_stmt_dynfors *) stmt);
			break;
		case PLPGSQL_STMT_GETDIAG:
			free_getdiag((PLpgSQL_stmt_getdiag *) stmt);
			break;
		case PLPGSQL_STMT_OPEN:
			free_open((PLpgSQL_stmt_open *) stmt);
			break;
		case PLPGSQL_STMT_FETCH:
			free_fetch((PLpgSQL_stmt_fetch *) stmt);
			break;
		case PLPGSQL_STMT_CLOSE:
			free_close((PLpgSQL_stmt_close *) stmt);
			break;
		case PLPGSQL_STMT_PERFORM:
			free_perform((PLpgSQL_stmt_perform *) stmt);
			break;
		default:
			elog(ERROR, "unrecognized cmd_type: %d", stmt->cmd_type);
			break;
	}
}