plan 9 kernel history: overview | file list | diff list

1991/0809/port/devcons.c (diff list | history)

1991/0808/sys/src/9/port/devcons.c:37,731991/0809/sys/src/9/port/devcons.c:37,84 (short | long | prev | next)
1990/0227    
} 
 
/* 
1991/0607    
 *   Print a string on the console.  Convert \n to \r\n 
1991/0809    
 *   Print a string on the console.  Convert \n to \r\n for serial 
 *   line consoles.  Locking of the queues is left up to the screen 
 *   or uart code.  Multi-line messages to serial consoles may get 
 *   interspersed with other messages. 
1990/0227    
 */ 
void 
putstrn(char *str, int n) 
{ 
	int s, c, m; 
1991/0809    
	char buf[PRINTSIZE+2]; 
	int m; 
1990/0227    
	char *t; 
1991/0808    
static Lock fuck; 
1990/0227    
 
1991/0808    
loop: 
s = splhi(); 
if(!canlock(&fuck)){ 
	splx(s); 
	goto loop; 
} 
1991/0809    
	/* 
	 *  if there's an attached bit mapped display, 
	 *  put the message there.  screenputs is defined 
	 *  as a null macro for systems that have no such 
	 *  display. 
	 */ 
	screenputs(str, n); 
 
	/* 
	 *  if there's a serial line being used as a console, 
	 *  put the message there.  Tack a carriage return 
	 *  before new lines. 
	 */ 
	if(printq.puts == 0) 
		return; 
1990/0227    
	while(n > 0){ 
1991/0607    
		if(printq.puts && *str=='\n') 
			(*printq.puts)(&printq, "\r", 1); 
		m = n; 
1990/0227    
		t = memchr(str+1, '\n', m-1); 
		if(t) 
			if(t-str < m) 
				m = t - str; 
1991/0607    
		if(printq.puts) 
			(*printq.puts)(&printq, str, m); 
		screenputs(str, m); 
1990/0227    
		n -= m; 
		str += m; 
1991/0809    
		t = memchr(str, '\n', n); 
		if(t){ 
			m = t - str; 
			memmove(buf, str, m); 
			buf[m] = '\r'; 
			buf[m+1] = '\n'; 
			(*printq.puts)(&printq, buf, m+2); 
			str = t + 1; 
			n -= m + 1; 
		} else { 
			(*printq.puts)(&printq, str, n); 
			break; 
		} 
1990/0227    
	} 
1991/0808    
unlock(&fuck); 
splx(s); 
1990/0227    
} 
 
1991/0607    
/* 


source code copyright © 1990-2005 Lucent Technologies; see license
Plan 9 distribution
comments to russ cox (rsc@swtch.com)