143 lines
4.5 KiB
Groff
143 lines
4.5 KiB
Groff
.\" $NetBSD: kprintf.9,v 1.10 2001/09/04 02:51:16 wiz Exp $
|
|
.\"
|
|
.\" Copyright (c) 1998 The NetBSD Foundation, Inc.
|
|
.\" All rights reserved.
|
|
.\"
|
|
.\" This code is derived from software contributed to The NetBSD Foundation
|
|
.\" by Jeremy Cooper.
|
|
.\"
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
.\" modification, are permitted provided that the following conditions
|
|
.\" are met:
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
.\" 3. All advertising materials mentioning features or use of this software
|
|
.\" must display the following acknowledgement:
|
|
.\" This product includes software developed by the NetBSD
|
|
.\" Foundation, Inc. and its contributors.
|
|
.\" 4. Neither the name of The NetBSD Foundation nor the names of its
|
|
.\" contributors may be used to endorse or promote products derived
|
|
.\" from this software without specific prior written permission.
|
|
.\"
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
.\" POSSIBILITY OF SUCH DAMAGE.
|
|
.\"
|
|
.Dd September 1, 1998
|
|
.Dt KPRINTF 9
|
|
.Os
|
|
.Sh NAME
|
|
.Nm printf, snprintf, vprintf, vsnprintf, uprintf, ttyprintf, tprintf
|
|
.Nd kernel formatted output conversion
|
|
.Sh SYNOPSIS
|
|
.Fd #include <sys/systm.h>
|
|
.Ft void
|
|
.Fn "printf" "const char *format" "..."
|
|
.Ft int
|
|
.Fn "snprintf" "char *buf" "size_t size" "const char *format" "..."
|
|
.Ft void
|
|
.Fn "vprintf" "const char *format" "va_list ap"
|
|
.Ft int
|
|
.Fn "vsnprintf" "char *buf" "size_t size" "const char *format" "va_list ap"
|
|
.Ft void
|
|
.Fn "uprintf" "const char *format" "..."
|
|
.Ft void
|
|
.Fn "ttyprintf" "struct tty *tty" "const char *format" "..."
|
|
.Fd #include <sys/tprintf.h>
|
|
.Ft tpr_t
|
|
.Fn "tprintf_open" "struct proc *p"
|
|
.Ft void
|
|
.Fn "tprintf" "tpr_t tpr" "const char *format" "..."
|
|
.Ft void
|
|
.Fn "tprintf_close" "tpr_t tpr"
|
|
.Sh DESCRIPTION
|
|
The
|
|
.Fn printf
|
|
family of functions allows the kernel to send formatted messages to various
|
|
output devices.
|
|
The functions
|
|
.Fn printf
|
|
and
|
|
.Fn vprintf
|
|
send formatted strings to the system console.
|
|
The functions
|
|
.Fn snprintf
|
|
and
|
|
.Fn vsnprintf
|
|
write output to a string buffer. These four functions work similarly
|
|
to their user space counterparts, and are not described in detail here.
|
|
.Pp
|
|
The functions
|
|
.Fn uprintf
|
|
and
|
|
.Fn ttyprintf
|
|
send formatted strings to the current process's controlling tty and a specific
|
|
tty, respectively.
|
|
.Pp
|
|
The
|
|
.Fn tprintf
|
|
function sends formatted strings to a process's controlling tty,
|
|
via a handle of type tpr_t.
|
|
This allows multiple write operations to the tty with a guarantee that the
|
|
tty will be valid across calls. A handle is acquired by calling
|
|
.Fn tprintf_open
|
|
with the target process as an argument. This handle must be closed with
|
|
a matching call to
|
|
.Fn tprintf_close .
|
|
.Sh RETURN VALUES
|
|
The
|
|
.Fn snprintf
|
|
and
|
|
.Fn vsnprintf
|
|
functions return the number of characters placed in the buffer
|
|
.Fa buf .
|
|
.Sh SEE ALSO
|
|
.Xr printf 3 ,
|
|
.Xr printf 1 ,
|
|
.Xr bitmask_snprintf 9
|
|
.Sh CODE REFERENCES
|
|
.Pa sys/kern/subr_prf.c
|
|
.Sh HISTORY
|
|
The
|
|
.Fn sprintf
|
|
and
|
|
.Fn vsprintf
|
|
unsized string formatting functions are supported for compatibility only,
|
|
and are not documented here. New code should use the size-limited
|
|
.Fn snprintf
|
|
and
|
|
.Fn vsnprintf
|
|
functions instead.
|
|
.Pp
|
|
In
|
|
.Nx 1.5
|
|
and earlier,
|
|
.Fn printf
|
|
supported more format strings than the user space
|
|
.Fn printf .
|
|
These nonstandard format strings are no longer supported. For the
|
|
functionality provided by the former
|
|
.Li %b
|
|
format string, see
|
|
.Xr bitmask_snprintf 9 .
|
|
.Sh BUGS
|
|
The
|
|
.Fn uprintf
|
|
and
|
|
.Fn ttyprintf
|
|
functions should be used sparingly, if at all. Where multiple lines of
|
|
output are required to reach a process's controlling terminal,
|
|
.Fn tprintf
|
|
is preferred.
|