~ubuntu-branches/ubuntu/utopic/modules/utopic-proposed

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
/*****
 ** ** Module Header ******************************************************* **
 ** 									     **
 **   Modules Revision 3.2						     **
 **   Providing a flexible user environment				     **
 ** 									     **
 **   File:		modules_def.h					     **
 **   First Edition:	1991/10/23					     **
 ** 									     **
 **   Authors:	John Furlan, jlf@behere.com				     **
 **		Jens Hamisch, jens@Strawberry.COM			     **
 **		R.K. Owen, rk@owen.sj.ca.us				     **
 ** 									     **
 **   Description:							     **
 ** 									     **
 **   Exports:								     **
 ** 									     **
 **   Notes:								     **
 ** 									     **
 ** ************************************************************************ **
 ****/

/** ** Copyright *********************************************************** **
 ** 									     **
 ** Copyright 1991-1994 by John L. Furlan.                      	     **
 ** see LICENSE.GPL, which must be provided, for details		     **
 ** 									     ** 
 ** ************************************************************************ **/

#ifndef _MODULES_DEF_H
#define _MODULES_DEF_H

/** ************************************************************************ **/
/** 				      HEADERS				     **/
/** ************************************************************************ **/

#include <stdio.h>
#include <stdarg.h>
#include <tcl.h>
#include "config.h"

#ifndef CONST84
#  define CONST84	/* const */
#endif

#if (TCL_MAJOR_VERSION < 8)
#  define TCL_RESULT(interp) ((interp)->result)
#else
#  define TCL_RESULT(interp) Tcl_GetStringResult(interp)
#endif

#ifndef HAVE_STDINT_H
/* assume 32 bit - hope for the best */
typedef	int	intptr_h;
#endif

#ifdef HAVE_STDLIB_H
#  include <stdlib.h>
#endif

#if STDC_HEADERS || HAVE_STRING_H
#  include <string.h>
/**
 **  An ANSI string.h and pre-ANSI memory.h might conflict.
 **/
#  if !STDC_HEADERS && HAVE_MEMORY_H
#    include <memory.h>
#  endif /** not STDC_HEADERS and HAVE_MEMORY_H **/
#else /** not STDC_HEADERS and not HAVE_STRING_H **/
#  include <strings.h>
/**
 **  memory.h and strings.h conflict on some systems.
 **/
#endif /** not STDC_HEADERS and not HAVE_STRING_H  **/

#ifdef HAVE_UNISTD_H
#  include <unistd.h>
#  include <sys/types.h>
#endif

#ifdef HAVE_CTYPE_H
#  include <ctype.h>
#endif

#ifdef HAVE_SYS_MODE_H
/* #include <sys/mode.h> */
#endif

#ifdef HAVE_SYS_STAT_H
#  include <sys/stat.h>
#endif

#ifdef HAVE_SYS_TERMIOS_H
#  include <sys/termios.h>
#else
#  ifdef HAVE_TERMIO_H
#    include <termio.h>
#  endif
#endif

#ifdef HAVE_FCNTL_H
#  include <fcntl.h>
#endif

#if !defined(TIOCGWINSZ) && defined(HAVE_SYS_IOCTL_H)
#  include <sys/ioctl.h>
#endif

#if defined(DIRENT) || defined(_POSIX_VERSION)
#  include <dirent.h>
#  define NLENGTH(dirent) (strlen((dirent)->d_name))
#else /** not (DIRENT or _POSIX_VERSION) **/
#  define dirent direct
#  define NLENGTH(dirent) ((dirent)->d_namlen)
#  ifdef SYSNDIR
#    include <sys/ndir.h>
#  endif /** SYSNDIR **/
#  ifdef SYSDIR
#    include <sys/dir.h>
#  endif /** SYSDIR **/
#  ifdef NDIR
#    include <ndir.h>
#  endif /** NDIR **/
#endif /** not (DIRENT or _POSIX_VERSION) **/

#ifdef HAVE_ERRNO_H
#  include <errno.h>
#else
extern	int	  errno;
#endif

