Beispiel #1
0
int main (void) {

	int command;

	display_menu ();
	printf("Enter a command from above menu:");
	scanf("%d", &command);
	switch (command) {	
		case 0:
			display_menu ();
			break;
		case 1:
			copy ();
			display_menu ();
			break;
		case -1:
			return 0;
		default:
			printf("Invalid choice\n");
			break;
	}
	printf("\n");
	printf("\n");

	return 0;
}
Beispiel #2
0
/**
* \brief DMA callback function for transfer complete.
*/
static void dma_callback(struct dma_resource* const resource)
{
    transfer_is_done = true;
    dma_break++;
    if (true == is_scrolling) {
        /* Used for automatically exit implementation */
        if ((dma_block_count * 4) <= dma_break) {
            dma_break = 0;
            /* Stop Automated character mode */
            xpro_lcd_automated_char_stop();
            printf("Exits from scrolling mode.\n\n\r");
            display_menu();
        }
    }

    if (true == is_bitmapping) {
        /* Used for automatically exit implementation */
        if ((bitmapping_repeat_count) <= dma_break) {
            dma_break = 0;
            /* Stop Automated bit mode */
            xpro_lcd_automated_bit_stop();
            printf("Exits from Bit mapping mode.\n\n\r");
            display_menu();
        }
    }
}
Beispiel #3
0
/**
 * \brief Application entry point for adcife example.
 *
 * \return Unused (ANSI-C compatibility).
 */
int main(void)
{
	uint32_t uc_key = 0;

	/* Initialize the SAM system */
	sysclk_init();
	board_init();

	/* Initialize the UART console */
	configure_console();

	/* Output example information */
	puts(STRING_HEADER);

	/* Set default ADCIFE test mode. */
	g_adc_test_mode.uc_trigger_mode = TRIGGER_MODE_SOFTWARE;
	g_adc_test_mode.uc_pdc_en = 1;
	g_adc_test_mode.uc_gain_en = 0;

	display_menu();

	start_dac();

	start_adc();

	while (1) {
		/* ADCIFE software trigger per 1s */
		if (g_adc_test_mode.uc_trigger_mode == TRIGGER_MODE_SOFTWARE) {
			adc_start_software_conversion(&g_adc_inst);
		}
		if (!usart_read(CONF_UART, &uc_key)) {
			adc_disable_interrupt(&g_adc_inst, ADC_SEQ_SEOC);
			display_menu();
			set_adc_test_mode();
			start_adc();
			puts("Press any key to display configuration menu.\r");
		}
		delay_ms(1000);
		if (g_uc_condone_flag == 1) {
			if(g_adc_test_mode.uc_pdc_en == 0) {
				printf("Internal DAC Voltage = %4d mv  \r\n",
						(int)(g_adc_sample_data[0] * VOLT_REF / MAX_DIGITAL));
			} else {
				printf("Internal DAC Voltage = %4d mv  \r\n",
						(int)(g_adc_sample_data[0] * VOLT_REF /
							MAX_DIGITAL));
				printf("Scaled VCC Voltage = %4d mv  \r\n",
						(int)(g_adc_sample_data[1] * VOLT_REF /
							MAX_DIGITAL));
			}
			g_uc_condone_flag = 0;
		}
	}
}
Beispiel #4
0
/**
 * \brief Application entry point.
 *
 * \return Unused (ANSI-C compatibility).
 */
int main(void)
{
	uint8_t uc_key;

	/* Initialize the SAM3 system */
	SystemInit();
	board_init();

	WDT->WDT_MR = WDT_MR_WDDIS;

	/* Initialize the console uart */
	configure_console();

	/* Output example information */
	puts(STRING_HEADER);

	/* configure LED. */
	led_config();

	/* configure push buttons. */
	configure_buttons();

	/* Set default priorities for 2 buttons. */
	puts("Set INT1's priority higher than INT2.\r");
	set_interrupt_priority(INT_PRIOR_HIGH, INT_PRIOR_LOW);

	/* Display the main menu. */
	display_menu();

	// Flash the LED.
	while (1) {
		while (uart_read(CONSOLE_UART, &uc_key));

		switch (uc_key) {
		case '1':
			set_interrupt_priority(INT_PRIOR_LOW, INT_PRIOR_HIGH);
			puts("Set INT2's priority higher than INT1.\n\r\r");
			break;

		case '2':
			set_interrupt_priority(INT_PRIOR_HIGH, INT_PRIOR_LOW);
			puts("Set INT1's priority higher than INT2.\n\r\r");
			break;

		case 'h':
			display_menu();
			break;

		default:
			puts("Invalid input.\r");
			break;
		}
	}
}
Beispiel #5
0
/**
 * \brief Application entry point for SPI example.
 *
 * \return Unused (ANSI-C compatibility).
 */
