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 66 64 65 66 20 4b 49 54 5f 49 if..#ifdef KIT_I
05f0: 4e 43 4c 55 44 45 53 5f 49 54 43 4c 0a 54 63 6c NCLUDES_ITCL.Tcl
0600: 5f 41 70 70 49 6e 69 74 50 72 6f 63 09 49 74 63 _AppInitProc.Itc
0610: 6c 5f 49 6e 69 74 3b 0a 23 65 6e 64 69 66 0a 23 l_Init;.#endif.#
0620: 69 66 64 65 66 20 4b 49 54 5f 49 4e 43 4c 55 44 ifdef KIT_INCLUD
0630: 45 53 5f 4d 4b 34 54 43 4c 0a 54 63 6c 5f 41 70 ES_MK4TCL.Tcl_Ap
0640: 70 49 6e 69 74 50 72 6f 63 09 4d 6b 34 74 63 6c pInitProc.Mk4tcl
0650: 5f 49 6e 69 74 3b 0a 23 65 6e 64 69 66 0a 54 63 _Init;.#endif.Tc
0660: 6c 5f 41 70 70 49 6e 69 74 50 72 6f 63 20 56 66 l_AppInitProc Vf
0670: 73 5f 49 6e 69 74 2c 20 52 65 63 68 61 6e 5f 49 s_Init, Rechan_I
0680: 6e 69 74 3b 0a 23 69 66 64 65 66 20 4b 49 54 5f nit;.#ifdef KIT_
0690: 49 4e 43 4c 55 44 45 53 5f 50 57 42 0a 54 63 6c INCLUDES_PWB.Tcl
06a0: 5f 41 70 70 49 6e 69 74 50 72 6f 63 09 50 77 62 _AppInitProc.Pwb
06b0: 5f 49 6e 69 74 3b 0a 23 65 6e 64 69 66 0a 23 69 _Init;.#endif.#i
06c0: 66 64 65 66 20 4b 49 54 5f 49 4e 43 4c 55 44 45 fdef KIT_INCLUDE
06d0: 53 5f 5a 4c 49 42 0a 54 63 6c 5f 41 70 70 49 6e S_ZLIB.Tcl_AppIn
06e0: 69 74 50 72 6f 63 20 5a 6c 69 62 5f 49 6e 69 74 itProc Zlib_Init
06f0: 3b 0a 23 65 6e 64 69 66 0a 23 69 66 64 65 66 20 ;.#endif.#ifdef
0700: 4b 49 54 5f 53 54 4f 52 41 47 45 5f 43 56 46 53 KIT_STORAGE_CVFS
0710: 0a 54 63 6c 5f 41 70 70 49 6e 69 74 50 72 6f 63 .Tcl_AppInitProc
0720: 20 56 66 73 5f 6b 69 74 64 6c 6c 5f 64 61 74 61 Vfs_kitdll_data
0730: 5f 74 63 6c 5f 49 6e 69 74 3b 0a 23 65 6e 64 69 _tcl_Init;.#endi
0740: 66 0a 23 69 66 64 65 66 20 54 43 4c 5f 54 48 52 f.#ifdef TCL_THR
0750: 45 41 44 53 0a 54 63 6c 5f 41 70 70 49 6e 69 74 EADS.Tcl_AppInit
0760: 50 72 6f 63 09 54 68 72 65 61 64 5f 49 6e 69 74 Proc.Thread_Init
0770: 3b 0a 23 65 6e 64 69 66 0a 23 69 66 64 65 66 20 ;.#endif.#ifdef
0780: 5f 57 49 4e 33 32 0a 54 63 6c 5f 41 70 70 49 6e _WIN32.Tcl_AppIn
0790: 69 74 50 72 6f 63 09 44 64 65 5f 49 6e 69 74 2c itProc.Dde_Init,
07a0: 20 52 65 67 69 73 74 72 79 5f 49 6e 69 74 3b 0a Registry_Init;.
07b0: 23 65 6e 64 69 66 0a 0a 23 69 66 64 65 66 20 54 #endif..#ifdef T
07c0: 43 4c 4b 49 54 5f 44 4c 4c 0a 23 20 20 64 65 66 CLKIT_DLL.# def
07d0: 69 6e 65 20 54 43 4c 4b 49 54 5f 4d 4f 55 4e 54 ine TCLKIT_MOUNT
07e0: 50 4f 49 4e 54 20 22 2f 2e 4b 49 54 44 4c 4c 5f POINT "/.KITDLL_
07f0: 54 43 4c 22 0a 23 65 6c 73 65 0a 23 20 20 64 65 TCL".#else.# de
0800: 66 69 6e 65 20 54 43 4c 4b 49 54 5f 4d 4f 55 4e fine TCLKIT_MOUN
0810: 54 50 4f 49 4e 54 20 22 5b 69 6e 66 6f 20 6e 61 TPOINT "[info na
0820: 6d 65 6f 66 65 78 65 63 75 74 61 62 6c 65 5d 22 meofexecutable]"
0830: 0a 23 65 6e 64 69 66 20 2f 2a 20 54 43 4c 4b 49 .#endif /* TCLKI
0840: 54 5f 44 4c 4c 20 2a 2f 0a 0a 23 69 66 64 65 66 T_DLL */..#ifdef
0850: 20 48 41 56 45 5f 41 43 43 45 50 54 41 42 4c 45 HAVE_ACCEPTABLE
0860: 5f 44 4c 41 44 44 52 0a 23 20 20 69 66 64 65 66 _DLADDR.# ifdef
0870: 20 4b 49 54 53 48 5f 4e 45 45 44 5f 57 49 4e 4d KITSH_NEED_WINM
0880: 41 49 4e 0a 23 20 20 20 20 69 66 64 65 66 20 5f AIN.# ifdef _
0890: 57 49 4e 33 32 5f 57 43 45 0a 69 6e 74 20 77 57 WIN32_WCE.int wW
08a0: 69 6e 4d 61 69 6e 28 48 49 4e 53 54 41 4e 43 45 inMain(HINSTANCE
08b0: 20 68 49 6e 73 74 61 6e 63 65 2c 20 48 49 4e 53 hInstance, HINS
08c0: 54 41 4e 43 45 20 68 50 72 65 76 49 6e 73 74 61 TANCE hPrevInsta
08d0: 6e 63 65 2c 20 4c 50 53 54 52 20 6c 70 73 7a 43 nce, LPSTR lpszC
08e0: 6d 64 4c 69 6e 65 2c 20 69 6e 74 20 6e 43 6d 64 mdLine, int nCmd
08f0: 53 68 6f 77 29 3b 0a 23 20 20 20 20 65 6c 73 65 Show);.# else
0900: 0a 69 6e 74 20 57 69 6e 4d 61 69 6e 28 48 49 4e .int WinMain(HIN
0910: 53 54 41 4e 43 45 20 68 49 6e 73 74 61 6e 63 65 STANCE hInstance
0920: 2c 20 48 49 4e 53 54 41 4e 43 45 20 68 50 72 65 , HINSTANCE hPre
0930: 76 49 6e 73 74 61 6e 63 65 2c 20 4c 50 53 54 52 vInstance, LPSTR
0940: 20 6c 70 73 7a 43 6d 64 4c 69 6e 65 2c 20 69 6e lpszCmdLine, in
0950: 74 20 6e 43 6d 64 53 68 6f 77 29 3b 0a 23 20 20 t nCmdShow);.#
0960: 20 20 65 6e 64 69 66 20 2f 2a 20 5f 57 49 4e 33 endif /* _WIN3
0970: 32 5f 57 43 45 20 2a 2f 0a 23 20 20 65 6e 64 69 2_WCE */.# endi
0980: 66 20 2f 2a 20 4b 49 54 53 48 5f 4e 45 45 44 5f f /* KITSH_NEED_
0990: 57 49 4e 4d 41 49 4e 20 2a 2f 0a 69 6e 74 20 6d WINMAIN */.int m
09a0: 61 69 6e 28 69 6e 74 20 61 72 67 63 2c 20 63 68 ain(int argc, ch
09b0: 61 72 20 2a 2a 61 72 67 76 29 3b 0a 23 65 6e 64 ar **argv);.#end
09c0: 69 66 20 2f 2a 20 48 41 56 45 5f 41 43 43 45 50 if /* HAVE_ACCEP
09d0: 54 41 42 4c 45 5f 44 4c 41 44 44 52 20 2a 2f 0a TABLE_DLADDR */.
09e0: 0a 23 69 66 64 65 66 20 54 43 4c 4b 49 54 5f 52 .#ifdef TCLKIT_R
09f0: 45 51 55 49 52 45 5f 54 43 4c 45 58 45 43 55 54 EQUIRE_TCLEXECUT
0a00: 41 42 4c 45 4e 41 4d 45 0a 63 68 61 72 20 2a 74 ABLENAME.char *t
0a10: 63 6c 45 78 65 63 75 74 61 62 6c 65 4e 61 6d 65 clExecutableName
0a20: 3b 0a 23 65 6e 64 69 66 0a 0a 2f 2a 0a 20 2a 20 ;.#endif../*. *
0a30: 20 41 74 74 65 6d 70 74 20 74 6f 20 6c 6f 61 64 Attempt to load
0a40: 20 61 20 22 62 6f 6f 74 2e 74 63 6c 22 20 65 6e a "boot.tcl" en
0a50: 74 72 79 20 66 72 6f 6d 20 74 68 65 20 65 6d 62 try from the emb
0a60: 65 64 64 65 64 20 4d 65 74 61 4b 69 74 20 66 69 edded MetaKit fi
0a70: 6c 65 2e 0a 20 2a 20 20 49 66 20 74 68 65 72 65 le.. * If there
0a80: 20 69 73 6e 27 74 20 6f 6e 65 2c 20 74 72 79 20 isn't one, try
0a90: 74 6f 20 6f 70 65 6e 20 61 20 72 65 67 75 6c 61 to open a regula
0aa0: 72 20 22 73 65 74 75 70 2e 74 63 6c 22 20 66 69 r "setup.tcl" fi
0ab0: 6c 65 20 69 6e 73 74 65 61 64 2e 0a 20 2a 20 20 le instead.. *
0ac0: 49 66 20 74 68 61 74 20 66 61 69 6c 73 2c 20 74 If that fails, t
0ad0: 68 69 73 20 63 6f 64 65 20 77 69 6c 6c 20 74 68 his code will th
0ae0: 72 6f 77 20 61 6e 20 65 72 72 6f 72 2c 20 75 73 row an error, us
0af0: 69 6e 67 20 61 20 6d 65 73 73 61 67 65 20 62 6f ing a message bo
0b00: 78 2e 0a 20 2a 2f 0a 2f 2a 0a 20 2a 20 54 68 69 x.. */./*. * Thi
0b10: 73 20 54 63 6c 20 63 6f 64 65 20 69 73 20 69 6e s Tcl code is in
0b20: 76 6f 6b 65 64 20 77 68 65 6e 65 76 65 72 20 54 voked whenever T
0b30: 63 6c 5f 49 6e 69 74 28 29 20 69 73 20 63 61 6c cl_Init() is cal
0b40: 6c 65 64 20 6f 6e 20 61 6e 0a 20 2a 20 69 6e 74 led on an. * int
0b50: 65 72 70 72 65 74 65 72 2e 20 20 49 74 20 73 68 erpreter. It sh
0b60: 6f 75 6c 64 20 6d 6f 75 6e 74 20 75 70 20 74 68 ould mount up th
0b70: 65 20 56 46 53 20 61 6e 64 20 6d 61 6b 65 20 65 e VFS and make e
0b80: 76 65 72 79 74 68 69 6e 67 20 72 65 61 64 79 20 verything ready
0b90: 66 6f 72 0a 20 2a 20 74 68 61 74 20 69 6e 74 65 for. * that inte
0ba0: 72 70 72 65 74 65 72 20 74 6f 20 64 6f 20 69 74 rpreter to do it
0bb0: 73 20 6a 6f 62 2e 0a 20 2a 2f 0a 73 74 61 74 69 s job.. */.stati
0bc0: 63 20 63 68 61 72 20 2a 70 72 65 49 6e 69 74 43 c char *preInitC
0bd0: 6d 64 20 3d 20 0a 23 69 66 20 64 65 66 69 6e 65 md = .#if define
0be0: 64 28 5f 57 49 4e 33 32 5f 57 43 45 29 20 26 26 d(_WIN32_WCE) &&
0bf0: 20 21 64 65 66 69 6e 65 64 28 54 43 4c 4b 49 54 !defined(TCLKIT
0c00: 5f 44 4c 4c 29 0a 2f 2a 20 73 69 6c 6c 79 20 68 _DLL)./* silly h
0c10: 61 63 6b 20 74 6f 20 67 65 74 20 77 69 6e 63 65 ack to get wince
0c20: 20 70 6f 72 74 20 74 6f 20 6c 61 75 6e 63 68 2c port to launch,
0c30: 20 73 6f 6d 65 20 73 6f 72 74 20 6f 66 20 73 74 some sort of st
0c40: 64 7b 69 6e 2c 6f 75 74 2c 65 72 72 7d 20 70 72 d{in,out,err} pr
0c50: 6f 62 6c 65 6d 20 2a 2f 0a 22 6f 70 65 6e 20 2f oblem */."open /
0c60: 6b 69 74 6f 75 74 2e 74 78 74 20 61 3b 20 6f 70 kitout.txt a; op
0c70: 65 6e 20 2f 6b 69 74 6f 75 74 2e 74 78 74 20 61 en /kitout.txt a
0c80: 3b 20 6f 70 65 6e 20 2f 6b 69 74 6f 75 74 2e 74 ; open /kitout.t
0c90: 78 74 20 61 5c 6e 22 0a 2f 2a 20 74 68 69 73 20 xt a\n"./* this
0ca0: 74 6f 6f 20 73 65 65 6d 73 20 74 6f 20 62 65 20 too seems to be
0cb0: 6e 65 65 64 65 64 20 6f 6e 20 77 69 6e 63 65 20 needed on wince
0cc0: 2d 20 69 74 20 61 70 70 65 61 72 73 20 74 6f 20 - it appears to
0cd0: 62 65 20 72 65 6c 61 74 65 64 20 74 6f 20 74 68 be related to th
0ce0: 65 20 61 62 6f 76 65 20 2a 2f 0a 22 63 61 74 63 e above */."catc
0cf0: 68 20 7b 72 65 6e 61 6d 65 20 73 6f 75 72 63 65 h {rename source
0d00: 20 3a 3a 74 63 6c 3a 3a 73 6f 75 72 63 65 7d 5c ::tcl::source}\
0d10: 6e 22 0a 22 70 72 6f 63 20 73 6f 75 72 63 65 20 n"."proc source
0d20: 66 69 6c 65 20 7b 5c 6e 22 0a 09 22 73 65 74 20 file {\n".."set
0d30: 6f 6c 64 20 5b 69 6e 66 6f 20 73 63 72 69 70 74 old [info script
0d40: 5d 5c 6e 22 0a 09 22 69 6e 66 6f 20 73 63 72 69 ]\n".."info scri
0d50: 70 74 20 24 66 69 6c 65 5c 6e 22 0a 09 22 73 65 pt $file\n".."se
0d60: 74 20 66 69 64 20 5b 6f 70 65 6e 20 24 66 69 6c t fid [open $fil
0d70: 65 5d 5c 6e 22 0a 09 22 73 65 74 20 64 61 74 61 e]\n".."set data
0d80: 20 5b 72 65 61 64 20 24 66 69 64 5d 5c 6e 22 0a [read $fid]\n".
0d90: 09 22 63 6c 6f 73 65 20 24 66 69 64 5c 6e 22 0a ."close $fid\n".
0da0: 09 22 73 65 74 20 63 6f 64 65 20 5b 63 61 74 63 ."set code [catc
0db0: 68 20 7b 75 70 6c 65 76 65 6c 20 31 20 24 64 61 h {uplevel 1 $da
0dc0: 74 61 7d 20 72 65 73 5d 5c 6e 22 0a 09 22 69 6e ta} res]\n".."in
0dd0: 66 6f 20 73 63 72 69 70 74 20 24 6f 6c 64 5c 6e fo script $old\n
0de0: 22 0a 09 22 69 66 20 7b 24 63 6f 64 65 20 3d 3d ".."if {$code ==
0df0: 20 32 7d 20 7b 20 73 65 74 20 63 6f 64 65 20 30 2} { set code 0
0e00: 20 7d 5c 6e 22 0a 09 22 72 65 74 75 72 6e 20 2d }\n".."return -
0e10: 63 6f 64 65 20 24 63 6f 64 65 20 24 72 65 73 5c code $code $res\
0e20: 6e 22 0a 22 7d 5c 6e 22 0a 23 65 6e 64 69 66 20 n"."}\n".#endif
0e30: 2f 2a 20 5f 57 49 4e 33 32 5f 57 43 45 20 26 26 /* _WIN32_WCE &&
0e40: 20 21 54 43 4c 4b 49 54 5f 44 4c 4c 20 2a 2f 0a !TCLKIT_DLL */.
0e50: 22 70 72 6f 63 20 74 63 6c 4b 69 74 49 6e 69 74 "proc tclKitInit
0e60: 20 7b 7d 20 7b 5c 6e 22 0a 09 22 72 65 6e 61 6d {} {\n".."renam
0e70: 65 20 74 63 6c 4b 69 74 49 6e 69 74 20 7b 7d 5c e tclKitInit {}\
0e80: 6e 22 0a 23 69 66 64 65 66 20 4b 49 54 5f 49 4e n".#ifdef KIT_IN
0e90: 43 4c 55 44 45 53 5f 5a 4c 49 42 0a 09 22 63 61 CLUDES_ZLIB.."ca
0ea0: 74 63 68 20 7b 20 6c 6f 61 64 20 7b 7d 20 7a 6c tch { load {} zl
0eb0: 69 62 20 7d 5c 6e 22 0a 23 65 6e 64 69 66 0a 23 ib }\n".#endif.#
0ec0: 69 66 64 65 66 20 4b 49 54 5f 49 4e 43 4c 55 44 ifdef KIT_INCLUD
0ed0: 45 53 5f 4d 4b 34 54 43 4c 0a 09 22 63 61 74 63 ES_MK4TCL.."catc
0ee0: 68 20 7b 20 6c 6f 61 64 20 7b 7d 20 4d 6b 34 74 h { load {} Mk4t
0ef0: 63 6c 20 7d 5c 6e 22 0a 23 65 6e 64 69 66 0a 23 cl }\n".#endif.#
0f00: 69 66 64 65 66 20 54 43 4c 4b 49 54 5f 44 4c 4c ifdef TCLKIT_DLL
0f10: 0a 09 22 6c 6f 61 64 20 7b 7d 20 74 63 6c 6b 69 .."load {} tclki
0f20: 74 3a 3a 69 6e 69 74 5c 6e 22 0a 23 65 6e 64 69 t::init\n".#endi
0f30: 66 0a 09 22 73 65 74 20 62 6f 6f 74 66 69 6c 65 f.."set bootfile
0f40: 20 5b 66 69 6c 65 20 6a 6f 69 6e 20 22 20 54 43 [file join " TC
0f50: 4c 4b 49 54 5f 4d 4f 55 4e 54 50 4f 49 4e 54 20 LKIT_MOUNTPOINT
0f60: 22 20 62 6f 6f 74 2e 74 63 6c 5d 5c 6e 22 0a 09 " boot.tcl]\n"..
0f70: 22 69 66 20 7b 5b 66 69 6c 65 20 65 78 69 73 74 "if {[file exist
0f80: 73 20 24 62 6f 6f 74 66 69 6c 65 5d 7d 20 7b 5c s $bootfile]} {\
0f90: 6e 22 0a 09 09 22 63 61 74 63 68 20 7b 5c 6e 22 n"..."catch {\n"
0fa0: 0a 09 09 09 22 73 65 74 20 66 20 5b 6f 70 65 6e ...."set f [open
0fb0: 20 24 62 6f 6f 74 66 69 6c 65 5d 5c 6e 22 0a 09 $bootfile]\n"..
0fc0: 09 09 22 73 65 74 20 73 20 5b 72 65 61 64 20 24 .."set s [read $
0fd0: 66 5d 5c 6e 22 0a 09 09 09 22 63 6c 6f 73 65 20 f]\n"...."close
0fe0: 24 66 5c 6e 22 0a 09 09 22 7d 5c 6e 22 0a 09 22 $f\n"..."}\n".."
0ff0: 7d 5c 6e 22 0a 23 69 66 64 65 66 20 4b 49 54 5f }\n".#ifdef KIT_
1000: 53 54 4f 52 41 47 45 5f 4d 4b 34 0a 09 22 73 65 STORAGE_MK4.."se
1010: 74 20 3a 3a 74 63 6c 4b 69 74 53 74 6f 72 61 67 t ::tclKitStorag
1020: 65 20 5c 22 6d 6b 34 5c 22 5c 6e 22 0a 09 22 69 e \"mk4\"\n".."i
1030: 66 20 7b 21 5b 69 6e 66 6f 20 65 78 69 73 74 73 f {![info exists
1040: 20 73 5d 7d 20 7b 5c 6e 22 0a 09 09 22 6d 6b 3a s]} {\n"..."mk:
1050: 3a 66 69 6c 65 20 6f 70 65 6e 20 65 78 65 20 5b :file open exe [
1060: 69 6e 66 6f 20 6e 61 6d 65 6f 66 65 78 65 63 75 info nameofexecu
1070: 74 61 62 6c 65 5d 20 2d 72 65 61 64 6f 6e 6c 79 table] -readonly
1080: 5c 6e 22 0a 09 09 22 73 65 74 20 6e 20 5b 6d 6b \n"..."set n [mk
1090: 3a 3a 73 65 6c 65 63 74 20 65 78 65 2e 64 69 72 ::select exe.dir
10a0: 73 21 30 2e 66 69 6c 65 73 20 6e 61 6d 65 20 62 s!0.files name b
10b0: 6f 6f 74 2e 74 63 6c 5d 5c 6e 22 0a 09 09 22 69 oot.tcl]\n"..."i
10c0: 66 20 7b 24 6e 20 21 3d 20 5c 22 5c 22 7d 20 7b f {$n != \"\"} {
10d0: 5c 6e 22 0a 09 09 09 22 73 65 74 20 73 20 5b 6d \n"...."set s [m
10e0: 6b 3a 3a 67 65 74 20 65 78 65 2e 64 69 72 73 21 k::get exe.dirs!
10f0: 30 2e 66 69 6c 65 73 21 24 6e 20 63 6f 6e 74 65 0.files!$n conte
1100: 6e 74 73 5d 5c 6e 22 0a 09 09 09 22 69 66 20 7b nts]\n"...."if {
1110: 21 5b 73 74 72 69 6e 67 20 6c 65 6e 67 74 68 20 ![string length
1120: 24 73 5d 7d 20 7b 20 65 72 72 6f 72 20 5c 22 65 $s]} { error \"e
1130: 6d 70 74 79 20 62 6f 6f 74 2e 74 63 6c 5c 22 20 mpty boot.tcl\"
1140: 7d 5c 6e 22 0a 09 09 09 22 63 61 74 63 68 20 7b }\n"...."catch {
1150: 6c 6f 61 64 20 7b 7d 20 7a 6c 69 62 7d 5c 6e 22 load {} zlib}\n"
1160: 0a 09 09 09 22 69 66 20 7b 5b 6d 6b 3a 3a 67 65 ...."if {[mk::ge
1170: 74 20 65 78 65 2e 64 69 72 73 21 30 2e 66 69 6c t exe.dirs!0.fil
1180: 65 73 21 24 6e 20 73 69 7a 65 5d 20 21 3d 20 5b es!$n size] != [
1190: 73 74 72 69 6e 67 20 6c 65 6e 67 74 68 20 24 73 string length $s
11a0: 5d 7d 20 7b 5c 6e 22 0a 09 09 09 09 22 73 65 74 ]} {\n"....."set
11b0: 20 73 20 5b 7a 6c 69 62 20 64 65 63 6f 6d 70 72 s [zlib decompr
11c0: 65 73 73 20 24 73 5d 5c 6e 22 0a 09 09 09 22 7d ess $s]\n"...."}
11d0: 5c 6e 22 0a 09 09 22 7d 5c 6e 22 0a 09 22 7d 5c \n"..."}\n".."}\
11e0: 6e 22 0a 23 65 6e 64 69 66 20 2f 2a 20 4b 49 54 n".#endif /* KIT
11f0: 5f 53 54 4f 52 41 47 45 5f 4d 4b 34 20 2a 2f 0a _STORAGE_MK4 */.
1200: 23 69 66 64 65 66 20 4b 49 54 5f 53 54 4f 52 41 #ifdef KIT_STORA
1210: 47 45 5f 5a 49 50 0a 09 22 73 65 74 20 3a 3a 74 GE_ZIP.."set ::t
1220: 63 6c 4b 69 74 53 74 6f 72 61 67 65 20 5c 22 7a clKitStorage \"z
1230: 69 70 5c 22 5c 6e 22 0a 09 22 63 61 74 63 68 20 ip\"\n".."catch
1240: 7b 20 6c 6f 61 64 20 7b 7d 20 76 66 73 20 7d 5c { load {} vfs }\
1250: 6e 22 0a 09 22 69 66 20 7b 21 5b 69 6e 66 6f 20 n".."if {![info
1260: 65 78 69 73 74 73 20 73 5d 7d 20 7b 5c 6e 22 0a exists s]} {\n".
1270: 23 20 20 69 6e 63 6c 75 64 65 20 22 7a 69 70 76 # include "zipv
1280: 66 73 2e 74 63 6c 2e 68 22 0a 09 09 22 63 61 74 fs.tcl.h"..."cat
1290: 63 68 20 7b 5c 6e 22 0a 09 09 09 22 73 65 74 20 ch {\n"...."set
12a0: 3a 3a 74 63 6c 4b 69 74 53 74 6f 72 61 67 65 5f ::tclKitStorage_
12b0: 66 64 20 5b 3a 3a 7a 69 70 3a 3a 6f 70 65 6e 20 fd [::zip::open
12c0: 5b 69 6e 66 6f 20 6e 61 6d 65 6f 66 65 78 65 63 [info nameofexec
12d0: 75 74 61 62 6c 65 5d 5d 5c 6e 22 0a 09 09 09 22 utable]]\n"...."
12e0: 3a 3a 7a 69 70 3a 3a 73 74 61 74 20 24 3a 3a 74 ::zip::stat $::t
12f0: 63 6c 4b 69 74 53 74 6f 72 61 67 65 5f 66 64 20 clKitStorage_fd
1300: 62 6f 6f 74 2e 74 63 6c 20 73 62 5c 6e 22 0a 09 boot.tcl sb\n"..
1310: 09 09 22 73 65 65 6b 20 24 3a 3a 74 63 6c 4b 69 .."seek $::tclKi
1320: 74 53 74 6f 72 61 67 65 5f 66 64 20 24 73 62 28 tStorage_fd $sb(
1330: 69 6e 6f 29 5c 6e 22 0a 09 09 09 22 3a 3a 7a 69 ino)\n"...."::zi
1340: 70 3a 3a 44 61 74 61 20 24 3a 3a 74 63 6c 4b 69 p::Data $::tclKi
1350: 74 53 74 6f 72 61 67 65 5f 66 64 20 73 62 20 73 tStorage_fd sb s
1360: 5c 6e 22 0a 09 09 22 7d 5c 6e 22 0a 09 22 7d 5c \n"..."}\n".."}\
1370: 6e 22 0a 23 65 6e 64 69 66 20 2f 2a 20 4b 49 54 n".#endif /* KIT
1380: 5f 53 54 4f 52 41 47 45 5f 5a 49 50 20 2a 2f 0a _STORAGE_ZIP */.
1390: 23 69 66 64 65 66 20 4b 49 54 5f 53 54 4f 52 41 #ifdef KIT_STORA
13a0: 47 45 5f 43 56 46 53 0a 09 22 73 65 74 20 3a 3a GE_CVFS.."set ::
13b0: 74 63 6c 4b 69 74 53 74 6f 72 61 67 65 20 5c 22 tclKitStorage \"
13c0: 63 76 66 73 5c 22 5c 6e 22 0a 09 22 6c 6f 61 64 cvfs\"\n".."load
13d0: 20 7b 7d 20 72 65 63 68 61 6e 5c 6e 22 0a 09 22 {} rechan\n".."
13e0: 6c 6f 61 64 20 7b 7d 20 76 66 73 5c 6e 22 0a 09 load {} vfs\n"..
13f0: 22 6c 6f 61 64 20 7b 7d 20 76 66 73 5f 6b 69 74 "load {} vfs_kit
1400: 64 6c 6c 5f 64 61 74 61 5f 74 63 6c 5c 6e 22 0a dll_data_tcl\n".
1410: 23 69 6e 63 6c 75 64 65 20 22 76 66 73 5f 6b 69 #include "vfs_ki
1420: 74 64 6c 6c 2e 74 63 6c 2e 68 22 0a 09 22 69 66 tdll.tcl.h".."if
1430: 20 7b 21 5b 69 6e 66 6f 20 65 78 69 73 74 73 20 {![info exists
1440: 73 5d 7d 20 7b 5c 6e 22 0a 09 09 22 63 61 74 63 s]} {\n"..."catc
1450: 68 20 7b 5c 6e 22 0a 09 09 09 22 73 65 74 20 73 h {\n"...."set s
1460: 20 5b 3a 3a 76 66 73 3a 3a 6b 69 74 64 6c 6c 3a [::vfs::kitdll:
1470: 3a 64 61 74 61 3a 3a 67 65 74 44 61 74 61 20 74 :data::getData t
1480: 63 6c 20 62 6f 6f 74 2e 74 63 6c 5d 5c 6e 22 0a cl boot.tcl]\n".
1490: 09 09 22 7d 5c 6e 22 0a 09 22 7d 5c 6e 22 0a 23 .."}\n".."}\n".#
14a0: 65 6e 64 69 66 20 2f 2a 20 4b 49 54 5f 53 54 4f endif /* KIT_STO
14b0: 52 41 47 45 5f 43 56 46 53 20 2a 2f 0a 23 69 66 RAGE_CVFS */.#if
14c0: 64 65 66 20 54 43 4c 4b 49 54 5f 44 4c 4c 0a 09 def TCLKIT_DLL..
14d0: 22 3a 3a 74 63 6c 6b 69 74 3a 3a 69 6e 69 74 3a "::tclkit::init:
14e0: 3a 69 6e 69 74 49 6e 74 65 72 70 5c 6e 22 0a 09 :initInterp\n"..
14f0: 22 72 65 6e 61 6d 65 20 3a 3a 74 63 6c 6b 69 74 "rename ::tclkit
1500: 3a 3a 69 6e 69 74 3a 3a 69 6e 69 74 49 6e 74 65 ::init::initInte
1510: 72 70 20 7b 7d 5c 6e 22 0a 23 65 6c 73 65 0a 09 rp {}\n".#else..
1520: 22 69 66 20 7b 21 5b 69 6e 66 6f 20 65 78 69 73 "if {![info exis
1530: 74 73 20 73 5d 7d 20 7b 5c 6e 22 0a 09 09 22 73 ts s]} {\n"..."s
1540: 65 74 20 66 20 5b 6f 70 65 6e 20 73 65 74 75 70 et f [open setup
1550: 2e 74 63 6c 5d 5c 6e 22 0a 09 09 22 73 65 74 20 .tcl]\n"..."set
1560: 73 20 5b 72 65 61 64 20 24 66 5d 5c 6e 22 0a 09 s [read $f]\n"..
1570: 09 22 63 6c 6f 73 65 20 24 66 5c 6e 22 0a 09 22 ."close $f\n".."
1580: 7d 5c 6e 22 0a 23 65 6e 64 69 66 20 2f 2a 20 54 }\n".#endif /* T
1590: 43 4c 4b 49 54 5f 44 4c 4c 20 2a 2f 0a 09 22 75 CLKIT_DLL */.."u
15a0: 70 6c 65 76 65 6c 20 23 30 20 24 73 5c 6e 22 0a plevel #0 $s\n".
15b0: 23 69 66 20 64 65 66 69 6e 65 64 28 4b 49 54 5f #if defined(KIT_
15c0: 49 4e 43 4c 55 44 45 53 5f 54 4b 29 20 26 26 20 INCLUDES_TK) &&
15d0: 64 65 66 69 6e 65 64 28 4b 49 54 5f 54 4b 5f 56 defined(KIT_TK_V
15e0: 45 52 53 49 4f 4e 29 0a 09 22 70 61 63 6b 61 67 ERSION).."packag
15f0: 65 20 69 66 6e 65 65 64 65 64 20 54 6b 20 22 20 e ifneeded Tk "
1600: 4b 49 54 5f 54 4b 5f 56 45 52 53 49 4f 4e 20 22 KIT_TK_VERSION "
1610: 20 7b 5c 6e 22 0a 09 09 22 6c 6f 61 64 20 7b 7d {\n"..."load {}
1620: 20 54 6b 5c 6e 22 0a 09 22 7d 5c 6e 22 0a 23 65 Tk\n".."}\n".#e
1630: 6e 64 69 66 0a 23 69 66 64 65 66 20 5f 57 49 4e ndif.#ifdef _WIN
1640: 33 32 0a 09 22 63 61 74 63 68 20 7b 6c 6f 61 64 32.."catch {load
1650: 20 7b 7d 20 64 64 65 7d 5c 6e 22 0a 09 22 63 61 {} dde}\n".."ca
1660: 74 63 68 20 7b 6c 6f 61 64 20 7b 7d 20 72 65 67 tch {load {} reg
1670: 69 73 74 72 79 7d 5c 6e 22 0a 23 65 6e 64 69 66 istry}\n".#endif
1680: 20 2f 2a 20 5f 57 49 4e 33 32 20 2a 2f 0a 09 22 /* _WIN32 */.."
1690: 72 65 74 75 72 6e 20 30 5c 6e 22 0a 22 7d 5c 6e return 0\n"."}\n
16a0: 22 0a 22 74 63 6c 4b 69 74 49 6e 69 74 22 3b 0a "."tclKitInit";.
16b0: 0a 73 74 61 74 69 63 20 63 6f 6e 73 74 20 63 68 .static const ch
16c0: 61 72 20 69 6e 69 74 53 63 72 69 70 74 5b 5d 20 ar initScript[]
16d0: 3d 0a 22 69 66 20 7b 5b 66 69 6c 65 20 69 73 66 =."if {[file isf
16e0: 69 6c 65 20 5b 66 69 6c 65 20 6a 6f 69 6e 20 5b ile [file join [
16f0: 69 6e 66 6f 20 6e 61 6d 65 6f 66 65 78 65 5d 20 info nameofexe]
1700: 6d 61 69 6e 2e 74 63 6c 5d 5d 7d 20 7b 5c 6e 22 main.tcl]]} {\n"
1710: 0a 09 22 69 66 20 7b 5b 69 6e 66 6f 20 63 6f 6d .."if {[info com
1720: 6d 61 6e 64 73 20 63 6f 6e 73 6f 6c 65 5d 20 21 mands console] !
1730: 3d 20 7b 7d 7d 20 7b 20 63 6f 6e 73 6f 6c 65 20 = {}} { console
1740: 68 69 64 65 20 7d 5c 6e 22 0a 09 22 73 65 74 20 hide }\n".."set
1750: 74 63 6c 5f 69 6e 74 65 72 61 63 74 69 76 65 20 tcl_interactive
1760: 30 5c 6e 22 0a 09 22 69 6e 63 72 20 61 72 67 63 0\n".."incr argc
1770: 5c 6e 22 0a 09 22 73 65 74 20 61 72 67 76 20 5b \n".."set argv [
1780: 6c 69 6e 73 65 72 74 20 24 61 72 67 76 20 30 20 linsert $argv 0
1790: 24 61 72 67 76 30 5d 5c 6e 22 0a 09 22 73 65 74 $argv0]\n".."set
17a0: 20 61 72 67 76 30 20 5b 66 69 6c 65 20 6a 6f 69 argv0 [file joi
17b0: 6e 20 5b 69 6e 66 6f 20 6e 61 6d 65 6f 66 65 78 n [info nameofex
17c0: 65 5d 20 6d 61 69 6e 2e 74 63 6c 5d 5c 6e 22 0a e] main.tcl]\n".
17d0: 22 7d 20 65 6c 73 65 20 63 6f 6e 74 69 6e 75 65 "} else continue
17e0: 5c 6e 22 3b 0a 0a 2f 2a 20 53 65 74 45 78 65 63 \n";../* SetExec
17f0: 4e 61 6d 65 20 2d 2d 0a 0a 20 20 20 48 61 63 6b Name --.. Hack
1800: 20 74 6f 20 67 65 74 20 61 72 6f 75 6e 64 20 54 to get around T
1810: 63 6c 20 62 75 67 20 31 32 32 34 38 38 38 2e 0a cl bug 1224888..
1820: 2a 2f 0a 73 74 61 74 69 63 20 76 6f 69 64 20 53 */.static void S
1830: 65 74 45 78 65 63 4e 61 6d 65 28 54 63 6c 5f 49 etExecName(Tcl_I
1840: 6e 74 65 72 70 20 2a 69 6e 74 65 72 70 2c 20 63 nterp *interp, c
1850: 6f 6e 73 74 20 63 68 61 72 20 2a 70 61 74 68 29 onst char *path)
1860: 20 7b 0a 23 69 66 64 65 66 20 54 43 4c 4b 49 54 {.#ifdef TCLKIT
1870: 5f 52 45 51 55 49 52 45 5f 54 43 4c 45 58 45 43 _REQUIRE_TCLEXEC
1880: 55 54 41 42 4c 45 4e 41 4d 45 0a 09 74 63 6c 45 UTABLENAME..tclE
1890: 78 65 63 75 74 61 62 6c 65 4e 61 6d 65 20 3d 20 xecutableName =
18a0: 73 74 72 64 75 70 28 70 61 74 68 29 3b 0a 23 65 strdup(path);.#e
18b0: 6e 64 69 66 0a 09 54 63 6c 5f 46 69 6e 64 45 78 ndif..Tcl_FindEx
18c0: 65 63 75 74 61 62 6c 65 28 70 61 74 68 29 3b 0a ecutable(path);.
18d0: 0a 09 72 65 74 75 72 6e 3b 0a 7d 0a 0a 73 74 61 ..return;.}..sta
18e0: 74 69 63 20 76 6f 69 64 20 46 69 6e 64 41 6e 64 tic void FindAnd
18f0: 53 65 74 45 78 65 63 4e 61 6d 65 28 54 63 6c 5f SetExecName(Tcl_
1900: 49 6e 74 65 72 70 20 2a 69 6e 74 65 72 70 29 20 Interp *interp)
1910: 7b 0a 09 69 6e 74 20 6c 65 6e 20 3d 20 30 3b 0a {..int len = 0;.
1920: 09 54 63 6c 5f 4f 62 6a 20 2a 65 78 65 63 4e 61 .Tcl_Obj *execNa
1930: 6d 65 4f 62 6a 3b 0a 09 54 63 6c 5f 4f 62 6a 20 meObj;..Tcl_Obj
1940: 2a 6c 6f 62 6a 76 5b 31 5d 3b 0a 23 69 66 64 65 *lobjv[1];.#ifde
1950: 66 20 48 41 56 45 5f 52 45 41 44 4c 49 4e 4b 0a f HAVE_READLINK.
1960: 09 73 73 69 7a 65 5f 74 20 72 65 61 64 6c 69 6e .ssize_t readlin
1970: 6b 5f 72 65 74 3b 0a 09 63 68 61 72 20 65 78 65 k_ret;..char exe
1980: 5f 62 75 66 5b 34 30 39 36 5d 3b 0a 23 65 6e 64 _buf[4096];.#end
1990: 69 66 20 2f 2a 20 48 41 56 45 5f 52 45 41 44 4c if /* HAVE_READL
19a0: 49 4e 4b 20 2a 2f 0a 23 69 66 64 65 66 20 48 41 INK */.#ifdef HA
19b0: 56 45 5f 41 43 43 45 50 54 41 42 4c 45 5f 44 4c VE_ACCEPTABLE_DL
19c0: 41 44 44 52 0a 09 44 6c 5f 69 6e 66 6f 20 73 79 ADDR..Dl_info sy
19d0: 6d 69 6e 66 6f 3b 0a 09 69 6e 74 20 64 6c 61 64 minfo;..int dlad
19e0: 64 72 5f 72 65 74 3b 0a 23 65 6e 64 69 66 20 2f dr_ret;.#endif /
19f0: 2a 20 48 41 56 45 5f 41 43 43 45 50 54 41 42 4c * HAVE_ACCEPTABL
1a00: 45 5f 44 4c 41 44 44 52 20 2a 2f 20 0a 0a 23 69 E_DLADDR */ ..#i
1a10: 66 64 65 66 20 48 41 56 45 5f 52 45 41 44 4c 49 fdef HAVE_READLI
1a20: 4e 4b 0a 09 69 66 20 28 54 63 6c 5f 47 65 74 4e NK..if (Tcl_GetN
1a30: 61 6d 65 4f 66 45 78 65 63 75 74 61 62 6c 65 28 ameOfExecutable(
1a40: 29 20 3d 3d 20 4e 55 4c 4c 29 20 7b 0a 09 09 72 ) == NULL) {...r
1a50: 65 61 64 6c 69 6e 6b 5f 72 65 74 20 3d 20 72 65 eadlink_ret = re
1a60: 61 64 6c 69 6e 6b 28 22 2f 70 72 6f 63 2f 73 65 adlink("/proc/se
1a70: 6c 66 2f 65 78 65 22 2c 20 65 78 65 5f 62 75 66 lf/exe", exe_buf
1a80: 2c 20 73 69 7a 65 6f 66 28 65 78 65 5f 62 75 66 , sizeof(exe_buf
1a90: 29 20 2d 20 31 29 3b 0a 0a 09 09 69 66 20 28 72 ) - 1);....if (r
1aa0: 65 61 64 6c 69 6e 6b 5f 72 65 74 20 3e 20 30 20 eadlink_ret > 0
1ab0: 26 26 20 72 65 61 64 6c 69 6e 6b 5f 72 65 74 20 && readlink_ret
1ac0: 3c 20 28 73 69 7a 65 6f 66 28 65 78 65 5f 62 75 < (sizeof(exe_bu
1ad0: 66 29 20 2d 20 31 29 29 20 7b 0a 09 09 09 65 78 f) - 1)) {....ex
1ae0: 65 5f 62 75 66 5b 72 65 61 64 6c 69 6e 6b 5f 72 e_buf[readlink_r
1af0: 65 74 5d 20 3d 20 27 5c 30 27 3b 0a 0a 09 09 09 et] = '\0';.....
1b00: 53 65 74 45 78 65 63 4e 61 6d 65 28 69 6e 74 65 SetExecName(inte
1b10: 72 70 2c 20 65 78 65 5f 62 75 66 29 3b 0a 0a 09 rp, exe_buf);...
1b20: 09 09 72 65 74 75 72 6e 3b 0a 09 09 7d 0a 09 7d ..return;...}..}
1b30: 0a 0a 09 69 66 20 28 54 63 6c 5f 47 65 74 4e 61 ...if (Tcl_GetNa
1b40: 6d 65 4f 66 45 78 65 63 75 74 61 62 6c 65 28 29 meOfExecutable()
1b50: 20 3d 3d 20 4e 55 4c 4c 29 20 7b 0a 09 09 72 65 == NULL) {...re
1b60: 61 64 6c 69 6e 6b 5f 72 65 74 20 3d 20 72 65 61 adlink_ret = rea
1b70: 64 6c 69 6e 6b 28 22 2f 70 72 6f 63 2f 63 75 72 dlink("/proc/cur
1b80: 70 72 6f 63 2f 66 69 6c 65 22 2c 20 65 78 65 5f proc/file", 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 69 66 20 28 73 74 72 63 6d 70 28 65 78 ...if (strcmp(ex
1c20: 65 5f 62 75 66 2c 20 22 75 6e 6b 6e 6f 77 6e 22 e_buf, "unknown"
1c30: 29 20 21 3d 20 30 29 20 7b 0a 09 09 09 09 53 65 ) != 0) {.....Se
1c40: 74 45 78 65 63 4e 61 6d 65 28 69 6e 74 65 72 70 tExecName(interp
1c50: 2c 20 65 78 65 5f 62 75 66 29 3b 0a 0a 09 09 09 , exe_buf);.....
1c60: 09 72 65 74 75 72 6e 3b 0a 09 09 09 7d 0a 09 09 .return;....}...
1c70: 7d 0a 09 7d 0a 23 65 6e 64 69 66 20 2f 2a 20 48 }..}.#endif /* H
1c80: 41 56 45 5f 52 45 41 44 4c 49 4e 4b 20 2a 2f 0a AVE_READLINK */.
1c90: 0a 23 69 66 64 65 66 20 48 41 56 45 5f 41 43 43 .#ifdef HAVE_ACC
1ca0: 45 50 54 41 42 4c 45 5f 44 4c 41 44 44 52 0a 23 EPTABLE_DLADDR.#
1cb0: 20 20 69 66 6e 64 65 66 20 54 43 4c 4b 49 54 5f ifndef TCLKIT_
1cc0: 44 4c 4c 0a 09 69 66 20 28 54 63 6c 5f 47 65 74 DLL..if (Tcl_Get
1cd0: 4e 61 6d 65 4f 66 45 78 65 63 75 74 61 62 6c 65 NameOfExecutable
1ce0: 28 29 20 3d 3d 20 4e 55 4c 4c 29 20 7b 0a 09 09 () == NULL) {...
1cf0: 64 6c 61 64 64 72 5f 72 65 74 20 3d 20 64 6c 61 dladdr_ret = dla
1d00: 64 64 72 28 26 53 65 74 45 78 65 63 4e 61 6d 65 ddr(&SetExecName
1d10: 2c 20 26 73 79 6d 69 6e 66 6f 29 3b 0a 09 09 69 , &syminfo);...i
1d20: 66 20 28 64 6c 61 64 64 72 5f 72 65 74 20 21 3d f (dladdr_ret !=
1d30: 20 30 29 20 7b 0a 09 09 09 53 65 74 45 78 65 63 0) {....SetExec
1d40: 4e 61 6d 65 28 69 6e 74 65 72 70 2c 20 73 79 6d Name(interp, sym
1d50: 69 6e 66 6f 2e 64 6c 69 5f 66 6e 61 6d 65 29 3b info.dli_fname);
1d60: 0a 0a 09 09 09 72 65 74 75 72 6e 3b 0a 09 09 7d .....return;...}
1d70: 0a 09 7d 0a 23 20 20 65 6e 64 69 66 20 2f 2a 20 ..}.# endif /*
1d80: 21 54 43 4c 4b 49 54 5f 44 4c 4c 20 2a 2f 0a 0a !TCLKIT_DLL */..
1d90: 23 20 20 69 66 64 65 66 20 4b 49 54 53 48 5f 4e # ifdef KITSH_N
1da0: 45 45 44 5f 57 49 4e 4d 41 49 4e 0a 09 69 66 20 EED_WINMAIN..if
1db0: 28 54 63 6c 5f 47 65 74 4e 61 6d 65 4f 66 45 78 (Tcl_GetNameOfEx
1dc0: 65 63 75 74 61 62 6c 65 28 29 20 3d 3d 20 4e 55 ecutable() == NU
1dd0: 4c 4c 29 20 7b 0a 23 20 20 20 20 69 66 64 65 66 LL) {.# ifdef
1de0: 20 5f 57 49 4e 33 32 5f 57 43 45 0a 09 09 64 6c _WIN32_WCE...dl
1df0: 61 64 64 72 5f 72 65 74 20 3d 20 64 6c 61 64 64 addr_ret = dladd
1e00: 72 28 26 57 69 6e 4d 61 69 6e 2c 20 26 73 79 6d r(&WinMain, &sym
1e10: 69 6e 66 6f 29 3b 0a 23 20 20 20 20 65 6c 73 65 info);.# else
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 77 57 69 6e 4d 61 69 6e dladdr(&wWinMain
1e40: 2c 20 26 73 79 6d 69 6e 66 6f 29 3b 0a 23 20 20 , &syminfo);.#
1e50: 20 20 65 6e 64 69 66 20 2f 2a 20 5f 57 49 4e 33 endif /* _WIN3
1e60: 32 5f 57 43 45 20 2a 2f 0a 0a 09 09 69 66 20 28 2_WCE */....if (
1e70: 64 6c 61 64 64 72 5f 72 65 74 20 21 3d 20 30 29 dladdr_ret != 0)
1e80: 20 7b 0a 09 09 09 53 65 74 45 78 65 63 4e 61 6d {....SetExecNam
1e90: 65 28 69 6e 74 65 72 70 2c 20 73 79 6d 69 6e 66 e(interp, syminf
1ea0: 6f 2e 64 6c 69 5f 66 6e 61 6d 65 29 3b 0a 0a 09 o.dli_fname);...
1eb0: 09 09 72 65 74 75 72 6e 3b 0a 09 09 7d 0a 09 7d ..return;...}..}
1ec0: 0a 23 20 20 65 6e 64 69 66 20 2f 2a 20 4b 49 54 .# endif /* KIT
1ed0: 53 48 5f 4e 45 45 44 5f 57 49 4e 4d 41 49 4e 20 SH_NEED_WINMAIN
1ee0: 2a 2f 0a 0a 09 69 66 20 28 54 63 6c 5f 47 65 74 */...if (Tcl_Get
1ef0: 4e 61 6d 65 4f 66 45 78 65 63 75 74 61 62 6c 65 NameOfExecutable
1f00: 28 29 20 3d 3d 20 4e 55 4c 4c 29 20 7b 0a 09 09 () == NULL) {...
1f10: 64 6c 61 64 64 72 5f 72 65 74 20 3d 20 64 6c 61 dladdr_ret = dla
1f20: 64 64 72 28 26 6d 61 69 6e 2c 20 26 73 79 6d 69 ddr(&main, &symi
1f30: 6e 66 6f 29 3b 0a 09 09 69 66 20 28 64 6c 61 64 nfo);...if (dlad
1f40: 64 72 5f 72 65 74 20 21 3d 20 30 29 20 7b 0a 09 dr_ret != 0) {..
1f50: 09 09 53 65 74 45 78 65 63 4e 61 6d 65 28 69 6e ..SetExecName(in
1f60: 74 65 72 70 2c 20 73 79 6d 69 6e 66 6f 2e 64 6c terp, syminfo.dl
1f70: 69 5f 66 6e 61 6d 65 29 3b 0a 0a 09 09 09 72 65 i_fname);.....re
1f80: 74 75 72 6e 3b 0a 09 09 7d 0a 09 7d 0a 23 65 6e turn;...}..}.#en
1f90: 64 69 66 20 2f 2a 20 48 41 56 45 5f 41 43 43 45 dif /* HAVE_ACCE
1fa0: 50 54 41 42 4c 45 5f 44 4c 41 44 44 52 20 2a 2f PTABLE_DLADDR */
1fb0: 0a 0a 09 69 66 20 28 54 63 6c 5f 47 65 74 4e 61 ...if (Tcl_GetNa
1fc0: 6d 65 4f 66 45 78 65 63 75 74 61 62 6c 65 28 29 meOfExecutable()
1fd0: 20 3d 3d 20 4e 55 4c 4c 29 20 7b 0a 09 09 6c 6f == NULL) {...lo
1fe0: 62 6a 76 5b 30 5d 20 3d 20 54 63 6c 5f 47 65 74 bjv[0] = Tcl_Get
1ff0: 56 61 72 32 45 78 28 69 6e 74 65 72 70 2c 20 22 Var2Ex(interp, "
2000: 61 72 67 76 30 22 2c 20 4e 55 4c 4c 2c 20 54 43 argv0", NULL, TC
2010: 4c 5f 47 4c 4f 42 41 4c 5f 4f 4e 4c 59 29 3b 0a L_GLOBAL_ONLY);.
2020: 09 09 65 78 65 63 4e 61 6d 65 4f 62 6a 20 3d 20 ..execNameObj =
2030: 54 63 6c 5f 46 53 4a 6f 69 6e 54 6f 50 61 74 68 Tcl_FSJoinToPath
2040: 28 54 63 6c 5f 46 53 47 65 74 43 77 64 28 69 6e (Tcl_FSGetCwd(in
2050: 74 65 72 70 29 2c 20 31 2c 20 6c 6f 62 6a 76 29 terp), 1, lobjv)
2060: 3b 0a 0a 09 09 53 65 74 45 78 65 63 4e 61 6d 65 ;....SetExecName
2070: 28 69 6e 74 65 72 70 2c 20 54 63 6c 5f 47 65 74 (interp, Tcl_Get
2080: 53 74 72 69 6e 67 46 72 6f 6d 4f 62 6a 28 65 78 StringFromObj(ex
2090: 65 63 4e 61 6d 65 4f 62 6a 2c 20 26 6c 65 6e 29 ecNameObj, &len)
20a0: 29 3b 0a 0a 09 09 72 65 74 75 72 6e 3b 0a 09 7d );....return;..}
20b0: 0a 0a 09 72 65 74 75 72 6e 3b 0a 7d 0a 0a 73 74 ...return;.}..st
20c0: 61 74 69 63 20 76 6f 69 64 20 5f 54 63 6c 6b 69 atic void _Tclki
20d0: 74 5f 47 65 6e 65 72 69 63 5f 49 6e 69 74 28 76 t_Generic_Init(v
20e0: 6f 69 64 29 20 7b 0a 23 69 66 64 65 66 20 4b 49 oid) {.#ifdef KI
20f0: 54 5f 49 4e 43 4c 55 44 45 53 5f 49 54 43 4c 0a T_INCLUDES_ITCL.
2100: 09 54 63 6c 5f 53 74 61 74 69 63 50 61 63 6b 61 .Tcl_StaticPacka
2110: 67 65 28 30 2c 20 22 49 74 63 6c 22 2c 20 49 74 ge(0, "Itcl", It
2120: 63 6c 5f 49 6e 69 74 2c 20 4e 55 4c 4c 29 3b 0a cl_Init, NULL);.
2130: 23 65 6e 64 69 66 20 0a 23 69 66 64 65 66 20 4b #endif .#ifdef K
2140: 49 54 5f 49 4e 43 4c 55 44 45 53 5f 4d 4b 34 54 IT_INCLUDES_MK4T
2150: 43 4c 0a 09 54 63 6c 5f 53 74 61 74 69 63 50 61 CL..Tcl_StaticPa
2160: 63 6b 61 67 65 28 30 2c 20 22 4d 6b 34 74 63 6c ckage(0, "Mk4tcl
2170: 22 2c 20 4d 6b 34 74 63 6c 5f 49 6e 69 74 2c 20 ", Mk4tcl_Init,
2180: 4e 55 4c 4c 29 3b 0a 23 65 6e 64 69 66 0a 23 69 NULL);.#endif.#i
2190: 66 64 65 66 20 4b 49 54 5f 49 4e 43 4c 55 44 45 fdef KIT_INCLUDE
21a0: 53 5f 50 57 42 0a 09 54 63 6c 5f 53 74 61 74 69 S_PWB..Tcl_Stati
21b0: 63 50 61 63 6b 61 67 65 28 30 2c 20 22 70 77 62 cPackage(0, "pwb
21c0: 22 2c 20 50 77 62 5f 49 6e 69 74 2c 20 4e 55 4c ", Pwb_Init, NUL
21d0: 4c 29 3b 0a 23 65 6e 64 69 66 20 0a 09 54 63 6c L);.#endif ..Tcl
21e0: 5f 53 74 61 74 69 63 50 61 63 6b 61 67 65 28 30 _StaticPackage(0
21f0: 2c 20 22 72 65 63 68 61 6e 22 2c 20 52 65 63 68 , "rechan", Rech
2200: 61 6e 5f 49 6e 69 74 2c 20 4e 55 4c 4c 29 3b 0a an_Init, NULL);.
2210: 09 54 63 6c 5f 53 74 61 74 69 63 50 61 63 6b 61 .Tcl_StaticPacka
2220: 67 65 28 30 2c 20 22 76 66 73 22 2c 20 56 66 73 ge(0, "vfs", Vfs
2230: 5f 49 6e 69 74 2c 20 4e 55 4c 4c 29 3b 0a 23 69 _Init, NULL);.#i
2240: 66 64 65 66 20 4b 49 54 5f 49 4e 43 4c 55 44 45 fdef KIT_INCLUDE
2250: 53 5f 5a 4c 49 42 0a 09 54 63 6c 5f 53 74 61 74 S_ZLIB..Tcl_Stat
2260: 69 63 50 61 63 6b 61 67 65 28 30 2c 20 22 7a 6c icPackage(0, "zl
2270: 69 62 22 2c 20 5a 6c 69 62 5f 49 6e 69 74 2c 20 ib", Zlib_Init,
2280: 4e 55 4c 4c 29 3b 0a 23 65 6e 64 69 66 0a 23 69 NULL);.#endif.#i
2290: 66 64 65 66 20 4b 49 54 5f 53 54 4f 52 41 47 45 fdef KIT_STORAGE
22a0: 5f 43 56 46 53 0a 09 54 63 6c 5f 53 74 61 74 69 _CVFS..Tcl_Stati
22b0: 63 50 61 63 6b 61 67 65 28 30 2c 20 22 76 66 73 cPackage(0, "vfs
22c0: 5f 6b 69 74 64 6c 6c 5f 64 61 74 61 5f 74 63 6c _kitdll_data_tcl
22d0: 22 2c 20 56 66 73 5f 6b 69 74 64 6c 6c 5f 64 61 ", Vfs_kitdll_da
22e0: 74 61 5f 74 63 6c 5f 49 6e 69 74 2c 20 4e 55 4c ta_tcl_Init, NUL
22f0: 4c 29 3b 0a 23 65 6e 64 69 66 0a 23 69 66 64 65 L);.#endif.#ifde
2300: 66 20 54 43 4c 5f 54 48 52 45 41 44 53 0a 09 54 f TCL_THREADS..T
2310: 63 6c 5f 53 74 61 74 69 63 50 61 63 6b 61 67 65 cl_StaticPackage
2320: 28 30 2c 20 22 54 68 72 65 61 64 22 2c 20 54 68 (0, "Thread", Th
2330: 72 65 61 64 5f 49 6e 69 74 2c 20 4e 55 4c 4c 29 read_Init, NULL)
2340: 3b 0a 23 65 6e 64 69 66 0a 23 69 66 64 65 66 20 ;.#endif.#ifdef
2350: 5f 57 49 4e 33 32 0a 09 54 63 6c 5f 53 74 61 74 _WIN32..Tcl_Stat
2360: 69 63 50 61 63 6b 61 67 65 28 30 2c 20 22 64 64 icPackage(0, "dd
2370: 65 22 2c 20 44 64 65 5f 49 6e 69 74 2c 20 4e 55 e", Dde_Init, NU
2380: 4c 4c 29 3b 0a 09 54 63 6c 5f 53 74 61 74 69 63 LL);..Tcl_Static
2390: 50 61 63 6b 61 67 65 28 30 2c 20 22 72 65 67 69 Package(0, "regi
23a0: 73 74 72 79 22 2c 20 52 65 67 69 73 74 72 79 5f stry", Registry_
23b0: 49 6e 69 74 2c 20 4e 55 4c 4c 29 3b 0a 23 65 6e Init, NULL);.#en
23c0: 64 69 66 0a 23 69 66 64 65 66 20 4b 49 54 5f 49 dif.#ifdef KIT_I
23d0: 4e 43 4c 55 44 45 53 5f 54 4b 0a 09 54 63 6c 5f NCLUDES_TK..Tcl_
23e0: 53 74 61 74 69 63 50 61 63 6b 61 67 65 28 30 2c StaticPackage(0,
23f0: 20 22 54 6b 22 2c 20 54 6b 5f 49 6e 69 74 2c 20 "Tk", Tk_Init,
2400: 54 6b 5f 53 61 66 65 49 6e 69 74 29 3b 0a 23 65 Tk_SafeInit);.#e
2410: 6e 64 69 66 0a 0a 09 54 63 6c 53 65 74 50 72 65 ndif...TclSetPre
2420: 49 6e 69 74 53 63 72 69 70 74 28 70 72 65 49 6e InitScript(preIn
2430: 69 74 43 6d 64 29 3b 0a 0a 09 72 65 74 75 72 6e itCmd);...return
2440: 3b 0a 7d 0a 0a 73 74 61 74 69 63 20 76 6f 69 64 ;.}..static void
2450: 20 5f 54 63 6c 6b 69 74 5f 49 6e 74 65 72 70 5f _Tclkit_Interp_
2460: 49 6e 69 74 28 54 63 6c 5f 49 6e 74 65 72 70 20 Init(Tcl_Interp
2470: 2a 69 6e 74 65 72 70 29 20 7b 0a 23 69 66 64 65 *interp) {.#ifde
2480: 66 20 54 43 4c 4b 49 54 5f 43 41 4e 5f 53 45 54 f TCLKIT_CAN_SET
2490: 5f 45 4e 43 4f 44 49 4e 47 0a 09 54 63 6c 5f 44 _ENCODING..Tcl_D
24a0: 53 74 72 69 6e 67 20 65 6e 63 6f 64 69 6e 67 4e String encodingN
24b0: 61 6d 65 3b 0a 23 65 6e 64 69 66 20 2f 2a 20 54 ame;.#endif /* T
24c0: 43 4c 4b 49 54 5f 43 41 4e 5f 53 45 54 5f 45 4e CLKIT_CAN_SET_EN
24d0: 43 4f 44 49 4e 47 20 2a 2f 0a 0a 09 2f 2a 20 74 CODING */.../* t
24e0: 68 65 20 74 63 6c 5f 72 63 46 69 6c 65 4e 61 6d he tcl_rcFileNam
24f0: 65 20 76 61 72 69 61 62 6c 65 20 6f 6e 6c 79 20 e variable only
2500: 65 78 69 73 74 73 20 69 6e 20 74 68 65 20 69 6e exists in the in
2510: 69 74 69 61 6c 20 69 6e 74 65 72 70 72 65 74 65 itial interprete
2520: 72 20 2a 2f 0a 23 69 66 64 65 66 20 5f 57 49 4e r */.#ifdef _WIN
2530: 33 32 0a 09 54 63 6c 5f 53 65 74 56 61 72 28 69 32..Tcl_SetVar(i
2540: 6e 74 65 72 70 2c 20 22 74 63 6c 5f 72 63 46 69 nterp, "tcl_rcFi
2550: 6c 65 4e 61 6d 65 22 2c 20 22 7e 2f 74 63 6c 6b leName", "~/tclk
2560: 69 74 72 63 2e 74 63 6c 22 2c 20 54 43 4c 5f 47 itrc.tcl", TCL_G
2570: 4c 4f 42 41 4c 5f 4f 4e 4c 59 29 3b 0a 23 65 6c LOBAL_ONLY);.#el
2580: 73 65 0a 09 54 63 6c 5f 53 65 74 56 61 72 28 69 se..Tcl_SetVar(i
2590: 6e 74 65 72 70 2c 20 22 74 63 6c 5f 72 63 46 69 nterp, "tcl_rcFi
25a0: 6c 65 4e 61 6d 65 22 2c 20 22 7e 2f 2e 74 63 6c leName", "~/.tcl
25b0: 6b 69 74 72 63 22 2c 20 54 43 4c 5f 47 4c 4f 42 kitrc", TCL_GLOB
25c0: 41 4c 5f 4f 4e 4c 59 29 3b 0a 23 65 6e 64 69 66 AL_ONLY);.#endif
25d0: 0a 0a 23 69 66 64 65 66 20 54 43 4c 4b 49 54 5f ..#ifdef TCLKIT_
25e0: 43 41 4e 5f 53 45 54 5f 45 4e 43 4f 44 49 4e 47 CAN_SET_ENCODING
25f0: 0a 09 2f 2a 20 53 65 74 20 74 68 65 20 65 6e 63 ../* Set the enc
2600: 6f 64 69 6e 67 20 66 72 6f 6d 20 74 68 65 20 45 oding from the E
2610: 6e 76 69 72 6f 6e 6d 65 6e 74 20 2a 2f 0a 09 54 nvironment */..T
2620: 63 6c 5f 47 65 74 45 6e 63 6f 64 69 6e 67 4e 61 cl_GetEncodingNa
2630: 6d 65 46 72 6f 6d 45 6e 76 69 72 6f 6e 6d 65 6e meFromEnvironmen
2640: 74 28 26 65 6e 63 6f 64 69 6e 67 4e 61 6d 65 29 t(&encodingName)
2650: 3b 0a 09 54 63 6c 5f 53 65 74 53 79 73 74 65 6d ;..Tcl_SetSystem
2660: 45 6e 63 6f 64 69 6e 67 28 4e 55 4c 4c 2c 20 54 Encoding(NULL, T
2670: 63 6c 5f 44 53 74 72 69 6e 67 56 61 6c 75 65 28 cl_DStringValue(
2680: 26 65 6e 63 6f 64 69 6e 67 4e 61 6d 65 29 29 3b &encodingName));
2690: 0a 09 54 63 6c 5f 53 65 74 56 61 72 28 69 6e 74 ..Tcl_SetVar(int
26a0: 65 72 70 2c 20 22 74 63 6c 6b 69 74 5f 73 79 73 erp, "tclkit_sys
26b0: 74 65 6d 5f 65 6e 63 6f 64 69 6e 67 22 2c 20 54 tem_encoding", T
26c0: 63 6c 5f 44 53 74 72 69 6e 67 56 61 6c 75 65 28 cl_DStringValue(
26d0: 26 65 6e 63 6f 64 69 6e 67 4e 61 6d 65 29 2c 20 &encodingName),
26e0: 30 29 3b 0a 09 54 63 6c 5f 44 53 74 72 69 6e 67 0);..Tcl_DString
26f0: 46 72 65 65 28 26 65 6e 63 6f 64 69 6e 67 4e 61 Free(&encodingNa
2700: 6d 65 29 3b 0a 23 65 6e 64 69 66 0a 0a 09 2f 2a me);.#endif.../*
2710: 20 48 61 63 6b 20 74 6f 20 67 65 74 20 61 72 6f Hack to get aro
2720: 75 6e 64 20 54 63 6c 20 62 75 67 20 31 32 32 34 und Tcl bug 1224
2730: 38 38 38 2e 20 20 54 68 69 73 20 6d 75 73 74 20 888. This must
2740: 62 65 20 72 75 6e 20 68 65 72 65 20 61 6e 64 0a be run here and.
2750: 09 20 2a 20 69 6e 20 4c 69 62 72 61 72 79 50 61 . * in LibraryPa
2760: 74 68 4f 62 6a 43 6d 64 20 62 65 63 61 75 73 65 thObjCmd because
2770: 20 74 68 69 73 20 69 6e 66 6f 72 6d 61 74 69 6f this informatio
2780: 6e 20 69 73 20 6e 65 65 64 65 64 20 62 6f 74 68 n is needed both
2790: 0a 09 20 2a 20 62 65 66 6f 72 65 20 61 6e 64 20 .. * before and
27a0: 61 66 74 65 72 20 74 68 61 74 20 63 6f 6d 6d 61 after that comma
27b0: 6e 64 20 69 73 20 72 75 6e 2e 20 2a 2f 0a 09 46 nd is run. */..F
27c0: 69 6e 64 41 6e 64 53 65 74 45 78 65 63 4e 61 6d indAndSetExecNam
27d0: 65 28 69 6e 74 65 72 70 29 3b 0a 0a 09 72 65 74 e(interp);...ret
27e0: 75 72 6e 3b 0a 7d 0a 0a 69 6e 74 20 54 63 6c 4b urn;.}..int TclK
27f0: 69 74 5f 41 70 70 49 6e 69 74 28 54 63 6c 5f 49 it_AppInit(Tcl_I
2800: 6e 74 65 72 70 20 2a 69 6e 74 65 72 70 29 20 7b nterp *interp) {
2810: 0a 23 69 66 64 65 66 20 4b 49 54 5f 49 4e 43 4c .#ifdef KIT_INCL
2820: 55 44 45 53 5f 54 4b 0a 23 20 20 69 66 64 65 66 UDES_TK.# ifdef
2830: 20 5f 57 49 4e 33 32 0a 23 20 20 20 20 69 66 6e _WIN32.# ifn
2840: 64 65 66 20 5f 57 49 4e 33 32 5f 57 43 45 0a 09 def _WIN32_WCE..
2850: 63 68 61 72 20 6d 73 67 42 75 66 5b 32 30 34 39 char msgBuf[2049
2860: 5d 3b 0a 23 20 20 20 20 65 6e 64 69 66 20 2f 2a ];.# endif /*
2870: 20 21 5f 57 49 4e 33 32 5f 57 43 45 20 2a 2f 0a !_WIN32_WCE */.
2880: 23 20 20 65 6e 64 69 66 20 2f 2a 20 5f 57 49 4e # endif /* _WIN
2890: 33 32 20 2a 2f 0a 23 65 6e 64 69 66 20 2f 2a 20 32 */.#endif /*
28a0: 4b 49 54 5f 49 4e 43 4c 55 44 45 53 5f 54 4b 20 KIT_INCLUDES_TK
28b0: 2a 2f 0a 0a 09 2f 2a 20 50 65 72 66 6f 72 6d 20 */.../* Perform
28c0: 63 6f 6d 6d 6f 6e 20 69 6e 69 74 69 61 6c 69 7a common initializ
28d0: 61 74 69 6f 6e 20 2a 2f 0a 09 5f 54 63 6c 6b 69 ation */.._Tclki
28e0: 74 5f 47 65 6e 65 72 69 63 5f 49 6e 69 74 28 29 t_Generic_Init()
28f0: 3b 0a 0a 09 5f 54 63 6c 6b 69 74 5f 49 6e 74 65 ;..._Tclkit_Inte
2900: 72 70 5f 49 6e 69 74 28 69 6e 74 65 72 70 29 3b rp_Init(interp);
2910: 0a 0a 09 69 66 20 28 54 63 6c 5f 49 6e 69 74 28 ...if (Tcl_Init(
2920: 69 6e 74 65 72 70 29 20 3d 3d 20 54 43 4c 5f 45 interp) == TCL_E
2930: 52 52 4f 52 29 20 7b 0a 09 09 67 6f 74 6f 20 65 RROR) {...goto e
2940: 72 72 6f 72 3b 0a 09 7d 0a 0a 23 69 66 64 65 66 rror;..}..#ifdef
2950: 20 4b 49 54 5f 49 4e 43 4c 55 44 45 53 5f 54 4b KIT_INCLUDES_TK
2960: 0a 23 20 20 69 66 64 65 66 20 5f 57 49 4e 33 32 .# ifdef _WIN32
2970: 0a 09 69 66 20 28 54 6b 5f 49 6e 69 74 28 69 6e ..if (Tk_Init(in
2980: 74 65 72 70 29 20 3d 3d 20 54 43 4c 5f 45 52 52 terp) == TCL_ERR
2990: 4f 52 29 20 7b 0a 09 09 67 6f 74 6f 20 65 72 72 OR) {...goto err
29a0: 6f 72 3b 0a 09 7d 0a 09 69 66 20 28 54 6b 5f 43 or;..}..if (Tk_C
29b0: 72 65 61 74 65 43 6f 6e 73 6f 6c 65 57 69 6e 64 reateConsoleWind
29c0: 6f 77 28 69 6e 74 65 72 70 29 20 3d 3d 20 54 43 ow(interp) == TC
29d0: 4c 5f 45 52 52 4f 52 29 20 7b 0a 09 09 67 6f 74 L_ERROR) {...got
29e0: 6f 20 65 72 72 6f 72 3b 0a 09 7d 0a 23 20 20 65 o error;..}.# e
29f0: 6e 64 69 66 20 2f 2a 20 5f 57 49 4e 33 32 20 2a ndif /* _WIN32 *
2a00: 2f 0a 23 65 6e 64 69 66 20 2f 2a 20 4b 49 54 5f /.#endif /* KIT_
2a10: 49 4e 43 4c 55 44 45 53 5f 54 4b 20 2a 2f 0a 0a INCLUDES_TK */..
2a20: 09 2f 2a 20 6d 65 73 73 79 20 62 65 63 61 75 73 ./* messy becaus
2a30: 65 20 54 63 6c 53 65 74 53 74 61 72 74 75 70 53 e TclSetStartupS
2a40: 63 72 69 70 74 50 61 74 68 20 69 73 20 63 61 6c criptPath is cal
2a50: 6c 65 64 20 73 6c 69 67 68 74 6c 79 20 74 6f 6f led slightly too
2a60: 20 6c 61 74 65 20 2a 2f 0a 09 69 66 20 28 54 63 late */..if (Tc
2a70: 6c 5f 45 76 61 6c 28 69 6e 74 65 72 70 2c 20 69 l_Eval(interp, i
2a80: 6e 69 74 53 63 72 69 70 74 29 20 3d 3d 20 54 43 nitScript) == TC
2a90: 4c 5f 4f 4b 29 20 7b 0a 09 09 54 63 6c 5f 4f 62 L_OK) {...Tcl_Ob
2aa0: 6a 2a 20 70 61 74 68 3b 0a 23 69 66 64 65 66 20 j* path;.#ifdef
2ab0: 48 41 56 45 5f 54 43 4c 53 45 54 53 54 41 52 54 HAVE_TCLSETSTART
2ac0: 55 50 53 43 52 49 50 54 50 41 54 48 0a 09 09 70 UPSCRIPTPATH...p
2ad0: 61 74 68 20 3d 20 54 63 6c 47 65 74 53 74 61 72 ath = TclGetStar
2ae0: 74 75 70 53 63 72 69 70 74 50 61 74 68 28 29 3b tupScriptPath();
2af0: 0a 09 09 54 63 6c 53 65 74 53 74 61 72 74 75 70 ...TclSetStartup
2b00: 53 63 72 69 70 74 50 61 74 68 28 54 63 6c 5f 47 ScriptPath(Tcl_G
2b10: 65 74 4f 62 6a 52 65 73 75 6c 74 28 69 6e 74 65 etObjResult(inte
2b20: 72 70 29 29 3b 0a 23 65 6c 69 66 20 64 65 66 69 rp));.#elif defi
2b30: 6e 65 64 28 48 41 56 45 5f 54 43 4c 5f 53 45 54 ned(HAVE_TCL_SET
2b40: 53 54 41 52 54 55 50 53 43 52 49 50 54 29 0a 09 STARTUPSCRIPT)..
2b50: 09 70 61 74 68 20 3d 20 54 63 6c 5f 47 65 74 53 .path = Tcl_GetS
2b60: 74 61 72 74 75 70 53 63 72 69 70 74 28 4e 55 4c tartupScript(NUL
2b70: 4c 29 3b 0a 09 09 54 63 6c 5f 53 65 74 53 74 61 L);...Tcl_SetSta
2b80: 72 74 75 70 53 63 72 69 70 74 28 54 63 6c 5f 47 rtupScript(Tcl_G
2b90: 65 74 4f 62 6a 52 65 73 75 6c 74 28 69 6e 74 65 etObjResult(inte
2ba0: 72 70 29 2c 20 4e 55 4c 4c 29 3b 0a 23 65 6e 64 rp), NULL);.#end
2bb0: 69 66 0a 09 09 69 66 20 28 70 61 74 68 20 3d 3d if...if (path ==
2bc0: 20 4e 55 4c 4c 29 20 7b 0a 09 09 09 54 63 6c 5f NULL) {....Tcl_
2bd0: 45 76 61 6c 28 69 6e 74 65 72 70 2c 20 22 69 6e Eval(interp, "in
2be0: 63 72 20 61 72 67 63 20 2d 31 3b 20 73 65 74 20 cr argc -1; set
2bf0: 61 72 67 76 20 5b 6c 72 61 6e 67 65 20 24 61 72 argv [lrange $ar
2c00: 67 76 20 31 20 65 6e 64 5d 22 29 3b 0a 09 09 7d gv 1 end]");...}
2c10: 0a 09 7d 0a 0a 09 54 63 6c 5f 53 65 74 56 61 72 ..}...Tcl_SetVar
2c20: 28 69 6e 74 65 72 70 2c 20 22 65 72 72 6f 72 49 (interp, "errorI
2c30: 6e 66 6f 22 2c 20 22 22 2c 20 54 43 4c 5f 47 4c nfo", "", TCL_GL
2c40: 4f 42 41 4c 5f 4f 4e 4c 59 29 3b 0a 09 54 63 6c OBAL_ONLY);..Tcl
2c50: 5f 52 65 73 65 74 52 65 73 75 6c 74 28 69 6e 74 _ResetResult(int
2c60: 65 72 70 29 3b 0a 0a 09 72 65 74 75 72 6e 20 54 erp);...return T
2c70: 43 4c 5f 4f 4b 3b 0a 0a 65 72 72 6f 72 3a 0a 23 CL_OK;..error:.#
2c80: 69 66 64 65 66 20 4b 49 54 5f 49 4e 43 4c 55 44 ifdef KIT_INCLUD
2c90: 45 53 5f 54 4b 0a 23 20 20 69 66 64 65 66 20 5f ES_TK.# ifdef _
2ca0: 57 49 4e 33 32 0a 09 4d 65 73 73 61 67 65 42 65 WIN32..MessageBe
2cb0: 65 70 28 4d 42 5f 49 43 4f 4e 45 58 43 4c 41 4d ep(MB_ICONEXCLAM
2cc0: 41 54 49 4f 4e 29 3b 0a 23 20 20 20 20 69 66 6e ATION);.# ifn
2cd0: 64 65 66 20 5f 57 49 4e 33 32 5f 57 43 45 0a 09 def _WIN32_WCE..
2ce0: 73 6e 70 72 69 6e 74 66 28 6d 73 67 42 75 66 2c snprintf(msgBuf,
2cf0: 20 73 69 7a 65 6f 66 28 6d 73 67 42 75 66 29 2c sizeof(msgBuf),
2d00: 0a 09 09 22 41 20 63 72 69 74 69 63 61 6c 20 65 ..."A critical e
2d10: 72 72 6f 72 20 68 61 73 20 6f 63 63 75 72 72 65 rror has occurre
2d20: 64 2e 20 20 50 6c 65 61 73 65 20 72 65 70 6f 72 d. Please repor
2d30: 74 20 74 68 69 73 20 74 6f 20 74 68 65 20 54 63 t this to the Tc
2d40: 6c 6b 69 74 20 76 65 6e 64 6f 72 2e 5c 6e 49 6e lkit vendor.\nIn
2d50: 74 65 72 70 72 65 74 65 72 20 52 65 74 75 72 6e terpreter Return
2d60: 65 64 3a 20 25 73 5c 6e 45 72 72 6f 72 20 49 6e ed: %s\nError In
2d70: 66 6f 3a 20 25 73 22 2c 0a 09 09 54 63 6c 5f 47 fo: %s",...Tcl_G
2d80: 65 74 53 74 72 69 6e 67 52 65 73 75 6c 74 28 69 etStringResult(i
2d90: 6e 74 65 72 70 29 2c 0a 09 09 54 63 6c 5f 47 65 nterp),...Tcl_Ge
2da0: 74 56 61 72 28 69 6e 74 65 72 70 2c 20 22 65 72 tVar(interp, "er
2db0: 72 6f 72 49 6e 66 6f 22 2c 20 54 43 4c 5f 47 4c rorInfo", TCL_GL
2dc0: 4f 42 41 4c 5f 4f 4e 4c 59 29 29 3b 0a 0a 09 4d OBAL_ONLY));...M
2dd0: 65 73 73 61 67 65 42 6f 78 28 4e 55 4c 4c 2c 20 essageBox(NULL,
2de0: 6d 73 67 42 75 66 2c 20 22 45 72 72 6f 72 20 69 msgBuf, "Error i
2df0: 6e 20 54 63 6c 4b 69 74 22 2c 0a 09 09 4d 42 5f n TclKit",...MB_
2e00: 49 43 4f 4e 53 54 4f 50 20 7c 20 4d 42 5f 4f 4b ICONSTOP | MB_OK
2e10: 20 7c 20 4d 42 5f 54 41 53 4b 4d 4f 44 41 4c 20 | MB_TASKMODAL
2e20: 7c 20 4d 42 5f 53 45 54 46 4f 52 45 47 52 4f 55 | MB_SETFOREGROU
2e30: 4e 44 29 3b 0a 0a 09 45 78 69 74 50 72 6f 63 65 ND);...ExitProce
2e40: 73 73 28 31 29 3b 0a 23 20 20 20 20 65 6e 64 69 ss(1);.# endi
2e50: 66 20 2f 2a 20 21 5f 57 49 4e 33 32 5f 57 43 45 f /* !_WIN32_WCE
2e60: 20 2a 2f 0a 20 20 20 20 2f 2a 20 77 65 20 77 6f */. /* we wo
2e70: 6e 27 74 20 72 65 61 63 68 20 74 68 69 73 2c 20 n't reach this,
2e80: 62 75 74 20 77 65 20 6e 65 65 64 20 74 68 65 20 but we need the
2e90: 72 65 74 75 72 6e 20 2a 2f 0a 23 20 20 65 6e 64 return */.# end
2ea0: 69 66 20 2f 2a 20 5f 57 49 4e 33 32 20 2a 2f 0a if /* _WIN32 */.
2eb0: 23 65 6e 64 69 66 20 2f 2a 20 4b 49 54 5f 49 4e #endif /* KIT_IN
2ec0: 43 4c 55 44 45 53 5f 54 4b 20 2a 2f 0a 0a 09 72 CLUDES_TK */...r
2ed0: 65 74 75 72 6e 20 54 43 4c 5f 45 52 52 4f 52 3b eturn TCL_ERROR;
2ee0: 0a 7d 0a 0a 0a 23 69 66 64 65 66 20 54 43 4c 4b .}...#ifdef TCLK
2ef0: 49 54 5f 44 4c 4c 0a 23 20 20 69 66 64 65 66 20 IT_DLL.# ifdef
2f00: 48 41 56 45 5f 41 43 43 45 50 54 41 42 4c 45 5f HAVE_ACCEPTABLE_
2f10: 44 4c 41 44 44 52 0a 2f 2a 20 53 79 6d 62 6f 6c DLADDR./* Symbol
2f20: 20 74 6f 20 72 65 73 6f 6c 76 65 20 61 67 61 69 to resolve agai
2f30: 6e 73 74 20 64 6c 61 64 64 72 28 29 20 2a 2f 0a nst dladdr() */.
2f40: 73 74 61 74 69 63 20 76 6f 69 64 20 5f 74 63 6c static void _tcl
2f50: 6b 69 74 5f 64 75 6d 6d 79 5f 66 75 6e 63 28 76 kit_dummy_func(v
2f60: 6f 69 64 29 20 7b 0a 09 72 65 74 75 72 6e 3b 0a oid) {..return;.
2f70: 7d 0a 23 20 20 65 6e 64 69 66 20 2f 2a 20 48 41 }.# endif /* HA
2f80: 56 45 5f 41 43 43 45 50 54 41 42 4c 45 5f 44 4c VE_ACCEPTABLE_DL
2f90: 41 44 44 52 20 2a 2f 0a 0a 2f 2a 0a 20 2a 20 54 ADDR */../*. * T
2fa0: 68 69 73 20 66 75 6e 63 74 69 6f 6e 20 77 69 6c his function wil
2fb0: 6c 20 72 65 74 75 72 6e 20 61 20 70 61 74 68 6e l return a pathn
2fc0: 61 6d 65 20 77 65 20 63 61 6e 20 6f 70 65 6e 28 ame we can open(
2fd0: 29 20 74 6f 20 74 72 65 61 74 20 61 73 20 61 20 ) to treat as a
2fe0: 56 46 53 2c 0a 20 2a 20 68 6f 70 65 66 75 6c 6c VFS,. * hopefull
2ff0: 79 0a 20 2a 2f 0a 73 74 61 74 69 63 20 63 68 61 y. */.static cha
3000: 72 20 2a 66 69 6e 64 5f 74 63 6c 6b 69 74 5f 64 r *find_tclkit_d
3010: 6c 6c 5f 70 61 74 68 28 76 6f 69 64 29 20 7b 0a ll_path(void) {.
3020: 23 69 66 64 65 66 20 48 41 56 45 5f 41 43 43 45 #ifdef HAVE_ACCE
3030: 50 54 41 42 4c 45 5f 44 4c 41 44 44 52 0a 09 44 PTABLE_DLADDR..D
3040: 6c 5f 69 6e 66 6f 20 73 79 6d 69 6e 66 6f 3b 0a l_info syminfo;.
3050: 09 69 6e 74 20 64 6c 61 64 64 72 5f 72 65 74 3b .int dladdr_ret;
3060: 0a 23 65 6e 64 69 66 20 2f 2a 20 48 41 56 45 5f .#endif /* HAVE_
3070: 41 43 43 45 50 54 41 42 4c 45 5f 44 4c 41 44 44 ACCEPTABLE_DLADD
3080: 52 20 2a 2f 0a 23 69 66 64 65 66 20 5f 57 49 4e R */.#ifdef _WIN
3090: 33 32 0a 09 54 43 48 41 52 20 6d 6f 64 75 6c 65 32..TCHAR module
30a0: 6e 61 6d 65 5b 38 31 39 32 5d 3b 0a 09 44 57 4f name[8192];..DWO
30b0: 52 44 20 67 6d 66 6e 5f 72 65 74 3b 0a 23 65 6e RD gmfn_ret;.#en
30c0: 64 69 66 20 2f 2a 20 5f 57 49 4e 33 32 20 2a 2f dif /* _WIN32 */
30d0: 0a 0a 23 69 66 64 65 66 20 48 41 56 45 5f 41 43 ..#ifdef HAVE_AC
30e0: 43 45 50 54 41 42 4c 45 5f 44 4c 41 44 44 52 0a CEPTABLE_DLADDR.
30f0: 09 64 6c 61 64 64 72 5f 72 65 74 20 3d 20 64 6c .dladdr_ret = dl
3100: 61 64 64 72 28 26 5f 74 63 6c 6b 69 74 5f 64 75 addr(&_tclkit_du
3110: 6d 6d 79 5f 66 75 6e 63 2c 20 26 73 79 6d 69 6e mmy_func, &symin
3120: 66 6f 29 3b 0a 09 69 66 20 28 64 6c 61 64 64 72 fo);..if (dladdr
3130: 5f 72 65 74 20 21 3d 20 30 29 20 7b 0a 09 09 69 _ret != 0) {...i
3140: 66 20 28 73 79 6d 69 6e 66 6f 2e 64 6c 69 5f 66 f (syminfo.dli_f
3150: 6e 61 6d 65 20 26 26 20 73 79 6d 69 6e 66 6f 2e name && syminfo.
3160: 64 6c 69 5f 66 6e 61 6d 65 5b 30 5d 20 21 3d 20 dli_fname[0] !=
3170: 27 5c 30 27 29 20 7b 0a 09 09 09 72 65 74 75 72 '\0') {....retur
3180: 6e 28 73 74 72 64 75 70 28 73 79 6d 69 6e 66 6f n(strdup(syminfo
3190: 2e 64 6c 69 5f 66 6e 61 6d 65 29 29 3b 0a 09 09 .dli_fname));...
31a0: 7d 0a 09 7d 0a 23 65 6e 64 69 66 20 2f 2a 20 48 }..}.#endif /* H
31b0: 41 56 45 5f 41 43 43 45 50 54 41 42 4c 45 5f 44 AVE_ACCEPTABLE_D
31c0: 4c 41 44 44 52 20 2a 2f 0a 0a 23 69 66 64 65 66 LADDR */..#ifdef
31d0: 20 5f 57 49 4e 33 32 0a 09 67 6d 66 6e 5f 72 65 _WIN32..gmfn_re
31e0: 74 20 3d 20 47 65 74 4d 6f 64 75 6c 65 46 69 6c t = GetModuleFil
31f0: 65 4e 61 6d 65 28 54 63 6c 57 69 6e 47 65 74 54 eName(TclWinGetT
3200: 63 6c 49 6e 73 74 61 6e 63 65 28 29 2c 20 6d 6f clInstance(), mo
3210: 64 75 6c 65 6e 61 6d 65 2c 20 73 69 7a 65 6f 66 dulename, sizeof
3220: 28 6d 6f 64 75 6c 65 6e 61 6d 65 29 20 2f 20 73 (modulename) / s
3230: 69 7a 65 6f 66 28 6d 6f 64 75 6c 65 6e 61 6d 65 izeof(modulename
3240: 5b 30 5d 29 20 2d 20 31 29 3b 0a 0a 09 69 66 20 [0]) - 1);...if
3250: 28 67 6d 66 6e 5f 72 65 74 20 21 3d 20 30 29 20 (gmfn_ret != 0)
3260: 7b 0a 09 09 72 65 74 75 72 6e 28 73 74 72 64 75 {...return(strdu
3270: 70 28 6d 6f 64 75 6c 65 6e 61 6d 65 29 29 3b 0a p(modulename));.
3280: 09 7d 0a 23 65 6e 64 69 66 20 2f 2a 20 5f 57 49 .}.#endif /* _WI
3290: 4e 33 32 20 2a 2f 0a 0a 09 72 65 74 75 72 6e 28 N32 */...return(
32a0: 4e 55 4c 4c 29 3b 0a 7d 0a 0a 2f 2a 0a 20 2a 20 NULL);.}../*. *
32b0: 54 68 69 73 20 66 75 6e 63 74 69 6f 6e 20 65 78 This function ex
32c0: 69 73 74 73 20 74 6f 20 61 6c 6c 6f 77 20 43 20 ists to allow C
32d0: 63 6f 64 65 20 74 6f 20 69 6e 69 74 69 61 6c 69 code to initiali
32e0: 7a 65 20 61 20 70 61 72 74 69 63 75 6c 61 72 0a ze a particular.
32f0: 20 2a 20 69 6e 74 65 72 70 72 65 74 65 72 2e 0a * interpreter..
3300: 20 2a 2f 0a 73 74 61 74 69 63 20 69 6e 74 20 74 */.static int t
3310: 63 6c 6b 69 74 5f 69 6e 69 74 5f 69 6e 69 74 69 clkit_init_initi
3320: 6e 74 65 72 70 28 43 6c 69 65 6e 74 44 61 74 61 nterp(ClientData
3330: 20 63 64 2c 20 54 63 6c 5f 49 6e 74 65 72 70 20 cd, Tcl_Interp
3340: 2a 69 6e 74 65 72 70 2c 20 69 6e 74 20 6f 62 6a *interp, int obj
3350: 63 2c 20 54 63 6c 5f 4f 62 6a 20 2a 43 4f 4e 53 c, Tcl_Obj *CONS
3360: 54 20 6f 62 6a 76 5b 5d 29 20 7b 0a 09 63 68 61 T objv[]) {..cha
3370: 72 20 2a 6b 69 74 64 6c 6c 5f 70 61 74 68 3b 0a r *kitdll_path;.
3380: 0a 09 6b 69 74 64 6c 6c 5f 70 61 74 68 20 3d 20 ..kitdll_path =
3390: 66 69 6e 64 5f 74 63 6c 6b 69 74 5f 64 6c 6c 5f find_tclkit_dll_
33a0: 70 61 74 68 28 29 3b 0a 09 69 66 20 28 6b 69 74 path();..if (kit
33b0: 64 6c 6c 5f 70 61 74 68 20 21 3d 20 4e 55 4c 4c dll_path != NULL
33c0: 29 20 7b 0a 09 09 54 63 6c 5f 53 65 74 56 61 72 ) {...Tcl_SetVar
33d0: 28 69 6e 74 65 72 70 2c 20 22 74 63 6c 4b 69 74 (interp, "tclKit
33e0: 46 69 6c 65 6e 61 6d 65 22 2c 20 6b 69 74 64 6c Filename", kitdl
33f0: 6c 5f 70 61 74 68 2c 20 54 43 4c 5f 47 4c 4f 42 l_path, TCL_GLOB
3400: 41 4c 5f 4f 4e 4c 59 29 3b 0a 0a 09 09 66 72 65 AL_ONLY);....fre
3410: 65 28 6b 69 74 64 6c 6c 5f 70 61 74 68 29 3b 0a e(kitdll_path);.
3420: 09 7d 0a 0a 09 5f 54 63 6c 6b 69 74 5f 49 6e 74 .}..._Tclkit_Int
3430: 65 72 70 5f 49 6e 69 74 28 69 6e 74 65 72 70 29 erp_Init(interp)
3440: 3b 0a 0a 09 72 65 74 75 72 6e 28 54 43 4c 5f 4f ;...return(TCL_O
3450: 4b 29 3b 0a 7d 0a 0a 2f 2a 0a 20 2a 20 43 72 65 K);.}../*. * Cre
3460: 61 74 65 20 61 20 70 61 63 6b 61 67 65 20 66 6f ate a package fo
3470: 72 20 69 6e 69 74 69 61 6c 69 7a 69 6e 67 20 61 r initializing a
3480: 20 70 61 72 74 69 63 75 6c 61 72 20 69 6e 74 65 particular inte
3490: 72 70 72 65 74 65 72 2e 20 20 54 68 69 73 20 69 rpreter. This i
34a0: 73 0a 20 2a 20 6f 75 72 20 68 6f 6f 6b 20 74 6f s. * our hook to
34b0: 20 68 61 76 65 20 54 63 6c 20 69 6e 76 6f 6b 65 have Tcl invoke
34c0: 20 43 20 63 6f 6d 6d 61 6e 64 73 20 77 68 65 6e C commands when
34d0: 20 63 72 65 61 74 69 6e 67 20 61 6e 20 69 6e 74 creating an int
34e0: 65 72 70 72 65 74 65 72 2e 0a 20 2a 20 54 68 65 erpreter.. * The
34f0: 20 70 72 65 49 6e 69 74 43 6d 64 20 77 69 6c 6c preInitCmd will
3500: 20 6c 6f 61 64 20 74 68 65 20 70 61 63 6b 61 67 load the packag
3510: 65 20 69 6e 20 74 68 65 20 6e 65 77 20 69 6e 74 e in the new int
3520: 65 72 70 72 65 74 65 72 20 61 6e 64 20 69 6e 76 erpreter and inv
3530: 6f 6b 65 0a 20 2a 20 74 68 69 73 20 66 75 6e 63 oke. * this func
3540: 74 69 6f 6e 2e 0a 20 2a 2f 0a 69 6e 74 20 54 63 tion.. */.int Tc
3550: 6c 6b 69 74 5f 69 6e 69 74 5f 49 6e 69 74 28 54 lkit_init_Init(T
3560: 63 6c 5f 49 6e 74 65 72 70 20 2a 69 6e 74 65 72 cl_Interp *inter
3570: 70 29 20 7b 0a 09 54 63 6c 5f 43 6f 6d 6d 61 6e p) {..Tcl_Comman
3580: 64 20 74 63 6c 43 72 65 61 74 43 6f 6d 6d 5f 72 d tclCreatComm_r
3590: 65 74 3b 0a 09 69 6e 74 20 74 63 6c 50 6b 67 50 et;..int tclPkgP
35a0: 72 6f 76 5f 72 65 74 3b 0a 0a 09 74 63 6c 43 72 rov_ret;...tclCr
35b0: 65 61 74 43 6f 6d 6d 5f 72 65 74 20 3d 20 54 63 eatComm_ret = Tc
35c0: 6c 5f 43 72 65 61 74 65 4f 62 6a 43 6f 6d 6d 61 l_CreateObjComma
35d0: 6e 64 28 69 6e 74 65 72 70 2c 20 22 3a 3a 74 63 nd(interp, "::tc
35e0: 6c 6b 69 74 3a 3a 69 6e 69 74 3a 3a 69 6e 69 74 lkit::init::init
35f0: 49 6e 74 65 72 70 22 2c 20 74 63 6c 6b 69 74 5f Interp", tclkit_
3600: 69 6e 69 74 5f 69 6e 69 74 69 6e 74 65 72 70 2c init_initinterp,
3610: 20 4e 55 4c 4c 2c 20 4e 55 4c 4c 29 3b 0a 09 69 NULL, NULL);..i
3620: 66 20 28 21 74 63 6c 43 72 65 61 74 43 6f 6d 6d f (!tclCreatComm
3630: 5f 72 65 74 29 20 7b 0a 09 09 72 65 74 75 72 6e _ret) {...return
3640: 28 54 43 4c 5f 45 52 52 4f 52 29 3b 0a 09 7d 0a (TCL_ERROR);..}.
3650: 0a 09 74 63 6c 50 6b 67 50 72 6f 76 5f 72 65 74 ..tclPkgProv_ret
3660: 20 3d 20 54 63 6c 5f 50 6b 67 50 72 6f 76 69 64 = Tcl_PkgProvid
3670: 65 28 69 6e 74 65 72 70 2c 20 22 74 63 6c 6b 69 e(interp, "tclki
3680: 74 3a 3a 69 6e 69 74 22 2c 20 22 31 2e 30 22 29 t::init", "1.0")
3690: 3b 0a 0a 09 72 65 74 75 72 6e 28 74 63 6c 50 6b ;...return(tclPk
36a0: 67 50 72 6f 76 5f 72 65 74 29 3b 0a 7d 0a 0a 2f gProv_ret);.}../
36b0: 2a 0a 20 2a 20 49 6e 69 74 69 61 6c 69 7a 65 20 *. * Initialize
36c0: 74 68 65 20 54 63 6c 20 73 79 73 74 65 6d 20 77 the Tcl system w
36d0: 68 65 6e 20 77 65 20 61 72 65 20 6c 6f 61 64 65 hen we are loade
36e0: 64 2c 20 74 68 61 74 20 77 61 79 20 54 63 6c 20 d, that way Tcl
36f0: 66 75 6e 63 74 69 6f 6e 73 0a 20 2a 20 61 72 65 functions. * are
3700: 20 72 65 61 64 79 20 74 6f 20 62 65 20 75 73 65 ready to be use
3710: 64 20 77 68 65 6e 20 69 6e 76 6f 6b 65 64 2e 0a d when invoked..
3720: 20 2a 2f 0a 76 6f 69 64 20 5f 5f 61 74 74 72 69 */.void __attri
3730: 62 75 74 65 5f 5f 28 28 63 6f 6e 73 74 72 75 63 bute__((construc
3740: 74 6f 72 29 29 20 5f 54 63 6c 6b 69 74 5f 49 6e tor)) _Tclkit_In
3750: 69 74 28 76 6f 69 64 29 20 7b 0a 09 54 63 6c 5f it(void) {..Tcl_
3760: 53 74 61 74 69 63 50 61 63 6b 61 67 65 28 30 2c StaticPackage(0,
3770: 20 22 74 63 6c 6b 69 74 3a 3a 69 6e 69 74 22 2c "tclkit::init",
3780: 20 54 63 6c 6b 69 74 5f 69 6e 69 74 5f 49 6e 69 Tclkit_init_Ini
3790: 74 2c 20 4e 55 4c 4c 29 3b 0a 0a 09 5f 54 63 6c t, NULL);..._Tcl
37a0: 6b 69 74 5f 47 65 6e 65 72 69 63 5f 49 6e 69 74 kit_Generic_Init
37b0: 28 29 3b 0a 0a 09 72 65 74 75 72 6e 3b 0a 7d 0a ();...return;.}.
37c0: 23 65 6e 64 69 66 0a #endif.