Simplify the tprintf() API.

Loose the special <sys/tprintf.h> #include file.
This commit is contained in:
Poul-Henning Kamp 2000-11-26 20:35:21 +00:00
parent 4d88c4598f
commit a52585d77e
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=69214
6 changed files with 22 additions and 107 deletions

View File

@ -46,7 +46,6 @@
#include <sys/malloc.h>
#include <sys/proc.h>
#include <sys/tty.h>
#include <sys/tprintf.h>
#include <sys/syslog.h>
#include <sys/cons.h>
@ -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

View File

@ -53,7 +53,6 @@
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <sys/syslog.h>
#include <sys/tprintf.h>
#include <sys/sysctl.h>
#include <sys/signalvar.h>
@ -1969,14 +1968,8 @@ nfs_msg(p, server, msg)
struct proc *p;
char *server, *msg;
{
tpr_t tpr;
if (p)
tpr = tprintf_open(p);
else
tpr = NULL;
tprintf(tpr, "nfs server %s: %s\n", server, msg);
tprintf_close(tpr);
tprintf(p, LOG_INFO, "nfs server %s: %s\n", server, msg);
return (0);
}

View File

@ -53,7 +53,6 @@
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <sys/syslog.h>
#include <sys/tprintf.h>
#include <sys/sysctl.h>
#include <sys/signalvar.h>
@ -1969,14 +1968,8 @@ nfs_msg(p, server, msg)
struct proc *p;
char *server, *msg;
{
tpr_t tpr;
if (p)
tpr = tprintf_open(p);
else
tpr = NULL;
tprintf(tpr, "nfs server %s: %s\n", server, msg);
tprintf_close(tpr);
tprintf(p, LOG_INFO, "nfs server %s: %s\n", server, msg);
return (0);
}

View File

@ -53,7 +53,6 @@
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <sys/syslog.h>
#include <sys/tprintf.h>
#include <sys/sysctl.h>
#include <sys/signalvar.h>
@ -1969,14 +1968,8 @@ nfs_msg(p, server, msg)
struct proc *p;
char *server, *msg;
{
tpr_t tpr;
if (p)
tpr = tprintf_open(p);
else
tpr = NULL;
tprintf(tpr, "nfs server %s: %s\n", server, msg);
tprintf_close(tpr);
tprintf(p, LOG_INFO, "nfs server %s: %s\n", server, msg);
return (0);
}

View File

@ -122,6 +122,7 @@ long strtol __P((const char *, char **, int));
u_long strtoul __P((const char *, char **, int));
quad_t strtoq __P((const char *, char **, int));
u_quad_t strtouq __P((const char *, char **, int));
void tprintf __P((struct proc *p, int pri, const char *, ...)) __printflike(3, 4);
void bcopy __P((const void *from, void *to, size_t len));
void ovbcopy __P((const void *from, void *to, size_t len));

View File

@ -1,49 +0,0 @@
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
*
* 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 University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
*
* @(#)tprintf.h 8.1 (Berkeley) 6/2/93
* $FreeBSD$
*/
#ifndef _SYS_TPRINTF_H_
#define _SYS_TPRINTF_H_
typedef struct session *tpr_t;
struct proc;
tpr_t tprintf_open __P((struct proc *));
void tprintf_close __P((tpr_t));
int tprintf __P((tpr_t, const char *fmt, ...)) __printflike(2, 3);
#endif