subr_prf.c (4d88c4598f14e4d5082a49db412c90511fc2d3b2) subr_prf.c (a52585d77efffcaa9e29319304a4dc888aed7a86)
1/*-
2 * Copyright (c) 1986, 1988, 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 * (c) UNIX System Laboratories, Inc.
5 * All or some portions of this file are derived from material licensed
6 * to the University of California by American Telephone and Telegraph
7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 * the permission of UNIX System Laboratories, Inc.

--- 32 unchanged lines hidden (view full) ---

41
42#include <sys/param.h>
43#include <sys/systm.h>
44#include <sys/kernel.h>
45#include <sys/msgbuf.h>
46#include <sys/malloc.h>
47#include <sys/proc.h>
48#include <sys/tty.h>
1/*-
2 * Copyright (c) 1986, 1988, 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 * (c) UNIX System Laboratories, Inc.
5 * All or some portions of this file are derived from material licensed
6 * to the University of California by American Telephone and Telegraph
7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 * the permission of UNIX System Laboratories, Inc.

--- 32 unchanged lines hidden (view full) ---

41
42#include <sys/param.h>
43#include <sys/systm.h>
44#include <sys/kernel.h>
45#include <sys/msgbuf.h>
46#include <sys/malloc.h>
47#include <sys/proc.h>
48#include <sys/tty.h>
49#include <sys/tprintf.h>
50#include <sys/syslog.h>
51#include <sys/cons.h>
52
53/*
54 * Note that stdarg.h and the ANSI style va_start macro is used for both
55 * ANSI and traditional C compilers.
56 */
57#include <machine/stdarg.h>

--- 58 unchanged lines hidden (view full) ---

116 pca.tty = p->p_session->s_ttyp;
117 pca.flags = TOTTY;
118 retval = kvprintf(fmt, putchar, &pca, 10, ap);
119 va_end(ap);
120 }
121 return retval;
122}
123
49#include <sys/syslog.h>
50#include <sys/cons.h>
51
52/*
53 * Note that stdarg.h and the ANSI style va_start macro is used for both
54 * ANSI and traditional C compilers.
55 */
56#include <machine/stdarg.h>

--- 58 unchanged lines hidden (view full) ---

115 pca.tty = p->p_session->s_ttyp;
116 pca.flags = TOTTY;
117 retval = kvprintf(fmt, putchar, &pca, 10, ap);
118 va_end(ap);
119 }
120 return retval;
121}
122
124tpr_t
125tprintf_open(p)
126 struct proc *p;
127{
128
129 if (p->p_flag & P_CONTROLT && p->p_session->s_ttyvp) {
130 SESSHOLD(p->p_session);
131 return ((tpr_t) p->p_session);
132 }
133 return ((tpr_t) NULL);
134}
135
136void
137tprintf_close(sess)
138 tpr_t sess;
139{
140
141 if (sess)
142 SESSRELE((struct session *) sess);
143}
144
145/*
146 * tprintf prints on the controlling terminal associated
123/*
124 * tprintf prints on the controlling terminal associated
147 * with the given session.
125 * with the given session, possibly to the log as well.
148 */
126 */
149int
150tprintf(tpr_t tpr, const char *fmt, ...)
127void
128tprintf(struct proc *p, int pri, const char *fmt, ...)
151{
129{
152 struct session *sess = (struct session *)tpr;
153 struct tty *tp = NULL;
130 struct tty *tp = NULL;
154 int flags = TOLOG;
131 int flags = 0, shld = 0;
155 va_list ap;
156 struct putchar_arg pca;
157 int retval;
158
132 va_list ap;
133 struct putchar_arg pca;
134 int retval;
135
159 logpri(LOG_INFO);
160 if (sess && sess->s_ttyvp && ttycheckoutq(sess->s_ttyp, 0)) {
161 flags |= TOTTY;
162 tp = sess->s_ttyp;
136 if (pri != -1) {
137 logpri(pri);
138 flags |= TOLOG;
163 }
139 }
164 va_start(ap, fmt);
140 if (p->p_flag & P_CONTROLT && p->p_session->s_ttyvp) {
141 SESSHOLD(p->p_session);
142 shld++;
143 if (ttycheckoutq(p->p_session->s_ttyp, 0)) {
144 flags |= TOTTY;
145 tp = p->p_session->s_ttyp;
146 }
147 }
165 pca.tty = tp;
166 pca.flags = flags;
148 pca.tty = tp;
149 pca.flags = flags;
150 va_start(ap, fmt);
167 retval = kvprintf(fmt, putchar, &pca, 10, ap);
168 va_end(ap);
151 retval = kvprintf(fmt, putchar, &pca, 10, ap);
152 va_end(ap);
153 if (shld)
154 SESSRELE(p->p_session);
169 logwakeup();
155 logwakeup();
170 return retval;
171}
172
173/*
174 * Ttyprintf displays a message on a tty; it should be used only by
175 * the tty driver, or anything that knows the underlying tty will not
176 * be revoke(2)'d away. Other callers should use tprintf.
177 */
178int

--- 38 unchanged lines hidden (view full) ---

217 struct putchar_arg pca;
218 va_start(ap, fmt);
219 pca.tty = NULL;
220 pca.flags = TOCONS;
221 retval += kvprintf(fmt, putchar, &pca, 10, ap);
222 va_end(ap);
223 }
224 logwakeup();
156}
157
158/*
159 * Ttyprintf displays a message on a tty; it should be used only by
160 * the tty driver, or anything that knows the underlying tty will not
161 * be revoke(2)'d away. Other callers should use tprintf.
162 */
163int

--- 38 unchanged lines hidden (view full) ---

202 struct putchar_arg pca;
203 va_start(ap, fmt);
204 pca.tty = NULL;
205 pca.flags = TOCONS;
206 retval += kvprintf(fmt, putchar, &pca, 10, ap);
207 va_end(ap);
208 }
209 logwakeup();
225 return retval;
226}
227
228static void
229logpri(level)
230 int level;
231{
232 char nbuf[MAXNBUF];
233 char *p;

--- 565 unchanged lines hidden ---
210}
211
212static void
213logpri(level)
214 int level;
215{
216 char nbuf[MAXNBUF];
217 char *p;

--- 565 unchanged lines hidden ---