* Copyright (c) 1991 The Regents of the University of California.
* %sccs.include.redist.c%
* @(#)clnp_sprintf.c 7.1 (Berkeley) %G%
* CLNP needs a version of sprintf in the kernel. If anything else
* ever needs it, this can trivially be dropped into kern/subr_prf.c.
* Note that stdarg.h and the ANSI style va_start macro is used for both
* ANSI and traditional C compilers.
#include <machine/stdarg.h>
int sprintf
__P((char *, const char *, ...));
* Scaled down version of sprintf(3).
sprintf(char *buf
, const char *fmt
, ...)
sprintf(buf
, fmt
/*, va_alist */)
int lflag
; /* hold a long in base 8 */
char num
[(sizeof(long) * NBBY
/ 3) + 1];
while ((ch
= *fmt
++) != '%') {
reswitch
: switch (ch
= *fmt
++) {
va_arg(ap
, long) : va_arg(ap
, int);
va_arg(ap
, u_long
) : va_arg(ap
, u_int
);
va_arg(ap
, u_long
) : va_arg(ap
, u_int
);
va_arg(ap
, u_long
) : va_arg(ap
, u_int
);
*p
++ = "0123456789abcdef"[ul
% base
];