-
Notifications
You must be signed in to change notification settings - Fork 0
/
ModuleCmd_Clear.c
145 lines (121 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
/*****
** ** Module Header ******************************************************* **
** **
** Modules Revision 3.0 **
** Providing a flexible user environment **
** **
** File: ModuleCmd_Clear.c **
** First Edition: 1991/10/23 **
** **
** Authors: John Furlan, [email protected] **
** Jens Hamisch, [email protected] **
** R.K. Owen, <[email protected]> or <[email protected]> **
** **
** 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$";
static void *UseId[] = { &UseId, Id };
/** ************************************************************************ **/
/** HEADERS **/
/** ************************************************************************ **/
#include "modules_def.h"
/** ************************************************************************ **/
/** LOCAL DATATYPES **/
/** ************************************************************************ **/
/** not applicable **/
/** ************************************************************************ **/
/** CONSTANTS **/
/** ************************************************************************ **/
/** not applicable **/
/** ************************************************************************ **/
/** MACROS **/
/** ************************************************************************ **/
/** not applicable **/
/** ************************************************************************ **/
/** LOCAL DATA **/
/** ************************************************************************ **/
/** not applicable **/
/** ************************************************************************ **/
/** 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], /** user response input **/
*ptr, /** reponse pointer **/
*clearargv[4]; /** argv vector **/
Tcl_Obj **objv; /** Tcl Object vector **/
int objc; /** Tcl Object vector count **/
/**
** 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] ");
ptr = fgets(buf, 10, stdin);
}
/**
** Reset the shell variables 'LOADEDMODULES' and '_LMFILES_'
**/
if( *ptr == 'y' || *ptr == 'Y') {
clearargv[0] = "setenv";
clearargv[1] = "LOADEDMODULES";
clearargv[2] = "";
clearargv[3] = NULL;
/* convert fomr argv to objv */
Tcl_ArgvToObjv(&objc, &objv, -1, (char **) clearargv);
cmdSetEnv( (ClientData) 0, interp, objc, objv);
clearargv[0] = "setenv";
clearargv[1] = "_LMFILES_";
clearargv[2] = "";
clearargv[3] = NULL;
/* convert fomr argv to objv */
Tcl_ArgvToObjv(&objc, &objv, -1, (char **) clearargv);
cmdSetEnv( (ClientData) 0, interp, objc, objv);
} else {
fprintf( stderr, "\nLOADEDMODULES was NOT cleared.\n");
}
/**
** Return on success
**/
return( TCL_OK);
}