-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcmdChdir.c
More file actions
54 lines (46 loc) · 1.49 KB
/
cmdChdir.c
File metadata and controls
54 lines (46 loc) · 1.49 KB
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
/*****
** ** Module Header ******************************************************* **
** **
** File: cmdChdir.c **
** First Edition: 2009-06-27 **
** **
** Authors: Gerrit Renker **
** Description: Implements a "chdir" command to set the working **
** directory upon module load/switch. **
** **
** Exports: cmdChDir **
** **
** Attached Globals: g_flags These are set up accordingly before **
** this function is called in order to **
** control everything **
** change_dir Communicates the target directory. **
** ************************************************************************ **
****/
#include "modules_def.h"
static char module_name[] = __FILE__;
char *change_dir = NULL;
int cmdChDir(ClientData client_data, Tcl_Interp *interp,
int argc, CONST84 char *argv[])
{
#if WITH_DEBUGGING_CALLBACK
ErrorLogger( NO_ERR_START, LOC, __func__, NULL);
#endif
if(g_flags & ~(M_LOAD|M_SWSTATE2))
return TCL_OK;
if (argc != 2) {
if (OK != ErrorLogger( ERR_USAGE, LOC, argv[0], " directory", NULL))
return TCL_ERROR;
}
if (g_flags & M_NONPERSIST)
return TCL_OK;
if(g_flags & M_DISPLAY) {
fprintf(stderr, "%s\t%s\n", argv[0], argv[1]);
return TCL_OK;
}
/* The actual work happens here */
if (change_dir != NULL) {
free(change_dir);
}
change_dir = strdup(argv[1]);
return TCL_OK;
}