hunt/playit.c
/*
 * send_stuff:
 *	Send standard input characters to the driver
 */
Send standard input characters to the driver
Send standard input characters to the driver
static void
send_stuff()
{
	int		count;
	char		*sp, *nsp;
	static char	inp[BUFSIZ];
	static char	Buf[BUFSIZ];
	count = read(STDIN_FILENO, Buf, sizeof Buf);
	if (count < 0)
		err(1, "read");
	if (count == 0)
		return;
	if (nchar_send <= 0) {
	    if (!no_beep)
		display_beep();
	    return;
	}
	Buf[count] = '\0';
	for (sp = Buf, nsp = inp; *sp != '\0'; sp++, nsp++) {
		if (inputmode == INPUTMODE_PLAY) {
			*nsp = map_key[(int)*sp];
			if (*nsp == 'q') {
				intr(0);
				nsp--;
			}
			if (*nsp == '\n' || *nsp == '\r')
				inputmode = INPUTMODE_COM;
		}
		else if (inputmode == INPUTMODE_COM) {
			int ret;
			*nsp = *sp;
			if (*nsp == '\n' || *nsp == '\r')
				inputmode = INPUTMODE_PLAY;
			else if (display_iserasechar(*nsp))
				*nsp = '\b';
			else if (display_iskillchar(*nsp))
				*nsp = 21;
		}
	}
	count = nsp - inp;
	if (count) {
		nchar_send -= count;
		if (nchar_send < 0)
		{
			count += nchar_send;
			nchar_send = 0;
		}
		(void) write(Socket, inp, count);
		if (Otto_mode) {
			Otto_expect += count;
		}
	}
}
static void send_stuff ( ) { int count ; char * sp , * nsp ; static char inp [ BUFSIZ ] ; static char Buf [ BUFSIZ ] ; count = read ( STDIN_FILENO , Buf , sizeof Buf ) ; if ( count < 0 ) err ( 1 , " " ) ; if ( count == 0 ) return ; if ( nchar_send <= 0 ) { if ( ! no_beep ) display_beep ( ) ; return ; } Buf [ count ] = ' \0 ' ; for ( sp = Buf , nsp = inp ; * sp != ' \0 ' ; sp ++ , nsp ++ ) { if ( inputmode == INPUTMODE_PLAY ) { * nsp = map_key [ ( int ) * sp ] ; if ( * nsp == ' ' ) { intr ( 0 ) ; nsp -- ; } if ( * nsp == ' \n ' || * nsp == ' \r ' ) inputmode = INPUTMODE_COM ; } else if ( inputmode == INPUTMODE_COM ) { int ret ; * nsp = * sp ; if ( * nsp == ' \n ' || * nsp == ' \r ' ) inputmode = INPUTMODE_PLAY ; else if ( display_iserasechar ( * nsp ) ) * nsp = ' \b ' ; else if ( display_iskillchar ( * nsp ) ) * nsp = 21 ; } } count = nsp - inp ; if ( count ) { nchar_send -= count ; if ( nchar_send < 0 ) { count += nchar_send ; nchar_send = 0 ; } ( void ) write ( Socket , inp , count ) ; if ( Otto_mode ) { Otto_expect += count ; } } }
send_stuff:
      Send standard input characters to the driver
send_stuff : Send standard input characters to the driver
/* Drain the user's keystrokes: */ /*
	 * look for 'q'uit commands; if we find one,
	 * confirm it.  If it is not confirmed, strip
	 * it out of the input
	 */ /* don't map in com-mode */ /*
			display_move(com_y, com_x);
			ret = process_message_char(*nsp, &com_buf_p,
					com_buf, COM_MAX_LENGTH);
			if (ret == 1)
				inputmode = INPUTMODE_PLAY;
			else display_getyx(&com_y, &com_x);
			*/ /* Send term-independent special chars */ /*
			else if (ret == 2) {
			*/ /* No room in buffer - ring the bell but don't
				 * send the character */ /*
				display_beep();
				nsp--;
			}
			*/ /*
			 * The user can insert commands over otto.
			 * So, otto shouldn't be alarmed when the 
			 * server processes more than otto asks for.
			 */