#ifdef HAVE_ASSERT_H
#  include <assert.h>
#else
#  warning "not able to test code assertions"
#  define assert(condition)
#endif

/** ************************************************************************ **/
/** 				  LOCAL DATATYPES			     **/
/** ************************************************************************ **/

/**
 **  Structure to store information about a file.  Includes its name
 **  and the structure to store information from the stat system call.
 **/

typedef struct _file_entry {
    char*        fi_prefix;
    char*        fi_name;
    struct stat  fi_stats;
    int          fi_listcount;
    struct _file_entry* fi_subdir;
} fi_ent;

/**
 **  Error handling
 **/

typedef	enum	{
	NO_ERR = 0,			/** No error			     **/
	NO_ERR_DEBUG,			/** Debugging			     **/
	NO_ERR_START,			/** Start logging		     **/
	NO_ERR_END,			/** End logging			     **/
	NO_ERR_VERBOSE,			/** Verbose messages		     **/
	ERR_PARAM = 10,			/** Parameter error		     **/
	ERR_USAGE,			/** Usage information		     **/
	ERR_ARGSTOLONG,			/** Arguments to long		     **/
	ERR_OPT_AMBIG = 40,		/** Option is ambiguous		     **/
	ERR_OPT_NOARG,			/** Option allows no argument	     **/
	ERR_OPT_REQARG,			/** Option requires an argument	     **/
	ERR_OPT_UNKNOWN,		/** Unrecognized option 	     **/
	ERR_OPT_ILL,			/** Illegal option 		     **/
	ERR_OPT_INV,			/** Invalid option 		     **/
	ERR_USERLVL,			/** Unknown userlevel		     **/
	ERR_GETOPT,			/** getopt() failed		     **/
	ERR_OPEN = 50,			/** Error opening file		     **/
	ERR_POPEN,			/** Error opening pipe	    	     **/
	ERR_OPENDIR,			/** Error opening directory	     **/
	ERR_CLOSE,			/** Error when closing a file	     **/
	ERR_PCLOSE,			/** Error when closing a pipe	     **/
	ERR_CLOSEDIR,			/** Error when closing a directory   **/
	ERR_READ,			/** Error when reading from a file   **/
	ERR_READDIR,			/** Error when reading directory     **/
	ERR_WRITE,			/** Error when writing to a file     **/
	ERR_SEEK,			/** Seek error			     **/
	ERR_FLUSH,			/** Flush error			     **/
	ERR_DUP,			/** File duplication error	     **/
	ERR_DIRNAME,			/** Cannot build directory name	     **/
	ERR_NAMETOLONG,			/** Directory name to long	     **/
	ERR_DIRNOTFOUND,		/** Directory not found		     **/
	ERR_FILEINDIR,			/** File not in directory	     **/
	ERR_NODIR,			/** Not a directory		     **/
	ERR_UNLINK,			/** Cannot unlink file		     **/
	ERR_RENAME,			/** Cannot rename file		     **/
	ERR_ALLOC = 70,			/** Out of memory		     **/
	ERR_SOURCE,			/** Error while sourcing ...	     **/
	ERR_UNAME,			/** Uname failed		     **/
	ERR_GETHOSTNAME,		/** gethostname failed		     **/
	ERR_GETDOMAINNAME,		/** getdomainname failed	     **/
	ERR_STRING,			/** string error		     **/
	ERR_DISPLAY = 90,		/** cannot open display	    	     **/
	ERR_IN_MODULEFILE = 100,	/** modulefile related errors	     **/
	ERR_PARSE,			/** Parse error (modulefile)	     **/
	ERR_EXEC,			/** Execution error (modulefile)     **/
	ERR_EXTRACT,			/** Cannot extract X11 ressources    **/
	ERR_COMMAND,			/** Unrecognized command	     **/
	ERR_LOCATE,			/** Module file not found	     **/
	ERR_MAGIC,			/** Bad magic number		     **/
	ERR_MODULE_PATH,		/** Module path not set		     **/
	ERR_HOME,			/** Home not set		     **/
	ERR_SHELL,			/** Unknown shell type		     **/
	ERR_DERELICT,			/** Unknown shell derelict	     **/
	ERR_CONFLICT = 150,		/** Module file conflicts	     **/
	ERR_PREREQ,			/** Module file prerequirements	     **/
	ERR_NOTLOADED,			/** Module file is currently not l.  **/
	ERR_DUP_SYMVERS,		/** Duplicate symbolic version	     **/
	ERR_SYMLOOP,			/** Loop in symbol version def.	     **/
	ERR_BADMODNAM,			/** Bad modulename in version, alias **/
	ERR_DUP_ALIAS,			/** Duplicate alias		     **/
	ERR_CACHE_INVAL,		/** Invalid cache version	     **/
	ERR_CACHE_LOAD,			/** Cannot load cache properly	     **/
	ERR_BEGINENV,			/** No update if no .modulesbeginenv **/
	ERR_BEGINENVX,			/** No MODULESBEGINENV env.var.      **/
	ERR_INIT_TCL,			/** Cannot initialize TCL	     **/
	ERR_INIT_TCLX,			/** Cannot initialize extended TCL   **/
	ERR_INIT_ALPATH,		/** Cannot set up autoload path      **/
	ERR_INIT_STUP,			/** No 'module load in the shellstups**/
	ERR_SET_VAR,			/** Cannot set TCL variable	     **/
	ERR_INFO_DESCR,			/** Unrecognized module info descr.  **/
	ERR_INVWGHT_WARN,		/** Invalid error weight	     **/
	ERR_INVFAC_WARN,		/** Invalid error facility	     **/
	ERR_COLON,			/** Colon in tracing pattern	     **/
	ERR_INTERNAL = 990,		/** Error logger internal error	     **/
	ERR_INTERAL,			/** Alias module internal error	     **/
	ERR_INTERRL,			/** Error logger internal error	     **/
	ERR_INVAL,			/** Invalid parameter to the error   **/
	ERR_INVWGHT,			/** logger			     **/
	ERR_INVFAC,			/** Invalid error facility	     **/
        ERR_ENVVAR,                     /** env. variables are inconsistent  **/
} ErrType;

