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 64 65 66 69 6e 65 20 54 43 lse.# define TC
0810: 4c 4b 49 54 5f 4d 4f 55 4e 54 50 4f 49 4e 54 20 LKIT_MOUNTPOINT
0820: 22 5b 69 6e 66 6f 20 6e 61 6d 65 6f 66 65 78 65 "[info nameofexe
0830: 63 75 74 61 62 6c 65 5d 22 0a 23 20 20 64 65 66 cutable]".# def
0840: 69 6e 65 20 54 43 4c 4b 49 54 5f 56 46 53 53 4f ine TCLKIT_VFSSO
0850: 55 52 43 45 20 22 5b 69 6e 66 6f 20 6e 61 6d 65 URCE "[info name
0860: 6f 66 65 78 65 63 75 74 61 62 6c 65 5d 22 0a 23 ofexecutable]".#
0870: 65 6e 64 69 66 20 2f 2a 20 54 43 4c 4b 49 54 5f endif /* TCLKIT_
0880: 44 4c 4c 20 2a 2f 0a 0a 23 69 66 6e 64 65 66 20 DLL */..#ifndef
0890: 54 43 4c 4b 49 54 5f 44 4c 4c 0a 23 20 20 69 66 TCLKIT_DLL.# if
08a0: 64 65 66 20 48 41 56 45 5f 41 43 43 45 50 54 41 def HAVE_ACCEPTA
08b0: 42 4c 45 5f 44 4c 41 44 44 52 0a 23 20 20 20 20 BLE_DLADDR.#
08c0: 69 66 64 65 66 20 4b 49 54 53 48 5f 4e 45 45 44 ifdef KITSH_NEED
08d0: 5f 57 49 4e 4d 41 49 4e 0a 23 20 20 20 20 20 20 _WINMAIN.#
08e0: 69 66 64 65 66 20 5f 57 49 4e 33 32 5f 57 43 45 ifdef _WIN32_WCE
08f0: 0a 69 6e 74 20 77 57 69 6e 4d 61 69 6e 28 48 49 .int wWinMain(HI
0900: 4e 53 54 41 4e 43 45 20 68 49 6e 73 74 61 6e 63 NSTANCE hInstanc
0910: 65 2c 20 48 49 4e 53 54 41 4e 43 45 20 68 50 72 e, HINSTANCE hPr
0920: 65 76 49 6e 73 74 61 6e 63 65 2c 20 4c 50 53 54 evInstance, LPST
0930: 52 20 6c 70 73 7a 43 6d 64 4c 69 6e 65 2c 20 69 R lpszCmdLine, i
0940: 6e 74 20 6e 43 6d 64 53 68 6f 77 29 3b 0a 23 20 nt nCmdShow);.#
0950: 20 20 20 20 20 65 6c 73 65 0a 69 6e 74 20 57 69 else.int Wi
0960: 6e 4d 61 69 6e 28 48 49 4e 53 54 41 4e 43 45 20 nMain(HINSTANCE
0970: 68 49 6e 73 74 61 6e 63 65 2c 20 48 49 4e 53 54 hInstance, HINST
0980: 41 4e 43 45 20 68 50 72 65 76 49 6e 73 74 61 6e ANCE hPrevInstan
0990: 63 65 2c 20 4c 50 53 54 52 20 6c 70 73 7a 43 6d ce, LPSTR lpszCm
09a0: 64 4c 69 6e 65 2c 20 69 6e 74 20 6e 43 6d 64 53 dLine, int nCmdS
09b0: 68 6f 77 29 3b 0a 23 20 20 20 20 20 20 65 6e 64 how);.# end
09c0: 69 66 20 2f 2a 20 5f 57 49 4e 33 32 5f 57 43 45 if /* _WIN32_WCE
09d0: 20 2a 2f 0a 23 20 20 20 20 65 6e 64 69 66 20 2f */.# endif /
09e0: 2a 20 4b 49 54 53 48 5f 4e 45 45 44 5f 57 49 4e * KITSH_NEED_WIN
09f0: 4d 41 49 4e 20 2a 2f 0a 69 6e 74 20 6d 61 69 6e MAIN */.int main
0a00: 28 69 6e 74 20 61 72 67 63 2c 20 63 68 61 72 20 (int argc, char
0a10: 2a 2a 61 72 67 76 29 3b 0a 23 20 20 65 6e 64 69 **argv);.# endi
0a20: 66 20 2f 2a 20 48 41 56 45 5f 41 43 43 45 50 54 f /* HAVE_ACCEPT
0a30: 41 42 4c 45 5f 44 4c 41 44 44 52 20 2a 2f 0a 23 ABLE_DLADDR */.#
0a40: 65 6e 64 69 66 20 2f 2a 20 21 54 43 4c 4b 49 54 endif /* !TCLKIT
0a50: 5f 44 4c 4c 20 2a 2f 0a 0a 23 69 66 64 65 66 20 _DLL */..#ifdef
0a60: 54 43 4c 4b 49 54 5f 44 4c 4c 0a 76 6f 69 64 20 TCLKIT_DLL.void
0a70: 5f 5f 61 74 74 72 69 62 75 74 65 5f 5f 28 28 63 __attribute__((c
0a80: 6f 6e 73 74 72 75 63 74 6f 72 29 29 20 5f 54 63 onstructor)) _Tc
0a90: 6c 6b 69 74 5f 49 6e 69 74 28 76 6f 69 64 29 3b lkit_Init(void);
0aa0: 0a 23 65 6c 73 65 0a 73 74 61 74 69 63 20 76 6f .#else.static vo
0ab0: 69 64 20 5f 54 63 6c 6b 69 74 5f 49 6e 69 74 28 id _Tclkit_Init(
0ac0: 76 6f 69 64 29 3b 0a 23 65 6e 64 69 66 0a 0a 23 void);.#endif..#
0ad0: 69 66 64 65 66 20 54 43 4c 4b 49 54 5f 52 45 51 ifdef TCLKIT_REQ
0ae0: 55 49 52 45 5f 54 43 4c 45 58 45 43 55 54 41 42 UIRE_TCLEXECUTAB
0af0: 4c 45 4e 41 4d 45 0a 63 68 61 72 20 2a 74 63 6c LENAME.char *tcl
0b00: 45 78 65 63 75 74 61 62 6c 65 4e 61 6d 65 3b 0a ExecutableName;.
0b10: 23 65 6e 64 69 66 0a 0a 2f 2a 0a 20 2a 20 20 41 #endif../*. * A
0b20: 74 74 65 6d 70 74 20 74 6f 20 6c 6f 61 64 20 61 ttempt to load a
0b30: 20 22 62 6f 6f 74 2e 74 63 6c 22 20 65 6e 74 72 "boot.tcl" entr
0b40: 79 20 66 72 6f 6d 20 74 68 65 20 65 6d 62 65 64 y from the embed
0b50: 64 65 64 20 4d 65 74 61 4b 69 74 20 66 69 6c 65 ded MetaKit file
0b60: 2e 0a 20 2a 2f 0a 2f 2a 0a 20 2a 20 54 68 69 73 .. */./*. * This
0b70: 20 54 63 6c 20 63 6f 64 65 20 69 73 20 69 6e 76 Tcl code is inv
0b80: 6f 6b 65 64 20 77 68 65 6e 65 76 65 72 20 54 63 oked whenever Tc
0b90: 6c 5f 49 6e 69 74 28 29 20 69 73 20 63 61 6c 6c l_Init() is call
0ba0: 65 64 20 6f 6e 20 61 6e 0a 20 2a 20 69 6e 74 65 ed on an. * inte
0bb0: 72 70 72 65 74 65 72 2e 20 20 49 74 20 73 68 6f rpreter. It sho
0bc0: 75 6c 64 20 6d 6f 75 6e 74 20 75 70 20 74 68 65 uld mount up the
0bd0: 20 56 46 53 20 61 6e 64 20 6d 61 6b 65 20 65 76 VFS and make ev
0be0: 65 72 79 74 68 69 6e 67 20 72 65 61 64 79 20 66 erything ready f
0bf0: 6f 72 0a 20 2a 20 74 68 61 74 20 69 6e 74 65 72 or. * that inter
0c00: 70 72 65 74 65 72 20 74 6f 20 64 6f 20 69 74 73 preter to do its
0c10: 20 6a 6f 62 2e 0a 20 2a 2f 0a 73 74 61 74 69 63 job.. */.static
0c20: 20 63 68 61 72 20 2a 70 72 65 49 6e 69 74 43 6d char *preInitCm
0c30: 64 20 3d 20 0a 23 69 66 20 64 65 66 69 6e 65 64 d = .#if defined
0c40: 28 5f 57 49 4e 33 32 5f 57 43 45 29 20 26 26 20 (_WIN32_WCE) &&
0c50: 21 64 65 66 69 6e 65 64 28 54 43 4c 4b 49 54 5f !defined(TCLKIT_
0c60: 44 4c 4c 29 0a 2f 2a 20 73 69 6c 6c 79 20 68 61 DLL)./* silly ha
0c70: 63 6b 20 74 6f 20 67 65 74 20 77 69 6e 63 65 20 ck to get wince
0c80: 70 6f 72 74 20 74 6f 20 6c 61 75 6e 63 68 2c 20 port to launch,
0c90: 73 6f 6d 65 20 73 6f 72 74 20 6f 66 20 73 74 64 some sort of std
0ca0: 7b 69 6e 2c 6f 75 74 2c 65 72 72 7d 20 70 72 6f {in,out,err} pro
0cb0: 62 6c 65 6d 20 2a 2f 0a 22 6f 70 65 6e 20 2f 6b blem */."open /k
0cc0: 69 74 6f 75 74 2e 74 78 74 20 61 3b 20 6f 70 65 itout.txt a; ope
0cd0: 6e 20 2f 6b 69 74 6f 75 74 2e 74 78 74 20 61 3b n /kitout.txt a;
0ce0: 20 6f 70 65 6e 20 2f 6b 69 74 6f 75 74 2e 74 78 open /kitout.tx
0cf0: 74 20 61 5c 6e 22 0a 2f 2a 20 74 68 69 73 20 74 t a\n"./* this t
0d00: 6f 6f 20 73 65 65 6d 73 20 74 6f 20 62 65 20 6e oo seems to be n
0d10: 65 65 64 65 64 20 6f 6e 20 77 69 6e 63 65 20 2d eeded on wince -
0d20: 20 69 74 20 61 70 70 65 61 72 73 20 74 6f 20 62 it appears to b
0d30: 65 20 72 65 6c 61 74 65 64 20 74 6f 20 74 68 65 e related to the
0d40: 20 61 62 6f 76 65 20 2a 2f 0a 22 63 61 74 63 68 above */."catch
0d50: 20 7b 72 65 6e 61 6d 65 20 73 6f 75 72 63 65 20 {rename source
0d60: 3a 3a 74 63 6c 3a 3a 73 6f 75 72 63 65 7d 5c 6e ::tcl::source}\n
0d70: 22 0a 22 70 72 6f 63 20 73 6f 75 72 63 65 20 66 "."proc source f
0d80: 69 6c 65 20 7b 5c 6e 22 0a 09 22 73 65 74 20 6f ile {\n".."set o
0d90: 6c 64 20 5b 69 6e 66 6f 20 73 63 72 69 70 74 5d ld [info script]
0da0: 5c 6e 22 0a 09 22 69 6e 66 6f 20 73 63 72 69 70 \n".."info scrip
0db0: 74 20 24 66 69 6c 65 5c 6e 22 0a 09 22 73 65 74 t $file\n".."set
0dc0: 20 66 69 64 20 5b 6f 70 65 6e 20 24 66 69 6c 65 fid [open $file
0dd0: 5d 5c 6e 22 0a 09 22 73 65 74 20 64 61 74 61 20 ]\n".."set data
0de0: 5b 72 65 61 64 20 24 66 69 64 5d 5c 6e 22 0a 09 [read $fid]\n"..
0df0: 22 63 6c 6f 73 65 20 24 66 69 64 5c 6e 22 0a 09 "close $fid\n"..
0e00: 22 73 65 74 20 63 6f 64 65 20 5b 63 61 74 63 68 "set code [catch
0e10: 20 7b 75 70 6c 65 76 65 6c 20 31 20 24 64 61 74 {uplevel 1 $dat
0e20: 61 7d 20 72 65 73 5d 5c 6e 22 0a 09 22 69 6e 66 a} res]\n".."inf
0e30: 6f 20 73 63 72 69 70 74 20 24 6f 6c 64 5c 6e 22 o script $old\n"
0e40: 0a 09 22 69 66 20 7b 24 63 6f 64 65 20 3d 3d 20 .."if {$code ==
0e50: 32 7d 20 7b 20 73 65 74 20 63 6f 64 65 20 30 20 2} { set code 0
0e60: 7d 5c 6e 22 0a 09 22 72 65 74 75 72 6e 20 2d 63 }\n".."return -c
0e70: 6f 64 65 20 24 63 6f 64 65 20 24 72 65 73 5c 6e ode $code $res\n
0e80: 22 0a 22 7d 5c 6e 22 0a 23 65 6e 64 69 66 20 2f "."}\n".#endif /
0e90: 2a 20 5f 57 49 4e 33 32 5f 57 43 45 20 26 26 20 * _WIN32_WCE &&
0ea0: 21 54 43 4c 4b 49 54 5f 44 4c 4c 20 2a 2f 0a 22 !TCLKIT_DLL */."
0eb0: 70 72 6f 63 20 74 63 6c 4b 69 74 49 6e 69 74 20 proc tclKitInit
0ec0: 7b 7d 20 7b 5c 6e 22 0a 09 22 72 65 6e 61 6d 65 {} {\n".."rename
0ed0: 20 74 63 6c 4b 69 74 49 6e 69 74 20 7b 7d 5c 6e tclKitInit {}\n
0ee0: 22 0a 09 22 63 61 74 63 68 20 7b 20 6c 6f 61 64 ".."catch { load
0ef0: 20 7b 7d 20 76 66 73 20 7d 5c 6e 22 0a 23 69 66 {} vfs }\n".#if
0f00: 64 65 66 20 4b 49 54 5f 49 4e 43 4c 55 44 45 53 def KIT_INCLUDES
0f10: 5f 5a 4c 49 42 0a 09 22 63 61 74 63 68 20 7b 20 _ZLIB.."catch {
0f20: 6c 6f 61 64 20 7b 7d 20 7a 6c 69 62 20 7d 5c 6e load {} zlib }\n
0f30: 22 0a 23 65 6e 64 69 66 0a 23 69 66 64 65 66 20 ".#endif.#ifdef
0f40: 4b 49 54 5f 49 4e 43 4c 55 44 45 53 5f 4d 4b 34 KIT_INCLUDES_MK4
0f50: 54 43 4c 0a 09 22 63 61 74 63 68 20 7b 20 6c 6f TCL.."catch { lo
0f60: 61 64 20 7b 7d 20 4d 6b 34 74 63 6c 20 7d 5c 6e ad {} Mk4tcl }\n
0f70: 22 0a 23 65 6e 64 69 66 0a 09 22 6c 6f 61 64 20 ".#endif.."load
0f80: 7b 7d 20 74 63 6c 6b 69 74 3a 3a 69 6e 69 74 5c {} tclkit::init\
0f90: 6e 22 0a 09 22 3a 3a 74 63 6c 6b 69 74 3a 3a 69 n".."::tclkit::i
0fa0: 6e 69 74 3a 3a 69 6e 69 74 49 6e 74 65 72 70 5c nit::initInterp\
0fb0: 6e 22 0a 09 22 72 65 6e 61 6d 65 20 3a 3a 74 63 n".."rename ::tc
0fc0: 6c 6b 69 74 3a 3a 69 6e 69 74 3a 3a 69 6e 69 74 lkit::init::init
0fd0: 49 6e 74 65 72 70 20 7b 7d 5c 6e 22 0a 09 22 73 Interp {}\n".."s
0fe0: 65 74 20 62 6f 6f 74 66 69 6c 65 20 5b 66 69 6c et bootfile [fil
0ff0: 65 20 6a 6f 69 6e 20 22 20 54 43 4c 4b 49 54 5f e join " TCLKIT_
1000: 4d 4f 55 4e 54 50 4f 49 4e 54 20 22 20 62 6f 6f MOUNTPOINT " boo
1010: 74 2e 74 63 6c 5d 5c 6e 22 0a 09 22 69 66 20 7b t.tcl]\n".."if {
1020: 5b 66 69 6c 65 20 65 78 69 73 74 73 20 24 62 6f [file exists $bo
1030: 6f 74 66 69 6c 65 5d 7d 20 7b 5c 6e 22 0a 09 09 otfile]} {\n"...
1040: 22 63 61 74 63 68 20 7b 5c 6e 22 0a 09 09 09 22 "catch {\n"...."
1050: 73 65 74 20 66 20 5b 6f 70 65 6e 20 24 62 6f 6f set f [open $boo
1060: 74 66 69 6c 65 5d 5c 6e 22 0a 09 09 09 22 73 65 tfile]\n"...."se
1070: 74 20 73 20 5b 72 65 61 64 20 24 66 5d 5c 6e 22 t s [read $f]\n"
1080: 0a 09 09 09 22 63 6c 6f 73 65 20 24 66 5c 6e 22 ...."close $f\n"
1090: 0a 09 09 22 7d 5c 6e 22 0a 09 22 7d 20 65 6c 73 ..."}\n".."} els
10a0: 65 20 7b 5c 6e 22 0a 09 09 22 73 65 74 20 3a 3a e {\n"..."set ::
10b0: 54 43 4c 4b 49 54 5f 49 4e 49 54 56 46 53 20 31 TCLKIT_INITVFS 1
10c0: 5c 6e 22 0a 09 22 7d 5c 6e 22 0a 23 69 66 64 65 \n".."}\n".#ifde
10d0: 66 20 4b 49 54 5f 53 54 4f 52 41 47 45 5f 4d 4b f KIT_STORAGE_MK
10e0: 34 0a 09 22 73 65 74 20 3a 3a 74 63 6c 4b 69 74 4.."set ::tclKit
10f0: 53 74 6f 72 61 67 65 20 5c 22 6d 6b 34 5c 22 5c Storage \"mk4\"\
1100: 6e 22 0a 09 22 69 66 20 7b 21 5b 69 6e 66 6f 20 n".."if {![info
1110: 65 78 69 73 74 73 20 73 5d 7d 20 7b 5c 6e 22 0a exists s]} {\n".
1120: 09 09 22 6d 6b 3a 3a 66 69 6c 65 20 6f 70 65 6e .."mk::file open
1130: 20 65 78 65 20 22 20 54 43 4c 4b 49 54 5f 56 46 exe " TCLKIT_VF
1140: 53 53 4f 55 52 43 45 20 22 20 2d 72 65 61 64 6f SSOURCE " -reado
1150: 6e 6c 79 5c 6e 22 0a 09 09 22 73 65 74 20 6e 20 nly\n"..."set n
1160: 5b 6d 6b 3a 3a 73 65 6c 65 63 74 20 65 78 65 2e [mk::select exe.
1170: 64 69 72 73 21 30 2e 66 69 6c 65 73 20 6e 61 6d dirs!0.files nam
1180: 65 20 62 6f 6f 74 2e 74 63 6c 5d 5c 6e 22 0a 09 e boot.tcl]\n"..
1190: 09 22 69 66 20 7b 24 6e 20 21 3d 20 5c 22 5c 22 ."if {$n != \"\"
11a0: 7d 20 7b 5c 6e 22 0a 09 09 09 22 73 65 74 20 73 } {\n"...."set s
11b0: 20 5b 6d 6b 3a 3a 67 65 74 20 65 78 65 2e 64 69 [mk::get exe.di
11c0: 72 73 21 30 2e 66 69 6c 65 73 21 24 6e 20 63 6f rs!0.files!$n co
11d0: 6e 74 65 6e 74 73 5d 5c 6e 22 0a 09 09 09 22 69 ntents]\n"...."i
11e0: 66 20 7b 21 5b 73 74 72 69 6e 67 20 6c 65 6e 67 f {![string leng
11f0: 74 68 20 24 73 5d 7d 20 7b 20 65 72 72 6f 72 20 th $s]} { error
1200: 5c 22 65 6d 70 74 79 20 62 6f 6f 74 2e 74 63 6c \"empty boot.tcl
1210: 5c 22 20 7d 5c 6e 22 0a 09 09 09 22 63 61 74 63 \" }\n"...."catc
1220: 68 20 7b 6c 6f 61 64 20 7b 7d 20 7a 6c 69 62 7d h {load {} zlib}
1230: 5c 6e 22 0a 09 09 09 22 69 66 20 7b 5b 6d 6b 3a \n"...."if {[mk:
1240: 3a 67 65 74 20 65 78 65 2e 64 69 72 73 21 30 2e :get exe.dirs!0.
1250: 66 69 6c 65 73 21 24 6e 20 73 69 7a 65 5d 20 21 files!$n size] !
1260: 3d 20 5b 73 74 72 69 6e 67 20 6c 65 6e 67 74 68 = [string length
1270: 20 24 73 5d 7d 20 7b 5c 6e 22 0a 09 09 09 09 22 $s]} {\n"....."
1280: 73 65 74 20 73 20 5b 7a 6c 69 62 20 64 65 63 6f set s [zlib deco
1290: 6d 70 72 65 73 73 20 24 73 5d 5c 6e 22 0a 09 09 mpress $s]\n"...
12a0: 09 22 7d 5c 6e 22 0a 09 09 22 7d 5c 6e 22 0a 09 ."}\n"..."}\n"..
12b0: 22 7d 5c 6e 22 0a 23 65 6e 64 69 66 20 2f 2a 20 "}\n".#endif /*
12c0: 4b 49 54 5f 53 54 4f 52 41 47 45 5f 4d 4b 34 20 KIT_STORAGE_MK4
12d0: 2a 2f 0a 23 69 66 64 65 66 20 4b 49 54 5f 53 54 */.#ifdef KIT_ST
12e0: 4f 52 41 47 45 5f 5a 49 50 0a 09 22 73 65 74 20 ORAGE_ZIP.."set
12f0: 3a 3a 74 63 6c 4b 69 74 53 74 6f 72 61 67 65 20 ::tclKitStorage
1300: 5c 22 7a 69 70 5c 22 5c 6e 22 0a 09 22 69 66 20 \"zip\"\n".."if
1310: 7b 21 5b 69 6e 66 6f 20 65 78 69 73 74 73 20 73 {![info exists s
1320: 5d 7d 20 7b 5c 6e 22 0a 23 20 20 69 6e 63 6c 75 ]} {\n".# inclu
1330: 64 65 20 22 7a 69 70 76 66 73 2e 74 63 6c 2e 68 de "zipvfs.tcl.h
1340: 22 0a 09 09 22 63 61 74 63 68 20 7b 5c 6e 22 0a "..."catch {\n".
1350: 09 09 09 22 73 65 74 20 3a 3a 74 63 6c 4b 69 74 ..."set ::tclKit
1360: 53 74 6f 72 61 67 65 5f 66 64 20 5b 3a 3a 7a 69 Storage_fd [::zi
1370: 70 3a 3a 6f 70 65 6e 20 22 20 54 43 4c 4b 49 54 p::open " TCLKIT
1380: 5f 56 46 53 53 4f 55 52 43 45 20 22 5d 5c 6e 22 _VFSSOURCE "]\n"
1390: 0a 09 09 09 22 3a 3a 7a 69 70 3a 3a 73 74 61 74 ...."::zip::stat
13a0: 20 24 3a 3a 74 63 6c 4b 69 74 53 74 6f 72 61 67 $::tclKitStorag
13b0: 65 5f 66 64 20 62 6f 6f 74 2e 74 63 6c 20 73 62 e_fd boot.tcl sb
13c0: 5c 6e 22 0a 09 09 09 22 73 65 65 6b 20 24 3a 3a \n"...."seek $::
13d0: 74 63 6c 4b 69 74 53 74 6f 72 61 67 65 5f 66 64 tclKitStorage_fd
13e0: 20 24 73 62 28 69 6e 6f 29 5c 6e 22 0a 09 09 09 $sb(ino)\n"....
13f0: 22 3a 3a 7a 69 70 3a 3a 44 61 74 61 20 24 3a 3a "::zip::Data $::
1400: 74 63 6c 4b 69 74 53 74 6f 72 61 67 65 5f 66 64 tclKitStorage_fd
1410: 20 73 62 20 73 5c 6e 22 0a 09 09 22 7d 5c 6e 22 sb s\n"..."}\n"
1420: 0a 09 22 7d 5c 6e 22 0a 23 65 6e 64 69 66 20 2f .."}\n".#endif /
1430: 2a 20 4b 49 54 5f 53 54 4f 52 41 47 45 5f 5a 49 * KIT_STORAGE_ZI
1440: 50 20 2a 2f 0a 23 69 66 64 65 66 20 4b 49 54 5f P */.#ifdef KIT_
1450: 53 54 4f 52 41 47 45 5f 43 56 46 53 0a 09 22 73 STORAGE_CVFS.."s
1460: 65 74 20 3a 3a 74 63 6c 4b 69 74 53 74 6f 72 61 et ::tclKitStora
1470: 67 65 20 5c 22 63 76 66 73 5c 22 5c 6e 22 0a 09 ge \"cvfs\"\n"..
1480: 22 6c 6f 61 64 20 7b 7d 20 72 65 63 68 61 6e 5c "load {} rechan\
1490: 6e 22 0a 09 22 6c 6f 61 64 20 7b 7d 20 63 76 66 n".."load {} cvf
14a0: 73 5f 64 61 74 61 5f 74 63 6c 5c 6e 22 0a 23 69 s_data_tcl\n".#i
14b0: 6e 63 6c 75 64 65 20 22 63 76 66 73 2e 74 63 6c nclude "cvfs.tcl
14c0: 2e 68 22 0a 09 22 69 66 20 7b 21 5b 69 6e 66 6f .h".."if {![info
14d0: 20 65 78 69 73 74 73 20 73 5d 7d 20 7b 5c 6e 22 exists s]} {\n"
14e0: 0a 09 09 22 63 61 74 63 68 20 7b 5c 6e 22 0a 09 ..."catch {\n"..
14f0: 09 09 22 73 65 74 20 73 20 5b 3a 3a 76 66 73 3a .."set s [::vfs:
1500: 3a 63 76 66 73 3a 3a 64 61 74 61 3a 3a 67 65 74 :cvfs::data::get
1510: 44 61 74 61 20 74 63 6c 20 62 6f 6f 74 2e 74 63 Data tcl boot.tc
1520: 6c 5d 5c 6e 22 0a 09 09 22 7d 5c 6e 22 0a 09 22 l]\n"..."}\n".."
1530: 7d 5c 6e 22 0a 23 65 6e 64 69 66 20 2f 2a 20 4b }\n".#endif /* K
1540: 49 54 5f 53 54 4f 52 41 47 45 5f 43 56 46 53 20 IT_STORAGE_CVFS
1550: 2a 2f 0a 09 22 69 66 20 7b 21 5b 69 6e 66 6f 20 */.."if {![info
1560: 65 78 69 73 74 73 20 73 5d 7d 20 7b 5c 6e 22 0a exists s]} {\n".
1570: 09 09 22 73 65 74 20 73 20 5c 22 5c 22 5c 6e 22 .."set s \"\"\n"
1580: 0a 09 22 7d 5c 6e 22 0a 23 69 66 64 65 66 20 54 .."}\n".#ifdef T
1590: 43 4c 4b 49 54 5f 44 4c 4c 0a 09 22 73 65 74 20 CLKIT_DLL.."set
15a0: 3a 3a 54 43 4c 4b 49 54 5f 54 59 50 45 20 5c 22 ::TCLKIT_TYPE \"
15b0: 6b 69 74 64 6c 6c 5c 22 5c 6e 22 0a 23 65 6c 73 kitdll\"\n".#els
15c0: 65 0a 09 22 73 65 74 20 3a 3a 54 43 4c 4b 49 54 e.."set ::TCLKIT
15d0: 5f 54 59 50 45 20 5c 22 74 63 6c 6b 69 74 5c 22 _TYPE \"tclkit\"
15e0: 5c 6e 22 0a 23 65 6e 64 69 66 20 2f 2a 20 54 43 \n".#endif /* TC
15f0: 4c 4b 49 54 5f 44 4c 4c 20 2a 2f 0a 09 22 73 65 LKIT_DLL */.."se
1600: 74 20 3a 3a 54 43 4c 4b 49 54 5f 4d 4f 55 4e 54 t ::TCLKIT_MOUNT
1610: 50 4f 49 4e 54 20 22 20 54 43 4c 4b 49 54 5f 4d POINT " TCLKIT_M
1620: 4f 55 4e 54 50 4f 49 4e 54 20 22 5c 6e 22 0a 09 OUNTPOINT "\n"..
1630: 22 73 65 74 20 3a 3a 54 43 4c 4b 49 54 5f 56 46 "set ::TCLKIT_VF
1640: 53 53 4f 55 52 43 45 20 22 20 54 43 4c 4b 49 54 SSOURCE " TCLKIT
1650: 5f 56 46 53 53 4f 55 52 43 45 20 22 5c 6e 22 0a _VFSSOURCE "\n".
1660: 09 22 73 65 74 20 3a 3a 54 43 4c 4b 49 54 5f 4d ."set ::TCLKIT_M
1670: 4f 55 4e 54 50 4f 49 4e 54 5f 56 41 52 20 7b 22 OUNTPOINT_VAR {"
1680: 20 54 43 4c 4b 49 54 5f 4d 4f 55 4e 54 50 4f 49 TCLKIT_MOUNTPOI
1690: 4e 54 20 22 7d 5c 6e 22 0a 09 22 73 65 74 20 3a NT "}\n".."set :
16a0: 3a 54 43 4c 4b 49 54 5f 56 46 53 53 4f 55 52 43 :TCLKIT_VFSSOURC
16b0: 45 5f 56 41 52 20 7b 22 20 54 43 4c 4b 49 54 5f E_VAR {" TCLKIT_
16c0: 56 46 53 53 4f 55 52 43 45 20 22 7d 5c 6e 22 0a VFSSOURCE "}\n".
16d0: 09 22 75 70 6c 65 76 65 6c 20 23 30 20 24 73 5c ."uplevel #0 $s\
16e0: 6e 22 0a 23 69 66 20 64 65 66 69 6e 65 64 28 4b n".#if defined(K
16f0: 49 54 5f 49 4e 43 4c 55 44 45 53 5f 54 4b 29 20 IT_INCLUDES_TK)
1700: 26 26 20 64 65 66 69 6e 65 64 28 4b 49 54 5f 54 && defined(KIT_T
1710: 4b 5f 56 45 52 53 49 4f 4e 29 0a 09 22 70 61 63 K_VERSION).."pac
1720: 6b 61 67 65 20 69 66 6e 65 65 64 65 64 20 54 6b kage ifneeded Tk
1730: 20 22 20 4b 49 54 5f 54 4b 5f 56 45 52 53 49 4f " KIT_TK_VERSIO
1740: 4e 20 22 20 7b 5c 6e 22 0a 09 09 22 6c 6f 61 64 N " {\n"..."load
1750: 20 7b 7d 20 54 6b 5c 6e 22 0a 09 22 7d 5c 6e 22 {} Tk\n".."}\n"
1760: 0a 23 65 6e 64 69 66 0a 23 69 66 64 65 66 20 5f .#endif.#ifdef _
1770: 57 49 4e 33 32 0a 09 22 63 61 74 63 68 20 7b 6c WIN32.."catch {l
1780: 6f 61 64 20 7b 7d 20 64 64 65 7d 5c 6e 22 0a 09 oad {} dde}\n"..
1790: 22 63 61 74 63 68 20 7b 6c 6f 61 64 20 7b 7d 20 "catch {load {}
17a0: 72 65 67 69 73 74 72 79 7d 5c 6e 22 0a 23 65 6e registry}\n".#en
17b0: 64 69 66 20 2f 2a 20 5f 57 49 4e 33 32 20 2a 2f dif /* _WIN32 */
17c0: 0a 09 22 72 65 74 75 72 6e 20 30 5c 6e 22 0a 22 .."return 0\n"."
17d0: 7d 5c 6e 22 0a 22 74 63 6c 4b 69 74 49 6e 69 74 }\n"."tclKitInit
17e0: 22 3b 0a 0a 73 74 61 74 69 63 20 63 6f 6e 73 74 ";..static const
17f0: 20 63 68 61 72 20 69 6e 69 74 53 63 72 69 70 74 char initScript
1800: 5b 5d 20 3d 0a 22 69 66 20 7b 5b 66 69 6c 65 20 [] =."if {[file
1810: 69 73 66 69 6c 65 20 5b 66 69 6c 65 20 6a 6f 69 isfile [file joi
1820: 6e 20 5b 69 6e 66 6f 20 6e 61 6d 65 6f 66 65 78 n [info nameofex
1830: 65 5d 20 6d 61 69 6e 2e 74 63 6c 5d 5d 7d 20 7b e] main.tcl]]} {
1840: 5c 6e 22 0a 09 22 69 66 20 7b 5b 69 6e 66 6f 20 \n".."if {[info
1850: 63 6f 6d 6d 61 6e 64 73 20 63 6f 6e 73 6f 6c 65 commands console
1860: 5d 20 21 3d 20 7b 7d 7d 20 7b 20 63 6f 6e 73 6f ] != {}} { conso
1870: 6c 65 20 68 69 64 65 20 7d 5c 6e 22 0a 09 22 73 le hide }\n".."s
1880: 65 74 20 74 63 6c 5f 69 6e 74 65 72 61 63 74 69 et tcl_interacti
1890: 76 65 20 30 5c 6e 22 0a 09 22 69 6e 63 72 20 61 ve 0\n".."incr a
18a0: 72 67 63 5c 6e 22 0a 09 22 73 65 74 20 61 72 67 rgc\n".."set arg
18b0: 76 20 5b 6c 69 6e 73 65 72 74 20 24 61 72 67 76 v [linsert $argv
18c0: 20 30 20 24 61 72 67 76 30 5d 5c 6e 22 0a 09 22 0 $argv0]\n".."
18d0: 73 65 74 20 61 72 67 76 30 20 5b 66 69 6c 65 20 set argv0 [file
18e0: 6a 6f 69 6e 20 5b 69 6e 66 6f 20 6e 61 6d 65 6f join [info nameo
18f0: 66 65 78 65 5d 20 6d 61 69 6e 2e 74 63 6c 5d 5c fexe] main.tcl]\
1900: 6e 22 0a 22 7d 20 65 6c 73 65 20 63 6f 6e 74 69 n"."} else conti
1910: 6e 75 65 5c 6e 22 3b 0a 0a 2f 2a 20 53 65 74 45 nue\n";../* SetE
1920: 78 65 63 4e 61 6d 65 20 2d 2d 0a 0a 20 20 20 48 xecName --.. H
1930: 61 63 6b 20 74 6f 20 67 65 74 20 61 72 6f 75 6e ack to get aroun
1940: 64 20 54 63 6c 20 62 75 67 20 31 32 32 34 38 38 d Tcl bug 122488
1950: 38 2e 0a 2a 2f 0a 73 74 61 74 69 63 20 76 6f 69 8..*/.static voi
1960: 64 20 53 65 74 45 78 65 63 4e 61 6d 65 28 54 63 d SetExecName(Tc
1970: 6c 5f 49 6e 74 65 72 70 20 2a 69 6e 74 65 72 70 l_Interp *interp
1980: 2c 20 63 6f 6e 73 74 20 63 68 61 72 20 2a 70 61 , const char *pa
1990: 74 68 29 20 7b 0a 23 69 66 64 65 66 20 54 43 4c th) {.#ifdef TCL
19a0: 4b 49 54 5f 52 45 51 55 49 52 45 5f 54 43 4c 45 KIT_REQUIRE_TCLE
19b0: 58 45 43 55 54 41 42 4c 45 4e 41 4d 45 0a 09 74 XECUTABLENAME..t
19c0: 63 6c 45 78 65 63 75 74 61 62 6c 65 4e 61 6d 65 clExecutableName
19d0: 20 3d 20 73 74 72 64 75 70 28 70 61 74 68 29 3b = strdup(path);
19e0: 0a 23 65 6e 64 69 66 0a 09 54 63 6c 5f 46 69 6e .#endif..Tcl_Fin
19f0: 64 45 78 65 63 75 74 61 62 6c 65 28 70 61 74 68 dExecutable(path
1a00: 29 3b 0a 0a 09 72 65 74 75 72 6e 3b 0a 7d 0a 0a );...return;.}..
1a10: 73 74 61 74 69 63 20 76 6f 69 64 20 46 69 6e 64 static void Find
1a20: 41 6e 64 53 65 74 45 78 65 63 4e 61 6d 65 28 54 AndSetExecName(T
1a30: 63 6c 5f 49 6e 74 65 72 70 20 2a 69 6e 74 65 72 cl_Interp *inter
1a40: 70 29 20 7b 0a 09 69 6e 74 20 6c 65 6e 20 3d 20 p) {..int len =
1a50: 30 3b 0a 09 54 63 6c 5f 4f 62 6a 20 2a 65 78 65 0;..Tcl_Obj *exe
1a60: 63 4e 61 6d 65 4f 62 6a 3b 0a 09 54 63 6c 5f 4f cNameObj;..Tcl_O
1a70: 62 6a 20 2a 6c 6f 62 6a 76 5b 31 5d 3b 0a 23 69 bj *lobjv[1];.#i
1a80: 66 64 65 66 20 48 41 56 45 5f 52 45 41 44 4c 49 fdef HAVE_READLI
1a90: 4e 4b 0a 09 73 73 69 7a 65 5f 74 20 72 65 61 64 NK..ssize_t read
1aa0: 6c 69 6e 6b 5f 72 65 74 3b 0a 09 63 68 61 72 20 link_ret;..char
1ab0: 65 78 65 5f 62 75 66 5b 34 30 39 36 5d 3b 0a 23 exe_buf[4096];.#
1ac0: 65 6e 64 69 66 20 2f 2a 20 48 41 56 45 5f 52 45 endif /* HAVE_RE
1ad0: 41 44 4c 49 4e 4b 20 2a 2f 0a 23 69 66 64 65 66 ADLINK */.#ifdef
1ae0: 20 48 41 56 45 5f 41 43 43 45 50 54 41 42 4c 45 HAVE_ACCEPTABLE
1af0: 5f 44 4c 41 44 44 52 0a 09 44 6c 5f 69 6e 66 6f _DLADDR..Dl_info
1b00: 20 73 79 6d 69 6e 66 6f 3b 0a 09 69 6e 74 20 64 syminfo;..int d
1b10: 6c 61 64 64 72 5f 72 65 74 3b 0a 23 65 6e 64 69 laddr_ret;.#endi
1b20: 66 20 2f 2a 20 48 41 56 45 5f 41 43 43 45 50 54 f /* HAVE_ACCEPT
1b30: 41 42 4c 45 5f 44 4c 41 44 44 52 20 2a 2f 20 0a ABLE_DLADDR */ .
1b40: 0a 23 69 66 64 65 66 20 48 41 56 45 5f 52 45 41 .#ifdef HAVE_REA
1b50: 44 4c 49 4e 4b 0a 09 69 66 20 28 54 63 6c 5f 47 DLINK..if (Tcl_G
1b60: 65 74 4e 61 6d 65 4f 66 45 78 65 63 75 74 61 62 etNameOfExecutab
1b70: 6c 65 28 29 20 3d 3d 20 4e 55 4c 4c 29 20 7b 0a le() == NULL) {.
1b80: 09 09 72 65 61 64 6c 69 6e 6b 5f 72 65 74 20 3d ..readlink_ret =
1b90: 20 72 65 61 64 6c 69 6e 6b 28 22 2f 70 72 6f 63 readlink("/proc
1ba0: 2f 73 65 6c 66 2f 65 78 65 22 2c 20 65 78 65 5f /self/exe", exe_
1bb0: 62 75 66 2c 20 73 69 7a 65 6f 66 28 65 78 65 5f buf, sizeof(exe_
1bc0: 62 75 66 29 20 2d 20 31 29 3b 0a 0a 09 09 69 66 buf) - 1);....if
1bd0: 20 28 72 65 61 64 6c 69 6e 6b 5f 72 65 74 20 3e (readlink_ret >
1be0: 20 30 20 26 26 20 72 65 61 64 6c 69 6e 6b 5f 72 0 && readlink_r
1bf0: 65 74 20 3c 20 28 73 69 7a 65 6f 66 28 65 78 65 et < (sizeof(exe
1c00: 5f 62 75 66 29 20 2d 20 31 29 29 20 7b 0a 09 09 _buf) - 1)) {...
1c10: 09 65 78 65 5f 62 75 66 5b 72 65 61 64 6c 69 6e .exe_buf[readlin
1c20: 6b 5f 72 65 74 5d 20 3d 20 27 5c 30 27 3b 0a 0a k_ret] = '\0';..
1c30: 09 09 09 53 65 74 45 78 65 63 4e 61 6d 65 28 69 ...SetExecName(i
1c40: 6e 74 65 72 70 2c 20 65 78 65 5f 62 75 66 29 3b nterp, exe_buf);
1c50: 0a 0a 09 09 09 72 65 74 75 72 6e 3b 0a 09 09 7d .....return;...}
1c60: 0a 09 7d 0a 0a 09 69 66 20 28 54 63 6c 5f 47 65 ..}...if (Tcl_Ge
1c70: 74 4e 61 6d 65 4f 66 45 78 65 63 75 74 61 62 6c tNameOfExecutabl
1c80: 65 28 29 20 3d 3d 20 4e 55 4c 4c 29 20 7b 0a 09 e() == NULL) {..
1c90: 09 72 65 61 64 6c 69 6e 6b 5f 72 65 74 20 3d 20 .readlink_ret =
1ca0: 72 65 61 64 6c 69 6e 6b 28 22 2f 70 72 6f 63 2f readlink("/proc/
1cb0: 63 75 72 70 72 6f 63 2f 66 69 6c 65 22 2c 20 65 curproc/file", e
1cc0: 78 65 5f 62 75 66 2c 20 73 69 7a 65 6f 66 28 65 xe_buf, sizeof(e
1cd0: 78 65 5f 62 75 66 29 20 2d 20 31 29 3b 0a 0a 09 xe_buf) - 1);...
1ce0: 09 69 66 20 28 72 65 61 64 6c 69 6e 6b 5f 72 65 .if (readlink_re
1cf0: 74 20 3e 20 30 20 26 26 20 72 65 61 64 6c 69 6e t > 0 && readlin
1d00: 6b 5f 72 65 74 20 3c 20 28 73 69 7a 65 6f 66 28 k_ret < (sizeof(
1d10: 65 78 65 5f 62 75 66 29 20 2d 20 31 29 29 20 7b exe_buf) - 1)) {
1d20: 0a 09 09 09 65 78 65 5f 62 75 66 5b 72 65 61 64 ....exe_buf[read
1d30: 6c 69 6e 6b 5f 72 65 74 5d 20 3d 20 27 5c 30 27 link_ret] = '\0'
1d40: 3b 0a 0a 09 09 09 69 66 20 28 73 74 72 63 6d 70 ;.....if (strcmp
1d50: 28 65 78 65 5f 62 75 66 2c 20 22 75 6e 6b 6e 6f (exe_buf, "unkno
1d60: 77 6e 22 29 20 21 3d 20 30 29 20 7b 0a 09 09 09 wn") != 0) {....
1d70: 09 53 65 74 45 78 65 63 4e 61 6d 65 28 69 6e 74 .SetExecName(int
1d80: 65 72 70 2c 20 65 78 65 5f 62 75 66 29 3b 0a 0a erp, exe_buf);..
1d90: 09 09 09 09 72 65 74 75 72 6e 3b 0a 09 09 09 7d ....return;....}
1da0: 0a 09 09 7d 0a 09 7d 0a 23 65 6e 64 69 66 20 2f ...}..}.#endif /
1db0: 2a 20 48 41 56 45 5f 52 45 41 44 4c 49 4e 4b 20 * HAVE_READLINK
1dc0: 2a 2f 0a 0a 23 69 66 64 65 66 20 48 41 56 45 5f */..#ifdef HAVE_
1dd0: 41 43 43 45 50 54 41 42 4c 45 5f 44 4c 41 44 44 ACCEPTABLE_DLADD
1de0: 52 0a 23 20 20 69 66 6e 64 65 66 20 54 43 4c 4b R.# ifndef TCLK
1df0: 49 54 5f 44 4c 4c 0a 09 69 66 20 28 54 63 6c 5f IT_DLL..if (Tcl_
1e00: 47 65 74 4e 61 6d 65 4f 66 45 78 65 63 75 74 61 GetNameOfExecuta
1e10: 62 6c 65 28 29 20 3d 3d 20 4e 55 4c 4c 29 20 7b ble() == NULL) {
1e20: 0a 09 09 64 6c 61 64 64 72 5f 72 65 74 20 3d 20 ...dladdr_ret =
1e30: 64 6c 61 64 64 72 28 26 53 65 74 45 78 65 63 4e dladdr(&SetExecN
1e40: 61 6d 65 2c 20 26 73 79 6d 69 6e 66 6f 29 3b 0a ame, &syminfo);.
1e50: 09 09 69 66 20 28 64 6c 61 64 64 72 5f 72 65 74 ..if (dladdr_ret
1e60: 20 21 3d 20 30 29 20 7b 0a 09 09 09 53 65 74 45 != 0) {....SetE
1e70: 78 65 63 4e 61 6d 65 28 69 6e 74 65 72 70 2c 20 xecName(interp,
1e80: 73 79 6d 69 6e 66 6f 2e 64 6c 69 5f 66 6e 61 6d syminfo.dli_fnam
1e90: 65 29 3b 0a 0a 09 09 09 72 65 74 75 72 6e 3b 0a e);.....return;.
1ea0: 09 09 7d 0a 09 7d 0a 23 20 20 20 20 69 66 64 65 ..}..}.# ifde
1eb0: 66 20 4b 49 54 53 48 5f 4e 45 45 44 5f 57 49 4e f KITSH_NEED_WIN
1ec0: 4d 41 49 4e 0a 09 69 66 20 28 54 63 6c 5f 47 65 MAIN..if (Tcl_Ge
1ed0: 74 4e 61 6d 65 4f 66 45 78 65 63 75 74 61 62 6c tNameOfExecutabl
1ee0: 65 28 29 20 3d 3d 20 4e 55 4c 4c 29 20 7b 0a 23 e() == NULL) {.#
1ef0: 20 20 20 20 20 20 69 66 64 65 66 20 5f 57 49 4e ifdef _WIN
1f00: 33 32 5f 57 43 45 0a 09 09 64 6c 61 64 64 72 5f 32_WCE...dladdr_
1f10: 72 65 74 20 3d 20 64 6c 61 64 64 72 28 26 57 69 ret = dladdr(&Wi
1f20: 6e 4d 61 69 6e 2c 20 26 73 79 6d 69 6e 66 6f 29 nMain, &syminfo)
1f30: 3b 0a 23 20 20 20 20 20 20 65 6c 73 65 0a 09 09 ;.# else...
1f40: 64 6c 61 64 64 72 5f 72 65 74 20 3d 20 64 6c 61 dladdr_ret = dla
1f50: 64 64 72 28 26 77 57 69 6e 4d 61 69 6e 2c 20 26 ddr(&wWinMain, &
1f60: 73 79 6d 69 6e 66 6f 29 3b 0a 23 20 20 20 20 20 syminfo);.#
1f70: 20 65 6e 64 69 66 20 2f 2a 20 5f 57 49 4e 33 32 endif /* _WIN32
1f80: 5f 57 43 45 20 2a 2f 0a 0a 09 09 69 66 20 28 64 _WCE */....if (d
1f90: 6c 61 64 64 72 5f 72 65 74 20 21 3d 20 30 29 20 laddr_ret != 0)
1fa0: 7b 0a 09 09 09 53 65 74 45 78 65 63 4e 61 6d 65 {....SetExecName
1fb0: 28 69 6e 74 65 72 70 2c 20 73 79 6d 69 6e 66 6f (interp, syminfo
1fc0: 2e 64 6c 69 5f 66 6e 61 6d 65 29 3b 0a 0a 09 09 .dli_fname);....
1fd0: 09 72 65 74 75 72 6e 3b 0a 09 09 7d 0a 09 7d 0a .return;...}..}.
1fe0: 23 20 20 20 20 65 6e 64 69 66 20 2f 2a 20 4b 49 # endif /* KI
1ff0: 54 53 48 5f 4e 45 45 44 5f 57 49 4e 4d 41 49 4e TSH_NEED_WINMAIN
2000: 20 2a 2f 0a 0a 09 69 66 20 28 54 63 6c 5f 47 65 */...if (Tcl_Ge
2010: 74 4e 61 6d 65 4f 66 45 78 65 63 75 74 61 62 6c tNameOfExecutabl
2020: 65 28 29 20 3d 3d 20 4e 55 4c 4c 29 20 7b 0a 09 e() == NULL) {..
2030: 09 64 6c 61 64 64 72 5f 72 65 74 20 3d 20 64 6c .dladdr_ret = dl
2040: 61 64 64 72 28 26 6d 61 69 6e 2c 20 26 73 79 6d addr(&main, &sym
2050: 69 6e 66 6f 29 3b 0a 09 09 69 66 20 28 64 6c 61 info);...if (dla
2060: 64 64 72 5f 72 65 74 20 21 3d 20 30 29 20 7b 0a ddr_ret != 0) {.
2070: 09 09 09 53 65 74 45 78 65 63 4e 61 6d 65 28 69 ...SetExecName(i
2080: 6e 74 65 72 70 2c 20 73 79 6d 69 6e 66 6f 2e 64 nterp, syminfo.d
2090: 6c 69 5f 66 6e 61 6d 65 29 3b 0a 0a 09 09 09 72 li_fname);.....r
20a0: 65 74 75 72 6e 3b 0a 09 09 7d 0a 09 7d 0a 23 20 eturn;...}..}.#
20b0: 20 65 6e 64 69 66 20 2f 2a 20 21 54 43 4c 4b 49 endif /* !TCLKI
20c0: 54 5f 44 4c 4c 20 2a 2f 0a 23 65 6e 64 69 66 20 T_DLL */.#endif
20d0: 2f 2a 20 48 41 56 45 5f 41 43 43 45 50 54 41 42 /* HAVE_ACCEPTAB
20e0: 4c 45 5f 44 4c 41 44 44 52 20 2a 2f 0a 0a 09 69 LE_DLADDR */...i
20f0: 66 20 28 54 63 6c 5f 47 65 74 4e 61 6d 65 4f 66 f (Tcl_GetNameOf
2100: 45 78 65 63 75 74 61 62 6c 65 28 29 20 3d 3d 20 Executable() ==
2110: 4e 55 4c 4c 29 20 7b 0a 09 09 6c 6f 62 6a 76 5b NULL) {...lobjv[
2120: 30 5d 20 3d 20 54 63 6c 5f 47 65 74 56 61 72 32 0] = Tcl_GetVar2
2130: 45 78 28 69 6e 74 65 72 70 2c 20 22 61 72 67 76 Ex(interp, "argv
2140: 30 22 2c 20 4e 55 4c 4c 2c 20 54 43 4c 5f 47 4c 0", NULL, TCL_GL
2150: 4f 42 41 4c 5f 4f 4e 4c 59 29 3b 0a 09 09 65 78 OBAL_ONLY);...ex
2160: 65 63 4e 61 6d 65 4f 62 6a 20 3d 20 54 63 6c 5f ecNameObj = Tcl_
2170: 46 53 4a 6f 69 6e 54 6f 50 61 74 68 28 54 63 6c FSJoinToPath(Tcl
2180: 5f 46 53 47 65 74 43 77 64 28 69 6e 74 65 72 70 _FSGetCwd(interp
2190: 29 2c 20 31 2c 20 6c 6f 62 6a 76 29 3b 0a 0a 09 ), 1, lobjv);...
21a0: 09 53 65 74 45 78 65 63 4e 61 6d 65 28 69 6e 74 .SetExecName(int
21b0: 65 72 70 2c 20 54 63 6c 5f 47 65 74 53 74 72 69 erp, Tcl_GetStri
21c0: 6e 67 46 72 6f 6d 4f 62 6a 28 65 78 65 63 4e 61 ngFromObj(execNa
21d0: 6d 65 4f 62 6a 2c 20 26 6c 65 6e 29 29 3b 0a 0a meObj, &len));..
21e0: 09 09 72 65 74 75 72 6e 3b 0a 09 7d 0a 0a 09 72 ..return;..}...r
21f0: 65 74 75 72 6e 3b 0a 7d 0a 0a 73 74 61 74 69 63 eturn;.}..static
2200: 20 76 6f 69 64 20 5f 54 63 6c 6b 69 74 5f 47 65 void _Tclkit_Ge
2210: 6e 65 72 69 63 5f 49 6e 69 74 28 76 6f 69 64 29 neric_Init(void)
2220: 20 7b 0a 23 69 66 64 65 66 20 4b 49 54 5f 49 4e {.#ifdef KIT_IN
2230: 43 4c 55 44 45 53 5f 4d 4b 34 54 43 4c 0a 09 54 CLUDES_MK4TCL..T
2240: 63 6c 5f 53 74 61 74 69 63 50 61 63 6b 61 67 65 cl_StaticPackage
2250: 28 30 2c 20 22 4d 6b 34 74 63 6c 22 2c 20 4d 6b (0, "Mk4tcl", Mk
2260: 34 74 63 6c 5f 49 6e 69 74 2c 20 4e 55 4c 4c 29 4tcl_Init, NULL)
2270: 3b 0a 23 65 6e 64 69 66 0a 23 69 66 64 65 66 20 ;.#endif.#ifdef
2280: 4b 49 54 5f 49 4e 43 4c 55 44 45 53 5f 50 57 42 KIT_INCLUDES_PWB
2290: 0a 09 54 63 6c 5f 53 74 61 74 69 63 50 61 63 6b ..Tcl_StaticPack
22a0: 61 67 65 28 30 2c 20 22 70 77 62 22 2c 20 50 77 age(0, "pwb", Pw
22b0: 62 5f 49 6e 69 74 2c 20 4e 55 4c 4c 29 3b 0a 23 b_Init, NULL);.#
22c0: 65 6e 64 69 66 20 0a 09 54 63 6c 5f 53 74 61 74 endif ..Tcl_Stat
22d0: 69 63 50 61 63 6b 61 67 65 28 30 2c 20 22 72 65 icPackage(0, "re
22e0: 63 68 61 6e 22 2c 20 52 65 63 68 61 6e 5f 49 6e chan", Rechan_In
22f0: 69 74 2c 20 4e 55 4c 4c 29 3b 0a 09 54 63 6c 5f it, NULL);..Tcl_
2300: 53 74 61 74 69 63 50 61 63 6b 61 67 65 28 30 2c StaticPackage(0,
2310: 20 22 76 66 73 22 2c 20 56 66 73 5f 49 6e 69 74 "vfs", Vfs_Init
2320: 2c 20 4e 55 4c 4c 29 3b 0a 23 69 66 64 65 66 20 , NULL);.#ifdef
2330: 4b 49 54 5f 49 4e 43 4c 55 44 45 53 5f 5a 4c 49 KIT_INCLUDES_ZLI
2340: 42 0a 09 54 63 6c 5f 53 74 61 74 69 63 50 61 63 B..Tcl_StaticPac
2350: 6b 61 67 65 28 30 2c 20 22 7a 6c 69 62 22 2c 20 kage(0, "zlib",
2360: 5a 6c 69 62 5f 49 6e 69 74 2c 20 4e 55 4c 4c 29 Zlib_Init, NULL)
2370: 3b 0a 23 65 6e 64 69 66 0a 23 69 66 64 65 66 20 ;.#endif.#ifdef
2380: 4b 49 54 5f 53 54 4f 52 41 47 45 5f 43 56 46 53 KIT_STORAGE_CVFS
2390: 0a 09 54 63 6c 5f 53 74 61 74 69 63 50 61 63 6b ..Tcl_StaticPack
23a0: 61 67 65 28 30 2c 20 22 63 76 66 73 5f 64 61 74 age(0, "cvfs_dat
23b0: 61 5f 74 63 6c 22 2c 20 43 76 66 73 5f 64 61 74 a_tcl", Cvfs_dat
23c0: 61 5f 74 63 6c 5f 49 6e 69 74 2c 20 4e 55 4c 4c a_tcl_Init, NULL
23d0: 29 3b 0a 23 65 6e 64 69 66 0a 23 69 66 64 65 66 );.#endif.#ifdef
23e0: 20 54 43 4c 5f 54 48 52 45 41 44 53 0a 09 54 63 TCL_THREADS..Tc
23f0: 6c 5f 53 74 61 74 69 63 50 61 63 6b 61 67 65 28 l_StaticPackage(
2400: 30 2c 20 22 54 68 72 65 61 64 22 2c 20 54 68 72 0, "Thread", Thr
2410: 65 61 64 5f 49 6e 69 74 2c 20 4e 55 4c 4c 29 3b ead_Init, NULL);
2420: 0a 23 65 6e 64 69 66 0a 23 69 66 64 65 66 20 5f .#endif.#ifdef _
2430: 57 49 4e 33 32 0a 09 54 63 6c 5f 53 74 61 74 69 WIN32..Tcl_Stati
2440: 63 50 61 63 6b 61 67 65 28 30 2c 20 22 64 64 65 cPackage(0, "dde
2450: 22 2c 20 44 64 65 5f 49 6e 69 74 2c 20 4e 55 4c ", Dde_Init, NUL
2460: 4c 29 3b 0a 09 54 63 6c 5f 53 74 61 74 69 63 50 L);..Tcl_StaticP
2470: 61 63 6b 61 67 65 28 30 2c 20 22 72 65 67 69 73 ackage(0, "regis
2480: 74 72 79 22 2c 20 52 65 67 69 73 74 72 79 5f 49 try", Registry_I
2490: 6e 69 74 2c 20 4e 55 4c 4c 29 3b 0a 23 65 6e 64 nit, NULL);.#end
24a0: 69 66 0a 23 69 66 64 65 66 20 4b 49 54 5f 49 4e if.#ifdef KIT_IN
24b0: 43 4c 55 44 45 53 5f 54 4b 0a 09 54 63 6c 5f 53 CLUDES_TK..Tcl_S
24c0: 74 61 74 69 63 50 61 63 6b 61 67 65 28 30 2c 20 taticPackage(0,
24d0: 22 54 6b 22 2c 20 54 6b 5f 49 6e 69 74 2c 20 54 "Tk", Tk_Init, T
24e0: 6b 5f 53 61 66 65 49 6e 69 74 29 3b 0a 23 65 6e k_SafeInit);.#en
24f0: 64 69 66 0a 0a 09 5f 54 63 6c 6b 69 74 5f 47 65 dif..._Tclkit_Ge
2500: 6e 65 72 69 63 4c 69 62 5f 49 6e 69 74 28 29 3b nericLib_Init();
2510: 0a 0a 09 54 63 6c 53 65 74 50 72 65 49 6e 69 74 ...TclSetPreInit
2520: 53 63 72 69 70 74 28 70 72 65 49 6e 69 74 43 6d Script(preInitCm
2530: 64 29 3b 0a 0a 09 72 65 74 75 72 6e 3b 0a 7d 0a d);...return;.}.
2540: 0a 73 74 61 74 69 63 20 76 6f 69 64 20 5f 54 63 .static void _Tc
2550: 6c 6b 69 74 5f 49 6e 74 65 72 70 5f 49 6e 69 74 lkit_Interp_Init
2560: 28 54 63 6c 5f 49 6e 74 65 72 70 20 2a 69 6e 74 (Tcl_Interp *int
2570: 65 72 70 29 20 7b 0a 23 69 66 64 65 66 20 54 43 erp) {.#ifdef TC
2580: 4c 4b 49 54 5f 43 41 4e 5f 53 45 54 5f 45 4e 43 LKIT_CAN_SET_ENC
2590: 4f 44 49 4e 47 0a 09 54 63 6c 5f 44 53 74 72 69 ODING..Tcl_DStri
25a0: 6e 67 20 65 6e 63 6f 64 69 6e 67 4e 61 6d 65 3b ng encodingName;
25b0: 0a 23 65 6e 64 69 66 20 2f 2a 20 54 43 4c 4b 49 .#endif /* TCLKI
25c0: 54 5f 43 41 4e 5f 53 45 54 5f 45 4e 43 4f 44 49 T_CAN_SET_ENCODI
25d0: 4e 47 20 2a 2f 0a 0a 23 69 66 6e 64 65 66 20 54 NG */..#ifndef T
25e0: 43 4c 4b 49 54 5f 44 4c 4c 0a 09 2f 2a 20 74 68 CLKIT_DLL../* th
25f0: 65 20 74 63 6c 5f 72 63 46 69 6c 65 4e 61 6d 65 e tcl_rcFileName
2600: 20 76 61 72 69 61 62 6c 65 20 6f 6e 6c 79 20 65 variable only e
2610: 78 69 73 74 73 20 69 6e 20 74 68 65 20 69 6e 69 xists in the ini
2620: 74 69 61 6c 20 69 6e 74 65 72 70 72 65 74 65 72 tial interpreter
2630: 20 2a 2f 0a 23 20 20 69 66 64 65 66 20 5f 57 49 */.# ifdef _WI
2640: 4e 33 32 0a 09 54 63 6c 5f 53 65 74 56 61 72 28 N32..Tcl_SetVar(
2650: 69 6e 74 65 72 70 2c 20 22 74 63 6c 5f 72 63 46 interp, "tcl_rcF
2660: 69 6c 65 4e 61 6d 65 22 2c 20 22 7e 2f 74 63 6c ileName", "~/tcl
2670: 6b 69 74 72 63 2e 74 63 6c 22 2c 20 54 43 4c 5f kitrc.tcl", TCL_
2680: 47 4c 4f 42 41 4c 5f 4f 4e 4c 59 29 3b 0a 23 20 GLOBAL_ONLY);.#
2690: 20 65 6c 73 65 0a 09 54 63 6c 5f 53 65 74 56 61 else..Tcl_SetVa
26a0: 72 28 69 6e 74 65 72 70 2c 20 22 74 63 6c 5f 72 r(interp, "tcl_r
26b0: 63 46 69 6c 65 4e 61 6d 65 22 2c 20 22 7e 2f 2e cFileName", "~/.
26c0: 74 63 6c 6b 69 74 72 63 22 2c 20 54 43 4c 5f 47 tclkitrc", TCL_G
26d0: 4c 4f 42 41 4c 5f 4f 4e 4c 59 29 3b 0a 23 20 20 LOBAL_ONLY);.#
26e0: 65 6e 64 69 66 20 2f 2a 20 5f 57 49 4e 33 32 20 endif /* _WIN32
26f0: 2a 2f 0a 23 65 6e 64 69 66 20 2f 2a 20 21 54 43 */.#endif /* !TC
2700: 4c 4b 49 54 5f 44 4c 4c 20 2a 2f 0a 0a 23 69 66 LKIT_DLL */..#if
2710: 64 65 66 20 54 43 4c 4b 49 54 5f 43 41 4e 5f 53 def TCLKIT_CAN_S
2720: 45 54 5f 45 4e 43 4f 44 49 4e 47 0a 09 2f 2a 20 ET_ENCODING../*
2730: 53 65 74 20 74 68 65 20 65 6e 63 6f 64 69 6e 67 Set the encoding
2740: 20 66 72 6f 6d 20 74 68 65 20 45 6e 76 69 72 6f from the Enviro
2750: 6e 6d 65 6e 74 20 2a 2f 0a 09 54 63 6c 5f 47 65 nment */..Tcl_Ge
2760: 74 45 6e 63 6f 64 69 6e 67 4e 61 6d 65 46 72 6f tEncodingNameFro
2770: 6d 45 6e 76 69 72 6f 6e 6d 65 6e 74 28 26 65 6e mEnvironment(&en
2780: 63 6f 64 69 6e 67 4e 61 6d 65 29 3b 0a 09 54 63 codingName);..Tc
2790: 6c 5f 53 65 74 53 79 73 74 65 6d 45 6e 63 6f 64 l_SetSystemEncod
27a0: 69 6e 67 28 4e 55 4c 4c 2c 20 54 63 6c 5f 44 53 ing(NULL, Tcl_DS
27b0: 74 72 69 6e 67 56 61 6c 75 65 28 26 65 6e 63 6f tringValue(&enco
27c0: 64 69 6e 67 4e 61 6d 65 29 29 3b 0a 09 54 63 6c dingName));..Tcl
27d0: 5f 53 65 74 56 61 72 28 69 6e 74 65 72 70 2c 20 _SetVar(interp,
27e0: 22 74 63 6c 6b 69 74 5f 73 79 73 74 65 6d 5f 65 "tclkit_system_e
27f0: 6e 63 6f 64 69 6e 67 22 2c 20 54 63 6c 5f 44 53 ncoding", Tcl_DS
2800: 74 72 69 6e 67 56 61 6c 75 65 28 26 65 6e 63 6f tringValue(&enco
2810: 64 69 6e 67 4e 61 6d 65 29 2c 20 30 29 3b 0a 09 dingName), 0);..
2820: 54 63 6c 5f 44 53 74 72 69 6e 67 46 72 65 65 28 Tcl_DStringFree(
2830: 26 65 6e 63 6f 64 69 6e 67 4e 61 6d 65 29 3b 0a &encodingName);.
2840: 23 65 6e 64 69 66 20 2f 2a 20 54 43 4c 4b 49 54 #endif /* TCLKIT
2850: 5f 43 41 4e 5f 53 45 54 5f 45 4e 43 4f 44 49 4e _CAN_SET_ENCODIN
2860: 47 20 2a 2f 0a 0a 09 2f 2a 20 48 61 63 6b 20 74 G */.../* Hack t
2870: 6f 20 67 65 74 20 61 72 6f 75 6e 64 20 54 63 6c o get around Tcl
2880: 20 62 75 67 20 31 32 32 34 38 38 38 2e 20 20 54 bug 1224888. T
2890: 68 69 73 20 6d 75 73 74 20 62 65 20 72 75 6e 20 his must be run
28a0: 68 65 72 65 20 61 6e 64 0a 09 20 2a 20 69 6e 20 here and.. * in
28b0: 4c 69 62 72 61 72 79 50 61 74 68 4f 62 6a 43 6d LibraryPathObjCm
28c0: 64 20 62 65 63 61 75 73 65 20 74 68 69 73 20 69 d because this i
28d0: 6e 66 6f 72 6d 61 74 69 6f 6e 20 69 73 20 6e 65 nformation is ne
28e0: 65 64 65 64 20 62 6f 74 68 0a 09 20 2a 20 62 65 eded both.. * be
28f0: 66 6f 72 65 20 61 6e 64 20 61 66 74 65 72 20 74 fore and after t
2900: 68 61 74 20 63 6f 6d 6d 61 6e 64 20 69 73 20 72 hat command is r
2910: 75 6e 2e 20 2a 2f 0a 09 46 69 6e 64 41 6e 64 53 un. */..FindAndS
2920: 65 74 45 78 65 63 4e 61 6d 65 28 69 6e 74 65 72 etExecName(inter
2930: 70 29 3b 0a 0a 23 69 66 20 64 65 66 69 6e 65 64 p);..#if defined
2940: 28 5f 57 49 4e 33 32 29 20 26 26 20 64 65 66 69 (_WIN32) && defi
2950: 6e 65 64 28 4b 49 54 5f 49 4e 43 4c 55 44 45 53 ned(KIT_INCLUDES
2960: 5f 54 4b 29 0a 09 2f 2a 20 45 76 65 72 79 20 69 _TK)../* Every i
2970: 6e 74 65 72 70 72 65 74 65 72 20 6e 65 65 64 73 nterpreter needs
2980: 20 74 68 69 73 20 64 6f 6e 65 20 2a 2f 0a 09 54 this done */..T
2990: 6b 5f 49 6e 69 74 43 6f 6e 73 6f 6c 65 43 68 61 k_InitConsoleCha
29a0: 6e 6e 65 6c 73 28 69 6e 74 65 72 70 29 3b 0a 23 nnels(interp);.#
29b0: 65 6e 64 69 66 20 2f 2a 20 5f 57 49 4e 33 32 20 endif /* _WIN32
29c0: 61 6e 64 20 4b 49 54 5f 49 4e 43 4c 55 44 45 53 and KIT_INCLUDES
29d0: 5f 54 4b 20 2a 2f 0a 0a 09 72 65 74 75 72 6e 3b _TK */...return;
29e0: 0a 7d 0a 0a 23 69 66 6e 64 65 66 20 54 43 4c 4b .}..#ifndef TCLK
29f0: 49 54 5f 44 4c 4c 0a 69 6e 74 20 54 63 6c 4b 69 IT_DLL.int TclKi
2a00: 74 5f 41 70 70 49 6e 69 74 28 54 63 6c 5f 49 6e t_AppInit(Tcl_In
2a10: 74 65 72 70 20 2a 69 6e 74 65 72 70 29 20 7b 0a terp *interp) {.
2a20: 23 69 66 64 65 66 20 4b 49 54 5f 49 4e 43 4c 55 #ifdef KIT_INCLU
2a30: 44 45 53 5f 54 4b 0a 23 20 20 69 66 64 65 66 20 DES_TK.# ifdef
2a40: 5f 57 49 4e 33 32 0a 23 20 20 20 20 69 66 6e 64 _WIN32.# ifnd
2a50: 65 66 20 5f 57 49 4e 33 32 5f 57 43 45 0a 09 63 ef _WIN32_WCE..c
2a60: 68 61 72 20 6d 73 67 42 75 66 5b 32 30 34 39 5d har msgBuf[2049]
2a70: 3b 0a 23 20 20 20 20 65 6e 64 69 66 20 2f 2a 20 ;.# endif /*
2a80: 21 5f 57 49 4e 33 32 5f 57 43 45 20 2a 2f 0a 23 !_WIN32_WCE */.#
2a90: 20 20 65 6e 64 69 66 20 2f 2a 20 5f 57 49 4e 33 endif /* _WIN3
2aa0: 32 20 2a 2f 0a 23 65 6e 64 69 66 20 2f 2a 20 4b 2 */.#endif /* K
2ab0: 49 54 5f 49 4e 43 4c 55 44 45 53 5f 54 4b 20 2a IT_INCLUDES_TK *
2ac0: 2f 0a 0a 09 2f 2a 20 50 65 72 66 6f 72 6d 20 63 /.../* Perform c
2ad0: 6f 6d 6d 6f 6e 20 69 6e 69 74 69 61 6c 69 7a 61 ommon initializa
2ae0: 74 69 6f 6e 20 2a 2f 0a 09 5f 54 63 6c 6b 69 74 tion */.._Tclkit
2af0: 5f 49 6e 69 74 28 29 3b 0a 0a 09 69 66 20 28 54 _Init();...if (T
2b00: 63 6c 5f 49 6e 69 74 28 69 6e 74 65 72 70 29 20 cl_Init(interp)
2b10: 3d 3d 20 54 43 4c 5f 45 52 52 4f 52 29 20 7b 0a == TCL_ERROR) {.
2b20: 09 09 67 6f 74 6f 20 65 72 72 6f 72 3b 0a 09 7d ..goto error;..}
2b30: 0a 0a 23 69 66 64 65 66 20 4b 49 54 5f 49 4e 43 ..#ifdef KIT_INC
2b40: 4c 55 44 45 53 5f 54 4b 0a 23 20 20 69 66 64 65 LUDES_TK.# ifde
2b50: 66 20 5f 57 49 4e 33 32 0a 09 69 66 20 28 54 6b f _WIN32..if (Tk
2b60: 5f 49 6e 69 74 28 69 6e 74 65 72 70 29 20 3d 3d _Init(interp) ==
2b70: 20 54 43 4c 5f 45 52 52 4f 52 29 20 7b 0a 09 09 TCL_ERROR) {...
2b80: 67 6f 74 6f 20 65 72 72 6f 72 3b 0a 09 7d 0a 09 goto error;..}..
2b90: 69 66 20 28 54 6b 5f 43 72 65 61 74 65 43 6f 6e if (Tk_CreateCon
2ba0: 73 6f 6c 65 57 69 6e 64 6f 77 28 69 6e 74 65 72 soleWindow(inter
2bb0: 70 29 20 3d 3d 20 54 43 4c 5f 45 52 52 4f 52 29 p) == TCL_ERROR)
2bc0: 20 7b 0a 09 09 67 6f 74 6f 20 65 72 72 6f 72 3b {...goto error;
2bd0: 0a 09 7d 0a 23 20 20 65 6e 64 69 66 20 2f 2a 20 ..}.# endif /*
2be0: 5f 57 49 4e 33 32 20 2a 2f 0a 23 65 6e 64 69 66 _WIN32 */.#endif
2bf0: 20 2f 2a 20 4b 49 54 5f 49 4e 43 4c 55 44 45 53 /* KIT_INCLUDES
2c00: 5f 54 4b 20 2a 2f 0a 0a 09 2f 2a 20 6d 65 73 73 _TK */.../* mess
2c10: 79 20 62 65 63 61 75 73 65 20 54 63 6c 53 65 74 y because TclSet
2c20: 53 74 61 72 74 75 70 53 63 72 69 70 74 50 61 74 StartupScriptPat
2c30: 68 20 69 73 20 63 61 6c 6c 65 64 20 73 6c 69 67 h is called slig
2c40: 68 74 6c 79 20 74 6f 6f 20 6c 61 74 65 20 2a 2f htly too late */
2c50: 0a 09 69 66 20 28 54 63 6c 5f 45 76 61 6c 28 69 ..if (Tcl_Eval(i
2c60: 6e 74 65 72 70 2c 20 69 6e 69 74 53 63 72 69 70 nterp, initScrip
2c70: 74 29 20 3d 3d 20 54 43 4c 5f 4f 4b 29 20 7b 0a t) == TCL_OK) {.
2c80: 09 09 54 63 6c 5f 4f 62 6a 2a 20 70 61 74 68 3b ..Tcl_Obj* path;
2c90: 0a 23 69 66 64 65 66 20 48 41 56 45 5f 54 43 4c .#ifdef HAVE_TCL
2ca0: 53 45 54 53 54 41 52 54 55 50 53 43 52 49 50 54 SETSTARTUPSCRIPT
2cb0: 50 41 54 48 0a 09 09 70 61 74 68 20 3d 20 54 63 PATH...path = Tc
2cc0: 6c 47 65 74 53 74 61 72 74 75 70 53 63 72 69 70 lGetStartupScrip
2cd0: 74 50 61 74 68 28 29 3b 0a 09 09 54 63 6c 53 65 tPath();...TclSe
2ce0: 74 53 74 61 72 74 75 70 53 63 72 69 70 74 50 61 tStartupScriptPa
2cf0: 74 68 28 54 63 6c 5f 47 65 74 4f 62 6a 52 65 73 th(Tcl_GetObjRes
2d00: 75 6c 74 28 69 6e 74 65 72 70 29 29 3b 0a 23 65 ult(interp));.#e
2d10: 6c 69 66 20 64 65 66 69 6e 65 64 28 48 41 56 45 lif defined(HAVE
2d20: 5f 54 43 4c 5f 53 45 54 53 54 41 52 54 55 50 53 _TCL_SETSTARTUPS
2d30: 43 52 49 50 54 29 0a 09 09 70 61 74 68 20 3d 20 CRIPT)...path =
2d40: 54 63 6c 5f 47 65 74 53 74 61 72 74 75 70 53 63 Tcl_GetStartupSc
2d50: 72 69 70 74 28 4e 55 4c 4c 29 3b 0a 09 09 54 63 ript(NULL);...Tc
2d60: 6c 5f 53 65 74 53 74 61 72 74 75 70 53 63 72 69 l_SetStartupScri
2d70: 70 74 28 54 63 6c 5f 47 65 74 4f 62 6a 52 65 73 pt(Tcl_GetObjRes
2d80: 75 6c 74 28 69 6e 74 65 72 70 29 2c 20 4e 55 4c ult(interp), NUL
2d90: 4c 29 3b 0a 23 65 6e 64 69 66 0a 09 09 69 66 20 L);.#endif...if
2da0: 28 70 61 74 68 20 3d 3d 20 4e 55 4c 4c 29 20 7b (path == NULL) {
2db0: 0a 09 09 09 54 63 6c 5f 45 76 61 6c 28 69 6e 74 ....Tcl_Eval(int
2dc0: 65 72 70 2c 20 22 69 6e 63 72 20 61 72 67 63 20 erp, "incr argc
2dd0: 2d 31 3b 20 73 65 74 20 61 72 67 76 20 5b 6c 72 -1; set argv [lr
2de0: 61 6e 67 65 20 24 61 72 67 76 20 31 20 65 6e 64 ange $argv 1 end
2df0: 5d 22 29 3b 0a 09 09 7d 0a 09 7d 0a 0a 09 54 63 ]");...}..}...Tc
2e00: 6c 5f 53 65 74 56 61 72 28 69 6e 74 65 72 70 2c l_SetVar(interp,
2e10: 20 22 65 72 72 6f 72 49 6e 66 6f 22 2c 20 22 22 "errorInfo", ""
2e20: 2c 20 54 43 4c 5f 47 4c 4f 42 41 4c 5f 4f 4e 4c , TCL_GLOBAL_ONL
2e30: 59 29 3b 0a 09 54 63 6c 5f 52 65 73 65 74 52 65 Y);..Tcl_ResetRe
2e40: 73 75 6c 74 28 69 6e 74 65 72 70 29 3b 0a 0a 09 sult(interp);...
2e50: 72 65 74 75 72 6e 20 54 43 4c 5f 4f 4b 3b 0a 0a return TCL_OK;..
2e60: 65 72 72 6f 72 3a 0a 23 69 66 64 65 66 20 4b 49 error:.#ifdef KI
2e70: 54 5f 49 4e 43 4c 55 44 45 53 5f 54 4b 0a 23 20 T_INCLUDES_TK.#
2e80: 20 69 66 64 65 66 20 5f 57 49 4e 33 32 0a 09 4d ifdef _WIN32..M
2e90: 65 73 73 61 67 65 42 65 65 70 28 4d 42 5f 49 43 essageBeep(MB_IC
2ea0: 4f 4e 45 58 43 4c 41 4d 41 54 49 4f 4e 29 3b 0a ONEXCLAMATION);.
2eb0: 23 20 20 20 20 69 66 6e 64 65 66 20 5f 57 49 4e # ifndef _WIN
2ec0: 33 32 5f 57 43 45 0a 09 73 6e 70 72 69 6e 74 66 32_WCE..snprintf
2ed0: 28 6d 73 67 42 75 66 2c 20 73 69 7a 65 6f 66 28 (msgBuf, sizeof(
2ee0: 6d 73 67 42 75 66 29 2c 0a 09 09 22 41 20 63 72 msgBuf),..."A cr
2ef0: 69 74 69 63 61 6c 20 65 72 72 6f 72 20 68 61 73 itical error has
2f00: 20 6f 63 63 75 72 72 65 64 2e 20 20 50 6c 65 61 occurred. Plea
2f10: 73 65 20 72 65 70 6f 72 74 20 74 68 69 73 20 74 se report this t
2f20: 6f 20 74 68 65 20 54 63 6c 6b 69 74 20 76 65 6e o the Tclkit ven
2f30: 64 6f 72 2e 5c 6e 49 6e 74 65 72 70 72 65 74 65 dor.\nInterprete
2f40: 72 20 52 65 74 75 72 6e 65 64 3a 20 25 73 5c 6e r Returned: %s\n
2f50: 45 72 72 6f 72 20 49 6e 66 6f 3a 20 25 73 22 2c Error Info: %s",
2f60: 0a 09 09 54 63 6c 5f 47 65 74 53 74 72 69 6e 67 ...Tcl_GetString
2f70: 52 65 73 75 6c 74 28 69 6e 74 65 72 70 29 2c 0a Result(interp),.
2f80: 09 09 54 63 6c 5f 47 65 74 56 61 72 28 69 6e 74 ..Tcl_GetVar(int
2f90: 65 72 70 2c 20 22 65 72 72 6f 72 49 6e 66 6f 22 erp, "errorInfo"
2fa0: 2c 20 54 43 4c 5f 47 4c 4f 42 41 4c 5f 4f 4e 4c , TCL_GLOBAL_ONL
2fb0: 59 29 29 3b 0a 0a 09 4d 65 73 73 61 67 65 42 6f Y));...MessageBo
2fc0: 78 28 4e 55 4c 4c 2c 20 6d 73 67 42 75 66 2c 20 x(NULL, msgBuf,
2fd0: 22 45 72 72 6f 72 20 69 6e 20 54 63 6c 4b 69 74 "Error in TclKit
2fe0: 22 2c 0a 09 09 4d 42 5f 49 43 4f 4e 53 54 4f 50 ",...MB_ICONSTOP
2ff0: 20 7c 20 4d 42 5f 4f 4b 20 7c 20 4d 42 5f 54 41 | MB_OK | MB_TA
3000: 53 4b 4d 4f 44 41 4c 20 7c 20 4d 42 5f 53 45 54 SKMODAL | MB_SET
3010: 46 4f 52 45 47 52 4f 55 4e 44 29 3b 0a 0a 09 45 FOREGROUND);...E
3020: 78 69 74 50 72 6f 63 65 73 73 28 31 29 3b 0a 23 xitProcess(1);.#
3030: 20 20 20 20 65 6e 64 69 66 20 2f 2a 20 21 5f 57 endif /* !_W
3040: 49 4e 33 32 5f 57 43 45 20 2a 2f 0a 20 20 20 20 IN32_WCE */.
3050: 2f 2a 20 77 65 20 77 6f 6e 27 74 20 72 65 61 63 /* we won't reac
3060: 68 20 74 68 69 73 2c 20 62 75 74 20 77 65 20 6e h this, but we n
3070: 65 65 64 20 74 68 65 20 72 65 74 75 72 6e 20 2a eed the return *
3080: 2f 0a 23 20 20 65 6e 64 69 66 20 2f 2a 20 5f 57 /.# endif /* _W
3090: 49 4e 33 32 20 2a 2f 0a 23 65 6e 64 69 66 20 2f IN32 */.#endif /
30a0: 2a 20 4b 49 54 5f 49 4e 43 4c 55 44 45 53 5f 54 * KIT_INCLUDES_T
30b0: 4b 20 2a 2f 0a 0a 09 72 65 74 75 72 6e 20 54 43 K */...return TC
30c0: 4c 5f 45 52 52 4f 52 3b 0a 7d 0a 23 65 6e 64 69 L_ERROR;.}.#endi
30d0: 66 20 2f 2a 20 21 54 43 4c 4b 49 54 5f 44 4c 4c f /* !TCLKIT_DLL
30e0: 20 2a 2f 0a 0a 0a 23 69 66 64 65 66 20 54 43 4c */...#ifdef TCL
30f0: 4b 49 54 5f 44 4c 4c 0a 23 20 20 69 66 64 65 66 KIT_DLL.# ifdef
3100: 20 48 41 56 45 5f 41 43 43 45 50 54 41 42 4c 45 HAVE_ACCEPTABLE
3110: 5f 44 4c 41 44 44 52 0a 2f 2a 20 53 79 6d 62 6f _DLADDR./* Symbo
3120: 6c 20 74 6f 20 72 65 73 6f 6c 76 65 20 61 67 61 l to resolve aga
3130: 69 6e 73 74 20 64 6c 61 64 64 72 28 29 20 2a 2f inst dladdr() */
3140: 0a 73 74 61 74 69 63 20 76 6f 69 64 20 5f 74 63 .static void _tc
3150: 6c 6b 69 74 5f 64 75 6d 6d 79 5f 66 75 6e 63 28 lkit_dummy_func(
3160: 76 6f 69 64 29 20 7b 0a 09 72 65 74 75 72 6e 3b void) {..return;
3170: 0a 7d 0a 23 20 20 65 6e 64 69 66 20 2f 2a 20 48 .}.# endif /* H
3180: 41 56 45 5f 41 43 43 45 50 54 41 42 4c 45 5f 44 AVE_ACCEPTABLE_D
3190: 4c 41 44 44 52 20 2a 2f 0a 0a 2f 2a 0a 20 2a 20 LADDR */../*. *
31a0: 54 68 69 73 20 66 75 6e 63 74 69 6f 6e 20 77 69 This function wi
31b0: 6c 6c 20 72 65 74 75 72 6e 20 61 20 70 61 74 68 ll return a path
31c0: 6e 61 6d 65 20 77 65 20 63 61 6e 20 6f 70 65 6e name we can open
31d0: 28 29 20 74 6f 20 74 72 65 61 74 20 61 73 20 61 () to treat as a
31e0: 20 56 46 53 2c 0a 20 2a 20 68 6f 70 65 66 75 6c VFS,. * hopeful
31f0: 6c 79 0a 20 2a 2f 0a 73 74 61 74 69 63 20 63 68 ly. */.static ch
3200: 61 72 20 2a 66 69 6e 64 5f 74 63 6c 6b 69 74 5f ar *find_tclkit_
3210: 64 6c 6c 5f 70 61 74 68 28 76 6f 69 64 29 20 7b dll_path(void) {
3220: 0a 23 69 66 64 65 66 20 48 41 56 45 5f 41 43 43 .#ifdef HAVE_ACC
3230: 45 50 54 41 42 4c 45 5f 44 4c 41 44 44 52 0a 09 EPTABLE_DLADDR..
3240: 44 6c 5f 69 6e 66 6f 20 73 79 6d 69 6e 66 6f 3b Dl_info syminfo;
3250: 0a 09 69 6e 74 20 64 6c 61 64 64 72 5f 72 65 74 ..int dladdr_ret
3260: 3b 0a 23 65 6e 64 69 66 20 2f 2a 20 48 41 56 45 ;.#endif /* HAVE
3270: 5f 41 43 43 45 50 54 41 42 4c 45 5f 44 4c 41 44 _ACCEPTABLE_DLAD
3280: 44 52 20 2a 2f 0a 23 69 66 64 65 66 20 5f 57 49 DR */.#ifdef _WI
3290: 4e 33 32 0a 09 54 43 48 41 52 20 6d 6f 64 75 6c N32..TCHAR modul
32a0: 65 6e 61 6d 65 5b 38 31 39 32 5d 3b 0a 09 44 57 ename[8192];..DW
32b0: 4f 52 44 20 67 6d 66 6e 5f 72 65 74 3b 0a 23 65 ORD gmfn_ret;.#e
32c0: 6e 64 69 66 20 2f 2a 20 5f 57 49 4e 33 32 20 2a ndif /* _WIN32 *
32d0: 2f 0a 0a 23 69 66 64 65 66 20 48 41 56 45 5f 41 /..#ifdef HAVE_A
32e0: 43 43 45 50 54 41 42 4c 45 5f 44 4c 41 44 44 52 CCEPTABLE_DLADDR
32f0: 0a 09 64 6c 61 64 64 72 5f 72 65 74 20 3d 20 64 ..dladdr_ret = d
3300: 6c 61 64 64 72 28 26 5f 74 63 6c 6b 69 74 5f 64 laddr(&_tclkit_d
3310: 75 6d 6d 79 5f 66 75 6e 63 2c 20 26 73 79 6d 69 ummy_func, &symi
3320: 6e 66 6f 29 3b 0a 09 69 66 20 28 64 6c 61 64 64 nfo);..if (dladd
3330: 72 5f 72 65 74 20 21 3d 20 30 29 20 7b 0a 09 09 r_ret != 0) {...
3340: 69 66 20 28 73 79 6d 69 6e 66 6f 2e 64 6c 69 5f if (syminfo.dli_
3350: 66 6e 61 6d 65 20 26 26 20 73 79 6d 69 6e 66 6f fname && syminfo
3360: 2e 64 6c 69 5f 66 6e 61 6d 65 5b 30 5d 20 21 3d .dli_fname[0] !=
3370: 20 27 5c 30 27 29 20 7b 0a 09 09 09 72 65 74 75 '\0') {....retu
3380: 72 6e 28 73 74 72 64 75 70 28 73 79 6d 69 6e 66 rn(strdup(syminf
3390: 6f 2e 64 6c 69 5f 66 6e 61 6d 65 29 29 3b 0a 09 o.dli_fname));..
33a0: 09 7d 0a 09 7d 0a 23 65 6e 64 69 66 20 2f 2a 20 .}..}.#endif /*
33b0: 48 41 56 45 5f 41 43 43 45 50 54 41 42 4c 45 5f HAVE_ACCEPTABLE_
33c0: 44 4c 41 44 44 52 20 2a 2f 0a 0a 23 69 66 64 65 DLADDR */..#ifde
33d0: 66 20 5f 57 49 4e 33 32 0a 09 67 6d 66 6e 5f 72 f _WIN32..gmfn_r
33e0: 65 74 20 3d 20 47 65 74 4d 6f 64 75 6c 65 46 69 et = GetModuleFi
33f0: 6c 65 4e 61 6d 65 28 54 63 6c 57 69 6e 47 65 74 leName(TclWinGet
3400: 54 63 6c 49 6e 73 74 61 6e 63 65 28 29 2c 20 6d TclInstance(), m
3410: 6f 64 75 6c 65 6e 61 6d 65 2c 20 73 69 7a 65 6f odulename, sizeo
3420: 66 28 6d 6f 64 75 6c 65 6e 61 6d 65 29 20 2f 20 f(modulename) /
3430: 73 69 7a 65 6f 66 28 6d 6f 64 75 6c 65 6e 61 6d sizeof(modulenam
3440: 65 5b 30 5d 29 20 2d 20 31 29 3b 0a 0a 09 69 66 e[0]) - 1);...if
3450: 20 28 67 6d 66 6e 5f 72 65 74 20 21 3d 20 30 29 (gmfn_ret != 0)
3460: 20 7b 0a 09 09 72 65 74 75 72 6e 28 73 74 72 64 {...return(strd
3470: 75 70 28 6d 6f 64 75 6c 65 6e 61 6d 65 29 29 3b up(modulename));
3480: 0a 09 7d 0a 23 65 6e 64 69 66 20 2f 2a 20 5f 57 ..}.#endif /* _W
3490: 49 4e 33 32 20 2a 2f 0a 0a 09 72 65 74 75 72 6e IN32 */...return
34a0: 28 4e 55 4c 4c 29 3b 0a 7d 0a 23 65 6c 73 65 0a (NULL);.}.#else.
34b0: 23 20 64 65 66 69 6e 65 20 66 69 6e 64 5f 74 63 # define find_tc
34c0: 6c 6b 69 74 5f 64 6c 6c 5f 70 61 74 68 28 29 20 lkit_dll_path()
34d0: 4e 55 4c 4c 0a 23 65 6e 64 69 66 0a 0a 2f 2a 0a NULL.#endif../*.
34e0: 20 2a 20 54 68 69 73 20 66 75 6e 63 74 69 6f 6e * This function
34f0: 20 65 78 69 73 74 73 20 74 6f 20 61 6c 6c 6f 77 exists to allow
3500: 20 43 20 63 6f 64 65 20 74 6f 20 69 6e 69 74 69 C code to initi
3510: 61 6c 69 7a 65 20 61 20 70 61 72 74 69 63 75 6c alize a particul
3520: 61 72 0a 20 2a 20 69 6e 74 65 72 70 72 65 74 65 ar. * interprete
3530: 72 2e 0a 20 2a 2f 0a 73 74 61 74 69 63 20 69 6e r.. */.static in
3540: 74 20 74 63 6c 6b 69 74 5f 69 6e 69 74 5f 69 6e t tclkit_init_in
3550: 69 74 69 6e 74 65 72 70 28 43 6c 69 65 6e 74 44 itinterp(ClientD
3560: 61 74 61 20 63 64 2c 20 54 63 6c 5f 49 6e 74 65 ata cd, Tcl_Inte
3570: 72 70 20 2a 69 6e 74 65 72 70 2c 20 69 6e 74 20 rp *interp, int
3580: 6f 62 6a 63 2c 20 54 63 6c 5f 4f 62 6a 20 2a 43 objc, Tcl_Obj *C
3590: 4f 4e 53 54 20 6f 62 6a 76 5b 5d 29 20 7b 0a 09 ONST objv[]) {..
35a0: 63 68 61 72 20 2a 6b 69 74 64 6c 6c 5f 70 61 74 char *kitdll_pat
35b0: 68 3b 0a 0a 09 6b 69 74 64 6c 6c 5f 70 61 74 68 h;...kitdll_path
35c0: 20 3d 20 66 69 6e 64 5f 74 63 6c 6b 69 74 5f 64 = find_tclkit_d
35d0: 6c 6c 5f 70 61 74 68 28 29 3b 0a 09 69 66 20 28 ll_path();..if (
35e0: 6b 69 74 64 6c 6c 5f 70 61 74 68 20 21 3d 20 4e kitdll_path != N
35f0: 55 4c 4c 29 20 7b 0a 09 09 54 63 6c 5f 53 65 74 ULL) {...Tcl_Set
3600: 56 61 72 28 69 6e 74 65 72 70 2c 20 22 74 63 6c Var(interp, "tcl
3610: 4b 69 74 46 69 6c 65 6e 61 6d 65 22 2c 20 6b 69 KitFilename", ki
3620: 74 64 6c 6c 5f 70 61 74 68 2c 20 54 43 4c 5f 47 tdll_path, TCL_G
3630: 4c 4f 42 41 4c 5f 4f 4e 4c 59 29 3b 0a 0a 09 09 LOBAL_ONLY);....
3640: 66 72 65 65 28 6b 69 74 64 6c 6c 5f 70 61 74 68 free(kitdll_path
3650: 29 3b 0a 09 7d 0a 0a 09 5f 54 63 6c 6b 69 74 5f );..}..._Tclkit_
3660: 49 6e 74 65 72 70 5f 49 6e 69 74 28 69 6e 74 65 Interp_Init(inte
3670: 72 70 29 3b 0a 0a 09 72 65 74 75 72 6e 28 54 43 rp);...return(TC
3680: 4c 5f 4f 4b 29 3b 0a 7d 0a 0a 2f 2a 0a 20 2a 20 L_OK);.}../*. *
3690: 43 72 65 61 74 65 20 61 20 70 61 63 6b 61 67 65 Create a package
36a0: 20 66 6f 72 20 69 6e 69 74 69 61 6c 69 7a 69 6e for initializin
36b0: 67 20 61 20 70 61 72 74 69 63 75 6c 61 72 20 69 g a particular i
36c0: 6e 74 65 72 70 72 65 74 65 72 2e 20 20 54 68 69 nterpreter. Thi
36d0: 73 20 69 73 0a 20 2a 20 6f 75 72 20 68 6f 6f 6b s is. * our hook
36e0: 20 74 6f 20 68 61 76 65 20 54 63 6c 20 69 6e 76 to have Tcl inv
36f0: 6f 6b 65 20 43 20 63 6f 6d 6d 61 6e 64 73 20 77 oke C commands w
3700: 68 65 6e 20 63 72 65 61 74 69 6e 67 20 61 6e 20 hen creating an
3710: 69 6e 74 65 72 70 72 65 74 65 72 2e 0a 20 2a 20 interpreter.. *
3720: 54 68 65 20 70 72 65 49 6e 69 74 43 6d 64 20 77 The preInitCmd w
3730: 69 6c 6c 20 6c 6f 61 64 20 74 68 65 20 70 61 63 ill load the pac
3740: 6b 61 67 65 20 69 6e 20 74 68 65 20 6e 65 77 20 kage in the new
3750: 69 6e 74 65 72 70 72 65 74 65 72 20 61 6e 64 20 interpreter and
3760: 69 6e 76 6f 6b 65 0a 20 2a 20 74 68 69 73 20 66 invoke. * this f
3770: 75 6e 63 74 69 6f 6e 2e 0a 20 2a 2f 0a 69 6e 74 unction.. */.int
3780: 20 54 63 6c 6b 69 74 5f 69 6e 69 74 5f 49 6e 69 Tclkit_init_Ini
3790: 74 28 54 63 6c 5f 49 6e 74 65 72 70 20 2a 69 6e t(Tcl_Interp *in
37a0: 74 65 72 70 29 20 7b 0a 09 54 63 6c 5f 43 6f 6d terp) {..Tcl_Com
37b0: 6d 61 6e 64 20 74 63 6c 43 72 65 61 74 43 6f 6d mand tclCreatCom
37c0: 6d 5f 72 65 74 3b 0a 09 69 6e 74 20 74 63 6c 50 m_ret;..int tclP
37d0: 6b 67 50 72 6f 76 5f 72 65 74 3b 0a 0a 09 74 63 kgProv_ret;...tc
37e0: 6c 43 72 65 61 74 43 6f 6d 6d 5f 72 65 74 20 3d lCreatComm_ret =
37f0: 20 54 63 6c 5f 43 72 65 61 74 65 4f 62 6a 43 6f Tcl_CreateObjCo
3800: 6d 6d 61 6e 64 28 69 6e 74 65 72 70 2c 20 22 3a mmand(interp, ":
3810: 3a 74 63 6c 6b 69 74 3a 3a 69 6e 69 74 3a 3a 69 :tclkit::init::i
3820: 6e 69 74 49 6e 74 65 72 70 22 2c 20 74 63 6c 6b nitInterp", tclk
3830: 69 74 5f 69 6e 69 74 5f 69 6e 69 74 69 6e 74 65 it_init_initinte
3840: 72 70 2c 20 4e 55 4c 4c 2c 20 4e 55 4c 4c 29 3b rp, NULL, NULL);
3850: 0a 09 69 66 20 28 21 74 63 6c 43 72 65 61 74 43 ..if (!tclCreatC
3860: 6f 6d 6d 5f 72 65 74 29 20 7b 0a 09 09 72 65 74 omm_ret) {...ret
3870: 75 72 6e 28 54 43 4c 5f 45 52 52 4f 52 29 3b 0a urn(TCL_ERROR);.
3880: 09 7d 0a 0a 09 74 63 6c 50 6b 67 50 72 6f 76 5f .}...tclPkgProv_
3890: 72 65 74 20 3d 20 54 63 6c 5f 50 6b 67 50 72 6f ret = Tcl_PkgPro
38a0: 76 69 64 65 28 69 6e 74 65 72 70 2c 20 22 74 63 vide(interp, "tc
38b0: 6c 6b 69 74 3a 3a 69 6e 69 74 22 2c 20 22 31 2e lkit::init", "1.
38c0: 30 22 29 3b 0a 0a 09 72 65 74 75 72 6e 28 74 63 0");...return(tc
38d0: 6c 50 6b 67 50 72 6f 76 5f 72 65 74 29 3b 0a 7d lPkgProv_ret);.}
38e0: 0a 0a 2f 2a 0a 20 2a 20 49 6e 69 74 69 61 6c 69 ../*. * Initiali
38f0: 7a 65 20 74 68 65 20 54 63 6c 20 73 79 73 74 65 ze the Tcl syste
3900: 6d 20 77 68 65 6e 20 77 65 20 61 72 65 20 6c 6f m when we are lo
3910: 61 64 65 64 2c 20 74 68 61 74 20 77 61 79 20 54 aded, that way T
3920: 63 6c 20 66 75 6e 63 74 69 6f 6e 73 0a 20 2a 20 cl functions. *
3930: 61 72 65 20 72 65 61 64 79 20 74 6f 20 62 65 20 are ready to be
3940: 75 73 65 64 20 77 68 65 6e 20 69 6e 76 6f 6b 65 used when invoke
3950: 64 2e 0a 20 2a 2f 0a 23 69 66 64 65 66 20 54 43 d.. */.#ifdef TC
3960: 4c 4b 49 54 5f 44 4c 4c 0a 76 6f 69 64 20 5f 5f LKIT_DLL.void __
3970: 61 74 74 72 69 62 75 74 65 5f 5f 28 28 63 6f 6e attribute__((con
3980: 73 74 72 75 63 74 6f 72 29 29 20 5f 54 63 6c 6b structor)) _Tclk
3990: 69 74 5f 49 6e 69 74 28 76 6f 69 64 29 20 7b 0a it_Init(void) {.
39a0: 23 65 6c 73 65 0a 73 74 61 74 69 63 20 76 6f 69 #else.static voi
39b0: 64 20 5f 54 63 6c 6b 69 74 5f 49 6e 69 74 28 76 d _Tclkit_Init(v
39c0: 6f 69 64 29 20 7b 0a 23 65 6e 64 69 66 0a 09 54 oid) {.#endif..T
39d0: 63 6c 5f 53 74 61 74 69 63 50 61 63 6b 61 67 65 cl_StaticPackage
39e0: 28 30 2c 20 22 74 63 6c 6b 69 74 3a 3a 69 6e 69 (0, "tclkit::ini
39f0: 74 22 2c 20 54 63 6c 6b 69 74 5f 69 6e 69 74 5f t", Tclkit_init_
3a00: 49 6e 69 74 2c 20 4e 55 4c 4c 29 3b 0a 0a 09 5f Init, NULL);..._
3a10: 54 63 6c 6b 69 74 5f 47 65 6e 65 72 69 63 5f 49 Tclkit_Generic_I
3a20: 6e 69 74 28 29 3b 0a 0a 09 72 65 74 75 72 6e 3b nit();...return;
3a30: 0a 7d 0a .}.