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

📄 ecuphdir.c

📁 一个通讯程序源码
💻 C
📖 第 1 页 / 共 4 页
字号:
/*+-------------------------------------------------------------------------	ecuphone.c -- visual phone dialer/directory editor	wht@n4hgf.Mt-Park.GA.US  .---[ title ]------------modified-.<-- dirw "top line"  |   stand out mode                |<-- dirw "header line"  |                                 |<-- scrw first line  |                                 |  |                                 |  |                                 |  |                                 |<-- scrw last line  +---------------------------------+<-- dirw bottom separator line  |                                 |<-- dirw extra cmd prompt line  |   stand out mode                |<-- dirw "cmd line"  `---------------------------------'<-- dirw bottom line  00000000001111111111222222222233333333334444444444555555555566  01234567890123456789012345678901234567890123456789012345678901 0.--[ entry nnnnn ]-------------------------------------------. 1|                                                            | 2| telephone number  ___________________                      | 3| device            __________                               | 4| baud rate         _____                                    | 5| parity            _                                        | 6| description       ________________________________________ | 7| debug level       _  (dialer -x value 0-9)                 | 8| DCD watch         _                                        | 9|                                                            |10| <prompt>                                                   |11| <control key description>                                  |12`------------------------------------------------------------'  Defined functions:	check_curr_pde()	dirw_bot_msg(msg)	dirw_cmd_line_setup(prompt1,prompt2)	dirw_display()	dirw_display_config()	dirw_display_phonedir_name()	dirw_get_cmd()	phdir_add_or_edit(tpde,edit)	phdir_add_or_edit_read(prompt,edit,y,buf,bufmax,delim)	phdir_cmd_add(tpde)	phdir_cmd_change_dir()	phdir_cmd_down()	phdir_cmd_find()	phdir_cmd_mark(tpde)	phdir_cmd_remove()	phdir_cmd_remove_oops()	phdir_cmd_save()	phdir_cmd_set_wait()	phdir_cmd_unmark(tpde)	phdir_cmd_unmark_all()	phdir_cmd_up()	phdir_dial_cycle()	phdir_display(line,tpde,stand_out)	phdir_display_logical(line,tpde,stand_out)	phdir_list_add(tpde)	phdir_list_erase()	phdir_list_remove(tpde)	phdir_list_save_if_dirty()	phdir_list_search(logical,exact_flag)	phdir_list_set_dirty(flag)	phdir_manager()	scrw_fill(tpde,curr_pde_line)	scrw_fill_at(line_num,tpde,curr_pde_line)	want_pd_create(name)--------------------------------------------------------------------------*//*+:EDITS:*//*:09-10-1992-13:58-wht@n4hgf-ECU release 3.20 *//*:08-22-1992-15:38-wht@n4hgf-ECU release 3.20 BETA *//*:05-17-1992-18:29-wht@n4hgf-pde add now cycles thru fields til END *//*:11-28-1991-14:32-wht@n4hgf-add dcdwatch option *//*:11-20-1991-05:19-wht@n4hgf-improve "Any" line handling on add or edit *//*:08-28-1991-15:15-wht@n4hgf2-fix bad structure in phdir_add_or_edit_read *//*:08-25-1991-14:39-wht@n4hgf-SVR4 port thanks to aega84!lh *//*:08-15-1991-18:13-wht@n4hgf-do not allow edit of non-existent entry *//*:08-11-1991-19:56-wht@n4hgf-soup up tty name for ISC vs. SCO *//*:08-07-1991-13:48-root@n4hgf-w subcommand was not asking both questions *//*:08-01-1991-03:52-wht@n4hgf-when editing string, set cursor to end *//*:07-25-1991-12:56-wht@n4hgf-ECU release 3.10 *//*:07-17-1991-07:04-wht@n4hgf-avoid SCO UNIX nap bug *//*:07-12-1991-15:37-wht@n4hgf-fix core dump when creating phone from setup *//*:06-09-1991-16:54-jjb-want_pd_create sneak path when not in curses *//*:06-02-1991-19:43-wht@n4hgf-add dial debug level *//*:06-02-1991-17:29-wht@n4hgf-move hdb_choose_Any to hdbintf.c *//*:06-01-1991-23:53-wht@n4hgf-use PDE_..._LEN identifiers *//*:04-03-1991-14:47-wht@n4hgf-must refresh both windows in terminfo curses *//*:03-18-1991-21:39-wht@n4hgf-add wrefresh of scrw in up/down *//*:02-05-1991-14:51-wht@n4hgf-calloc PDE instead of malloc *//*:01-09-1991-22:31-wht@n4hgf-ISC port *//*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */#include "ecucurses.h"#define STDIO_H_INCLUDED#define OMIT_TERMIO_REFERENCES#include "ecu.h"#include "pc_scr.h"#include "ecupde.h"#include "ecukey.h"#include "ecuxkey.h"#include "esd.h"#include "var.h"extern int tcap_LINES;char *find_procedure();char *make_char_graphic();char *linst_err_text();WINDOW *window_create();void dirw_bot_msg();void dirw_display_phonedir_name();void dirw_cmd_line_setup();/* window definitions */#define DIRW_LINES		(tcap_LINES - 1)#define DIRW_COLS		(80)#define DIRW_TOP_LINES	2#define DIRW_BOT_LINES	4#define DIRW_CMD_LINE	(DIRW_LINES - 2)#define SCRW_LINES		(DIRW_LINES - DIRW_TOP_LINES - DIRW_BOT_LINES)#define SCRW_COLS		(DIRW_COLS)#define SCRW_TLY		(DIRW_TOP_LINES)#define SCRW_TLX		0#define PDE_ITEM_COUNT	(7)#define ADDW_LINES		(PDE_ITEM_COUNT + 6)#define ADDW_COLS		(62)#define ADDW_TLY		(SCRW_TLY + 1)#define ADDW_TLX		(4)extern int errno;extern int windows_active;extern char errmsg[];extern char kbdintr;extern char phonedir_name[];		/* phone directory name */extern char *phonedir_trigger;WINDOW *dirw = (WINDOW *)0;WINDOW *scrw = (WINDOW *)0;WINDOW *addw = (WINDOW *)0;PDE *phdir_list_head = (PDE *)0;	/* pointer to first pde in linked list */PDE *curr_pde = (PDE *)0;		/* current pde */PDE *remove_pde = (PDE *)0;		/* if non-zero, pde just removed */int remove_dirty_flag;			/* phdir_list_dirty at remove time */int phdir_list_quan = 0;			/* count of items in list now */int phdir_list_dirty = 0;			/* phdir_list modified but not saved */int pde_marked_for_redial_count = 0;int scrw_curr_pde_line;			/* scrw line curr_pde is on */int phonedir_name_x;			/* position for phonedir name on screen */#define NAP_DECISEC_SINGLE_MIN         10#define NAP_DECISEC_MULTIPLE_MIN       10int nap_decisec_single   = 150;int nap_decisec_multiple = 50;/*+-------------------------------------------------------------------------	phdir_list_erase()--------------------------------------------------------------------------*/voidphdir_list_erase(){	register PDE *pde = phdir_list_head;	register PDE *next;	while(pde)	{		next = pde->next;		free((char *)pde);		pde = next;	}	phdir_list_head = (PDE *)0;	phdir_list_quan = 0;	curr_pde = (PDE *)0;	remove_pde = (PDE *)0;	pde_marked_for_redial_count = 0;}	/* end of phdir_list_erase *//*+-------------------------------------------------------------------------	phdir_list_set_dirty(flag)0: clean, 1 dirty, -1 do not modify;update screen only--------------------------------------------------------------------------*/voidphdir_list_set_dirty(flag)int flag;{	register itmp;	if(flag != phdir_list_dirty)	{		if(flag != -1)			phdir_list_dirty = flag;		wmove(dirw,0,DIRW_COLS - 14);		if(phdir_list_dirty)			waddstr(dirw," modified ");		else		{			itmp = 10;#if defined(SVR4)			whline(dirw, (unsigned long)(sHR & 0x00ff), itmp);#else			while(itmp--)				waddch(dirw,(unsigned)sHR);#endif		}		wrefresh(dirw);	}}	/* end of phdir_list_set_dirty *//*+-------------------------------------------------------------------------	phdir_list_add(tpde) -- add to linked list--------------------------------------------------------------------------*/voidphdir_list_add(tpde)PDE *tpde;{	register PDE *this = tpde;	register PDE *prev;	register PDE *next;/* if empty, init list with this one and quit */	if(phdir_list_head == (PDE *)0)	{		phdir_list_head = this;		this->prev = (PDE *)0;		this->next = (PDE *)0;		phdir_list_quan++;		return;	}/* list not empty */	prev = (PDE *)0;		/* no previous yet */	next = phdir_list_head;	/* init next to top of list */	while(strcmp(next->logical,this->logical) < 0)	{		prev = next;		next = prev->next;		if(next == (PDE *)0)			break;	}	if(prev)		/* if non-zero, we will not update the list head */	{		this->next = prev->next;		this->prev = prev;		prev->next = this;		if(next)			next->prev = this;	}	else	/* 'this' is to become the new list head (1st element) */	{		this->next = next;		this->prev = (PDE *)0;		if(next)			next->prev = this;		phdir_list_head = this;	}	phdir_list_quan++;}	/* end of pde_add *//*+-------------------------------------------------------------------------	phdir_list_remove(tpde) -- remove from linked list--------------------------------------------------------------------------*/voidphdir_list_remove(tpde)register PDE *tpde;{	register PDE *prev;	register PDE *next;	prev = (PDE *)0;	/* there is no previous now */	if((next = phdir_list_head) == (PDE *)0)	/* if empty list */		return;	while(next != tpde)	{		prev = next;		next = prev->next;		if(next == (PDE *)0)			return;	}/* take care of "current pde" */	if(tpde == curr_pde)	{		if(tpde->next)			curr_pde = tpde->next;		else if(tpde->prev)			curr_pde = tpde->prev;		else			curr_pde = (PDE *)0;	}/* marked? */	if(tpde->redial)	{		tpde->redial = 0;		pde_marked_for_redial_count--;	}/* unlink */	if(prev)		/* if non-zero, we will not update the list head */	{		prev->next = tpde->next;		if(tpde->next)			(tpde->next)->prev = prev;	}	else	{		phdir_list_head = tpde->next;		if(tpde->next)			(tpde->next)->prev = (PDE *)0;	}	tpde->next = (PDE *)0;	tpde->prev = (PDE *)0;	phdir_list_quan--;}	/* end of phdir_list_remove *//*+-----------------------------------------------------------------------	PDE *phdir_list_search(logical,exact_flag)------------------------------------------------------------------------*/PDE *phdir_list_search(logical,exact_flag)char *logical;int exact_flag;{	register PDE *tpde;	if(!phdir_list_quan)	{		if(phdir_list_read())			return((PDE *)0);	}	if(!logical || !*logical)		return((PDE *)0);	tpde = phdir_list_head;	while(tpde)	{		/* only first few chars necessary for match with ulcmpb */		if(exact_flag)		{			if(strcmp(tpde->logical,logical) == 0)				return(tpde);		}		else		{			if(ulcmpb(tpde->logical,logical) < 0)				return(tpde);		}		tpde = tpde->next;	}	if(!tpde)		sprintf(errmsg,"'%s' not found",logical);	return(tpde);}	/* end of phdir_list_search *//*+-------------------------------------------------------------------------	want_pd_create(name)--------------------------------------------------------------------------*/intwant_pd_create(name)char *name;{	uchar uctmp = 255;	if(!dirw)		return(1);#ifdef COMPILER_BUG_FIXED	dirw_bot_msg("type 'y' or 'n'");	while(uctmp == 255)	{		ring_bell();		dirw_cmd_line_setup(name,"does not exist: create?");		uctmp = ttygetc(0);		if(isupper(uctmp))			uctmp = tolower(uctmp);		switch(uctmp)		{			case 'y': uctmp = 1; break;			case 'n': uctmp = 0; break;			default: uctmp = 255; break;				}	}	dirw_bot_msg("");	return((int)uctmp);#elseKROCK:	dirw_bot_msg("type 'y' or 'n'");	ring_bell();	dirw_cmd_line_setup(name,"does not exist: create?");	uctmp = ttygetc(0);	dirw_bot_msg("");	if(isupper(uctmp))		uctmp = tolower(uctmp);	switch(uctmp)	{		case 'y': return(1);		case 'n': return(0);	}	goto KROCK;#endif}	/* end of want_pd_create *//*+-------------------------------------------------------------------------	dirw_display_phonedir_name()--------------------------------------------------------------------------*/voiddirw_display_phonedir_name(){	register itmp,x;	char s80[80];	if(!dirw || !phonedir_name[0])		return;	wmove(dirw,0,phonedir_name_x);	waddch(dirw,' ');	strncpy(s80,phonedir_name,itmp = DIRW_COLS - phonedir_name_x - 5);	s80[itmp] = 0;	waddstr(dirw,s80);	waddch(dirw,' ');	getyx(dirw,itmp,x);#if defined(SVR4)	whline(dirw, (unsigned long)(sHR & 0x00ff), DIRW_COLS - 1 - x);#else	while(x < DIRW_COLS - 1)	{		waddch(dirw,sHR);		x++;	}#endif}	/* end of dirw_display_phonedir_name *//*+-------------------------------------------------------------------------	dirw_display_config()--------------------------------------------------------------------------*/voiddirw_display_config(){	register y,x;	if(!dirw)		return;#if defined(SVR4)	wmove(dirw,DIRW_LINES - DIRW_BOT_LINES,1);	whline(dirw, (unsigned long)(sHR & 0x00ff), DIRW_COLS - 2);#else	wmove(dirw,DIRW_LINES - DIRW_BOT_LINES,0);	waddch(dirw,sLT);	getyx(dirw,y,x);	while(x++ < (DIRW_COLS - 1))		waddch(dirw,sHR);	waddch(dirw,sRT);#endif	if(pde_marked_for_redial_count)	{		wmove(dirw,DIRW_LINES - DIRW_BOT_LINES,2);		wstandout(dirw);		wprintw(dirw," REDIAL CYCLE  wait: single=%d multiple=%d ",			nap_decisec_single / 10,nap_decisec_multiple / 10);		wmove(dirw,DIRW_LINES - DIRW_BOT_LINES,56);		wprintw(dirw," %2d marked entr%s ",			pde_marked_for_redial_count,			(pde_marked_for_redial_count == 1) ? "y" : "ies");		wstandend(dirw);	}}	/* end of dirw_display_config *//*+-----------------------------------------------------------------------	dirw_display()0000000000111111111122222222223333333333444444444455555555556666666666777777777701234567890123456789012345678901234567890123456789012345678901234567890123456789| entry name | telephone number | tty | baud P | description                   || 0123456789 | 0123456789012345 | 01  | baud P | 01234567890123456789012345678 |------------------------------------------------------------------------*/voiddirw_display(){	if(!dirw)

⌨️ 快捷键说明

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