/**
 **  Error return values. Only OK, PROBLEM and ERROR will be returned to the
 **  caller, In case of the remaining, the error handler takes control over the
 **  whole application.
 **/

typedef	enum	{
	OK	= 0,			/** Everything's up and running	     **/
	WARN	= 2,			/** A warning (mapped to OK by the   **/
					/** Errorlogger			     **/
	PROBLEM	= 5,			/** Problem ... program might cont.  **/
	ERROR	= 7,			/** Error .. try gracefull aborting  **/
	FATAL	= 10,			/** The following will lead to the   **/
	PANIC	= 20			/** progrm being aborted by the er-  **/
					/** ror logger immediatelly	     **/
} ErrCode;

/**
 **  Internal return value to handle the various ways a module load
 **	could end.
 **/
typedef enum	{
	EM_OK		= 0,		/** normal return	**/
	EM_EXIT,			/** cmd: exit N		**/
					/** (set g_retval = N)	**/
	EM_BREAK,			/** cmd: break		**/
	EM_CONTINUE,			/** cmd: continue	**/
	EM_ERROR			/** abnormal return	**/
} EM_RetVal;

/** ************************************************************************ **/
/** 				     CONSTANTS				     **/
/** ************************************************************************ **/

#define      MODULES_MAGIC_COOKIE         "#%Module"
#define      MODULES_MAGIC_COOKIE_LENGTH  8

/**
 **  User level
 **/

#define	UL_NOVICE	0
#define	UL_ADVANCED	64
#define	UL_EXPERT	128

/**
 **  Debugging
 **/

