xref: /illumos-gate/usr/src/cmd/mail/Dout.c (revision 20a7641f9918de8574b8b3b47dbe35c4bfc78df1)
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 	Dout - Print debug output
28 
29     SYNOPSIS
30 	void Dout(char *subname, int level, char *msg, ...)
31 
32     DESCRIPTION
33 	Dout prints debugging output if debugging is turned
34 	on (-x specified) and the level of this message is
35 	lower than the value of the global variable debug.
36 	The subroutine name is printed if it is not a null
37 	string.
38 */
39 #include "mail.h"
40 #ifdef __STDC__
41 # include <stdarg.h>
42 #else
43 # include <varargs.h>
44 #endif
45 
46 /* VARARGS3 PRINTFLIKE3 */
47 void
48 #ifdef __STDC__
49 Dout(char *subname, int level, char *fmt, ...)
50 #else
51 # ifdef lint
52 Dout(Xsubname, Xlevel, Xfmt, va_alist)
53 char *Xsubname, *Xfmt;
54 int Xlevel;
55 va_dcl
56 # else
57 Dout(va_alist)
58 va_dcl
59 # endif
60 #endif
61 {
62 #ifndef __STDC__
63 	char    *subname;
64 	int	level;
65 	char    *fmt;
66 #endif
67 	va_list args;
68 
69 #ifndef __STDC__
70 #ifdef lint
71 	subname = Xsubname;
72 	level = Xlevel;
73 	fmt = Xfmt;
74 # endif
75 #endif
76 
77 #ifdef __STDC__
78 	va_start(args, fmt);
79 #else
80 	va_start(args);
81 	subname = va_arg(args, char *);
82 	level = va_arg(args, int);
83 	fmt = va_arg(args, char *);
84 #endif
85 
86 	if (debug > level) {
87 		if (subname && *subname) {
88 			fprintf(dbgfp,"%s(): ", subname);
89 		}
90 		vfprintf(dbgfp, fmt, args);
91 	}
92 	va_end(args);
93 }
94