File init.c

 ** ** Module Header ******************************************************* **
 ** 									     **
 **   Modules Revision 3.0						     **
 **   Providing a flexible user environment				     **
 ** 									     **
 **   File:		init.c						     **
 **   First Edition:	1991/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:								     **
 ** 									     **
 ** ************************************************************************ **
References Variables: Id init.c

Included Files


Local Variables

Id
static char Id[]
Used in:   init.c

UseId
static void* UseId[]

module_name
static char module_name[]

Used in: InitializeModuleCommands()  
  Initialize_Tcl()  
  Module_Tcl_ExitCmd()  
  Setup_Environment()  
  TieStdout()  
  UnTieStdout()  

cshStartUps
static char* cshStartUps[]

Used in: SetStartupFiles()  

tcshStartUps
static char* tcshStartUps[]

Used in: SetStartupFiles()  

shStartUps
static char* shStartUps[]

Used in: SetStartupFiles()  

bashStartUps
static char* bashStartUps[]

Used in: SetStartupFiles()  

zshStartUps
static char* zshStartUps[]

Used in: SetStartupFiles()  

genericStartUps
static char* genericStartUps[]

Used in: SetStartupFiles()  

shellprops
static char* shellprops[][4]

Used in: set_shell_properties()  

Global Function InitializeModuleCommands()

 ** ** 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:	1991/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 )
Prototyped in: modules_def.h
Calls: Module_Error() error.c
  Tcl_CreateCommand(), Tcl_Init(), Tclxcmd_Init()
Called by: Initialize_Tcl() init.c
  ModuleCmd_Display() ModuleCmd_Display.c
  ModuleCmd_Load() ModuleCmd_Load.c
  ModuleCmd_Refresh() ModuleCmd_Refresh.c
  ModuleCmd_Whatis() ModuleCmd_Whatis.c
  PerModuleHelp() ModuleCmd_Help.c
  whatis_dir() ModuleCmd_Whatis.c
References Functions: Module_Tcl_ExitCmd() init.c
  cmdConflict() cmdConflict.c
  cmdIsLoaded() cmdIsLoaded.c
  cmdModule() cmdModule.c
  cmdModuleAlias() cmdVersion.c
  cmdModuleInfo() cmdInfo.c
  cmdModuleLog() cmdLog.c
  cmdModuleTrace() cmdTrace.c
  cmdModuleUser() cmdUlvl.c
  cmdModuleVerbose() cmdVerbose.c
  cmdModuleVersion() cmdVersion.c
  cmdModuleWhatis() cmdWhatis.c
  cmdPrereq() cmdConflict.c
  cmdRemovePath() cmdPath.c
  cmdSetAlias() cmdAlias.c
  cmdSetEnv() cmdSetenv.c
  cmdSetPath() cmdPath.c
  cmdSystem() cmdMisc.c
  cmdUname() cmdUname.c
  cmdUnsetEnv() cmdSetenv.c
  cmdXResource() cmdXResource.c
References Variables: module_name init.c
  shell_derelict main.c

Global Function Initialize_Tcl()

 ** ** 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:	1991/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[] )
Prototyped in: modules_def.h
Calls: InitializeModuleCommands() init.c
  Module_Error() error.c
  moduleSetenv() cmdSetenv.c
  null_free() utility.c
  set_shell_properties() init.c
  xgetenv() utility.c
  Tcl_CreateInterp(), Tcl_InitHashTable(), fclose(), fopen(), fprintf(), getenv(), malloc()
Called by: main() main.c
References Variables: aliasSetHashTable main.c
  aliasUnsetHashTable main.c
  markAliasHashTable main.c
  markVariableHashTable main.c
  module_name init.c
  setenvHashTable main.c
  unsetenvHashTable main.c

Global Function Module_Tcl_ExitCmd()

 ** ** Function-Header ***************************************************** **
 ** 									     **
 **   Function:		Module_Tcl_ExitCmd				     **
 ** 									     **
 **   Description:	Error (???) exit routine			     **
 ** 									     **
 **   First Edition:	1991/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, const char* argv[] )
Calls: Module_Error() error.c
  stringer() utility.c
  Tcl_GetInt(), Tcl_SetResult(), sprintf()
Used in: InitializeModuleCommands() init.c
References Variables: module_name init.c

Global Function SetStartupFiles()

 ** ** Function-Header ***************************************************** **
 ** 									     **
 **   Function:		SetStartupFiles					     **
 ** 									     **
 **   Description:	Collects all startupfiles used by the various shells **
 **			in the array 'shell_startups'. This function does not**
 **			care if the startup file do not exist!		     **
 ** 									     **
 **   First Edition:	1991/10/23					     **
 ** 									     **
 **   Parameters:	shell_name	the shell being used		     **
 **   Result:		shell_startups	NULL terminated list of startup files**
 **					for the shell			     **
 **					returns NULL if an error	     **
 **   Attached Globals:	-						     **
 ** 									     **
 ** ************************************************************************ **
char** SetStartupFiles ( char* shell_name )
Prototyped in: modules_def.h
Calls: strcmp()
Called by: ModuleCmd_Init() ModuleCmd_Init.c
References Variables: bashStartUps init.c
  cshStartUps init.c
  genericStartUps init.c
  shStartUps init.c
  tcshStartUps init.c
  zshStartUps init.c

Global Function Setup_Environment()

 ** ** 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:	1991/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 )
Prototyped in: modules_def.h
Calls: Module_Error() error.c
  getLMFILES() utility.c
  Tcl_SetVar(), Tcl_SetVar2(), strlen()
Called by: main() main.c
References Variables: module_name init.c
  environ

Global Function TieStdout()

 ** ** 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:	1991/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 )
Prototyped in: modules_def.h
Calls: Module_Error() error.c
  close(), dup()
Called by: cmdSystem() cmdMisc.c
References Variables: _fil_stderr cmdModule.c
  _fil_stdout cmdModule.c
  module_name init.c

Global Function UnTieStdout()

int UnTieStdout ( int saved_stdout )
Prototyped in: modules_def.h
Calls: Module_Error() error.c
  close(), dup()
Called by: cmdSystem() cmdMisc.c
References Variables: _fil_stdout cmdModule.c
  module_name init.c

Local Function set_shell_properties()

 ** ** Function-Header ***************************************************** **
 ** 									     **
 **   Function:		set_shell_properties				     **
 ** 									     **
 **   Description:	Normalize the current calling shell to one of the    **
 **			basic shells defining the variable and alias syntax  **
 ** 									     **
 **   First Edition:	1991/10/23					     **
 ** 									     **
 **   Parameters:	const char	*name	Invoking shell name	     **
 ** 									     **
 **   Result:		char*			Shell derelict name	     **
 ** 									     **
 **   Attached Globals:	shell_derelict					     **
 ** 			shell_cmd_separator				     **
 ** 									     **
 ** ************************************************************************ **
static char* set_shell_properties ( const char* name )
Prototyped in: init.c
Calls: strcmp()
Called by: Initialize_Tcl() init.c
References Variables: shell_cmd_separator main.c
  shell_derelict main.c
  shell_init main.c
  shell_name main.c
  shellprops init.c