#define	WITHOUT_DEBUGGING		!defined( WITH_DEBUG_INFO)
#define	WITH_DEBUGGING			defined( WITH_DEBUG_INFO)
#define	WITH_DEBUGGING_MODULECMD	(WITH_DEBUGGING && WITH_DEBUG_INFO > 0)
#define	WITH_DEBUGGING_MODULECMD_1	(WITH_DEBUGGING && WITH_DEBUG_INFO > 1)
#define	WITH_DEBUGGING_INIT		(WITH_DEBUGGING && WITH_DEBUG_INFO > 10)
#define	WITH_DEBUGGING_CALLBACK		(WITH_DEBUGGING && WITH_DEBUG_INFO > 20)
#define	WITH_DEBUGGING_CALLBACK_1	(WITH_DEBUGGING && WITH_DEBUG_INFO > 21)
#define	WITH_DEBUGGING_LOCATE		(WITH_DEBUGGING && WITH_DEBUG_INFO > 30)
#define	WITH_DEBUGGING_LOCATE_1		(WITH_DEBUGGING && WITH_DEBUG_INFO > 31)
#define	WITH_DEBUGGING_UTIL		(WITH_DEBUGGING && WITH_DEBUG_INFO > 40)
#define	WITH_DEBUGGING_UTIL_1		(WITH_DEBUGGING && WITH_DEBUG_INFO > 41)
#define	WITH_DEBUGGING_UTIL_2		(WITH_DEBUGGING && WITH_DEBUG_INFO > 42)
#define	WITH_DEBUGGING_UTIL_3		(WITH_DEBUGGING && WITH_DEBUG_INFO > 43)

/**
 **  Default error log facilities
 **/

#ifdef	WITH_LOG_FACILITY_VERBOSE
#   define	DEF_FACILITY_VERBOSE		WITH_LOG_FACILITY_VERBOSE
#else
#   define	DEF_FACILITY_VERBOSE		_stderr
#endif

#ifdef	WITH_LOG_FACILITY_INFO
#   define	DEF_FACILITY_INFO		WITH_LOG_FACILITY_INFO
#else
#   define	DEF_FACILITY_INFO		_stderr
#endif

#ifdef	WITH_LOG_FACILITY_DEBUG
#   define	DEF_FACILITY_DEBUG		WITH_LOG_FACILITY_DEBUG
#else
#   define	DEF_FACILITY_DEBUG		NULL
#endif

#ifdef	WITH_LOG_FACILITY_TRACE
#   define	DEF_FACILITY_TRACE		WITH_LOG_FACILITY_TRACE
#else
#   define	DEF_FACILITY_TRACE		NULL
#endif

#ifdef	WITH_LOG_FACILITY_WARN
#   define	DEF_FACILITY_WARN		WITH_LOG_FACILITY_WARN
#else
#   define	DEF_FACILITY_WARN		_stderr
#endif

#ifdef	WITH_LOG_FACILITY_PROB
#   define	DEF_FACILITY_PROB		WITH_LOG_FACILITY_PROB
#else
#   define	DEF_FACILITY_PROB		_stderr
#endif

#ifdef	WITH_LOG_FACILITY_ERROR
#   define	DEF_FACILITY_ERROR		WITH_LOG_FACILITY_ERROR
#else
#   define	DEF_FACILITY_ERROR		_stderr
#endif

#ifdef	WITH_LOG_FACILITY_FATAL
#   define	DEF_FACILITY_FATAL		WITH_LOG_FACILITY_FATAL
#else
#   define	DEF_FACILITY_FATAL		_stderr
#endif

#ifdef	WITH_LOG_FACILITY_PANIC
#   define	DEF_FACILITY_PANIC		WITH_LOG_FACILITY_PANIC
#else
#   define	DEF_FACILITY_PANIC		_stderr
#endif

/**
 **  g_flags values
 **/

#define      M_REMOVE	0x0001
#define      M_DISPLAY	0x0002
#define      M_SWSTATE1	0x0004
#define      M_SWSTATE2	0x0008
#define      M_SWSTATE3	0x0010
#define      M_SWITCH	( M_SWSTATE1 | M_SWSTATE2 | M_SWSTATE3)
#define      M_LOAD	0x0020
#define      M_CLEAR	0x0040
#define      M_PREPEND	0x0080
#define      M_HELP	0x0100
#define      M_WHATIS	0x0200
#define      M_NONPERSIST	0x0400
#define      M_SUBCMD	0x8000

