4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
28 /* All Rights Reserved */
40 #include <sys/types.h>
44 * consolidation pkg command library includes
50 * internal global variables
53 static boolean_t debugFlag
= B_FALSE
; /* debug messages enabled? */
54 static boolean_t echoFlag
= B_TRUE
; /* interactive msgs enabled? */
57 * *****************************************************************************
58 * global external (public) functions
59 * *****************************************************************************
64 * Synopsis: Output an interactive message if interaction is enabled
65 * Description: Main method for outputting an interactive message; call to
66 * output interactive message if interation has not been disabled
67 * by a previous call to echoSetFlag(0).
68 * Arguments: format - [RO, RO*] (char *)
69 * printf-style format for debugging message to be output
70 * VARG_LIST - [RO] (?)
71 * arguments as appropriate to 'format' specified
81 /* output message if echoing is enabled */
83 if (echoFlag
== B_TRUE
) {
86 (void) vfprintf(stderr
, fmt
, ap
);
90 (void) putc('\n', stderr
);
96 * Synopsis: Output a debugging message if debugging is enabled
97 * Description: Main method for outputting a debugging message; call to
98 * output debugging message if debugging has been enabled
99 * by a previous call to echoDebugSetFlag(1).
100 * Arguments: format - [RO, RO*] (char *)
101 * printf-style format for debugging message to be output
102 * VARG_LIST - [RO] (?)
103 * arguments as appropriate to 'format' specified
105 * NOTE: format of message will be:
106 * # [ aaa bbb ccc ] message
107 * where: aaa - process i.d.
109 * ccc - name of program
111 * # [ 25685 0 pkgadd ] unable to get package list
116 echoDebug(char *a_fmt
, ...)
120 /* output debugging message if debugging is enabled */
122 if (debugFlag
== B_TRUE
) {
123 char *p
= get_prog_name();
125 (void) fprintf(stderr
, "# [%6d %3d", getpid(), getzoneid());
127 if ((p
!= (char *)NULL
) && (*p
!= '\0')) {
128 fprintf(stderr
, " %-11s", p
);
131 (void) fprintf(stderr
, "] ");
135 (void) vfprintf(stderr
, a_fmt
, ap
);
139 (void) putc('\n', stderr
);
144 * get the "interactive message enabled" flag
153 * set the "interactive message enabled" flag
157 echoSetFlag(boolean_t a_echoFlag
)
162 echoFlag
= a_echoFlag
;
167 * get the "debugging message enabled" flag
171 echoDebugGetFlag(void) {
176 * set the "debugging message enabled" flag
180 echoDebugSetFlag(boolean_t a_debugFlag
)
184 oldvalue
= debugFlag
;
185 debugFlag
= a_debugFlag
;