** ** 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> **
** **
** **
** ************************************************************************ **
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>
Preprocessor definitions
#define HISTTAB 100
typedef struct _mod_module ModModule
struct _mod_module |
|
{ |
|
struct _mod_module* next; |
|
struct _mod_name* version; |
|
struct _mod_name* name; |
|
char* module; |
|
} |
|
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[]
UseId
static void* UseId[]
module_name
static char module_name[]
modlist
static ModModule* modlist
aliaslist
static ModName* aliaslist
** ** 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 )
** ** 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 )
** ** 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 )
** ** 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 )
** ** 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[] )
** ** 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[] )
** ** 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 )
** ** 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 )
** ** 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 )
static void CleanupName ( ModName* ptr )
static void CleanupVersionSub ( ModModule* ptr )
** ** 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 )
** ** 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 )
** ** 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 )