KPRINTF(9) NetBSD Kernel Manual KPRINTF(9)
NAME
printf, snprintf, vprintf, vsnprintf, uprintf, ttyprintf, tprintf - ker- nel formatted output conversion
SYNOPSIS
#include <sys/systm.h> void printf(const char *format, ...); int snprintf(char *buf, size_t size, const char *format, ...); void vprintf(const char *format, va_list ap); int vsnprintf(char *buf, size_t size, const char *format, va_list ap); void uprintf(const char *format, ...); void ttyprintf(struct tty *tty, const char *format, ...); #include <sys/tprintf.h> tpr_t tprintf_open(struct proc *p); void tprintf(tpr_t tpr, const char *format, ...); void tprintf_close(tpr_t tpr);
DESCRIPTION
The printf() family of functions allows the kernel to send formatted mes- sages to various output devices. The functions printf() and vprintf() send formatted strings to the system console. The functions snprintf() and vsnprintf() write output to a string buffer. These four functions work similarly to their user space counterparts, and are not described in detail here. The functions uprintf() and ttyprintf() send formatted strings to the current process's controlling tty and a specific tty, respectively. The 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 tprintf_open() with the target process as an argument. This handle must be closed with a matching call to tprintf_close().
RETURN VALUES
The snprintf() and vsnprintf() functions return the number of characters placed in the buffer buf.
SEE ALSO
printf(1), printf(3), bitmask_snprintf(9)
CODE REFERENCES
sys/kern/subr_prf.c
HISTORY
The sprintf() and vsprintf() unsized string formatting functions are sup- ported for compatibility only, and are not documented here. New code should use the size-limited snprintf() and vsnprintf() functions instead. In NetBSD 1.5 and earlier, printf() supported more format strings than the user space printf(). These nonstandard format strings are no longer supported. For the functionality provided by the former %b format string, see bitmask_snprintf(9).
BUGS
The uprintf() and ttyprintf() functions should be used sparingly, if at all. Where multiple lines of output are required to reach a process's controlling terminal, tprintf() is preferred. NetBSD 1.6 September 1, 1998 2
Powered by man-cgi (2024-08-26). Maintained for NetBSD by Kimmo Suominen. Based on man-cgi by Panagiotis Christias.