mirror of
https://github.com/envmodules/modules.git
synced 2026-06-10 00:56:30 +08:00
185 lines
5.7 KiB
C
185 lines
5.7 KiB
C
/*****
|
||
** ** Module Header ******************************************************* **
|
||
** **
|
||
** Modules Revision 3.0 **
|
||
** Providing a flexible user environment **
|
||
** **
|
||
** File: ModuleCmd_Display.c **
|
||
** First Edition: 1991/10/23 **
|
||
** **
|
||
** Authors: John Furlan, jlf@behere.com **
|
||
** Jens Hamisch, jens@Strawberry.COM **
|
||
** **
|
||
** Description: Displays what changes a modulefile will make to the **
|
||
** environment including any conflics or prerequisits. **
|
||
** **
|
||
** Exports: ModuleCmd_Display **
|
||
** **
|
||
** Notes: **
|
||
** **
|
||
** ************************************************************************ **
|
||
****/
|
||
|
||
/** ** Copyright *********************************************************** **
|
||
** **
|
||
** Copyright 1991-1994 by John L. Furlan. **
|
||
** see LICENSE.GPL, which must be provided, for details **
|
||
** **
|
||
** ************************************************************************ **/
|
||
|
||
static char Id[] = "@(#)$Id: ModuleCmd_Display.c,v 1.9 2009/08/23 23:30:42 rkowen Exp $";
|
||
static void *UseId[] = { &UseId, Id };
|
||
|
||
/** ************************************************************************ **/
|
||
/** HEADERS **/
|
||
/** ************************************************************************ **/
|
||
|
||
#include "modules_def.h"
|
||
|
||
/** ************************************************************************ **/
|
||
/** LOCAL DATATYPES **/
|
||
/** ************************************************************************ **/
|
||
|
||
/** not applicable **/
|
||
|
||
/** ************************************************************************ **/
|
||
/** CONSTANTS **/
|
||
/** ************************************************************************ **/
|
||
|
||
/** not applicable **/
|
||
|
||
/** ************************************************************************ **/
|
||
/** MACROS **/
|
||
/** ************************************************************************ **/
|
||
|
||
/** not applicable **/
|
||
|
||
/** ************************************************************************ **/
|
||
/** LOCAL DATA **/
|
||
/** ************************************************************************ **/
|
||
|
||
char local_line[] =
|
||
"-------------------------------------------------------------------";
|
||
static char module_name[] = __FILE__;
|
||
|
||
/** ************************************************************************ **/
|
||
/** PROTOTYPES **/
|
||
/** ************************************************************************ **/
|
||
|
||
/** not applicable **/
|
||
|
||
|
||
/*++++
|
||
** ** Function-Header ***************************************************** **
|
||
** **
|
||
** Function: ModuleCmd_Display **
|
||
** **
|
||
** Description: Execution of the module-command 'display' **
|
||
** Display every change a module 'load' would apply to **
|
||
** the environment **
|
||
** **
|
||
** First Edition: 1991/10/23 **
|
||
** **
|
||
** Parameters: Tcl_Interp *interp Attached Tcl Interp. **
|
||
** char *argv[] Argument list **
|
||
** **
|
||
** Result: int TCL_ERROR Failure **
|
||
** TCL_OK Successful operation **
|
||
** **
|
||
** Attached Globals: g_specified_module The module name from the **
|
||
** command line. **
|
||
** g_flags These are set up accordingly before **
|
||
** this function is called in order to **
|
||
** control everything **
|
||
** g_current_module The module which is handled **
|
||
** by the current command **
|
||
** **
|
||
** ************************************************************************ **
|
||
++++*/
|
||
|
||
int ModuleCmd_Display( Tcl_Interp *interp,
|
||
int argc,
|
||
char *argv[])
|
||
{
|
||
Tcl_Interp *disp_interp;
|
||
Tcl_DString cmdbuf;
|
||
int i,
|
||
result;
|
||
char modulefile[ MOD_BUFSIZE];
|
||
char modulename[ MOD_BUFSIZE];
|
||
|
||
/**
|
||
** Initialize the command buffer and set up the modules flag to 'display
|
||
** only'
|
||
**/
|
||
Tcl_DStringInit( &cmdbuf);
|
||
g_flags |= M_DISPLAY;
|
||
|
||
/**
|
||
** Handle each passed module file. Create a Tcl interpreter for each
|
||
** module file to be handled and initialize it with custom module commands
|
||
**/
|
||
|
||
for(i=0; i<argc && argv[i]; i++) {
|
||
/**
|
||
** Set the name of the module specified on the command line
|
||
**/
|
||
|
||
g_specified_module = argv[i];
|
||
|
||
disp_interp = Tcl_CreateInterp();
|
||
if( TCL_OK != (result = Module_Init( disp_interp))) {
|
||
Tcl_DeleteInterp( disp_interp);
|
||
return( result); /** -------- EXIT (FAILURE) -------> **/
|
||
}
|
||
|
||
/**
|
||
** locate the filename related to the passed module
|
||
**/
|
||
|
||
if( Locate_ModuleFile(disp_interp, argv[i], modulename, modulefile) ==
|
||
TCL_ERROR) {
|
||
Tcl_DeleteInterp( disp_interp);
|
||
if( OK != ErrorLogger( ERR_LOCATE, LOC, argv[i], NULL))
|
||
break;
|
||
else
|
||
continue;
|
||
}
|
||
|
||
/**
|
||
** Print out everything that would happen if the module file were
|
||
** executed ...
|
||
**/
|
||
|
||
g_current_module = modulename;
|
||
|
||
fprintf( stderr, "%s\n",local_line);
|
||
fprintf( stderr, "%s:\n\n", modulefile);
|
||
|
||
result = CallModuleProcedure( disp_interp, &cmdbuf, modulefile,
|
||
"ModulesDisplay", 0);
|
||
|
||
fprintf( stderr, "%s\n",local_line);
|
||
|
||
/**
|
||
** Remove the Tcl interpreter that has been used for printing ...
|
||
**/
|
||
|
||
Tcl_DeleteInterp( disp_interp);
|
||
|
||
} /** for **/
|
||
|
||
/**
|
||
** Leave the 'display only mode', free up what has been used and return
|
||
**/
|
||
|
||
g_flags &= ~M_DISPLAY;
|
||
fprintf( stderr, "\n");
|
||
|
||
Tcl_DStringFree( &cmdbuf);
|
||
|
||
return( TCL_OK);
|
||
|
||
} /** End of 'ModuleCmd_Display' **/
|
||
|