/**
 **  markers for switching 
 **/

#define      SWMARKER        "--VARMARKER--"  /**  for variables and aliases  **/
#define      APP_SW_MARKER   "--APPMARKER--"  /**  for appending paths  **/
#define      PRE_SW_MARKER   "--PREMARKER--"  /**  for prepending paths  **/

/**
 **  return values 
 **/

#define TCL_LEVEL0_RETURN    11

/**
 **  uname defaults when uname can't be found 
 **/

#ifndef UNAME_SYSNAME
#  define UNAME_SYSNAME		"unknown"
#endif

#ifndef UNAME_NODENAME
#  define UNAME_NODENAME	"unknown"
#endif

#ifndef UNAME_RELEASE
#  define UNAME_RELEASE		"unknown"
#endif

#ifndef UNAME_VERSION
#  define UNAME_VERSION		"unknown"
#endif

#ifndef UNAME_MACHINE
#  define UNAME_MACHINE		"unknown"
#endif

#ifndef UNAME_DOMAIN
#  define UNAME_DOMAIN		"unknown"
#endif

/**
 **  RC files
 **/

#ifndef	RCFILE
#  define	RCFILE		"rc"
#endif

#ifndef	MODULERCFILE
#  define	MODULERCFILE	".modulerc"
#endif

#ifndef	VERSIONFILE
#  define	VERSIONFILE	".version"
#endif

#ifndef	APR_CACHE
#  define	APR_CACHE	"apropos.cache"
#endif

/**
 **  Buffer sizes
 **/

#define  LINELENGTH	8192
#define  MOD_BUFSIZE	1024

/** ************************************************************************ **/
/**				      MACROS				     **/
/** ************************************************************************ **/

/**
 **  I'm going to remove all of the calls to free( ) since they are not
 **    necessary for Modules.  Since the modulecmd program is only run for
 **    a very short time ( usually <1sec) it's faster to not clutter the heap
 **    by freeing up memory.
 **
 **  If you disagree with this decision, or have some problems with this
 **    behavior on your system, configure with --enable-free
 **
 **  Note that all memory deallocations should go through null_free()
 **/

#ifndef USE_FREE
#  define  free( x)  
#  define  FreeList( x, y)  
#endif

/** 
 **  Some systems don't define S_ISDIR and S_ISREG
 **/

#ifdef HAVE_SYS_STAT_H
#  ifndef S_ISDIR
#    define S_ISDIR( m) (((m) & S_IFMT) == S_IFDIR)
#  endif
#  ifndef S_ISREG
#    define S_ISREG( m) (((m) & S_IFMT) == S_IFREG)
#  endif
#endif

/**
 **  Error logger
 **/

#define	ErrorLogger	Module_Error
#define	LOC		module_name, __LINE__

/** ************************************************************************ **/
/** 				    GLOBAL DATA				     **/
/** ************************************************************************ **/

extern	char	**environ;

extern	char	 *version_string;
extern	char	 *date_string;
extern	char	 *g_current_module;
extern	char	 *g_specified_module;
extern	char	 *shell_name;
extern	char	 *shell_derelict;
extern	char	 *shell_init;
extern	char	 *shell_cmd_separator;
extern	int	  g_flags;
extern	int	  g_retval;
extern	int	  g_output;
extern	int	  append_flag;
extern	char	 *line;
extern	char	 *error_line;
extern	char	  local_line[];
extern	char	  _default[];
extern	char	  _colon[];

extern	int	  linenum;

extern	char	*addRE;
extern	char	*rmRE;
extern	char	*swRE;
extern	char	*dispRE;
extern	char	*listRE;
extern	char	*availRE;
extern	char	*helpRE;
extern	char	*initRE;
extern	char	*initxRE;
extern	char	*useRE;
extern	char	*unuseRE;
extern	char	*updateRE;
extern	char	*purgeRE;
extern	char	*clearRE;
extern	char	*whatisRE;
extern	char	*aproposRE;
extern	char	*refreshRE;

