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 52 45 51 55 49 52 45 5f 54 TCLKIT_REQUIRE_T
0a70: 43 4c 45 58 45 43 55 54 41 42 4c 45 4e 41 4d 45 CLEXECUTABLENAME
0a80: 0a 63 68 61 72 20 2a 74 63 6c 45 78 65 63 75 74 .char *tclExecut
0a90: 61 62 6c 65 4e 61 6d 65 3b 0a 23 65 6e 64 69 66 ableName;.#endif
0aa0: 0a 0a 2f 2a 0a 20 2a 20 20 41 74 74 65 6d 70 74 ../*. * Attempt
0ab0: 20 74 6f 20 6c 6f 61 64 20 61 20 22 62 6f 6f 74 to load a "boot
0ac0: 2e 74 63 6c 22 20 65 6e 74 72 79 20 66 72 6f 6d .tcl" entry from
0ad0: 20 74 68 65 20 65 6d 62 65 64 64 65 64 20 4d 65 the embedded Me
0ae0: 74 61 4b 69 74 20 66 69 6c 65 2e 0a 20 2a 2f 0a taKit file.. */.
0af0: 2f 2a 0a 20 2a 20 54 68 69 73 20 54 63 6c 20 63 /*. * This Tcl c
0b00: 6f 64 65 20 69 73 20 69 6e 76 6f 6b 65 64 20 77 ode is invoked w
0b10: 68 65 6e 65 76 65 72 20 54 63 6c 5f 49 6e 69 74 henever Tcl_Init
0b20: 28 29 20 69 73 20 63 61 6c 6c 65 64 20 6f 6e 20 () is called on
0b30: 61 6e 0a 20 2a 20 69 6e 74 65 72 70 72 65 74 65 an. * interprete
0b40: 72 2e 20 20 49 74 20 73 68 6f 75 6c 64 20 6d 6f r. It should mo
0b50: 75 6e 74 20 75 70 20 74 68 65 20 56 46 53 20 61 unt up the VFS a
0b60: 6e 64 20 6d 61 6b 65 20 65 76 65 72 79 74 68 69 nd make everythi
0b70: 6e 67 20 72 65 61 64 79 20 66 6f 72 0a 20 2a 20 ng ready for. *
0b80: 74 68 61 74 20 69 6e 74 65 72 70 72 65 74 65 72 that interpreter
0b90: 20 74 6f 20 64 6f 20 69 74 73 20 6a 6f 62 2e 0a to do its job..
0ba0: 20 2a 2f 0a 73 74 61 74 69 63 20 63 68 61 72 20 */.static char
0bb0: 2a 70 72 65 49 6e 69 74 43 6d 64 20 3d 20 0a 23 *preInitCmd = .#
0bc0: 69 66 20 64 65 66 69 6e 65 64 28 5f 57 49 4e 33 if defined(_WIN3
0bd0: 32 5f 57 43 45 29 20 26 26 20 21 64 65 66 69 6e 2_WCE) && !defin
0be0: 65 64 28 54 43 4c 4b 49 54 5f 44 4c 4c 29 0a 2f ed(TCLKIT_DLL)./
0bf0: 2a 20 73 69 6c 6c 79 20 68 61 63 6b 20 74 6f 20 * silly hack to
0c00: 67 65 74 20 77 69 6e 63 65 20 70 6f 72 74 20 74 get wince port t
0c10: 6f 20 6c 61 75 6e 63 68 2c 20 73 6f 6d 65 20 73 o launch, some s
0c20: 6f 72 74 20 6f 66 20 73 74 64 7b 69 6e 2c 6f 75 ort of std{in,ou
0c30: 74 2c 65 72 72 7d 20 70 72 6f 62 6c 65 6d 20 2a t,err} problem *
0c40: 2f 0a 22 6f 70 65 6e 20 2f 6b 69 74 6f 75 74 2e /."open /kitout.
0c50: 74 78 74 20 61 3b 20 6f 70 65 6e 20 2f 6b 69 74 txt a; open /kit
0c60: 6f 75 74 2e 74 78 74 20 61 3b 20 6f 70 65 6e 20 out.txt a; open
0c70: 2f 6b 69 74 6f 75 74 2e 74 78 74 20 61 5c 6e 22 /kitout.txt a\n"
0c80: 0a 2f 2a 20 74 68 69 73 20 74 6f 6f 20 73 65 65 ./* this too see
0c90: 6d 73 20 74 6f 20 62 65 20 6e 65 65 64 65 64 20 ms to be needed
0ca0: 6f 6e 20 77 69 6e 63 65 20 2d 20 69 74 20 61 70 on wince - it ap
0cb0: 70 65 61 72 73 20 74 6f 20 62 65 20 72 65 6c 61 pears to be rela
0cc0: 74 65 64 20 74 6f 20 74 68 65 20 61 62 6f 76 65 ted to the above
0cd0: 20 2a 2f 0a 22 63 61 74 63 68 20 7b 72 65 6e 61 */."catch {rena
0ce0: 6d 65 20 73 6f 75 72 63 65 20 3a 3a 74 63 6c 3a me source ::tcl:
0cf0: 3a 73 6f 75 72 63 65 7d 5c 6e 22 0a 22 70 72 6f :source}\n"."pro
0d00: 63 20 73 6f 75 72 63 65 20 66 69 6c 65 20 7b 5c c source file {\
0d10: 6e 22 0a 09 22 73 65 74 20 6f 6c 64 20 5b 69 6e n".."set old [in
0d20: 66 6f 20 73 63 72 69 70 74 5d 5c 6e 22 0a 09 22 fo script]\n".."
0d30: 69 6e 66 6f 20 73 63 72 69 70 74 20 24 66 69 6c info script $fil
0d40: 65 5c 6e 22 0a 09 22 73 65 74 20 66 69 64 20 5b e\n".."set fid [
0d50: 6f 70 65 6e 20 24 66 69 6c 65 5d 5c 6e 22 0a 09 open $file]\n"..
0d60: 22 73 65 74 20 64 61 74 61 20 5b 72 65 61 64 20 "set data [read
0d70: 24 66 69 64 5d 5c 6e 22 0a 09 22 63 6c 6f 73 65 $fid]\n".."close
0d80: 20 24 66 69 64 5c 6e 22 0a 09 22 73 65 74 20 63 $fid\n".."set c
0d90: 6f 64 65 20 5b 63 61 74 63 68 20 7b 75 70 6c 65 ode [catch {uple
0da0: 76 65 6c 20 31 20 24 64 61 74 61 7d 20 72 65 73 vel 1 $data} res
0db0: 5d 5c 6e 22 0a 09 22 69 6e 66 6f 20 73 63 72 69 ]\n".."info scri
0dc0: 70 74 20 24 6f 6c 64 5c 6e 22 0a 09 22 69 66 20 pt $old\n".."if
0dd0: 7b 24 63 6f 64 65 20 3d 3d 20 32 7d 20 7b 20 73 {$code == 2} { s
0de0: 65 74 20 63 6f 64 65 20 30 20 7d 5c 6e 22 0a 09 et code 0 }\n"..
0df0: 22 72 65 74 75 72 6e 20 2d 63 6f 64 65 20 24 63 "return -code $c
0e00: 6f 64 65 20 24 72 65 73 5c 6e 22 0a 22 7d 5c 6e ode $res\n"."}\n
0e10: 22 0a 23 65 6e 64 69 66 20 2f 2a 20 5f 57 49 4e ".#endif /* _WIN
0e20: 33 32 5f 57 43 45 20 26 26 20 21 54 43 4c 4b 49 32_WCE && !TCLKI
0e30: 54 5f 44 4c 4c 20 2a 2f 0a 22 70 72 6f 63 20 74 T_DLL */."proc t
0e40: 63 6c 4b 69 74 49 6e 69 74 20 7b 7d 20 7b 5c 6e clKitInit {} {\n
0e50: 22 0a 09 22 72 65 6e 61 6d 65 20 74 63 6c 4b 69 ".."rename tclKi
0e60: 74 49 6e 69 74 20 7b 7d 5c 6e 22 0a 09 22 63 61 tInit {}\n".."ca
0e70: 74 63 68 20 7b 20 6c 6f 61 64 20 7b 7d 20 76 66 tch { load {} vf
0e80: 73 20 7d 5c 6e 22 0a 23 69 66 64 65 66 20 4b 49 s }\n".#ifdef KI
0e90: 54 5f 49 4e 43 4c 55 44 45 53 5f 5a 4c 49 42 0a T_INCLUDES_ZLIB.
0ea0: 09 22 63 61 74 63 68 20 7b 20 6c 6f 61 64 20 7b ."catch { load {
0eb0: 7d 20 7a 6c 69 62 20 7d 5c 6e 22 0a 23 65 6e 64 } zlib }\n".#end
0ec0: 69 66 0a 23 69 66 64 65 66 20 4b 49 54 5f 49 4e if.#ifdef KIT_IN
0ed0: 43 4c 55 44 45 53 5f 4d 4b 34 54 43 4c 0a 09 22 CLUDES_MK4TCL.."
0ee0: 63 61 74 63 68 20 7b 20 6c 6f 61 64 20 7b 7d 20 catch { load {}
0ef0: 4d 6b 34 74 63 6c 20 7d 5c 6e 22 0a 23 65 6e 64 Mk4tcl }\n".#end
0f00: 69 66 0a 23 69 66 64 65 66 20 54 43 4c 4b 49 54 if.#ifdef TCLKIT
0f10: 5f 44 4c 4c 0a 09 22 6c 6f 61 64 20 7b 7d 20 74 _DLL.."load {} t
0f20: 63 6c 6b 69 74 3a 3a 69 6e 69 74 5c 6e 22 0a 09 clkit::init\n"..
0f30: 22 3a 3a 74 63 6c 6b 69 74 3a 3a 69 6e 69 74 3a "::tclkit::init:
0f40: 3a 69 6e 69 74 49 6e 74 65 72 70 5c 6e 22 0a 09 :initInterp\n"..
0f50: 22 72 65 6e 61 6d 65 20 3a 3a 74 63 6c 6b 69 74 "rename ::tclkit
0f60: 3a 3a 69 6e 69 74 3a 3a 69 6e 69 74 49 6e 74 65 ::init::initInte
0f70: 72 70 20 7b 7d 5c 6e 22 0a 23 65 6e 64 69 66 20 rp {}\n".#endif
0f80: 2f 2a 20 54 43 4c 4b 49 54 5f 44 4c 4c 20 2a 2f /* TCLKIT_DLL */
0f90: 0a 09 22 73 65 74 20 62 6f 6f 74 66 69 6c 65 20 .."set bootfile
0fa0: 5b 66 69 6c 65 20 6a 6f 69 6e 20 22 20 54 43 4c [file join " TCL
0fb0: 4b 49 54 5f 4d 4f 55 4e 54 50 4f 49 4e 54 20 22 KIT_MOUNTPOINT "
0fc0: 20 62 6f 6f 74 2e 74 63 6c 5d 5c 6e 22 0a 09 22 boot.tcl]\n".."
0fd0: 69 66 20 7b 5b 66 69 6c 65 20 65 78 69 73 74 73 if {[file exists
0fe0: 20 24 62 6f 6f 74 66 69 6c 65 5d 7d 20 7b 5c 6e $bootfile]} {\n
0ff0: 22 0a 09 09 22 63 61 74 63 68 20 7b 5c 6e 22 0a "..."catch {\n".
1000: 09 09 09 22 73 65 74 20 66 20 5b 6f 70 65 6e 20 ..."set f [open
1010: 24 62 6f 6f 74 66 69 6c 65 5d 5c 6e 22 0a 09 09 $bootfile]\n"...
1020: 09 22 73 65 74 20 73 20 5b 72 65 61 64 20 24 66 ."set s [read $f
1030: 5d 5c 6e 22 0a 09 09 09 22 63 6c 6f 73 65 20 24 ]\n"...."close $
1040: 66 5c 6e 22 0a 09 09 22 7d 5c 6e 22 0a 09 22 7d f\n"..."}\n".."}
1050: 20 65 6c 73 65 20 7b 5c 6e 22 0a 09 09 22 73 65 else {\n"..."se
1060: 74 20 3a 3a 54 43 4c 4b 49 54 5f 49 4e 49 54 56 t ::TCLKIT_INITV
1070: 46 53 20 31 5c 6e 22 0a 09 22 7d 5c 6e 22 0a 23 FS 1\n".."}\n".#
1080: 69 66 64 65 66 20 4b 49 54 5f 53 54 4f 52 41 47 ifdef KIT_STORAG
1090: 45 5f 4d 4b 34 0a 09 22 73 65 74 20 3a 3a 74 63 E_MK4.."set ::tc
10a0: 6c 4b 69 74 53 74 6f 72 61 67 65 20 5c 22 6d 6b lKitStorage \"mk
10b0: 34 5c 22 5c 6e 22 0a 09 22 69 66 20 7b 21 5b 69 4\"\n".."if {![i
10c0: 6e 66 6f 20 65 78 69 73 74 73 20 73 5d 7d 20 7b nfo exists s]} {
10d0: 5c 6e 22 0a 09 09 22 6d 6b 3a 3a 66 69 6c 65 20 \n"..."mk::file
10e0: 6f 70 65 6e 20 65 78 65 20 22 20 54 43 4c 4b 49 open exe " TCLKI
10f0: 54 5f 56 46 53 53 4f 55 52 43 45 20 22 20 2d 72 T_VFSSOURCE " -r
1100: 65 61 64 6f 6e 6c 79 5c 6e 22 0a 09 09 22 73 65 eadonly\n"..."se
1110: 74 20 6e 20 5b 6d 6b 3a 3a 73 65 6c 65 63 74 20 t n [mk::select
1120: 65 78 65 2e 64 69 72 73 21 30 2e 66 69 6c 65 73 exe.dirs!0.files
1130: 20 6e 61 6d 65 20 62 6f 6f 74 2e 74 63 6c 5d 5c name boot.tcl]\
1140: 6e 22 0a 09 09 22 69 66 20 7b 24 6e 20 21 3d 20 n"..."if {$n !=
1150: 5c 22 5c 22 7d 20 7b 5c 6e 22 0a 09 09 09 22 73 \"\"} {\n"...."s
1160: 65 74 20 73 20 5b 6d 6b 3a 3a 67 65 74 20 65 78 et s [mk::get ex
1170: 65 2e 64 69 72 73 21 30 2e 66 69 6c 65 73 21 24 e.dirs!0.files!$
1180: 6e 20 63 6f 6e 74 65 6e 74 73 5d 5c 6e 22 0a 09 n contents]\n"..
1190: 09 09 22 69 66 20 7b 21 5b 73 74 72 69 6e 67 20 .."if {![string
11a0: 6c 65 6e 67 74 68 20 24 73 5d 7d 20 7b 20 65 72 length $s]} { er
11b0: 72 6f 72 20 5c 22 65 6d 70 74 79 20 62 6f 6f 74 ror \"empty boot
11c0: 2e 74 63 6c 5c 22 20 7d 5c 6e 22 0a 09 09 09 22 .tcl\" }\n"...."
11d0: 63 61 74 63 68 20 7b 6c 6f 61 64 20 7b 7d 20 7a catch {load {} z
11e0: 6c 69 62 7d 5c 6e 22 0a 09 09 09 22 69 66 20 7b lib}\n"...."if {
11f0: 5b 6d 6b 3a 3a 67 65 74 20 65 78 65 2e 64 69 72 [mk::get exe.dir
1200: 73 21 30 2e 66 69 6c 65 73 21 24 6e 20 73 69 7a s!0.files!$n siz
1210: 65 5d 20 21 3d 20 5b 73 74 72 69 6e 67 20 6c 65 e] != [string le
1220: 6e 67 74 68 20 24 73 5d 7d 20 7b 5c 6e 22 0a 09 ngth $s]} {\n"..
1230: 09 09 09 22 73 65 74 20 73 20 5b 7a 6c 69 62 20 ..."set s [zlib
1240: 64 65 63 6f 6d 70 72 65 73 73 20 24 73 5d 5c 6e decompress $s]\n
1250: 22 0a 09 09 09 22 7d 5c 6e 22 0a 09 09 22 7d 5c "...."}\n"..."}\
1260: 6e 22 0a 09 22 7d 5c 6e 22 0a 23 65 6e 64 69 66 n".."}\n".#endif
1270: 20 2f 2a 20 4b 49 54 5f 53 54 4f 52 41 47 45 5f /* KIT_STORAGE_
1280: 4d 4b 34 20 2a 2f 0a 23 69 66 64 65 66 20 4b 49 MK4 */.#ifdef KI
1290: 54 5f 53 54 4f 52 41 47 45 5f 5a 49 50 0a 09 22 T_STORAGE_ZIP.."
12a0: 73 65 74 20 3a 3a 74 63 6c 4b 69 74 53 74 6f 72 set ::tclKitStor
12b0: 61 67 65 20 5c 22 7a 69 70 5c 22 5c 6e 22 0a 09 age \"zip\"\n"..
12c0: 22 69 66 20 7b 21 5b 69 6e 66 6f 20 65 78 69 73 "if {![info exis
12d0: 74 73 20 73 5d 7d 20 7b 5c 6e 22 0a 23 20 20 69 ts s]} {\n".# i
12e0: 6e 63 6c 75 64 65 20 22 7a 69 70 76 66 73 2e 74 nclude "zipvfs.t
12f0: 63 6c 2e 68 22 0a 09 09 22 63 61 74 63 68 20 7b cl.h"..."catch {
1300: 5c 6e 22 0a 09 09 09 22 73 65 74 20 3a 3a 74 63 \n"...."set ::tc
1310: 6c 4b 69 74 53 74 6f 72 61 67 65 5f 66 64 20 5b lKitStorage_fd [
1320: 3a 3a 7a 69 70 3a 3a 6f 70 65 6e 20 22 20 54 43 ::zip::open " TC
1330: 4c 4b 49 54 5f 56 46 53 53 4f 55 52 43 45 20 22 LKIT_VFSSOURCE "
1340: 5d 5c 6e 22 0a 09 09 09 22 3a 3a 7a 69 70 3a 3a ]\n"...."::zip::
1350: 73 74 61 74 20 24 3a 3a 74 63 6c 4b 69 74 53 74 stat $::tclKitSt
1360: 6f 72 61 67 65 5f 66 64 20 62 6f 6f 74 2e 74 63 orage_fd boot.tc
1370: 6c 20 73 62 5c 6e 22 0a 09 09 09 22 73 65 65 6b l sb\n"...."seek
1380: 20 24 3a 3a 74 63 6c 4b 69 74 53 74 6f 72 61 67 $::tclKitStorag
1390: 65 5f 66 64 20 24 73 62 28 69 6e 6f 29 5c 6e 22 e_fd $sb(ino)\n"
13a0: 0a 09 09 09 22 3a 3a 7a 69 70 3a 3a 44 61 74 61 ...."::zip::Data
13b0: 20 24 3a 3a 74 63 6c 4b 69 74 53 74 6f 72 61 67 $::tclKitStorag
13c0: 65 5f 66 64 20 73 62 20 73 5c 6e 22 0a 09 09 22 e_fd sb s\n"..."
13d0: 7d 5c 6e 22 0a 09 22 7d 5c 6e 22 0a 23 65 6e 64 }\n".."}\n".#end
13e0: 69 66 20 2f 2a 20 4b 49 54 5f 53 54 4f 52 41 47 if /* KIT_STORAG
13f0: 45 5f 5a 49 50 20 2a 2f 0a 23 69 66 64 65 66 20 E_ZIP */.#ifdef
1400: 4b 49 54 5f 53 54 4f 52 41 47 45 5f 43 56 46 53 KIT_STORAGE_CVFS
1410: 0a 09 22 73 65 74 20 3a 3a 74 63 6c 4b 69 74 53 .."set ::tclKitS
1420: 74 6f 72 61 67 65 20 5c 22 63 76 66 73 5c 22 5c torage \"cvfs\"\
1430: 6e 22 0a 09 22 6c 6f 61 64 20 7b 7d 20 72 65 63 n".."load {} rec
1440: 68 61 6e 5c 6e 22 0a 09 22 6c 6f 61 64 20 7b 7d han\n".."load {}
1450: 20 63 76 66 73 5f 64 61 74 61 5f 74 63 6c 5c 6e cvfs_data_tcl\n
1460: 22 0a 23 69 6e 63 6c 75 64 65 20 22 63 76 66 73 ".#include "cvfs
1470: 2e 74 63 6c 2e 68 22 0a 09 22 69 66 20 7b 21 5b .tcl.h".."if {![
1480: 69 6e 66 6f 20 65 78 69 73 74 73 20 73 5d 7d 20 info exists s]}
1490: 7b 5c 6e 22 0a 09 09 22 63 61 74 63 68 20 7b 5c {\n"..."catch {\
14a0: 6e 22 0a 09 09 09 22 73 65 74 20 73 20 5b 3a 3a n"...."set s [::
14b0: 76 66 73 3a 3a 63 76 66 73 3a 3a 64 61 74 61 3a vfs::cvfs::data:
14c0: 3a 67 65 74 44 61 74 61 20 74 63 6c 20 62 6f 6f :getData tcl boo
14d0: 74 2e 74 63 6c 5d 5c 6e 22 0a 09 09 22 7d 5c 6e t.tcl]\n"..."}\n
14e0: 22 0a 09 22 7d 5c 6e 22 0a 23 65 6e 64 69 66 20 ".."}\n".#endif
14f0: 2f 2a 20 4b 49 54 5f 53 54 4f 52 41 47 45 5f 43 /* KIT_STORAGE_C
1500: 56 46 53 20 2a 2f 0a 23 69 66 6e 64 65 66 20 54 VFS */.#ifndef T
1510: 43 4c 4b 49 54 5f 44 4c 4c 0a 09 22 69 66 20 7b CLKIT_DLL.."if {
1520: 21 5b 69 6e 66 6f 20 65 78 69 73 74 73 20 73 5d ![info exists s]
1530: 7d 20 7b 5c 6e 22 0a 09 09 22 73 65 74 20 73 20 } {\n"..."set s
1540: 5c 22 5c 22 5c 6e 22 0a 09 22 7d 5c 6e 22 0a 23 \"\"\n".."}\n".#
1550: 65 6e 64 69 66 20 2f 2a 20 21 54 43 4c 4b 49 54 endif /* !TCLKIT
1560: 5f 44 4c 4c 20 2a 2f 0a 23 69 66 64 65 66 20 54 _DLL */.#ifdef T
1570: 43 4c 4b 49 54 5f 44 4c 4c 0a 09 22 73 65 74 20 CLKIT_DLL.."set
1580: 3a 3a 54 43 4c 4b 49 54 5f 54 59 50 45 20 5c 22 ::TCLKIT_TYPE \"
1590: 6b 69 74 64 6c 6c 5c 22 5c 6e 22 0a 23 65 6c 73 kitdll\"\n".#els
15a0: 65 0a 09 22 73 65 74 20 3a 3a 54 43 4c 4b 49 54 e.."set ::TCLKIT
15b0: 5f 54 59 50 45 20 5c 22 74 63 6c 6b 69 74 5c 22 _TYPE \"tclkit\"
15c0: 5c 6e 22 0a 23 65 6e 64 69 66 20 2f 2a 20 54 43 \n".#endif /* TC
15d0: 4c 4b 49 54 5f 44 4c 4c 20 2a 2f 0a 09 22 73 65 LKIT_DLL */.."se
15e0: 74 20 3a 3a 54 43 4c 4b 49 54 5f 4d 4f 55 4e 54 t ::TCLKIT_MOUNT
15f0: 50 4f 49 4e 54 20 22 20 54 43 4c 4b 49 54 5f 4d POINT " TCLKIT_M
1600: 4f 55 4e 54 50 4f 49 4e 54 20 22 5c 6e 22 0a 09 OUNTPOINT "\n"..
1610: 22 73 65 74 20 3a 3a 54 43 4c 4b 49 54 5f 56 46 "set ::TCLKIT_VF
1620: 53 53 4f 55 52 43 45 20 22 20 54 43 4c 4b 49 54 SSOURCE " TCLKIT
1630: 5f 56 46 53 53 4f 55 52 43 45 20 22 5c 6e 22 0a _VFSSOURCE "\n".
1640: 09 22 73 65 74 20 3a 3a 54 43 4c 4b 49 54 5f 4d ."set ::TCLKIT_M
1650: 4f 55 4e 54 50 4f 49 4e 54 5f 56 41 52 20 7b 22 OUNTPOINT_VAR {"
1660: 20 54 43 4c 4b 49 54 5f 4d 4f 55 4e 54 50 4f 49 TCLKIT_MOUNTPOI
1670: 4e 54 20 22 7d 5c 6e 22 0a 09 22 73 65 74 20 3a NT "}\n".."set :
1680: 3a 54 43 4c 4b 49 54 5f 56 46 53 53 4f 55 52 43 :TCLKIT_VFSSOURC
1690: 45 5f 56 41 52 20 7b 22 20 54 43 4c 4b 49 54 5f E_VAR {" TCLKIT_
16a0: 56 46 53 53 4f 55 52 43 45 20 22 7d 5c 6e 22 0a VFSSOURCE "}\n".
16b0: 09 22 75 70 6c 65 76 65 6c 20 23 30 20 24 73 5c ."uplevel #0 $s\
16c0: 6e 22 0a 23 69 66 20 64 65 66 69 6e 65 64 28 4b n".#if defined(K
16d0: 49 54 5f 49 4e 43 4c 55 44 45 53 5f 54 4b 29 20 IT_INCLUDES_TK)
16e0: 26 26 20 64 65 66 69 6e 65 64 28 4b 49 54 5f 54 && defined(KIT_T
16f0: 4b 5f 56 45 52 53 49 4f 4e 29 0a 09 22 70 61 63 K_VERSION).."pac
1700: 6b 61 67 65 20 69 66 6e 65 65 64 65 64 20 54 6b kage ifneeded Tk
1710: 20 22 20 4b 49 54 5f 54 4b 5f 56 45 52 53 49 4f " KIT_TK_VERSIO
1720: 4e 20 22 20 7b 5c 6e 22 0a 09 09 22 6c 6f 61 64 N " {\n"..."load
1730: 20 7b 7d 20 54 6b 5c 6e 22 0a 09 22 7d 5c 6e 22 {} Tk\n".."}\n"
1740: 0a 23 65 6e 64 69 66 0a 23 69 66 64 65 66 20 5f .#endif.#ifdef _
1750: 57 49 4e 33 32 0a 09 22 63 61 74 63 68 20 7b 6c WIN32.."catch {l
1760: 6f 61 64 20 7b 7d 20 64 64 65 7d 5c 6e 22 0a 09 oad {} dde}\n"..
1770: 22 63 61 74 63 68 20 7b 6c 6f 61 64 20 7b 7d 20 "catch {load {}
1780: 72 65 67 69 73 74 72 79 7d 5c 6e 22 0a 23 65 6e registry}\n".#en
1790: 64 69 66 20 2f 2a 20 5f 57 49 4e 33 32 20 2a 2f dif /* _WIN32 */
17a0: 0a 09 22 72 65 74 75 72 6e 20 30 5c 6e 22 0a 22 .."return 0\n"."
17b0: 7d 5c 6e 22 0a 22 74 63 6c 4b 69 74 49 6e 69 74 }\n"."tclKitInit
17c0: 22 3b 0a 0a 73 74 61 74 69 63 20 63 6f 6e 73 74 ";..static const
17d0: 20 63 68 61 72 20 69 6e 69 74 53 63 72 69 70 74 char initScript
17e0: 5b 5d 20 3d 0a 22 69 66 20 7b 5b 66 69 6c 65 20 [] =."if {[file
17f0: 69 73 66 69 6c 65 20 5b 66 69 6c 65 20 6a 6f 69 isfile [file joi
1800: 6e 20 5b 69 6e 66 6f 20 6e 61 6d 65 6f 66 65 78 n [info nameofex
1810: 65 5d 20 6d 61 69 6e 2e 74 63 6c 5d 5d 7d 20 7b e] main.tcl]]} {
1820: 5c 6e 22 0a 09 22 69 66 20 7b 5b 69 6e 66 6f 20 \n".."if {[info
1830: 63 6f 6d 6d 61 6e 64 73 20 63 6f 6e 73 6f 6c 65 commands console
1840: 5d 20 21 3d 20 7b 7d 7d 20 7b 20 63 6f 6e 73 6f ] != {}} { conso
1850: 6c 65 20 68 69 64 65 20 7d 5c 6e 22 0a 09 22 73 le hide }\n".."s
1860: 65 74 20 74 63 6c 5f 69 6e 74 65 72 61 63 74 69 et tcl_interacti
1870: 76 65 20 30 5c 6e 22 0a 09 22 69 6e 63 72 20 61 ve 0\n".."incr a
1880: 72 67 63 5c 6e 22 0a 09 22 73 65 74 20 61 72 67 rgc\n".."set arg
1890: 76 20 5b 6c 69 6e 73 65 72 74 20 24 61 72 67 76 v [linsert $argv
18a0: 20 30 20 24 61 72 67 76 30 5d 5c 6e 22 0a 09 22 0 $argv0]\n".."
18b0: 73 65 74 20 61 72 67 76 30 20 5b 66 69 6c 65 20 set argv0 [file
18c0: 6a 6f 69 6e 20 5b 69 6e 66 6f 20 6e 61 6d 65 6f join [info nameo
18d0: 66 65 78 65 5d 20 6d 61 69 6e 2e 74 63 6c 5d 5c fexe] main.tcl]\
18e0: 6e 22 0a 22 7d 20 65 6c 73 65 20 63 6f 6e 74 69 n"."} else conti
18f0: 6e 75 65 5c 6e 22 3b 0a 0a 2f 2a 20 53 65 74 45 nue\n";../* SetE
1900: 78 65 63 4e 61 6d 65 20 2d 2d 0a 0a 20 20 20 48 xecName --.. H
1910: 61 63 6b 20 74 6f 20 67 65 74 20 61 72 6f 75 6e ack to get aroun
1920: 64 20 54 63 6c 20 62 75 67 20 31 32 32 34 38 38 d Tcl bug 122488
1930: 38 2e 0a 2a 2f 0a 73 74 61 74 69 63 20 76 6f 69 8..*/.static voi
1940: 64 20 53 65 74 45 78 65 63 4e 61 6d 65 28 54 63 d SetExecName(Tc
1950: 6c 5f 49 6e 74 65 72 70 20 2a 69 6e 74 65 72 70 l_Interp *interp
1960: 2c 20 63 6f 6e 73 74 20 63 68 61 72 20 2a 70 61 , const char *pa
1970: 74 68 29 20 7b 0a 23 69 66 64 65 66 20 54 43 4c th) {.#ifdef TCL
1980: 4b 49 54 5f 52 45 51 55 49 52 45 5f 54 43 4c 45 KIT_REQUIRE_TCLE
1990: 58 45 43 55 54 41 42 4c 45 4e 41 4d 45 0a 09 74 XECUTABLENAME..t
19a0: 63 6c 45 78 65 63 75 74 61 62 6c 65 4e 61 6d 65 clExecutableName
19b0: 20 3d 20 73 74 72 64 75 70 28 70 61 74 68 29 3b = strdup(path);
19c0: 0a 23 65 6e 64 69 66 0a 09 54 63 6c 5f 46 69 6e .#endif..Tcl_Fin
19d0: 64 45 78 65 63 75 74 61 62 6c 65 28 70 61 74 68 dExecutable(path
19e0: 29 3b 0a 0a 09 72 65 74 75 72 6e 3b 0a 7d 0a 0a );...return;.}..
19f0: 73 74 61 74 69 63 20 76 6f 69 64 20 46 69 6e 64 static void Find
1a00: 41 6e 64 53 65 74 45 78 65 63 4e 61 6d 65 28 54 AndSetExecName(T
1a10: 63 6c 5f 49 6e 74 65 72 70 20 2a 69 6e 74 65 72 cl_Interp *inter
1a20: 70 29 20 7b 0a 09 69 6e 74 20 6c 65 6e 20 3d 20 p) {..int len =
1a30: 30 3b 0a 09 54 63 6c 5f 4f 62 6a 20 2a 65 78 65 0;..Tcl_Obj *exe
1a40: 63 4e 61 6d 65 4f 62 6a 3b 0a 09 54 63 6c 5f 4f cNameObj;..Tcl_O
1a50: 62 6a 20 2a 6c 6f 62 6a 76 5b 31 5d 3b 0a 23 69 bj *lobjv[1];.#i
1a60: 66 64 65 66 20 48 41 56 45 5f 52 45 41 44 4c 49 fdef HAVE_READLI
1a70: 4e 4b 0a 09 73 73 69 7a 65 5f 74 20 72 65 61 64 NK..ssize_t read
1a80: 6c 69 6e 6b 5f 72 65 74 3b 0a 09 63 68 61 72 20 link_ret;..char
1a90: 65 78 65 5f 62 75 66 5b 34 30 39 36 5d 3b 0a 23 exe_buf[4096];.#
1aa0: 65 6e 64 69 66 20 2f 2a 20 48 41 56 45 5f 52 45 endif /* HAVE_RE
1ab0: 41 44 4c 49 4e 4b 20 2a 2f 0a 23 69 66 64 65 66 ADLINK */.#ifdef
1ac0: 20 48 41 56 45 5f 41 43 43 45 50 54 41 42 4c 45 HAVE_ACCEPTABLE
1ad0: 5f 44 4c 41 44 44 52 0a 09 44 6c 5f 69 6e 66 6f _DLADDR..Dl_info
1ae0: 20 73 79 6d 69 6e 66 6f 3b 0a 09 69 6e 74 20 64 syminfo;..int d
1af0: 6c 61 64 64 72 5f 72 65 74 3b 0a 23 65 6e 64 69 laddr_ret;.#endi
1b00: 66 20 2f 2a 20 48 41 56 45 5f 41 43 43 45 50 54 f /* HAVE_ACCEPT
1b10: 41 42 4c 45 5f 44 4c 41 44 44 52 20 2a 2f 20 0a ABLE_DLADDR */ .
1b20: 0a 23 69 66 64 65 66 20 48 41 56 45 5f 52 45 41 .#ifdef HAVE_REA
1b30: 44 4c 49 4e 4b 0a 09 69 66 20 28 54 63 6c 5f 47 DLINK..if (Tcl_G
1b40: 65 74 4e 61 6d 65 4f 66 45 78 65 63 75 74 61 62 etNameOfExecutab
1b50: 6c 65 28 29 20 3d 3d 20 4e 55 4c 4c 29 20 7b 0a le() == NULL) {.
1b60: 09 09 72 65 61 64 6c 69 6e 6b 5f 72 65 74 20 3d ..readlink_ret =
1b70: 20 72 65 61 64 6c 69 6e 6b 28 22 2f 70 72 6f 63 readlink("/proc
1b80: 2f 73 65 6c 66 2f 65 78 65 22 2c 20 65 78 65 5f /self/exe", exe_
1b90: 62 75 66 2c 20 73 69 7a 65 6f 66 28 65 78 65 5f buf, sizeof(exe_
1ba0: 62 75 66 29 20 2d 20 31 29 3b 0a 0a 09 09 69 66 buf) - 1);....if
1bb0: 20 28 72 65 61 64 6c 69 6e 6b 5f 72 65 74 20 3e (readlink_ret >
1bc0: 20 30 20 26 26 20 72 65 61 64 6c 69 6e 6b 5f 72 0 && readlink_r
1bd0: 65 74 20 3c 20 28 73 69 7a 65 6f 66 28 65 78 65 et < (sizeof(exe
1be0: 5f 62 75 66 29 20 2d 20 31 29 29 20 7b 0a 09 09 _buf) - 1)) {...
1bf0: 09 65 78 65 5f 62 75 66 5b 72 65 61 64 6c 69 6e .exe_buf[readlin
1c00: 6b 5f 72 65 74 5d 20 3d 20 27 5c 30 27 3b 0a 0a k_ret] = '\0';..
1c10: 09 09 09 53 65 74 45 78 65 63 4e 61 6d 65 28 69 ...SetExecName(i
1c20: 6e 74 65 72 70 2c 20 65 78 65 5f 62 75 66 29 3b nterp, exe_buf);
1c30: 0a 0a 09 09 09 72 65 74 75 72 6e 3b 0a 09 09 7d .....return;...}
1c40: 0a 09 7d 0a 0a 09 69 66 20 28 54 63 6c 5f 47 65 ..}...if (Tcl_Ge
1c50: 74 4e 61 6d 65 4f 66 45 78 65 63 75 74 61 62 6c tNameOfExecutabl
1c60: 65 28 29 20 3d 3d 20 4e 55 4c 4c 29 20 7b 0a 09 e() == NULL) {..
1c70: 09 72 65 61 64 6c 69 6e 6b 5f 72 65 74 20 3d 20 .readlink_ret =
1c80: 72 65 61 64 6c 69 6e 6b 28 22 2f 70 72 6f 63 2f readlink("/proc/
1c90: 63 75 72 70 72 6f 63 2f 66 69 6c 65 22 2c 20 65 curproc/file", e
1ca0: 78 65 5f 62 75 66 2c 20 73 69 7a 65 6f 66 28 65 xe_buf, sizeof(e
1cb0: 78 65 5f 62 75 66 29 20 2d 20 31 29 3b 0a 0a 09 xe_buf) - 1);...
1cc0: 09 69 66 20 28 72 65 61 64 6c 69 6e 6b 5f 72 65 .if (readlink_re
1cd0: 74 20 3e 20 30 20 26 26 20 72 65 61 64 6c 69 6e t > 0 && readlin
1ce0: 6b 5f 72 65 74 20 3c 20 28 73 69 7a 65 6f 66 28 k_ret < (sizeof(
1cf0: 65 78 65 5f 62 75 66 29 20 2d 20 31 29 29 20 7b exe_buf) - 1)) {
1d00: 0a 09 09 09 65 78 65 5f 62 75 66 5b 72 65 61 64 ....exe_buf[read
1d10: 6c 69 6e 6b 5f 72 65 74 5d 20 3d 20 27 5c 30 27 link_ret] = '\0'
1d20: 3b 0a 0a 09 09 09 69 66 20 28 73 74 72 63 6d 70 ;.....if (strcmp
1d30: 28 65 78 65 5f 62 75 66 2c 20 22 75 6e 6b 6e 6f (exe_buf, "unkno
1d40: 77 6e 22 29 20 21 3d 20 30 29 20 7b 0a 09 09 09 wn") != 0) {....
1d50: 09 53 65 74 45 78 65 63 4e 61 6d 65 28 69 6e 74 .SetExecName(int
1d60: 65 72 70 2c 20 65 78 65 5f 62 75 66 29 3b 0a 0a erp, exe_buf);..
1d70: 09 09 09 09 72 65 74 75 72 6e 3b 0a 09 09 09 7d ....return;....}
1d80: 0a 09 09 7d 0a 09 7d 0a 23 65 6e 64 69 66 20 2f ...}..}.#endif /
1d90: 2a 20 48 41 56 45 5f 52 45 41 44 4c 49 4e 4b 20 * HAVE_READLINK
1da0: 2a 2f 0a 0a 23 69 66 64 65 66 20 48 41 56 45 5f */..#ifdef HAVE_
1db0: 41 43 43 45 50 54 41 42 4c 45 5f 44 4c 41 44 44 ACCEPTABLE_DLADD
1dc0: 52 0a 23 20 20 69 66 6e 64 65 66 20 54 43 4c 4b R.# ifndef TCLK
1dd0: 49 54 5f 44 4c 4c 0a 09 69 66 20 28 54 63 6c 5f IT_DLL..if (Tcl_
1de0: 47 65 74 4e 61 6d 65 4f 66 45 78 65 63 75 74 61 GetNameOfExecuta
1df0: 62 6c 65 28 29 20 3d 3d 20 4e 55 4c 4c 29 20 7b ble() == NULL) {
1e00: 0a 09 09 64 6c 61 64 64 72 5f 72 65 74 20 3d 20 ...dladdr_ret =
1e10: 64 6c 61 64 64 72 28 26 53 65 74 45 78 65 63 4e dladdr(&SetExecN
1e20: 61 6d 65 2c 20 26 73 79 6d 69 6e 66 6f 29 3b 0a ame, &syminfo);.
1e30: 09 09 69 66 20 28 64 6c 61 64 64 72 5f 72 65 74 ..if (dladdr_ret
1e40: 20 21 3d 20 30 29 20 7b 0a 09 09 09 53 65 74 45 != 0) {....SetE
1e50: 78 65 63 4e 61 6d 65 28 69 6e 74 65 72 70 2c 20 xecName(interp,
1e60: 73 79 6d 69 6e 66 6f 2e 64 6c 69 5f 66 6e 61 6d syminfo.dli_fnam
1e70: 65 29 3b 0a 0a 09 09 09 72 65 74 75 72 6e 3b 0a e);.....return;.
1e80: 09 09 7d 0a 09 7d 0a 23 20 20 20 20 69 66 64 65 ..}..}.# ifde
1e90: 66 20 4b 49 54 53 48 5f 4e 45 45 44 5f 57 49 4e f KITSH_NEED_WIN
1ea0: 4d 41 49 4e 0a 09 69 66 20 28 54 63 6c 5f 47 65 MAIN..if (Tcl_Ge
1eb0: 74 4e 61 6d 65 4f 66 45 78 65 63 75 74 61 62 6c tNameOfExecutabl
1ec0: 65 28 29 20 3d 3d 20 4e 55 4c 4c 29 20 7b 0a 23 e() == NULL) {.#
1ed0: 20 20 20 20 20 20 69 66 64 65 66 20 5f 57 49 4e ifdef _WIN
1ee0: 33 32 5f 57 43 45 0a 09 09 64 6c 61 64 64 72 5f 32_WCE...dladdr_
1ef0: 72 65 74 20 3d 20 64 6c 61 64 64 72 28 26 57 69 ret = dladdr(&Wi
1f00: 6e 4d 61 69 6e 2c 20 26 73 79 6d 69 6e 66 6f 29 nMain, &syminfo)
1f10: 3b 0a 23 20 20 20 20 20 20 65 6c 73 65 0a 09 09 ;.# else...
1f20: 64 6c 61 64 64 72 5f 72 65 74 20 3d 20 64 6c 61 dladdr_ret = dla
1f30: 64 64 72 28 26 77 57 69 6e 4d 61 69 6e 2c 20 26 ddr(&wWinMain, &
1f40: 73 79 6d 69 6e 66 6f 29 3b 0a 23 20 20 20 20 20 syminfo);.#
1f50: 20 65 6e 64 69 66 20 2f 2a 20 5f 57 49 4e 33 32 endif /* _WIN32
1f60: 5f 57 43 45 20 2a 2f 0a 0a 09 09 69 66 20 28 64 _WCE */....if (d
1f70: 6c 61 64 64 72 5f 72 65 74 20 21 3d 20 30 29 20 laddr_ret != 0)
1f80: 7b 0a 09 09 09 53 65 74 45 78 65 63 4e 61 6d 65 {....SetExecName
1f90: 28 69 6e 74 65 72 70 2c 20 73 79 6d 69 6e 66 6f (interp, syminfo
1fa0: 2e 64 6c 69 5f 66 6e 61 6d 65 29 3b 0a 0a 09 09 .dli_fname);....
1fb0: 09 72 65 74 75 72 6e 3b 0a 09 09 7d 0a 09 7d 0a .return;...}..}.
1fc0: 23 20 20 20 20 65 6e 64 69 66 20 2f 2a 20 4b 49 # endif /* KI
1fd0: 54 53 48 5f 4e 45 45 44 5f 57 49 4e 4d 41 49 4e TSH_NEED_WINMAIN
1fe0: 20 2a 2f 0a 0a 09 69 66 20 28 54 63 6c 5f 47 65 */...if (Tcl_Ge
1ff0: 74 4e 61 6d 65 4f 66 45 78 65 63 75 74 61 62 6c tNameOfExecutabl
2000: 65 28 29 20 3d 3d 20 4e 55 4c 4c 29 20 7b 0a 09 e() == NULL) {..
2010: 09 64 6c 61 64 64 72 5f 72 65 74 20 3d 20 64 6c .dladdr_ret = dl
2020: 61 64 64 72 28 26 6d 61 69 6e 2c 20 26 73 79 6d addr(&main, &sym
2030: 69 6e 66 6f 29 3b 0a 09 09 69 66 20 28 64 6c 61 info);...if (dla
2040: 64 64 72 5f 72 65 74 20 21 3d 20 30 29 20 7b 0a ddr_ret != 0) {.
2050: 09 09 09 53 65 74 45 78 65 63 4e 61 6d 65 28 69 ...SetExecName(i
2060: 6e 74 65 72 70 2c 20 73 79 6d 69 6e 66 6f 2e 64 nterp, syminfo.d
2070: 6c 69 5f 66 6e 61 6d 65 29 3b 0a 0a 09 09 09 72 li_fname);.....r
2080: 65 74 75 72 6e 3b 0a 09 09 7d 0a 09 7d 0a 23 20 eturn;...}..}.#
2090: 20 65 6e 64 69 66 20 2f 2a 20 21 54 43 4c 4b 49 endif /* !TCLKI
20a0: 54 5f 44 4c 4c 20 2a 2f 0a 23 65 6e 64 69 66 20 T_DLL */.#endif
20b0: 2f 2a 20 48 41 56 45 5f 41 43 43 45 50 54 41 42 /* HAVE_ACCEPTAB
20c0: 4c 45 5f 44 4c 41 44 44 52 20 2a 2f 0a 0a 09 69 LE_DLADDR */...i
20d0: 66 20 28 54 63 6c 5f 47 65 74 4e 61 6d 65 4f 66 f (Tcl_GetNameOf
20e0: 45 78 65 63 75 74 61 62 6c 65 28 29 20 3d 3d 20 Executable() ==
20f0: 4e 55 4c 4c 29 20 7b 0a 09 09 6c 6f 62 6a 76 5b NULL) {...lobjv[
2100: 30 5d 20 3d 20 54 63 6c 5f 47 65 74 56 61 72 32 0] = Tcl_GetVar2
2110: 45 78 28 69 6e 74 65 72 70 2c 20 22 61 72 67 76 Ex(interp, "argv
2120: 30 22 2c 20 4e 55 4c 4c 2c 20 54 43 4c 5f 47 4c 0", NULL, TCL_GL
2130: 4f 42 41 4c 5f 4f 4e 4c 59 29 3b 0a 09 09 65 78 OBAL_ONLY);...ex
2140: 65 63 4e 61 6d 65 4f 62 6a 20 3d 20 54 63 6c 5f ecNameObj = Tcl_
2150: 46 53 4a 6f 69 6e 54 6f 50 61 74 68 28 54 63 6c FSJoinToPath(Tcl
2160: 5f 46 53 47 65 74 43 77 64 28 69 6e 74 65 72 70 _FSGetCwd(interp
2170: 29 2c 20 31 2c 20 6c 6f 62 6a 76 29 3b 0a 0a 09 ), 1, lobjv);...
2180: 09 53 65 74 45 78 65 63 4e 61 6d 65 28 69 6e 74 .SetExecName(int
2190: 65 72 70 2c 20 54 63 6c 5f 47 65 74 53 74 72 69 erp, Tcl_GetStri
21a0: 6e 67 46 72 6f 6d 4f 62 6a 28 65 78 65 63 4e 61 ngFromObj(execNa
21b0: 6d 65 4f 62 6a 2c 20 26 6c 65 6e 29 29 3b 0a 0a meObj, &len));..
21c0: 09 09 72 65 74 75 72 6e 3b 0a 09 7d 0a 0a 09 72 ..return;..}...r
21d0: 65 74 75 72 6e 3b 0a 7d 0a 0a 73 74 61 74 69 63 eturn;.}..static
21e0: 20 76 6f 69 64 20 5f 54 63 6c 6b 69 74 5f 47 65 void _Tclkit_Ge
21f0: 6e 65 72 69 63 5f 49 6e 69 74 28 76 6f 69 64 29 neric_Init(void)
2200: 20 7b 0a 23 69 66 64 65 66 20 4b 49 54 5f 49 4e {.#ifdef KIT_IN
2210: 43 4c 55 44 45 53 5f 4d 4b 34 54 43 4c 0a 09 54 CLUDES_MK4TCL..T
2220: 63 6c 5f 53 74 61 74 69 63 50 61 63 6b 61 67 65 cl_StaticPackage
2230: 28 30 2c 20 22 4d 6b 34 74 63 6c 22 2c 20 4d 6b (0, "Mk4tcl", Mk
2240: 34 74 63 6c 5f 49 6e 69 74 2c 20 4e 55 4c 4c 29 4tcl_Init, NULL)
2250: 3b 0a 23 65 6e 64 69 66 0a 23 69 66 64 65 66 20 ;.#endif.#ifdef
2260: 4b 49 54 5f 49 4e 43 4c 55 44 45 53 5f 50 57 42 KIT_INCLUDES_PWB
2270: 0a 09 54 63 6c 5f 53 74 61 74 69 63 50 61 63 6b ..Tcl_StaticPack
2280: 61 67 65 28 30 2c 20 22 70 77 62 22 2c 20 50 77 age(0, "pwb", Pw
2290: 62 5f 49 6e 69 74 2c 20 4e 55 4c 4c 29 3b 0a 23 b_Init, NULL);.#
22a0: 65 6e 64 69 66 20 0a 09 54 63 6c 5f 53 74 61 74 endif ..Tcl_Stat
22b0: 69 63 50 61 63 6b 61 67 65 28 30 2c 20 22 72 65 icPackage(0, "re
22c0: 63 68 61 6e 22 2c 20 52 65 63 68 61 6e 5f 49 6e chan", Rechan_In
22d0: 69 74 2c 20 4e 55 4c 4c 29 3b 0a 09 54 63 6c 5f it, NULL);..Tcl_
22e0: 53 74 61 74 69 63 50 61 63 6b 61 67 65 28 30 2c StaticPackage(0,
22f0: 20 22 76 66 73 22 2c 20 56 66 73 5f 49 6e 69 74 "vfs", Vfs_Init
2300: 2c 20 4e 55 4c 4c 29 3b 0a 23 69 66 64 65 66 20 , NULL);.#ifdef
2310: 4b 49 54 5f 49 4e 43 4c 55 44 45 53 5f 5a 4c 49 KIT_INCLUDES_ZLI
2320: 42 0a 09 54 63 6c 5f 53 74 61 74 69 63 50 61 63 B..Tcl_StaticPac
2330: 6b 61 67 65 28 30 2c 20 22 7a 6c 69 62 22 2c 20 kage(0, "zlib",
2340: 5a 6c 69 62 5f 49 6e 69 74 2c 20 4e 55 4c 4c 29 Zlib_Init, NULL)
2350: 3b 0a 23 65 6e 64 69 66 0a 23 69 66 64 65 66 20 ;.#endif.#ifdef
2360: 4b 49 54 5f 53 54 4f 52 41 47 45 5f 43 56 46 53 KIT_STORAGE_CVFS
2370: 0a 09 54 63 6c 5f 53 74 61 74 69 63 50 61 63 6b ..Tcl_StaticPack
2380: 61 67 65 28 30 2c 20 22 63 76 66 73 5f 64 61 74 age(0, "cvfs_dat
2390: 61 5f 74 63 6c 22 2c 20 43 76 66 73 5f 64 61 74 a_tcl", Cvfs_dat
23a0: 61 5f 74 63 6c 5f 49 6e 69 74 2c 20 4e 55 4c 4c a_tcl_Init, NULL
23b0: 29 3b 0a 23 65 6e 64 69 66 0a 23 69 66 64 65 66 );.#endif.#ifdef
23c0: 20 54 43 4c 5f 54 48 52 45 41 44 53 0a 09 54 63 TCL_THREADS..Tc
23d0: 6c 5f 53 74 61 74 69 63 50 61 63 6b 61 67 65 28 l_StaticPackage(
23e0: 30 2c 20 22 54 68 72 65 61 64 22 2c 20 54 68 72 0, "Thread", Thr
23f0: 65 61 64 5f 49 6e 69 74 2c 20 4e 55 4c 4c 29 3b ead_Init, NULL);
2400: 0a 23 65 6e 64 69 66 0a 23 69 66 64 65 66 20 5f .#endif.#ifdef _
2410: 57 49 4e 33 32 0a 09 54 63 6c 5f 53 74 61 74 69 WIN32..Tcl_Stati
2420: 63 50 61 63 6b 61 67 65 28 30 2c 20 22 64 64 65 cPackage(0, "dde
2430: 22 2c 20 44 64 65 5f 49 6e 69 74 2c 20 4e 55 4c ", Dde_Init, NUL
2440: 4c 29 3b 0a 09 54 63 6c 5f 53 74 61 74 69 63 50 L);..Tcl_StaticP
2450: 61 63 6b 61 67 65 28 30 2c 20 22 72 65 67 69 73 ackage(0, "regis
2460: 74 72 79 22 2c 20 52 65 67 69 73 74 72 79 5f 49 try", Registry_I
2470: 6e 69 74 2c 20 4e 55 4c 4c 29 3b 0a 23 65 6e 64 nit, NULL);.#end
2480: 69 66 0a 23 69 66 64 65 66 20 4b 49 54 5f 49 4e if.#ifdef KIT_IN
2490: 43 4c 55 44 45 53 5f 54 4b 0a 09 54 63 6c 5f 53 CLUDES_TK..Tcl_S
24a0: 74 61 74 69 63 50 61 63 6b 61 67 65 28 30 2c 20 taticPackage(0,
24b0: 22 54 6b 22 2c 20 54 6b 5f 49 6e 69 74 2c 20 54 "Tk", Tk_Init, T
24c0: 6b 5f 53 61 66 65 49 6e 69 74 29 3b 0a 23 65 6e k_SafeInit);.#en
24d0: 64 69 66 0a 0a 09 5f 54 63 6c 6b 69 74 5f 47 65 dif..._Tclkit_Ge
24e0: 6e 65 72 69 63 4c 69 62 5f 49 6e 69 74 28 29 3b nericLib_Init();
24f0: 0a 0a 09 54 63 6c 53 65 74 50 72 65 49 6e 69 74 ...TclSetPreInit
2500: 53 63 72 69 70 74 28 70 72 65 49 6e 69 74 43 6d Script(preInitCm
2510: 64 29 3b 0a 0a 09 72 65 74 75 72 6e 3b 0a 7d 0a d);...return;.}.
2520: 0a 73 74 61 74 69 63 20 76 6f 69 64 20 5f 54 63 .static void _Tc
2530: 6c 6b 69 74 5f 49 6e 74 65 72 70 5f 49 6e 69 74 lkit_Interp_Init
2540: 28 54 63 6c 5f 49 6e 74 65 72 70 20 2a 69 6e 74 (Tcl_Interp *int
2550: 65 72 70 29 20 7b 0a 23 69 66 64 65 66 20 54 43 erp) {.#ifdef TC
2560: 4c 4b 49 54 5f 43 41 4e 5f 53 45 54 5f 45 4e 43 LKIT_CAN_SET_ENC
2570: 4f 44 49 4e 47 0a 09 54 63 6c 5f 44 53 74 72 69 ODING..Tcl_DStri
2580: 6e 67 20 65 6e 63 6f 64 69 6e 67 4e 61 6d 65 3b ng encodingName;
2590: 0a 23 65 6e 64 69 66 20 2f 2a 20 54 43 4c 4b 49 .#endif /* TCLKI
25a0: 54 5f 43 41 4e 5f 53 45 54 5f 45 4e 43 4f 44 49 T_CAN_SET_ENCODI
25b0: 4e 47 20 2a 2f 0a 0a 23 69 66 6e 64 65 66 20 54 NG */..#ifndef T
25c0: 43 4c 4b 49 54 5f 44 4c 4c 0a 09 2f 2a 20 74 68 CLKIT_DLL../* th
25d0: 65 20 74 63 6c 5f 72 63 46 69 6c 65 4e 61 6d 65 e tcl_rcFileName
25e0: 20 76 61 72 69 61 62 6c 65 20 6f 6e 6c 79 20 65 variable only e
25f0: 78 69 73 74 73 20 69 6e 20 74 68 65 20 69 6e 69 xists in the ini
2600: 74 69 61 6c 20 69 6e 74 65 72 70 72 65 74 65 72 tial interpreter
2610: 20 2a 2f 0a 23 20 20 69 66 64 65 66 20 5f 57 49 */.# ifdef _WI
2620: 4e 33 32 0a 09 54 63 6c 5f 53 65 74 56 61 72 28 N32..Tcl_SetVar(
2630: 69 6e 74 65 72 70 2c 20 22 74 63 6c 5f 72 63 46 interp, "tcl_rcF
2640: 69 6c 65 4e 61 6d 65 22 2c 20 22 7e 2f 74 63 6c ileName", "~/tcl
2650: 6b 69 74 72 63 2e 74 63 6c 22 2c 20 54 43 4c 5f kitrc.tcl", TCL_
2660: 47 4c 4f 42 41 4c 5f 4f 4e 4c 59 29 3b 0a 23 20 GLOBAL_ONLY);.#
2670: 20 65 6c 73 65 0a 09 54 63 6c 5f 53 65 74 56 61 else..Tcl_SetVa
2680: 72 28 69 6e 74 65 72 70 2c 20 22 74 63 6c 5f 72 r(interp, "tcl_r
2690: 63 46 69 6c 65 4e 61 6d 65 22 2c 20 22 7e 2f 2e cFileName", "~/.
26a0: 74 63 6c 6b 69 74 72 63 22 2c 20 54 43 4c 5f 47 tclkitrc", TCL_G
26b0: 4c 4f 42 41 4c 5f 4f 4e 4c 59 29 3b 0a 23 20 20 LOBAL_ONLY);.#
26c0: 65 6e 64 69 66 20 2f 2a 20 5f 57 49 4e 33 32 20 endif /* _WIN32
26d0: 2a 2f 0a 23 65 6e 64 69 66 20 2f 2a 20 21 54 43 */.#endif /* !TC
26e0: 4c 4b 49 54 5f 44 4c 4c 20 2a 2f 0a 0a 23 69 66 LKIT_DLL */..#if
26f0: 64 65 66 20 54 43 4c 4b 49 54 5f 43 41 4e 5f 53 def TCLKIT_CAN_S
2700: 45 54 5f 45 4e 43 4f 44 49 4e 47 0a 09 2f 2a 20 ET_ENCODING../*
2710: 53 65 74 20 74 68 65 20 65 6e 63 6f 64 69 6e 67 Set the encoding
2720: 20 66 72 6f 6d 20 74 68 65 20 45 6e 76 69 72 6f from the Enviro
2730: 6e 6d 65 6e 74 20 2a 2f 0a 09 54 63 6c 5f 47 65 nment */..Tcl_Ge
2740: 74 45 6e 63 6f 64 69 6e 67 4e 61 6d 65 46 72 6f tEncodingNameFro
2750: 6d 45 6e 76 69 72 6f 6e 6d 65 6e 74 28 26 65 6e mEnvironment(&en
2760: 63 6f 64 69 6e 67 4e 61 6d 65 29 3b 0a 09 54 63 codingName);..Tc
2770: 6c 5f 53 65 74 53 79 73 74 65 6d 45 6e 63 6f 64 l_SetSystemEncod
2780: 69 6e 67 28 4e 55 4c 4c 2c 20 54 63 6c 5f 44 53 ing(NULL, Tcl_DS
2790: 74 72 69 6e 67 56 61 6c 75 65 28 26 65 6e 63 6f tringValue(&enco
27a0: 64 69 6e 67 4e 61 6d 65 29 29 3b 0a 09 54 63 6c dingName));..Tcl
27b0: 5f 53 65 74 56 61 72 28 69 6e 74 65 72 70 2c 20 _SetVar(interp,
27c0: 22 74 63 6c 6b 69 74 5f 73 79 73 74 65 6d 5f 65 "tclkit_system_e
27d0: 6e 63 6f 64 69 6e 67 22 2c 20 54 63 6c 5f 44 53 ncoding", Tcl_DS
27e0: 74 72 69 6e 67 56 61 6c 75 65 28 26 65 6e 63 6f tringValue(&enco
27f0: 64 69 6e 67 4e 61 6d 65 29 2c 20 30 29 3b 0a 09 dingName), 0);..
2800: 54 63 6c 5f 44 53 74 72 69 6e 67 46 72 65 65 28 Tcl_DStringFree(
2810: 26 65 6e 63 6f 64 69 6e 67 4e 61 6d 65 29 3b 0a &encodingName);.
2820: 23 65 6e 64 69 66 20 2f 2a 20 54 43 4c 4b 49 54 #endif /* TCLKIT
2830: 5f 43 41 4e 5f 53 45 54 5f 45 4e 43 4f 44 49 4e _CAN_SET_ENCODIN
2840: 47 20 2a 2f 0a 0a 09 2f 2a 20 48 61 63 6b 20 74 G */.../* Hack t
2850: 6f 20 67 65 74 20 61 72 6f 75 6e 64 20 54 63 6c o get around Tcl
2860: 20 62 75 67 20 31 32 32 34 38 38 38 2e 20 20 54 bug 1224888. T
2870: 68 69 73 20 6d 75 73 74 20 62 65 20 72 75 6e 20 his must be run
2880: 68 65 72 65 20 61 6e 64 0a 09 20 2a 20 69 6e 20 here and.. * in
2890: 4c 69 62 72 61 72 79 50 61 74 68 4f 62 6a 43 6d LibraryPathObjCm
28a0: 64 20 62 65 63 61 75 73 65 20 74 68 69 73 20 69 d because this i
28b0: 6e 66 6f 72 6d 61 74 69 6f 6e 20 69 73 20 6e 65 nformation is ne
28c0: 65 64 65 64 20 62 6f 74 68 0a 09 20 2a 20 62 65 eded both.. * be
28d0: 66 6f 72 65 20 61 6e 64 20 61 66 74 65 72 20 74 fore and after t
28e0: 68 61 74 20 63 6f 6d 6d 61 6e 64 20 69 73 20 72 hat command is r
28f0: 75 6e 2e 20 2a 2f 0a 09 46 69 6e 64 41 6e 64 53 un. */..FindAndS
2900: 65 74 45 78 65 63 4e 61 6d 65 28 69 6e 74 65 72 etExecName(inter
2910: 70 29 3b 0a 0a 23 69 66 20 64 65 66 69 6e 65 64 p);..#if defined
2920: 28 5f 57 49 4e 33 32 29 20 26 26 20 64 65 66 69 (_WIN32) && defi
2930: 6e 65 64 28 4b 49 54 5f 49 4e 43 4c 55 44 45 53 ned(KIT_INCLUDES
2940: 5f 54 4b 29 0a 09 54 6b 5f 49 6e 69 74 43 6f 6e _TK)..Tk_InitCon
2950: 73 6f 6c 65 43 68 61 6e 6e 65 6c 73 28 69 6e 74 soleChannels(int
2960: 65 72 70 29 3b 0a 23 65 6e 64 69 66 20 2f 2a 20 erp);.#endif /*
2970: 5f 57 49 4e 33 32 20 61 6e 64 20 4b 49 54 5f 49 _WIN32 and KIT_I
2980: 4e 43 4c 55 44 45 53 5f 54 4b 20 2a 2f 0a 0a 09 NCLUDES_TK */...
2990: 72 65 74 75 72 6e 3b 0a 7d 0a 0a 23 69 66 6e 64 return;.}..#ifnd
29a0: 65 66 20 54 43 4c 4b 49 54 5f 44 4c 4c 0a 69 6e ef TCLKIT_DLL.in
29b0: 74 20 54 63 6c 4b 69 74 5f 41 70 70 49 6e 69 74 t TclKit_AppInit
29c0: 28 54 63 6c 5f 49 6e 74 65 72 70 20 2a 69 6e 74 (Tcl_Interp *int
29d0: 65 72 70 29 20 7b 0a 23 69 66 64 65 66 20 4b 49 erp) {.#ifdef KI
29e0: 54 5f 49 4e 43 4c 55 44 45 53 5f 54 4b 0a 23 20 T_INCLUDES_TK.#
29f0: 20 69 66 64 65 66 20 5f 57 49 4e 33 32 0a 23 20 ifdef _WIN32.#
2a00: 20 20 20 69 66 6e 64 65 66 20 5f 57 49 4e 33 32 ifndef _WIN32
2a10: 5f 57 43 45 0a 09 63 68 61 72 20 6d 73 67 42 75 _WCE..char msgBu
2a20: 66 5b 32 30 34 39 5d 3b 0a 23 20 20 20 20 65 6e f[2049];.# en
2a30: 64 69 66 20 2f 2a 20 21 5f 57 49 4e 33 32 5f 57 dif /* !_WIN32_W
2a40: 43 45 20 2a 2f 0a 23 20 20 65 6e 64 69 66 20 2f CE */.# endif /
2a50: 2a 20 5f 57 49 4e 33 32 20 2a 2f 0a 23 65 6e 64 * _WIN32 */.#end
2a60: 69 66 20 2f 2a 20 4b 49 54 5f 49 4e 43 4c 55 44 if /* KIT_INCLUD
2a70: 45 53 5f 54 4b 20 2a 2f 0a 0a 09 2f 2a 20 50 65 ES_TK */.../* Pe
2a80: 72 66 6f 72 6d 20 63 6f 6d 6d 6f 6e 20 69 6e 69 rform common ini
2a90: 74 69 61 6c 69 7a 61 74 69 6f 6e 20 2a 2f 0a 09 tialization */..
2aa0: 5f 54 63 6c 6b 69 74 5f 47 65 6e 65 72 69 63 5f _Tclkit_Generic_
2ab0: 49 6e 69 74 28 29 3b 0a 0a 09 5f 54 63 6c 6b 69 Init();..._Tclki
2ac0: 74 5f 49 6e 74 65 72 70 5f 49 6e 69 74 28 69 6e t_Interp_Init(in
2ad0: 74 65 72 70 29 3b 0a 0a 09 69 66 20 28 54 63 6c terp);...if (Tcl
2ae0: 5f 49 6e 69 74 28 69 6e 74 65 72 70 29 20 3d 3d _Init(interp) ==
2af0: 20 54 43 4c 5f 45 52 52 4f 52 29 20 7b 0a 09 09 TCL_ERROR) {...
2b00: 67 6f 74 6f 20 65 72 72 6f 72 3b 0a 09 7d 0a 0a goto error;..}..
2b10: 23 69 66 64 65 66 20 4b 49 54 5f 49 4e 43 4c 55 #ifdef KIT_INCLU
2b20: 44 45 53 5f 54 4b 0a 23 20 20 69 66 64 65 66 20 DES_TK.# ifdef
2b30: 5f 57 49 4e 33 32 0a 09 69 66 20 28 54 6b 5f 49 _WIN32..if (Tk_I
2b40: 6e 69 74 28 69 6e 74 65 72 70 29 20 3d 3d 20 54 nit(interp) == T
2b50: 43 4c 5f 45 52 52 4f 52 29 20 7b 0a 09 09 67 6f CL_ERROR) {...go
2b60: 74 6f 20 65 72 72 6f 72 3b 0a 09 7d 0a 09 69 66 to error;..}..if
2b70: 20 28 54 6b 5f 43 72 65 61 74 65 43 6f 6e 73 6f (Tk_CreateConso
2b80: 6c 65 57 69 6e 64 6f 77 28 69 6e 74 65 72 70 29 leWindow(interp)
2b90: 20 3d 3d 20 54 43 4c 5f 45 52 52 4f 52 29 20 7b == TCL_ERROR) {
2ba0: 0a 09 09 67 6f 74 6f 20 65 72 72 6f 72 3b 0a 09 ...goto error;..
2bb0: 7d 0a 23 20 20 65 6e 64 69 66 20 2f 2a 20 5f 57 }.# endif /* _W
2bc0: 49 4e 33 32 20 2a 2f 0a 23 65 6e 64 69 66 20 2f IN32 */.#endif /
2bd0: 2a 20 4b 49 54 5f 49 4e 43 4c 55 44 45 53 5f 54 * KIT_INCLUDES_T
2be0: 4b 20 2a 2f 0a 0a 09 2f 2a 20 6d 65 73 73 79 20 K */.../* messy
2bf0: 62 65 63 61 75 73 65 20 54 63 6c 53 65 74 53 74 because TclSetSt
2c00: 61 72 74 75 70 53 63 72 69 70 74 50 61 74 68 20 artupScriptPath
2c10: 69 73 20 63 61 6c 6c 65 64 20 73 6c 69 67 68 74 is called slight
2c20: 6c 79 20 74 6f 6f 20 6c 61 74 65 20 2a 2f 0a 09 ly too late */..
2c30: 69 66 20 28 54 63 6c 5f 45 76 61 6c 28 69 6e 74 if (Tcl_Eval(int
2c40: 65 72 70 2c 20 69 6e 69 74 53 63 72 69 70 74 29 erp, initScript)
2c50: 20 3d 3d 20 54 43 4c 5f 4f 4b 29 20 7b 0a 09 09 == TCL_OK) {...
2c60: 54 63 6c 5f 4f 62 6a 2a 20 70 61 74 68 3b 0a 23 Tcl_Obj* path;.#
2c70: 69 66 64 65 66 20 48 41 56 45 5f 54 43 4c 53 45 ifdef HAVE_TCLSE
2c80: 54 53 54 41 52 54 55 50 53 43 52 49 50 54 50 41 TSTARTUPSCRIPTPA
2c90: 54 48 0a 09 09 70 61 74 68 20 3d 20 54 63 6c 47 TH...path = TclG
2ca0: 65 74 53 74 61 72 74 75 70 53 63 72 69 70 74 50 etStartupScriptP
2cb0: 61 74 68 28 29 3b 0a 09 09 54 63 6c 53 65 74 53 ath();...TclSetS
2cc0: 74 61 72 74 75 70 53 63 72 69 70 74 50 61 74 68 tartupScriptPath
2cd0: 28 54 63 6c 5f 47 65 74 4f 62 6a 52 65 73 75 6c (Tcl_GetObjResul
2ce0: 74 28 69 6e 74 65 72 70 29 29 3b 0a 23 65 6c 69 t(interp));.#eli
2cf0: 66 20 64 65 66 69 6e 65 64 28 48 41 56 45 5f 54 f defined(HAVE_T
2d00: 43 4c 5f 53 45 54 53 54 41 52 54 55 50 53 43 52 CL_SETSTARTUPSCR
2d10: 49 50 54 29 0a 09 09 70 61 74 68 20 3d 20 54 63 IPT)...path = Tc
2d20: 6c 5f 47 65 74 53 74 61 72 74 75 70 53 63 72 69 l_GetStartupScri
2d30: 70 74 28 4e 55 4c 4c 29 3b 0a 09 09 54 63 6c 5f pt(NULL);...Tcl_
2d40: 53 65 74 53 74 61 72 74 75 70 53 63 72 69 70 74 SetStartupScript
2d50: 28 54 63 6c 5f 47 65 74 4f 62 6a 52 65 73 75 6c (Tcl_GetObjResul
2d60: 74 28 69 6e 74 65 72 70 29 2c 20 4e 55 4c 4c 29 t(interp), NULL)
2d70: 3b 0a 23 65 6e 64 69 66 0a 09 09 69 66 20 28 70 ;.#endif...if (p
2d80: 61 74 68 20 3d 3d 20 4e 55 4c 4c 29 20 7b 0a 09 ath == NULL) {..
2d90: 09 09 54 63 6c 5f 45 76 61 6c 28 69 6e 74 65 72 ..Tcl_Eval(inter
2da0: 70 2c 20 22 69 6e 63 72 20 61 72 67 63 20 2d 31 p, "incr argc -1
2db0: 3b 20 73 65 74 20 61 72 67 76 20 5b 6c 72 61 6e ; set argv [lran
2dc0: 67 65 20 24 61 72 67 76 20 31 20 65 6e 64 5d 22 ge $argv 1 end]"
2dd0: 29 3b 0a 09 09 7d 0a 09 7d 0a 0a 09 54 63 6c 5f );...}..}...Tcl_
2de0: 53 65 74 56 61 72 28 69 6e 74 65 72 70 2c 20 22 SetVar(interp, "
2df0: 65 72 72 6f 72 49 6e 66 6f 22 2c 20 22 22 2c 20 errorInfo", "",
2e00: 54 43 4c 5f 47 4c 4f 42 41 4c 5f 4f 4e 4c 59 29 TCL_GLOBAL_ONLY)
2e10: 3b 0a 09 54 63 6c 5f 52 65 73 65 74 52 65 73 75 ;..Tcl_ResetResu
2e20: 6c 74 28 69 6e 74 65 72 70 29 3b 0a 0a 09 72 65 lt(interp);...re
2e30: 74 75 72 6e 20 54 43 4c 5f 4f 4b 3b 0a 0a 65 72 turn TCL_OK;..er
2e40: 72 6f 72 3a 0a 23 69 66 64 65 66 20 4b 49 54 5f ror:.#ifdef KIT_
2e50: 49 4e 43 4c 55 44 45 53 5f 54 4b 0a 23 20 20 69 INCLUDES_TK.# i
2e60: 66 64 65 66 20 5f 57 49 4e 33 32 0a 09 4d 65 73 fdef _WIN32..Mes
2e70: 73 61 67 65 42 65 65 70 28 4d 42 5f 49 43 4f 4e sageBeep(MB_ICON
2e80: 45 58 43 4c 41 4d 41 54 49 4f 4e 29 3b 0a 23 20 EXCLAMATION);.#
2e90: 20 20 20 69 66 6e 64 65 66 20 5f 57 49 4e 33 32 ifndef _WIN32
2ea0: 5f 57 43 45 0a 09 73 6e 70 72 69 6e 74 66 28 6d _WCE..snprintf(m
2eb0: 73 67 42 75 66 2c 20 73 69 7a 65 6f 66 28 6d 73 sgBuf, sizeof(ms
2ec0: 67 42 75 66 29 2c 0a 09 09 22 41 20 63 72 69 74 gBuf),..."A crit
2ed0: 69 63 61 6c 20 65 72 72 6f 72 20 68 61 73 20 6f ical error has o
2ee0: 63 63 75 72 72 65 64 2e 20 20 50 6c 65 61 73 65 ccurred. Please
2ef0: 20 72 65 70 6f 72 74 20 74 68 69 73 20 74 6f 20 report this to
2f00: 74 68 65 20 54 63 6c 6b 69 74 20 76 65 6e 64 6f the Tclkit vendo
2f10: 72 2e 5c 6e 49 6e 74 65 72 70 72 65 74 65 72 20 r.\nInterpreter
2f20: 52 65 74 75 72 6e 65 64 3a 20 25 73 5c 6e 45 72 Returned: %s\nEr
2f30: 72 6f 72 20 49 6e 66 6f 3a 20 25 73 22 2c 0a 09 ror Info: %s",..
2f40: 09 54 63 6c 5f 47 65 74 53 74 72 69 6e 67 52 65 .Tcl_GetStringRe
2f50: 73 75 6c 74 28 69 6e 74 65 72 70 29 2c 0a 09 09 sult(interp),...
2f60: 54 63 6c 5f 47 65 74 56 61 72 28 69 6e 74 65 72 Tcl_GetVar(inter
2f70: 70 2c 20 22 65 72 72 6f 72 49 6e 66 6f 22 2c 20 p, "errorInfo",
2f80: 54 43 4c 5f 47 4c 4f 42 41 4c 5f 4f 4e 4c 59 29 TCL_GLOBAL_ONLY)
2f90: 29 3b 0a 0a 09 4d 65 73 73 61 67 65 42 6f 78 28 );...MessageBox(
2fa0: 4e 55 4c 4c 2c 20 6d 73 67 42 75 66 2c 20 22 45 NULL, msgBuf, "E
2fb0: 72 72 6f 72 20 69 6e 20 54 63 6c 4b 69 74 22 2c rror in TclKit",
2fc0: 0a 09 09 4d 42 5f 49 43 4f 4e 53 54 4f 50 20 7c ...MB_ICONSTOP |
2fd0: 20 4d 42 5f 4f 4b 20 7c 20 4d 42 5f 54 41 53 4b MB_OK | MB_TASK
2fe0: 4d 4f 44 41 4c 20 7c 20 4d 42 5f 53 45 54 46 4f MODAL | MB_SETFO
2ff0: 52 45 47 52 4f 55 4e 44 29 3b 0a 0a 09 45 78 69 REGROUND);...Exi
3000: 74 50 72 6f 63 65 73 73 28 31 29 3b 0a 23 20 20 tProcess(1);.#
3010: 20 20 65 6e 64 69 66 20 2f 2a 20 21 5f 57 49 4e endif /* !_WIN
3020: 33 32 5f 57 43 45 20 2a 2f 0a 20 20 20 20 2f 2a 32_WCE */. /*
3030: 20 77 65 20 77 6f 6e 27 74 20 72 65 61 63 68 20 we won't reach
3040: 74 68 69 73 2c 20 62 75 74 20 77 65 20 6e 65 65 this, but we nee
3050: 64 20 74 68 65 20 72 65 74 75 72 6e 20 2a 2f 0a d the return */.
3060: 23 20 20 65 6e 64 69 66 20 2f 2a 20 5f 57 49 4e # endif /* _WIN
3070: 33 32 20 2a 2f 0a 23 65 6e 64 69 66 20 2f 2a 20 32 */.#endif /*
3080: 4b 49 54 5f 49 4e 43 4c 55 44 45 53 5f 54 4b 20 KIT_INCLUDES_TK
3090: 2a 2f 0a 0a 09 72 65 74 75 72 6e 20 54 43 4c 5f */...return TCL_
30a0: 45 52 52 4f 52 3b 0a 7d 0a 23 65 6e 64 69 66 20 ERROR;.}.#endif
30b0: 2f 2a 20 21 54 43 4c 4b 49 54 5f 44 4c 4c 20 2a /* !TCLKIT_DLL *
30c0: 2f 0a 0a 0a 23 69 66 64 65 66 20 54 43 4c 4b 49 /...#ifdef TCLKI
30d0: 54 5f 44 4c 4c 0a 23 20 20 69 66 64 65 66 20 48 T_DLL.# ifdef H
30e0: 41 56 45 5f 41 43 43 45 50 54 41 42 4c 45 5f 44 AVE_ACCEPTABLE_D
30f0: 4c 41 44 44 52 0a 2f 2a 20 53 79 6d 62 6f 6c 20 LADDR./* Symbol
3100: 74 6f 20 72 65 73 6f 6c 76 65 20 61 67 61 69 6e to resolve again
3110: 73 74 20 64 6c 61 64 64 72 28 29 20 2a 2f 0a 73 st dladdr() */.s
3120: 74 61 74 69 63 20 76 6f 69 64 20 5f 74 63 6c 6b tatic void _tclk
3130: 69 74 5f 64 75 6d 6d 79 5f 66 75 6e 63 28 76 6f it_dummy_func(vo
3140: 69 64 29 20 7b 0a 09 72 65 74 75 72 6e 3b 0a 7d id) {..return;.}
3150: 0a 23 20 20 65 6e 64 69 66 20 2f 2a 20 48 41 56 .# endif /* HAV
3160: 45 5f 41 43 43 45 50 54 41 42 4c 45 5f 44 4c 41 E_ACCEPTABLE_DLA
3170: 44 44 52 20 2a 2f 0a 0a 2f 2a 0a 20 2a 20 54 68 DDR */../*. * Th
3180: 69 73 20 66 75 6e 63 74 69 6f 6e 20 77 69 6c 6c is function will
3190: 20 72 65 74 75 72 6e 20 61 20 70 61 74 68 6e 61 return a pathna
31a0: 6d 65 20 77 65 20 63 61 6e 20 6f 70 65 6e 28 29 me we can open()
31b0: 20 74 6f 20 74 72 65 61 74 20 61 73 20 61 20 56 to treat as a V
31c0: 46 53 2c 0a 20 2a 20 68 6f 70 65 66 75 6c 6c 79 FS,. * hopefully
31d0: 0a 20 2a 2f 0a 73 74 61 74 69 63 20 63 68 61 72 . */.static char
31e0: 20 2a 66 69 6e 64 5f 74 63 6c 6b 69 74 5f 64 6c *find_tclkit_dl
31f0: 6c 5f 70 61 74 68 28 76 6f 69 64 29 20 7b 0a 23 l_path(void) {.#
3200: 69 66 64 65 66 20 48 41 56 45 5f 41 43 43 45 50 ifdef HAVE_ACCEP
3210: 54 41 42 4c 45 5f 44 4c 41 44 44 52 0a 09 44 6c TABLE_DLADDR..Dl
3220: 5f 69 6e 66 6f 20 73 79 6d 69 6e 66 6f 3b 0a 09 _info syminfo;..
3230: 69 6e 74 20 64 6c 61 64 64 72 5f 72 65 74 3b 0a int dladdr_ret;.
3240: 23 65 6e 64 69 66 20 2f 2a 20 48 41 56 45 5f 41 #endif /* HAVE_A
3250: 43 43 45 50 54 41 42 4c 45 5f 44 4c 41 44 44 52 CCEPTABLE_DLADDR
3260: 20 2a 2f 0a 23 69 66 64 65 66 20 5f 57 49 4e 33 */.#ifdef _WIN3
3270: 32 0a 09 54 43 48 41 52 20 6d 6f 64 75 6c 65 6e 2..TCHAR modulen
3280: 61 6d 65 5b 38 31 39 32 5d 3b 0a 09 44 57 4f 52 ame[8192];..DWOR
3290: 44 20 67 6d 66 6e 5f 72 65 74 3b 0a 23 65 6e 64 D gmfn_ret;.#end
32a0: 69 66 20 2f 2a 20 5f 57 49 4e 33 32 20 2a 2f 0a if /* _WIN32 */.
32b0: 0a 23 69 66 64 65 66 20 48 41 56 45 5f 41 43 43 .#ifdef HAVE_ACC
32c0: 45 50 54 41 42 4c 45 5f 44 4c 41 44 44 52 0a 09 EPTABLE_DLADDR..
32d0: 64 6c 61 64 64 72 5f 72 65 74 20 3d 20 64 6c 61 dladdr_ret = dla
32e0: 64 64 72 28 26 5f 74 63 6c 6b 69 74 5f 64 75 6d ddr(&_tclkit_dum
32f0: 6d 79 5f 66 75 6e 63 2c 20 26 73 79 6d 69 6e 66 my_func, &syminf
3300: 6f 29 3b 0a 09 69 66 20 28 64 6c 61 64 64 72 5f o);..if (dladdr_
3310: 72 65 74 20 21 3d 20 30 29 20 7b 0a 09 09 69 66 ret != 0) {...if
3320: 20 28 73 79 6d 69 6e 66 6f 2e 64 6c 69 5f 66 6e (syminfo.dli_fn
3330: 61 6d 65 20 26 26 20 73 79 6d 69 6e 66 6f 2e 64 ame && syminfo.d
3340: 6c 69 5f 66 6e 61 6d 65 5b 30 5d 20 21 3d 20 27 li_fname[0] != '
3350: 5c 30 27 29 20 7b 0a 09 09 09 72 65 74 75 72 6e \0') {....return
3360: 28 73 74 72 64 75 70 28 73 79 6d 69 6e 66 6f 2e (strdup(syminfo.
3370: 64 6c 69 5f 66 6e 61 6d 65 29 29 3b 0a 09 09 7d dli_fname));...}
3380: 0a 09 7d 0a 23 65 6e 64 69 66 20 2f 2a 20 48 41 ..}.#endif /* HA
3390: 56 45 5f 41 43 43 45 50 54 41 42 4c 45 5f 44 4c VE_ACCEPTABLE_DL
33a0: 41 44 44 52 20 2a 2f 0a 0a 23 69 66 64 65 66 20 ADDR */..#ifdef
33b0: 5f 57 49 4e 33 32 0a 09 67 6d 66 6e 5f 72 65 74 _WIN32..gmfn_ret
33c0: 20 3d 20 47 65 74 4d 6f 64 75 6c 65 46 69 6c 65 = GetModuleFile
33d0: 4e 61 6d 65 28 54 63 6c 57 69 6e 47 65 74 54 63 Name(TclWinGetTc
33e0: 6c 49 6e 73 74 61 6e 63 65 28 29 2c 20 6d 6f 64 lInstance(), mod
33f0: 75 6c 65 6e 61 6d 65 2c 20 73 69 7a 65 6f 66 28 ulename, sizeof(
3400: 6d 6f 64 75 6c 65 6e 61 6d 65 29 20 2f 20 73 69 modulename) / si
3410: 7a 65 6f 66 28 6d 6f 64 75 6c 65 6e 61 6d 65 5b zeof(modulename[
3420: 30 5d 29 20 2d 20 31 29 3b 0a 0a 09 69 66 20 28 0]) - 1);...if (
3430: 67 6d 66 6e 5f 72 65 74 20 21 3d 20 30 29 20 7b gmfn_ret != 0) {
3440: 0a 09 09 72 65 74 75 72 6e 28 73 74 72 64 75 70 ...return(strdup
3450: 28 6d 6f 64 75 6c 65 6e 61 6d 65 29 29 3b 0a 09 (modulename));..
3460: 7d 0a 23 65 6e 64 69 66 20 2f 2a 20 5f 57 49 4e }.#endif /* _WIN
3470: 33 32 20 2a 2f 0a 0a 09 72 65 74 75 72 6e 28 4e 32 */...return(N
3480: 55 4c 4c 29 3b 0a 7d 0a 0a 2f 2a 0a 20 2a 20 54 ULL);.}../*. * T
3490: 68 69 73 20 66 75 6e 63 74 69 6f 6e 20 65 78 69 his function exi
34a0: 73 74 73 20 74 6f 20 61 6c 6c 6f 77 20 43 20 63 sts to allow C c
34b0: 6f 64 65 20 74 6f 20 69 6e 69 74 69 61 6c 69 7a ode to initializ
34c0: 65 20 61 20 70 61 72 74 69 63 75 6c 61 72 0a 20 e a particular.
34d0: 2a 20 69 6e 74 65 72 70 72 65 74 65 72 2e 0a 20 * interpreter..
34e0: 2a 2f 0a 73 74 61 74 69 63 20 69 6e 74 20 74 63 */.static int tc
34f0: 6c 6b 69 74 5f 69 6e 69 74 5f 69 6e 69 74 69 6e lkit_init_initin
3500: 74 65 72 70 28 43 6c 69 65 6e 74 44 61 74 61 20 terp(ClientData
3510: 63 64 2c 20 54 63 6c 5f 49 6e 74 65 72 70 20 2a cd, Tcl_Interp *
3520: 69 6e 74 65 72 70 2c 20 69 6e 74 20 6f 62 6a 63 interp, int objc
3530: 2c 20 54 63 6c 5f 4f 62 6a 20 2a 43 4f 4e 53 54 , Tcl_Obj *CONST
3540: 20 6f 62 6a 76 5b 5d 29 20 7b 0a 09 63 68 61 72 objv[]) {..char
3550: 20 2a 6b 69 74 64 6c 6c 5f 70 61 74 68 3b 0a 0a *kitdll_path;..
3560: 09 6b 69 74 64 6c 6c 5f 70 61 74 68 20 3d 20 66 .kitdll_path = f
3570: 69 6e 64 5f 74 63 6c 6b 69 74 5f 64 6c 6c 5f 70 ind_tclkit_dll_p
3580: 61 74 68 28 29 3b 0a 09 69 66 20 28 6b 69 74 64 ath();..if (kitd
3590: 6c 6c 5f 70 61 74 68 20 21 3d 20 4e 55 4c 4c 29 ll_path != NULL)
35a0: 20 7b 0a 09 09 54 63 6c 5f 53 65 74 56 61 72 28 {...Tcl_SetVar(
35b0: 69 6e 74 65 72 70 2c 20 22 74 63 6c 4b 69 74 46 interp, "tclKitF
35c0: 69 6c 65 6e 61 6d 65 22 2c 20 6b 69 74 64 6c 6c ilename", kitdll
35d0: 5f 70 61 74 68 2c 20 54 43 4c 5f 47 4c 4f 42 41 _path, TCL_GLOBA
35e0: 4c 5f 4f 4e 4c 59 29 3b 0a 0a 09 09 66 72 65 65 L_ONLY);....free
35f0: 28 6b 69 74 64 6c 6c 5f 70 61 74 68 29 3b 0a 09 (kitdll_path);..
3600: 7d 0a 0a 09 5f 54 63 6c 6b 69 74 5f 49 6e 74 65 }..._Tclkit_Inte
3610: 72 70 5f 49 6e 69 74 28 69 6e 74 65 72 70 29 3b rp_Init(interp);
3620: 0a 0a 09 72 65 74 75 72 6e 28 54 43 4c 5f 4f 4b ...return(TCL_OK
3630: 29 3b 0a 7d 0a 0a 2f 2a 0a 20 2a 20 43 72 65 61 );.}../*. * Crea
3640: 74 65 20 61 20 70 61 63 6b 61 67 65 20 66 6f 72 te a package for
3650: 20 69 6e 69 74 69 61 6c 69 7a 69 6e 67 20 61 20 initializing a
3660: 70 61 72 74 69 63 75 6c 61 72 20 69 6e 74 65 72 particular inter
3670: 70 72 65 74 65 72 2e 20 20 54 68 69 73 20 69 73 preter. This is
3680: 0a 20 2a 20 6f 75 72 20 68 6f 6f 6b 20 74 6f 20 . * our hook to
3690: 68 61 76 65 20 54 63 6c 20 69 6e 76 6f 6b 65 20 have Tcl invoke
36a0: 43 20 63 6f 6d 6d 61 6e 64 73 20 77 68 65 6e 20 C commands when
36b0: 63 72 65 61 74 69 6e 67 20 61 6e 20 69 6e 74 65 creating an inte
36c0: 72 70 72 65 74 65 72 2e 0a 20 2a 20 54 68 65 20 rpreter.. * The
36d0: 70 72 65 49 6e 69 74 43 6d 64 20 77 69 6c 6c 20 preInitCmd will
36e0: 6c 6f 61 64 20 74 68 65 20 70 61 63 6b 61 67 65 load the package
36f0: 20 69 6e 20 74 68 65 20 6e 65 77 20 69 6e 74 65 in the new inte
3700: 72 70 72 65 74 65 72 20 61 6e 64 20 69 6e 76 6f rpreter and invo
3710: 6b 65 0a 20 2a 20 74 68 69 73 20 66 75 6e 63 74 ke. * this funct
3720: 69 6f 6e 2e 0a 20 2a 2f 0a 69 6e 74 20 54 63 6c ion.. */.int Tcl
3730: 6b 69 74 5f 69 6e 69 74 5f 49 6e 69 74 28 54 63 kit_init_Init(Tc
3740: 6c 5f 49 6e 74 65 72 70 20 2a 69 6e 74 65 72 70 l_Interp *interp
3750: 29 20 7b 0a 09 54 63 6c 5f 43 6f 6d 6d 61 6e 64 ) {..Tcl_Command
3760: 20 74 63 6c 43 72 65 61 74 43 6f 6d 6d 5f 72 65 tclCreatComm_re
3770: 74 3b 0a 09 69 6e 74 20 74 63 6c 50 6b 67 50 72 t;..int tclPkgPr
3780: 6f 76 5f 72 65 74 3b 0a 0a 09 74 63 6c 43 72 65 ov_ret;...tclCre
3790: 61 74 43 6f 6d 6d 5f 72 65 74 20 3d 20 54 63 6c atComm_ret = Tcl
37a0: 5f 43 72 65 61 74 65 4f 62 6a 43 6f 6d 6d 61 6e _CreateObjComman
37b0: 64 28 69 6e 74 65 72 70 2c 20 22 3a 3a 74 63 6c d(interp, "::tcl
37c0: 6b 69 74 3a 3a 69 6e 69 74 3a 3a 69 6e 69 74 49 kit::init::initI
37d0: 6e 74 65 72 70 22 2c 20 74 63 6c 6b 69 74 5f 69 nterp", tclkit_i
37e0: 6e 69 74 5f 69 6e 69 74 69 6e 74 65 72 70 2c 20 nit_initinterp,
37f0: 4e 55 4c 4c 2c 20 4e 55 4c 4c 29 3b 0a 09 69 66 NULL, NULL);..if
3800: 20 28 21 74 63 6c 43 72 65 61 74 43 6f 6d 6d 5f (!tclCreatComm_
3810: 72 65 74 29 20 7b 0a 09 09 72 65 74 75 72 6e 28 ret) {...return(
3820: 54 43 4c 5f 45 52 52 4f 52 29 3b 0a 09 7d 0a 0a TCL_ERROR);..}..
3830: 09 74 63 6c 50 6b 67 50 72 6f 76 5f 72 65 74 20 .tclPkgProv_ret
3840: 3d 20 54 63 6c 5f 50 6b 67 50 72 6f 76 69 64 65 = Tcl_PkgProvide
3850: 28 69 6e 74 65 72 70 2c 20 22 74 63 6c 6b 69 74 (interp, "tclkit
3860: 3a 3a 69 6e 69 74 22 2c 20 22 31 2e 30 22 29 3b ::init", "1.0");
3870: 0a 0a 09 72 65 74 75 72 6e 28 74 63 6c 50 6b 67 ...return(tclPkg
3880: 50 72 6f 76 5f 72 65 74 29 3b 0a 7d 0a 0a 2f 2a Prov_ret);.}../*
3890: 0a 20 2a 20 49 6e 69 74 69 61 6c 69 7a 65 20 74 . * Initialize t
38a0: 68 65 20 54 63 6c 20 73 79 73 74 65 6d 20 77 68 he Tcl system wh
38b0: 65 6e 20 77 65 20 61 72 65 20 6c 6f 61 64 65 64 en we are loaded
38c0: 2c 20 74 68 61 74 20 77 61 79 20 54 63 6c 20 66 , that way Tcl f
38d0: 75 6e 63 74 69 6f 6e 73 0a 20 2a 20 61 72 65 20 unctions. * are
38e0: 72 65 61 64 79 20 74 6f 20 62 65 20 75 73 65 64 ready to be used
38f0: 20 77 68 65 6e 20 69 6e 76 6f 6b 65 64 2e 0a 20 when invoked..
3900: 2a 2f 0a 76 6f 69 64 20 5f 5f 61 74 74 72 69 62 */.void __attrib
3910: 75 74 65 5f 5f 28 28 63 6f 6e 73 74 72 75 63 74 ute__((construct
3920: 6f 72 29 29 20 5f 54 63 6c 6b 69 74 5f 49 6e 69 or)) _Tclkit_Ini
3930: 74 28 76 6f 69 64 29 20 7b 0a 09 54 63 6c 5f 53 t(void) {..Tcl_S
3940: 74 61 74 69 63 50 61 63 6b 61 67 65 28 30 2c 20 taticPackage(0,
3950: 22 74 63 6c 6b 69 74 3a 3a 69 6e 69 74 22 2c 20 "tclkit::init",
3960: 54 63 6c 6b 69 74 5f 69 6e 69 74 5f 49 6e 69 74 Tclkit_init_Init
3970: 2c 20 4e 55 4c 4c 29 3b 0a 0a 09 5f 54 63 6c 6b , NULL);..._Tclk
3980: 69 74 5f 47 65 6e 65 72 69 63 5f 49 6e 69 74 28 it_Generic_Init(
3990: 29 3b 0a 0a 09 72 65 74 75 72 6e 3b 0a 7d 0a 23 );...return;.}.#
39a0: 65 6e 64 69 66 0a endif.