📄 putk.c
字号:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/fs/putk.c
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
27600 /* FS must occasionally print some message. It uses the standard library
27601 * routine prink(). (The name "printf" is really a macro defined as "printk").
27602 * Printing is done by calling the TTY task directly, not going through FS.
27603 */
27604
27605 #include "fs.h"
27606 #include <minix/com.h>
27607
27608 #define BUF_SIZE 100 /* print buffer size */
27609
27610 PRIVATE int buf_count; /* # characters in the buffer */
27611 PRIVATE char print_buf[BUF_SIZE]; /* output is buffered here */
27612 PRIVATE message putch_msg; /* used for message to TTY task */
27613
27614 FORWARD _PROTOTYPE( void flush, (void) );
27615
27616 /*===========================================================================*
27617 * putk *
27618 *===========================================================================*/
27619 PUBLIC void putk(c)
27620 int c;
27621 {
27622 /* Accumulate another character. If 0 or buffer full, print it. */
27623
27624 if (c == 0 || buf_count == BUF_SIZE) flush();
27625 if (c == '\n') putk('\r');
27626 if (c != 0) print_buf[buf_count++] = c;
27627 }
27630 /*===========================================================================*
27631 * flush *
27632 *===========================================================================*/
27633 PRIVATE void flush()
27634 {
27635 /* Flush the print buffer by calling TTY task. */
27636
27637
27638 if (buf_count == 0) return;
27639 putch_msg.m_type = DEV_WRITE;
27640 putch_msg.PROC_NR = 1;
27641 putch_msg.TTY_LINE = 0;
27642 putch_msg.ADDRESS = print_buf;
27643 putch_msg.COUNT = buf_count;
27644 call_task(TTY, &putch_msg);
27645 buf_count = 0;
27646 }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -