⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 zcurses.c

📁 一个通讯程序源码
💻 C
📖 第 1 页 / 共 3 页
字号:
			sprintf(s128,"XFERINFO %s rate ~= %.0f ch/sec (%.0lf%%)",				text,rate,efficiency);		}		if(!dumbtty)			report_top_line(s128 + 9);#if defined(WHT)		if(final)			ecu_log_event(getppid(),s128);#endif	}}	/* end of report_file_xfer_rate *//*+-------------------------------------------------------------------------	report_transfer_progress(filepos,initfpos)--------------------------------------------------------------------------*/voidreport_transfer_progress(filepos,initfpos)long filepos;long initfpos;{char refr;	if(dumbtty)		return;	if(rdchk(0))	{		read(0,&refr,1);		if(refr == 0x0C || refr == 0x012)	/* ^L or ^R */		{			touchwin(stdscr);			wrefresh(stdscr);			touchwin(win);			wrefresh(win);		}	}	if((filepos > 99999999L) || (filepos < 0L))		return;	sprintf(s128,"%-8lu",filepos);	wmove(win,3,19);	waddstr(win,s128);	report_file_xfer_rate("data",filepos - initfpos,0);	report_rx_tx_count();	/* which will do a refresh */}	/* end of report_transfer_progress *//*+-------------------------------------------------------------------------	report_rxpos(pos) - report received file progress--------------------------------------------------------------------------*/voidreport_rxpos(pos)long pos;{	if(dumbtty)		return;	report_transfer_progress(pos,initial_filepos);}	/* end of report_rxpos *//*+-------------------------------------------------------------------------	report_txpos(pos) - report transmitted file progress--------------------------------------------------------------------------*/voidreport_txpos(pos)long pos;{	if(dumbtty)		return;	report_transfer_progress(pos,initial_filepos);}	/* end of report_txpos *//*+-------------------------------------------------------------------------	report_error_count()  this file: row 10 col 22 len 3  total:     row 10 col 33 len 4  skipped:   row 10 col 53 len 3--------------------------------------------------------------------------*/voidreport_error_count(){	char tmp[16];	if(dumbtty)	{		return;	}	wmove(win,10,22);	sprintf(tmp,"%-3d",this_file_errors);	if(this_file_errors)		wstandout(win);	waddstr(win,tmp);	if(this_file_errors)		wstandend(win);	wmove(win,10,33);	sprintf(tmp,"%-4d",total_errors);	if(total_errors)		wstandout(win);	waddstr(win,tmp);	if(total_errors)		wstandend(win);	wmove(win,10,53);	sprintf(tmp,"%-3d",skip_count);	waddstr(win,tmp);	wrefresh(win);}	/* end of report_error_count *//*+-------------------------------------------------------------------------	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(dumbtty)	{		if(error_flag)		{			dumbtty_newline();			dumbtty_pos = printf("%s ",rptstr);			++this_file_errors;			++total_errors;		}		return;	}	if(strlen(rptstr) > 22)	{		strncpy(s24,rptstr,22);		s24[23] = 0;		rptstr = s24;	}	clear_area(win,5,7,22);	waddstr(win,rptstr);	if(error_flag)	{		++this_file_errors;		++total_errors;		report_error_count();	}#if 0	else		wrefresh(win);#endif}	/* 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:   ",6);		write(log_packets,rptstr,strlen(rptstr));		write(log_packets,"\n",1);	}	if(dumbtty)	{		if(error_flag)		{			dumbtty_newline();			dumbtty_pos = printf("%s ",rptstr);			++this_file_errors;			++total_errors;		}		return;	}	if(strlen(rptstr) > 22)	{		strncpy(s24,rptstr,22);		s24[23] = 0;		rptstr = s24;	}	clear_area(win,5,35,22);	waddstr(win,rptstr);	report_window();	if(error_flag)	{		++this_file_errors;		++total_errors;		report_error_count();	}#if 0	else		wrefresh(win);#endif}	/* 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(log_packets)	{		sprintf(s60,"rpt %d:",error_flag);		write(log_packets,s60,strlen(s60));		write(log_packets,rptstr,strlen(rptstr));		write(log_packets,"\n",1);	}	if(dumbtty)	{		if(!strlen(rptstr))			return;		switch(error_flag)		{			case 0:				break;			case 1:				this_file_errors++;				total_errors++;			case -1:			case 2:			case 3:				dumbtty_newline();				dumbtty_pos = printf("%s ",rptstr);				fflush(stdout);		}		return;	}	if(strlen(rptstr) > 55)	{		strncpy(s60,rptstr,55);		s60[55] = 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);}	/* 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 41 length 8--------------------------------------------------------------------------*/voidreport_file_open_tod(){	if(dumbtty)		return;	clear_area(win,8,41,8);	waddstr(win,get_tod(1,(char *)0));	wrefresh(win);}	/* end of report_file_open_tod *//*+-------------------------------------------------------------------------	report_file_open_mode(file_mode)  mode map: row 4 col 46 len 10--------------------------------------------------------------------------*/report_file_open_mode(file_mode)unsigned short file_mode;{	if(dumbtty)		return;	clear_area(win,3,46,10);	waddstr(win,mode_map(file_mode,(char *)0));	wrefresh(win);}	/* end of report_file_open_mode *//*+-------------------------------------------------------------------------	report_file_open_length(long_length)  length:   row 3 col 36 len  8--------------------------------------------------------------------------*/report_file_open_length(length)long length;{	if(dumbtty)		return;	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);	}	this_file_start_seconds = time((long *)0);	this_file_xfer_count = 0;	if(dumbtty)	{		dumbtty_newline();		dumbtty_pos = printf("Sending '%s' ",filename);		fflush(stdout);		return;	}	/* 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);	/* length */	report_file_open_length(filestat->st_size);	/* mode */	report_file_open_mode(filestat->st_mode);	/* 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,file_mode)  filenumber: row 2 col  8 len  3              row 2 col 12 len  7 clear "of ###"  filename:   row 2 col 20 len 38--------------------------------------------------------------------------*/report_file_rcv_started(filename,length,last_mod_time,file_mode)char *filename;long length;				/* if < 0, "UNKNOWN" */long last_mod_time;			/* not currently displayed */unsigned short file_mode;	/* UNIX file modifier or zero */{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);	}	this_file_start_seconds = time((long *)0);	this_file_xfer_count = 0;	if(dumbtty)	{		dumbtty_newline();		dumbtty_pos = printf("Receiving '%s' ",filename) - 2;		fflush(stdout);		return;	}	/* filename */	if(strlen(filename) > 38)	{		strncpy(s50,filename,38);		s50[39] = 0;		cptr = s50;	}	else		cptr = filename;	clear_area(win,2,20,38);	waddstr(win,cptr);	/* file number */	clear_area(win,2,8,3);	Filcnt++;	sprintf(s50,"%-3d",Filcnt);	/* rz uses as file number 1-n */	waddstr(win,s50);/* if remote sender provides a file count, display it */	if(npats)	{		clear_area(win,2,12,7);	/* clear "of ###" */		sprintf(s50,"of %3d:",npats);		waddstr(win,s50);	}	/* length */	report_file_open_length(length);	/* mode */	report_file_open_mode(file_mode);	/* 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(skipped)--------------------------------------------------------------------------*/void report_file_close(skipped)int skipped;{	if(dumbtty)	{		dumbtty_newline();		dumbtty_pos +=			printf("Transfer time was %s",get_elapsed_time(elapsed_seconds));		dumbtty_newline();		if(s128[0])		{			dumbtty_pos += strlen(s128 + 9);			fputs(s128 + 9,stdout);			dumbtty_newline();		}		if(this_file_errors)		{			dumbtty_pos +=				printf("Errors for this file were %d",this_file_errors);			dumbtty_newline();		}		return;	}	if(show_window)	{		clear_area(win,9,50,8);		waddstr(win,"+0");		Txpos = 0;		Rxpos = 0;	}	report_str("End of file",0);	if(!skipped)	{		report_file_xfer_rate("last file",			this_file_xfer_count - initial_filepos,1);	}	wrefresh(win);	this_file_start_seconds = 0;}	/* end of report_file_close *//*+-------------------------------------------------------------------------	report_comm_baud_rate(baud_rate) baud rate: row 7 col 14 length 5--------------------------------------------------------------------------*/report_comm_baud_rate(baud_rate)unsigned int baud_rate;{	char tstr8[8];	zcurses_baud_rate = baud_rate;	if(dumbtty)	{		return;	}	clear_area(win,7,14,5);	if(baud_rate == 0)		waddstr(win,"?");	else	{		sprintf(tstr8,"%-5u",baud_rate);		waddstr(win,tstr8);	}	wrefresh(win);}	/* end of report_comm_baud_rate *//*+-------------------------------------------------------------------------	report_file_byte_io(count)--------------------------------------------------------------------------*/report_file_byte_io(count)long count;{	this_file_xfer_count = count;	total_data_bytes_xfered += count;	if(dumbtty)	{		if(count)		{			dumbtty_newline();			printf("Transferred %ld bytes for this file\n",count);			dumbtty_newline();		}		return;	}	if(total_data_bytes_xfered)	{		sprintf(s128,"Total file bytes transferred: %ld",			total_data_bytes_xfered);		report_str(s128,-1);	}}	/* end of report_file_byte_io *//* end of zcurses.c *//* vi: set tabstop=4 shiftwidth=4: */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -