Add a vtprintf. It is to tprintf what vprintf is to printf.

Reviewed by:	kib
This commit is contained in:
Navdeep Parhar 2013-09-07 07:53:21 +00:00
parent d6d3e03e1e
commit 34c916c6d2
2 changed files with 13 additions and 5 deletions

View File

@ -175,15 +175,24 @@ out:
}
/*
* tprintf prints on the controlling terminal associated with the given
* session, possibly to the log as well.
* tprintf and vtprintf print on the controlling terminal associated with the
* given session, possibly to the log as well.
*/
void
tprintf(struct proc *p, int pri, const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
vtprintf(p, pri, fmt, ap);
va_end(ap);
}
void
vtprintf(struct proc *p, int pri, const char *fmt, va_list ap)
{
struct tty *tp = NULL;
int flags = 0;
va_list ap;
struct putchar_arg pca;
struct session *sess = NULL;
@ -208,13 +217,11 @@ tprintf(struct proc *p, int pri, const char *fmt, ...)
pca.tty = tp;
pca.flags = flags;
pca.p_bufr = NULL;
va_start(ap, fmt);
if (pca.tty != NULL)
tty_lock(pca.tty);
kvprintf(fmt, putchar, &pca, 10, ap);
if (pca.tty != NULL)
tty_unlock(pca.tty);
va_end(ap);
if (sess != NULL)
sess_release(sess);
msgbuftrigger = 1;

View File

@ -212,6 +212,7 @@ u_long strtoul(const char *, char **, int) __nonnull(1);
quad_t strtoq(const char *, char **, int) __nonnull(1);
u_quad_t strtouq(const char *, char **, int) __nonnull(1);
void tprintf(struct proc *p, int pri, const char *, ...) __printflike(3, 4);
void vtprintf(struct proc *, int, const char *, __va_list) __printflike(3, 0);
void hexdump(const void *ptr, int length, const char *hdr, int flags);
#define HD_COLUMN_MASK 0xff
#define HD_DELIM_MASK 0xff00