📄 monitor.c
字号:
Mini_TIP_SetCurrSession(Session_ids[i]); Mini_TIP_DestroyProc(); Mini_TIP_exit(); }; fflush(stdout); fflush(stderr); exit_loop = TRUE; NumberOfConnections=0; return ((INT32) 0);}INT32connect_cmd(token, tokencnt)char **token;int tokencnt;{ INT32 retval; if (tokencnt < 2) return (EMSYNTAX); if ((retval = Mini_TIP_init(token[1], &Session_ids[NumberOfConnections])) == SUCCESS) { NumberOfConnections=NumberOfConnections+1; }; return ((INT32) retval);}INT32disconnect_cmd(token, tokencnt)char **token;int tokencnt;{ INT32 retval; int i; if ((retval = Mini_TIP_disc()) != SUCCESS) return ((INT32) retval); else { /* find some other session */ NumberOfConnections=NumberOfConnections - 1; for (i = 0; i < NumberOfConnections; i++) { if ((retval = Mini_TIP_SetCurrSession(Session_ids[i])) == SUCCESS) return (retval); } if (i >= NumberOfConnections) { /* exit DFE */ exit_loop = TRUE; } } return ((INT32) retval);}INT32create_proc_cmd(token, tokencnt)char **token;int tokencnt;{ INT32 retval; retval = Mini_TIP_CreateProc(); return ((INT32) retval);}INT32capab_cmd(token, tokencnt)char **token;int tokencnt;{ INT32 retval; retval = Mini_TIP_Capabilities(); return ((INT32) retval);}INT32exit_conn_cmd(token, tokencnt)char **token;int tokencnt;{ INT32 retval; int i; if ((retval = Mini_TIP_exit()) != SUCCESS) {; return (retval); } else { /* find some other session */ NumberOfConnections=NumberOfConnections - 1; for (i = 0; i < NumberOfConnections; i++) { if ((retval = Mini_TIP_SetCurrSession(Session_ids[i])) == SUCCESS) return (retval); } if (i >= NumberOfConnections) { /* exit DFE */ exit_loop = TRUE; } } return ((INT32) retval);}INT32init_proc_cmd(token, tokencnt)char **token;int tokencnt;{ INT32 retval; retval = Mini_send_init_info(&init_info); return ((INT32) retval);}INT32destroy_proc_cmd(token, tokencnt)char **token;int tokencnt;{ INT32 retval; retval = Mini_TIP_DestroyProc(); return ((INT32) retval);}INT32set_sessionid_cmd(token, tokencnt)char **token;int tokencnt;{ INT32 retval; int sid; if (tokencnt < 2) return (EMSYNTAX); if (sscanf(token[1],"%d",&sid) != 1) return (EMSYNTAX); retval = Mini_TIP_SetCurrSession(sid); return ((INT32) retval);}INT32set_pid_cmd(token, tokencnt)char **token;int tokencnt;{ INT32 retval; int pid; if (tokencnt < 2) return (EMSYNTAX); if (sscanf(token[1],"%d",&pid) != 1) return (EMSYNTAX); retval = Mini_TIP_SetPID(pid); return ((INT32) retval);}INT32go_cmd(token, token_count) char *token[]; int token_count; { INT32 retval; if ((retval = Mini_go()) != SUCCESS) { return(FAILURE); } else { GoCmdFlag = 1; BlockMode = NONBLOCK; if (TipStdinMode & TIP_NBLOCK) io_config.io_control = TERM_29K; else if (TipStdinMode & TIP_ASYNC) io_config.io_control = TERM_29K; else if (TipStdinMode == TIP_COOKED) io_config.io_control = TERM_USER; else { TipStdinMode = TIP_COOKED; io_config.io_control = TERM_USER; } io_config.target_running = TRUE; return(SUCCESS); };} /* end go_cmd() *//*** This command is used to "trace" or step through code.** A "t" command with no parameters defaults to a single.** step. A "t" command with an integer value following** steps for as many instructions as is specified by** that integer.*/INT32trace_cmd(token, token_count) char *token[]; int token_count; { int result; INT32 count; INT32 retval; if (token_count == 1) { count = 1; } else if (token_count >= 2) { result = get_word(token[1], &count); if (result != 0) return (EMSYNTAX); } if ((retval = Mini_step(count)) != SUCCESS) { return(FAILURE); } else { GoCmdFlag = 1; BlockMode = NONBLOCK; if (TipStdinMode & TIP_NBLOCK) io_config.io_control = TERM_29K; else if (TipStdinMode & TIP_ASYNC) io_config.io_control = TERM_29K; else if (TipStdinMode == TIP_COOKED) io_config.io_control = TERM_USER; else { TipStdinMode = TIP_COOKED; io_config.io_control = TERM_USER; } io_config.target_running = TRUE; return(SUCCESS); } } /* end trace_cmd() *//* * The "ch0" command is used to send characters (input) to the application * program asynchronously. This command deinstalls the control-C handler, * sets up input to raw mode, polls the keyboard, sends the bytes to the * TIP. The command is exited when Ctrl-U is typed. */INT32channel0_cmd(token, token_count) char *token[]; int token_count;{ io_config.io_control = TERM_29K;#ifndef MSDOS ioctl (fileno(stdin), TCGETA, &NewTermbuf); /* New settings */ NewTermbuf.c_lflag &= ~(ICANON); NewTermbuf.c_cc[4] = 0; /* MIN */ NewTermbuf.c_cc[5] = 0; /* TIME */ ioctl (fileno(stdin), TCSETA, &NewTermbuf); /* Set new settings */#endif return (0);}/* * Only for stdin, not for command file input */INT32Mini_poll_channel0(){ BYTE ch; /* read from terminal */#ifdef MSDOS /* CBREAK mode */ if (kbhit()) { ch = (unsigned char) getche(); if (io_config.echo_mode == (INT32) TRUE) { putc (ch, io_config.echo_file); fflush (io_config.echo_file); } if (ch == (BYTE) TOGGLE_CHAR) { /* Ctrl-U typed, give control back to User */ io_config.io_control = TERM_USER; display_termuser(); return (0); } else { if (ch == (unsigned char) 13) { /* \r, insert \n */ putchar(10); /* line feed */ if (io_config.echo_mode == (INT32) TRUE) { putc (ch, io_config.echo_file); fflush (io_config.echo_file); } }#ifdef MSDOS if (ch == (unsigned char) 10) { /* \n, ignore \n */ return (0); }#endif Mini_put_stdin((char *)&ch, 1, &io_count_done); return (0); } } return(0);#else /* Unix */ /* * Set STDIN to CBREAK mode. For each character read() send it * to TIP using Mini_put_stdin(). This is done only if the * terminal is controlled by the 29K Target System, i.e. when * io_config.io_control == TERM_29K. Otherwise, this function should * not be called as it would affect the command-line processing. */ /* while ((io_bufsize = read (fileno(stdin), &ch, 1)) == 1) { */ if ((io_bufsize = read (fileno(stdin), &ch, 1)) == 1) { if (io_config.echo_mode == (INT32) TRUE) { putc (ch, io_config.echo_file); fflush (io_config.echo_file); } if (ch == (BYTE) TOGGLE_CHAR) { /* process ctrl-U */ ioctl (fileno(stdin), TCSETA, &OldTermbuf); /* reset old settings */ io_config.io_control = TERM_USER; display_termuser(); return (0); } else { /* send it to TIP */ Mini_put_stdin((char *)&ch, 1, &io_count_done); } } return (0);#endif} /* end Mini_poll_channel0() */voidPrintTrapMsg(num)int num;{ if ((num >= 0) && (num <= 22)) { fprintf(stderr, "%s Trap occurred at ", TrapMsg[num]); if (io_config.echo_mode == (INT32) TRUE) fprintf(io_config.echo_file, "%s Trap occurred at ", TrapMsg[num]); } else { fprintf(stderr, "Trap %d occurred at "); if (io_config.echo_mode == (INT32) TRUE) fprintf(io_config.echo_file, "Trap %d occurred at "); }}voiddisplay_term29k(){ fprintf(stderr,"\nTerminal controlled 29K target...Type Ctrl-U <ret> for mondfe prompt\n"); fflush (stderr); if (io_config.echo_mode == (INT32) TRUE) fprintf(stderr,"\nTerminal controlled 29K target...Type Ctrl-U <ret> for mondfe prompt\n");#ifndef MSDOS ioctl (fileno(stdin), TCGETA, &NewTermbuf); /* New settings */ NewTermbuf.c_lflag &= ~(ICANON); NewTermbuf.c_cc[4] = 0; /* MIN */ NewTermbuf.c_cc[5] = 0; /* TIME */ ioctl (fileno(stdin), TCSETA, &NewTermbuf); /* Set new settings */#endif}voiddisplay_termuser(){#ifndef MSDOS ioctl (fileno(stdin), TCSETA, &OldTermbuf); /*reset settings */#endif /* Print a prompt */ fprintf(stderr, "\n%s>", ProgramName); if (io_config.echo_mode == (INT32) TRUE) fprintf(io_config.echo_file, "\n%s>", ProgramName);}INT32quietmode_off(token, token_count) char *token[]; int token_count;{ QuietMode = 0; return (0);}INT32quietmode_on(token, token_count) char *token[]; int token_count;{ QuietMode = 1; return (0);}INT32logoff_cmd(token, token_count) char *token[]; int token_count;{ if (io_config.log_mode == (INT32) TRUE) { io_config.log_mode = (INT32) FALSE; (void) fclose(io_config.log_file); } return (0);}INT32logon_cmd(token, token_count) char *token[]; int token_count;{ if (io_config.log_mode == (INT32) FALSE) { if (strcmp(io_config.log_filename, "\0") != 0) {/* valid file */ io_config.log_mode = (INT32) TRUE; if ((io_config.log_file = fopen(io_config.log_filename, "a")) == NULL) { io_config.log_mode = (INT32) FALSE; warning(EMLOGOPEN); }; } else { warning(EMLOGOPEN); } } return (0);}INT32set_logfile(token, token_count) char *token[]; int token_count;{ if (token_count < 2) /* insufficient number of args */ return (EMSYNTAX); (void) strcpy ((char *)(&(io_config.log_filename[0])),token[1]); if (io_config.log_mode == (INT32) TRUE) { /* replace log file used */ if ((io_config.log_file = fopen (io_config.log_filename, "w")) == NULL) { warning (EMLOGOPEN); io_config.log_mode = (INT32) FALSE; } } else { io_config.log_mode = (INT32) TRUE; if ((io_config.log_file = fopen (io_config.log_filename, "w")) == NULL) { warning (EMLOGOPEN); io_config.log_mode = (INT32) FALSE; } } return (0);}INT32echomode_on(token, token_count) char *token[]; int token_count;{ if (io_config.echo_mode == (INT32) FALSE) { if (strcmp(io_config.echo_filename, "\0") != 0) { /* if valid file in effect */ io_config.echo_mode = (INT32) TRUE; if ((io_config.echo_file = fopen (io_config.echo_filename, "a")) == NULL) { warning (EMECHOPEN); io_config.echo_mode = (INT32) FALSE; } } else warning(EMINVECHOFILE); } return (0);}INT32echomode_off(token, token_count) char *token[]; int token_count;{ if (io_config.echo_mode == (INT32) TRUE) { io_config.echo_mode = (INT32) FALSE; (void) fclose(io_config.echo_file); } return (0);}INT32echofile_cmd(token, token_count) char *token[]; int token_count;{ if (token_count < 2) /* insufficient number of args */ return (EMSYNTAX); (void) strcpy ((char *)(&(io_config.echo_filename[0])),token[1]); if (io_config.echo_mode == (INT32) TRUE) { /* replace echo file used */ if ((io_config.echo_file = fopen (io_config.echo_filename, "w")) == NULL) { warning (EMECHOPEN); io_config.echo_mode = (INT32) FALSE; } } else { io_config.echo_mode = (INT32) TRUE; if ((io_config.echo_file = fopen (io_config.echo_filename, "w")) == NULL) { warning (EMECHOPEN); io_config.echo_mode = (INT32) FALSE; } } return (0);}INT32cmdfile_cmd(token, token_count) char *token[]; int token_count;{ if (token_count < 2) return (EMSYNTAX); (void) strcpy((char *)(&(io_config.cmd_filename[0])),token[1]); if (io_config.cmd_file_io == (INT32) TRUE) { warning (EMCMDFILENEST); /* command file nesting not allowed */ } else { io_config.cmd_file_io = (INT32) TRUE; if ((io_config.cmd_file = fopen (io_config.cmd_filename,"r")) == NULL) { warning (EMCMDOPEN); io_config.cmd_file_io = (INT32) FALSE; } else { /* MON_STDIN is command file */ MON_STDIN = fileno(io_config.cmd_file); /* set MON_STDIN */ } } return (0);}INT32tip_cmd(token, token_count) char *token[]; int token_count;{ if (token_count < 2) return (EMSYNTAX); sprintf(tip_cmd_buffer, "%s %s\0", token[0], token[1]); Mini_put_trans(tip_cmd_buffer); return (0);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -