File cmdVersion.c

 ** ** Module Header ******************************************************* **
 ** 									     **
 **   Modules Revision 3.0						     **
 **   Providing a flexible user environment				     **
 ** 									     **
 **   File:		cmdVersion.c					     **
 **   First Edition:	95/12/28					     **
 ** 									     **
 **   Authors:	Jens Hamisch, jens@Strawberry.COM			     **
 ** 									     **
 **   Description:	The Tcl module-version routine which provides the    **
 **			definition of symbolic version names and the module- **
 **			alias command providing the definition of module and **
 **			version aliases					     **
 ** 									     **
 **   Exports:		cmdModuleVersion				     **
 **			cmdModuleAlias					     **
 **			CleanupVersion					     **
 **			AliasLookup					     **
 **			ExpandVersions					     **
 ** 									     **
 **   Notes:	This module defines the callback functions for the defi-     **
 **		nition of symbolic module names and module aliases. The      **
 **		syntax of the according commands is defined as:		     **
 ** 									     **
 **	    Module-Versions:						     **
 **		module-version <module>/<version> <name> [ <name> ... ]	     **
 **		module-version /<version> <name> [ <name> ... ]		     **
 **		module-version <module> <name> [ <name> ... ]		     **
 **		module-version <alias> <name> [ <name> ... ]		     **
 ** 									     **
 **	    Module-Alias:						     **
 **		module-alias <alias> <module>/<version>			     **
 **		module-alias <alias> /<version>				     **
 **		module-alias <alias> <module>				     **
 **		module-alias <alias> <alias>				     **
 ** 									     **
 ** 									     **
 ** ************************************************************************ **
References Variables: IdcmdVersion.c

Included Files


Preprocessor definitions

#define HISTTAB 100

Typedef ModModule

typedef struct _mod_module ModModule
struct _mod_module 
   { 
     struct _mod_module* next; 
     struct _mod_name* version; 
     struct _mod_name* name; 
     char* module; 
   } 

Typedef ModName

typedef struct _mod_name ModName
struct _mod_name 
   { 
     struct _mod_name* next; 
     struct _mod_name* ptr; 
     struct _mod_name* version; 
     struct _mod_module* module; 
     char* name; 
   } 

Local Variables

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

UseId
static void* UseId[]

module_name
static char module_name[]
Used in: AddModule()
  AddName()
  AliasLookup()
  CheckModuleVersion()
  ExpandVersions()
  VersionLookup()
  cmdModuleAlias()
  cmdModuleVersion()
  scan_versions()

modlist
static ModModule* modlist
Used in: AddModule()
  CleanupVersion()
  FindModule()

aliaslist
static ModName* aliaslist
Used in: AliasLookup()
  CleanupVersion()
  cmdModuleAlias()


Global Function AliasLookup()

 ** ** Function-Header ***************************************************** **
 ** 									     **
 **   Function:		AliasLookup					     **
 ** 									     **
 **   Description:	Resolves a given alias to a module/version string    **
 ** 									     **
 **   First Edition:	95/12/28					     **
 ** 									     **
 **   Parameters:	char	*alias		Name of the alias to be re-  **
 **						solved			     **
 **			char	**module	Buffer for the module name   **
 **			char	**version	Buffer for the module version**
 ** 									     **
 **   Result:		int	1		Success, value in the buffer **
 **						is valid		     **
 **				0		Any error, or not found	     **
 ** 									     **
 **   Attached Globals:	aliaslist	List containing all alises	     **
 ** 									     **
 ** ************************************************************************ **
int AliasLookup ( char* alias, char** module, char** version )
Prototyped in: modules_def.h
Calls: FindName()cmdVersion.c
  Module_Error()error.c
Called by: CheckModuleVersion()cmdVersion.c
  VersionLookup()cmdVersion.c
  cmdModuleInfo()cmdInfo.c
References Variables: aliaslistcmdVersion.c
  module_namecmdVersion.c

Global Function CleanupVersion()

 ** ** Function-Header ***************************************************** **
 ** 									     **
 **   Function:		CleanupVersion					     **
 ** 									     **
 **   Description:	Cleanup the version structure			     **
 ** 									     **
 **   First Edition:	95/12/28					     **
 ** 									     **
 **   Parameters:	-						     **
 ** 									     **
 **   Result:		-						     **
 ** 									     **
 **   Attached Globals:	modlist		List containing all version names    **
 **			aliaslist	List containing all alises	     **
 ** 									     **
 ** ************************************************************************ **
void CleanupVersion ( ModModule* ptr )
Calls: CleanupName()cmdVersion.c
  CleanupVersionSub()cmdVersion.c
Called by: CleanupVersionSub()cmdVersion.c
References Variables: aliaslistcmdVersion.c
  modlistcmdVersion.c

Global Function ExpandVersions()

 ** ** Function-Header ***************************************************** **
 ** 									     **
 **   Function:		ExpandVersions					     **
 ** 									     **
 **   Description:	Callback function for 'version'			     **
 ** 									     **
 **   First Edition:	95/12/28					     **
 ** 									     **
 **   Parameters:	char	*name		Name to be expanded	     **
 ** 									     **
 **   Result:		char*	NULL		No symbols found	     **
 **				Otherwise	Pointer to the list string   **
 ** 									     **
 ** ************************************************************************ **
char* ExpandVersions ( char* name )
Prototyped in: modules_def.h
Calls: CheckModuleVersion()cmdVersion.c
  FindModule()cmdVersion.c
  FindName()cmdVersion.c
  Module_Error()error.c
  scan_versions()cmdVersion.c
  strrchr()
Called by: cmdModuleInfo()cmdInfo.c
  print_aligned_files()ModuleCmd_Avail.c
References Variables: module_namecmdVersion.c

Global Function VersionLookup()

 ** ** Function-Header ***************************************************** **
 ** 									     **
 **   Function:		VersionLookup					     **
 ** 									     **
 **   Description:	Resolves a given alias to a module/version string    **
 ** 									     **
 **   First Edition:	95/12/28					     **
 ** 									     **
 **   Parameters:	char	*alias		Name of the alias to be re-  **
 **						solved			     **
 **			char	**module	Buffer for the module name   **
 **			char	**version	Buffer for the module version**
 ** 									     **
 **   Result:		int	1		Success, value in the buffer **
 **						is valid		     **
 **				0		Any error, or not found	     **

** Attached Globals: g_current_module The module which is handled ** ** by the current command ** ** ** ** ************************************************************************ **
int VersionLookup ( char* name, char** module, char** version )
Prototyped in: modules_def.h
Calls: AliasLookup()cmdVersion.c
  FindModule()cmdVersion.c
  FindName()cmdVersion.c
  Module_Error()error.c
  malloc(), realloc(), strcpy(), strrchr()
Called by: GetModuleName()locate_module.c
  Locate_ModuleFile()locate_module.c
  SourceVers()locate_module.c
  cmdModuleInfo()cmdInfo.c
References Variables: _defaultmain.c
  g_current_modulemain.c
  module_namecmdVersion.c

Global Function cmdModuleAlias()

 ** ** Function-Header ***************************************************** **
 ** 									     **
 **   Function:		cmdModuleAlias					     **
 ** 									     **
 **   Description:	Callback function for 'alias'			     **
 ** 									     **
 **   First Edition:	95/12/28					     **
 ** 									     **
 **   Parameters:	ClientData	 client_data			     **
 **			Tcl_Interp	*interp		According Tcl interp.**
 **			int		 argc		Number of arguments  **
 **			char		*argv[]		Argument array	     **
 ** 									     **
 **   Result:		int	TCL_OK		Successfull completion	     **
 **				TCL_ERROR	Any error		     **
 ** 									     **
 **   Attached Globals:	aliaslist	List containing all alises	     **
 **   			g_flags		These are set up accordingly before  **
 **					this function is called in order to  **
 **					control everything		     **
 ** 									     **
 ** ************************************************************************ **
int cmdModuleAlias ( ClientData client_data, Tcl_Interp* interp, int argc, char* argv[] )
Prototyped in: modules_def.h
Calls: AddModule()cmdVersion.c
  AddName()cmdVersion.c
  CheckModuleVersion()cmdVersion.c
  FindName()cmdVersion.c
  Module_Error()error.c
  fprintf(), strcmp(), strrchr()
Used in: InitializeModuleCommands()init.c
References Variables: _defaultmain.c
  aliaslistcmdVersion.c
  g_flagsmain.c
  module_namecmdVersion.c

