-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathModuleCmd_Display.c
185 lines (147 loc) · 5.69 KB
/
ModuleCmd_Display.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
/*****
** ** Module Header ******************************************************* **
** **
** Modules Revision 3.0 **
** Providing a flexible user environment **
** **
** File: ModuleCmd_Display.c **
** First Edition: 1991/10/23 **
** **
** Authors: John Furlan, [email protected] **
** Jens Hamisch, [email protected] **
** **
** Description: Displays what changes a modulefile will make to the **
** environment including any conflics or prerequisits. **
** **
** Exports: ModuleCmd_Display **
** **
** Notes: **
** **
** ************************************************************************ **
****/
/** ** Copyright *********************************************************** **
** **
** Copyright 1991-1994 by John L. Furlan. **
** see LICENSE.GPL, which must be provided, for details **
** **
** ************************************************************************ **/
static char Id[] = "@(#)$Id$";
static void *UseId[] = { &UseId, Id };
/** ************************************************************************ **/
/** HEADERS **/
/** ************************************************************************ **/
#include "modules_def.h"
/** ************************************************************************ **/
/** LOCAL DATATYPES **/
/** ************************************************************************ **/
/** not applicable **/
/** ************************************************************************ **/
/** CONSTANTS **/
/** ************************************************************************ **/
/** not applicable **/
/** ************************************************************************ **/
/** MACROS **/
/** ************************************************************************ **/
/** not applicable **/
/** ************************************************************************ **/
/** LOCAL DATA **/
/** ************************************************************************ **/
char local_line[] =
"-------------------------------------------------------------------";
static char module_name[] = __FILE__;
/** ************************************************************************ **/
/** PROTOTYPES **/
/** ************************************************************************ **/
/** not applicable **/
/*++++
** ** Function-Header ***************************************************** **
** **
** Function: ModuleCmd_Display **
** **
** Description: Execution of the module-command 'display' **
** Display every change a module 'load' would apply to **
** the environment **
** **
** First Edition: 1991/10/23 **
** **
** Parameters: Tcl_Interp *interp Attached Tcl Interp. **
** char *argv[] Argument list **
** **
** Result: int TCL_ERROR Failure **
** TCL_OK Successful operation **
** **
** Attached Globals: g_specified_module The module name from the **
** command line. **
** g_flags These are set up accordingly before **
** this function is called in order to **
** control everything **
** g_current_module The module which is handled **
** by the current command **
** **
** ************************************************************************ **
++++*/
int ModuleCmd_Display( Tcl_Interp *interp,
int argc,
char *argv[])
{
Tcl_Interp *disp_interp;
Tcl_DString cmdbuf;
int i,
result;
char modulefile[ MOD_BUFSIZE];
char modulename[ MOD_BUFSIZE];
/**
** Initialize the command buffer and set up the modules flag to 'display
** only'
**/
Tcl_DStringInit( &cmdbuf);
g_flags |= M_DISPLAY;
/**
** Handle each passed module file. Create a Tcl interpreter for each
** module file to be handled and initialize it with custom module commands
**/
for(i=0; i<argc && argv[i]; i++) {
/**
** Set the name of the module specified on the command line
**/
g_specified_module = argv[i];
disp_interp = EM_CreateInterp();
if( TCL_OK != (result = Module_Init( disp_interp))) {
EM_DeleteInterp( disp_interp);
return( result); /** -------- EXIT (FAILURE) -------> **/
}
/**
** locate the filename related to the passed module
**/
if( Locate_ModuleFile(disp_interp, argv[i], modulename, modulefile) ==
TCL_ERROR) {
g_retval = 1;
EM_DeleteInterp( disp_interp);
if( OK != ErrorLogger( ERR_LOCATE, LOC, argv[i], NULL))
break;
else
continue;
}
/**
** Print out everything that would happen if the module file were
** executed ...
**/
g_current_module = modulename;
fprintf( stderr, "%s\n",local_line);
fprintf( stderr, "%s:\n\n", modulefile);
result = CallModuleProcedure( disp_interp, &cmdbuf, modulefile,
"ModulesDisplay", 0);
fprintf( stderr, "%s\n",local_line);
/**
** Remove the Tcl interpreter that has been used for printing ...
**/
EM_DeleteInterp( disp_interp);
} /** for **/
/**
** Leave the 'display only mode', free up what has been used and return
**/
g_flags &= ~M_DISPLAY;
fprintf( stderr, "\n");
Tcl_DStringFree( &cmdbuf);
return( TCL_OK);
} /** End of 'ModuleCmd_Display' **/