int main(void)
{
	uint8_t uc_key;

	/* Initialize the SAM system. */
	sysclk_init();
	board_init();

	/* Initialize the console UART. */
	configure_console();

	/* Output example information. */
	puts(STRING_HEADER);

	/* Configure SPI interrupts for slave only. */
	NVIC_ClearPendingIRQ(SPI_IRQn);
	NVIC_DisableIRQ(SPI_IRQn);
	NVIC_SetPriority(SPI_IRQn, 0);
	NVIC_EnableIRQ(SPI_IRQn);

	spi_slave_initialize();
	spi_xdmac_configure(SPI0);

	/* Display menu. */
	display_menu();

	while (1) {
		scanf("%c", (char *)&uc_key);

		switch (uc_key) {
		case 'h':
			display_menu();
			break;

		case 't':
			spi_disable_xdmac();
			NVIC_ClearPendingIRQ(SPI_IRQn);
			NVIC_DisableIRQ(SPI_IRQn);
			NVIC_SetPriority(SPI_IRQn, 0);
			NVIC_EnableIRQ(SPI_IRQn);
			spi_master_go();
			break;

		default:
			/* Set configuration #n. */
			if ((uc_key >= '0')
					&& (uc_key <= ('0' + NUM_SPCK_CONFIGURATIONS - 1))) {
				spi_set_clock_configuration(uc_key - '0');
			}
			break;
		}
	}
}
Beispiel #6
0
void STLMoblet::keyPressEvent(int keyCode)
{
	switch(keyCode)
	{
	case MAK_BACK:
		maExit(0);
		break;
	case MAK_0:
		STL_containers();
		display_menu();
		break;
	case MAK_1:
		functors_explained();
		STL_functors();
		display_menu();
		break;
	case MAK_2:
		pointer_adapters_explained();
		STL_adaptors();
		display_menu();
		break;
	case MAK_3:
		predicates_explained();
		display_menu();
		break;
	case MAK_4:
		STL_algorithms();
		display_menu();
		break;
	case MAK_5:
		STL_string();
		display_menu();
		break;
	case MAK_6:
		aux_functions();
		display_menu();
		break;
	case MAK_7:
		STL_auto_ptr();
		display_menu();
		break;
	case MAK_8:
		STL_pair();
		display_menu();
		break;
	case MAK_9:
		STL_iterators();
		display_menu();
		break;
	}

}
Beispiel #7
0
/**
 * \brief The main function.
 */
