4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
22 #pragma ident "%Z%%M% %I% %E% SMI"
25 * Copyright (c) 1987, 1988, 1989, 1990 by Sun Microsystems, Inc.
28 /* Copyright (c) 1988 AT&T */
29 /* All Rights Reserved */
32 * Subroutines for the 4.0 compatibility run-time link editor.
35 #include <sys/types.h>
38 * Local "printf" & stdio facilities.
40 int stdout
= 1; /* File descriptor for output */
41 int stderr
= 2; /* File descriptor for errors */
43 static char *printn();
67 fprintf(fd
, fmt
, va_alist
)
88 extern char *program_name
;
91 prf(stderr
, "%s (4.x.ld.so): ", program_name
);
93 prf(stderr
, "\n", x1
);
103 sprintf(cp
, fmt
, va_alist
)
111 doprf(-1, fmt
, x1
, cp
);
116 * printf worker functions
126 doprf(fd
, fmt
, adx
, linebuf
);
130 doprf(fd
, fmt
, adx
, linebuf
)
133 register va_list adx
;
136 register int c
; /* Character temporary */
137 register char *lbp
; /* Pointer into stack buffer */
138 register char *s
; /* %s temporary */
139 int i
; /* General integer temporary */
140 int b
; /* Conversion base */
142 #define PUTCHAR(c) { \
143 if (lbp >= &linebuf[128]) { \
144 _write(fd, linebuf, lbp - &linebuf[0]); \
152 while ((c
= *fmt
++) != '%') {
154 _write(fd
, linebuf
, lbp
- &linebuf
[0]);
161 /* THIS CODE IS VAX DEPENDENT IN HANDLING %l? AND %c */
168 case 'u': /* what a joke */
174 lbp
= printn(fd
, va_arg(adx
, u_long
), b
, &linebuf
[0], lbp
,
179 b
= va_arg(adx
, int);
180 for (i
= 24; i
>= 0; i
-= 8)
181 if (c
= (b
>> i
) & 0x7f) {
187 s
= va_arg(adx
, char *);
201 * Printn prints a number n in base b.
204 printn(fd
, n
, b
, linebufp
, lbp
, linebufend
)
205 int fd
; /* File descriptor to get output */
206 u_long n
; /* Number */
208 char *linebufp
; /* Buffer location */
209 register char *lbp
; /* Current offset in buffer */
210 char *linebufend
; /* Where buffer ends */
212 char prbuf
[11]; /* Local result accumulator */
216 #define PUTCHAR(c) { \
217 if (lbp >= linebufend) { \
218 _write(fd, linebufp, lbp - linebufp); \
224 if (b
== 10 && (int)n
< 0) {
226 n
= (unsigned)(-(int)n
);
230 *cp
++ = "0123456789abcdef"[n
%b
];
235 } while (cp
> prbuf
);
250 return (write(fd
, buf
, len
));