]>
git.saurik.com Git - apple/boot.git/blob - i386/libsa/prf.c
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
7 * Reserved. This file contains Original Code and/or Modifications of
8 * Original Code as defined in and that are subject to the Apple Public
9 * Source License Version 1.1 (the "License"). You may not use this file
10 * except in compliance with the License. Please obtain a copy of the
11 * License at http://www.apple.com/publicsource and read it before using
14 * The Original Code and all software distributed under the License are
15 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
19 * License for the specific language governing rights and limitations
22 * @APPLE_LICENSE_HEADER_END@
25 * Mach Operating System
26 * Copyright (c) 1990 Carnegie-Mellon University
27 * Copyright (c) 1989 Carnegie-Mellon University
28 * Copyright (c) 1988 Carnegie-Mellon University
29 * Copyright (c) 1987 Carnegie-Mellon University
30 * All rights reserved. The CMU software License Agreement specifies
31 * the terms and conditions for use and redistribution.
34 * Copyright (c) 1982, 1986 Regents of the University of California.
35 * All rights reserved. The Berkeley software License Agreement
36 * specifies the terms and conditions for redistribution.
38 * @(#)prf.c 7.1 (Berkeley) 6/5/86
41 #include <sys/param.h>
47 * Scaled down version of C Library printf.
48 * Used to print diagnostic information directly on console tty.
49 * Since it is not interrupt driven, all system activities are
55 * Printn prints a number n in base b.
56 * We don't use recursion to avoid deep kernel stacks.
59 printn(n
, b
, flag
, minwidth
, putfn_p
, putfn_arg
)
61 int b
, flag
, minwidth
;
67 int width
= 0, neg
= 0;
69 if (b
== 10 && (int)n
< 0) {
71 n
= (unsigned)(-(int)n
);
75 *cp
++ = "0123456789abcdef"[n%b
];
81 (*putfn_p
)('-', putfn_arg
);
84 while (width
++ < minwidth
)
85 (*putfn_p
)( (flag
& ZERO
) ? '0' : ' ', putfn_arg
);
88 (*putfn_p
)(*--cp
, putfn_arg
);
101 int flag
= 0, minwidth
= 0, width
= 0;
104 while ((c
= *fmt
++) != '%') {
107 (*putfn_p
)(c
, putfn_arg
);
144 printn((u_long
)*adx
, b
, flag
, minwidth
, putfn_p
, putfn_arg
);
149 (*putfn_p
)(c
, putfn_arg
);
152 while (width
++ < minwidth
)
153 (*putfn_p
)(' ', putfn_arg
);
156 (*putfn_p
)((char)*adx
, putfn_arg
);