File init.c

 ** ** 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:								     **
 ** 									     **
 ** ************************************************************************ **
References Variables: Idinit.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()


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:	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 )
Prototyped in: modules_def.h
Calls: Module_Error()error.c
  Tcl_CreateCommand(), Tcl_Init()
Called by: Initialize_Tcl()init.c
  ModuleCmd_Display()ModuleCmd_Display.c
  ModuleCmd_Load()ModuleCmd_Load.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_nameinit.c
  shell_derelictmain.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:	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[] )
Prototyped in: modules_def.h
Calls: InitializeModuleCommands()init.c
  Module_Error()error.c
  moduleSetenv()cmdSetenv.c
  set_derelict()utility.c
  Tcl_CreateInterp(), Tcl_InitHashTable(), fclose(), fopen(), fprintf(), getenv(), malloc(), strcat(), strcpy(), strlen()
Called by: main()main.c
References Variables: aliasSetHashTablemain.c
  aliasUnsetHashTablemain.c
  markAliasHashTablemain.c
  markVariableHashTablemain.c
  module_nameinit.c
  setenvHashTablemain.c
  shell_namemain.c
  unsetenvHashTablemain.c

Global Function Module_Tcl_ExitCmd()

 ** ** 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[] )
Calls: Module_Error()error.c
  Tcl_GetInt(), Tcl_SetResult(), malloc(), sprintf()
Used in: InitializeModuleCommands()init.c
References Variables: module_nameinit.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**
 **			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 )
Prototyped in: modules_def.h
Calls: strcmp()
Called by: ModuleCmd_Init()ModuleCmd_Init.c
References Variables: bashStartUpsinit.c
  cshStartUpsinit.c
  genericStartUpsinit.c
  shStartUpsinit.c
  shell_namemain.c
  shell_startupsmain.c
  tcshStartUpsinit.c
  zshStartUpsinit.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:	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 )
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_nameinit.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:	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 )
Prototyped in: modules_def.h
Calls: Module_Error()error.c
  close(), dup()
Called by: cmdSystem()cmdMisc.c
References Variables: _fil_stderrcmdModule.c
  _fil_stdoutcmdModule.c
  module_nameinit.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_stdoutcmdModule.c
  module_nameinit.c