mtree: no more /lib and /lib/i386.
[minix.git] / commands / yap / output.c
blob53c535b0085a49065dadd26d193d473efedfa057
1 /* Copyright (c) 1985 Ceriel J.H. Jacobs */
3 /*
4 * Handle output to screen
5 */
7 # ifndef lint
8 static char rcsid[] = "$Header$";
9 # endif
11 # define _OUTPUT_
13 # include "in_all.h"
14 # include "output.h"
15 # include "main.h"
17 # define OBUFSIZ 64*128
19 static char _outbuf[OBUFSIZ];
21 VOID
22 flush() { /* Flush output buffer, by writing it */
23 register char *p = _outbuf;
25 _ocnt = OBUFSIZ;
26 if (_optr) (VOID) write(1, p, _optr - p);
27 _optr = p;
30 VOID
31 nflush() { /* Flush output buffer, ignoring it */
33 _ocnt = OBUFSIZ;
34 _optr = _outbuf;
37 int
38 fputch(ch) char ch; { /* print a character */
39 putch(ch);
42 VOID
43 putline(s) register char *s; { /* Print string s */
45 if (!s) return;
46 while (*s) {
47 putch(*s++);
52 * A safe version of putline. All control characters are echoed as ^X
55 VOID
56 cputline(s) char *s; {
57 register c;
59 while (c = *s++) {
60 if ((unsigned) c > 0177) c &= 0177;
61 if (c < ' ' || c == 0177) {
62 putch('^');
63 c ^= 0100;
65 putch(c);
70 * Simple minded routine to print a number
73 VOID
74 prnum(n) long n; {
76 putline(getnum(n));
79 static char *
80 fillnum(n, p)
81 long n;
82 char *p;
84 if (n >= 10) {
85 p = fillnum(n / 10, p);
87 *p++ = (int) (n % 10) + '0';
88 *p = '\0';
89 return p;
92 char *
93 getnum(n)
94 long n;
96 static char buf[20];
98 fillnum(n, buf);
99 return buf;