~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Minix Cross Reference
Minix/inet/putk.c


  1 /* INET must occasionally print some message.  It uses the standard library
  2  * routine prink().  (The name "printf" is really a macro defined as "printk").
  3  * Printing is done by calling the TTY task directly, not going through FS.
  4  */
  5 
  6 #include "inet.h"
  7 
  8 #define BUF_SIZE          100   /* print buffer size */
  9 
 10 PRIVATE int buf_count;          /* # characters in the buffer */
 11 PRIVATE char print_buf[BUF_SIZE];       /* output is buffered here */
 12 PRIVATE message putch_msg;      /* used for message to TTY task */
 13 
 14 FORWARD _PROTOTYPE (void flush, (void) );
 15 _PROTOTYPE (void putk, (int c) );
 16 
 17 
 18 /*===========================================================================*
 19  *                              putk                                         *
 20  *===========================================================================*/
 21 PUBLIC void putk(c)
 22 int c;
 23 {
 24 /* Accumulate another character.  If 0 or buffer full, print it. */
 25 
 26   if (c == 0 || buf_count == BUF_SIZE) flush();
 27   if (c == '\n') putk('\r');
 28   if (c != 0) print_buf[buf_count++] = c;
 29 }
 30 
 31 
 32 /*===========================================================================*
 33  *                              flush                                        *
 34  *===========================================================================*/
 35 PRIVATE void flush()
 36 {
 37 /* Flush the print buffer by calling TTY task. */
 38 
 39   if (buf_count == 0) return;
 40   putch_msg.m_type = DEV_WRITE;
 41   putch_msg.PROC_NR  = THIS_PROC;
 42   putch_msg.TTY_LINE = 0;
 43   putch_msg.ADDRESS  = print_buf;
 44   putch_msg.COUNT = buf_count;
 45   sendrec(TTY, &putch_msg);
 46   if (putch_msg.REP_STATUS == SUSPEND)
 47         receive(TTY, &putch_msg);
 48   buf_count = 0;
 49 }
 50 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.