extern	Tcl_HashTable	*setenvHashTable;
extern	Tcl_HashTable	*unsetenvHashTable;
extern	Tcl_HashTable	*aliasSetHashTable;
extern	Tcl_HashTable	*aliasUnsetHashTable;
extern	Tcl_HashTable	*markVariableHashTable;
extern	Tcl_HashTable	*markAliasHashTable;

extern	char    _fil_stdin[];
extern	char    _fil_stdout[];
extern	char    _fil_stderr[];
extern	char    _fil_devnull[];

extern	int	sw_detach;
extern	int	sw_force;
extern	int	sw_format;
#define	SW_SET		0x01
#define	SW_HUMAN	0x02
#define	SW_PARSE	0x04
#define	SW_TERSE	0x08
#define	SW_LONG		0x10
#define	SW_LIST		0x20
extern	int	sw_create;
extern	int	sw_verbose;
extern	int	sw_userlvl;
extern	int	sw_icase;

extern	char	*instpath;
extern	char	*rc_file;
extern	char	*modulerc_file;
extern	char	*version_file;
extern	char	*change_dir;

extern	char	 long_header[];

/** ************************************************************************ **/
/**				    PROTOTYPES				     **/
/** ************************************************************************ **/

/**  locate_module.c  **/
extern	int	  Locate_ModuleFile( Tcl_Interp*, char*, char*, char*);
extern	char	**SortedDirList( Tcl_Interp*, char*, char*, int*);
extern	char	**SplitIntoList( Tcl_Interp*, char*, int*, const char*);
extern	int	  SourceVers( Tcl_Interp*, char*, char*);
extern	int	  SourceRC( Tcl_Interp *interp, char *, char *);
#ifdef USE_FREE
extern	void	  FreeList( char**, int);
#endif

/**  main.c  **/
extern  void	  module_usage(FILE *output);

/**  ModuleCmd_Avail.c  **/
extern	int	  ModuleCmd_Avail( Tcl_Interp*, int, char*[]);
extern	void	  print_dirents( char*);
extern	char	 *strip_top( char*);
extern	void	  print_aligned_files(Tcl_Interp*,char*,char*,char**,int,int);
extern	int	  check_dir( char*);
extern	fi_ent	 *get_dir( char*, char*, int*, int*);
extern	void	  dirlst_to_list( char**, fi_ent*, int, int*, char*, char*);
extern	void	  delete_dirlst( fi_ent*, int);
extern	void	  delete_cache_list( char**, int);

/**  ModuleCmd_Clear.c  **/
extern	int	  ModuleCmd_Clear( Tcl_Interp*, int, char*[]);

/**  ModuleCmd_Display.c  **/
extern	int	  ModuleCmd_Display( Tcl_Interp*, int, char*[]);

/**  ModuleCmd_Help.c  **/
extern	int	  ModuleCmd_Help( Tcl_Interp*, int, char*[]);

/**  ModuleCmd_Init.c  **/
extern	int	  ModuleCmd_Init( Tcl_Interp*, int, char*[]);

/**  ModuleCmd_List.c  **/
extern	int	  ModuleCmd_List( Tcl_Interp*, int, char*[]);

/**  ModuleCmd_Load.c  **/
extern	int	  ModuleCmd_Load( Tcl_Interp*, int, int, char*[]);

/**  ModuleCmd_Purge.c  **/
extern	int	  ModuleCmd_Purge( Tcl_Interp*, int, char*[]);

/**  ModuleCmd_Switch.c  **/
extern	int	  ModuleCmd_Switch( Tcl_Interp*, int, char*[]);

/**  ModuleCmd_Update.c  **/
extern	int	  ModuleCmd_Update( Tcl_Interp*, int, char*[]);