int main(void)
{
	uint8_t key;

	/* Initialize the SAM system */
	sysclk_init();
	board_init();

	/* Initialize the console  */
	configure_console();

	/* Output example information */
	printf("-- AES Example --\r\n");
	printf("-- %s\n\r", BOARD_NAME);
	printf("-- Compiled: %s %s --\n\r", __DATE__, __TIME__);

	/* Enable the AES module. */
	aes_get_config_defaults(&g_aes_cfg);
	aes_init(AES, &g_aes_cfg);
	aes_enable();

	/* Enable AES interrupt. */
	aes_enable_interrupt(AES, AES_INTERRUPT_DATA_READY);

	/* Display menu */
	display_menu();

	while (1) {
		scanf("%c", (char *)&key);

		switch (key) {
		case 'h':
			display_menu();
			break;

		case 'e':
			printf("GCM mode encryption test.\r\n");
			gcm_mode_encryption_test();
			break;

		case 'd':
			printf("GCM mode decryption test.\r\n");
			gcm_mode_decryption_test();
			break;

		default:
			break;
		}
	}
}
Beispiel #8
0
int main(int argc, char * argv[]){
	char input[MAX_INPUT_SIZE];
	pthread_t thread;

	if(argc < 2){
		printf("usage :\n");
		printf("WifoPluginsConsole <userid>\n");
		printf("with <userid equal to 1 or 2\n");
		return -1;
	}

	strncpy(step, "start", sizeof(step));
	wx_wengo = atoi(argv[1]);


	printf("Using wx_wengo_%d\n\n", wx_wengo);

	// register or quit
	while(strequals(step, "start")){
		display_menu(step);
		//fgets(input, sizeof(input), stdin);
		gets(input);
		// if a quit, then quit
		if(strequals(input, "quit")){
			printf("\nBye.\n");
			return 0;
		}
		execute_action(input);
	}

	// display whole menu
	display_menu(NULL);

	// launch a thread to display the menu
	if(pthread_create(&thread, NULL, interact, NULL) != 0){
		// TODO notify GUI
		return FALSE;
	}


	// event loop
	while(phPoll() == 0){
		if(strequals(step, "quit")){
			break;
		}
		usleep(40);
	}

	return 0;
}
Beispiel #9
0
void main_platform() {
	
	if(button_read_button(&down_btn)) {
		if(is_view(gfx_mono_active_menu)) {
			if(gfx_mono_active_menu != NO_GPS_VIEW) {
				display_next_view();					
			}					
		}
		
		// If it's not a view then the down button should be used for menu navigation.
		else {
			gfx_mono_menu_process_key(&menu_list[gfx_mono_active_menu-(VIEW_MAX_INDEX+1)], GFX_MONO_MENU_KEYCODE_DOWN);
			ssd1306_write_display();	
		}

	}

	if(button_read_button(&select_btn)) {
		if(is_view(gfx_mono_active_menu)) {
			ssd1306_clear_display();
			display_menu(MAIN_MENU);
		}
		else {
			volatile uint8_t menuChoice = gfx_mono_menu_process_key(&menu_list[gfx_mono_active_menu-(VIEW_MAX_INDEX+1)], GFX_MONO_MENU_KEYCODE_ENTER);
			menu_link menu = menu_list[gfx_mono_active_menu-(VIEW_MAX_INDEX+1)].element_links[menuChoice];
		
			// TODO: Skriv om snyggare :)
			if(menu == EXIT_MENU) {
				menu_list[gfx_mono_active_menu-(VIEW_MAX_INDEX+1)].current_page = 0;
				menu_list[gfx_mono_active_menu-(VIEW_MAX_INDEX+1)].current_selection = 0;
			
			
				if(is_view(menu_list[gfx_mono_active_menu-(VIEW_MAX_INDEX+1)].parent)) {
					display_view(menu_list[gfx_mono_active_menu-(VIEW_MAX_INDEX+1)].parent);
				}
				else {
					menu = menu_list[gfx_mono_active_menu-(VIEW_MAX_INDEX+1)].parent;
					display_menu(menu);
				}
			
			}
			else {
				display_menu(menu);
			}
		}
	
	}
}
Beispiel #10
0
static Uint8	process_input(SDL_Scancode const *s, t_menuentries *item)
{
  t_menuentries	old_item;

  old_item = *item;
  *item += (*s == get_input(UP_INP)->code && *item != START_MEN) ? -1 : 0;
  *item += (*s == get_input(DOWN_INP)->code && *item != SCORE_MEN) ? 1 : 0;
  if (*s == get_input(RETURN_INP)->code)
  {
    play_sfx(get_common_sfx(BLIPCANCEL_SFX));
    set_launcher(&space_destroy);
  }
  else if (*s == get_input(START_INP)->code)
  {
    if (entries[*item].enabled)
    {
      play_sfx(get_common_sfx(BLIPOK_SFX));
      set_launcher(entries[*item].callback);
    }
  }
  if (*item != old_item)
  {
    display_menu();
    play_sfx(get_common_sfx(BLIPSEL_SFX));
    return (1);
  }
  return (0);
}
Beispiel #11
0
/**
 * \brief Set AFEC resolution mode.
 */
