📄 scurses.c
字号:
wmove(win,1,54); waddch(win,(status) ? 'R' : ' '); wmove(win,1,54); wrefresh(win);} /* end of report_rx_ind *//*+------------------------------------------------------------------------- report_tx_ind(status)--------------------------------------------------------------------------*/voidreport_tx_ind(status)int status;{ wmove(win,1,56); waddch(win,(status) ? 'T' : ' '); wmove(win,1,56); wrefresh(win);} /* end of report_tx_ind *//*+------------------------------------------------------------------------- report_rx_tx_count() rx char count: row 6 col 16 length 8 unsigned long tx char count: row 6 col 29 length 8 unsigned long now time of day: row 1 col 50 length 8 hh:mm:ss This procedure may be counted upon to perform wrefresh(win)elapsed time row 9 col 26 length 8current tod row 9 col 47 length 8--------------------------------------------------------------------------*/report_rx_tx_count(){ extern unsigned long rx_char_count; extern unsigned long tx_char_count; register char *cptr; sprintf(s128,"%8ld",rx_char_count); wmove(win,6,16); waddstr(win,s128); sprintf(s128,"%8ld",tx_char_count); wmove(win,6,29); waddstr(win,s128); /* now time of day */ clear_area(win,9,47,8); cptr = hhmmss((char *)0); waddstr(win,cptr); current_seconds = time((long *)0); elapsed_seconds = current_seconds - start_seconds; cptr = get_elapsed_time(elapsed_seconds); clear_area(win,9,26,8); waddstr(win,cptr); wrefresh(win); /* calling procs expect this to occur always */} /* end of report_rx_tx_count *//*+------------------------------------------------------------------------- report_line(baud_rate,mode)--------------------------------------------------------------------------*/voidreport_line(baud_rate,mode)unsigned baud_rate;char *mode;{char s16[16]; wmove(win,7,14); sprintf(s16,"%5u",baud_rate); waddstr(win,s16); clear_area(win,7,52,6); waddstr(win,mode); wrefresh(win);} /* end of report_line *//*+------------------------------------------------------------------------- report_rxpos(pos) row 3 col 19 len 8--------------------------------------------------------------------------*/voidreport_rxpos(pos)long pos;{char tmp[16];char refr; if(rdchk(0)) { read(0,&refr,1); if(refr == 0x0C || refr == 0x012) /* ^L or ^R */ { write(2,"\033[2J",4); Nap((long)60); touchwin(stdscr); wrefresh(stdscr); touchwin(win); wrefresh(win); } } if((pos > 99999999L) || (pos < 0L)) return; sprintf(tmp,"%8lu",pos); wmove(win,3,19); waddstr(win,tmp); wrefresh(win); report_rx_tx_count(); /* which will do a refresh */} /* end of report_rxpos *//*+------------------------------------------------------------------------- report_txpos(pos)--------------------------------------------------------------------------*/voidreport_txpos(pos)long pos;{ report_rxpos(pos);} /* end of report_txpos *//*+------------------------------------------------------------------------- report_last_txhdr(rptstr,error_flag) 5,7,22--------------------------------------------------------------------------*/voidreport_last_txhdr(rptstr,error_flag)register char *rptstr;int error_flag;{char s24[24]; if(log_packets) { write(log_packets,"tx: ",6); write(log_packets,rptstr,strlen(rptstr)); write(log_packets,"\n",1); } if(strlen(rptstr) > 22) { strncpy(s24,rptstr,22); s24[23] = 0; rptstr = s24; } clear_area(win,5,7,22); waddstr(win,rptstr); wrefresh(win); if(error_flag) { ++this_file_errors; ++total_errors; report_error_count(); }} /* end of report_last_txhdr *//*+------------------------------------------------------------------------- report_last_rxhdr(rptstr,error_flag) 5,35,22--------------------------------------------------------------------------*/voidreport_last_rxhdr(rptstr,error_flag)register char *rptstr;int error_flag;{char s24[24];extern int log_packets; if(log_packets) { write(log_packets,"rx: ",4); write(log_packets,(error_flag) ? "E " : " ",2); write(log_packets,rptstr,strlen(rptstr)); write(log_packets,"\n",1); } if(strlen(rptstr) > 22) { strncpy(s24,rptstr,22); s24[23] = 0; rptstr = s24; } clear_area(win,5,35,22); waddstr(win,rptstr); wrefresh(win); if(error_flag) { ++this_file_errors; ++total_errors; report_error_count(); }} /* end of report_last_rxhdr *//*+------------------------------------------------------------------------- report_str(rptstr,error_flag) row 11/12 col 3 len 55 error_flag == 0 for status/progress message == 1 for bump error count, unless rptstr is null in which case, merely clear error string area == 2 write string on bottom line (not an error) == 3 write string on transaction line (not an error) == -1 use error line but do not bump error count--------------------------------------------------------------------------*/voidreport_str(rptstr,error_flag)register char *rptstr;int error_flag;{char s60[60];extern int log_packets; if(strlen(rptstr) > 55) { strncpy(s60,rptstr,55); s60[56] = 0; rptstr = s60; } switch(error_flag) { case 0: clear_area(win,12,3,55); break; case 1: ++this_file_errors; ++total_errors; report_error_count(); case -1: clear_area(win,11,3,55); break; case 2: clear_area(win,13,3,55); break; case 3: clear_area(win,4,3,55); break; } waddstr(win,rptstr); wrefresh(win); if(log_packets) { write(log_packets,"info: ",6); sprintf(s60,"%2d ",error_flag); write(log_packets,s60,3); write(log_packets,rptstr,strlen(rptstr)); write(log_packets,"\n",1); }} /* end of report_str *//*+------------------------------------------------------------------------- report_transaction()--------------------------------------------------------------------------*/voidreport_transaction(str)char *str;{ report_str(str,3);} /* end of report_transaction *//*+------------------------------------------------------------------------- report_file_open_tod() -- time of start of this file this file open time: row 8 col 47 length 8--------------------------------------------------------------------------*/voidreport_file_open_tod(){ clear_area(win,8,47,8); waddstr(win,hhmmss((char *)0)); wrefresh(win);} /* end of report_file_open_tod *//*+------------------------------------------------------------------------- report_file_open_length(long_length) length: row 3 col 36 len 8--------------------------------------------------------------------------*/report_file_open_length(length)long length;{ clear_area(win,3,36,8); if(length <= 0) waddstr(win,"unknown"); else { sprintf(s128,"%8lu",length); waddstr(win,s128); } wrefresh(win);} /* end of report_file_open_length *//*+------------------------------------------------------------------------- report_file_send_open(filename,filestat) filename: row 2 col 20 len 38 number: row 2 col 8 len 3 length: row 3 col 36 len 8 mode: row 3 col 46 len 10 time of start of this file: row 4 col 47 length 8 hh:mm:ss--------------------------------------------------------------------------*/voidreport_file_send_open(filename,filestat)char *filename;struct stat *filestat;{char s50[50];register char *cptr = filename; if(log_packets) { write(log_packets,"file: ",6); write(log_packets,filename,strlen(filename)); write(log_packets,"\n",1); } /* number */ clear_area(win,2,8,3); sprintf(s50,"%3d",Filcnt); waddstr(win,s50); /* filename */ if(strlen(filename) > 38) { strncpy(s50,filename,38); s50[39] = 0; cptr = s50; } clear_area(win,2,20,38); waddstr(win,cptr);#if defined(LOG_XFER) sprintf(s128,"sending %s",filename); ecu_log_event(getppid(),s128);#endif /* length */ report_file_open_length(filestat->st_size); /* time of start of this file */ report_file_open_tod(); this_file_errors = 0; report_error_count();} /* end of report_file_send_open *//*+------------------------------------------------------------------------- report_file_rcv_started(filename,length,last_mod_time) filename: row 2 col 7 len 50 length: row 3 col 36 len 8 if not xmodem time of start of this file: row 4 col 47 length 8 hh:mm:ss--------------------------------------------------------------------------*/report_file_rcv_started(filename,length,last_mod_time)char *filename;long length; /* if < 0, "UNKNOWN" */long last_mod_time; /* not currently displayed */{register char *cptr;char s50[50]; if(log_packets) { write(log_packets,"file: ",6); write(log_packets,filename,strlen(filename)); write(log_packets,"\n",1); } /* filename */ if(strlen(filename) > 38) { strncpy(s50,filename,38); s50[39] = 0; cptr = s50; } else cptr = filename;#if defined(LOG_XFER) sprintf(s128,"receiving %s",filename); ecu_log_event(getppid(),s128);#endif clear_area(win,2,20,38); waddstr(win,cptr); /* file number */ clear_area(win,2,8,3); sprintf(s50,"%3d",Filcnt); /* rz uses as file number 1-n */ waddstr(win,s50);/* if remote sender provides a file count, display it */ if(npaths) { clear_area(win,2,12,7); /* clear "of ###" */ sprintf(s50,"of %3d:",npaths); waddstr(win,s50); } /* length */ report_file_open_length(length); /* time of start of this file */ report_file_open_tod(); this_file_errors = 0; report_error_count();} /* end of report_file_rcv_started *//*+------------------------------------------------------------------------- report_file_close()--------------------------------------------------------------------------*/void report_file_close(){ report_str("End of file",0); wrefresh(win);} /* end of report_file_close *//*+------------------------------------------------------------------------- report_file_byte_io(count)--------------------------------------------------------------------------*/report_file_byte_io(count)long count;{ total_data_chars_xfered += (long)count; if(total_data_chars_xfered) { sprintf(s128,"Total file bytes transferred: %lu", total_data_chars_xfered); report_str(s128,-1); }} /* end of report_file_byte_io *//* end of scurses.c *//* vi: set tabstop=4 shiftwidth=4: */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -