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