1    | /*****
2    |  ** ** Module Header ******************************************************* **
3    |  ** 									     **
4    |  **   Modules Revision 3.0						     **
5    |  **   Providing a flexible user environment				     **
6    |  ** 									     **
7    |  **   File:		cmdVerbose.c					     **
8    |  **   First Edition:	1995/12/31					     **
9    |  ** 									     **
10   |  **   Authors:	Jens Hamisch, jens@Strawberry.COM			     **
11   |  ** 									     **
12   |  **   Description:	The Tcl module-verbose routine allows switchin ver-  **
13   |  **			bosity on and off during module file execution	     **
14   |  ** 									     **
15   |  **   Exports:		cmdModuleVerbose				     **
16   |  ** 									     **
17   |  **   Notes:								     **
18   |  ** 									     **
19   |  ** ************************************************************************ **
20   |  ****/
21   | 
22   | /** ** Copyright *********************************************************** **
23   |  ** 									     **
24   |  ** Copyright 1991-1994 by John L. Furlan.                      	     **
25   |  ** see LICENSE.GPL, which must be provided, for details		     **
26   |  ** 									     ** 
27   |  ** ************************************************************************ **/
28   | 
29   | static char Id[] = "@(#)$Id: cmdVerbose.c.src.html,v 1.6 2006/01/18 05:35:11 rkowen Exp $";
30   | static void *UseId[] = { &UseId, Id };
31   | 
32   | /** ************************************************************************ **/
33   | /** 				      HEADERS				     **/
34   | /** ************************************************************************ **/
35   | 
36   | #include "modules_def.h"
37   | 
38   | /** ************************************************************************ **/
39   | /** 				  LOCAL DATATYPES			     **/
40   | /** ************************************************************************ **/
41   | 
42   | /** not applicable **/
43   | 
44   | /** ************************************************************************ **/
45   | /** 				     CONSTANTS				     **/
46   | /** ************************************************************************ **/
47   | 
48   | /** not applicable **/
49   | 
50   | /** ************************************************************************ **/
51   | /**				      MACROS				     **/
52   | /** ************************************************************************ **/
53   | 
54   | /** not applicable **/
55   | 
56   | /** ************************************************************************ **/
57   | /** 				    LOCAL DATA				     **/
58   | /** ************************************************************************ **/
59   | 
60   | static	char	module_name[] = "cmdVerbose.c";	/** File name of this module **/
61   | #if WITH_DEBUGGING_CALLBACK
62   | static	char	_proc_cmdModuleVerbose[] = "cmdModuleVerbose";
63   | #endif
64   | 
65   | /** ************************************************************************ **/
66   | /**				    PROTOTYPES				     **/
67   | /** ************************************************************************ **/
68   | 
69   | /** not applicable **/
70   | 
71   | 
72   | /*++++
73   |  ** ** Function-Header ***************************************************** **
74   |  ** 									     **
75   |  **   Function:		cmdModuleVerbose				     **
76   |  ** 									     **
77   |  **   Description:	Callback function for 'verbose'			     **
78   |  ** 									     **
79   |  **   First Edition:	1995/12/31					     **
80   |  ** 									     **
81   |  **   Parameters:	ClientData	 client_data			     **
82   |  **			Tcl_Interp	*interp		According Tcl interp.**
83   |  **			int		 argc		Number of arguments  **
84   |  **			char		*argv[]		Argument array	     **
85   |  ** 									     **
86   |  **   Result:		int	TCL_OK		Successfull completion	     **
87   |  **				TCL_ERROR	Any error		     **
88   |  ** 									     **
89   |  **   Attached Globals:	sw_verbose	The verbose level selector	     **
90   |  **   			g_flags		These are set up accordingly before  **
91   |  **					this function is called in order to  **
92   |  **					control everything		     **
93   |  ** 									     **
94   |  ** ************************************************************************ **
95   |  ++++*/
96   | 
97   | int	cmdModuleVerbose(	ClientData	 client_data,
98   | 		      		Tcl_Interp	*interp,
99   | 		      		int		 argc,
100  | 		      		CONST84 char	*argv[])
101  | {
102  | #if WITH_DEBUGGING_CALLBACK
103  |     ErrorLogger( NO_ERR_START, LOC, _proc_cmdModuleVerbose, NULL);
104  | #endif
105  |     char **argptr = (char **) argv;
106  | 
107  |     /**
108  |      **  Whatis mode?
109  |      **/
110  | 
111  |     if( g_flags & (M_WHATIS | M_HELP))
112  |         return( TCL_OK);		/** ------- EXIT PROCEDURE -------> **/
113  | 	
114  |     /**
115  |      **  Parameter check
116  |      **/
117  | 
118  |     if( argc < 2) {
119  | 	if( OK != ErrorLogger( ERR_USAGE, LOC, argptr[0], " on|off|fmt [args]",
120  | 	    NULL))
121  | 	    return( TCL_ERROR);		/** -------- EXIT (FAILURE) -------> **/
122  |     }
123  |   
124  |     /**
125  |      **  Display mode?
126  |      **/
127  | 
128  |     if( g_flags & M_DISPLAY) {
129  | 	fprintf( stderr, "%s ", argptr[ 0]);
130  | 	while( --argc)
131  | 	    fprintf( stderr, "%s ", *++argptr);
132  | 	fprintf( stderr, "\n");
133  |         return( TCL_OK);		/** ------- EXIT PROCEDURE -------> **/
134  |     }
135  | 
136  |     /**
137  |      **  on or off
138  |      **/
139  | 
140  |     if( !strcmp( argptr[1], "on"))
141  | 	sw_verbose = 1;
142  |     else if( !strcmp( argptr[1], "off"))
143  | 	sw_verbose = 0;
144  |     else
145  | 	Module_Verbosity( --argc, ++argptr);
146  | 
147  | #if WITH_DEBUGGING_CALLBACK
148  |     ErrorLogger( NO_ERR_END, LOC, _proc_cmdModuleVerbose, NULL);
149  | #endif
150  | 
151  |     return( TCL_OK);
152  | 
153  | } /** End of 'cmdModuleVerbose' **/
154  |