pkgin_all: script to auto-install all packages
[minix.git] / lib / libsys / kputc.c
blob9e73012728756f578a171acddcf9be5795549ddf
1 /* A server must occasionally print some message. It uses a simple version of
2 * printf() found in the system lib that calls kputc() to output characters.
3 * Printing is done with a call to the kernel, and not by going through FS.
5 * This routine can only be used by servers and device drivers. The kernel
6 * must define its own kputc(). Note that the log driver also defines its own
7 * kputc() to directly call the TTY instead of going through this library.
8 */
10 #include "sysutil.h"
12 static char print_buf[DIAG_BUFSIZE]; /* output is buffered here */
14 /*===========================================================================*
15 * kputc *
16 *===========================================================================*/
17 void kputc(int c)
19 /* Accumulate another character. If 0 or buffer full, print it. */
20 static int buf_count; /* # characters in the buffer */
22 if ((c == 0 && buf_count > 0) || buf_count == sizeof(print_buf)) {
23 sys_sysctl(SYSCTL_CODE_DIAG, print_buf, buf_count);
24 buf_count = 0;
26 if (c != 0) {
28 /* Append a single character to the output buffer. */
29 print_buf[buf_count] = c;
30 buf_count++;