Global Function cmdModuleVersion()

 ** ** Function-Header ***************************************************** **
 ** 									     **
 **   Function:		cmdModuleVersion				     **
 ** 									     **
 **   Description:	Callback function for 'version'			     **
 ** 									     **
 **   First Edition:	95/12/28					     **
 ** 									     **
 **   Parameters:	ClientData	 client_data			     **
 **			Tcl_Interp	*interp		According Tcl interp.**
 **			int		 argc		Number of arguments  **
 **			char		*argv[]		Argument array	     **
 ** 									     **
 **   Result:		int	TCL_OK		Successfull completion	     **
 **				TCL_ERROR	Any error		     **
 ** 									     **
 **   Attached Globals:	modlist		List containing all version names    **
 **   			g_flags		These are set up accordingly before  **
 **					this function is called in order to  **
 **					control everything		     **
 ** 									     **
 ** ************************************************************************ **
int cmdModuleVersion ( ClientData client_data, Tcl_Interp* interp, int argc, char* argv[] )
Prototyped in: modules_def.h
Calls: AddModule()cmdVersion.c
  AddName()cmdVersion.c
  CheckModuleVersion()cmdVersion.c
  FindName()cmdVersion.c
  Module_Error()error.c
  fprintf(), strrchr()
Called by: SourceVers()locate_module.c
Used in: InitializeModuleCommands()init.c
References Variables: g_flagsmain.c
  module_namecmdVersion.c

Local Function AddModule()

 ** ** Function-Header ***************************************************** **
 ** 									     **
 **   Function:		AddModule					     **
 ** 									     **
 **   Description:	Add a new entry to the modules queue		     **
 ** 									     **
 **   First Edition:	95/12/28					     **
 ** 									     **
 **   Parameters:	char	*name		Name of the new module	     **
 ** 									     **
 **   Result:		ModModule*	NULL	Any error                    **
 **					Else	Pointer to the new record    **
 ** 									     **
 **   Attached Globals:	modlist		List containing all version names    **
 ** 									     **
 ** ************************************************************************ **
static ModModule* AddModule ( char* name )
Prototyped in: cmdVersion.c
Calls: FindModule()cmdVersion.c
  Module_Error()error.c
  malloc(), strdup()
Called by: cmdModuleAlias()cmdVersion.c
  cmdModuleVersion()cmdVersion.c
References Variables: modlistcmdVersion.c
  module_namecmdVersion.c

Local Function AddName()

 ** ** Function-Header ***************************************************** **
 ** 									     **
 **   Function:		AddName						     **
 ** 									     **
 **   Description:	Add a new entry to the name queue		     **
 ** 									     **
 **   First Edition:	95/12/28					     **
 ** 									     **
 **   Parameters:	char	 *name		Name of the new entry	     **
 **			ModName	**start		Start of the queue	     **
 **			ModModule *module	Parent module record pointer **
 ** 									     **
 **   Result:		ModName*	NULL	Any error                    **
 **					Else	Pointer to the new record    **
 ** 									     **
 ** ************************************************************************ **
static ModName* AddName ( char* name, ModName** start, ModModule* module )
Prototyped in: cmdVersion.c
Calls: FindName()cmdVersion.c
  Module_Error()error.c
  malloc(), strdup()
Called by: cmdModuleAlias()cmdVersion.c
  cmdModuleVersion()cmdVersion.c
References Variables: module_namecmdVersion.c

Local Function CheckModuleVersion()

 ** ** Function-Header ***************************************************** **
 ** 									     **
 **   Function:		CheckModuleVersion				     **
 ** 									     **
 **   Description:	Reduce the passed module name into a <mod>/<vers>    **
 **			string						     **
 ** 									     **
 **   First Edition:	95/12/28					     **
 ** 									     **
 **   Parameters:	char	*name		name to be checked	     **
 ** 									     **
 **   Result:		char*	NULL		any error		     **
 **				Otherwise	Pointer to a <mod>/<vers>    **
 **						string			     **
 ** 									     **
 **   Attached Globals:	modlist		List containing all version names    **
 **			aliaslist	List containing all alises	     **
 **			g_current_module	The module which is handled  **
 **						by the current command	     **
 ** 									     **
 ** ************************************************************************ **
static char* CheckModuleVersion ( char* name )
Prototyped in: cmdVersion.c
Calls: AliasLookup()cmdVersion.c
  Module_Error()error.c
  strcat(), strcpy(), strlen(), strrchr()
