0000: 2f 2a 20 0a 20 2a 20 74 63 6c 41 70 70 49 6e 69 /* . * tclAppIni
0010: 74 2e 63 20 2d 2d 0a 20 2a 0a 20 2a 20 20 50 72 t.c --. *. * Pr
0020: 6f 76 69 64 65 73 20 61 20 64 65 66 61 75 6c 74 ovides a default
0030: 20 76 65 72 73 69 6f 6e 20 6f 66 20 74 68 65 20 version of the
0040: 6d 61 69 6e 20 70 72 6f 67 72 61 6d 20 61 6e 64 main program and
0050: 20 54 63 6c 5f 41 70 70 49 6e 69 74 0a 20 2a 20 Tcl_AppInit. *
0060: 20 70 72 6f 63 65 64 75 72 65 20 66 6f 72 20 54 procedure for T
0070: 63 6c 20 61 70 70 6c 69 63 61 74 69 6f 6e 73 20 cl applications
0080: 28 77 69 74 68 6f 75 74 20 54 6b 29 2e 20 20 4e (without Tk). N
0090: 6f 74 65 20 74 68 61 74 20 74 68 69 73 0a 20 2a ote that this. *
00a0: 20 20 70 72 6f 67 72 61 6d 20 6d 75 73 74 20 62 program must b
00b0: 65 20 62 75 69 6c 74 20 69 6e 20 57 69 6e 33 32 e built in Win32
00c0: 20 63 6f 6e 73 6f 6c 65 20 6d 6f 64 65 20 74 6f console mode to
00d0: 20 77 6f 72 6b 20 70 72 6f 70 65 72 6c 79 2e 0a work properly..
00e0: 20 2a 0a 20 2a 20 43 6f 70 79 72 69 67 68 74 20 *. * Copyright
00f0: 28 63 29 20 31 39 39 36 2d 31 39 39 37 20 62 79 (c) 1996-1997 by
0100: 20 53 75 6e 20 4d 69 63 72 6f 73 79 73 74 65 6d Sun Microsystem
0110: 73 2c 20 49 6e 63 2e 0a 20 2a 20 43 6f 70 79 72 s, Inc.. * Copyr
0120: 69 67 68 74 20 28 63 29 20 31 39 39 38 2d 31 39 ight (c) 1998-19
0130: 39 39 20 62 79 20 53 63 72 69 70 74 69 63 73 20 99 by Scriptics
0140: 43 6f 72 70 6f 72 61 74 69 6f 6e 2e 0a 20 2a 20 Corporation.. *
0150: 43 6f 70 79 72 69 67 68 74 20 28 63 29 20 32 30 Copyright (c) 20
0160: 30 30 2d 32 30 30 32 20 4a 65 61 6e 2d 43 6c 61 00-2002 Jean-Cla
0170: 75 64 65 20 57 69 70 70 6c 65 72 20 3c 6a 63 77 ude Wippler <jcw
0180: 40 65 71 75 69 34 2e 63 6f 6d 3e 0a 20 2a 0a 20 @equi4.com>. *.
0190: 2a 20 53 65 65 20 74 68 65 20 66 69 6c 65 20 22 * See the file "
01a0: 6c 69 63 65 6e 73 65 2e 74 65 72 6d 73 22 20 66 license.terms" f
01b0: 6f 72 20 69 6e 66 6f 72 6d 61 74 69 6f 6e 20 6f or information o
01c0: 6e 20 75 73 61 67 65 20 61 6e 64 20 72 65 64 69 n usage and redi
01d0: 73 74 72 69 62 75 74 69 6f 6e 0a 20 2a 20 6f 66 stribution. * of
01e0: 20 74 68 69 73 20 66 69 6c 65 2c 20 61 6e 64 20 this file, and
01f0: 66 6f 72 20 61 20 44 49 53 43 4c 41 49 4d 45 52 for a DISCLAIMER
0200: 20 4f 46 20 41 4c 4c 20 57 41 52 52 41 4e 54 49 OF ALL WARRANTI
0210: 45 53 2e 0a 20 2a 0a 20 2a 20 52 43 53 3a 20 40 ES.. *. * RCS: @
0220: 28 23 29 20 24 49 64 24 0a 20 2a 2f 0a 0a 23 69 (#) $Id$. */..#i
0230: 66 64 65 66 20 4b 49 54 5f 49 4e 43 4c 55 44 45 fdef KIT_INCLUDE
0240: 53 5f 54 4b 0a 23 20 20 69 6e 63 6c 75 64 65 20 S_TK.# include
0250: 3c 74 6b 2e 68 3e 0a 23 65 6e 64 69 66 20 2f 2a <tk.h>.#endif /*
0260: 20 4b 49 54 5f 49 4e 43 4c 55 44 45 53 5f 54 4b KIT_INCLUDES_TK
0270: 20 2a 2f 0a 23 69 6e 63 6c 75 64 65 20 3c 74 63 */.#include <tc
0280: 6c 2e 68 3e 0a 0a 23 69 66 64 65 66 20 5f 57 49 l.h>..#ifdef _WI
0290: 4e 33 32 0a 23 20 20 64 65 66 69 6e 65 20 57 49 N32.# define WI
02a0: 4e 33 32 5f 4c 45 41 4e 5f 41 4e 44 5f 4d 45 41 N32_LEAN_AND_MEA
02b0: 4e 0a 23 20 20 69 6e 63 6c 75 64 65 20 3c 77 69 N.# include <wi
02c0: 6e 64 6f 77 73 2e 68 3e 0a 23 20 20 75 6e 64 65 ndows.h>.# unde
02d0: 66 20 57 49 4e 33 32 5f 4c 45 41 4e 5f 41 4e 44 f WIN32_LEAN_AND
02e0: 5f 4d 45 41 4e 0a 23 65 6e 64 69 66 20 2f 2a 20 _MEAN.#endif /*
02f0: 5f 57 49 4e 33 32 20 2a 2f 0a 0a 23 69 66 6e 64 _WIN32 */..#ifnd
0300: 65 66 20 4d 42 5f 54 41 53 4b 4d 4f 44 41 4c 0a ef MB_TASKMODAL.
0310: 23 20 20 64 65 66 69 6e 65 20 4d 42 5f 54 41 53 # define MB_TAS
0320: 4b 4d 4f 44 41 4c 20 30 0a 23 65 6e 64 69 66 20 KMODAL 0.#endif
0330: 2f 2a 20 4d 42 5f 54 41 53 4b 4d 4f 44 41 4c 20 /* MB_TASKMODAL
0340: 2a 2f 0a 0a 23 69 6e 63 6c 75 64 65 20 22 74 63 */..#include "tc
0350: 6c 49 6e 74 2e 68 22 0a 0a 23 69 66 64 65 66 20 lInt.h"..#ifdef
0360: 48 41 56 45 5f 55 4e 49 53 54 44 5f 48 0a 23 20 HAVE_UNISTD_H.#
0370: 20 69 6e 63 6c 75 64 65 20 3c 75 6e 69 73 74 64 include <unistd
0380: 2e 68 3e 0a 23 65 6e 64 69 66 0a 23 69 66 64 65 .h>.#endif.#ifde
0390: 66 20 48 41 56 45 5f 53 54 52 49 4e 47 5f 48 0a f HAVE_STRING_H.
03a0: 23 20 20 69 6e 63 6c 75 64 65 20 3c 73 74 72 69 # include <stri
03b0: 6e 67 2e 68 3e 0a 23 65 6e 64 69 66 0a 23 69 66 ng.h>.#endif.#if
03c0: 64 65 66 20 48 41 56 45 5f 53 54 52 49 4e 47 53 def HAVE_STRINGS
03d0: 5f 48 0a 23 20 20 69 6e 63 6c 75 64 65 20 3c 73 _H.# include <s
03e0: 74 72 69 6e 67 73 2e 68 3e 0a 23 65 6e 64 69 66 trings.h>.#endif
03f0: 0a 0a 2f 2a 20 46 6f 72 20 64 6c 61 64 64 72 28 ../* For dladdr(
0400: 29 20 61 6e 64 20 44 6c 5f 69 6e 66 6f 20 2a 2f ) and Dl_info */
0410: 0a 23 69 66 64 65 66 20 48 41 56 45 5f 44 4c 46 .#ifdef HAVE_DLF
0420: 43 4e 5f 48 0a 23 20 20 69 6e 63 6c 75 64 65 20 CN_H.# include
0430: 3c 64 6c 66 63 6e 2e 68 3e 0a 23 65 6e 64 69 66 <dlfcn.h>.#endif
0440: 0a 0a 23 69 66 20 64 65 66 69 6e 65 64 28 48 41 ..#if defined(HA
0450: 56 45 5f 54 43 4c 5f 47 45 54 45 4e 43 4f 44 49 VE_TCL_GETENCODI
0460: 4e 47 4e 41 4d 45 46 52 4f 4d 45 4e 56 49 52 4f NGNAMEFROMENVIRO
0470: 4e 4d 45 4e 54 29 20 26 26 20 64 65 66 69 6e 65 NMENT) && define
0480: 64 28 48 41 56 45 5f 54 43 4c 5f 53 45 54 53 59 d(HAVE_TCL_SETSY
0490: 53 54 45 4d 45 4e 43 4f 44 49 4e 47 29 0a 23 20 STEMENCODING).#
04a0: 20 64 65 66 69 6e 65 20 54 43 4c 4b 49 54 5f 43 define TCLKIT_C
04b0: 41 4e 5f 53 45 54 5f 45 4e 43 4f 44 49 4e 47 20 AN_SET_ENCODING
04c0: 31 0a 23 65 6e 64 69 66 0a 23 69 66 20 31 30 20 1.#endif.#if 10
04d0: 2a 20 54 43 4c 5f 4d 41 4a 4f 52 5f 56 45 52 53 * TCL_MAJOR_VERS
04e0: 49 4f 4e 20 2b 20 54 43 4c 5f 4d 49 4e 4f 52 5f ION + TCL_MINOR_
04f0: 56 45 52 53 49 4f 4e 20 3c 20 38 35 0a 23 20 20 VERSION < 85.#
0500: 64 65 66 69 6e 65 20 54 43 4c 4b 49 54 5f 52 45 define TCLKIT_RE
0510: 51 55 49 52 45 5f 54 43 4c 45 58 45 43 55 54 41 QUIRE_TCLEXECUTA
0520: 42 4c 45 4e 41 4d 45 20 31 0a 23 65 6e 64 69 66 BLENAME 1.#endif
0530: 0a 0a 23 69 66 20 31 30 20 2a 20 54 43 4c 5f 4d ..#if 10 * TCL_M
0540: 41 4a 4f 52 5f 56 45 52 53 49 4f 4e 20 2b 20 54 AJOR_VERSION + T
0550: 43 4c 5f 4d 49 4e 4f 52 5f 56 45 52 53 49 4f 4e CL_MINOR_VERSION
0560: 20 3c 20 38 35 0a 23 20 20 64 65 66 69 6e 65 20 < 85.# define
0570: 4b 49 54 5f 49 4e 43 4c 55 44 45 53 5f 50 57 42 KIT_INCLUDES_PWB
0580: 20 31 0a 23 65 6e 64 69 66 0a 23 69 66 20 31 30 1.#endif.#if 10
0590: 20 2a 20 54 43 4c 5f 4d 41 4a 4f 52 5f 56 45 52 * TCL_MAJOR_VER
05a0: 53 49 4f 4e 20 2b 20 54 43 4c 5f 4d 49 4e 4f 52 SION + TCL_MINOR
05b0: 5f 56 45 52 53 49 4f 4e 20 3c 20 38 36 0a 23 20 _VERSION < 86.#
05c0: 20 64 65 66 69 6e 65 20 4b 49 54 5f 49 4e 43 4c define KIT_INCL
05d0: 55 44 45 53 5f 5a 4c 49 42 20 31 0a 23 65 6e 64 UDES_ZLIB 1.#end
05e0: 69 66 0a 0a 23 69 6e 63 6c 75 64 65 20 22 6b 69 if..#include "ki
05f0: 74 49 6e 69 74 2d 6c 69 62 73 2e 68 22 0a 0a 23 tInit-libs.h"..#
0600: 69 66 64 65 66 20 4b 49 54 5f 49 4e 43 4c 55 44 ifdef KIT_INCLUD
0610: 45 53 5f 4d 4b 34 54 43 4c 0a 54 63 6c 5f 41 70 ES_MK4TCL.Tcl_Ap
0620: 70 49 6e 69 74 50 72 6f 63 09 4d 6b 34 74 63 6c pInitProc.Mk4tcl
0630: 5f 49 6e 69 74 3b 0a 23 65 6e 64 69 66 0a 54 63 _Init;.#endif.Tc
0640: 6c 5f 41 70 70 49 6e 69 74 50 72 6f 63 20 56 66 l_AppInitProc Vf
0650: 73 5f 49 6e 69 74 2c 20 52 65 63 68 61 6e 5f 49 s_Init, Rechan_I
0660: 6e 69 74 3b 0a 23 69 66 64 65 66 20 4b 49 54 5f nit;.#ifdef KIT_
0670: 49 4e 43 4c 55 44 45 53 5f 50 57 42 0a 54 63 6c INCLUDES_PWB.Tcl
0680: 5f 41 70 70 49 6e 69 74 50 72 6f 63 09 50 77 62 _AppInitProc.Pwb
0690: 5f 49 6e 69 74 3b 0a 23 65 6e 64 69 66 0a 23 69 _Init;.#endif.#i
06a0: 66 64 65 66 20 4b 49 54 5f 49 4e 43 4c 55 44 45 fdef KIT_INCLUDE
06b0: 53 5f 5a 4c 49 42 0a 54 63 6c 5f 41 70 70 49 6e S_ZLIB.Tcl_AppIn
06c0: 69 74 50 72 6f 63 20 5a 6c 69 62 5f 49 6e 69 74 itProc Zlib_Init
06d0: 3b 0a 23 65 6e 64 69 66 0a 23 69 66 64 65 66 20 ;.#endif.#ifdef
06e0: 4b 49 54 5f 53 54 4f 52 41 47 45 5f 43 56 46 53 KIT_STORAGE_CVFS
06f0: 0a 54 63 6c 5f 41 70 70 49 6e 69 74 50 72 6f 63 .Tcl_AppInitProc
0700: 20 43 76 66 73 5f 64 61 74 61 5f 74 63 6c 5f 49 Cvfs_data_tcl_I
0710: 6e 69 74 3b 0a 23 65 6e 64 69 66 0a 23 69 66 64 nit;.#endif.#ifd
0720: 65 66 20 54 43 4c 5f 54 48 52 45 41 44 53 0a 54 ef TCL_THREADS.T
0730: 63 6c 5f 41 70 70 49 6e 69 74 50 72 6f 63 09 54 cl_AppInitProc.T
0740: 68 72 65 61 64 5f 49 6e 69 74 3b 0a 23 65 6e 64 hread_Init;.#end
0750: 69 66 0a 23 69 66 64 65 66 20 5f 57 49 4e 33 32 if.#ifdef _WIN32
0760: 0a 54 63 6c 5f 41 70 70 49 6e 69 74 50 72 6f 63 .Tcl_AppInitProc
0770: 09 44 64 65 5f 49 6e 69 74 2c 20 52 65 67 69 73 .Dde_Init, Regis
0780: 74 72 79 5f 49 6e 69 74 3b 0a 23 65 6e 64 69 66 try_Init;.#endif
0790: 0a 0a 23 69 66 64 65 66 20 54 43 4c 4b 49 54 5f ..#ifdef TCLKIT_
07a0: 44 4c 4c 0a 23 20 20 64 65 66 69 6e 65 20 54 43 DLL.# define TC
07b0: 4c 4b 49 54 5f 4d 4f 55 4e 54 50 4f 49 4e 54 20 LKIT_MOUNTPOINT
07c0: 22 2f 2e 4b 49 54 44 4c 4c 5f 54 43 4c 22 0a 23 "/.KITDLL_TCL".#
07d0: 20 20 64 65 66 69 6e 65 20 54 43 4c 4b 49 54 5f define TCLKIT_
07e0: 56 46 53 53 4f 55 52 43 45 20 22 24 3a 3a 74 63 VFSSOURCE "$::tc
07f0: 6c 4b 69 74 46 69 6c 65 6e 61 6d 65 22 0a 23 65 lKitFilename".#e
0800: 6c 73 65 0a 23 20 20 69 66 20 30 0a 23 20 20 20 lse.# if 0.#
0810: 20 64 65 66 69 6e 65 20 54 43 4c 4b 49 54 5f 4d define TCLKIT_M
0820: 4f 55 4e 54 50 4f 49 4e 54 20 22 5b 69 6e 66 6f OUNTPOINT "[info
0830: 20 6e 61 6d 65 6f 66 65 78 65 63 75 74 61 62 6c nameofexecutabl
0840: 65 5d 22 0a 23 20 20 20 20 64 65 66 69 6e 65 20 e]".# define
0850: 54 43 4c 4b 49 54 5f 56 46 53 53 4f 55 52 43 45 TCLKIT_VFSSOURCE
0860: 20 22 5b 69 6e 66 6f 20 6e 61 6d 65 6f 66 65 78 "[info nameofex
0870: 65 63 75 74 61 62 6c 65 5d 22 0a 23 20 20 65 6c ecutable]".# el
0880: 73 65 0a 23 20 20 20 20 64 65 66 69 6e 65 20 54 se.# define T
0890: 43 4c 4b 49 54 5f 4d 4f 55 4e 54 50 4f 49 4e 54 CLKIT_MOUNTPOINT
08a0: 20 22 2f 2e 54 43 4c 4b 49 54 22 0a 23 20 20 20 "/.TCLKIT".#
08b0: 20 64 65 66 69 6e 65 20 54 43 4c 4b 49 54 5f 56 define TCLKIT_V
08c0: 46 53 53 4f 55 52 43 45 20 22 5b 69 6e 66 6f 20 FSSOURCE "[info
08d0: 6e 61 6d 65 6f 66 65 78 65 63 75 74 61 62 6c 65 nameofexecutable
08e0: 5d 22 0a 23 20 20 65 6e 64 69 66 0a 23 65 6e 64 ]".# endif.#end
08f0: 69 66 20 2f 2a 20 54 43 4c 4b 49 54 5f 44 4c 4c if /* TCLKIT_DLL
0900: 20 2a 2f 0a 0a 23 69 66 6e 64 65 66 20 54 43 4c */..#ifndef TCL
0910: 4b 49 54 5f 44 4c 4c 0a 23 20 20 69 66 64 65 66 KIT_DLL.# ifdef
0920: 20 48 41 56 45 5f 41 43 43 45 50 54 41 42 4c 45 HAVE_ACCEPTABLE
0930: 5f 44 4c 41 44 44 52 0a 23 20 20 20 20 69 66 64 _DLADDR.# ifd
0940: 65 66 20 4b 49 54 53 48 5f 4e 45 45 44 5f 57 49 ef KITSH_NEED_WI
0950: 4e 4d 41 49 4e 0a 23 20 20 20 20 20 20 69 66 64 NMAIN.# ifd
0960: 65 66 20 5f 57 49 4e 33 32 5f 57 43 45 0a 69 6e ef _WIN32_WCE.in
0970: 74 20 77 57 69 6e 4d 61 69 6e 28 48 49 4e 53 54 t wWinMain(HINST
0980: 41 4e 43 45 20 68 49 6e 73 74 61 6e 63 65 2c 20 ANCE hInstance,
0990: 48 49 4e 53 54 41 4e 43 45 20 68 50 72 65 76 49 HINSTANCE hPrevI
09a0: 6e 73 74 61 6e 63 65 2c 20 4c 50 53 54 52 20 6c nstance, LPSTR l
09b0: 70 73 7a 43 6d 64 4c 69 6e 65 2c 20 69 6e 74 20 pszCmdLine, int
09c0: 6e 43 6d 64 53 68 6f 77 29 3b 0a 23 20 20 20 20 nCmdShow);.#
09d0: 20 20 65 6c 73 65 0a 69 6e 74 20 57 69 6e 4d 61 else.int WinMa
09e0: 69 6e 28 48 49 4e 53 54 41 4e 43 45 20 68 49 6e in(HINSTANCE hIn
09f0: 73 74 61 6e 63 65 2c 20 48 49 4e 53 54 41 4e 43 stance, HINSTANC
0a00: 45 20 68 50 72 65 76 49 6e 73 74 61 6e 63 65 2c E hPrevInstance,
0a10: 20 4c 50 53 54 52 20 6c 70 73 7a 43 6d 64 4c 69 LPSTR lpszCmdLi
0a20: 6e 65 2c 20 69 6e 74 20 6e 43 6d 64 53 68 6f 77 ne, int nCmdShow
0a30: 29 3b 0a 23 20 20 20 20 20 20 65 6e 64 69 66 20 );.# endif
0a40: 2f 2a 20 5f 57 49 4e 33 32 5f 57 43 45 20 2a 2f /* _WIN32_WCE */
0a50: 0a 23 20 20 20 20 65 6e 64 69 66 20 2f 2a 20 4b .# endif /* K
0a60: 49 54 53 48 5f 4e 45 45 44 5f 57 49 4e 4d 41 49 ITSH_NEED_WINMAI
0a70: 4e 20 2a 2f 0a 69 6e 74 20 6d 61 69 6e 28 69 6e N */.int main(in
0a80: 74 20 61 72 67 63 2c 20 63 68 61 72 20 2a 2a 61 t argc, char **a
0a90: 72 67 76 29 3b 0a 23 20 20 65 6e 64 69 66 20 2f rgv);.# endif /
0aa0: 2a 20 48 41 56 45 5f 41 43 43 45 50 54 41 42 4c * HAVE_ACCEPTABL
0ab0: 45 5f 44 4c 41 44 44 52 20 2a 2f 0a 23 65 6e 64 E_DLADDR */.#end
0ac0: 69 66 20 2f 2a 20 21 54 43 4c 4b 49 54 5f 44 4c if /* !TCLKIT_DL
0ad0: 4c 20 2a 2f 0a 0a 23 69 66 64 65 66 20 54 43 4c L */..#ifdef TCL
0ae0: 4b 49 54 5f 44 4c 4c 0a 76 6f 69 64 20 5f 5f 61 KIT_DLL.void __a
0af0: 74 74 72 69 62 75 74 65 5f 5f 28 28 63 6f 6e 73 ttribute__((cons
0b00: 74 72 75 63 74 6f 72 29 29 20 5f 54 63 6c 6b 69 tructor)) _Tclki
0b10: 74 5f 49 6e 69 74 28 76 6f 69 64 29 3b 0a 23 65 t_Init(void);.#e
0b20: 6c 73 65 0a 73 74 61 74 69 63 20 76 6f 69 64 20 lse.static void
0b30: 5f 54 63 6c 6b 69 74 5f 49 6e 69 74 28 76 6f 69 _Tclkit_Init(voi
0b40: 64 29 3b 0a 23 65 6e 64 69 66 0a 0a 23 69 66 64 d);.#endif..#ifd
0b50: 65 66 20 54 43 4c 4b 49 54 5f 52 45 51 55 49 52 ef TCLKIT_REQUIR
0b60: 45 5f 54 43 4c 45 58 45 43 55 54 41 42 4c 45 4e E_TCLEXECUTABLEN
0b70: 41 4d 45 0a 63 68 61 72 20 2a 74 63 6c 45 78 65 AME.char *tclExe
0b80: 63 75 74 61 62 6c 65 4e 61 6d 65 3b 0a 23 65 6e cutableName;.#en
0b90: 64 69 66 0a 0a 2f 2a 0a 20 2a 20 20 41 74 74 65 dif../*. * Atte
0ba0: 6d 70 74 20 74 6f 20 6c 6f 61 64 20 61 20 22 62 mpt to load a "b
0bb0: 6f 6f 74 2e 74 63 6c 22 20 65 6e 74 72 79 20 66 oot.tcl" entry f
0bc0: 72 6f 6d 20 74 68 65 20 65 6d 62 65 64 64 65 64 rom the embedded
0bd0: 20 4d 65 74 61 4b 69 74 20 66 69 6c 65 2e 0a 20 MetaKit file..
0be0: 2a 2f 0a 2f 2a 0a 20 2a 20 54 68 69 73 20 54 63 */./*. * This Tc
0bf0: 6c 20 63 6f 64 65 20 69 73 20 69 6e 76 6f 6b 65 l code is invoke
0c00: 64 20 77 68 65 6e 65 76 65 72 20 54 63 6c 5f 49 d whenever Tcl_I
0c10: 6e 69 74 28 29 20 69 73 20 63 61 6c 6c 65 64 20 nit() is called
0c20: 6f 6e 20 61 6e 0a 20 2a 20 69 6e 74 65 72 70 72 on an. * interpr
0c30: 65 74 65 72 2e 20 20 49 74 20 73 68 6f 75 6c 64 eter. It should
0c40: 20 6d 6f 75 6e 74 20 75 70 20 74 68 65 20 56 46 mount up the VF
0c50: 53 20 61 6e 64 20 6d 61 6b 65 20 65 76 65 72 79 S and make every
0c60: 74 68 69 6e 67 20 72 65 61 64 79 20 66 6f 72 0a thing ready for.
0c70: 20 2a 20 74 68 61 74 20 69 6e 74 65 72 70 72 65 * that interpre
0c80: 74 65 72 20 74 6f 20 64 6f 20 69 74 73 20 6a 6f ter to do its jo
0c90: 62 2e 0a 20 2a 2f 0a 73 74 61 74 69 63 20 63 68 b.. */.static ch
0ca0: 61 72 20 2a 70 72 65 49 6e 69 74 43 6d 64 20 3d ar *preInitCmd =
0cb0: 20 0a 23 69 66 20 64 65 66 69 6e 65 64 28 5f 57 .#if defined(_W
0cc0: 49 4e 33 32 5f 57 43 45 29 20 26 26 20 21 64 65 IN32_WCE) && !de
0cd0: 66 69 6e 65 64 28 54 43 4c 4b 49 54 5f 44 4c 4c fined(TCLKIT_DLL
0ce0: 29 0a 2f 2a 20 73 69 6c 6c 79 20 68 61 63 6b 20 )./* silly hack
0cf0: 74 6f 20 67 65 74 20 77 69 6e 63 65 20 70 6f 72 to get wince por
0d00: 74 20 74 6f 20 6c 61 75 6e 63 68 2c 20 73 6f 6d t to launch, som
0d10: 65 20 73 6f 72 74 20 6f 66 20 73 74 64 7b 69 6e e sort of std{in
0d20: 2c 6f 75 74 2c 65 72 72 7d 20 70 72 6f 62 6c 65 ,out,err} proble
0d30: 6d 20 2a 2f 0a 22 6f 70 65 6e 20 2f 6b 69 74 6f m */."open /kito
0d40: 75 74 2e 74 78 74 20 61 3b 20 6f 70 65 6e 20 2f ut.txt a; open /
0d50: 6b 69 74 6f 75 74 2e 74 78 74 20 61 3b 20 6f 70 kitout.txt a; op
0d60: 65 6e 20 2f 6b 69 74 6f 75 74 2e 74 78 74 20 61 en /kitout.txt a
0d70: 5c 6e 22 0a 2f 2a 20 74 68 69 73 20 74 6f 6f 20 \n"./* this too
0d80: 73 65 65 6d 73 20 74 6f 20 62 65 20 6e 65 65 64 seems to be need
0d90: 65 64 20 6f 6e 20 77 69 6e 63 65 20 2d 20 69 74 ed on wince - it
0da0: 20 61 70 70 65 61 72 73 20 74 6f 20 62 65 20 72 appears to be r
0db0: 65 6c 61 74 65 64 20 74 6f 20 74 68 65 20 61 62 elated to the ab
0dc0: 6f 76 65 20 2a 2f 0a 22 63 61 74 63 68 20 7b 72 ove */."catch {r
0dd0: 65 6e 61 6d 65 20 73 6f 75 72 63 65 20 3a 3a 74 ename source ::t
0de0: 63 6c 3a 3a 73 6f 75 72 63 65 7d 5c 6e 22 0a 22 cl::source}\n"."
0df0: 70 72 6f 63 20 73 6f 75 72 63 65 20 66 69 6c 65 proc source file
0e00: 20 7b 5c 6e 22 0a 09 22 73 65 74 20 6f 6c 64 20 {\n".."set old
0e10: 5b 69 6e 66 6f 20 73 63 72 69 70 74 5d 5c 6e 22 [info script]\n"
0e20: 0a 09 22 69 6e 66 6f 20 73 63 72 69 70 74 20 24 .."info script $
0e30: 66 69 6c 65 5c 6e 22 0a 09 22 73 65 74 20 66 69 file\n".."set fi
0e40: 64 20 5b 6f 70 65 6e 20 24 66 69 6c 65 5d 5c 6e d [open $file]\n
0e50: 22 0a 09 22 73 65 74 20 64 61 74 61 20 5b 72 65 ".."set data [re
0e60: 61 64 20 24 66 69 64 5d 5c 6e 22 0a 09 22 63 6c ad $fid]\n".."cl
0e70: 6f 73 65 20 24 66 69 64 5c 6e 22 0a 09 22 73 65 ose $fid\n".."se
0e80: 74 20 63 6f 64 65 20 5b 63 61 74 63 68 20 7b 75 t code [catch {u
0e90: 70 6c 65 76 65 6c 20 31 20 24 64 61 74 61 7d 20 plevel 1 $data}
0ea0: 72 65 73 5d 5c 6e 22 0a 09 22 69 6e 66 6f 20 73 res]\n".."info s
0eb0: 63 72 69 70 74 20 24 6f 6c 64 5c 6e 22 0a 09 22 cript $old\n".."
0ec0: 69 66 20 7b 24 63 6f 64 65 20 3d 3d 20 32 7d 20 if {$code == 2}
0ed0: 7b 20 73 65 74 20 63 6f 64 65 20 30 20 7d 5c 6e { set code 0 }\n
0ee0: 22 0a 09 22 72 65 74 75 72 6e 20 2d 63 6f 64 65 ".."return -code
0ef0: 20 24 63 6f 64 65 20 24 72 65 73 5c 6e 22 0a 22 $code $res\n"."
0f00: 7d 5c 6e 22 0a 23 65 6e 64 69 66 20 2f 2a 20 5f }\n".#endif /* _
0f10: 57 49 4e 33 32 5f 57 43 45 20 26 26 20 21 54 43 WIN32_WCE && !TC
0f20: 4c 4b 49 54 5f 44 4c 4c 20 2a 2f 0a 22 70 72 6f LKIT_DLL */."pro
0f30: 63 20 74 63 6c 4b 69 74 49 6e 69 74 20 7b 7d 20 c tclKitInit {}
0f40: 7b 5c 6e 22 0a 09 22 72 65 6e 61 6d 65 20 74 63 {\n".."rename tc
0f50: 6c 4b 69 74 49 6e 69 74 20 7b 7d 5c 6e 22 0a 09 lKitInit {}\n"..
0f60: 22 63 61 74 63 68 20 7b 20 6c 6f 61 64 20 7b 7d "catch { load {}
0f70: 20 76 66 73 20 7d 5c 6e 22 0a 23 69 66 64 65 66 vfs }\n".#ifdef
0f80: 20 4b 49 54 5f 49 4e 43 4c 55 44 45 53 5f 5a 4c KIT_INCLUDES_ZL
0f90: 49 42 0a 09 22 63 61 74 63 68 20 7b 20 6c 6f 61 IB.."catch { loa
0fa0: 64 20 7b 7d 20 7a 6c 69 62 20 7d 5c 6e 22 0a 23 d {} zlib }\n".#
0fb0: 65 6e 64 69 66 0a 23 69 66 64 65 66 20 4b 49 54 endif.#ifdef KIT
0fc0: 5f 49 4e 43 4c 55 44 45 53 5f 4d 4b 34 54 43 4c _INCLUDES_MK4TCL
0fd0: 0a 09 22 63 61 74 63 68 20 7b 20 6c 6f 61 64 20 .."catch { load
0fe0: 7b 7d 20 4d 6b 34 74 63 6c 20 7d 5c 6e 22 0a 23 {} Mk4tcl }\n".#
0ff0: 65 6e 64 69 66 0a 09 22 6c 6f 61 64 20 7b 7d 20 endif.."load {}
1000: 74 63 6c 6b 69 74 3a 3a 69 6e 69 74 5c 6e 22 0a tclkit::init\n".
1010: 09 22 3a 3a 74 63 6c 6b 69 74 3a 3a 69 6e 69 74 ."::tclkit::init
1020: 3a 3a 69 6e 69 74 49 6e 74 65 72 70 5c 6e 22 0a ::initInterp\n".
1030: 09 22 72 65 6e 61 6d 65 20 3a 3a 74 63 6c 6b 69 ."rename ::tclki
1040: 74 3a 3a 69 6e 69 74 3a 3a 69 6e 69 74 49 6e 74 t::init::initInt
1050: 65 72 70 20 7b 7d 5c 6e 22 0a 09 22 73 65 74 20 erp {}\n".."set
1060: 62 6f 6f 74 66 69 6c 65 20 5b 66 69 6c 65 20 6a bootfile [file j
1070: 6f 69 6e 20 22 20 54 43 4c 4b 49 54 5f 4d 4f 55 oin " TCLKIT_MOU
1080: 4e 54 50 4f 49 4e 54 20 22 20 62 6f 6f 74 2e 74 NTPOINT " boot.t
1090: 63 6c 5d 5c 6e 22 0a 09 22 69 66 20 7b 5b 66 69 cl]\n".."if {[fi
10a0: 6c 65 20 65 78 69 73 74 73 20 24 62 6f 6f 74 66 le exists $bootf
10b0: 69 6c 65 5d 7d 20 7b 5c 6e 22 0a 09 09 22 63 61 ile]} {\n"..."ca
10c0: 74 63 68 20 7b 5c 6e 22 0a 09 09 09 22 73 65 74 tch {\n"...."set
10d0: 20 66 20 5b 6f 70 65 6e 20 24 62 6f 6f 74 66 69 f [open $bootfi
10e0: 6c 65 5d 5c 6e 22 0a 09 09 09 22 73 65 74 20 73 le]\n"...."set s
10f0: 20 5b 72 65 61 64 20 24 66 5d 5c 6e 22 0a 09 09 [read $f]\n"...
1100: 09 22 63 6c 6f 73 65 20 24 66 5c 6e 22 0a 09 09 ."close $f\n"...
1110: 22 7d 5c 6e 22 0a 09 22 7d 20 65 6c 73 65 20 7b "}\n".."} else {
1120: 5c 6e 22 0a 09 09 22 73 65 74 20 3a 3a 54 43 4c \n"..."set ::TCL
1130: 4b 49 54 5f 49 4e 49 54 56 46 53 20 31 5c 6e 22 KIT_INITVFS 1\n"
1140: 0a 09 22 7d 5c 6e 22 0a 23 69 66 64 65 66 20 4b .."}\n".#ifdef K
1150: 49 54 5f 53 54 4f 52 41 47 45 5f 4d 4b 34 0a 09 IT_STORAGE_MK4..
1160: 22 73 65 74 20 3a 3a 74 63 6c 4b 69 74 53 74 6f "set ::tclKitSto
1170: 72 61 67 65 20 5c 22 6d 6b 34 5c 22 5c 6e 22 0a rage \"mk4\"\n".
1180: 09 22 69 66 20 7b 21 5b 69 6e 66 6f 20 65 78 69 ."if {![info exi
1190: 73 74 73 20 73 5d 7d 20 7b 5c 6e 22 0a 09 09 22 sts s]} {\n"..."
11a0: 6d 6b 3a 3a 66 69 6c 65 20 6f 70 65 6e 20 65 78 mk::file open ex
11b0: 65 20 22 20 54 43 4c 4b 49 54 5f 56 46 53 53 4f e " TCLKIT_VFSSO
11c0: 55 52 43 45 20 22 20 2d 72 65 61 64 6f 6e 6c 79 URCE " -readonly
11d0: 5c 6e 22 0a 09 09 22 73 65 74 20 6e 20 5b 6d 6b \n"..."set n [mk
11e0: 3a 3a 73 65 6c 65 63 74 20 65 78 65 2e 64 69 72 ::select exe.dir
11f0: 73 21 30 2e 66 69 6c 65 73 20 6e 61 6d 65 20 62 s!0.files name b
1200: 6f 6f 74 2e 74 63 6c 5d 5c 6e 22 0a 09 09 22 69 oot.tcl]\n"..."i
1210: 66 20 7b 24 6e 20 21 3d 20 5c 22 5c 22 7d 20 7b f {$n != \"\"} {
1220: 5c 6e 22 0a 09 09 09 22 73 65 74 20 73 20 5b 6d \n"...."set s [m
1230: 6b 3a 3a 67 65 74 20 65 78 65 2e 64 69 72 73 21 k::get exe.dirs!
1240: 30 2e 66 69 6c 65 73 21 24 6e 20 63 6f 6e 74 65 0.files!$n conte
1250: 6e 74 73 5d 5c 6e 22 0a 09 09 09 22 69 66 20 7b nts]\n"...."if {
1260: 21 5b 73 74 72 69 6e 67 20 6c 65 6e 67 74 68 20 ![string length
1270: 24 73 5d 7d 20 7b 20 65 72 72 6f 72 20 5c 22 65 $s]} { error \"e
1280: 6d 70 74 79 20 62 6f 6f 74 2e 74 63 6c 5c 22 20 mpty boot.tcl\"
1290: 7d 5c 6e 22 0a 09 09 09 22 63 61 74 63 68 20 7b }\n"...."catch {
12a0: 6c 6f 61 64 20 7b 7d 20 7a 6c 69 62 7d 5c 6e 22 load {} zlib}\n"
12b0: 0a 09 09 09 22 69 66 20 7b 5b 6d 6b 3a 3a 67 65 ...."if {[mk::ge
12c0: 74 20 65 78 65 2e 64 69 72 73 21 30 2e 66 69 6c t exe.dirs!0.fil
12d0: 65 73 21 24 6e 20 73 69 7a 65 5d 20 21 3d 20 5b es!$n size] != [
12e0: 73 74 72 69 6e 67 20 6c 65 6e 67 74 68 20 24 73 string length $s
12f0: 5d 7d 20 7b 5c 6e 22 0a 09 09 09 09 22 73 65 74 ]} {\n"....."set
1300: 20 73 20 5b 7a 6c 69 62 20 64 65 63 6f 6d 70 72 s [zlib decompr
1310: 65 73 73 20 24 73 5d 5c 6e 22 0a 09 09 09 22 7d ess $s]\n"...."}
1320: 5c 6e 22 0a 09 09 22 7d 5c 6e 22 0a 09 22 7d 5c \n"..."}\n".."}\
1330: 6e 22 0a 23 65 6e 64 69 66 20 2f 2a 20 4b 49 54 n".#endif /* KIT
1340: 5f 53 54 4f 52 41 47 45 5f 4d 4b 34 20 2a 2f 0a _STORAGE_MK4 */.
1350: 23 69 66 64 65 66 20 4b 49 54 5f 53 54 4f 52 41 #ifdef KIT_STORA
1360: 47 45 5f 5a 49 50 0a 09 22 73 65 74 20 3a 3a 74 GE_ZIP.."set ::t
1370: 63 6c 4b 69 74 53 74 6f 72 61 67 65 20 5c 22 7a clKitStorage \"z
1380: 69 70 5c 22 5c 6e 22 0a 09 22 69 66 20 7b 21 5b ip\"\n".."if {![
1390: 69 6e 66 6f 20 65 78 69 73 74 73 20 73 5d 7d 20 info exists s]}
13a0: 7b 5c 6e 22 0a 23 20 20 69 6e 63 6c 75 64 65 20 {\n".# include
13b0: 22 7a 69 70 76 66 73 2e 74 63 6c 2e 68 22 0a 09 "zipvfs.tcl.h"..
13c0: 09 22 63 61 74 63 68 20 7b 5c 6e 22 0a 09 09 09 ."catch {\n"....
13d0: 22 73 65 74 20 3a 3a 74 63 6c 4b 69 74 53 74 6f "set ::tclKitSto
13e0: 72 61 67 65 5f 66 64 20 5b 3a 3a 7a 69 70 3a 3a rage_fd [::zip::
13f0: 6f 70 65 6e 20 22 20 54 43 4c 4b 49 54 5f 56 46 open " TCLKIT_VF
1400: 53 53 4f 55 52 43 45 20 22 5d 5c 6e 22 0a 09 09 SSOURCE "]\n"...
1410: 09 22 3a 3a 7a 69 70 3a 3a 73 74 61 74 20 24 3a ."::zip::stat $:
1420: 3a 74 63 6c 4b 69 74 53 74 6f 72 61 67 65 5f 66 :tclKitStorage_f
1430: 64 20 62 6f 6f 74 2e 74 63 6c 20 73 62 5c 6e 22 d boot.tcl sb\n"
1440: 0a 09 09 09 22 73 65 65 6b 20 24 3a 3a 74 63 6c ...."seek $::tcl
1450: 4b 69 74 53 74 6f 72 61 67 65 5f 66 64 20 24 73 KitStorage_fd $s
1460: 62 28 69 6e 6f 29 5c 6e 22 0a 09 09 09 22 3a 3a b(ino)\n"...."::
1470: 7a 69 70 3a 3a 44 61 74 61 20 24 3a 3a 74 63 6c zip::Data $::tcl
1480: 4b 69 74 53 74 6f 72 61 67 65 5f 66 64 20 73 62 KitStorage_fd sb
1490: 20 73 5c 6e 22 0a 09 09 22 7d 5c 6e 22 0a 09 22 s\n"..."}\n".."
14a0: 7d 5c 6e 22 0a 23 65 6e 64 69 66 20 2f 2a 20 4b }\n".#endif /* K
14b0: 49 54 5f 53 54 4f 52 41 47 45 5f 5a 49 50 20 2a IT_STORAGE_ZIP *
14c0: 2f 0a 23 69 66 64 65 66 20 4b 49 54 5f 53 54 4f /.#ifdef KIT_STO
14d0: 52 41 47 45 5f 43 56 46 53 0a 09 22 73 65 74 20 RAGE_CVFS.."set
14e0: 3a 3a 74 63 6c 4b 69 74 53 74 6f 72 61 67 65 20 ::tclKitStorage
14f0: 5c 22 63 76 66 73 5c 22 5c 6e 22 0a 09 22 6c 6f \"cvfs\"\n".."lo
1500: 61 64 20 7b 7d 20 72 65 63 68 61 6e 5c 6e 22 0a ad {} rechan\n".
1510: 09 22 6c 6f 61 64 20 7b 7d 20 63 76 66 73 5f 64 ."load {} cvfs_d
1520: 61 74 61 5f 74 63 6c 5c 6e 22 0a 23 69 6e 63 6c ata_tcl\n".#incl
1530: 75 64 65 20 22 63 76 66 73 2e 74 63 6c 2e 68 22 ude "cvfs.tcl.h"
1540: 0a 09 22 69 66 20 7b 21 5b 69 6e 66 6f 20 65 78 .."if {![info ex
1550: 69 73 74 73 20 73 5d 7d 20 7b 5c 6e 22 0a 09 09 ists s]} {\n"...
1560: 22 63 61 74 63 68 20 7b 5c 6e 22 0a 09 09 09 22 "catch {\n"...."
1570: 73 65 74 20 73 20 5b 3a 3a 76 66 73 3a 3a 63 76 set s [::vfs::cv
1580: 66 73 3a 3a 64 61 74 61 3a 3a 67 65 74 44 61 74 fs::data::getDat
1590: 61 20 74 63 6c 20 62 6f 6f 74 2e 74 63 6c 5d 5c a tcl boot.tcl]\
15a0: 6e 22 0a 09 09 22 7d 5c 6e 22 0a 09 22 7d 5c 6e n"..."}\n".."}\n
15b0: 22 0a 23 65 6e 64 69 66 20 2f 2a 20 4b 49 54 5f ".#endif /* KIT_
15c0: 53 54 4f 52 41 47 45 5f 43 56 46 53 20 2a 2f 0a STORAGE_CVFS */.
15d0: 09 22 69 66 20 7b 21 5b 69 6e 66 6f 20 65 78 69 ."if {![info exi
15e0: 73 74 73 20 73 5d 7d 20 7b 5c 6e 22 0a 09 09 22 sts s]} {\n"..."
15f0: 73 65 74 20 73 20 5c 22 5c 22 5c 6e 22 0a 09 22 set s \"\"\n".."
1600: 7d 5c 6e 22 0a 23 69 66 64 65 66 20 54 43 4c 4b }\n".#ifdef TCLK
1610: 49 54 5f 44 4c 4c 0a 09 22 73 65 74 20 3a 3a 54 IT_DLL.."set ::T
1620: 43 4c 4b 49 54 5f 54 59 50 45 20 5c 22 6b 69 74 CLKIT_TYPE \"kit
1630: 64 6c 6c 5c 22 5c 6e 22 0a 23 65 6c 73 65 0a 09 dll\"\n".#else..
1640: 22 73 65 74 20 3a 3a 54 43 4c 4b 49 54 5f 54 59 "set ::TCLKIT_TY
1650: 50 45 20 5c 22 74 63 6c 6b 69 74 5c 22 5c 6e 22 PE \"tclkit\"\n"
1660: 0a 23 65 6e 64 69 66 20 2f 2a 20 54 43 4c 4b 49 .#endif /* TCLKI
1670: 54 5f 44 4c 4c 20 2a 2f 0a 09 22 73 65 74 20 3a T_DLL */.."set :
1680: 3a 54 43 4c 4b 49 54 5f 4d 4f 55 4e 54 50 4f 49 :TCLKIT_MOUNTPOI
1690: 4e 54 20 22 20 54 43 4c 4b 49 54 5f 4d 4f 55 4e NT " TCLKIT_MOUN
16a0: 54 50 4f 49 4e 54 20 22 5c 6e 22 0a 09 22 63 61 TPOINT "\n".."ca
16b0: 74 63 68 20 7b 20 73 65 74 20 3a 3a 54 43 4c 4b tch { set ::TCLK
16c0: 49 54 5f 56 46 53 53 4f 55 52 43 45 20 22 20 54 IT_VFSSOURCE " T
16d0: 43 4c 4b 49 54 5f 56 46 53 53 4f 55 52 43 45 20 CLKIT_VFSSOURCE
16e0: 22 20 7d 5c 6e 22 0a 09 22 73 65 74 20 3a 3a 54 " }\n".."set ::T
16f0: 43 4c 4b 49 54 5f 4d 4f 55 4e 54 50 4f 49 4e 54 CLKIT_MOUNTPOINT
1700: 5f 56 41 52 20 7b 22 20 54 43 4c 4b 49 54 5f 4d _VAR {" TCLKIT_M
1710: 4f 55 4e 54 50 4f 49 4e 54 20 22 7d 5c 6e 22 0a OUNTPOINT "}\n".
1720: 09 22 73 65 74 20 3a 3a 54 43 4c 4b 49 54 5f 56 ."set ::TCLKIT_V
1730: 46 53 53 4f 55 52 43 45 5f 56 41 52 20 7b 22 20 FSSOURCE_VAR {"
1740: 54 43 4c 4b 49 54 5f 56 46 53 53 4f 55 52 43 45 TCLKIT_VFSSOURCE
1750: 20 22 7d 5c 6e 22 0a 09 22 75 70 6c 65 76 65 6c "}\n".."uplevel
1760: 20 23 30 20 24 73 5c 6e 22 0a 23 69 66 20 64 65 #0 $s\n".#if de
1770: 66 69 6e 65 64 28 4b 49 54 5f 49 4e 43 4c 55 44 fined(KIT_INCLUD
1780: 45 53 5f 54 4b 29 20 26 26 20 64 65 66 69 6e 65 ES_TK) && define
1790: 64 28 4b 49 54 5f 54 4b 5f 56 45 52 53 49 4f 4e d(KIT_TK_VERSION
17a0: 29 0a 09 22 70 61 63 6b 61 67 65 20 69 66 6e 65 ).."package ifne
17b0: 65 64 65 64 20 54 6b 20 22 20 4b 49 54 5f 54 4b eded Tk " KIT_TK
17c0: 5f 56 45 52 53 49 4f 4e 20 22 20 7b 5c 6e 22 0a _VERSION " {\n".
17d0: 09 09 22 6c 6f 61 64 20 7b 7d 20 54 6b 5c 6e 22 .."load {} Tk\n"
17e0: 0a 09 22 7d 5c 6e 22 0a 23 65 6e 64 69 66 0a 23 .."}\n".#endif.#
17f0: 69 66 64 65 66 20 5f 57 49 4e 33 32 0a 09 22 63 ifdef _WIN32.."c
1800: 61 74 63 68 20 7b 6c 6f 61 64 20 7b 7d 20 64 64 atch {load {} dd
1810: 65 7d 5c 6e 22 0a 09 22 63 61 74 63 68 20 7b 6c e}\n".."catch {l
1820: 6f 61 64 20 7b 7d 20 72 65 67 69 73 74 72 79 7d oad {} registry}
1830: 5c 6e 22 0a 23 65 6e 64 69 66 20 2f 2a 20 5f 57 \n".#endif /* _W
1840: 49 4e 33 32 20 2a 2f 0a 09 22 72 65 74 75 72 6e IN32 */.."return
1850: 20 30 5c 6e 22 0a 22 7d 5c 6e 22 0a 22 74 63 6c 0\n"."}\n"."tcl
1860: 4b 69 74 49 6e 69 74 22 3b 0a 0a 73 74 61 74 69 KitInit";..stati
1870: 63 20 63 6f 6e 73 74 20 63 68 61 72 20 69 6e 69 c const char ini
1880: 74 53 63 72 69 70 74 5b 5d 20 3d 0a 22 69 66 20 tScript[] =."if
1890: 7b 5b 66 69 6c 65 20 69 73 66 69 6c 65 20 5b 66 {[file isfile [f
18a0: 69 6c 65 20 6a 6f 69 6e 20 22 20 54 43 4c 4b 49 ile join " TCLKI
18b0: 54 5f 56 46 53 53 4f 55 52 43 45 20 22 20 6d 61 T_VFSSOURCE " ma
18c0: 69 6e 2e 74 63 6c 5d 5d 7d 20 7b 5c 6e 22 0a 09 in.tcl]]} {\n"..
18d0: 22 69 66 20 7b 5b 69 6e 66 6f 20 63 6f 6d 6d 61 "if {[info comma
18e0: 6e 64 73 20 63 6f 6e 73 6f 6c 65 5d 20 21 3d 20 nds console] !=
18f0: 7b 7d 7d 20 7b 20 63 6f 6e 73 6f 6c 65 20 68 69 {}} { console hi
1900: 64 65 20 7d 5c 6e 22 0a 09 22 73 65 74 20 74 63 de }\n".."set tc
1910: 6c 5f 69 6e 74 65 72 61 63 74 69 76 65 20 30 5c l_interactive 0\
1920: 6e 22 0a 09 22 69 6e 63 72 20 61 72 67 63 5c 6e n".."incr argc\n
1930: 22 0a 09 22 73 65 74 20 61 72 67 76 20 5b 6c 69 ".."set argv [li
1940: 6e 73 65 72 74 20 24 61 72 67 76 20 30 20 24 61 nsert $argv 0 $a
1950: 72 67 76 30 5d 5c 6e 22 0a 09 22 73 65 74 20 61 rgv0]\n".."set a
1960: 72 67 76 30 20 5b 66 69 6c 65 20 6a 6f 69 6e 20 rgv0 [file join
1970: 22 20 54 43 4c 4b 49 54 5f 56 46 53 53 4f 55 52 " TCLKIT_VFSSOUR
1980: 43 45 20 22 20 6d 61 69 6e 2e 74 63 6c 5d 5c 6e CE " main.tcl]\n
1990: 22 0a 22 7d 20 65 6c 73 65 20 63 6f 6e 74 69 6e "."} else contin
19a0: 75 65 5c 6e 22 3b 0a 0a 2f 2a 20 53 65 74 45 78 ue\n";../* SetEx
19b0: 65 63 4e 61 6d 65 20 2d 2d 0a 0a 20 20 20 48 61 ecName --.. Ha
19c0: 63 6b 20 74 6f 20 67 65 74 20 61 72 6f 75 6e 64 ck to get around
19d0: 20 54 63 6c 20 62 75 67 20 31 32 32 34 38 38 38 Tcl bug 1224888
19e0: 2e 0a 2a 2f 0a 73 74 61 74 69 63 20 76 6f 69 64 ..*/.static void
19f0: 20 53 65 74 45 78 65 63 4e 61 6d 65 28 54 63 6c SetExecName(Tcl
1a00: 5f 49 6e 74 65 72 70 20 2a 69 6e 74 65 72 70 2c _Interp *interp,
1a10: 20 63 6f 6e 73 74 20 63 68 61 72 20 2a 70 61 74 const char *pat
1a20: 68 29 20 7b 0a 23 69 66 64 65 66 20 54 43 4c 4b h) {.#ifdef TCLK
1a30: 49 54 5f 52 45 51 55 49 52 45 5f 54 43 4c 45 58 IT_REQUIRE_TCLEX
1a40: 45 43 55 54 41 42 4c 45 4e 41 4d 45 0a 09 74 63 ECUTABLENAME..tc
1a50: 6c 45 78 65 63 75 74 61 62 6c 65 4e 61 6d 65 20 lExecutableName
1a60: 3d 20 73 74 72 64 75 70 28 70 61 74 68 29 3b 0a = strdup(path);.
1a70: 23 65 6e 64 69 66 0a 09 54 63 6c 5f 46 69 6e 64 #endif..Tcl_Find
1a80: 45 78 65 63 75 74 61 62 6c 65 28 70 61 74 68 29 Executable(path)
1a90: 3b 0a 0a 09 72 65 74 75 72 6e 3b 0a 7d 0a 0a 73 ;...return;.}..s
1aa0: 74 61 74 69 63 20 76 6f 69 64 20 46 69 6e 64 41 tatic void FindA
1ab0: 6e 64 53 65 74 45 78 65 63 4e 61 6d 65 28 54 63 ndSetExecName(Tc
1ac0: 6c 5f 49 6e 74 65 72 70 20 2a 69 6e 74 65 72 70 l_Interp *interp
1ad0: 29 20 7b 0a 09 69 6e 74 20 6c 65 6e 20 3d 20 30 ) {..int len = 0
1ae0: 3b 0a 09 54 63 6c 5f 4f 62 6a 20 2a 65 78 65 63 ;..Tcl_Obj *exec
1af0: 4e 61 6d 65 4f 62 6a 3b 0a 09 54 63 6c 5f 4f 62 NameObj;..Tcl_Ob
1b00: 6a 20 2a 6c 6f 62 6a 76 5b 31 5d 3b 0a 23 69 66 j *lobjv[1];.#if
1b10: 64 65 66 20 48 41 56 45 5f 52 45 41 44 4c 49 4e def HAVE_READLIN
1b20: 4b 0a 09 73 73 69 7a 65 5f 74 20 72 65 61 64 6c K..ssize_t readl
1b30: 69 6e 6b 5f 72 65 74 3b 0a 09 63 68 61 72 20 65 ink_ret;..char e
1b40: 78 65 5f 62 75 66 5b 34 30 39 36 5d 3b 0a 23 65 xe_buf[4096];.#e
1b50: 6e 64 69 66 20 2f 2a 20 48 41 56 45 5f 52 45 41 ndif /* HAVE_REA
1b60: 44 4c 49 4e 4b 20 2a 2f 0a 23 69 66 64 65 66 20 DLINK */.#ifdef
1b70: 48 41 56 45 5f 41 43 43 45 50 54 41 42 4c 45 5f HAVE_ACCEPTABLE_
1b80: 44 4c 41 44 44 52 0a 09 44 6c 5f 69 6e 66 6f 20 DLADDR..Dl_info
1b90: 73 79 6d 69 6e 66 6f 3b 0a 09 69 6e 74 20 64 6c syminfo;..int dl
1ba0: 61 64 64 72 5f 72 65 74 3b 0a 23 65 6e 64 69 66 addr_ret;.#endif
1bb0: 20 2f 2a 20 48 41 56 45 5f 41 43 43 45 50 54 41 /* HAVE_ACCEPTA
1bc0: 42 4c 45 5f 44 4c 41 44 44 52 20 2a 2f 20 0a 0a BLE_DLADDR */ ..
1bd0: 23 69 66 64 65 66 20 48 41 56 45 5f 52 45 41 44 #ifdef HAVE_READ
1be0: 4c 49 4e 4b 0a 09 69 66 20 28 54 63 6c 5f 47 65 LINK..if (Tcl_Ge
1bf0: 74 4e 61 6d 65 4f 66 45 78 65 63 75 74 61 62 6c tNameOfExecutabl
1c00: 65 28 29 20 3d 3d 20 4e 55 4c 4c 29 20 7b 0a 09 e() == NULL) {..
1c10: 09 72 65 61 64 6c 69 6e 6b 5f 72 65 74 20 3d 20 .readlink_ret =
1c20: 72 65 61 64 6c 69 6e 6b 28 22 2f 70 72 6f 63 2f readlink("/proc/
1c30: 73 65 6c 66 2f 65 78 65 22 2c 20 65 78 65 5f 62 self/exe", exe_b
1c40: 75 66 2c 20 73 69 7a 65 6f 66 28 65 78 65 5f 62 uf, sizeof(exe_b
1c50: 75 66 29 20 2d 20 31 29 3b 0a 0a 09 09 69 66 20 uf) - 1);....if
1c60: 28 72 65 61 64 6c 69 6e 6b 5f 72 65 74 20 3e 20 (readlink_ret >
1c70: 30 20 26 26 20 72 65 61 64 6c 69 6e 6b 5f 72 65 0 && readlink_re
1c80: 74 20 3c 20 28 73 69 7a 65 6f 66 28 65 78 65 5f t < (sizeof(exe_
1c90: 62 75 66 29 20 2d 20 31 29 29 20 7b 0a 09 09 09 buf) - 1)) {....
1ca0: 65 78 65 5f 62 75 66 5b 72 65 61 64 6c 69 6e 6b exe_buf[readlink
1cb0: 5f 72 65 74 5d 20 3d 20 27 5c 30 27 3b 0a 0a 09 _ret] = '\0';...
1cc0: 09 09 53 65 74 45 78 65 63 4e 61 6d 65 28 69 6e ..SetExecName(in
1cd0: 74 65 72 70 2c 20 65 78 65 5f 62 75 66 29 3b 0a terp, exe_buf);.
1ce0: 0a 09 09 09 72 65 74 75 72 6e 3b 0a 09 09 7d 0a ....return;...}.
1cf0: 09 7d 0a 0a 09 69 66 20 28 54 63 6c 5f 47 65 74 .}...if (Tcl_Get
1d00: 4e 61 6d 65 4f 66 45 78 65 63 75 74 61 62 6c 65 NameOfExecutable
1d10: 28 29 20 3d 3d 20 4e 55 4c 4c 29 20 7b 0a 09 09 () == NULL) {...
1d20: 72 65 61 64 6c 69 6e 6b 5f 72 65 74 20 3d 20 72 readlink_ret = r
1d30: 65 61 64 6c 69 6e 6b 28 22 2f 70 72 6f 63 2f 63 eadlink("/proc/c
1d40: 75 72 70 72 6f 63 2f 66 69 6c 65 22 2c 20 65 78 urproc/file", ex
1d50: 65 5f 62 75 66 2c 20 73 69 7a 65 6f 66 28 65 78 e_buf, sizeof(ex
1d60: 65 5f 62 75 66 29 20 2d 20 31 29 3b 0a 0a 09 09 e_buf) - 1);....
1d70: 69 66 20 28 72 65 61 64 6c 69 6e 6b 5f 72 65 74 if (readlink_ret
1d80: 20 3e 20 30 20 26 26 20 72 65 61 64 6c 69 6e 6b > 0 && readlink
1d90: 5f 72 65 74 20 3c 20 28 73 69 7a 65 6f 66 28 65 _ret < (sizeof(e
1da0: 78 65 5f 62 75 66 29 20 2d 20 31 29 29 20 7b 0a xe_buf) - 1)) {.
1db0: 09 09 09 65 78 65 5f 62 75 66 5b 72 65 61 64 6c ...exe_buf[readl
1dc0: 69 6e 6b 5f 72 65 74 5d 20 3d 20 27 5c 30 27 3b ink_ret] = '\0';
1dd0: 0a 0a 09 09 09 69 66 20 28 73 74 72 63 6d 70 28 .....if (strcmp(
1de0: 65 78 65 5f 62 75 66 2c 20 22 75 6e 6b 6e 6f 77 exe_buf, "unknow
1df0: 6e 22 29 20 21 3d 20 30 29 20 7b 0a 09 09 09 09 n") != 0) {.....
1e00: 53 65 74 45 78 65 63 4e 61 6d 65 28 69 6e 74 65 SetExecName(inte
1e10: 72 70 2c 20 65 78 65 5f 62 75 66 29 3b 0a 0a 09 rp, exe_buf);...
1e20: 09 09 09 72 65 74 75 72 6e 3b 0a 09 09 09 7d 0a ...return;....}.
1e30: 09 09 7d 0a 09 7d 0a 23 65 6e 64 69 66 20 2f 2a ..}..}.#endif /*
1e40: 20 48 41 56 45 5f 52 45 41 44 4c 49 4e 4b 20 2a HAVE_READLINK *
1e50: 2f 0a 0a 23 69 66 64 65 66 20 48 41 56 45 5f 41 /..#ifdef HAVE_A
1e60: 43 43 45 50 54 41 42 4c 45 5f 44 4c 41 44 44 52 CCEPTABLE_DLADDR
1e70: 0a 23 20 20 69 66 6e 64 65 66 20 54 43 4c 4b 49 .# ifndef TCLKI
1e80: 54 5f 44 4c 4c 0a 09 69 66 20 28 54 63 6c 5f 47 T_DLL..if (Tcl_G
1e90: 65 74 4e 61 6d 65 4f 66 45 78 65 63 75 74 61 62 etNameOfExecutab
1ea0: 6c 65 28 29 20 3d 3d 20 4e 55 4c 4c 29 20 7b 0a le() == NULL) {.
1eb0: 09 09 64 6c 61 64 64 72 5f 72 65 74 20 3d 20 64 ..dladdr_ret = d
1ec0: 6c 61 64 64 72 28 26 53 65 74 45 78 65 63 4e 61 laddr(&SetExecNa
1ed0: 6d 65 2c 20 26 73 79 6d 69 6e 66 6f 29 3b 0a 09 me, &syminfo);..
1ee0: 09 69 66 20 28 64 6c 61 64 64 72 5f 72 65 74 20 .if (dladdr_ret
1ef0: 21 3d 20 30 29 20 7b 0a 09 09 09 53 65 74 45 78 != 0) {....SetEx
1f00: 65 63 4e 61 6d 65 28 69 6e 74 65 72 70 2c 20 73 ecName(interp, s
1f10: 79 6d 69 6e 66 6f 2e 64 6c 69 5f 66 6e 61 6d 65 yminfo.dli_fname
1f20: 29 3b 0a 0a 09 09 09 72 65 74 75 72 6e 3b 0a 09 );.....return;..
1f30: 09 7d 0a 09 7d 0a 23 20 20 20 20 69 66 64 65 66 .}..}.# ifdef
1f40: 20 4b 49 54 53 48 5f 4e 45 45 44 5f 57 49 4e 4d KITSH_NEED_WINM
1f50: 41 49 4e 0a 09 69 66 20 28 54 63 6c 5f 47 65 74 AIN..if (Tcl_Get
1f60: 4e 61 6d 65 4f 66 45 78 65 63 75 74 61 62 6c 65 NameOfExecutable
1f70: 28 29 20 3d 3d 20 4e 55 4c 4c 29 20 7b 0a 23 20 () == NULL) {.#
1f80: 20 20 20 20 20 69 66 64 65 66 20 5f 57 49 4e 33 ifdef _WIN3
1f90: 32 5f 57 43 45 0a 09 09 64 6c 61 64 64 72 5f 72 2_WCE...dladdr_r
1fa0: 65 74 20 3d 20 64 6c 61 64 64 72 28 26 57 69 6e et = dladdr(&Win
1fb0: 4d 61 69 6e 2c 20 26 73 79 6d 69 6e 66 6f 29 3b Main, &syminfo);
1fc0: 0a 23 20 20 20 20 20 20 65 6c 73 65 0a 09 09 64 .# else...d
1fd0: 6c 61 64 64 72 5f 72 65 74 20 3d 20 64 6c 61 64 laddr_ret = dlad
1fe0: 64 72 28 26 77 57 69 6e 4d 61 69 6e 2c 20 26 73 dr(&wWinMain, &s
1ff0: 79 6d 69 6e 66 6f 29 3b 0a 23 20 20 20 20 20 20 yminfo);.#
2000: 65 6e 64 69 66 20 2f 2a 20 5f 57 49 4e 33 32 5f endif /* _WIN32_
2010: 57 43 45 20 2a 2f 0a 0a 09 09 69 66 20 28 64 6c WCE */....if (dl
2020: 61 64 64 72 5f 72 65 74 20 21 3d 20 30 29 20 7b addr_ret != 0) {
2030: 0a 09 09 09 53 65 74 45 78 65 63 4e 61 6d 65 28 ....SetExecName(
2040: 69 6e 74 65 72 70 2c 20 73 79 6d 69 6e 66 6f 2e interp, syminfo.
2050: 64 6c 69 5f 66 6e 61 6d 65 29 3b 0a 0a 09 09 09 dli_fname);.....
2060: 72 65 74 75 72 6e 3b 0a 09 09 7d 0a 09 7d 0a 23 return;...}..}.#
2070: 20 20 20 20 65 6e 64 69 66 20 2f 2a 20 4b 49 54 endif /* KIT
2080: 53 48 5f 4e 45 45 44 5f 57 49 4e 4d 41 49 4e 20 SH_NEED_WINMAIN
2090: 2a 2f 0a 0a 09 69 66 20 28 54 63 6c 5f 47 65 74 */...if (Tcl_Get
20a0: 4e 61 6d 65 4f 66 45 78 65 63 75 74 61 62 6c 65 NameOfExecutable
20b0: 28 29 20 3d 3d 20 4e 55 4c 4c 29 20 7b 0a 09 09 () == NULL) {...
20c0: 64 6c 61 64 64 72 5f 72 65 74 20 3d 20 64 6c 61 dladdr_ret = dla
20d0: 64 64 72 28 26 6d 61 69 6e 2c 20 26 73 79 6d 69 ddr(&main, &symi
20e0: 6e 66 6f 29 3b 0a 09 09 69 66 20 28 64 6c 61 64 nfo);...if (dlad
20f0: 64 72 5f 72 65 74 20 21 3d 20 30 29 20 7b 0a 09 dr_ret != 0) {..
2100: 09 09 53 65 74 45 78 65 63 4e 61 6d 65 28 69 6e ..SetExecName(in
2110: 74 65 72 70 2c 20 73 79 6d 69 6e 66 6f 2e 64 6c terp, syminfo.dl
2120: 69 5f 66 6e 61 6d 65 29 3b 0a 0a 09 09 09 72 65 i_fname);.....re
2130: 74 75 72 6e 3b 0a 09 09 7d 0a 09 7d 0a 23 20 20 turn;...}..}.#
2140: 65 6e 64 69 66 20 2f 2a 20 21 54 43 4c 4b 49 54 endif /* !TCLKIT
2150: 5f 44 4c 4c 20 2a 2f 0a 23 65 6e 64 69 66 20 2f _DLL */.#endif /
2160: 2a 20 48 41 56 45 5f 41 43 43 45 50 54 41 42 4c * HAVE_ACCEPTABL
2170: 45 5f 44 4c 41 44 44 52 20 2a 2f 0a 0a 09 69 66 E_DLADDR */...if
2180: 20 28 54 63 6c 5f 47 65 74 4e 61 6d 65 4f 66 45 (Tcl_GetNameOfE
2190: 78 65 63 75 74 61 62 6c 65 28 29 20 3d 3d 20 4e xecutable() == N
21a0: 55 4c 4c 29 20 7b 0a 09 09 6c 6f 62 6a 76 5b 30 ULL) {...lobjv[0
21b0: 5d 20 3d 20 54 63 6c 5f 47 65 74 56 61 72 32 45 ] = Tcl_GetVar2E
21c0: 78 28 69 6e 74 65 72 70 2c 20 22 61 72 67 76 30 x(interp, "argv0
21d0: 22 2c 20 4e 55 4c 4c 2c 20 54 43 4c 5f 47 4c 4f ", NULL, TCL_GLO
21e0: 42 41 4c 5f 4f 4e 4c 59 29 3b 0a 09 09 65 78 65 BAL_ONLY);...exe
21f0: 63 4e 61 6d 65 4f 62 6a 20 3d 20 54 63 6c 5f 46 cNameObj = Tcl_F
2200: 53 4a 6f 69 6e 54 6f 50 61 74 68 28 54 63 6c 5f SJoinToPath(Tcl_
2210: 46 53 47 65 74 43 77 64 28 69 6e 74 65 72 70 29 FSGetCwd(interp)
2220: 2c 20 31 2c 20 6c 6f 62 6a 76 29 3b 0a 0a 09 09 , 1, lobjv);....
2230: 53 65 74 45 78 65 63 4e 61 6d 65 28 69 6e 74 65 SetExecName(inte
2240: 72 70 2c 20 54 63 6c 5f 47 65 74 53 74 72 69 6e rp, Tcl_GetStrin
2250: 67 46 72 6f 6d 4f 62 6a 28 65 78 65 63 4e 61 6d gFromObj(execNam
2260: 65 4f 62 6a 2c 20 26 6c 65 6e 29 29 3b 0a 0a 09 eObj, &len));...
2270: 09 72 65 74 75 72 6e 3b 0a 09 7d 0a 0a 09 72 65 .return;..}...re
2280: 74 75 72 6e 3b 0a 7d 0a 0a 73 74 61 74 69 63 20 turn;.}..static
2290: 76 6f 69 64 20 5f 54 63 6c 6b 69 74 5f 47 65 6e void _Tclkit_Gen
22a0: 65 72 69 63 5f 49 6e 69 74 28 76 6f 69 64 29 20 eric_Init(void)
22b0: 7b 0a 23 69 66 64 65 66 20 4b 49 54 5f 49 4e 43 {.#ifdef KIT_INC
22c0: 4c 55 44 45 53 5f 4d 4b 34 54 43 4c 0a 09 54 63 LUDES_MK4TCL..Tc
22d0: 6c 5f 53 74 61 74 69 63 50 61 63 6b 61 67 65 28 l_StaticPackage(
22e0: 30 2c 20 22 4d 6b 34 74 63 6c 22 2c 20 4d 6b 34 0, "Mk4tcl", Mk4
22f0: 74 63 6c 5f 49 6e 69 74 2c 20 4e 55 4c 4c 29 3b tcl_Init, NULL);
2300: 0a 23 65 6e 64 69 66 0a 23 69 66 64 65 66 20 4b .#endif.#ifdef K
2310: 49 54 5f 49 4e 43 4c 55 44 45 53 5f 50 57 42 0a IT_INCLUDES_PWB.
2320: 09 54 63 6c 5f 53 74 61 74 69 63 50 61 63 6b 61 .Tcl_StaticPacka
2330: 67 65 28 30 2c 20 22 70 77 62 22 2c 20 50 77 62 ge(0, "pwb", Pwb
2340: 5f 49 6e 69 74 2c 20 4e 55 4c 4c 29 3b 0a 23 65 _Init, NULL);.#e
2350: 6e 64 69 66 20 0a 09 54 63 6c 5f 53 74 61 74 69 ndif ..Tcl_Stati
2360: 63 50 61 63 6b 61 67 65 28 30 2c 20 22 72 65 63 cPackage(0, "rec
2370: 68 61 6e 22 2c 20 52 65 63 68 61 6e 5f 49 6e 69 han", Rechan_Ini
2380: 74 2c 20 4e 55 4c 4c 29 3b 0a 09 54 63 6c 5f 53 t, NULL);..Tcl_S
2390: 74 61 74 69 63 50 61 63 6b 61 67 65 28 30 2c 20 taticPackage(0,
23a0: 22 76 66 73 22 2c 20 56 66 73 5f 49 6e 69 74 2c "vfs", Vfs_Init,
23b0: 20 4e 55 4c 4c 29 3b 0a 23 69 66 64 65 66 20 4b NULL);.#ifdef K
23c0: 49 54 5f 49 4e 43 4c 55 44 45 53 5f 5a 4c 49 42 IT_INCLUDES_ZLIB
23d0: 0a 09 54 63 6c 5f 53 74 61 74 69 63 50 61 63 6b ..Tcl_StaticPack
23e0: 61 67 65 28 30 2c 20 22 7a 6c 69 62 22 2c 20 5a age(0, "zlib", Z
23f0: 6c 69 62 5f 49 6e 69 74 2c 20 4e 55 4c 4c 29 3b lib_Init, NULL);
2400: 0a 23 65 6e 64 69 66 0a 23 69 66 64 65 66 20 4b .#endif.#ifdef K
2410: 49 54 5f 53 54 4f 52 41 47 45 5f 43 56 46 53 0a IT_STORAGE_CVFS.
2420: 09 54 63 6c 5f 53 74 61 74 69 63 50 61 63 6b 61 .Tcl_StaticPacka
2430: 67 65 28 30 2c 20 22 63 76 66 73 5f 64 61 74 61 ge(0, "cvfs_data
2440: 5f 74 63 6c 22 2c 20 43 76 66 73 5f 64 61 74 61 _tcl", Cvfs_data
2450: 5f 74 63 6c 5f 49 6e 69 74 2c 20 4e 55 4c 4c 29 _tcl_Init, NULL)
2460: 3b 0a 23 65 6e 64 69 66 0a 23 69 66 64 65 66 20 ;.#endif.#ifdef
2470: 54 43 4c 5f 54 48 52 45 41 44 53 0a 09 54 63 6c TCL_THREADS..Tcl
2480: 5f 53 74 61 74 69 63 50 61 63 6b 61 67 65 28 30 _StaticPackage(0
2490: 2c 20 22 54 68 72 65 61 64 22 2c 20 54 68 72 65 , "Thread", Thre
24a0: 61 64 5f 49 6e 69 74 2c 20 4e 55 4c 4c 29 3b 0a ad_Init, NULL);.
24b0: 23 65 6e 64 69 66 0a 23 69 66 64 65 66 20 5f 57 #endif.#ifdef _W
24c0: 49 4e 33 32 0a 09 54 63 6c 5f 53 74 61 74 69 63 IN32..Tcl_Static
24d0: 50 61 63 6b 61 67 65 28 30 2c 20 22 64 64 65 22 Package(0, "dde"
24e0: 2c 20 44 64 65 5f 49 6e 69 74 2c 20 4e 55 4c 4c , Dde_Init, NULL
24f0: 29 3b 0a 09 54 63 6c 5f 53 74 61 74 69 63 50 61 );..Tcl_StaticPa
2500: 63 6b 61 67 65 28 30 2c 20 22 72 65 67 69 73 74 ckage(0, "regist
2510: 72 79 22 2c 20 52 65 67 69 73 74 72 79 5f 49 6e ry", Registry_In
2520: 69 74 2c 20 4e 55 4c 4c 29 3b 0a 23 65 6e 64 69 it, NULL);.#endi
2530: 66 0a 23 69 66 64 65 66 20 4b 49 54 5f 49 4e 43 f.#ifdef KIT_INC
2540: 4c 55 44 45 53 5f 54 4b 0a 09 54 63 6c 5f 53 74 LUDES_TK..Tcl_St
2550: 61 74 69 63 50 61 63 6b 61 67 65 28 30 2c 20 22 aticPackage(0, "
2560: 54 6b 22 2c 20 54 6b 5f 49 6e 69 74 2c 20 54 6b Tk", Tk_Init, Tk
2570: 5f 53 61 66 65 49 6e 69 74 29 3b 0a 23 65 6e 64 _SafeInit);.#end
2580: 69 66 0a 0a 09 5f 54 63 6c 6b 69 74 5f 47 65 6e if..._Tclkit_Gen
2590: 65 72 69 63 4c 69 62 5f 49 6e 69 74 28 29 3b 0a ericLib_Init();.
25a0: 0a 09 54 63 6c 53 65 74 50 72 65 49 6e 69 74 53 ..TclSetPreInitS
25b0: 63 72 69 70 74 28 70 72 65 49 6e 69 74 43 6d 64 cript(preInitCmd
25c0: 29 3b 0a 0a 09 72 65 74 75 72 6e 3b 0a 7d 0a 0a );...return;.}..
25d0: 73 74 61 74 69 63 20 76 6f 69 64 20 5f 54 63 6c static void _Tcl
25e0: 6b 69 74 5f 49 6e 74 65 72 70 5f 49 6e 69 74 28 kit_Interp_Init(
25f0: 54 63 6c 5f 49 6e 74 65 72 70 20 2a 69 6e 74 65 Tcl_Interp *inte
2600: 72 70 29 20 7b 0a 23 69 66 64 65 66 20 54 43 4c rp) {.#ifdef TCL
2610: 4b 49 54 5f 43 41 4e 5f 53 45 54 5f 45 4e 43 4f KIT_CAN_SET_ENCO
2620: 44 49 4e 47 0a 09 54 63 6c 5f 44 53 74 72 69 6e DING..Tcl_DStrin
2630: 67 20 65 6e 63 6f 64 69 6e 67 4e 61 6d 65 3b 0a g encodingName;.
2640: 23 65 6e 64 69 66 20 2f 2a 20 54 43 4c 4b 49 54 #endif /* TCLKIT
2650: 5f 43 41 4e 5f 53 45 54 5f 45 4e 43 4f 44 49 4e _CAN_SET_ENCODIN
2660: 47 20 2a 2f 0a 0a 23 69 66 6e 64 65 66 20 54 43 G */..#ifndef TC
2670: 4c 4b 49 54 5f 44 4c 4c 0a 09 2f 2a 20 74 68 65 LKIT_DLL../* the
2680: 20 74 63 6c 5f 72 63 46 69 6c 65 4e 61 6d 65 20 tcl_rcFileName
2690: 76 61 72 69 61 62 6c 65 20 6f 6e 6c 79 20 65 78 variable only ex
26a0: 69 73 74 73 20 69 6e 20 74 68 65 20 69 6e 69 74 ists in the init
26b0: 69 61 6c 20 69 6e 74 65 72 70 72 65 74 65 72 20 ial interpreter
26c0: 2a 2f 0a 23 20 20 69 66 64 65 66 20 5f 57 49 4e */.# ifdef _WIN
26d0: 33 32 0a 09 54 63 6c 5f 53 65 74 56 61 72 28 69 32..Tcl_SetVar(i
26e0: 6e 74 65 72 70 2c 20 22 74 63 6c 5f 72 63 46 69 nterp, "tcl_rcFi
26f0: 6c 65 4e 61 6d 65 22 2c 20 22 7e 2f 74 63 6c 6b leName", "~/tclk
2700: 69 74 72 63 2e 74 63 6c 22 2c 20 54 43 4c 5f 47 itrc.tcl", TCL_G
2710: 4c 4f 42 41 4c 5f 4f 4e 4c 59 29 3b 0a 23 20 20 LOBAL_ONLY);.#
2720: 65 6c 73 65 0a 09 54 63 6c 5f 53 65 74 56 61 72 else..Tcl_SetVar
2730: 28 69 6e 74 65 72 70 2c 20 22 74 63 6c 5f 72 63 (interp, "tcl_rc
2740: 46 69 6c 65 4e 61 6d 65 22 2c 20 22 7e 2f 2e 74 FileName", "~/.t
2750: 63 6c 6b 69 74 72 63 22 2c 20 54 43 4c 5f 47 4c clkitrc", TCL_GL
2760: 4f 42 41 4c 5f 4f 4e 4c 59 29 3b 0a 23 20 20 65 OBAL_ONLY);.# e
2770: 6e 64 69 66 20 2f 2a 20 5f 57 49 4e 33 32 20 2a ndif /* _WIN32 *
2780: 2f 0a 23 65 6e 64 69 66 20 2f 2a 20 21 54 43 4c /.#endif /* !TCL
2790: 4b 49 54 5f 44 4c 4c 20 2a 2f 0a 0a 23 69 66 64 KIT_DLL */..#ifd
27a0: 65 66 20 54 43 4c 4b 49 54 5f 43 41 4e 5f 53 45 ef TCLKIT_CAN_SE
27b0: 54 5f 45 4e 43 4f 44 49 4e 47 0a 09 2f 2a 20 53 T_ENCODING../* S
27c0: 65 74 20 74 68 65 20 65 6e 63 6f 64 69 6e 67 20 et the encoding
27d0: 66 72 6f 6d 20 74 68 65 20 45 6e 76 69 72 6f 6e from the Environ
27e0: 6d 65 6e 74 20 2a 2f 0a 09 54 63 6c 5f 47 65 74 ment */..Tcl_Get
27f0: 45 6e 63 6f 64 69 6e 67 4e 61 6d 65 46 72 6f 6d EncodingNameFrom
2800: 45 6e 76 69 72 6f 6e 6d 65 6e 74 28 26 65 6e 63 Environment(&enc
2810: 6f 64 69 6e 67 4e 61 6d 65 29 3b 0a 09 54 63 6c odingName);..Tcl
2820: 5f 53 65 74 53 79 73 74 65 6d 45 6e 63 6f 64 69 _SetSystemEncodi
2830: 6e 67 28 4e 55 4c 4c 2c 20 54 63 6c 5f 44 53 74 ng(NULL, Tcl_DSt
2840: 72 69 6e 67 56 61 6c 75 65 28 26 65 6e 63 6f 64 ringValue(&encod
2850: 69 6e 67 4e 61 6d 65 29 29 3b 0a 09 54 63 6c 5f ingName));..Tcl_
2860: 53 65 74 56 61 72 28 69 6e 74 65 72 70 2c 20 22 SetVar(interp, "
2870: 74 63 6c 6b 69 74 5f 73 79 73 74 65 6d 5f 65 6e tclkit_system_en
2880: 63 6f 64 69 6e 67 22 2c 20 54 63 6c 5f 44 53 74 coding", Tcl_DSt
2890: 72 69 6e 67 56 61 6c 75 65 28 26 65 6e 63 6f 64 ringValue(&encod
28a0: 69 6e 67 4e 61 6d 65 29 2c 20 30 29 3b 0a 09 54 ingName), 0);..T
28b0: 63 6c 5f 44 53 74 72 69 6e 67 46 72 65 65 28 26 cl_DStringFree(&
28c0: 65 6e 63 6f 64 69 6e 67 4e 61 6d 65 29 3b 0a 23 encodingName);.#
28d0: 65 6e 64 69 66 20 2f 2a 20 54 43 4c 4b 49 54 5f endif /* TCLKIT_
28e0: 43 41 4e 5f 53 45 54 5f 45 4e 43 4f 44 49 4e 47 CAN_SET_ENCODING
28f0: 20 2a 2f 0a 0a 09 2f 2a 20 48 61 63 6b 20 74 6f */.../* Hack to
2900: 20 67 65 74 20 61 72 6f 75 6e 64 20 54 63 6c 20 get around Tcl
2910: 62 75 67 20 31 32 32 34 38 38 38 2e 20 20 54 68 bug 1224888. Th
2920: 69 73 20 6d 75 73 74 20 62 65 20 72 75 6e 20 68 is must be run h
2930: 65 72 65 20 61 6e 64 0a 09 20 2a 20 69 6e 20 4c ere and.. * in L
2940: 69 62 72 61 72 79 50 61 74 68 4f 62 6a 43 6d 64 ibraryPathObjCmd
2950: 20 62 65 63 61 75 73 65 20 74 68 69 73 20 69 6e because this in
2960: 66 6f 72 6d 61 74 69 6f 6e 20 69 73 20 6e 65 65 formation is nee
2970: 64 65 64 20 62 6f 74 68 0a 09 20 2a 20 62 65 66 ded both.. * bef
2980: 6f 72 65 20 61 6e 64 20 61 66 74 65 72 20 74 68 ore and after th
2990: 61 74 20 63 6f 6d 6d 61 6e 64 20 69 73 20 72 75 at command is ru
29a0: 6e 2e 20 2a 2f 0a 09 46 69 6e 64 41 6e 64 53 65 n. */..FindAndSe
29b0: 74 45 78 65 63 4e 61 6d 65 28 69 6e 74 65 72 70 tExecName(interp
29c0: 29 3b 0a 0a 23 69 66 20 64 65 66 69 6e 65 64 28 );..#if defined(
29d0: 5f 57 49 4e 33 32 29 20 26 26 20 64 65 66 69 6e _WIN32) && defin
29e0: 65 64 28 4b 49 54 5f 49 4e 43 4c 55 44 45 53 5f ed(KIT_INCLUDES_
29f0: 54 4b 29 0a 09 2f 2a 20 45 76 65 72 79 20 69 6e TK)../* Every in
2a00: 74 65 72 70 72 65 74 65 72 20 6e 65 65 64 73 20 terpreter needs
2a10: 74 68 69 73 20 64 6f 6e 65 20 2a 2f 0a 09 54 6b this done */..Tk
2a20: 5f 49 6e 69 74 43 6f 6e 73 6f 6c 65 43 68 61 6e _InitConsoleChan
2a30: 6e 65 6c 73 28 69 6e 74 65 72 70 29 3b 0a 23 65 nels(interp);.#e
2a40: 6e 64 69 66 20 2f 2a 20 5f 57 49 4e 33 32 20 61 ndif /* _WIN32 a
2a50: 6e 64 20 4b 49 54 5f 49 4e 43 4c 55 44 45 53 5f nd KIT_INCLUDES_
2a60: 54 4b 20 2a 2f 0a 0a 09 72 65 74 75 72 6e 3b 0a TK */...return;.
2a70: 7d 0a 0a 23 69 66 6e 64 65 66 20 54 43 4c 4b 49 }..#ifndef TCLKI
2a80: 54 5f 44 4c 4c 0a 69 6e 74 20 54 63 6c 4b 69 74 T_DLL.int TclKit
2a90: 5f 41 70 70 49 6e 69 74 28 54 63 6c 5f 49 6e 74 _AppInit(Tcl_Int
2aa0: 65 72 70 20 2a 69 6e 74 65 72 70 29 20 7b 0a 23 erp *interp) {.#
2ab0: 69 66 64 65 66 20 4b 49 54 5f 49 4e 43 4c 55 44 ifdef KIT_INCLUD
2ac0: 45 53 5f 54 4b 0a 23 20 20 69 66 64 65 66 20 5f ES_TK.# ifdef _
2ad0: 57 49 4e 33 32 0a 23 20 20 20 20 69 66 6e 64 65 WIN32.# ifnde
2ae0: 66 20 5f 57 49 4e 33 32 5f 57 43 45 0a 09 63 68 f _WIN32_WCE..ch
2af0: 61 72 20 6d 73 67 42 75 66 5b 32 30 34 39 5d 3b ar msgBuf[2049];
2b00: 0a 23 20 20 20 20 65 6e 64 69 66 20 2f 2a 20 21 .# endif /* !
2b10: 5f 57 49 4e 33 32 5f 57 43 45 20 2a 2f 0a 23 20 _WIN32_WCE */.#
2b20: 20 65 6e 64 69 66 20 2f 2a 20 5f 57 49 4e 33 32 endif /* _WIN32
2b30: 20 2a 2f 0a 23 65 6e 64 69 66 20 2f 2a 20 4b 49 */.#endif /* KI
2b40: 54 5f 49 4e 43 4c 55 44 45 53 5f 54 4b 20 2a 2f T_INCLUDES_TK */
2b50: 0a 0a 09 2f 2a 20 50 65 72 66 6f 72 6d 20 63 6f .../* Perform co
2b60: 6d 6d 6f 6e 20 69 6e 69 74 69 61 6c 69 7a 61 74 mmon initializat
2b70: 69 6f 6e 20 2a 2f 0a 09 5f 54 63 6c 6b 69 74 5f ion */.._Tclkit_
2b80: 49 6e 69 74 28 29 3b 0a 0a 09 69 66 20 28 54 63 Init();...if (Tc
2b90: 6c 5f 49 6e 69 74 28 69 6e 74 65 72 70 29 20 3d l_Init(interp) =
2ba0: 3d 20 54 43 4c 5f 45 52 52 4f 52 29 20 7b 0a 09 = TCL_ERROR) {..
2bb0: 09 67 6f 74 6f 20 65 72 72 6f 72 3b 0a 09 7d 0a .goto error;..}.
2bc0: 0a 23 69 66 64 65 66 20 4b 49 54 5f 49 4e 43 4c .#ifdef KIT_INCL
2bd0: 55 44 45 53 5f 54 4b 0a 23 20 20 69 66 64 65 66 UDES_TK.# ifdef
2be0: 20 5f 57 49 4e 33 32 0a 09 69 66 20 28 54 6b 5f _WIN32..if (Tk_
2bf0: 49 6e 69 74 28 69 6e 74 65 72 70 29 20 3d 3d 20 Init(interp) ==
2c00: 54 43 4c 5f 45 52 52 4f 52 29 20 7b 0a 09 09 67 TCL_ERROR) {...g
2c10: 6f 74 6f 20 65 72 72 6f 72 3b 0a 09 7d 0a 09 69 oto error;..}..i
2c20: 66 20 28 54 6b 5f 43 72 65 61 74 65 43 6f 6e 73 f (Tk_CreateCons
2c30: 6f 6c 65 57 69 6e 64 6f 77 28 69 6e 74 65 72 70 oleWindow(interp
2c40: 29 20 3d 3d 20 54 43 4c 5f 45 52 52 4f 52 29 20 ) == TCL_ERROR)
2c50: 7b 0a 09 09 67 6f 74 6f 20 65 72 72 6f 72 3b 0a {...goto error;.
2c60: 09 7d 0a 23 20 20 65 6e 64 69 66 20 2f 2a 20 5f .}.# endif /* _
2c70: 57 49 4e 33 32 20 2a 2f 0a 23 65 6e 64 69 66 20 WIN32 */.#endif
2c80: 2f 2a 20 4b 49 54 5f 49 4e 43 4c 55 44 45 53 5f /* KIT_INCLUDES_
2c90: 54 4b 20 2a 2f 0a 0a 09 2f 2a 20 6d 65 73 73 79 TK */.../* messy
2ca0: 20 62 65 63 61 75 73 65 20 54 63 6c 53 65 74 53 because TclSetS
2cb0: 74 61 72 74 75 70 53 63 72 69 70 74 50 61 74 68 tartupScriptPath
2cc0: 20 69 73 20 63 61 6c 6c 65 64 20 73 6c 69 67 68 is called sligh
2cd0: 74 6c 79 20 74 6f 6f 20 6c 61 74 65 20 2a 2f 0a tly too late */.
2ce0: 09 69 66 20 28 54 63 6c 5f 45 76 61 6c 28 69 6e .if (Tcl_Eval(in
2cf0: 74 65 72 70 2c 20 69 6e 69 74 53 63 72 69 70 74 terp, initScript
2d00: 29 20 3d 3d 20 54 43 4c 5f 4f 4b 29 20 7b 0a 09 ) == TCL_OK) {..
2d10: 09 54 63 6c 5f 4f 62 6a 2a 20 70 61 74 68 3b 0a .Tcl_Obj* path;.
2d20: 23 69 66 64 65 66 20 48 41 56 45 5f 54 43 4c 53 #ifdef HAVE_TCLS
2d30: 45 54 53 54 41 52 54 55 50 53 43 52 49 50 54 50 ETSTARTUPSCRIPTP
2d40: 41 54 48 0a 09 09 70 61 74 68 20 3d 20 54 63 6c ATH...path = Tcl
2d50: 47 65 74 53 74 61 72 74 75 70 53 63 72 69 70 74 GetStartupScript
2d60: 50 61 74 68 28 29 3b 0a 09 09 54 63 6c 53 65 74 Path();...TclSet
2d70: 53 74 61 72 74 75 70 53 63 72 69 70 74 50 61 74 StartupScriptPat
2d80: 68 28 54 63 6c 5f 47 65 74 4f 62 6a 52 65 73 75 h(Tcl_GetObjResu
2d90: 6c 74 28 69 6e 74 65 72 70 29 29 3b 0a 23 65 6c lt(interp));.#el
2da0: 69 66 20 64 65 66 69 6e 65 64 28 48 41 56 45 5f if defined(HAVE_
2db0: 54 43 4c 5f 53 45 54 53 54 41 52 54 55 50 53 43 TCL_SETSTARTUPSC
2dc0: 52 49 50 54 29 0a 09 09 70 61 74 68 20 3d 20 54 RIPT)...path = T
2dd0: 63 6c 5f 47 65 74 53 74 61 72 74 75 70 53 63 72 cl_GetStartupScr
2de0: 69 70 74 28 4e 55 4c 4c 29 3b 0a 09 09 54 63 6c ipt(NULL);...Tcl
2df0: 5f 53 65 74 53 74 61 72 74 75 70 53 63 72 69 70 _SetStartupScrip
2e00: 74 28 54 63 6c 5f 47 65 74 4f 62 6a 52 65 73 75 t(Tcl_GetObjResu
2e10: 6c 74 28 69 6e 74 65 72 70 29 2c 20 4e 55 4c 4c lt(interp), NULL
2e20: 29 3b 0a 23 65 6e 64 69 66 0a 09 09 69 66 20 28 );.#endif...if (
2e30: 70 61 74 68 20 3d 3d 20 4e 55 4c 4c 29 20 7b 0a path == NULL) {.
2e40: 09 09 09 54 63 6c 5f 45 76 61 6c 28 69 6e 74 65 ...Tcl_Eval(inte
2e50: 72 70 2c 20 22 69 6e 63 72 20 61 72 67 63 20 2d rp, "incr argc -
2e60: 31 3b 20 73 65 74 20 61 72 67 76 20 5b 6c 72 61 1; set argv [lra
2e70: 6e 67 65 20 24 61 72 67 76 20 31 20 65 6e 64 5d nge $argv 1 end]
2e80: 22 29 3b 0a 09 09 7d 0a 09 7d 0a 0a 09 54 63 6c ");...}..}...Tcl
2e90: 5f 53 65 74 56 61 72 28 69 6e 74 65 72 70 2c 20 _SetVar(interp,
2ea0: 22 65 72 72 6f 72 49 6e 66 6f 22 2c 20 22 22 2c "errorInfo", "",
2eb0: 20 54 43 4c 5f 47 4c 4f 42 41 4c 5f 4f 4e 4c 59 TCL_GLOBAL_ONLY
2ec0: 29 3b 0a 09 54 63 6c 5f 52 65 73 65 74 52 65 73 );..Tcl_ResetRes
2ed0: 75 6c 74 28 69 6e 74 65 72 70 29 3b 0a 0a 09 72 ult(interp);...r
2ee0: 65 74 75 72 6e 20 54 43 4c 5f 4f 4b 3b 0a 0a 65 eturn TCL_OK;..e
2ef0: 72 72 6f 72 3a 0a 23 69 66 64 65 66 20 4b 49 54 rror:.#ifdef KIT
2f00: 5f 49 4e 43 4c 55 44 45 53 5f 54 4b 0a 23 20 20 _INCLUDES_TK.#
2f10: 69 66 64 65 66 20 5f 57 49 4e 33 32 0a 09 4d 65 ifdef _WIN32..Me
2f20: 73 73 61 67 65 42 65 65 70 28 4d 42 5f 49 43 4f ssageBeep(MB_ICO
2f30: 4e 45 58 43 4c 41 4d 41 54 49 4f 4e 29 3b 0a 23 NEXCLAMATION);.#
2f40: 20 20 20 20 69 66 6e 64 65 66 20 5f 57 49 4e 33 ifndef _WIN3
2f50: 32 5f 57 43 45 0a 09 73 6e 70 72 69 6e 74 66 28 2_WCE..snprintf(
2f60: 6d 73 67 42 75 66 2c 20 73 69 7a 65 6f 66 28 6d msgBuf, sizeof(m
2f70: 73 67 42 75 66 29 2c 0a 09 09 22 41 20 63 72 69 sgBuf),..."A cri
2f80: 74 69 63 61 6c 20 65 72 72 6f 72 20 68 61 73 20 tical error has
2f90: 6f 63 63 75 72 72 65 64 2e 20 20 50 6c 65 61 73 occurred. Pleas
2fa0: 65 20 72 65 70 6f 72 74 20 74 68 69 73 20 74 6f e report this to
2fb0: 20 74 68 65 20 54 63 6c 6b 69 74 20 76 65 6e 64 the Tclkit vend
2fc0: 6f 72 2e 5c 6e 49 6e 74 65 72 70 72 65 74 65 72 or.\nInterpreter
2fd0: 20 52 65 74 75 72 6e 65 64 3a 20 25 73 5c 6e 45 Returned: %s\nE
2fe0: 72 72 6f 72 20 49 6e 66 6f 3a 20 25 73 22 2c 0a rror Info: %s",.
2ff0: 09 09 54 63 6c 5f 47 65 74 53 74 72 69 6e 67 52 ..Tcl_GetStringR
3000: 65 73 75 6c 74 28 69 6e 74 65 72 70 29 2c 0a 09 esult(interp),..
3010: 09 54 63 6c 5f 47 65 74 56 61 72 28 69 6e 74 65 .Tcl_GetVar(inte
3020: 72 70 2c 20 22 65 72 72 6f 72 49 6e 66 6f 22 2c rp, "errorInfo",
3030: 20 54 43 4c 5f 47 4c 4f 42 41 4c 5f 4f 4e 4c 59 TCL_GLOBAL_ONLY
3040: 29 29 3b 0a 0a 09 4d 65 73 73 61 67 65 42 6f 78 ));...MessageBox
3050: 28 4e 55 4c 4c 2c 20 6d 73 67 42 75 66 2c 20 22 (NULL, msgBuf, "
3060: 45 72 72 6f 72 20 69 6e 20 54 63 6c 4b 69 74 22 Error in TclKit"
3070: 2c 0a 09 09 4d 42 5f 49 43 4f 4e 53 54 4f 50 20 ,...MB_ICONSTOP
3080: 7c 20 4d 42 5f 4f 4b 20 7c 20 4d 42 5f 54 41 53 | MB_OK | MB_TAS
3090: 4b 4d 4f 44 41 4c 20 7c 20 4d 42 5f 53 45 54 46 KMODAL | MB_SETF
30a0: 4f 52 45 47 52 4f 55 4e 44 29 3b 0a 0a 09 45 78 OREGROUND);...Ex
30b0: 69 74 50 72 6f 63 65 73 73 28 31 29 3b 0a 23 20 itProcess(1);.#
30c0: 20 20 20 65 6e 64 69 66 20 2f 2a 20 21 5f 57 49 endif /* !_WI
30d0: 4e 33 32 5f 57 43 45 20 2a 2f 0a 20 20 20 20 2f N32_WCE */. /
30e0: 2a 20 77 65 20 77 6f 6e 27 74 20 72 65 61 63 68 * we won't reach
30f0: 20 74 68 69 73 2c 20 62 75 74 20 77 65 20 6e 65 this, but we ne
3100: 65 64 20 74 68 65 20 72 65 74 75 72 6e 20 2a 2f ed the return */
3110: 0a 23 20 20 65 6e 64 69 66 20 2f 2a 20 5f 57 49 .# endif /* _WI
3120: 4e 33 32 20 2a 2f 0a 23 65 6e 64 69 66 20 2f 2a N32 */.#endif /*
3130: 20 4b 49 54 5f 49 4e 43 4c 55 44 45 53 5f 54 4b KIT_INCLUDES_TK
3140: 20 2a 2f 0a 0a 09 72 65 74 75 72 6e 20 54 43 4c */...return TCL
3150: 5f 45 52 52 4f 52 3b 0a 7d 0a 23 65 6e 64 69 66 _ERROR;.}.#endif
3160: 20 2f 2a 20 21 54 43 4c 4b 49 54 5f 44 4c 4c 20 /* !TCLKIT_DLL
3170: 2a 2f 0a 0a 0a 23 69 66 64 65 66 20 54 43 4c 4b */...#ifdef TCLK
3180: 49 54 5f 44 4c 4c 0a 23 20 20 69 66 64 65 66 20 IT_DLL.# ifdef
3190: 48 41 56 45 5f 41 43 43 45 50 54 41 42 4c 45 5f HAVE_ACCEPTABLE_
31a0: 44 4c 41 44 44 52 0a 2f 2a 20 53 79 6d 62 6f 6c DLADDR./* Symbol
31b0: 20 74 6f 20 72 65 73 6f 6c 76 65 20 61 67 61 69 to resolve agai
31c0: 6e 73 74 20 64 6c 61 64 64 72 28 29 20 2a 2f 0a nst dladdr() */.
31d0: 73 74 61 74 69 63 20 76 6f 69 64 20 5f 74 63 6c static void _tcl
31e0: 6b 69 74 5f 64 75 6d 6d 79 5f 66 75 6e 63 28 76 kit_dummy_func(v
31f0: 6f 69 64 29 20 7b 0a 09 72 65 74 75 72 6e 3b 0a oid) {..return;.
3200: 7d 0a 23 20 20 65 6e 64 69 66 20 2f 2a 20 48 41 }.# endif /* HA
3210: 56 45 5f 41 43 43 45 50 54 41 42 4c 45 5f 44 4c VE_ACCEPTABLE_DL
3220: 41 44 44 52 20 2a 2f 0a 0a 2f 2a 0a 20 2a 20 54 ADDR */../*. * T
3230: 68 69 73 20 66 75 6e 63 74 69 6f 6e 20 77 69 6c his function wil
3240: 6c 20 72 65 74 75 72 6e 20 61 20 70 61 74 68 6e l return a pathn
3250: 61 6d 65 20 77 65 20 63 61 6e 20 6f 70 65 6e 28 ame we can open(
3260: 29 20 74 6f 20 74 72 65 61 74 20 61 73 20 61 20 ) to treat as a
3270: 56 46 53 2c 0a 20 2a 20 68 6f 70 65 66 75 6c 6c VFS,. * hopefull
3280: 79 0a 20 2a 2f 0a 73 74 61 74 69 63 20 63 68 61 y. */.static cha
3290: 72 20 2a 66 69 6e 64 5f 74 63 6c 6b 69 74 5f 64 r *find_tclkit_d
32a0: 6c 6c 5f 70 61 74 68 28 76 6f 69 64 29 20 7b 0a ll_path(void) {.
32b0: 23 69 66 64 65 66 20 48 41 56 45 5f 41 43 43 45 #ifdef HAVE_ACCE
32c0: 50 54 41 42 4c 45 5f 44 4c 41 44 44 52 0a 09 44 PTABLE_DLADDR..D
32d0: 6c 5f 69 6e 66 6f 20 73 79 6d 69 6e 66 6f 3b 0a l_info syminfo;.
32e0: 09 69 6e 74 20 64 6c 61 64 64 72 5f 72 65 74 3b .int dladdr_ret;
32f0: 0a 23 65 6e 64 69 66 20 2f 2a 20 48 41 56 45 5f .#endif /* HAVE_
3300: 41 43 43 45 50 54 41 42 4c 45 5f 44 4c 41 44 44 ACCEPTABLE_DLADD
3310: 52 20 2a 2f 0a 23 69 66 64 65 66 20 5f 57 49 4e R */.#ifdef _WIN
3320: 33 32 0a 09 54 43 48 41 52 20 6d 6f 64 75 6c 65 32..TCHAR module
3330: 6e 61 6d 65 5b 38 31 39 32 5d 3b 0a 09 44 57 4f name[8192];..DWO
3340: 52 44 20 67 6d 66 6e 5f 72 65 74 3b 0a 23 65 6e RD gmfn_ret;.#en
3350: 64 69 66 20 2f 2a 20 5f 57 49 4e 33 32 20 2a 2f dif /* _WIN32 */
3360: 0a 0a 23 69 66 64 65 66 20 48 41 56 45 5f 41 43 ..#ifdef HAVE_AC
3370: 43 45 50 54 41 42 4c 45 5f 44 4c 41 44 44 52 0a CEPTABLE_DLADDR.
3380: 09 64 6c 61 64 64 72 5f 72 65 74 20 3d 20 64 6c .dladdr_ret = dl
3390: 61 64 64 72 28 26 5f 74 63 6c 6b 69 74 5f 64 75 addr(&_tclkit_du
33a0: 6d 6d 79 5f 66 75 6e 63 2c 20 26 73 79 6d 69 6e mmy_func, &symin
33b0: 66 6f 29 3b 0a 09 69 66 20 28 64 6c 61 64 64 72 fo);..if (dladdr
33c0: 5f 72 65 74 20 21 3d 20 30 29 20 7b 0a 09 09 69 _ret != 0) {...i
33d0: 66 20 28 73 79 6d 69 6e 66 6f 2e 64 6c 69 5f 66 f (syminfo.dli_f
33e0: 6e 61 6d 65 20 26 26 20 73 79 6d 69 6e 66 6f 2e name && syminfo.
33f0: 64 6c 69 5f 66 6e 61 6d 65 5b 30 5d 20 21 3d 20 dli_fname[0] !=
3400: 27 5c 30 27 29 20 7b 0a 09 09 09 72 65 74 75 72 '\0') {....retur
3410: 6e 28 73 74 72 64 75 70 28 73 79 6d 69 6e 66 6f n(strdup(syminfo
3420: 2e 64 6c 69 5f 66 6e 61 6d 65 29 29 3b 0a 09 09 .dli_fname));...
3430: 7d 0a 09 7d 0a 23 65 6e 64 69 66 20 2f 2a 20 48 }..}.#endif /* H
3440: 41 56 45 5f 41 43 43 45 50 54 41 42 4c 45 5f 44 AVE_ACCEPTABLE_D
3450: 4c 41 44 44 52 20 2a 2f 0a 0a 23 69 66 64 65 66 LADDR */..#ifdef
3460: 20 5f 57 49 4e 33 32 0a 09 67 6d 66 6e 5f 72 65 _WIN32..gmfn_re
3470: 74 20 3d 20 47 65 74 4d 6f 64 75 6c 65 46 69 6c t = GetModuleFil
3480: 65 4e 61 6d 65 28 54 63 6c 57 69 6e 47 65 74 54 eName(TclWinGetT
3490: 63 6c 49 6e 73 74 61 6e 63 65 28 29 2c 20 6d 6f clInstance(), mo
34a0: 64 75 6c 65 6e 61 6d 65 2c 20 73 69 7a 65 6f 66 dulename, sizeof
34b0: 28 6d 6f 64 75 6c 65 6e 61 6d 65 29 20 2f 20 73 (modulename) / s
34c0: 69 7a 65 6f 66 28 6d 6f 64 75 6c 65 6e 61 6d 65 izeof(modulename
34d0: 5b 30 5d 29 20 2d 20 31 29 3b 0a 0a 09 69 66 20 [0]) - 1);...if
34e0: 28 67 6d 66 6e 5f 72 65 74 20 21 3d 20 30 29 20 (gmfn_ret != 0)
34f0: 7b 0a 09 09 72 65 74 75 72 6e 28 73 74 72 64 75 {...return(strdu
3500: 70 28 6d 6f 64 75 6c 65 6e 61 6d 65 29 29 3b 0a p(modulename));.
3510: 09 7d 0a 23 65 6e 64 69 66 20 2f 2a 20 5f 57 49 .}.#endif /* _WI
3520: 4e 33 32 20 2a 2f 0a 0a 09 72 65 74 75 72 6e 28 N32 */...return(
3530: 4e 55 4c 4c 29 3b 0a 7d 0a 23 65 6c 73 65 0a 23 NULL);.}.#else.#
3540: 20 64 65 66 69 6e 65 20 66 69 6e 64 5f 74 63 6c define find_tcl
3550: 6b 69 74 5f 64 6c 6c 5f 70 61 74 68 28 29 20 4e kit_dll_path() N
3560: 55 4c 4c 0a 23 65 6e 64 69 66 0a 0a 2f 2a 0a 20 ULL.#endif../*.
3570: 2a 20 54 68 69 73 20 66 75 6e 63 74 69 6f 6e 20 * This function
3580: 65 78 69 73 74 73 20 74 6f 20 61 6c 6c 6f 77 20 exists to allow
3590: 43 20 63 6f 64 65 20 74 6f 20 69 6e 69 74 69 61 C code to initia
35a0: 6c 69 7a 65 20 61 20 70 61 72 74 69 63 75 6c 61 lize a particula
35b0: 72 0a 20 2a 20 69 6e 74 65 72 70 72 65 74 65 72 r. * interpreter
35c0: 2e 0a 20 2a 2f 0a 73 74 61 74 69 63 20 69 6e 74 .. */.static int
35d0: 20 74 63 6c 6b 69 74 5f 69 6e 69 74 5f 69 6e 69 tclkit_init_ini
35e0: 74 69 6e 74 65 72 70 28 43 6c 69 65 6e 74 44 61 tinterp(ClientDa
35f0: 74 61 20 63 64 2c 20 54 63 6c 5f 49 6e 74 65 72 ta cd, Tcl_Inter
3600: 70 20 2a 69 6e 74 65 72 70 2c 20 69 6e 74 20 6f p *interp, int o
3610: 62 6a 63 2c 20 54 63 6c 5f 4f 62 6a 20 2a 43 4f bjc, Tcl_Obj *CO
3620: 4e 53 54 20 6f 62 6a 76 5b 5d 29 20 7b 0a 09 63 NST objv[]) {..c
3630: 68 61 72 20 2a 6b 69 74 64 6c 6c 5f 70 61 74 68 har *kitdll_path
3640: 3b 0a 0a 09 6b 69 74 64 6c 6c 5f 70 61 74 68 20 ;...kitdll_path
3650: 3d 20 66 69 6e 64 5f 74 63 6c 6b 69 74 5f 64 6c = find_tclkit_dl
3660: 6c 5f 70 61 74 68 28 29 3b 0a 09 69 66 20 28 6b l_path();..if (k
3670: 69 74 64 6c 6c 5f 70 61 74 68 20 21 3d 20 4e 55 itdll_path != NU
3680: 4c 4c 29 20 7b 0a 09 09 54 63 6c 5f 53 65 74 56 LL) {...Tcl_SetV
3690: 61 72 28 69 6e 74 65 72 70 2c 20 22 74 63 6c 4b ar(interp, "tclK
36a0: 69 74 46 69 6c 65 6e 61 6d 65 22 2c 20 6b 69 74 itFilename", kit
36b0: 64 6c 6c 5f 70 61 74 68 2c 20 54 43 4c 5f 47 4c dll_path, TCL_GL
36c0: 4f 42 41 4c 5f 4f 4e 4c 59 29 3b 0a 0a 09 09 66 OBAL_ONLY);....f
36d0: 72 65 65 28 6b 69 74 64 6c 6c 5f 70 61 74 68 29 ree(kitdll_path)
36e0: 3b 0a 09 7d 0a 0a 09 5f 54 63 6c 6b 69 74 5f 49 ;..}..._Tclkit_I
36f0: 6e 74 65 72 70 5f 49 6e 69 74 28 69 6e 74 65 72 nterp_Init(inter
3700: 70 29 3b 0a 0a 09 72 65 74 75 72 6e 28 54 43 4c p);...return(TCL
3710: 5f 4f 4b 29 3b 0a 7d 0a 0a 2f 2a 0a 20 2a 20 43 _OK);.}../*. * C
3720: 72 65 61 74 65 20 61 20 70 61 63 6b 61 67 65 20 reate a package
3730: 66 6f 72 20 69 6e 69 74 69 61 6c 69 7a 69 6e 67 for initializing
3740: 20 61 20 70 61 72 74 69 63 75 6c 61 72 20 69 6e a particular in
3750: 74 65 72 70 72 65 74 65 72 2e 20 20 54 68 69 73 terpreter. This
3760: 20 69 73 0a 20 2a 20 6f 75 72 20 68 6f 6f 6b 20 is. * our hook
3770: 74 6f 20 68 61 76 65 20 54 63 6c 20 69 6e 76 6f to have Tcl invo
3780: 6b 65 20 43 20 63 6f 6d 6d 61 6e 64 73 20 77 68 ke C commands wh
3790: 65 6e 20 63 72 65 61 74 69 6e 67 20 61 6e 20 69 en creating an i
37a0: 6e 74 65 72 70 72 65 74 65 72 2e 0a 20 2a 20 54 nterpreter.. * T
37b0: 68 65 20 70 72 65 49 6e 69 74 43 6d 64 20 77 69 he preInitCmd wi
37c0: 6c 6c 20 6c 6f 61 64 20 74 68 65 20 70 61 63 6b ll load the pack
37d0: 61 67 65 20 69 6e 20 74 68 65 20 6e 65 77 20 69 age in the new i
37e0: 6e 74 65 72 70 72 65 74 65 72 20 61 6e 64 20 69 nterpreter and i
37f0: 6e 76 6f 6b 65 0a 20 2a 20 74 68 69 73 20 66 75 nvoke. * this fu
3800: 6e 63 74 69 6f 6e 2e 0a 20 2a 2f 0a 69 6e 74 20 nction.. */.int
3810: 54 63 6c 6b 69 74 5f 69 6e 69 74 5f 49 6e 69 74 Tclkit_init_Init
3820: 28 54 63 6c 5f 49 6e 74 65 72 70 20 2a 69 6e 74 (Tcl_Interp *int
3830: 65 72 70 29 20 7b 0a 09 54 63 6c 5f 43 6f 6d 6d erp) {..Tcl_Comm
3840: 61 6e 64 20 74 63 6c 43 72 65 61 74 43 6f 6d 6d and tclCreatComm
3850: 5f 72 65 74 3b 0a 09 69 6e 74 20 74 63 6c 50 6b _ret;..int tclPk
3860: 67 50 72 6f 76 5f 72 65 74 3b 0a 0a 09 74 63 6c gProv_ret;...tcl
3870: 43 72 65 61 74 43 6f 6d 6d 5f 72 65 74 20 3d 20 CreatComm_ret =
3880: 54 63 6c 5f 43 72 65 61 74 65 4f 62 6a 43 6f 6d Tcl_CreateObjCom
3890: 6d 61 6e 64 28 69 6e 74 65 72 70 2c 20 22 3a 3a mand(interp, "::
38a0: 74 63 6c 6b 69 74 3a 3a 69 6e 69 74 3a 3a 69 6e tclkit::init::in
38b0: 69 74 49 6e 74 65 72 70 22 2c 20 74 63 6c 6b 69 itInterp", tclki
38c0: 74 5f 69 6e 69 74 5f 69 6e 69 74 69 6e 74 65 72 t_init_initinter
38d0: 70 2c 20 4e 55 4c 4c 2c 20 4e 55 4c 4c 29 3b 0a p, NULL, NULL);.
38e0: 09 69 66 20 28 21 74 63 6c 43 72 65 61 74 43 6f .if (!tclCreatCo
38f0: 6d 6d 5f 72 65 74 29 20 7b 0a 09 09 72 65 74 75 mm_ret) {...retu
3900: 72 6e 28 54 43 4c 5f 45 52 52 4f 52 29 3b 0a 09 rn(TCL_ERROR);..
3910: 7d 0a 0a 09 74 63 6c 50 6b 67 50 72 6f 76 5f 72 }...tclPkgProv_r
3920: 65 74 20 3d 20 54 63 6c 5f 50 6b 67 50 72 6f 76 et = Tcl_PkgProv
3930: 69 64 65 28 69 6e 74 65 72 70 2c 20 22 74 63 6c ide(interp, "tcl
3940: 6b 69 74 3a 3a 69 6e 69 74 22 2c 20 22 31 2e 30 kit::init", "1.0
3950: 22 29 3b 0a 0a 09 72 65 74 75 72 6e 28 74 63 6c ");...return(tcl
3960: 50 6b 67 50 72 6f 76 5f 72 65 74 29 3b 0a 7d 0a PkgProv_ret);.}.
3970: 0a 2f 2a 0a 20 2a 20 49 6e 69 74 69 61 6c 69 7a ./*. * Initializ
3980: 65 20 74 68 65 20 54 63 6c 20 73 79 73 74 65 6d e the Tcl system
3990: 20 77 68 65 6e 20 77 65 20 61 72 65 20 6c 6f 61 when we are loa
39a0: 64 65 64 2c 20 74 68 61 74 20 77 61 79 20 54 63 ded, that way Tc
39b0: 6c 20 66 75 6e 63 74 69 6f 6e 73 0a 20 2a 20 61 l functions. * a
39c0: 72 65 20 72 65 61 64 79 20 74 6f 20 62 65 20 75 re ready to be u
39d0: 73 65 64 20 77 68 65 6e 20 69 6e 76 6f 6b 65 64 sed when invoked
39e0: 2e 0a 20 2a 2f 0a 23 69 66 64 65 66 20 54 43 4c .. */.#ifdef TCL
39f0: 4b 49 54 5f 44 4c 4c 0a 76 6f 69 64 20 5f 5f 61 KIT_DLL.void __a
3a00: 74 74 72 69 62 75 74 65 5f 5f 28 28 63 6f 6e 73 ttribute__((cons
3a10: 74 72 75 63 74 6f 72 29 29 20 5f 54 63 6c 6b 69 tructor)) _Tclki
3a20: 74 5f 49 6e 69 74 28 76 6f 69 64 29 20 7b 0a 23 t_Init(void) {.#
3a30: 65 6c 73 65 0a 73 74 61 74 69 63 20 76 6f 69 64 else.static void
3a40: 20 5f 54 63 6c 6b 69 74 5f 49 6e 69 74 28 76 6f _Tclkit_Init(vo
3a50: 69 64 29 20 7b 0a 23 65 6e 64 69 66 0a 09 73 74 id) {.#endif..st
3a60: 61 74 69 63 20 69 6e 74 20 63 61 6c 6c 65 64 20 atic int called
3a70: 3d 20 30 3b 0a 0a 09 69 66 20 28 63 61 6c 6c 65 = 0;...if (calle
3a80: 64 29 20 7b 0a 09 09 72 65 74 75 72 6e 3b 0a 09 d) {...return;..
3a90: 7d 0a 0a 09 63 61 6c 6c 65 64 20 3d 20 31 3b 0a }...called = 1;.
3aa0: 0a 09 54 63 6c 5f 53 74 61 74 69 63 50 61 63 6b ..Tcl_StaticPack
3ab0: 61 67 65 28 30 2c 20 22 74 63 6c 6b 69 74 3a 3a age(0, "tclkit::
3ac0: 69 6e 69 74 22 2c 20 54 63 6c 6b 69 74 5f 69 6e init", Tclkit_in
3ad0: 69 74 5f 49 6e 69 74 2c 20 4e 55 4c 4c 29 3b 0a it_Init, NULL);.
3ae0: 0a 09 5f 54 63 6c 6b 69 74 5f 47 65 6e 65 72 69 .._Tclkit_Generi
3af0: 63 5f 49 6e 69 74 28 29 3b 0a 0a 09 72 65 74 75 c_Init();...retu
3b00: 72 6e 3b 0a 7d 0a 0a 23 69 66 20 64 65 66 69 6e rn;.}..#if defin
3b10: 65 64 28 54 43 4c 4b 49 54 5f 44 4c 4c 29 20 26 ed(TCLKIT_DLL) &
3b20: 26 20 64 65 66 69 6e 65 64 28 54 43 4c 4b 49 54 & defined(TCLKIT
3b30: 5f 44 4c 4c 5f 53 54 41 54 49 43 29 0a 69 6e 74 _DLL_STATIC).int
3b40: 20 54 63 6c 5f 49 6e 69 74 52 65 61 6c 28 54 63 Tcl_InitReal(Tc
3b50: 6c 5f 49 6e 74 65 72 70 20 2a 69 6e 74 65 72 70 l_Interp *interp
3b60: 29 3b 0a 0a 69 6e 74 20 54 63 6c 5f 49 6e 69 74 );..int Tcl_Init
3b70: 28 54 63 6c 5f 49 6e 74 65 72 70 20 2a 69 6e 74 (Tcl_Interp *int
3b80: 65 72 70 29 20 7b 0a 09 5f 54 63 6c 6b 69 74 5f erp) {.._Tclkit_
3b90: 49 6e 69 74 28 29 3b 0a 0a 09 72 65 74 75 72 6e Init();...return
3ba0: 28 54 63 6c 5f 49 6e 69 74 52 65 61 6c 28 69 6e (Tcl_InitReal(in
3bb0: 74 65 72 70 29 29 3b 0a 7d 0a 23 65 6e 64 69 66 terp));.}.#endif
3bc0: 0a .