From 7101ba5caa38060b2d927dc5bd81c320b7055e6b Mon Sep 17 00:00:00 2001 From: phk Date: Sun, 26 Nov 2000 20:35:21 +0000 Subject: Simplify the tprintf() API. Loose the special #include file. --- sys/kern/subr_prf.c | 52 ++++++++++++++++++---------------------------------- 1 file changed, 18 insertions(+), 34 deletions(-) (limited to 'sys/kern/subr_prf.c') diff --git a/sys/kern/subr_prf.c b/sys/kern/subr_prf.c index 13a4ade..4fb776b 100644 --- a/sys/kern/subr_prf.c +++ b/sys/kern/subr_prf.c @@ -46,7 +46,6 @@ #include #include #include -#include #include #include @@ -121,53 +120,39 @@ uprintf(const char *fmt, ...) return retval; } -tpr_t -tprintf_open(p) - struct proc *p; -{ - - if (p->p_flag & P_CONTROLT && p->p_session->s_ttyvp) { - SESSHOLD(p->p_session); - return ((tpr_t) p->p_session); - } - return ((tpr_t) NULL); -} - -void -tprintf_close(sess) - tpr_t sess; -{ - - if (sess) - SESSRELE((struct session *) sess); -} - /* * tprintf prints on the controlling terminal associated - * with the given session. + * with the given session, possibly to the log as well. */ -int -tprintf(tpr_t tpr, const char *fmt, ...) +void +tprintf(struct proc *p, int pri, const char *fmt, ...) { - struct session *sess = (struct session *)tpr; struct tty *tp = NULL; - int flags = TOLOG; + int flags = 0, shld = 0; va_list ap; struct putchar_arg pca; int retval; - logpri(LOG_INFO); - if (sess && sess->s_ttyvp && ttycheckoutq(sess->s_ttyp, 0)) { - flags |= TOTTY; - tp = sess->s_ttyp; + if (pri != -1) { + logpri(pri); + flags |= TOLOG; + } + if (p->p_flag & P_CONTROLT && p->p_session->s_ttyvp) { + SESSHOLD(p->p_session); + shld++; + if (ttycheckoutq(p->p_session->s_ttyp, 0)) { + flags |= TOTTY; + tp = p->p_session->s_ttyp; + } } - va_start(ap, fmt); pca.tty = tp; pca.flags = flags; + va_start(ap, fmt); retval = kvprintf(fmt, putchar, &pca, 10, ap); va_end(ap); + if (shld) + SESSRELE(p->p_session); logwakeup(); - return retval; } /* @@ -222,7 +207,6 @@ log(int level, const char *fmt, ...) va_end(ap); } logwakeup(); - return retval; } static void -- cgit v1.1