Called by: ExpandVersions()cmdVersion.c
  cmdModuleAlias()cmdVersion.c
  cmdModuleVersion()cmdVersion.c
References Variables: _defaultmain.c
  g_current_modulemain.c
  module_namecmdVersion.c

Local Function CleanupName()

static void CleanupName ( ModName* ptr )
Prototyped in: cmdVersion.c
Calls: CleanupName()cmdVersion.c
Called by: CleanupName()cmdVersion.c
  CleanupVersion()cmdVersion.c
  CleanupVersionSub()cmdVersion.c

Local Function CleanupVersionSub()

static void CleanupVersionSub ( ModModule* ptr )
Prototyped in: cmdVersion.c
Calls: CleanupName()cmdVersion.c
  CleanupVersion()cmdVersion.c
Called by: CleanupVersion()cmdVersion.c

Local Function FindModule()

 ** ** Function-Header ***************************************************** **
 ** 									     **
 **   Function:		FindModule					     **
 ** 									     **
 **   Description:	Find a new entry in the modules queue		     **
 ** 									     **
 **   First Edition:	95/12/28					     **
 ** 									     **
 **   Parameters:	char		*name	Name of be found	     **
 **			ModModule	**prev	Buffer for the 'previous'    **
 **						pointer			     **
 ** 									     **
 **   Result:		ModModule*	NULL	Any error or not found       **
 **					Else	Pointer to the record	     **
 ** 									     **
 **   Attached Globals:	modlist		List containing all version names    **
 ** 									     **
 ** ************************************************************************ **
static ModModule* FindModule ( char* name, ModModule** prev )
Prototyped in: cmdVersion.c
Calls: strcmp()
Called by: AddModule()cmdVersion.c
  ExpandVersions()cmdVersion.c
  VersionLookup()cmdVersion.c
References Variables: modlistcmdVersion.c

Local Function FindName()

 ** ** Function-Header ***************************************************** **
 ** 									     **
 **   Function:		FindName					     **
 ** 									     **
 **   Description:	Find a new entry in the modules queue		     **
 ** 									     **
 **   First Edition:	95/12/28					     **
 ** 									     **
 **   Parameters:	char	 *name		Name of be found	     **
 **			ModName  *start		Start of the name queue      **
 **			ModName	**prev		Buffer for the 'previous'    **
 **						pointer			     **
 ** 									     **
 **   Result:		ModName*	NULL	Any error or not found       **
 **					Else	Pointer to the record	     **
 ** 									     **
 ** ************************************************************************ **
static ModName* FindName ( char* name, ModName* start, ModName** prev )
Prototyped in: cmdVersion.c
Calls: strcmp()
Called by: AddName()cmdVersion.c
  AliasLookup()cmdVersion.c
  ExpandVersions()cmdVersion.c
  VersionLookup()cmdVersion.c
  cmdModuleAlias()cmdVersion.c
  cmdModuleVersion()cmdVersion.c
  scan_versions()cmdVersion.c

Local Function scan_versions()

 ** ** Function-Header ***************************************************** **
 ** 									     **
 **   Function:		scan_versions					     **
 ** 									     **
 **   Description:	Scan all symbolic versions pointed to be the passed  **
 **			ModName pointer and print them as a list into the    **
 **			passed buffer.					     **
 ** 									     **
 **   First Edition:	95/12/28					     **
 ** 									     **
 **   Parameters:	char	*buffer		Buffer for printing in	     **
 **			ModName	*ptr		Name structure pointer	     **
 **			ModModule  *modptr	Assigned module name	     **
 ** 									     **
 **   Result:		char*	NULL		Nothing printed into the     **
 **						buffer			     **
 **				Otherwise	Pointer to the end of the    **
 **						string in the buffer	     **
 ** 									     **
 ** ************************************************************************ **
static char* scan_versions ( char* buffer, char* base, ModName* ptr, ModModule* modptr )
Prototyped in: cmdVersion.c
Calls: FindName()cmdVersion.c
  Module_Error()error.c
  scan_versions()cmdVersion.c
  strcat(), strcpy(), strlen(), strstr()
Called by: ExpandVersions()cmdVersion.c
  scan_versions()cmdVersion.c
References Variables: module_namecmdVersion.c