1 /*****
2  ** ** Module Header ******************************************************* **
3  ** 									     **
4  **   Modules Revision 3.2						     **
5  **   Providing a flexible user environment				     **
6  ** 									     **
7  **   File:		modules_def.h					     **
8  **   First Edition:	1991/10/23					     **
9  ** 									     **
10  **   Authors:	John Furlan, jlf@behere.com				     **
11  **		Jens Hamisch, jens@Strawberry.COM			     **
12  **		R.K. Owen, rk@owen.sj.ca.us				     **
13  ** 									     **
14  **   Description:							     **
15  ** 									     **
16  **   Exports:								     **
17  ** 									     **
18  **   Notes:								     **
19  ** 									     **
20  ** ************************************************************************ **
21  ****/
22 
23 /** ** Copyright *********************************************************** **
24  ** 									     **
25  ** Copyright 1991-1994 by John L. Furlan.                      	     **
26  ** see LICENSE.GPL, which must be provided, for details		     **
27  ** 									     **
28  ** ************************************************************************ **/
29 
30 #ifndef _MODULES_DEF_H
31 #define _MODULES_DEF_H
32 
33 /** ************************************************************************ **/
34 /** 				      HEADERS				     **/
35 /** ************************************************************************ **/
36 
37 #include <stdio.h>
38 #include <stdarg.h>
39 #include <tcl.h>
40 #include "config.h"
41 
42 #ifndef CONST84
43 #  define CONST84	/* const */
44 #endif
45 
46 #if (TCL_MAJOR_VERSION < 8)
47 #  define TCL_RESULT(interp) ((interp)->result)
48 #else
49 #  define TCL_RESULT(interp) Tcl_GetStringResult(interp)
50 #endif
51 
52 #ifndef HAVE_STDINT_H
53 /* assume 32 bit - hope for the best */
54 typedef	int	intptr_h;
55 #endif
56 
57 #ifdef HAVE_STDLIB_H
58 #  include <stdlib.h>
59 #endif
60 
61 #if STDC_HEADERS || HAVE_STRING_H
62 #  include <string.h>
63 /**
64  **  An ANSI string.h and pre-ANSI memory.h might conflict.
65  **/
66 #  if !STDC_HEADERS && HAVE_MEMORY_H
67 #    include <memory.h>
68 #  endif /** not STDC_HEADERS and HAVE_MEMORY_H **/
69 #else /** not STDC_HEADERS and not HAVE_STRING_H **/
70 #  include <strings.h>
71 /**
72  **  memory.h and strings.h conflict on some systems.
73  **/
74 #endif /** not STDC_HEADERS and not HAVE_STRING_H  **/
75 
76 #ifdef HAVE_UNISTD_H
77 #  include <unistd.h>
78 #  include <sys/types.h>
79 #endif
80 
81 #ifdef HAVE_CTYPE_H
82 #  include <ctype.h>
83 #endif
84 
85 #ifdef HAVE_SYS_MODE_H
86 /* #include <sys/mode.h> */
87 #endif
88 
89 #ifdef HAVE_SYS_STAT_H
90 #  include <sys/stat.h>
91 #endif
92 
93 #ifdef HAVE_SYS_TERMIOS_H
94 #  include <sys/termios.h>
95 #else
96 #  ifdef HAVE_TERMIO_H
97 #    include <termio.h>
98 #  endif
99 #endif
100 
101 #ifdef HAVE_FCNTL_H
102 #  include <fcntl.h>
103 #endif
104 
105 #if !defined(TIOCGWINSZ) && defined(HAVE_SYS_IOCTL_H)
106 #  include <sys/ioctl.h>
107 #endif
108 
109 #if defined(DIRENT) || defined(_POSIX_VERSION)
110 #  include <dirent.h>
111 #  define NLENGTH(dirent) (strlen((dirent)->d_name))
112 #else /** not (DIRENT or _POSIX_VERSION) **/
113 #  define dirent direct
114 #  define NLENGTH(dirent) ((dirent)->d_namlen)
115 #  ifdef SYSNDIR
116 #    include <sys/ndir.h>
117 #  endif /** SYSNDIR **/
118 #  ifdef SYSDIR
119 #    include <sys/dir.h>
120 #  endif /** SYSDIR **/
121 #  ifdef NDIR
122 #    include <ndir.h>
123 #  endif /** NDIR **/
124 #endif /** not (DIRENT or _POSIX_VERSION) **/
125 
126 #ifdef HAVE_ERRNO_H
127 #  include <errno.h>
128 #else
129 extern	int	  errno;
130 #endif
131 
132 #ifdef HAVE_ASSERT_H
133 #  include <assert.h>
134 #else
135 #  warning "not able to test code assertions"
136 #  define assert(condition)
137 #endif
138 
139 /** ************************************************************************ **/
140 /** 				  LOCAL DATATYPES			     **/
141 /** ************************************************************************ **/
142 
143 /**
144  **  Structure to store information about a file.  Includes its name
145  **  and the structure to store information from the stat system call.
146  **/
147 
148 typedef struct _file_entry {
149     char*        fi_prefix;
150     char*        fi_name;
151     struct stat  fi_stats;
152     int          fi_listcount;
153     struct _file_entry* fi_subdir;
154 } fi_ent;
155 
156 /**
157  **  Error handling
158  **/
159 
160 typedef	enum	{
161 	NO_ERR = 0,			/** No error			     **/
162 	NO_ERR_DEBUG,			/** Debugging			     **/
163 	NO_ERR_START,			/** Start logging		     **/
164 	NO_ERR_END,			/** End logging			     **/
165 	NO_ERR_VERBOSE,			/** Verbose messages		     **/
166 	ERR_PARAM = 10,			/** Parameter error		     **/
167 	ERR_USAGE,			/** Usage information		     **/
168 	ERR_ARGSTOLONG,			/** Arguments to long		     **/
169 	ERR_OPT_AMBIG = 40,		/** Option is ambiguous		     **/
170 	ERR_OPT_NOARG,			/** Option allows no argument	     **/
171 	ERR_OPT_REQARG,			/** Option requires an argument	     **/
172 	ERR_OPT_UNKNOWN,		/** Unrecognized option 	     **/
173 	ERR_OPT_ILL,			/** Illegal option 		     **/
174 	ERR_OPT_INV,			/** Invalid option 		     **/
175 	ERR_USERLVL,			/** Unknown userlevel		     **/
176 	ERR_GETOPT,			/** getopt() failed		     **/
177 	ERR_OPEN = 50,			/** Error opening file		     **/
178 	ERR_POPEN,			/** Error opening pipe	    	     **/
179 	ERR_OPENDIR,			/** Error opening directory	     **/
180 	ERR_CLOSE,			/** Error when closing a file	     **/
181 	ERR_PCLOSE,			/** Error when closing a pipe	     **/
182 	ERR_CLOSEDIR,			/** Error when closing a directory   **/
183 	ERR_READ,			/** Error when reading from a file   **/
184 	ERR_READDIR,			/** Error when reading directory     **/
185 	ERR_WRITE,			/** Error when writing to a file     **/
186 	ERR_SEEK,			/** Seek error			     **/
187 	ERR_FLUSH,			/** Flush error			     **/
188 	ERR_DUP,			/** File duplication error	     **/
189 	ERR_DIRNAME,			/** Cannot build directory name	     **/
190 	ERR_NAMETOLONG,			/** Directory name to long	     **/
191 	ERR_DIRNOTFOUND,		/** Directory not found		     **/
192 	ERR_FILEINDIR,			/** File not in directory	     **/
193 	ERR_NODIR,			/** Not a directory		     **/
194 	ERR_UNLINK,			/** Cannot unlink file		     **/
195 	ERR_RENAME,			/** Cannot rename file		     **/
196 	ERR_ALLOC = 70,			/** Out of memory		     **/
197 	ERR_SOURCE,			/** Error while sourcing ...	     **/
198 	ERR_UNAME,			/** Uname failed		     **/
199 	ERR_GETHOSTNAME,		/** gethostname failed		     **/
200 	ERR_GETDOMAINNAME,		/** getdomainname failed	     **/
201 	ERR_STRING,			/** string error		     **/
202 	ERR_DISPLAY = 90,		/** cannot open display	    	     **/
203 	ERR_IN_MODULEFILE = 100,	/** modulefile related errors	     **/
204 	ERR_PARSE,			/** Parse error (modulefile)	     **/
205 	ERR_EXEC,			/** Execution error (modulefile)     **/
206 	ERR_EXTRACT,			/** Cannot extract X11 ressources    **/
207 	ERR_COMMAND,			/** Unrecognized command	     **/
208 	ERR_LOCATE,			/** Module file not found	     **/
209 	ERR_MAGIC,			/** Bad magic number		     **/
210 	ERR_MODULE_PATH,		/** Module path not set		     **/
211 	ERR_HOME,			/** Home not set		     **/
212 	ERR_SHELL,			/** Unknown shell type		     **/
213 	ERR_DERELICT,			/** Unknown shell derelict	     **/
214 	ERR_CONFLICT = 150,		/** Module file conflicts	     **/
215 	ERR_PREREQ,			/** Module file prerequirements	     **/
216 	ERR_NOTLOADED,			/** Module file is currently not l.  **/
217 	ERR_DUP_SYMVERS,		/** Duplicate symbolic version	     **/
218 	ERR_SYMLOOP,			/** Loop in symbol version def.	     **/
219 	ERR_BADMODNAM,			/** Bad modulename in version, alias **/
220 	ERR_DUP_ALIAS,			/** Duplicate alias		     **/
221 	ERR_CACHE_INVAL,		/** Invalid cache version	     **/
222 	ERR_CACHE_LOAD,			/** Cannot load cache properly	     **/
223 	ERR_BEGINENV,			/** No update if no .modulesbeginenv **/
224 	ERR_BEGINENVX,			/** No MODULESBEGINENV env.var.      **/
225 	ERR_INIT_TCL,			/** Cannot initialize TCL	     **/
226 	ERR_INIT_TCLX,			/** Cannot initialize extended TCL   **/
227 	ERR_INIT_ALPATH,		/** Cannot set up autoload path      **/
228 	ERR_INIT_STUP,			/** No 'module load in the shellstups**/
229 	ERR_SET_VAR,			/** Cannot set TCL variable	     **/
230 	ERR_INFO_DESCR,			/** Unrecognized module info descr.  **/
231 	ERR_INVWGHT_WARN,		/** Invalid error weight	     **/
232 	ERR_INVFAC_WARN,		/** Invalid error facility	     **/
233 	ERR_COLON,			/** Colon in tracing pattern	     **/
234 	ERR_INTERNAL = 990,		/** Error logger internal error	     **/
235 	ERR_INTERAL,			/** Alias module internal error	     **/
236 	ERR_INTERRL,			/** Error logger internal error	     **/
237 	ERR_INVAL,			/** Invalid parameter to the error   **/
238 	ERR_INVWGHT,			/** logger			     **/
239 	ERR_INVFAC,			/** Invalid error facility	     **/
240         ERR_ENVVAR                      /** env. variables are inconsistent  **/
241 } ErrType;
242 
243 /**
244  **  Error return values. Only OK, PROBLEM and ERROR will be returned to the
245  **  caller, In case of the remaining, the error handler takes control over the
246  **  whole application.
247  **/
248 
249 typedef	enum	{
250 	OK	= 0,			/** Everything's up and running	     **/
251 	WARN	= 2,			/** A warning (mapped to OK by the   **/
252 					/** Errorlogger			     **/
253 	PROBLEM	= 5,			/** Problem ... program might cont.  **/
254 	ERROR	= 7,			/** Error .. try gracefull aborting  **/
255 	FATAL	= 10,			/** The following will lead to the   **/
256 	PANIC	= 20			/** progrm being aborted by the er-  **/
257 					/** ror logger immediatelly	     **/
258 } ErrCode;
259 
260 /**
261  **  Internal return value to handle the various ways a module load
262  **	could end.
263  **/
264 typedef enum	{
265 	EM_OK		= 0,		/** normal return	**/
266 	EM_EXIT,			/** cmd: exit N		**/
267 					/** (set g_retval = N)	**/
268 	EM_BREAK,			/** cmd: break		**/
269 	EM_CONTINUE,			/** cmd: continue	**/
270 	EM_ERROR			/** abnormal return	**/
271 } EM_RetVal;
272 
273 /** ************************************************************************ **/
274 /** 				     CONSTANTS				     **/
275 /** ************************************************************************ **/
276 
277 #define      MODULES_MAGIC_COOKIE         "#%Module"
278 #define      MODULES_MAGIC_COOKIE_LENGTH  8
279 
280 /**
281  **  User level
282  **/
283 
284 #define	UL_NOVICE	0
285 #define	UL_ADVANCED	64
286 #define	UL_EXPERT	128
287 
288 /**
289  **  Debugging
290  **/
291 
292 #define	WITHOUT_DEBUGGING		!defined( WITH_DEBUG_INFO)
293 #define	WITH_DEBUGGING			defined( WITH_DEBUG_INFO)
294 #define	WITH_DEBUGGING_MODULECMD	(WITH_DEBUGGING && WITH_DEBUG_INFO > 0)
295 #define	WITH_DEBUGGING_MODULECMD_1	(WITH_DEBUGGING && WITH_DEBUG_INFO > 1)
296 #define	WITH_DEBUGGING_INIT		(WITH_DEBUGGING && WITH_DEBUG_INFO > 10)
297 #define	WITH_DEBUGGING_CALLBACK		(WITH_DEBUGGING && WITH_DEBUG_INFO > 20)
298 #define	WITH_DEBUGGING_CALLBACK_1	(WITH_DEBUGGING && WITH_DEBUG_INFO > 21)
299 #define	WITH_DEBUGGING_LOCATE		(WITH_DEBUGGING && WITH_DEBUG_INFO > 30)
300 #define	WITH_DEBUGGING_LOCATE_1		(WITH_DEBUGGING && WITH_DEBUG_INFO > 31)
301 #define	WITH_DEBUGGING_UTIL		(WITH_DEBUGGING && WITH_DEBUG_INFO > 40)
302 #define	WITH_DEBUGGING_UTIL_1		(WITH_DEBUGGING && WITH_DEBUG_INFO > 41)
303 #define	WITH_DEBUGGING_UTIL_2		(WITH_DEBUGGING && WITH_DEBUG_INFO > 42)
304 #define	WITH_DEBUGGING_UTIL_3		(WITH_DEBUGGING && WITH_DEBUG_INFO > 43)
305 
306 /**
307  **  Default error log facilities
308  **/
309 
310 #ifdef	WITH_LOG_FACILITY_VERBOSE
311 #   define	DEF_FACILITY_VERBOSE		WITH_LOG_FACILITY_VERBOSE
312 #else
313 #   define	DEF_FACILITY_VERBOSE		_stderr
314 #endif
315 
316 #ifdef	WITH_LOG_FACILITY_INFO
317 #   define	DEF_FACILITY_INFO		WITH_LOG_FACILITY_INFO
318 #else
319 #   define	DEF_FACILITY_INFO		_stderr
320 #endif
321 
322 #ifdef	WITH_LOG_FACILITY_DEBUG
323 #   define	DEF_FACILITY_DEBUG		WITH_LOG_FACILITY_DEBUG
324 #else
325 #   define	DEF_FACILITY_DEBUG		NULL
326 #endif
327 
328 #ifdef	WITH_LOG_FACILITY_TRACE
329 #   define	DEF_FACILITY_TRACE		WITH_LOG_FACILITY_TRACE
330 #else
331 #   define	DEF_FACILITY_TRACE		NULL
332 #endif
333 
334 #ifdef	WITH_LOG_FACILITY_WARN
335 #   define	DEF_FACILITY_WARN		WITH_LOG_FACILITY_WARN
336 #else
337 #   define	DEF_FACILITY_WARN		_stderr
338 #endif
339 
340 #ifdef	WITH_LOG_FACILITY_PROB
341 #   define	DEF_FACILITY_PROB		WITH_LOG_FACILITY_PROB
342 #else
343 #   define	DEF_FACILITY_PROB		_stderr
344 #endif
345 
346 #ifdef	WITH_LOG_FACILITY_ERROR
347 #   define	DEF_FACILITY_ERROR		WITH_LOG_FACILITY_ERROR
348 #else
349 #   define	DEF_FACILITY_ERROR		_stderr
350 #endif
351 
352 #ifdef	WITH_LOG_FACILITY_FATAL
353 #   define	DEF_FACILITY_FATAL		WITH_LOG_FACILITY_FATAL
354 #else
355 #   define	DEF_FACILITY_FATAL		_stderr
356 #endif
357 
358 #ifdef	WITH_LOG_FACILITY_PANIC
359 #   define	DEF_FACILITY_PANIC		WITH_LOG_FACILITY_PANIC
360 #else
361 #   define	DEF_FACILITY_PANIC		_stderr
362 #endif
363 
364 /**
365  **  g_flags values
366  **/
367 
368 #define      M_REMOVE	0x0001
369 #define      M_DISPLAY	0x0002
370 #define      M_SWSTATE1	0x0004
371 #define      M_SWSTATE2	0x0008
372 #define      M_SWSTATE3	0x0010
373 #define      M_SWITCH	( M_SWSTATE1 | M_SWSTATE2 | M_SWSTATE3)
374 #define      M_LOAD	0x0020
375 #define      M_CLEAR	0x0040
376 #define      M_PREPEND	0x0080
377 #define      M_HELP	0x0100
378 #define      M_WHATIS	0x0200
379 #define      M_NONPERSIST	0x0400
380 #define      M_SUBCMD	0x8000
381 
382 /**
383  **  markers for switching
384  **/
385 
386 #define      SWMARKER        "--VARMARKER--"  /**  for variables and aliases  **/
387 #define      APP_SW_MARKER   "--APPMARKER--"  /**  for appending paths  **/
388 #define      PRE_SW_MARKER   "--PREMARKER--"  /**  for prepending paths  **/
389 
390 /**
391  **  return values
392  **/
393 
394 #define TCL_LEVEL0_RETURN    11
395 
396 /**
397  **  uname defaults when uname can't be found
398  **/
399 
400 #ifndef UNAME_SYSNAME
401 #  define UNAME_SYSNAME		"unknown"
402 #endif
403 
404 #ifndef UNAME_NODENAME
405 #  define UNAME_NODENAME	"unknown"
406 #endif
407 
408 #ifndef UNAME_RELEASE
409 #  define UNAME_RELEASE		"unknown"
410 #endif
411 
412 #ifndef UNAME_VERSION
413 #  define UNAME_VERSION		"unknown"
414 #endif
415 
416 #ifndef UNAME_MACHINE
417 #  define UNAME_MACHINE		"unknown"
418 #endif
419 
420 #ifndef UNAME_DOMAIN
421 #  define UNAME_DOMAIN		"unknown"
422 #endif
423 
424 /**
425  **  RC files
426  **/
427 
428 #ifndef	RCFILE
429 #  define	RCFILE		"rc"
430 #endif
431 
432 #ifndef	MODULERCFILE
433 #  define	MODULERCFILE	".modulerc"
434 #endif
435 
436 #ifndef	VERSIONFILE
437 #  define	VERSIONFILE	".version"
438 #endif
439 
440 #ifndef	APR_CACHE
441 #  define	APR_CACHE	"apropos.cache"
442 #endif
443 
444 /**
445  **  Buffer sizes
446  **/
447 
448 #define  LINELENGTH	8192
449 #define  MOD_BUFSIZE	1024
450 
451 /** ************************************************************************ **/
452 /**				      MACROS				     **/
453 /** ************************************************************************ **/
454 
455 /**
456  **  I'm going to remove all of the calls to free( ) since they are not
457  **    necessary for Modules.  Since the modulecmd program is only run for
458  **    a very short time ( usually <1sec) it's faster to not clutter the heap
459  **    by freeing up memory.
460  **
461  **  If you disagree with this decision, or have some problems with this
462  **    behavior on your system, configure with --enable-free
463  **
464  **  Note that all memory deallocations should go through null_free()
465  **/
466 
467 #ifndef USE_FREE
468 #  define  free( x)
469 #  define  FreeList( x, y)
470 #endif
471 
472 /**
473  **  Some systems don't define S_ISDIR and S_ISREG
474  **/
475 
476 #ifdef HAVE_SYS_STAT_H
477 #  ifndef S_ISDIR
478 #    define S_ISDIR( m) (((m) & S_IFMT) == S_IFDIR)
479 #  endif
480 #  ifndef S_ISREG
481 #    define S_ISREG( m) (((m) & S_IFMT) == S_IFREG)
482 #  endif
483 #endif
484 
485 /**
486  **  Error logger
487  **/
488 
489 #define	ErrorLogger	Module_Error
490 #define	LOC		module_name, __LINE__
491 
492 /** ************************************************************************ **/
493 /** 				    GLOBAL DATA				     **/
494 /** ************************************************************************ **/
495 
496 extern	char	**environ;
497 
498 extern	char	 *version_string;
499 extern	char	 *date_string;
500 extern	char	 *g_current_module;
501 extern	char	 *g_specified_module;
502 extern	char	 *shell_name;
503 extern	char	 *shell_derelict;
504 extern	char	 *shell_init;
505 extern	char	 *shell_cmd_separator;
506 extern	int	  g_flags;
507 extern	int	  g_retval;
508 extern	int	  g_output;
509 extern	int	  append_flag;
510 extern	char	 *line;
511 extern	char	 *error_line;
512 extern	char	  local_line[];
513 extern	char	  _default[];
514 extern	char	  _colon[];
515 
516 extern	int	  linenum;
517 
518 extern	char	*addRE;
519 extern	char	*rmRE;
520 extern	char	*swRE;
521 extern	char	*dispRE;
522 extern	char	*listRE;
523 extern	char	*availRE;
524 extern	char	*helpRE;
525 extern	char	*initRE;
526 extern	char	*initxRE;
527 extern	char	*useRE;
528 extern	char	*unuseRE;
529 extern	char	*updateRE;
530 extern	char	*purgeRE;
531 extern	char	*clearRE;
532 extern	char	*whatisRE;
533 extern	char	*aproposRE;
534 extern	char	*refreshRE;
535 
536 extern	Tcl_HashTable	*setenvHashTable;
537 extern	Tcl_HashTable	*unsetenvHashTable;
538 extern	Tcl_HashTable	*aliasSetHashTable;
539 extern	Tcl_HashTable	*aliasUnsetHashTable;
540 extern	Tcl_HashTable	*markVariableHashTable;
541 extern	Tcl_HashTable	*markAliasHashTable;
542 
543 extern	char    _fil_stdin[];
544 extern	char    _fil_stdout[];
545 extern	char    _fil_stderr[];
546 extern	char    _fil_devnull[];
547 
548 extern	int	sw_detach;
549 extern	int	sw_force;
550 extern	int	sw_format;
551 #define	SW_SET		0x01
552 #define	SW_HUMAN	0x02
553 #define	SW_PARSE	0x04
554 #define	SW_TERSE	0x08
555 #define	SW_LONG		0x10
556 #define	SW_LIST		0x20
557 extern	int	sw_create;
558 extern	int	sw_verbose;
559 extern	int	sw_userlvl;
560 extern	int	sw_icase;
561 
562 extern	char	*instpath;
563 extern	char	*rc_file;
564 extern	char	*modulerc_file;
565 extern	char	*version_file;
566 extern	char	*change_dir;
567 
568 extern	char	 long_header[];
569 
570 /** ************************************************************************ **/
571 /**				    PROTOTYPES				     **/
572 /** ************************************************************************ **/
573 
574 /**  locate_module.c  **/
575 extern	int	  Locate_ModuleFile( Tcl_Interp*, char*, char*, char*);
576 extern	char	**SortedDirList( Tcl_Interp*, char*, char*, int*);
577 extern	char	**SplitIntoList( Tcl_Interp*, char*, int*, const char*);
578 extern	int	  SourceVers( Tcl_Interp*, char*, char*);
579 extern	int	  SourceRC( Tcl_Interp *interp, char *, char *);
580 #ifdef USE_FREE
581 extern	void	  FreeList( char**, int);
582 #endif
583 
584 /**  main.c  **/
585 extern  void	  module_usage(FILE *output);
586 
587 /**  ModuleCmd_Avail.c  **/
588 extern	int	  ModuleCmd_Avail( Tcl_Interp*, int, char*[]);
589 extern	void	  print_dirents( char*);
590 extern	char	 *strip_top( char*);
591 extern	void	  print_aligned_files(Tcl_Interp*,char*,char*,char**,int,int);
592 extern	int	  check_dir( char*);
593 extern	fi_ent	 *get_dir( char*, char*, int*, int*);
594 extern	void	  dirlst_to_list( char**, fi_ent*, int, int*, char*, char*);
595 extern	void	  delete_dirlst( fi_ent*, int);
596 extern	void	  delete_cache_list( char**, int);
597 
598 /**  ModuleCmd_Clear.c  **/
599 extern	int	  ModuleCmd_Clear( Tcl_Interp*, int, char*[]);
600 
601 /**  ModuleCmd_Display.c  **/
602 extern	int	  ModuleCmd_Display( Tcl_Interp*, int, char*[]);
603 
604 /**  ModuleCmd_Help.c  **/
605 extern	int	  ModuleCmd_Help( Tcl_Interp*, int, char*[]);
606 
607 /**  ModuleCmd_Init.c  **/
608 extern	int	  ModuleCmd_Init( Tcl_Interp*, int, char*[]);
609 
610 /**  ModuleCmd_List.c  **/
611 extern	int	  ModuleCmd_List( Tcl_Interp*, int, char*[]);
612 
613 /**  ModuleCmd_Load.c  **/
614 extern	int	  ModuleCmd_Load( Tcl_Interp*, int, int, char*[]);
615 
616 /**  ModuleCmd_Purge.c  **/
617 extern	int	  ModuleCmd_Purge( Tcl_Interp*, int, char*[]);
618 
619 /**  ModuleCmd_Refresh.c  **/
620 extern	int	  ModuleCmd_Refresh( Tcl_Interp*, int, char*[]);
621 
622 /**  ModuleCmd_Switch.c  **/
623 extern	int	  ModuleCmd_Switch( Tcl_Interp*, int, char*[]);
624 
625 /**  ModuleCmd_Update.c  **/
626 extern	int	  ModuleCmd_Update( Tcl_Interp*, int, char*[]);
627 
628 /**  ModuleCmd_Whatis.c  **/
629 extern	int	  ModuleCmd_Whatis( Tcl_Interp*, int, char*[]);
630 extern	int	  ModuleCmd_Apropos( Tcl_Interp*, int, char*[]);
631 
632 /**  ModuleCmd_Use.c  **/
633 extern	int	  ModuleCmd_Use( Tcl_Interp*, int, char*[]);
634 extern	int	  ModuleCmd_UnUse( Tcl_Interp*, int, char*[]);
635 
636 /**  cmdAlias.c  **/
637 extern	int	  cmdSetAlias( ClientData, Tcl_Interp*, int, CONST84 char*[]);
638 
639 /**  cmdConflict.c  **/
640 extern	int	  cmdConflict( ClientData, Tcl_Interp*, int, CONST84 char*[]);
641 extern	int	  cmdPrereq( ClientData, Tcl_Interp*, int, CONST84 char*[]);
642 
643 /**  cmdIsLoaded.c  **/
644 extern	int	  cmdIsLoaded(ClientData, Tcl_Interp*, int, CONST84 char*[]);
645 
646 /**  cmdVerbose.c  **/
647 extern	int	  cmdModuleVerbose(ClientData,Tcl_Interp*,int,CONST84 char*[]);
648 
649 /**  cmdWhatis.c  **/
650 extern	char	**whatis;
651 extern	void	  cmdModuleWhatisInit(void);
652 extern	void	  cmdModuleWhatisShut(void);
653 extern	int	  cmdModuleWhatis(ClientData,Tcl_Interp*,int,CONST84 char*[]);
654 
655 /**  cmdInfo.c  **/
656 extern	int	  cmdModuleInfo(ClientData, Tcl_Interp*, int, CONST84 char*[]);
657 extern	char	 *module_command;
658 
659 /**  cmdMisc.c  **/
660 extern	int	  cmdSystem( ClientData, Tcl_Interp*, int, CONST84 char*[]);
661 
662 /**  cmdModule.c  **/
663 extern	int	  cmdModule( ClientData, Tcl_Interp*, int, CONST84 char*[]);
664 extern	int	  Read_Modulefile( Tcl_Interp*, char*);
665 extern	int	  Execute_TclFile( Tcl_Interp*, char*);
666 extern	int	  CallModuleProcedure( Tcl_Interp*, Tcl_DString*, char*, char*,
667 			int);
668 
669 /**  cmdPath.c  **/
670 extern	int	  cmdSetPath( ClientData, Tcl_Interp*, int, CONST84 char*[]);
671 extern	int	  cmdRemovePath( ClientData, Tcl_Interp*, int, CONST84 char*[]);
672 extern	char	 *chk_nullvars( char*);
673 
674 /**  cmdSetenv.c  **/
675 extern	int	  cmdSetEnv( ClientData, Tcl_Interp*, int, CONST84 char*[]);
676 extern	int	  moduleSetenv( Tcl_Interp*, char	 *, char*, int);
677 extern	int	  cmdUnsetEnv( ClientData, Tcl_Interp*, int, CONST84 char*[]);
678 extern	int	  moduleUnsetenv( Tcl_Interp*, char	 *);
679 
680 /**  cmdUname.c  **/
681 extern	int	  cmdUname( ClientData, Tcl_Interp*, int, CONST84 char*[]);
682 
683 /**  cmdXResource.c  **/
684 extern	int	  cmdXResource( ClientData, Tcl_Interp*, int, CONST84 char*[]);
685 extern	void	  xresourceFinish( int);
686 
687 /**  cmdUlvl.c  **/
688 extern	int	  cmdModuleUser(ClientData, Tcl_Interp*, int, CONST84 char*[]);
689 extern	int	  cmdModuleUser_sub( char *user_level);
690 
691 /**  cmdChdir.c **/
692 extern	int	  cmdChDir(ClientData, Tcl_Interp*, int, CONST84 char*[]);
693 
694 /**  cmdLog.c  **/
695 extern	int	  cmdModuleLog( ClientData, Tcl_Interp*, int, CONST84 char*[]);
696 
697 /**  cmdTrace.c  **/
698 extern	int	  cmdModuleTrace(ClientData,Tcl_Interp*, int, CONST84 char*[]);
699 extern	char	 *GetTraceSel(Tcl_Interp*, char*);
700 extern	int	  CheckTracing(Tcl_Interp*, char*, char*);
701 extern	int	  CheckTracingList(Tcl_Interp*, char*, int, char**);
702 
703 /**  cmdVersion.c  **/
704 extern	int	  cmdModuleVersion(ClientData,Tcl_Interp*,int,CONST84 char*[]);
705 extern	int	  cmdModuleAlias(ClientData,Tcl_Interp*, int, CONST84 char*[]);
706 extern	int	  AliasLookup( char*, char**, char**);
707 extern	int	  VersionLookup( char*, char**, char**);
708 extern	char	 *ExpandVersions( char*);
709 
710 /**  init.c  **/
711 extern	Tcl_Interp	 *EM_CreateInterp(void);
712 extern	void	  EM_DeleteInterp(Tcl_Interp*);
713 extern	int	  Initialize_Tcl( Tcl_Interp**, int, char*[], char*[]);
714 extern	int	  InitializeModuleCommands( Tcl_Interp*);
715 extern	int	  Setup_Environment( Tcl_Interp*);
716 extern	char	**SetStartupFiles( char *shell_name);
717 extern	int	  TieStdout( void);
718 extern	int	  UnTieStdout( int);
719 
720 /**  utility.c  **/
721 extern	char	 *getLMFILES( Tcl_Interp *interp);
722 extern	int	  store_hash_value( Tcl_HashTable*, const char*, const char*);
723 extern	int	  clear_hash_value( Tcl_HashTable*, const char*);
724 extern	int	  store_old_shell_variable( Tcl_HashTable*, const char*,
725 			const char*);
726 extern	int	  clear_old_shell_variable( Tcl_HashTable*, const char*);
727 extern	void	  Delete_Global_Hash_Tables( void);
728 extern	void	  Delete_Hash_Tables( Tcl_HashTable**);
729 extern	Tcl_HashTable** Copy_Hash_Tables( void);
730 extern	int	  Unwind_Modulefile_Changes( Tcl_Interp*, Tcl_HashTable**);
731 extern	int	  Output_Modulefile_Changes( Tcl_Interp*);
732 extern	int	  store_env( void);
733 extern	int	  free_stored_env( void);
734 extern	void	  set_marked_entry( Tcl_HashTable*, char*, intptr_t);
735 extern	intptr_t  chk_marked_entry( Tcl_HashTable*, char*);
736 extern	Tcl_HashTable*  environ_changes;
737 extern	Tcl_HashTable*  alias_changes;
738 extern	int	  IsLoaded( Tcl_Interp*, char*, char**, char*);
739 extern	int	  IsLoaded_ExactMatch( Tcl_Interp*, char*, char	**, char*);
740 extern	int	  Update_LoadedList( Tcl_Interp*, char*, char*);
741 extern	int	  check_magic( char*, char*, int);
742 extern	void	  regex_quote( const char*, char*, int);
743 extern	char	 *xstrtok_r(char *, const char *, char **);
744 extern	char	 *xstrtok(char *, const char *);
745 extern	void	  chk4spch( char*);
746 extern	void	  cleanse_path( const char*, char*, int);
747 extern	void	 *module_malloc(size_t);
748 extern	void	 *module_realloc(void *,size_t);
749 extern	char	 *xdup(char const *);
750 extern	char	 *xgetenv(char const *);
751 extern  int       tmpfile_mod( char**, FILE**);
752 extern	char	 *stringer(char *, int, ...);
753 extern	void	  null_free(void **);
754 extern	size_t	  countTclHash(Tcl_HashTable *);
755 extern	EM_RetVal	ReturnValue( Tcl_Interp*, int);
756 extern	void	  OutputExit();
757 extern	char 	 *EMGetEnv(Tcl_Interp *, char const *);
758 extern	char 	 *EMSetEnv(Tcl_Interp *, char const *, char const *);
759 extern	int	  is_interactive(void);
760 
761 #ifndef HAVE_STRDUP
762 #  undef strdup
763 extern	char	 *strdup( char*);
764 #endif
765 
766 #ifndef HAVE_STRTOK
767 extern	char	 *strtok( char *, const char *);
768 #endif
769 
770 /** error.c **/
771 extern	char	**GetFacilityPtr( char *);
772 extern	int 	  Module_Error(	ErrType, char*, int, ...);
773 extern	int	  CheckFacility( char*, int*, int*);
774 extern	void	  Module_Tracing( int, int, char**);
775 extern	void	  Module_Verbosity( int, char**);
776 
777 #endif  /**  _MODULES_DEF_H  **/
778