static void set_afec_resolution(void)
{
	uint8_t uc_key;
	uint8_t uc_done = 0;

	display_menu();

	while (!uc_done) {
		while (uart_read(CONF_UART, &uc_key));

		switch (uc_key) {
		case 'n':
			g_max_digital = MAX_DIGITAL_12_BIT;
			afec_set_resolution(AFEC0, AFEC_12_BITS);
			puts(" Set Resolution to Normal \n\r");
			break;
		case 'e':
			g_max_digital = MAX_DIGITAL_12_BIT * 16;
			afec_set_resolution(AFEC0, AFEC_16_BITS);
			puts(" Set Resolution to Enhanced \n\r");
			break;
		case 'q':
			uc_done = 1;
			puts(" Quit Configuration \n\r");
			break;
		default:
			break;
		}
	}
}
Beispiel #12
0
int
show_bmarks_menu(FileView *view, const char tags[], int go_on_single_match)
{
	static menu_info m;
	init_menu_info(&m, strdup("Bookmarks"), strdup("No bookmarks found"));
	m.execute_handler = &execute_bmarks_cb;
	m.key_handler = &bmarks_khandler;

	if(is_null_or_empty(tags))
	{
		bmarks_list(&bmarks_cb, &m);
	}
	else
	{
		bmarks_find(tags, &bmarks_cb, &m);
	}

	if(go_on_single_match && m.len == 1)
	{
		goto_selected_file(view, m.items[m.pos], 0);
		reset_popup_menu(&m);
		return curr_stats.save_msg;
	}

	return display_menu(&m, view);
}
Beispiel #13
0
int
show_volumes_menu(FileView *view)
{
	TCHAR c;
	TCHAR vol_name[MAX_PATH];
	TCHAR file_buf[MAX_PATH];

	static menu_info m;
	init_menu_info(&m, VOLUMES, strdup("No volumes mounted"));
	m.title = strdup(" Mounted Volumes ");

	for(c = TEXT('a'); c < TEXT('z'); c++)
	{
		if(drive_exists(c))
		{
			TCHAR drive[] = TEXT("?:\\");
			drive[0] = c;
			if(GetVolumeInformation(drive, vol_name, MAX_PATH, NULL, NULL, NULL,
					file_buf, MAX_PATH))
			{
				char item_buf[MAX_PATH + 5];
				snprintf(item_buf, sizeof(item_buf), "%s  %s ", drive, vol_name);
				m.len = add_to_string_array(&m.items, m.len, 1, item_buf);
			}
		}
	}

	return display_menu(&m, view);
}
Beispiel #14
0
static void inheritance_menu(ostream &out, istream &in)
{
   int choice ;
   static FrInheritanceType types[] =
	        { NoInherit, InheritSimple,
		  InheritDFS, InheritBFS,
		  InheritLocalDFS,
		} ;
   static const char *type_name[] = { "None", "Simple", "DFS", "BFS",
				      "Local-DFS"
   				    } ;

   out << "Select inheritance type (currently "
       << type_name[get_inheritance_type()] << "):" << endl ;
   choice = display_menu(out,in,false,lengthof(types),
			 0,
			 "\t1. None\n"
			 "\t2. Simple IS-A lookup\n"
			 "\t3. Full Depth-First Search\n"
			 "\t4. Breadth-First Search\n"
			 "\t5. Per-slot inheritance, then full DFS\n"
			 ) ;
   set_inheritance_type(types[choice-1]) ;
   return ;
}
Beispiel #15
0
int
show_trashes_menu(FileView *view, int calc_size)
{
	char **trashes;
	int ntrashes;
	int i;

	static menu_data_t m;
	init_menu_data(&m, view,
			format_str("%sNon-empty trash directories", calc_size ? "[  size] " : ""),
			strdup("No non-empty trash directories found"));

	m.execute_handler = &execute_trashes_cb;
	m.key_handler = &trashes_khandler;
	m.extra_data = calc_size;

	trashes = list_trashes(&ntrashes);

	show_progress(NULL, 0);
	for(i = 0; i < ntrashes; i++)
	{
		char *const item = format_item(trashes[i], calc_size);
		m.len = put_into_string_array(&m.items, m.len, item);
	}

	free_string_array(trashes, ntrashes);

	return display_menu(m.state, view);
}
Beispiel #16
0
void main_menu() {
  int selected_menu_entry;
  do {
    selected_menu_entry = display_menu();
    if(selected_menu_entry == 1) {
      // run the game
      run();
    } else if(selected_menu_entry == 2) {
      // display the highscores
      show_highscores();
    } else if(selected_menu_entry == 3) {
      // display a dialog which explains the controls of the game
      display_controls();
    } else if(selected_menu_entry == 4) {
      // display a dialog which explains the elements of the game
      display_help();
    } else if(selected_menu_entry == 5) {
      // clear highscores
      if(clear_score_dialog() == 1) {
          clear_highscore();
      }
    }
    // leave if the menu entry "exit" is chosen
  } while(selected_menu_entry != 6);
}
Beispiel #17
0
/**
 * \brief Read user input and execute menu selection
 */
