xref: /illumos-gate/usr/src/cmd/mail/Tout.c (revision 2a8bcb4e)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
23 /*	  All Rights Reserved  	*/
24 
25 /*
26     NAME
27 	Tout - Print surrogate debug output
28 
29     SYNOPSIS
30 	void Tout(char *subname, char *msg, ...)
31 
32     DESCRIPTION
33 	Tout prints debugging output if surrogate tracing
34 	has been turned on (-T specified). The message will
35 	also go to the debug output if debugging is turned
36 	on (-x specified). The subroutine name is printed
37 	if it is not a null string.
38 */
39 #include "mail.h"
40 #ifdef __STDC__
41 # include <stdarg.h>
42 #else
43 # include <varargs.h>
44 #endif
45 
46 /* VARARGS2 PRINTFLIKE2 */
47 void
48 #ifdef __STDC__
Tout(char * subname,char * fmt,...)49 Tout(char *subname, char *fmt, ...)
50 #else
51 # ifdef lint
52 Tout(Xsubname, Xfmt, va_alist)
53 char *Xsubname, *Xfmt;
54 va_dcl
55 # else
56 Tout(va_alist)
57 va_dcl
58 # endif
59 #endif
60 {
61 #ifndef __STDC__
62         char    *subname;
63         char    *fmt;
64 #endif
65         va_list args;
66 
67 #if !defined(__STDC__) && defined(lint)
68 	subname = Xsubname;
69 	fmt = Xfmt;
70 #endif
71 
72         if (debug > 0) {
73 #ifdef __STDC__
74                 va_start(args, fmt);
75 #else
76                 va_start(args);
77                 subname = va_arg(args, char *);
78                 fmt = va_arg(args, char *);
79 #endif
80                 if (subname && *subname) {
81                         fprintf(dbgfp,"%s(): ", subname);
82                 }
83                 vfprintf(dbgfp, fmt, args);
84                 va_end(args);
85         }
86 
87         if (flgT) {
88 #ifdef __STDC__
89                 va_start(args, fmt);
90 #else
91                 va_start(args);
92                 subname = va_arg(args, char *);
93                 fmt = va_arg(args, char *);
94 #endif
95                 vfprintf(stdout, fmt, args);
96                 va_end(args);
97         }
98 }
99