forked from Stichting-MINIX-Research-Foundation/minix
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoutput.c
More file actions
executable file
·100 lines (78 loc) · 1.27 KB
/
Copy pathoutput.c
File metadata and controls
executable file
·100 lines (78 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/* Copyright (c) 1985 Ceriel J.H. Jacobs */
/*
* Handle output to screen
*/
# ifndef lint
static char rcsid[] = "$Header$";
# endif
# define _OUTPUT_
# include "in_all.h"
# include "output.h"
# include "main.h"
# define OBUFSIZ 64*128
static char _outbuf[OBUFSIZ];
VOID
flush() { /* Flush output buffer, by writing it */
register char *p = _outbuf;
_ocnt = OBUFSIZ;
if (_optr) (VOID) write(1, p, _optr - p);
_optr = p;
}
VOID
nflush() { /* Flush output buffer, ignoring it */
_ocnt = OBUFSIZ;
_optr = _outbuf;
}
int
fputch(ch) char ch; { /* print a character */
putch(ch);
}
VOID
putline(s) register char *s; { /* Print string s */
if (!s) return;
while (*s) {
putch(*s++);
}
}
/*
* A safe version of putline. All control characters are echoed as ^X
*/
VOID
cputline(s) char *s; {
register c;
while (c = *s++) {
if ((unsigned) c > 0177) c &= 0177;
if (c < ' ' || c == 0177) {
putch('^');
c ^= 0100;
}
putch(c);
}
}
/*
* Simple minded routine to print a number
*/
VOID
prnum(n) long n; {
putline(getnum(n));
}
static char *
fillnum(n, p)
long n;
char *p;
{
if (n >= 10) {
p = fillnum(n / 10, p);
}
*p++ = (int) (n % 10) + '0';
*p = '\0';
return p;
}
char *
getnum(n)
long n;
{
static char buf[20];
fillnum(n, buf);
return buf;
}