void menu_run(void)
{
    static unsigned int value = 0;
    int c = uart_getchar();

    if ((c >= '0') && (c <= '9')) {
        value *= 10;
        value += c - '0';
        uart_putchar(c);
    } else if ((c == '\n') || (c == '\r')) {
        if ((value > 0) && (value <= _current_menu_size)) {
            /* Invoke the callback */
            if (_current_menu[value - 1].handler != NULL) {
                uart_puts("\n");
                if (_current_menu[value - 1].handler() != 0) {
                    uart_puts("\nError\n");
                }
            }
        } else {    
            uart_puts("\nInvalid selection\n");
        }

        display_menu();
        value = 0;
    } else {
       /* Not a valid character */ 
    }
}
Beispiel #18
0
//---------main-------------------
int main(){
	char end;
	int operation;
	
	do{
		display_menu();
		scanf("%d",&operation);
		
		switch(operation){
			case 1 :
				display_list();
				break;
			case 2 :
				push();
				break;
			case 3 :
				pop();
				break;
			default :
				printf("Error : Wronge number entered.\n");
				break;
		}
		
		printf("\n\nDo you want to end program? Enter 'y' or 'n' : ");
		end=getche();
		printf("\n\n");
	}while(end!='y');
}
Beispiel #19
0
/*
 * The hash table is to keep track of leaves which have already been displayed
 * to the user.
 */
