Last change
on this file since 15 was 4, checked in by Mattia Monga, 14 years ago |
Importazione sorgenti libro
|
File size:
1.1 KB
|
Rev | Line | |
---|
[4] | 1 | /* A server must occasionally print some message. It uses a simple version of
|
---|
| 2 | * printf() found in the system library that calls putk() to output characters.
|
---|
| 3 | * The LOG driver cannot use the regular putk(). Hence, it uses a special
|
---|
| 4 | * version of putk() that directly sends to the TTY task.
|
---|
| 5 | *
|
---|
| 6 | * Changes:
|
---|
| 7 | * 21 July 2005: Created (Jorrit N. Herder)
|
---|
| 8 | */
|
---|
| 9 |
|
---|
| 10 | #include "log.h"
|
---|
| 11 |
|
---|
| 12 | /*===========================================================================*
|
---|
| 13 | * kputc *
|
---|
| 14 | *===========================================================================*/
|
---|
| 15 | void kputc(c)
|
---|
| 16 | int c;
|
---|
| 17 | {
|
---|
| 18 | /* Accumulate another character. If 0 or buffer full, print it. */
|
---|
| 19 | static int buf_count; /* # characters in the buffer */
|
---|
| 20 | static char print_buf[80]; /* output is buffered here */
|
---|
| 21 | message m;
|
---|
| 22 |
|
---|
| 23 | if ((c == 0 && buf_count > 0) || buf_count == sizeof(print_buf)) {
|
---|
| 24 | m.DIAG_BUF_COUNT = buf_count;
|
---|
| 25 | m.DIAG_PRINT_BUF = print_buf;
|
---|
| 26 | m.DIAG_PROC_NR = SELF;
|
---|
| 27 | m.m_type = DIAGNOSTICS; /* request TTY to output this buffer */
|
---|
| 28 | _sendrec(TTY_PROC_NR, &m); /* if it fails, we give up */
|
---|
| 29 | buf_count = 0; /* clear buffer for next batch */
|
---|
| 30 | }
|
---|
| 31 | if (c != 0) {
|
---|
| 32 | print_buf[buf_count++] = c;
|
---|
| 33 | }
|
---|
| 34 | }
|
---|
| 35 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.