-
Notifications
You must be signed in to change notification settings - Fork 0
/
ModuleCmd_Clear.c
150 lines (122 loc) · 4.8 KB
/
ModuleCmd_Clear.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
/*****
** ** Module Header ******************************************************* **
** **
** Modules Revision 3.0 **
** Providing a flexible user environment **
** **
** File: ModuleCmd_Clear.c **
** First Edition: 1991/10/23 **
** **
** Authors: John Furlan, jlf@behere.com **
** Jens Hamisch, jens@Strawberry.COM **
** **
** Description: Clears out Modules' concept of the currently loaded **
** modules. **
** **
** Exports: ModuleCmd_Clear **
** **
** Notes: **
** **
** ************************************************************************ **
****/
/** ** Copyright *********************************************************** **
** **
** Copyright 1991-1994 by John L. Furlan. **
** see LICENSE.GPL, which must be provided, for details **
** **
** ************************************************************************ **/
static char Id[] = "@(#)$Id: 9b86fc201dbbd679d77b6212a982307a362e1687 $";
static void *UseId[] = { &UseId, Id };
/** ************************************************************************ **/
/** HEADERS **/
/** ************************************************************************ **/
#include "modules_def.h"
/** ************************************************************************ **/
/** LOCAL DATATYPES **/
/** ************************************************************************ **/
/** not applicable **/
/** ************************************************************************ **/
/** CONSTANTS **/
/** ************************************************************************ **/
/** not applicable **/
/** ************************************************************************ **/
/** MACROS **/
/** ************************************************************************ **/
/** not applicable **/
/** ************************************************************************ **/
/** LOCAL DATA **/
/** ************************************************************************ **/
#if WITH_DEBUGGING_MODULECMD
static char module_name[] = "ModuleCmd_Clear.c"; /** File name of this module **/
static char _proc_ModuleCmd_Clear[] = "ModuleCmd_Clear";
#endif
/** ************************************************************************ **/
/** PROTOTYPES **/
/** ************************************************************************ **/
/** not applicable **/
/*++++
** ** Function-Header ***************************************************** **
** **
** Function: ModuleCmd_Clear **
** **
** Description: Execution of the module-command 'clear' **
** Resets the modules runtime information but doesn't **
** apply further changes to the environment at all **
** **
** First Edition: 1991/10/23 **
** **
** Parameters: Tcl_Interp *interp Attached Tcl Interp. **
** int argc Number of arguments **
** char *argv[] Argument list **
** **
** Result: int TCL_ERROR Failure **
** TCL_OK Successful operation **
** **
** Attached Globals: **
** **
** ************************************************************************ **
++++*/
int ModuleCmd_Clear( Tcl_Interp *interp,
int argc,
char *argv[])
{
char buf[10];
char* clearargv[4];
#if WITH_DEBUGGING_MODULECMD
ErrorLogger( NO_ERR_START, LOC, _proc_ModuleCmd_Clear, NULL);
#endif
/**
** Ask the user if he's really sure about what he's doing ...
**/
if( argc == 1 && !strcmp( argv[0], "yes")) {
buf[0] = 'y';
} else {
fprintf( stderr,
"\nAre you sure you want to clear all loaded modules!? [n] ");
fgets( buf, 10, stdin);
}
/**
** Reset the shell variables 'LOADEDMODULES' and '_LMFILES_'
**/
if( buf[0] == 'y') {
clearargv[0] = "setenv";
clearargv[1] = "LOADEDMODULES";
clearargv[2] = "";
clearargv[3] = NULL;
cmdSetEnv( (ClientData) 0, interp, 3, (CONST84 char **) clearargv);
clearargv[0] = "setenv";
clearargv[1] = "_LMFILES_";
clearargv[2] = "";
clearargv[3] = NULL;
cmdSetEnv( (ClientData) 0, interp, 3, (CONST84 char **) clearargv);
} else {
fprintf( stderr, "\nLOADEDMODULES was NOT cleared.\n");
}
/**
** Return on success
**/
#if WITH_DEBUGGING_MODULECMD
ErrorLogger( NO_ERR_END, LOC, _proc_ModuleCmd_Clear, NULL);
#endif
return( TCL_OK);
}