** ** Module Header ******************************************************* **
** **
** Modules Revision 3.0 **
** Providing a flexible user environment **
** **
** File: init.c **
** First Edition: 91/10/23 **
** **
** Authors: John Furlan, jlf@behere.com **
** Jens Hamisch, jens@Strawberry.COM **
** **
** Description: The initialization routines for Tcl Modules. **
** Primarily the setup of the different Tcl module **
** commands and the global hash tables are initialized **
** here. The initial storage of the begining **
** environment is here as well. **
** **
** Exports: Initialize_Tcl **
** Module_Tcl_ExitCmd **
** InitializeModuleCommands **
** Setup_Environment **
** TieStdout **
** UnTieStdout **
** SetStartupFiles **
** **
** Notes: **
** **
** ************************************************************************ **
Included Files
- #include "modules_def.h"
- #include <stdio.h>
- #include <tcl.h>
- #include "config.h"
- #include <stdlib.h>
- #include <string.h>
- #include <unistd.h>
- #include <sys/types.h>
- #include <ctype.h>
- #include <sys/stat.h>
- #include <sys/termios.h>
- #include <fcntl.h>
- #include <sys/ioctl.h>
- #include <dirent.h>
- #include <errno.h>
Local Variables
Id
static char Id[]
UseId
static void* UseId[]
module_name
static char module_name[]
cshStartUps
static char* cshStartUps[]
tcshStartUps
static char* tcshStartUps[]
shStartUps
static char* shStartUps[]
bashStartUps
static char* bashStartUps[]
zshStartUps
static char* zshStartUps[]
genericStartUps
static char* genericStartUps[]
** ** Function-Header ***************************************************** **
** **
** Function: InitializeModuleCommands **
** **
** Description: Initialization of the passed Tcl interpreter. At **
** first the standard Tcl and (if required) TclX initi- **
** alization is called. Thereafter all module commands **
** callback function are defined. **
** **
** First Edition: 91/10/23 **
** **
** Parameters: Tcl_Interp *interp The Tcl Interpreter **
** to be initilized **
** **
** Result: int TCL_OK All done, Success **
** TCL_ERROR Failure anywhere **
** **
** Attached Globals: - **
** **
** ************************************************************************ **
int InitializeModuleCommands ( Tcl_Interp* interp )
** ** Function-Header ***************************************************** **
** **
** Function: Initialize_Tcl **
** **
** Description: This procedure is called from 'main' in order to ini-**
** tialize the whole thing. The arguments specified on **
** the invoking command line are passed to here. **
** **
** First Edition: 91/10/23 **
** **
** Parameters: Tcl_Interp **interp Buffer to store the **
** Tcl interpr. handle **
** int argc Number od args and **
** char *argv[] arg. array from the **
** shell command line **
** char *environ[] Process environment **
** **
** Result: int **
** **
** Attached Globals: *Ptr will be initialized **
** *HashTable will be allocated and initialized **
** **
** ************************************************************************ **
int Initialize_Tcl ( Tcl_Interp** interp, int argc, char* argv[], char* environ[] )
** ** Function-Header ***************************************************** **
** **
** Function: Module_Tcl_ExitCmd **
** **
** Description: Error (???) exit routine **
** **
** First Edition: 91/10/23 **
** **
** Parameters: ClientData client_data **
** Tcl_Interp* interp The attached Tcl **
** interpreter **
** int argc Number of arguments **
** char *argv[] Array of arguments **
** to the module command**
** **
** Result: int TCL_ERROR Exit on error **
** **
** Attached Globals: **
** **
** ************************************************************************ **
int Module_Tcl_ExitCmd ( ClientData client_data, Tcl_Interp* interp, int argc, char* argv[] )
** ** Function-Header ***************************************************** **
** **
** Function: SetStartupFiles **
** **
** Description: Collects all startupfiles used by the various shells **
** in the array 'shell_startups'. This function does not**
** take care, if the startup file do exist! **
** **
** First Edition: 91/10/23 **
** **
** Parameters: - **
** Result: - **
** Attached Globals: shell_startups will be set up with a list of all **
** startup files used by the shell **
** specified in 'shell_name' **
** **
** ************************************************************************ **
int SetStartupFiles ( void )
** ** Function-Header ***************************************************** **
** **
** Function: Setup_Environment **
** **
** Description:Define all variables to be found in the current **
** shell environment as Tcl variables in the passed **
** Tcl interpreter. **
** Assign as value 0 to all of them. ??? Why ??? **
** **
** First Edition: 91/10/23 **
** **
** Parameters: Tcl_Interp *interp Attched Tcl interpr. **
** **
** Result: int TCL_ERROR Variable could not be set up **
** 0 Success ??? TCL_OK ??? **
** **
** Attached Globals: environ **
** **
** ************************************************************************ **
int Setup_Environment ( Tcl_Interp* interp )
** ** Function-Header ***************************************************** **
** **
** Function: TieStdout, UnTieStdout **
** **
** Description: TieStdout closes the 'stdout' handle and reopens it **
** as 'stderr'. The original 'stdout' handle is passed **
** back to the caller. **
** UnTieStdout reverts this by reopening 'stdout' as the**
** handle passed as parameter **
** **
** First Edition: 91/10/23 **
** **
** Parameters: int saved_stdout Handle to be used for rein- **
** stalling stdout **
** **
** Result: int The (just reinstalled or saved) stdout handle**
** **
** Attached Globals: - **
** **
** ************************************************************************ **
int TieStdout ( void )
int UnTieStdout ( int saved_stdout )