send_tty(buf, l) unsigned char *buf; int l; { int n; unsigned char *p; int nc;
void send_tty(buf, l) unsigned char *buf; int l; { int n; unsigned char *p; int nc;
send_tty(buf, l)unsigned char *buf;int l;{	int n;	unsigned char *p;	int nc;	if(l<=0)return;	LOGL4("sendttydata l=%d\tsent: ",l);	stats.kiss_out++;	p = buf;	nc = l;	n = 0;/* * we have to loop around here because each call to write may write a few * characters.  So we simply increment the buffer each time around.  If * we ever write no characters, we should get an error code, and io_error * will sleep for a fraction of a second.  Note that we are keyed to * the BSD 4.2 behaviour... the Sys 5 non-blocking I/O may or may not work * in this loop.  We may detect system 5 behaviour (this would result from * compile-time options) by having io_error barf when it detects an EAGAIN * error code. */	do {		if((n>0)&&(n<nc)) {	/* did we put only write a bit? */			p += n;			/* point to the new data */			nc -= n;		/* drop the length */		}		n = write(ttyfd, p, nc);		if(n>0){			if(n!=nc){				LOGL4("%d ",n);  /* no-one said loglevel 4 */			} else {				LOGL4("%d\n",n);     /* was efficient!!! */			}		}	} while( ((n>0)&&(n<nc)) || (io_error(n, p, nc, SEND_MSG, TTY_MODE)));}