]>
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>
55 * Scaled down version of C Library printf.
56 * Used to print diagnostic information directly on console tty.
57 * Since it is not interrupt driven, all system activities are
63 * Printn prints a number n in base b.
64 * We don't use recursion to avoid deep kernel stacks.
67 printn(n
, b
, flag
, minwidth
, putfn_p
, putfn_arg
)
69 int b
, flag
, minwidth
;
75 int width
= 0, neg
= 0;
77 if (b
== 10 && (int)n
< 0) {
79 n
= (unsigned)(-(int)n
);
83 *cp
++ = "0123456789abcdef"[n%b
];
89 (*putfn_p
)('-', putfn_arg
);
92 while (width
++ < minwidth
)
93 (*putfn_p
)( (flag
& ZERO
) ? '0' : ' ', putfn_arg
);
96 (*putfn_p
)(*--cp
, putfn_arg
);
109 int flag
= 0, minwidth
= 0, width
= 0;
112 while ((c
= *fmt
++) != '%') {
115 (*putfn_p
)(c
, putfn_arg
);
152 printn((u_long
)*adx
, b
, flag
, minwidth
, putfn_p
, putfn_arg
);
157 (*putfn_p
)(c
, putfn_arg
);
160 while (width
++ < minwidth
)
161 (*putfn_p
)(' ', putfn_arg
);
164 (*putfn_p
)((char)*adx
, putfn_arg
);