xref: /titanic_41/usr/src/cmd/lvm/metassist/common/volume_output.h (revision 6185db853e024a486ff8837e6784dd290d866112)
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 /*
23  * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _VOLUME_OUTPUT_H
28 #define	_VOLUME_OUTPUT_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 #include <stdio.h>
37 #include <stdarg.h>
38 
39 #ifdef DEBUG
40 /*
41  * The environment variable that must be set for metassist to
42  * enable debug output
43  */
44 #define	METASSIST_DEBUG_ENV	"METASSIST_DEBUG"
45 #endif
46 
47 /* Verbosity levels */
48 #define	OUTPUT_QUIET	0
49 #define	OUTPUT_TERSE	1
50 #define	OUTPUT_VERBOSE	2
51 #define	OUTPUT_DEBUG	3
52 
53 /*
54  * Set the maximum level of verbosity to be reported to the user.
55  * Strings sent to oprintf() with a higher verbosity level than this
56  * maximum level will not be reported to the user.
57  *
58  * @param       verbosity
59  *              One of the predefined constants:
60  *                OUTPUT_QUIET
61  *                OUTPUT_TERSE
62  *                OUTPUT_VERBOSE
63  *                OUTPUT_DEBUG
64  *
65  * @param       stream
66  *              The stream to print all qualifying output to.
67  *
68  * @return      0 on success, non-zero otherwise.
69  */
70 extern int set_max_verbosity(int verbosity, FILE *stream);
71 
72 /*
73  * Get the maximum level of verbosity to be reported to the user.
74  *
75  * @return      OUTPUT_QUIET
76  *
77  * @return      OUTPUT_TERSE
78  *
79  * @return      OUTPUT_VERBOSE
80  *
81  * @return      OUTPUT_DEBUG
82  */
83 extern int get_max_verbosity();
84 
85 /*
86  * Prints the given formatted string arguments to a predefined stream,
87  * if the given verbosity is less than or equal to the set maximum
88  * verbosity.
89  *
90  * @param       verbosity
91  *              Same as for set_max_verbosity()
92  *
93  * @param       fmt, ...
94  *              printf-style arguments
95  *
96  * @return      the number of characters output
97  *              if successful
98  *
99  * @return      negative value
100  *              if unsuccessful
101  */
102 extern int oprintf(int verbosity, char *fmt, ...);
103 
104 /*
105  * Identical to oprintf but with a va_list instead of variable length
106  * argument list.  This function is provided for external printf-style
107  * wrappers.
108  *
109  * @param       verbosity
110  *              Same as for set_max_verbosity()
111  *
112  * @param       fmt
113  *              printf format string
114  *
115  * @param       ap
116  *              a va_list containing remaining printf-style arguments
117  *
118  * @return      the number of characters output
119  *              if successful
120  *
121  * @return      negative value
122  *              if unsuccessful
123  */
124 extern int oprintf_va(int verbosity, char *fmt, va_list ap);
125 
126 #ifdef __cplusplus
127 }
128 #endif
129 
130 #endif /* _VOLUME_OUTPUT_H */
131