1
/* Dumb printing routines
3
Copyright (C) 1996 Pete A. Zaitcev
8
This program is free software; you can redistribute it and/or modify
9
it under the terms of the GNU General Public License as published by
10
the Free Software Foundation; either version 2 of the License, or
11
(at your option) any later version.
13
This program is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
GNU General Public License for more details.
18
You should have received a copy of the GNU General Public License
19
along with this program; if not, write to the Free Software
20
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
26
* This part is rewritten by Igor Timkin <ivt@msu.su>. Than I
27
* rewritten it again but kept the MISS style, originated from
28
* Wladimir Butenko. --P3
33
#define NULL (void *)0
36
static void putchar_1 (char c)
38
/* P3: This buffer can be static while xprintf flushes it on exit. */
39
static char buff[OBSIZE + 1];
42
if ((buff[ox] = c) == 0) {
65
* Print an unsigned integer in base b, avoiding recursion.
67
static int printn (long long n, int b)
69
static char prbuf[33];
73
if (b == 10 && n < 0) {
80
*cp++ = "0123456789ABCDEF"[(unsigned int) (((unsigned long)n) % b)];
81
while ((n = ((unsigned long long)n) / b & 0x0FFFFFFFFFFFFFFFULL));
90
int vprintf (char *fmt, va_list adx)
97
while ((c = *fmt++) != '%') {
105
if (c == 'd' || c == 'o' || c == 'x' || c == 'X') {
106
count += printn ((long long) va_arg (adx, unsigned),
107
c == 'o' ? 8 : (c == 'd' ? 10 : 16));
108
} else if (c == 'c') {
109
putchar (va_arg (adx, unsigned));
111
} else if (c == 's') {
112
if ((s = va_arg (adx, char *)) == NULL)
113
s = (char *)"(null)";
118
} else if (c == 'l' || c == 'O') {
119
count += printn ((long long) va_arg (adx, long), c == 'l' ? 10 : 8);
120
} else if (c == 'L') {
126
count += printn ((long long) va_arg (adx, long long), hex ? 16 : 10);
128
/* This is basically what libc's printf does */
129
putchar('%'); putchar(c);
138
* Scaled down version of C Library printf.
139
* Only %c %s %d (==%u) %o %x %X %l %O are recognized.
142
void prom_printf (char *fmt,...)