Exemplo n.º 1
0
void ui_mainloop() {
	init_wp_list();
	while(1) {
		char *str = rl_gets();
		char *str_end = str + strlen(str);


		/* extract the first token as the command */
		char *cmd = strtok(str, " ");
		if(cmd == NULL) { continue; }

		/* treat the remaining string as the arguments,
		 * which may need further parsing
		 */
		char *args = cmd + strlen(cmd) + 1;
		if(args >= str_end) {
			args = NULL;
		}

#ifdef HAS_DEVICE
		extern void sdl_clear_event_queue(void);
		sdl_clear_event_queue();
#endif

		int i;
		for(i = 0; i < NR_CMD; i ++) {
			if(strcmp(cmd, cmd_table[i].name) == 0) {
				if(cmd_table[i].handler(args) < 0) { return; }
				break;
			}
		}

		if(i == NR_CMD) { printf("Unknown command '%s'\n", cmd); }
	}
}
Exemplo n.º 2
0
void init_monitor(int argc, char *argv[]) {
    /* Perform some global initialization */

    /* Open the log file. */
    init_log();

    /* Load the string table and symbol table from the ELF file for future use. */
    load_elf_tables(argc, argv);

    /* Compile the regular expressions. */
    init_regex();

    /* Initialize the watchpoint link list. */
    init_wp_list();

    /* Display welcome message. */
    welcome();
}