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

📄 part02

📁 speech signal process tools
💻
📖 第 1 页 / 共 4 页
字号:
Xstatic	char	*Erase = "\010 \010";	/* erase string */XXstruct	tcap	{X	char		*tc_id;		/* key for capability	*/X	char		*tc_str;	/* ptr to Tc_str area	*/X	unsigned char	tc_delay;	/* # of msec to delay	*/X	unsigned char	tc_len;		/* length of tc_str	*/X	};XXstatic	char	Termcap [1024];Xstatic	char	Tstr [1024];		/* buffer for real escape sequence */Xstatic	char	*Tsp = Tstr;		/* pointer to be used by tgetstr */Xstatic	int	Tcap_count = 0;		/* # of entries extracted */XX/*-------- You may want to modify the following (also term.h) ----------*/X#include	"term.h"XXstatic	struct	tcap Tcap [] = {X		{ "bc",	0, NULL, 0 },	/* cursor backspace		*/X		{ "cm",	0, NULL, 0 },	/* cursor motion		*/X		{ "cl", 0, NULL, 0 },	/* clear entire screen		*/X		{ "cd", 0, NULL, 0 },	/* clear to end of display	*/X		{ "ce", 0, NULL, 0 },	/* clear to end of line		*/X		{ "ho", 0, NULL, 0 },	/* home cursor			*/X		{ "ks", 0, NULL, 0 },	/* start keypad xmit mode	*/X		{ "ke", 0, NULL, 0 },	/* end keypad xmit mode		*/X		{ "ku", 0, NULL, 0 },	/* (input) cursor upper		*/X		{ "kd", 0, NULL, 0 },	/* (input) cursor down		*/X		{ "kl", 0, NULL, 0 },	/* (input) cursor left		*/X		{ "kr", 0, NULL, 0 },	/* (input) cursor right		*/X		{ "md", 0, NULL, 0 },	/* mode dim (or highlite)	*/X		{ "me", 0, NULL, 0 },	/* mode end (return to normal)	*/X		{ "rc", 0, NULL, 0 },	/* restore cursor		*/X		{ "sc", 0, NULL, 0 },	/* save cursor			*/X		{ "so", 0, NULL, 0 },	/* start reverse video mode	*/X		{ "se", 0, NULL, 0 },	/* end				*/X		{ "us", 0, NULL, 0 },	/* start underline mode 	*/X		{ "ue", 0, NULL, 0 },	/* end				*/X		{ NULL, 0, NULL, 0 }X	};XXchar	*getenv ();Xchar	*tgetstr ();Xchar	*tgoto ();XX/*-------------------------------------------------------------05/10/86-+X|									|X|	      tcap_init : initialize termcap data structure		|X|									|X+----------------------------------------------------------------------*/Xtcap_init ()X	{X	struct	tcap	*p;X	char		*tp;X	unsigned int	delay;X	int		status;X	char		*termtype = getenv ("TERM");XX	if ((status = tgetent (Termcap, termtype)) != 1) {X		if (status == 0) {X			fprintf (stderr, "No entry for %s in termcap\r\n",X				 termtype);X			}X		else	fprintf (stderr, "Can not open termcap file\r\n");X		exit (1);X		}XX	for (p= &Tcap[0]; p->tc_id != EOS; p++) {X		tp = tgetstr (p-> tc_id, &Tsp);X		if (tp == NULL) {	 /* no such capability */X			if (p == &Tcap[BC]) tp = "\010";X			else tp = "";X			}X		delay = 0;X		while (isdigit (*tp)) {X			delay = delay*10 + (*tp++) - '0';X			}X		p->tc_str = tp;X		p->tc_delay = delay;X		p->tc_len = strlen (tp);X		Tcap_count++;X		}X	}XX/*----------------------------------------------------------------------+X|									|X|		screen : common screen operation routine		|X|									|X+----------------------------------------------------------------------*/Xscreen (code)Xint	code;		/* operation code */X	{X	int		n = BAD;	/* init to not valid entry */X	struct	tcap	*te;XX	if (Tcap_count == 0) tcap_init ();X	switch (code) {X		when SCR_DEL:		put_string (Erase, 0);X		when SCR_BACKSPACE:	n = BC;X		when SCR_ERASE:		n = CL;X		when SCR_HOME:		n = HO;X		when SCR_EEOL:		n = CE;X		when SCR_SAVE:		n = SC;X		when SCR_KEYXMIT:	n = KS;X		when SCR_NOKEYXMIT:	n = KE;X		when SCR_RESTORE:	n = RC;X		when SCR_REVERSE:	n = SO;X		when SCR_NORMAL:	n = SE;X		otherwise:	;	/* ignore it */X		}X	if (n != BAD) {X		te = &Tcap[n];X		delay (te-> tc_delay);X		put_string (te-> tc_str, (unsigned)te-> tc_len);X		}X	}X X/*----------------------------------------------------------------------+X|									|X|	   poscur : position cursor on line, column on screen		|X|									|X+----------------------------------------------------------------------*/Xposcur (line, column, s)Xunsigned char	line;Xunsigned char	column;Xchar		*s;		/* option string to output at line, column */X	{X	char	*p;XX	if (Tcap_count == 0) tcap_init ();X	p = tgoto (Tcap[CM].tc_str, column-1, line-1);X	delay (Tcap[CM].tc_delay);X	put_string (p, 0);X	if (s != NULL) put_string (s, 0);X	}XX/*-------------------------------------------------------------05/10/86-+X|									|X|	  delay : delay output for n msec (actually write NULL)		|X|									|X+----------------------------------------------------------------------*/XstaticXdelay (n)Xunsigned char	n;			/* # of msec to delay */X	{X	static	char	c = EOS;X	register int	i;XX	if (n == 0) return;XX	for (i=0; i<n; i++) {X		write (fileno (stdout), &c, 1);X		}X	}XX/*-------------------------------------------------------------05/11/86-+X|									|X|		  Routines to get mode-specific strings			|X|									|X+----------------------------------------------------------------------*/Xget_undline (sbuf, ebuf)Xchar	*sbuf;				/* enter mode buffer */Xchar	*ebuf;				/* exit mode buffer */X	{X	if (Tcap_count == 0) tcap_init ();X	strcpy (sbuf, Tcap[US].tc_str);X	strcpy (ebuf, Tcap[UE].tc_str);X	}XXget_hilite (sbuf, ebuf)Xchar	*sbuf;				/* enter mode buffer */Xchar	*ebuf;				/* exit mode buffer */X	{X	if (Tcap_count == 0) tcap_init ();X	strcpy (sbuf, Tcap[MD].tc_str);X	strcpy (ebuf, Tcap[ME].tc_str);X	}XXget_rvideo (sbuf, ebuf)Xchar	*sbuf;				/* enter mode buffer */Xchar	*ebuf;				/* exit mode buffer */X	{X	if (Tcap_count == 0) tcap_init ();X	strcpy (sbuf, Tcap[SO].tc_str);X	strcpy (ebuf, Tcap[SE].tc_str);X	}XX/*-------------------------------------------------------------07/05/87-+X|									|X|	    getkey : get user entered key (handle cursor key)		|X|									|X+----------------------------------------------------------------------*/Xgetkey ()X	{X	char		buf[20];	/* temporary hold the input stream */X	char		c;X	register int	i = 0;X	register int	ci = 0;		/* current matched index */X	int		idx;X	char		match;		/* flag, YES/NO */X	char		kmatch [4];	/* record how may char matched inX					   each key (KU, KD, KL, KR) */X	extern char	get_char();XX	for (i=0; i<4; i++) kmatch[i] = 0;Xloop:X	c = get_char () & 0x7f;			/* make it ASCII */X	for (match=NO, i=0; i<4; i++) {X		if (kmatch[i] < ci) continue;X		switch (i) {X			when 0: idx = KU;X			when 1: idx = KD;X			when 2: idx = KL;X			when 3: idx = KR;X			}X		if (c == Tcap[idx].tc_str[ci]) {X			kmatch[i]++;X			if (Tcap[idx].tc_len == ci+1) {X				ci = 0;X				return (0x80 | idx);X				}X			match = YES;X			}X		}X	buf[ci++] = c;		/* save input char in temp buffer */X	if (match == YES) goto loop;XX	pushback (&buf[1], ci-1);X	return (buf[0]);X	}SHAR_EOFif test 6575 -ne "`wc -c < 'term.c'`"then	echo shar: error transmitting "'term.c'" '(should have been 6575 characters)'fifi # end of overwriting checkecho shar: extracting "'io.c'" '(4106 characters)'if test -f 'io.c'then	echo shar: will not over-write existing file "'io.c'"elsesed 's/^X//' << \SHAR_EOF > 'io.c'X/* Last update: 01/13/88  11:26 AM  (Edition: 5) */X#include	<stdio.h>X#include	<ctype.h>X#include	<sys/file.h>XX#ifndef		_SGTTYB_X#include	<sgtty.h>X#endifXXint		Term_input;Xint		Term_output;Xextern	int	Debug;X/*-------------------------------------------------------------05/07/86-+X|									|X|	    put_string : write out a string to Term_output		|X|									|X+----------------------------------------------------------------------*/Xput_string (s, len)Xchar		*s;Xunsigned	len;X	{X	if (len == 0) len = strlen (s);X	if (Debug) {X		register int	i;X		register char	*p = s;XX		for (i=0; i<len; i++) put_char (*p++);X		}X	else write (Term_output, s, (int)len);X	}XX/*-------------------------------------------------------------05/07/86-+X|									|X|	    put_char : write out one char to Term_output		|X|									|X+----------------------------------------------------------------------*/Xput_char (c)Xchar	c;X	{X	if (Debug) {X		if (isprint(c)) write (Term_output, &c, 1);X		else	{X			char	buf [2];X			buf[0] = (c < ' ') ? '^' : '~';X			buf[1] = (c | 0x40) & 0x5f;X			write (Term_output, buf, 2);X			}X		}X	else write (Term_output, &c, 1);X	}XXstatic	char	Pushbuf [80];Xstatic	int	Pushi = 0;X/*-------------------------------------------------------------05/07/86-+X|									|X|		get_char : get a char from Term_input			|X|									|X+----------------------------------------------------------------------*/XcharXget_char ()X	{X	char		c;X	register int	i;XX	if (Pushi > 0) {		/* push buffer not empty */X		c = Pushbuf[0];X		Pushi--;X		for (i=0; i<Pushi; i++) {X			Pushbuf[i] = Pushbuf[i+1];X			}X		return (c);X		}X	read (Term_input, &c, 1);X	c &= 0x7f;			/* make it ASCII */X	return (c);X	}XXpushback (buf, len)Xchar	*buf;Xint	len;X	{X	register char	*p = &Pushbuf [Pushi];XX	Pushi += len;X	while (len-- > 0) {X		*p++ = *buf++;X		}X	}XXstatic	int		Old_flags;Xstatic	struct	sgttyb	Mode_tty;X/*-------------------------------------------------------------05/07/86-+X|									|X|		 cbreakio : enter/exit cbreak I/O mode			|X|									|X+----------------------------------------------------------------------*/Xcbreakio (n)Xint	n;				/* 1 -- enter, 0 -- exit */X	{X	static	int	cbreak_io = 0;X	int		ostate;XX	ostate = cbreak_io;X	if (n) {X		if (!cbreak_io) {X			open_tty ();X			cbreak_io = 1;X			}X		}X	else	{X		if (cbreak_io) {X			close_tty ();X			cbreak_io = 0;X			}X		}X	return (ostate);X	}XX/*-------------------------------------------------------------01/12/88-+X|									|X|		term_init : open terminal for read/write		|X|									|X+----------------------------------------------------------------------*/Xterm_init ()X	{X	extern	char	*Prgname;XX	if ((Term_input = open ("/dev/tty", O_RDONLY)) < 0) {X		perror ("term_init: open(/dev/tty,r)");X		exit (1);X		}X	if ((Term_output = open ("/dev/tty", O_WRONLY)) < 0) {X		perror ("term_init: open(/dev/tty,r)");X		exit (1);X		}XX	if (!isatty(Term_input) || !isatty(Term_output)) {X		fprintf (stderr, "You have to run %s interactively\n",X			 Prgname);X		exit (1);X		}X	}XX/*-------------------------------------------------------------01/12/88-+X|									|X|		 term_close : close terminal descriptors		|X|									|X+----------------------------------------------------------------------*/Xterm_close ()X	{X	close (Term_input);X	close (Term_output);X	}X/*------------------------------------------------------------07/10/84--+X|									|X|	 open_tty : open terminal in CBREAK mode without ECHO		|X|									|X+----------------------------------------------------------------------*/Xstatic	open_tty ()X	{X	gtty (Term_input, &Mode_tty);X	Old_flags = Mode_tty.sg_flags;		/* save old setting */X	Mode_tty.sg_flags |= CBREAK;X	Mode_tty.sg_flags &= ~(ECHO | CRMOD);X	stty (Term_input, &Mode_tty);X	}XX/*------------------------------------------------------------07/10/84--+X|									|X|	close_tty : close terminal and restore original setting		|X|									|X+----------------------------------------------------------------------*/Xstatic	close_tty ()X	{X	Mode_tty.sg_flags = Old_flags;X	stty (Term_input, &Mode_tty);		/* restore original setting */X	}SHAR_EOFif test 4106 -ne "`wc -c < 'io.c'`"then	echo shar: error transmitting "'io.c'" '(should have been 4106 characters)'fifi # end of overwriting checkecho shar: extracting "'summary.c'" '(1880 characters)'if test -f 'summary.c'then	echo shar: will not over-write existing file "'summary.c'"elsesed 's/^X//' << \SHAR_EOF > 'summary.c'X/* Last update: 01/14/88  00:30 AM  (Edition: 14) */X#include	<stdio.h>X#include	"basic.h"X#include	"form.h"XXstatic char	*Summary[] = {X"    RETURN - terminate        CTRL P or up arrow - vertical up one field",X"    TAB    - next field       CTRL N or down arrow - vertical down one field",X"    CTRL T - prev field       Intr char - abort",X"    CTRL L - refresh screen   Stop char - stop process",X"",X"--- Editable Field ---                  --- Selection Field ---",X"  Movement:",X"    CTRL A - beginning of field         SPACE  - show next selection",X"    CTRL E - end of field               CTRL H - show prev selection",X"    CTRL F - forward one char           x      - find next selection starts",X"             or --> key                          with character 'x'",X"    CTRL B - backword one char          ?      - get help message (-m flag)",X"             or <-- key or CTRL H",X"  Editing:",X"    CTRL U - delete to start of field",X"    CTRL K - delete to end of field",X"    CTRL W - delete prev word",XNULLX};XXstatic char	*Newline = "\r\n\r\n";Xstatic char	*Header = "Shell Form Version: ";Xextern	char	*Version;Xextern	char	*Copyright;Xextern	char	*Bugs;Xextern	char	get_char();X/*-------------------------------------------------------------01/13/88-+X|									|X|		 show_summary : display on-line summary 		|X|									|X+----------------------------------------------------------------------*/Xshow_summary ()X	{X	char	**pp = Summary;X	char	*p;XX	ENTER (show_summary);X	screen (SCR_ERASE);X	put_string (Header, 0);    put_string (Version, 0);X	put_string (Newline, 2);X	put_string (Copyright, 0); put_string (Newline, 2);X	put_string (Bugs, 0);      put_string (Newline, 4);X	while ((p = *pp++) != NULL) {X		put_string (p, 0);X		put_string (Newline, 2);X		}X	put_string ("\r\n     Press SPACE to continue: ", 0);X	while (get_char() != ' ');X	EXIT;X	}SHAR_EOFif test 1880 -ne "`wc -c < 'summary.c'`"then	echo shar: error transmitting "'summary.c'" '(should have been 1880 characters)'fifi # end of overwriting check#	End of shell archiveexit 0-- Please send comp.sources.unix-related mail to rsalz@uunet.uu.net.

⌨️ 快捷键说明

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