source: trunk/minix/commands/yap/output.c@ 15

Last change on this file since 15 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 1.4 KB
RevLine 
[9]1/* Copyright (c) 1985 Ceriel J.H. Jacobs */
2
3/*
4 * Handle output to screen
5 */
6
7# ifndef lint
8static char rcsid[] = "$Header: /cvsup/minix/src/commands/yap/output.c,v 1.1.1.1 2005/04/21 14:55:40 beng Exp $";
9# endif
10
11# define _OUTPUT_
12
13# include "in_all.h"
14# include "output.h"
15# include "main.h"
16
17# define OBUFSIZ 64*128
18
19static char _outbuf[OBUFSIZ];
20
21VOID
22flush() { /* Flush output buffer, by writing it */
23 register char *p = _outbuf;
24
25 _ocnt = OBUFSIZ;
26 if (_optr) (VOID) write(1, p, _optr - p);
27 _optr = p;
28}
29
30VOID
31nflush() { /* Flush output buffer, ignoring it */
32
33 _ocnt = OBUFSIZ;
34 _optr = _outbuf;
35}
36
37int
38fputch(ch) char ch; { /* print a character */
39 putch(ch);
40}
41
42VOID
43putline(s) register char *s; { /* Print string s */
44
45 if (!s) return;
46 while (*s) {
47 putch(*s++);
48 }
49}
50
51/*
52 * A safe version of putline. All control characters are echoed as ^X
53 */
54
55VOID
56cputline(s) char *s; {
57 register c;
58
59 while (c = *s++) {
60 if ((unsigned) c > 0177) c &= 0177;
61 if (c < ' ' || c == 0177) {
62 putch('^');
63 c ^= 0100;
64 }
65 putch(c);
66 }
67}
68
69/*
70 * Simple minded routine to print a number
71 */
72
73VOID
74prnum(n) long n; {
75
76 putline(getnum(n));
77}
78
79static char *
80fillnum(n, p)
81 long n;
82 char *p;
83{
84 if (n >= 10) {
85 p = fillnum(n / 10, p);
86 }
87 *p++ = (int) (n % 10) + '0';
88 *p = '\0';
89 return p;
90}
91
92char *
93getnum(n)
94 long n;
95{
96 static char buf[20];
97
98 fillnum(n, buf);
99 return buf;
100}
Note: See TracBrowser for help on using the repository browser.