]>
git.saurik.com Git - apple/bootx.git/blob - bootx.tproj/libclite.subproj/prf.c
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
26 * Mach Operating System
27 * Copyright (c) 1990 Carnegie-Mellon University
28 * Copyright (c) 1989 Carnegie-Mellon University
29 * Copyright (c) 1988 Carnegie-Mellon University
30 * Copyright (c) 1987 Carnegie-Mellon University
31 * All rights reserved. The CMU software License Agreement specifies
32 * the terms and conditions for use and redistribution.
35 * Copyright (c) 1982, 1986 Regents of the University of California.
36 * All rights reserved. The Berkeley software License Agreement
37 * specifies the terms and conditions for redistribution.
39 * @(#)prf.c 7.1 (Berkeley) 6/5/86
42 * prf.c - Helpers for the printf function.
44 * Copyright (c) 1998-2002 Apple Computer, Inc.
49 #include <sys/param.h>
56 * Scaled down version of C Library printf.
57 * Used to print diagnostic information directly on console tty.
58 * Since it is not interrupt driven, all system activities are
64 * Printn prints a number n in base b.
65 * We don't use recursion to avoid deep kernel stacks.
68 printn(n
, b
, flag
, minwidth
, putfn_p
, putfn_arg
)
70 int b
, flag
, minwidth
;
76 int width
= 0, neg
= 0;
78 if (b
== 10 && (int)n
< 0) {
80 n
= (unsigned)(-(int)n
);
84 *cp
++ = "0123456789abcdef0123456789ABCDEF"[(flag
& UCASE
) + n%b
];
90 (*putfn_p
)('-', putfn_arg
);
93 while (width
++ < minwidth
)
94 (*putfn_p
)( (flag
& ZERO
) ? '0' : ' ', putfn_arg
);
97 (*putfn_p
)(*--cp
, putfn_arg
);
110 int flag
= 0, minwidth
= 0, width
= 0;
113 while ((c
= *fmt
++) != '%') {
116 (*putfn_p
)(c
, putfn_arg
);
156 printn((u_long
)*adx
, b
, flag
, minwidth
, putfn_p
, putfn_arg
);
161 (*putfn_p
)(c
, putfn_arg
);
164 while (width
++ < minwidth
)
165 (*putfn_p
)(' ', putfn_arg
);
168 (*putfn_p
)((char)*adx
, putfn_arg
);