]>
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 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
23 * Mach Operating System
24 * Copyright (c) 1990 Carnegie-Mellon University
25 * Copyright (c) 1989 Carnegie-Mellon University
26 * Copyright (c) 1988 Carnegie-Mellon University
27 * Copyright (c) 1987 Carnegie-Mellon University
28 * All rights reserved. The CMU software License Agreement specifies
29 * the terms and conditions for use and redistribution.
32 * Copyright (c) 1982, 1986 Regents of the University of California.
33 * All rights reserved. The Berkeley software License Agreement
34 * specifies the terms and conditions for redistribution.
36 * @(#)prf.c 7.1 (Berkeley) 6/5/86
39 * prf.c - Helpers for the printf function.
41 * Copyright (c) 1998-2000 Apple Computer, Inc.
46 #include <sys/param.h>
52 * Scaled down version of C Library printf.
53 * Used to print diagnostic information directly on console tty.
54 * Since it is not interrupt driven, all system activities are
60 * Printn prints a number n in base b.
61 * We don't use recursion to avoid deep kernel stacks.
64 printn(n
, b
, flag
, minwidth
, putfn_p
, putfn_arg
)
66 int b
, flag
, minwidth
;
72 int width
= 0, neg
= 0;
74 if (b
== 10 && (int)n
< 0) {
76 n
= (unsigned)(-(int)n
);
80 *cp
++ = "0123456789abcdef"[n%b
];
86 (*putfn_p
)('-', putfn_arg
);
89 while (width
++ < minwidth
)
90 (*putfn_p
)( (flag
& ZERO
) ? '0' : ' ', putfn_arg
);
93 (*putfn_p
)(*--cp
, putfn_arg
);
106 int flag
= 0, minwidth
= 0, width
= 0;
109 while ((c
= *fmt
++) != '%') {
112 (*putfn_p
)(c
, putfn_arg
);
149 printn((u_long
)*adx
, b
, flag
, minwidth
, putfn_p
, putfn_arg
);
154 (*putfn_p
)(c
, putfn_arg
);
157 while (width
++ < minwidth
)
158 (*putfn_p
)(' ', putfn_arg
);
161 (*putfn_p
)((char)*adx
, putfn_arg
);