示例#1
0
static void
search_complete_cb (OlLyricSourceSearchTask *task,
                    enum OlLyricSourceStatus status,
                    GList *results,
                    gpointer userdata)
{
  printf ("search complete: ");
  print_status (status);
  ol_test_expect (status == (gsize)userdata);
  if (status == OL_LYRIC_SOURCE_STATUS_SUCCESS)
  {
    if (results)
    {
      test_download (OL_LYRIC_SOURCE_CANDIDATE (results->data));
      test_download_cancel (OL_LYRIC_SOURCE_CANDIDATE (results->data));
    }
    for (; results; results = results->next)
    {
      OlLyricSourceCandidate *candidate;
      candidate = OL_LYRIC_SOURCE_CANDIDATE (results->data);
      printf ("(%s)%s - %s - %s\n",
              ol_lyric_source_candidate_get_sourceid (candidate),
              ol_lyric_source_candidate_get_title (candidate),
              ol_lyric_source_candidate_get_artist (candidate),
              ol_lyric_source_candidate_get_album (candidate));
    }
  }
  task_cnt--;
  check_quit ();
}
示例#2
0
static Lisp_Object
default_error_handler (Lisp_Object data)
{
  int speccount = specpdl_depth ();

  /* None of this is invoked, normally.  This code is almost identical
     to the `command-error' function, except `command-error' does cool
     tricks with sounds.  This function is a fallback, invoked if
     command-error is unavailable.  */

  Fding (Qnil, Qnil, Qnil);

  if (!NILP (Fboundp (Qerrors_deactivate_region))
      && !NILP (Fsymbol_value (Qerrors_deactivate_region)))
    zmacs_deactivate_region ();
  Fdiscard_input ();
  specbind (Qinhibit_quit, Qt);
  Vstandard_output = Qt;
  Vstandard_input = Qt;
  Vexecuting_macro = Qnil;
  Fset (intern ("last-error"), data);
  clear_echo_area (selected_frame (), Qnil, 0);
  Fdisplay_error (data, Qt);
  check_quit (); /* make Vquit_flag accurate */
  Vquit_flag = Qnil;
  return (unbind_to (speccount, Qt));
}
示例#3
0
文件: hub_serv.c 项目: ajulien42/ft_p
void	hub_serv(char *str, t_serv clt)
{
	char	**tabcmd;

	if (strlen(str) < 2)
		return ;
	if (str[ft_strlen(str) - 1] == '\n')
		str[ft_strlen(str) - 1] = '\0';
	tabcmd = ft_strsplit(str, ' ');
	if (ft_strcmp(tabcmd[0], "quit") == 0)
		check_quit(tabcmd, clt);
	else if (ft_strcmp(tabcmd[0], "cd") == 0)
		serv_cd(tabcmd, clt);
	else if (ft_strcmp(tabcmd[0], "ls") == 0)
		serv_ls(tabcmd, clt);
	else if (ft_strcmp(tabcmd[0], "pwd") == 0)
		pwd_serv(tabcmd, clt);
	else if (ft_strcmp(tabcmd[0], "put") == 0)
		put_serv(tabcmd[1], clt);
	else if (ft_strcmp(tabcmd[0], "get") == 0)
		get_serv(tabcmd[1], clt);
	else
		write(clt.cs, "Command unknown to serveur.\n", 28);
	freetab(tabcmd);
}
示例#4
0
int main()
{
		WINDOW *menubar, *statusbar, *about;
		int key;
		init_scr();
		bkgd(COLOR_PAIR(1));
		menubar = subwin(stdscr, 1, 80, 0, 0);
		statusbar = subwin(stdscr, 1, 79, 23, 1);
		make_menubar(menubar);
		move(2, 1);
		printw("Press 'a' or 'h' to open the menus. ");
		printw("ESC or 'q' quits.");
		refresh();    
		while(1)
		{
				WINDOW **menu_items;            
				int selected_item;

				key = getch();
				werase(statusbar);
				wrefresh(statusbar);

				if (key == 'a')
				{
						menu_items=file_menu_list(0);
						selected_item = scroll_menu(menu_items, 4, 20, 0); 
						delete_menu(menu_items, 5);
						if (selected_item < 0)
								wprintw(statusbar, "You haven't selected any item");
						else
								wprintw(statusbar, "You have selected menu item %d.", selected_item);
						touchwin(stdscr);
						refresh();    
				}
				if (key == 'h')
				{
						menu_items=help_menu_list(20);
						selected_item = scroll_menu(menu_items, 2, 0, 1); 
						delete_menu(menu_items, 3);
						if (selected_item == 1)
						{
								about_window();
						}
						if (selected_item < 0)
								wprintw(statusbar, "You haven't selected any item");

				}
				if (key == ESCAPE || key == 'q')
				{
						if (check_quit() == 1)
								break;
				}
				touchwin(stdscr);
				refresh();    
		}
		endwin();
}
示例#5
0
int
check_what_happened (void)		/* called from QUIT when
					   something_happened gets set */
{
  something_happened = 0;
  if (alarm_happened)
    {
      alarm_happened = 0;
      handle_alarm_going_off ();
    }
  return check_quit ();
}
示例#6
0
static void
download_complete_cb (OlLyricSourceDownloadTask *task,
                      enum OlLyricSourceStatus status,
                      const gchar *content,
                      guint len,
                      gpointer userdata)
{
  printf ("download #%d complete: ",
          ol_lyric_source_task_get_id (OL_LYRIC_SOURCE_TASK (task)));
  print_status (status);
  ol_test_expect (status == (gsize)userdata);
  printf ("len: %u\n", len);
  printf ("%s\n", content);
  task_cnt--;
  check_quit ();
}
示例#7
0
文件: Quiz.c 项目: Shoop123/Quiz-C
//the main quiz loop
void run_question_loop()
{
	int i; //interator
	
	//loops through each question and evaluates the answer
	for (i = 0; i < questions_amount; i++)
	{
		char answer[10]; /*stores answer of user*/
	
		//asks the question by printing it on the screen
		print_question(questions[i]);
		
		//prints choices for user
		print_answers(questions[i]);
		
		//prints "Answer"
		printf("Answer: ");
		
		//allows user to asnwer the  question, and stores the answer in the answer variable
		gets(answer);
		
		//stores the answer correctness result
		int answer_result = check_answer(answer[0], questions[i].answer);
		
		//checks the answer
		if (!answer_result)
		{
			//checks of the user inputted 'q' to quit
			check_quit(answer[0]);
			//make the question repeat
			i--;
			
			//loose a life
			lose_life(player);
		}
		
		//if this is the last question, then print "Great Job!" and the amount of lives
		if (i == questions_amount - 1)
		{
			printf("Great Job :)\n");
			printf("You ended with: %i lives!", player.lives);
		}
	}
}