* Copyright (c) 1982, 1986, 1990 The Regents of the University of California.
* %sccs.include.redist.c%
* @(#)prf.c 7.2 (Berkeley) %G%
* Scaled down version of C Library printf.
* Used to print diagnostic information directly on console tty.
* Since it is not interrupt driven, all system activities are
* suspended. Printf should not be used for chit-chat.
* One additional format: %b is supported to decode error registers.
* printf("reg=%b\n", regval, "<base><arg>*");
* Where <base> is the output base expressed as a control character,
* e.g. \10 gives octal; \20 gives hex. Each arg is a sequence of
* characters, the first of which gives the bit number to be inspected
* (origin 1), and the next characters (up to a control character, i.e.
* a character <= 32), give the name of the register. Thus
* printf("reg=%b\n", 3, "\10\2BITTWO\1BITONE\n");
while ((c
= *fmt
++) != '%') {
/* THIS CODE IS VAX DEPENDENT IN HANDLING %l? AND %c */
case 'u': /* what a joke */
printn(userom
, (u_long
)*adx
, b
);
for (i
= 24; i
>= 0; i
-= 8)
printn(userom
, (u_long
)b
, *s
++);
putchar(userom
, any
? ',' : '<');
for (; (c
= *s
) > 32; s
++)
* Printn prints a number n in base b.
* We don't use recursion to avoid deep kernel stacks.
if (b
== 10 && (int)n
< 0) {
*cp
++ = "0123456789abcdef"[n
%b
];
* Print a character on console.
while((c
= cngetc()) == 0)
else if (c
== ('c'&037)) {