xref: /titanic_52/usr/src/cmd/mail/Tout.c (revision da5577f07f6199b51ea374581248790c288e827b)
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 #pragma ident	"%Z%%M%	%I%	%E% SMI"	/* SVr4.0 2.	*/
27 /*
28     NAME
29 	Tout - Print surrogate debug output
30 
31     SYNOPSIS
32 	void Tout(char *subname, char *msg, ...)
33 
34     DESCRIPTION
35 	Tout prints debugging output if surrogate tracing
36 	has been turned on (-T specified). The message will
37 	also go to the debug output if debugging is turned
38 	on (-x specified). The subroutine name is printed
39 	if it is not a null string.
40 */
41 #include "mail.h"
42 #ifdef __STDC__
43 # include <stdarg.h>
44 #else
45 # include <varargs.h>
46 #endif
47 
48 /* VARARGS2 PRINTFLIKE2 */
49 void
50 #ifdef __STDC__
51 Tout(char *subname, char *fmt, ...)
52 #else
53 # ifdef lint
54 Tout(Xsubname, Xfmt, va_alist)
55 char *Xsubname, *Xfmt;
56 va_dcl
57 # else
58 Tout(va_alist)
59 va_dcl
60 # endif
61 #endif
62 {
63 #ifndef __STDC__
64         char    *subname;
65         char    *fmt;
66 #endif
67         va_list args;
68 
69 #if !defined(__STDC__) && defined(lint)
70 	subname = Xsubname;
71 	fmt = Xfmt;
72 #endif
73 
74         if (debug > 0) {
75 #ifdef __STDC__
76                 va_start(args, fmt);
77 #else
78                 va_start(args);
79                 subname = va_arg(args, char *);
80                 fmt = va_arg(args, char *);
81 #endif
82                 if (subname && *subname) {
83                         fprintf(dbgfp,"%s(): ", subname);
84                 }
85                 vfprintf(dbgfp, fmt, args);
86                 va_end(args);
87         }
88 
89         if (flgT) {
90 #ifdef __STDC__
91                 va_start(args, fmt);
92 #else
93                 va_start(args);
94                 subname = va_arg(args, char *);
95                 fmt = va_arg(args, char *);
96 #endif
97                 vfprintf(stdout, fmt, args);
98                 va_end(args);
99         }
100 }
101