void Program_Controller::run_program(){
	bool cont = true;

	clear_screen( &Program_Controller::show_title );
	while( !cin.peek() );
	clear_screen( &Program_Controller::show_instructions );
	while(cont){
		int choice;

		clear_screen( &Program_Controller::show_menu );
		choice = get_choice(4);
		if(choice==1){
			cout << endl << endl;
			list.display_all();
			cout << "\n(press return to continue)\n";
			while( !cin.peek() );
		}
		else if(choice==2){
			int schoice;
			int smenu_choice;
			int search_count;
			char sterm[21] = {0};
			cout << "Search looks through name and/or location\n"
					 << "please enter a search term: ";
			cin.get(sterm, 21, '\n');
			cin.ignore(100, '\n');
			list.search_tree(sterm);
			search_count = list.show_search_list(true);
			cout << "\n----------------------------------------------\n"
					 << "1) View Detail\n"
					 << "2) Remove\n"
					 << "3) Return to main" << endl;
			cout << "choice: ";
			schoice = get_choice(3);
			if(schoice==1 || schoice==2){
				cout << "\nwhich: ";
				smenu_choice = get_choice(search_count);
				if(schoice==1){
					list.display_search_item(smenu_choice);
				}
				else if(schoice==2){
					list.delete_search_item(smenu_choice);
				}
				cout << "\n(press return to continue)\n";
				while( !cin.peek() );
			}
		}
		else if(choice==3){
			list.add_new();
			cout << "\n(press return to continue)\n";
			while( !cin.peek() );
		}
		//else if(choice==4);  TODO: implement
		//else if(choice==5);  TODO: implement
		else cont = false;

	}

	list.delete_tree();
}
Beispiel #2
0
int main(int argc, const char *argv[])
{
    V_NODE *head = NULL;
    int flag = 0;
    
    print_test();
    head = load_link();
    while(!flag)
    {
       
        print_list();
        switch(get_choice())
        {
            case 1:
                head = add_link(head);
                break;
            case 2:
                head = delete_link(head);
                break;
            case 3:
                print_link(head);
                break;
            case 4:
                flag = 1 ;
                save_link(head);
                break;
            default :
                break;
        }
    }
    return 0;
}
Beispiel #3
0
Datei: Ex5.c Projekt: marrusian/C
int main(void)
{
   int choice = 0;
   float num1 = 0.0f, num2 = 0.0f;

   menu();
   while((choice=get_choice())!='q' && !feof(stdin)){
      printf("Enter first number: ");
      num1=get_float();
      printf("Enter second number: ");
      if(choice=='d')
         while(!(num2=get_float()))
            printf("Can't divide by zero. Try again: ");
      else
         num2=get_float();
      
      switch(choice){
         case 'a': printf("%.1f + %.1f = %.1f\n", num1, num2, num1+num2);
                   break;
         case 's': printf("%.1f - %.1f = %1.f\n", num1, num2, num1-num2);
                   break;
         case 'm': printf("%.1f * %.1f = %1.f\n", num1, num2, num1*num2);
                   break;
         case 'd': printf("%.1f / %.1f = %1.f\n", num1, num2, num1/num2);
                   break;
         default: printf("Program error!\n"); exit(EXIT_FAILURE);
      }
      menu();
   }

   return 0;
}
void test_type_select(void)
{
	int choice = 0;
	xfer_type_show();

	while((choice = get_choice()) != 'q')
	{
		switch(choice)
		{
			case '1':
				s_xfer_type = 1;
				return;
			case '2':
				s_xfer_type = 2;
				return;
			case '3':
				s_xfer_type = 3;
				return;
			case '4':
				s_xfer_type = 4;
				return;
			case 'h':
				xfer_type_show();
				break;
			case 'q':
				s_xfer_type = 0;
				return;

			default:
				printf("Input errror ch=%x \n", choice);
				break;
		}
	}
	return;
}
void display_info(Course courses[], Student students[],
  int courses_actual, int students_actual)
{
  int choice;

  do
  {
    choice = get_choice();
    switch (choice)
    {
      case 0: break;
      case 1:
        find_CRN(courses, students, courses_actual, students_actual);
        break;
      case 2: find_subject(courses, courses_actual); break;
      case 3:
        add_course(courses, students, courses_actual, students_actual);
        break;
      case 4:
        remove_course(students, students_actual);
        break;
      default:
        printf("Your choice is outside the acceptable range.  "
          "Please try again.\n");
    } // switch (choice)
  } while (choice != 0);
} // display_info()
Beispiel #6
0
int main(void)
{
    int choice;
    void count(void);

    while ((choice = get_choice()) != 'q')
    {
        switch (choice)
        {
            case 'a':
                printf("Buy low, sell high.\n");
                break;
            case 'b':
                putchar('\a');
                break;
            case 'c':
                count();
                break;
            default:
                printf("Program error!\n");
                break;
        }
    }

    printf("Bye.\n");

    return 0;
}
Beispiel #7
0
static int get_choice(lua_State * L) {
    check_choice(L, 1);
    expr const & c = to_expr(L, 1);
    int i = lua_tointeger(L, 2);
    if (i < 0 || static_cast<unsigned>(i) >= get_num_choices(c))
        throw exception("arg #2 is an invalid choice index");
    return push_expr(L, get_choice(c, i));
}
Beispiel #8
0
void *manage_client(void *arg)
{
	int confd = (int)arg;
	
	/*call the funtion destruct client requierment*/
	get_choice(confd);
	
	pthread_exit((void*)0);
}
Beispiel #9
0
bool VM_System::set_buy(){
	if (get_choice() == max_water + 1){
		cout << "감사합니다" << endl;
		return false;
	}
	if (get_choice() == max_water){
		cout << "(" << money << ")" << "잔액이 반환되었습니다." << endl;
		money = 0;
		return true;
	}
	if (money - potable_water[choice] < 0){
		cout << "금액이 부족합니다." << endl;
		return true;
	}
	money -= potable_water[choice];
	system("cls");
	cout << choice << "번 음료 구매하였습니다, 남은 잔액은 " <<money<< "원 입니다."<< endl;
	return true;
}
Beispiel #10
0
int main (int argc, char *argv[])
{
    /*
     * Program header request increments and other data.
     */

    init_scr();
    menu_window();
    disp_menu();
    get_choice();
    quit_prg();

    return 0;

}
Beispiel #11
0
void display_info(char **subjects, char **courses, int *CRNs, int count)
{
    int choice;

    do
    {
        choice = get_choice();

        if(choice == 1)
            find_CRN(subjects, courses, CRNs, count);
        else if(choice == 2)
            find_subject(subjects, courses, CRNs, count);

    } while(choice != 0);

} // display_info()
Beispiel #12
0
int main(int argc, const char *argv[])
{
    int choice;

    while (1)
    {
        //1.display the main menu
        show_menu();
        //2.retrieve the user opition
        choice = get_choice();
        //3.According to the function of the corresponding choice of implementation
        do_choice(choice);

        system("pause>nul");
    }
    return 0;
}
Beispiel #13
0
int main(void)
{
   int choice = 0;

   menu();
   while((choice=get_choice())!='q' && !feof(stdin)){
      switch(choice){
         case 'a': printf("Buy low, sell high.\n"); break;
         case 'b': putchar('\a'); break;
         case 'c': count(); break;
         default: printf("Program error!"); exit(EXIT_FAILURE);
      }
      menu();
   }

   return 0;
}
Beispiel #14
0
int main(void)
{
	char c, action;
	float num1, num2, res;
	action = res = 0;

	printf("The litle calculator.\n");
	while ((c = get_choice()) != 'q') {

		printf("Insert number one:");
		num1 = get_float();
		printf("Insert number two:");
		num2 = get_float();

		switch(c) {
		case 'a':
			action = '+';
			res = num1 + num2;
			break;
		case 's':
			action = '-';
			res = num1 - num2;
			break;
		case 'm':
			action = '*';
			res = num1 * num2;
			break;
		case 'd':
			action = '/';
			while(num2 == 0) {
				printf("Only Chuck Norris can divide by zero.\n");
				printf("Enter another number:");
				num2 = get_float();
			}
			res = num1 / num2;
			break;
		}
		printf("%.2f %c %.2f = %.2f\n", num1, action, num2, res);

	}

	printf("\nGoodbye\n");

	return 0;
}
Beispiel #15
0
list<list<name>> collect_choice_symbols(expr const & e) {
    buffer<list<name>> r;
    for_each(e, [&](expr const & e, unsigned) {
            if (is_choice(e)) {
                buffer<name> cs;
                for (unsigned i = 0; i < get_num_choices(e); i++) {
                    expr const & c = get_app_fn(get_choice(e, i));
                    if (is_constant(c))
                        cs.push_back(const_name(c));
                    else if (is_local(c))
                        cs.push_back(mlocal_pp_name(c));
                }
                if (cs.size() > 1)
                    r.push_back(to_list(cs));
            }
            return true;
        });
    return to_list(r);
}
Beispiel #16
0
static void handle_init()
{
    fputs("\n================== START ==========================\n\n", stdout);
    fputs("Welcome to the Railway Ticket System, YOU CAN CHOOSE THE FOLLOWING OPTIONS:\n", stdout);
    fputs("    1. LOG IN\n", stdout);
    fputs("    2. REGISTER\n", stdout);
    fputs("    3. EXIT\n", stdout);
    char c = get_choice();
    switch(c){
         case '1':
            status = S_LOGIN;
            break;
         case '2':
            status = S_REGISTER;
            break;
        case '3':
            status = S_EXIT;
            break;
    }
}
Beispiel #17
0
int main(int argc, char *argv[]) {
  setvbuf(stdout, NULL, _IONBF, 0);

  cash = get_rand();

  puts("Welcome to ONLINE ROULETTE!");
  printf("Here, have $%ld to start on the house! You'll lose it all anyways >:)\n", cash);
  puts("");

  long bet;
  long choice;
  while(cash > 0) {
      bet = get_bet();
      cash -= bet;
      choice = get_choice();
      puts("");

      play_roulette(choice, bet);

      if (wins >= MAX_WINS) {
	printf("Wow you won %lu times? Looks like its time for you cash you out.\n", wins);
	printf("Congrats you made $%lu. See you next time!\n", cash);
	exit(-1);
      }

      if(cash > ONE_BILLION) {
	printf("*** Current Balance: $%lu ***\n", cash);
	if (wins >= HOTSTREAK) {
	  puts("Wow, I can't believe you did it.. You deserve this flag!");
	  print_flag();
	  exit(0);
	}
	else {
	  puts("Wait a second... You're not even on a hotstreak! Get out of here cheater!");
	  exit(-1);
	}
	}
  }
  puts("Haha, lost all the money I gave you already? See ya later!");
  return 0;
}
Beispiel #18
0
int main(int argc, const char *argv[])
{
    V_NODE *head=NULL;
    char flag=0;
    while(!flag)
    {

        print_list();
        switch(get_choice())
        {
            case 1 : head= link_add(head);break;
            case 2 : head= delete_link(head); break;
            case 3 : print_link(head);break;
            case 4 : flag=1; break;
            default : break;
        }
        getchar();
        getchar();
    }
    return 0;
}
Beispiel #19
0
void more(FILE *fp){
	char line[LINECHAR];
	char *ln;
	int i;
	char ch;

	i = 0;
	while((ln = fgets(line, LINECHAR, fp)) != NULL){ //while(fgets(line, LINECHAR,fp))
		fputs(line, stdout);
		i++;
		if(i >= MAXLINE -1){
			int rt;
			rt = get_choice();
			if(rt == 0)
				break;
			else if(rt == MAXLINE)
				i = 0;
			else if(rt == 1)
				;
		}
	}
}
Beispiel #20
0
Datei: 8.c Projekt: jnksu/CPP
int main(void)
{
	char options;
	
	while((options = get_choice()) != 'q')
	{
		switch(options){
			case 'a':calc('+');
					 break;
			case 's':calc('-');
					 break;
			case 'm':calc('*');
					 break;
			case 'd':calc('/');
					break;
			
			default:printf("Program Error!\n");
		}
	}
	printf("Bye.");
	return 0;
}
Beispiel #21
0
int main(void)
{
	char input[LIM][SIZE];
	char *ptstr[LIM];
	char select;
	
	int ct = 0;

	printf("Input up to %d lines finished by EOF(^Z).\n",LIM);
	puts("To stop, press the Enter key at a line's start.");
	while(ct < LIM && gets(input[ct]) && input[ct][0] != '\0')
		{
			ptstr[ct] = input[ct];			//注意,不要把二维数组传到接受指针数组的函数,一个元素是指针,一个是字符,二维数组定义为char (str *)[SIZE]
			ct ++;
		}
	
	while((select = get_choice())!= 'q')
		{
			switch(select)
			{
				case 'a': origin_put(ptstr,ct);
									break;
				case 'b': ascii_put(ptstr,ct);
									break;
				case 'c': length_put(ptstr,ct);
									break;
				case 'd': first_word_length_put(ptstr,ct);
									break;
				default:	puts("Program error!");
									break;
			}
			
		}
	printf("Bye!\n");
		
	return 0;
}
Beispiel #22
0
static void handle_verified()
{
    fputs("\n================== VERIFIED ======================\n\n", stdout);
    fputs("Welcome Back! Now, you can do the following things: \n", stdout);
    fputs("    1. QUERY TICKETS\n", stdout);
    fputs("    2. ORDER\n", stdout);
    fputs("    3. QUERY YOUR ORDER\n", stdout);
    fputs("    4. EXIT\n", stdout);
    char c = get_choice();
    switch(c){
         case '1':
            status = S_QUERY;
            break;
         case '2':
            status = S_ORDER;
            break;
        case '3':
            status = S_QUERY_ORDER;
            break;
        case '4':
            status = S_EXIT;
            break;
    }
}
Beispiel #23
0
int main(int argc, const char *argv[])
{
	int choice;
	
	do
	{
		show_menu();

		choice = get_choice();

		if (0 == choice)
		{
			break;
		}

		do_exercise(choice);

		sleep(2);
		system("clear");
	} while (choice != 0);

	printf("\n welcome to use this software, goodbye!\n");
	return 0;
}
Beispiel #24
0
int		fw_msgbox(char *title, char *msg, int flag)
{
  int x,y;
  
  x = ((gfx->win->res_w - MB_WIDTH) / 2);
  y = ((gfx->win->res_h - MB_HEIGHT) / 2);
  gfx->win->text = load_string(title, FONT, 13);
  gfx->win->dest.w = MB_WIDTH + 2;
  gfx->win->dest.h = MB_HEIGHT + 2;
  gfx->win->img = SDL_CreateRGBSurface(SDL_HWSURFACE, gfx->win->dest.w, gfx->win->dest.h,
				  gfx->bpp,
				  gfx->win->sdlMainScreen->format->Rmask,
				  gfx->win->sdlMainScreen->format->Gmask,
				  gfx->win->sdlMainScreen->format->Bmask,
				  gfx->win->sdlMainScreen->format->Amask);
  SDL_SetColorKey(gfx->win->img, SDL_SRCCOLORKEY,0);
  SDL_FillRect(gfx->win->img, NULL, SDL_MapRGB(gfx->win->sdlMainScreen->format,208,208,208));
  gfx->win->dest.x = 1;
  gfx->win->dest.y = 1;
  gfx->win->dest.h = MB_HEIGHT;
  gfx->win->dest.w = MB_WIDTH;
  SDL_FillRect(gfx->win->img, &(gfx->win->dest), SDL_MapRGB(gfx->win->sdlMainScreen->format,0,0,42));
  gfx->win->dest.x = 1;
  gfx->win->dest.y = 21;
  gfx->win->dest.h = 1;
  gfx->win->dest.w = MB_WIDTH;
  SDL_FillRect(gfx->win->img, &(gfx->win->dest), SDL_MapRGB(gfx->win->sdlMainScreen->format,208,208,208));
  gfx->win->dest.x = x;
  gfx->win->dest.y = y;
  aff_surf(gfx->win->img, 255);
  SDL_FreeSurface(gfx->win->img);
  gfx->win->dest.x = x + 3;
  gfx->win->dest.y = y + 2;
  aff_surf(gfx->win->text, 255);
  SDL_FreeSurface(gfx->win->text);
  gfx->win->text = load_string(msg, FONT, 14);
  gfx->win->dest.x = x + 7;
  gfx->win->dest.y = y + 24;
  aff_surf(gfx->win->text, 255);
  SDL_FreeSurface(gfx->win->text);
  if (flag == MB_OKCANCEL)
    {
      show_button(x, y, "OK", 0, "AFirstChaos/img/menu/mb_button.png");
      show_button(x, y, "Cancel", 2, "AFirstChaos/img/menu/mb_button.png");
    }
  else if (flag == MB_YESNO)
    {
      show_button(x, y, "Yes", 0, "AFirstChaos/img/menu/mb_button.png");
      show_button(x, y, "No", 2, "AFirstChaos/img/menu/mb_button.png");
    }
  else if (flag == MB_YESNOCANCEL)
    {
      show_button(x, y, "Yes", 0, "AFirstChaos/img/menu/mb_button.png");
      show_button(x, y, "No", 1, "AFirstChaos/img/menu/mb_button.png");
      show_button(x, y, "Cancel", 2, "AFirstChaos/img/menu/mb_button.png");
    }
  else
    {
      show_button(x, y, "OK", 1, "AFirstChaos/img/menu/mb_button.png");
      flag = MB_INFO;
    }
  return (get_choice(x, y, flag));
}
void demo_test(void)
{
	int errid = 0;
	int taskid[DEMO_TASK_MAX] = {0};
	int choice = 0;
	int i = 0;

#ifndef HAS_OFFLINE_DEMO
	printf("This version has not offline demo.\n");
	return;
#endif

	demo_usage_show();

	while((choice = get_choice()) != 'q')
	{
		switch(choice)
		{
			case 'i':
				errid = transfer_mgr_init();
				printf(">>>> Init Xfer, err=%d \n", errid);
				break;
			case '1':
				printf(">>>> Register HTTP Module start\n");
				errid = transfer_mgr_module_register(XFER_MODULE_HTTP, NULL);
				printf(">>>> Register HTTP Module, err=%d \n", errid);
				errid = transfer_mgr_setopt(DLOPT_SETUP_DEMO, XFER_TASK_HTTP, 1);
				printf(">>>> transfer_mgr_setopt, err=%d \n", errid);
				errid = transfer_mgr_set_demo_path(s_demo_path);
				printf(">>>> transfer_mgr_set_demo_path=%s, err=%d \n", s_demo_path, errid);
				break;
			case 'a':
				printf("-------------- http task add ---------------\n");
				for(i = 0; i < DEMO_TASK_MAX; i++)
				{
					//errid = transfer_mgr_task_add(demo_urls[i], demo_dests[i], XFER_TASK_HTTP, XFER_NULL, NULL, xfer_file_cb, &taskid[i]);
					errid = transfer_mgr_task_add(demo_urls[i], NULL, XFER_TASK_HTTP, XFER_BUFF, NULL, xfer_mem_cb, &taskid[i]);
					printf(">>>>[%d] Add Task, err=%d, id=%d\n", i+1, errid, taskid[i]);
				}

				break;
			case 's':
				/* start or restart HTTP task */
				for(i = 0; i < DEMO_TASK_MAX; i++)
				{
					errid = transfer_mgr_task_start(taskid[i]);
					printf(">>>>[%d] Start Task, err=%d, id=%d\n", i+1, errid, taskid[i]);
				}
				break;
			case 'p':

				/* pause HTTP task */
				for(i = 0; i < DEMO_TASK_MAX; i++)
				{
					errid = transfer_mgr_task_pause(taskid[i]);
					printf(">>>> Pause Task, err=%d, id=%d\n", errid, taskid[i]);
				}
				break;
			case 'c':
				/* close HTTP task */
				for(i = 0; i < DEMO_TASK_MAX; i++)
				{
					transfer_mgr_task_close(taskid[i]);
					printf(">>>> Close Task, id=%d\n", taskid[i]);
				}
				break;
			case 'u':
				printf(">>>> Uninit ...\n");
				transfer_mgr_fini();
				break;
			case 'h':
				demo_usage_show();
				break;
			case 'q':
				printf(">>>> Quit ...\n");
				return;

			default:
				printf("Input errror ch=%x \n", choice);
				break;
		}
	}
	return;
}
Beispiel #26
0
void film_genie(char* film)//the function for the film-genie game
{
	fflush(stdin);

	int i=0,count=0,string_length=0,comparison=0,comparison2=0,comparison3=0,x=0,spaces=0;

	char guess[400],guess_upper_string[400],guess_upper;

	char string[(strlen(film))];				//create an array big enough to hold all characters including spaces and null

	for(i=0;i<(strlen(film));i++){string[i]='\0';}	//clean the array so that when it comes to comparisons they will match
	for(i=0;i<400;i++){guess[i]='\0';}				//clean the guess array

	for(i=0;i<strlen(film);i++){string[i]='*';}	//fill the string array with * to show the number of characters that have to be guessed by the user
	string[strlen(film)]='\0';
	//printf("string is size %d after *'s\r\n",strlen(string));		//debug for showing how many stars are in the array

	for(i=0;i<strlen(film);i++){film[i]=toupper(film[i]);}	//convert everything to upper-case
	for(i=0;i<=strlen(film);i++){if(film[i]>64&&film[i]<123||film[i]==32){string_length++;}}
	//get the total number of characters and spaces and nothing else
	for(i=0;i<=strlen(film);i++){if(film[i]==32){spaces++;}}		//count the number of spaces , used in the character number checker
	for(i=0;i<=strlen(film);i++){if(film[i]<65&&film[i]>122&&film[i]!=32){film[i]='\0';}}		//null any characters present in film
	i=0;

	while(count<number_of_tries&&comparison!=(string_length-spaces)&&comparison2!=string_length)
	//if the number of tries goes to far , or they get the full thing
	{
		fflush(stdin);
		clear_screen();
		//printf("higher case film = %s\r\n",film);

		printf("Guess number:%d\r\n",count);
		printf("previous guess was:%s\r\n",guess);
		printf("number of characters=%d\r\n",string_length);
		printf("here is the string so far %s\r\n",string);
		get_choice();

		if(user_answer=='c'||user_answer=='C')
		{
			fflush(stdin);
			printf("\nplease enter a character\r\n");
			scanf("%2s",&guess);
			fflush(stdin);
			//printf("you entered %s\r\n",guess);
			for(i=0;i<=strlen(film);i++)//check for all characters that may match the guess
			{
					guess_upper=toupper(guess[0]);
					if(guess_upper==film[i]){string[i]=guess_upper;comparison++;}//if the guess is right replace the star in string with the character
					//and increment the comparison count(count until all letters have been guessed
			}
			//printf("comp=%d and sl=%d ,counter=%d\r\n",comparison,string_length,i);

			if(comparison==comparison3){count++;printf("Your character doesn't exist! Please continue playing\r\n");}
			//if the guess was incorrect then the comparison will be equal to comparison3
			else{comparison3=comparison;}//else the guess was right
			wait_for_user();
			fflush(stdin);
		}

		if(user_answer=='f'||user_answer=='F')
		{
			fflush(stdin);
			for(i=0;i<400;i++){guess[i]='\0';}
			for(i=0;i<400;i++){guess_upper_string[i]='\0';}
			i=0;

			printf("\nplease enter the full film name\r\n");


			for(x=0;guess[x]!='\r'&&x<=string_length&&guess[x]!='\n';x++){guess[x]=getchar();}
			//because scanf was giving me errors , i wrote my own version of it here
			fflush(stdin);
			//printf("you entered %s\r\n",guess);
			comparison2=0;

			for(i=0;i<=strlen(film);i++)//check for all characters that may match the guess
			{
					guess_upper_string[i]=toupper(guess[i]);
					//printf("guess=%c and film=%c\r\n",guess_upper_string[i],film[i]);
					if(guess_upper_string[i]==film[i]){string[i]=guess_upper_string[i];comparison2++;}
					//if the guess is right replace the star in string with the character
					if(comparison2==string_length){break;}
					//if all characters are matched then the guess is right , also handy if they only mispelled a single part of a long string
			}
			//printf("comp=%d and sl=%d ,counter=%d,string=%s\r\n",comparison2,string_length,comparison3,string);
			if(comparison2!=string_length){count++;}
			if(comparison2==comparison3){printf("Your character doesn't exist! Please continue playing\r\n");}
			//if the guess was incorrect then the comparison will be equal to comparison3
			else
				{comparison3=comparison;}		  //else the guess was right
			wait_for_user();
			fflush(stdin);
		}
		else
			{printf("please try again\r\n");wait_for_user();}

	}

	clear_screen();

	if(count>number_of_tries){printf("sorry but that wasn't the right answer\r\n");printf("%s was the right answer\r\n",film);}
	if(count==5){printf("That was a lucky one , well done\r\n");}
	if(count==0){printf("Your a Genius , well done\r\n");}
	else{printf("Congratulations You Won, %s was the right answer\r\n",film);}

	fflush(stdin);
	for(i=0;i<400;i++){play_again[i]='\0';}
	i=0;
	printf("would you like to continue playing?\r\n");
	printf("Y to continue or N to quit\r\n");
	scanf("%s",&play_again);
	fflush(stdin);
	if(play_again[0]=='y'||play_again[0]=='Y'){read_file();}
	if(play_again[0]=='n'||play_again[0]=='N'){end_all();}
	else
	{
		fflush(stdin);
		for(i=0;i<400;i++){play_again[i]='\0';}
		i=0;
		printf("wrong input, please try again\r\n");
		wait_for_user();
		printf("would you like to continue playing?\r\n");
		printf("Y to continue or N to quit\r\n");
		scanf("%s",&play_again);
		fflush(stdin);
		if(play_again[0]=='y'||play_again[0]=='Y'){read_file();}
		if(play_again[0]=='n'||play_again[0]=='N'){end_all();}
		else
		{
			for(i=0;i<400;i++){play_again[i]='\0';}
			i=0;
			while(i<10)//10 times is trying it really
			{
				printf("\nwould you like to continue playing?\r\n");
				printf("Y to continue or N to quit\r\n");
				scanf("%s",&play_again);
				if(play_again[0]=='y'||play_again[0]=='Y'){read_file();}
				if(play_again[0]=='n'||play_again[0]=='N'){end_all();}
				else{printf("character not recognized, please try again\r\n");i++;}
			}
			if(i==10){clear_screen();printf("Now redirecting you to the main menu , please don't try that again\r\n");wait_for_user();options();}
		}
	}
}
void xfer_test(void)
{
	int errid = 0;
	int taskid[XFER_TASK_MAX] = {0};
	transfer_task_list_t* tasklist = NULL;
	int choice = 0;
	int i = 0;

	xfer_usage_show();

	while((choice = get_choice()) != 'q')
	{
		switch(choice)
		{
			case 'i':
				errid = transfer_mgr_init();
				printf(">>>> Init Xfer, err=%d \n", errid);
				break;
			case '1':
				errid = transfer_mgr_module_register(XFER_MODULE_HTTP, NULL);
				printf(">>>> Register HTTP Module, err=%d \n", errid);
				break;
			case '2':
				errid = transfer_mgr_module_register(XFER_MODULE_THUNDER, (void *)s_license);
				printf(">>>> Register THUNDRE Module, err=%d \n", errid);
				break;
			case 'a':
				//for(i = 0; i < XFER_TASK_MAX; i++)
				printf("-------------- http task add ---------------\n");
				{
					errid = transfer_mgr_task_add(test_urls[0], test_dests[0], XFER_TASK_HTTP, XFER_NULL, NULL, xfer_file_cb, &taskid[0]); 
					printf(">>>> Add Task, err=%d, id=%d\n", errid, taskid[0]);
				}
				{
					errid = transfer_mgr_task_add(test_urls[1], test_dests[1], XFER_TASK_HTTP, XFER_NULL, NULL, xfer_file_cb, &taskid[1]); 
					printf(">>>> Add Task, err=%d, id=%d\n", errid, taskid[1]);
				}
				{
					errid = transfer_mgr_task_add(test_urls[2], test_dests[2], XFER_TASK_HTTP, XFER_NULL, NULL, xfer_mem_cb, &taskid[2]); 
					printf(">>>> Add Task, err=%d, id=%d\n", errid, taskid[2]);
				}

				printf("-------------- tunder url task add ---------------\n");
				{
					errid = transfer_mgr_task_add(test_urls[3], test_dests[3], XFER_TASK_XLTCID, XFER_NULL, NULL, xfer_file_cb, &taskid[3]); 
					printf(">>>> Add Task, err=%d, id=%d\n", errid, taskid[3]);
				}
				{
					errid = transfer_mgr_task_add(test_urls[4], test_dests[4], XFER_TASK_XLURL, XFER_NULL, NULL, xfer_file_cb, &taskid[4]); 
					printf(">>>> Add Task, err=%d, id=%d\n", errid, taskid[4]);
				}
				{
					errid = transfer_mgr_task_add(test_urls[5], test_dests[5], XFER_TASK_XLURL, XFER_NULL, NULL, xfer_file_cb, &taskid[5]); 
					printf(">>>> Add Task, err=%d, id=%d\n", errid, taskid[5]);
				}
				{
					errid = transfer_mgr_task_add(test_urls[6], test_dests[6], XFER_TASK_XLURL, XFER_NULL, NULL, xfer_file_cb, &taskid[6]); 
					printf(">>>> Add Task, err=%d, id=%d\n", errid, taskid[6]);
				}
				printf("-------------- tunder tcid task add ---------------\n");
				{
					errid = transfer_mgr_task_add(test_urls[7], test_dests[7], XFER_TASK_XLTCID, XFER_NULL, NULL, xfer_file_cb, &taskid[7]); 
					/* thunder cid task */
					printf(">>>> Add thunder tcid Task, err=%d, id=%d\n", errid, taskid[7]);
				}

				break;
			case 's':
				errid = transfer_mgr_get_task_list(&tasklist);

				/* start or restart THUNDER task */
				if((errid != 0) || (tasklist == NULL))
				{
					printf("----------tasklist is NULL,errid=%d----------\n", errid);
				}
				else
				{
					printf("----------tasklist->count=%d----------\n", tasklist->task_count);
					for(i = 0; i < tasklist->task_count; i++)
					{
						errid = transfer_mgr_task_start(tasklist->task_ids[i]);
						printf(">>>> Start Task, err=%d, id=%d\n", errid, tasklist->task_ids[i]);
					}

					transfer_mgr_release_task_list(tasklist);
				}

				/* start or restart HTTP task */
				for(i = 0; i < XFER_HTTP_TASK_MAX; i++)
				{
					errid = transfer_mgr_task_start(taskid[i]);
					printf(">>>> Start Task, err=%d, id=%d\n", errid, taskid[i]);
				}
				break;
			case 'p':
				errid = transfer_mgr_get_task_list(&tasklist);

				/* pause THUNDER task */
				if((errid != 0) || (tasklist == NULL))
				{
					printf("----------tasklist is NULL,errid=%d----------\n", errid);
				}
				else
				{
					printf("----------tasklist->count=%d----------\n", tasklist->task_count);
					for(i = 0; i < tasklist->task_count; i++)
					{
						errid = transfer_mgr_task_pause(tasklist->task_ids[i]);
						printf(">>>> Pause Task, err=%d, id=%d\n", errid, tasklist->task_ids[i]);
					}

					transfer_mgr_release_task_list(tasklist);
				}

				/* pause HTTP task */
				for(i = 0; i < XFER_HTTP_TASK_MAX; i++)
				{
					errid = transfer_mgr_task_pause(taskid[i]);
					printf(">>>> Pause Task, err=%d, id=%d\n", errid, taskid[i]);
				}
				break;
			case 'c':
				errid = transfer_mgr_get_task_list(&tasklist);

				/* close THUNDER task */
				if((errid != 0) || (tasklist == NULL))
				{
					printf("----------tasklist is NULL,errid=%d----------\n", errid);
				}
				else
				{
					printf("----------tasklist->count=%d----------\n", tasklist->task_count);
					for(i = 0; i < tasklist->task_count; i++)
					{
						transfer_mgr_task_close(tasklist->task_ids[i]);
						printf(">>>> Close Task, id=%d\n", tasklist->task_ids[i]);
					}

					transfer_mgr_release_task_list(tasklist);
				}

				/* close HTTP task */
				for(i = 0; i < XFER_HTTP_TASK_MAX; i++)
				{
					transfer_mgr_task_close(taskid[i]);
					printf(">>>> Close Task, id=%d\n", taskid[i]);
				}
				break;
			case 'u':
				printf(">>>> Uninit ...\n");
				transfer_mgr_fini();
				break;
			case 'l':
				errid = transfer_mgr_load(s_load_path);
				printf(">>>> Load task, err=%d\n", errid);
				break;
			case 'h':
				xfer_usage_show();
				break;
			case 'q':
				printf(">>>> Quit ...\n");
				return;
			case '9':
				errid = xfer_update_task_init();
				printf(">>>> Show task list detail, err=%d \n", errid);
				break;
			case '0':
				xfer_update_task_fini();
				break;

			default:
				printf("Input errror ch=%x \n", choice);
				break;
		}
	}
	return;
}
void thunder_test(void)
{
	int errid = 0;
	int taskid[XFER_TASK_MAX] = {0};
	transfer_task_list_t* tasklist = NULL;
	int choice = 0;
	int i = 0;
	int j = 0;

#ifndef HAS_MODULE_THUNDER
	printf("This version has not thunder module.\n");
	return;
#endif

	thunder_usage_show();

	while((choice = get_choice()) != 'q')
	{
		switch(choice)
		{
			case 'i':
				errid = transfer_mgr_init();
				printf(">>>> Init Xfer, err=%d \n", errid);
				//break;
			case '2':
				errid = transfer_mgr_module_register(XFER_MODULE_THUNDER, (void *)s_license);
				printf(">>>> Register THUNDRE Module, err=%d \n", errid);
				errid = transfer_mgr_set_path_prefix(s_path_prefix);
				printf(">>>> Set Path Prefix[%s], err=%d \n", s_path_prefix, errid);
				break;
			case 'a':
#if 0 //thunder cid task
				printf("-------------- tunder url task add ---------------\n");
				{
					/* thunder cid task */
					errid = transfer_mgr_task_add(test_urls[7], test_dests[7], XFER_TASK_XLTCID, XFER_NULL, NULL, xfer_file_cb, &taskid[7]); 
					printf(">>>> Add thunde tcid Task, err=%d, id=%d\n", errid, taskid[7]);
				}
#endif
#if 0 //thunder bt task
				{
					/* thunder BT task */
					errid = transfer_mgr_get_seed_info(bt_src, seed_path1, &seed_info); 
					printf("\n------------------------------------------------\n");
					printf("BT name=%s\n", seed_info->name);
					printf("BT saved_path=%s\n", seed_info->saved_path);
					printf("BT seed_file_path=%s\n", seed_info->seed_file_path);
					printf("BT total_size=%d\n", (int)seed_info->total_size);
					printf("BT file_num=%d\n", seed_info->file_num);
					for(j = 0; j < seed_info->file_num; j++)
					{
						printf("\tBT file_index[%d]=%d\n", j, seed_info->download_file_index_array[j]);
					}
					printf("BT download_num=%d\n", seed_info->download_num);
					printf("\n------------------------------------------------\n");

					errid = transfer_mgr_task_add_bt(bt_src, 
								seed_info->seed_file_path,
								seed_info->saved_path,
								seed_info->name,
								seed_info->download_file_index_array,
								seed_info->file_num,
								&taskid[8]); 
					printf(">>>> Add thunde BT Task, err=%d, id=%d\n", errid, taskid[8]);
					transfer_mgr_release_seed_info(&seed_info);
				}
				{
					/* thunder BT task */
					errid = transfer_mgr_get_seed_info(bt_src, seed_path2, &seed_info); 
					printf("\n------------------------------------------------\n");
					printf("BT name=%s\n", seed_info->name);
					printf("BT saved_path=%s\n", seed_info->saved_path);
					printf("BT seed_file_path=%s\n", seed_info->seed_file_path);
					printf("BT total_size=%d\n", (int)seed_info->total_size);
					printf("BT file_num=%d\n", seed_info->file_num);
					for(j = 0; j < seed_info->file_num; j++)
					{
						printf("\tBT file_index[%d]=%d\n", j, seed_info->download_file_index_array[j]);
					}
					printf("BT download_num=%d\n", seed_info->download_num);
					printf("\n------------------------------------------------\n");

					errid = transfer_mgr_task_add_bt(bt_src, 
								seed_info->seed_file_path,
								seed_info->saved_path,
								seed_info->name,
								seed_info->download_file_index_array,
								seed_info->file_num,
								&taskid[9]); 
					printf(">>>> Add thunde BT Task, err=%d, id=%d\n", errid, taskid[9]);
					transfer_mgr_release_seed_info(&seed_info);
				}
#endif
#if 1 //thunder url task
				/* url task*/
				{
					errid = transfer_mgr_task_add(test_urls[4], test_dests[4], XFER_TASK_XLURL, XFER_NULL, NULL, xfer_file_cb, &taskid[4]); 
					printf(">>>> Add Task, err=%d, id=%d\n", errid, taskid[4]);
				}
#endif
#if 0
				{
					errid = transfer_mgr_task_add(test_urls[5], test_dests[5], XFER_TASK_XLURL, XFER_NULL, NULL, xfer_file_cb, &taskid[5]); 
					printf(">>>> Add Task, err=%d, id=%d\n", errid, taskid[5]);
				}
				{
					errid = transfer_mgr_task_add(test_urls[6], test_dests[6], XFER_TASK_XLURL, XFER_NULL, NULL, xfer_file_cb, &taskid[6]); 
					printf(">>>> Add Task, err=%d, id=%d\n", errid, taskid[6]);
				}
				{
					errid = transfer_mgr_task_add(test_urls[7], test_dests[7], XFER_TASK_XLTCID, XFER_NULL, NULL, xfer_file_cb, &taskid[7]); 
					printf(">>>> Add Task, err=%d, id=%d\n", errid, taskid[7]);
				}
#endif

				break;
			case 's':
				errid = transfer_mgr_get_task_list(&tasklist);

				/* start or restart THUNDER task */
				if((errid != 0) || (tasklist == NULL))
				{
					printf("----------tasklist is NULL,errid=%d----------\n", errid);
				}
				else
				{
					printf("----------tasklist->count=%d----------\n", tasklist->task_count);
					for(i = 0; i < tasklist->task_count; i++)
					{
						errid = transfer_mgr_task_start(tasklist->task_ids[i]);
						printf(">>>> Start Task, err=%d, id=%d\n", errid, tasklist->task_ids[i]);
					}

					transfer_mgr_release_task_list(tasklist);
				}

				break;
			case 'p':
				errid = transfer_mgr_get_task_list(&tasklist);

				/* pause THUNDER task */
				if((errid != 0) || (tasklist == NULL))
				{
					printf("----------tasklist is NULL,errid=%d----------\n", errid);
				}
				else
				{
					printf("----------tasklist->count=%d----------\n", tasklist->task_count);
					for(i = 0; i < tasklist->task_count; i++)
					{
						errid = transfer_mgr_task_pause(tasklist->task_ids[i]);
						printf(">>>> Pause Task, err=%d, id=%d\n", errid, tasklist->task_ids[i]);
					}

					transfer_mgr_release_task_list(tasklist);
				}
				
				break;
			case 'c':
				errid = transfer_mgr_get_task_list(&tasklist);

				/* close THUNDER task */
				if((errid != 0) || (tasklist == NULL))
				{
					printf("----------tasklist is NULL,errid=%d----------\n", errid);
				}
				else
				{
					printf("----------tasklist->count=%d----------\n", tasklist->task_count);
					for(i = 0; i < tasklist->task_count; i++)
					{
						errid = transfer_mgr_task_check_busy(tasklist->task_ids[i]);
						printf(">>>> Check Task, id=%d, errid=%d\n", tasklist->task_ids[i], errid);
						if (errid == 0)
						{
							transfer_mgr_task_close(tasklist->task_ids[i]);
							printf(">>>> Close Task, id=%d\n", tasklist->task_ids[i]);
						}
					}

					transfer_mgr_release_task_list(tasklist);
				}
				break;
			case 'l':
				errid = transfer_mgr_load(s_load_path);
				printf(">>>> Load task, err=%d\n", errid);
				break;
			case 'u':
				printf(">>>> Uninit ...\n");
				transfer_mgr_fini();
				xfer_update_task_fini();
				break;
			case 'h':
				thunder_usage_show();
				break;
			case 'q':
				printf(">>>> Quit ...\n");
				return;
			case '9':
				errid = xfer_update_task_init();
				printf(">>>> Show task list detail, err=%d \n", errid);
				break;
			case '0':
				xfer_update_task_fini();
				break;

			default:
				printf("Input errror ch=%x \n", choice);
				break;
		}
	}
	return;
}
void thunder_vod_test(void)
{
	int errid = 0;
	int taskid = 0;
	int choice = 0;
	int percent;
	char buf[1024] = {0};
	static int vod_read = 0;

#ifndef HAS_MODULE_THUNDER
	printf("This version has not thunder module.\n");
	return;
#endif

	vod_usage_show();

	errid = transfer_mgr_init();
	printf(">>>> Init Xfer, err=%d \n", errid);

	errid = transfer_mgr_module_register(XFER_MODULE_THUNDER, (void *)s_license);
	printf(">>>> Register THUNDRE Module, err=%d \n", errid);

	errid = transfer_mgr_task_add_vod(s_vod_cid, s_vod_gcid, s_load_path, (int)atoi(s_vod_size), XFER_TASK_XLGCID, "vod.rmvb", &taskid);
	printf(">>>> Add thunde VOD Task, err=%d, id=%d\n", errid, taskid);

	while((choice = get_choice()) != 'q')
	{
		switch(choice)
		{
			case 's':
				errid = transfer_mgr_task_start(taskid);
				printf(">>>> Start Task, err=%d, id=%d\n", errid, taskid);
				break;
			case 'p':
				errid = transfer_mgr_task_pause(taskid);
				printf(">>>> Pause Task, err=%d, id=%d\n", errid, taskid);
				break;
			case 'u':
				printf(">>>> Uninit ...\n");
				transfer_mgr_fini();
				break;
			case 'q':
				printf(">>>> Quit ...\n");
				return;
			case '7':
				if (vod_read <= 1)
				{
					errid = transfer_mgr_read_kankan_file(taskid, 0, 1024, buf, 200);
					vod_read++;
				}
				errid = transfer_mgr_get_kankan_buffer_percent(taskid, &percent);
				printf(">>>> Read kankan_buffer err=%d, <%d%%>\n", errid, percent);
				break;
				/*
			case '8':
				errid = transfer_mgr_read_kankan_file(taskid, 0, 1024, buf, 200);
				printf(">>>> Read kankan_file, err=%d \n", errid);
				//printf("[%s]\n", buf);
				break;
				*/
			case '9':
				errid = xfer_update_task_init();
				printf(">>>> Show task list detail, err=%d \n", errid);
				break;
			case '0':
				xfer_update_task_fini();
				break;
			case 'h':
				vod_usage_show();
				break;

			default:
				printf("Input errror ch=%x \n", choice);
				break;
		}
	}
	return;
}
void http_test(void)
{
	int errid = 0;
	int taskid[HTTP_TASK_MAX] = {0};
	int choice = 0;
	int i = 0;

	http_usage_show();

	while((choice = get_choice()) != 'q')
	{
		switch(choice)
		{
			case 'i':
				errid = transfer_mgr_init();
				printf(">>>> Init Xfer, err=%d \n", errid);
				//break;
			case '1':
				errid = transfer_mgr_module_register(XFER_MODULE_HTTP, NULL);
				printf(">>>> Register HTTP Module, err=%d \n", errid);
				//errid = transfer_mgr_create_tmp_file(s_http_tmp_path);
				//printf(">>>> Create tmp file, path=%s, err=%d \n", s_http_tmp_path, errid);
				break;
			case 'a':
				printf("-------------- http task add ---------------\n");
				for(i = 0; i < HTTP_TASK_MAX; i++)
				{
					errid = transfer_mgr_task_add(http_urls[i], http_dests[i], XFER_TASK_HTTP, XFER_NULL, NULL, xfer_file_cb, &taskid[i]); 
					printf(">>>>[%d] Add Task, err=%d, id=%d\n", i+1, errid, taskid[i]);
				}

				break;
			case 's':
				/* start or restart HTTP task */
				for(i = 0; i < HTTP_TASK_MAX; i++)
				{
					errid = transfer_mgr_task_start(taskid[i]);
					printf(">>>>[%d] Start Task, err=%d, id=%d\n", i+1, errid, taskid[i]);
				}
				break;
			case 'p':

				/* pause HTTP task */
				for(i = 0; i < HTTP_TASK_MAX; i++)
				{
					errid = transfer_mgr_task_pause(taskid[i]);
					printf(">>>> Pause Task, err=%d, id=%d\n", errid, taskid[i]);
				}
				break;
			case 'c':
				/* close HTTP task */
				for(i = 0; i < HTTP_TASK_MAX; i++)
				{
					transfer_mgr_task_close(taskid[i]);
					printf(">>>> Close Task, id=%d\n", taskid[i]);
				}
				break;
			case 'u':
				printf(">>>> Uninit ...\n");
				transfer_mgr_fini();
				break;
			case 'h':
				http_usage_show();
				break;
			case 'q':
				printf(">>>> Quit ...\n");
				return;

			default:
				printf("Input errror ch=%x \n", choice);
				break;
		}
	}
	return;
}