int main(int argc, char **argv)
{
	int			i;

	/* Initialize space for blacklist hash table */
	if(hcreate(10000)==0) {
		fputs("Cannot create hash table.\n",stderr);
		return(EX_UNAVAILABLE);
	}

	i=0;
	do {
		if(read_pkglist(i++))
			break;
		if(display_menu())
			break;
		if(remove_packages())
			break;
		free_menu();
	} while(keep_going());
	hdestroy();

	fputs("\nProgram Terminated Successfully\n",stderr);
	return(0);
}
Beispiel #20
0
void load_gui(SDL_Surface *sdl_screen) {
    static Uint8 *keystate;
    int play = 0;

    if(load_bmp("fonts/gui_font.bmp") == -1) {
        printf("Loading bmp font error\n");
    }

    bg_color = SDL_MapRGB(sdl_screen->format, 255, 255, 255);
    display_menu(sdl_screen);
    cursor_pos = 0;
    while (!play) {
        SDL_PumpEvents();
        keystate = SDL_GetKeyState(NULL);
        if(keystate[SDLK_UP]) {
            move_cursor(sdl_screen, UP);
        }
        if(keystate[SDLK_DOWN]) {
            if(strcmp(selected_game, "") == 0 && cursor_pos < 2) move_cursor(sdl_screen, DOWN);
            else if (strcmp(selected_game, "") != 0 && cursor_pos < 3) move_cursor(sdl_screen, DOWN);
        }
        if(keystate[SDLK_RETURN]) play = menu_action(sdl_screen);
        if(keystate[SDLK_ESCAPE]) break;
        SDL_Flip(sdl_screen);
        SDL_Delay(100);
    }
}
Beispiel #21
0
int menu_action(SDL_Surface *sdl_screen) {
    char destination[0xFFFF];
    int action;
    action = (strcmp(selected_game, "") != 0)? cursor_pos: cursor_pos + 1;
    if(action == 0) {
        return 1;
    }
    if(action == 1) {
        if(getcwd(cwd, sizeof(cwd)) != NULL) {
            navigate(sdl_screen, cwd, destination);
            while(strcmp(destination, "") != 0 && strcmp(destination + strlen(destination) - 3, ".gb") != 0) {
                strcpy(cwd, destination);
                navigate(sdl_screen, cwd, destination);
            }
            if(strcmp(destination + strlen(destination) - 3, ".gb") == 0) {
                strcpy(selected_game,destination);
            }
            cursor_pos = 0;
            display_menu(sdl_screen);
        }
        else {
            printf("Error when getting current directory\n");
        }
    }
    else if(action == 2) {
        keyboard_conf(sdl_screen);
    }
    /*else if(action == 3){
    	joystick_conf(sdl_screen);
    }*/
    else if(action == 3) {
        exit(1);
    }
    return 0;
}
Beispiel #22
0
int popup( char* menu[], char* keys, int count, int x, int y, int border )
/*弹出式菜单的显示*/
{
	register int i, len;
	int endx, endy, choice;
	unsigned int *p;
	if((x>24)||(x<0)||(y>79)||(y<0))
	{
		printf("范围错");
		return -2;
	}
	len = 0;
	for( i = 0; i < count; i++ )
		if( strlen( menu[i]) > len ) len = strlen( menu[i] );
	endy = len + 2 + y;
	endx = count + 1 + x;
	if((endx+1>24)||(endy+1>79))
	{
		printf("菜单不匹配");
		return -2;
	}
	p = (unsigned int *) malloc((endx-x+1)*(endy-y+1));
	if( !p ) exit(1);
	save_video( x, endx + 1, y, endy+1, p );
	if( border ) disp_box( y, x, endy, endx, YELLOW );
	display_menu( menu, x + 1, y + 1, count );
	choice = get_resp( x + 1, y, count, menu, keys );
	restore_video( x, endx + 1, y, endy + 2, (unsigned char* ) p);
	free( p );
	return choice;
}
Beispiel #23
0
int main(int argc, char *argv[])
{
    MemoryManagement manager;
    char choice;
    while(1){
        display_menu();
        std::cout << "What do you want?" << std::endl;
        choice = getchar();
        switch(choice)  {
            case '1':manager.SetMemSize();system("clear");break;
            case '2':manager.SetAlgorithm();manager.flag = 1;system("clear");break;
            case '3':manager.NewProcess();manager.flag = 1;system("clear");break;
            case '4':manager.KillProcess();manager.flag = 1;system("clear");break;
            case '5':manager.DisplayMemoryUsage();manager.flag = 1;break;
            case '0':exit(1);break;
            default:break;
        }
        /*
        std::cout << "Manager Size:" << manager.mem_size << std::endl;
        std::cout << "Manager Algorithm:" << manager.ma_algorith << std::endl;
        std::cout << "Manager Pid:" << manager.pid << std::endl;
        std::cout << "Manager flag:" << manager.flag << std::endl;
        */
    }
    return EXIT_SUCCESS;
}
// Disp a specific screen
void DisplayManager::display() {
  lcd.clear(); lcd.setCursor(0, 0);

  if (display_mode == -2) {
    display_menu();
    return;
  }

  switch (display_mode) {
  case DATETIME:
    display_datetime();
    break;

  case POSITION:
    display_position();
    break;

  case ALTITUDE:
    display_altitude();
    break;

  case BATTERYM:
    display_battery();
    break;

  default:
    lcd.print(satellites);
    lcd.setCursor(0, 1);
    lcd.print(iterations);
    return;
  }
}
Beispiel #25
0
int
dosave(void)
{
    int n, selected[1];
    struct menulist menu;

    init_menulist(&menu);
    add_menuitem(&menu, 1, "Quicksave and exit the game", 'y', FALSE);
    add_menuitem(&menu, 2, "Abandon this game and delete its save file", '!',
                 FALSE);
    add_menuitem(&menu, 3, "Continue playing", 'n', FALSE);
    n = display_menu(menu.items, menu.icount, "Do you want to stop playing?",
                     PICK_ONE, PLHINT_URGENT, selected);
    free(menu.items);
    if (n)
        n = selected[0];
    else
        n = 3;

    if (n == 3) {
        if (multi > 0)
            nomul(0, NULL);
    } else if (n == 1) {
        pline("Saving...");
        if (dosave0(FALSE)) {
            program_state.something_worth_saving = 0;
            u.uhp = -1; /* universal game's over indicator */
            terminate();
        } else
            doredraw();
    } else if (n == 2) {
        return done2();
    }
    return 0;
}
Beispiel #26
0
int main()
{
    int a = 10;
    int b = 20;
    swap(&a,&b);
    char choice;
    pid=0;
    free_block = init_free_block(mem_size); //初始化空闲区
    for(;;)
    {
        display_menu();	//显示菜单
        fflush(stdin);
        choice=getchar();	//获取用户输入
        switch(choice)
        {
            case '1': set_mem_size(); break; 	//设置内存大小
            case '2': set_algorithm();flag=1; break;	//设置分配算法
            case '3': new_process(); flag=1; break;	//创建新进程
            case '4': kill_process();flag=1; break;	//删除进程
            case '5': display_mem_usage(); flag=1; break;	//显示内存使用
            case '0': do_exit(); exit(0);		//释放链表并退出
            default: break;
        }
        getchar();
    }
}
Beispiel #27
0
int
dohistory(const struct nh_cmd_arg *arg)
{
    struct nh_menulist menu;
    boolean over = program_state.gameover;
    boolean showall = over || wizard;
    int i;

    (void) arg;

    if (histcount < 2) {
        /* you get an automatic entry on turn 1 for being born. If it's the
           only one, there is nothing worth reporting */
        if (!over)
            pline(msgc_info, "History has not recorded anything about you.");
        return 0;
    }

    init_menulist(&menu);

    for (i = 0; i < histcount; i++) {
        if (histevents[i].hidden && !showall)
            continue;
        add_menutext(&menu, msgprintf("On T:%u you %s", histevents[i].when,
                                      histevents[i].what));
    }

    display_menu(&menu, "History has recorded:", PICK_NONE,
                 PLHINT_ANYWHERE, NULL);

    return 0;
}
Beispiel #28
0
void menu_main(){
  switch(current_function)//get current function and make decision based on it
  {
    case 0: //function 0 log
      if(!isShowingLog) show_log(); //if the log isnt showing show it
        if(nNxtButtonPressed == 2){ //if we are pressing left
          while(nNxtButtonPressed == 2); //must click and release to scroll another line
          scroll_down();
        }
        if(nNxtButtonPressed == 1){ //if we are pressing right
          while(nNxtButtonPressed==1); //must click and release to scroll another line
          scroll_up();
        }
    break;
    case 1: //function 1 menu
      display_menu();
    break;
  }
  if(nNxtButtonPressed==3 && current_function!=1){ //if we press enter and are not on menu
    while(nNxtButtonPressed==3); //dont allow double reads. you have to release before anything happens
    hide_log(); //hide the menu. cant hurt
    previous_function=current_function; //save the old function number
    current_function=1; //set the current function to menu
  }
}
Beispiel #29
0
int
show_undolist_menu(FileView *view, int with_details)
{
	char **p;
	size_t len;

	static menu_info m;
	init_menu_info(&m, UNDOLIST_MENU, strdup("Undolist is empty"));
	m.current = get_undolist_pos(with_details) + 1;
	m.pos = m.current - 1;
	m.title = strdup(" Undolist ");

	m.items = undolist(with_details);
	p = m.items;
	while(*p++ != NULL)
		m.len++;

	if(m.len > 0)
	{
		m.len = add_to_string_array(&m.items, m.len, 1, "list end");

		/* Add current position mark to menu item. */
		len = (m.items[m.pos] != NULL) ? strlen(m.items[m.pos]) : 0;
		m.items[m.pos] = realloc(m.items[m.pos], len + 1 + 1);
		memmove(m.items[m.pos] + 1, m.items[m.pos], len + 1);
		m.items[m.pos][0] = '*';
	}

	return display_menu(&m, view);
}
Beispiel #30
0
/*
 * the main method (including program loop)
 */