/**  ModuleCmd_Whatis.c  **/
extern	int	  ModuleCmd_Whatis( Tcl_Interp*, int, char*[]);
extern	int	  ModuleCmd_Apropos( Tcl_Interp*, int, char*[]);

/**  ModuleCmd_Use.c  **/
extern	int	  ModuleCmd_Use( Tcl_Interp*, int, char*[]);
extern	int	  ModuleCmd_UnUse( Tcl_Interp*, int, char*[]);

/**  cmdAlias.c  **/
extern	int	  cmdSetAlias( ClientData, Tcl_Interp*, int, CONST84 char*[]);

/**  cmdConflict.c  **/
extern	int	  cmdConflict( ClientData, Tcl_Interp*, int, CONST84 char*[]);
extern	int	  cmdPrereq( ClientData, Tcl_Interp*, int, CONST84 char*[]);

/**  cmdIsLoaded.c  **/
extern	int	  cmdIsLoaded(ClientData, Tcl_Interp*, int, CONST84 char*[]);

/**  cmdVerbose.c  **/
extern	int	  cmdModuleVerbose(ClientData,Tcl_Interp*,int,CONST84 char*[]);

/**  cmdWhatis.c  **/
extern	char	**whatis;
extern	void	  cmdModuleWhatisInit(void);
extern	void	  cmdModuleWhatisShut(void);
extern	int	  cmdModuleWhatis(ClientData,Tcl_Interp*,int,CONST84 char*[]);

/**  cmdInfo.c  **/
extern	int	  cmdModuleInfo(ClientData, Tcl_Interp*, int, CONST84 char*[]);
extern	char	 *module_command;

/**  cmdMisc.c  **/
extern	int	  cmdSystem( ClientData, Tcl_Interp*, int, CONST84 char*[]);

/**  cmdModule.c  **/
extern	int	  cmdModule( ClientData, Tcl_Interp*, int, CONST84 char*[]);
extern	int	  Read_Modulefile( Tcl_Interp*, char*);
extern	int	  Execute_TclFile( Tcl_Interp*, char*);
extern	int	  CallModuleProcedure( Tcl_Interp*, Tcl_DString*, char*, char*,
			int);

/**  cmdPath.c  **/
extern	int	  cmdSetPath( ClientData, Tcl_Interp*, int, CONST84 char*[]);
extern	int	  cmdRemovePath( ClientData, Tcl_Interp*, int, CONST84 char*[]);
extern	char	 *chk_nullvars( char*);

/**  cmdSetenv.c  **/
extern	int	  cmdSetEnv( ClientData, Tcl_Interp*, int, CONST84 char*[]);
extern	int	  moduleSetenv( Tcl_Interp*, char	 *, char*, int);
extern	int	  cmdUnsetEnv( ClientData, Tcl_Interp*, int, CONST84 char*[]);
extern	int	  moduleUnsetenv( Tcl_Interp*, char	 *);

/**  cmdUname.c  **/
extern	int	  cmdUname( ClientData, Tcl_Interp*, int, CONST84 char*[]);

/**  cmdXResource.c  **/
extern	int	  cmdXResource( ClientData, Tcl_Interp*, int, CONST84 char*[]);
extern	void	  xresourceFinish( int);

/**  cmdUlvl.c  **/
extern	int	  cmdModuleUser(ClientData, Tcl_Interp*, int, CONST84 char*[]);
extern	int	  cmdModuleUser_sub( char *user_level);

/**  cmdChdir.c **/
extern	int	  cmdChDir(ClientData, Tcl_Interp*, int, CONST84 char*[]);

/**  cmdLog.c  **/
extern	int	  cmdModuleLog( ClientData, Tcl_Interp*, int, CONST84 char*[]);

/**  cmdTrace.c  **/
extern	int	  cmdModuleTrace(ClientData,Tcl_Interp*, int, CONST84 char*[]);
extern	char	 *GetTraceSel(Tcl_Interp*, char*);
extern	int	  CheckTracing(Tcl_Interp*, char*, char*);
extern	int	  CheckTracingList(Tcl_Interp*, char*, int, char**);

/**  cmdVersion.c  **/
extern	int	  cmdModuleVersion(ClientData,Tcl_Interp*,int,CONST84 char*[]);
extern	int	  cmdModuleAlias(ClientData,Tcl_Interp*, int, CONST84 char*[]);
extern	int	  AliasLookup( char*, char**, char**);
extern	int	  VersionLookup( char*, char**, char**);
extern	char	 *ExpandVersions( char*);

/**  init.c  **/
extern	Tcl_Interp	 *EM_CreateInterp(void);
extern	void	  EM_DeleteInterp(Tcl_Interp*);
extern	int	  Initialize_Tcl( Tcl_Interp**, int, char*[], char*[]);
extern	int	  InitializeModuleCommands( Tcl_Interp*);
extern	int	  Setup_Environment( Tcl_Interp*);
extern	char	**SetStartupFiles( char *shell_name);
extern	int	  TieStdout( void);
extern	int	  UnTieStdout( int);

/**  utility.c  **/
extern	char	 *getLMFILES( Tcl_Interp *interp);
extern	int	  store_hash_value( Tcl_HashTable*, const char*, const char*);
extern	int	  clear_hash_value( Tcl_HashTable*, const char*);
extern	int	  store_old_shell_variable( Tcl_HashTable*, const char*,
			const char*);
extern	int	  clear_old_shell_variable( Tcl_HashTable*, const char*);
extern	void	  Delete_Global_Hash_Tables( void);
extern	void	  Delete_Hash_Tables( Tcl_HashTable**);
extern	Tcl_HashTable** Copy_Hash_Tables( void);
extern	int	  Unwind_Modulefile_Changes( Tcl_Interp*, Tcl_HashTable**);
extern	int	  Output_Modulefile_Changes( Tcl_Interp*);
extern	int	  store_env( void);
extern	int	  free_stored_env( void);
extern	void	  set_marked_entry( Tcl_HashTable*, char*, intptr_t);
extern	intptr_t  chk_marked_entry( Tcl_HashTable*, char*);
extern	Tcl_HashTable*  environ_changes;
extern	Tcl_HashTable*  alias_changes;
extern	int	  IsLoaded( Tcl_Interp*, char*, char**, char*);
extern	int	  IsLoaded_ExactMatch( Tcl_Interp*, char*, char	**, char*);
extern	int	  Update_LoadedList( Tcl_Interp*, char*, char*);
extern	int	  check_magic( char*, char*, int);
extern	char	 *xstrtok_r(char *, const char *, char **);
extern	char	 *xstrtok(char *, const char *);
extern	void	  chk4spch( char*);
extern	void	  cleanse_path( const char*, char*, int);
extern	void	 *module_malloc(size_t);
extern	void	 *module_realloc(void *,size_t);
extern	char	 *xdup(char const *);
extern	char	 *xgetenv(char const *);
extern  int       tmpfile_mod( char**, FILE**);
extern	char	 *stringer(char *, int, ...);
extern	void	  null_free(void **);
extern	size_t	  countTclHash(Tcl_HashTable *);
extern	EM_RetVal	ReturnValue( Tcl_Interp*, int);
extern	void	  OutputExit();
extern	char 	 *EMGetEnv(Tcl_Interp *, char const *);
extern	char 	 *EMSetEnv(Tcl_Interp *, char const *, char const *);
extern	int	  is_interactive(void);

#ifndef HAVE_STRDUP
#  undef strdup
extern	char	 *strdup( char*);
#endif

#ifndef HAVE_STRTOK
extern	char	 *strtok( char *, const char *);
#endif

/** error.c **/
extern	char	**GetFacilityPtr( char *);
extern	int 	  Module_Error(	ErrType, char*, int, ...);
extern	int	  CheckFacility( char*, int*, int*);
extern	void	  Module_Tracing( int, int, char**);
extern	void	  Module_Verbosity( int, char**);

#endif  /**  _MODULES_DEF_H  **/