int main(int argc, char* argv[]) {
  Event* event = read_data();
  int running = 1;
  int input;
	int t_index = 0; /* the index for the times */
	char* times_file;
	char* log_file;

	printf("Please enter times file: ");
	times_file = readline();
	printf("Please enter log file: ");
	log_file = readline();

	t_index = refresh(event, times_file, t_index);
  display_event_header(event);
  while (running) {
    input = display_menu(event);
		t_index = refresh(event, times_file, t_index);
    switch (input) {
      case 1:
        locate_entrant(event);
				append_to_file(log_file, "EM: entrant query");
        break;
      case 2:
        printf("\t%d\n", count_by_status(event, NOT_STARTED));
				append_to_file(log_file, "EM: entrants counted - not started");
        break;
      case 3:
        printf("\t%d\n", count_by_status(event, STARTED) + count_by_status(event, STOPPED));
				append_to_file(log_file, "EM: entrants counted - running");
        break;
      case 4:
        printf("\t%d\n", count_by_status(event, FINISHED));
				append_to_file(log_file, "EM: entrants counted - finished");
        break;
      case 5:
        list_excluded_safety(event);
				append_to_file(log_file, "EM: entrants listed - excluded");
        break;
      case 6:
        list_excluded_incorrect(event);
				append_to_file(log_file, "EM: entrants listed - disqualified");
        break;
      case 7:
        display_results(event);
				append_to_file(log_file, "EM: results displayed");
        break;
      case 8:
        running = 0;
				append_to_file(log_file, "EM: quitting");
        break;
      default:
        /* invalid input, do nothing */
        break;
    }
  }

  return EXIT_SUCCESS;
}