annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/lib/tcl8.6/tclAppInit.c @ 69:33d812a61356

planemo upload commit 2e9511a184a1ca667c7be0c6321a36dc4e3d116d
author jpayne
date Tue, 18 Mar 2025 17:55:14 -0400
parents
children
rev   line source
jpayne@69 1 /*
jpayne@69 2 * tclAppInit.c --
jpayne@69 3 *
jpayne@69 4 * Provides a default version of the main program and Tcl_AppInit
jpayne@69 5 * procedure for tclsh and other Tcl-based applications (without Tk).
jpayne@69 6 *
jpayne@69 7 * Copyright (c) 1993 The Regents of the University of California.
jpayne@69 8 * Copyright (c) 1994-1997 Sun Microsystems, Inc.
jpayne@69 9 * Copyright (c) 1998-1999 Scriptics Corporation.
jpayne@69 10 *
jpayne@69 11 * See the file "license.terms" for information on usage and redistribution of
jpayne@69 12 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
jpayne@69 13 */
jpayne@69 14
jpayne@69 15 #undef BUILD_tcl
jpayne@69 16 #undef STATIC_BUILD
jpayne@69 17 #include "tcl.h"
jpayne@69 18 #if TCL_MAJOR_VERSION < 9 && TCL_MINOR_VERSION < 7
jpayne@69 19 # define Tcl_LibraryInitProc Tcl_PackageInitProc
jpayne@69 20 # define Tcl_StaticLibrary Tcl_StaticPackage
jpayne@69 21 #endif
jpayne@69 22
jpayne@69 23 #ifdef TCL_TEST
jpayne@69 24 extern Tcl_LibraryInitProc Tcltest_Init;
jpayne@69 25 extern Tcl_LibraryInitProc Tcltest_SafeInit;
jpayne@69 26 #endif /* TCL_TEST */
jpayne@69 27
jpayne@69 28 #ifdef TCL_XT_TEST
jpayne@69 29 extern void XtToolkitInitialize(void);
jpayne@69 30 extern Tcl_LibraryInitProc Tclxttest_Init;
jpayne@69 31 #endif /* TCL_XT_TEST */
jpayne@69 32
jpayne@69 33 /*
jpayne@69 34 * The following #if block allows you to change the AppInit function by using
jpayne@69 35 * a #define of TCL_LOCAL_APPINIT instead of rewriting this entire file. The
jpayne@69 36 * #if checks for that #define and uses Tcl_AppInit if it does not exist.
jpayne@69 37 */
jpayne@69 38
jpayne@69 39 #ifndef TCL_LOCAL_APPINIT
jpayne@69 40 #define TCL_LOCAL_APPINIT Tcl_AppInit
jpayne@69 41 #endif
jpayne@69 42 #ifndef MODULE_SCOPE
jpayne@69 43 # define MODULE_SCOPE extern
jpayne@69 44 #endif
jpayne@69 45 MODULE_SCOPE int TCL_LOCAL_APPINIT(Tcl_Interp *);
jpayne@69 46 MODULE_SCOPE int main(int, char **);
jpayne@69 47
jpayne@69 48 /*
jpayne@69 49 * The following #if block allows you to change how Tcl finds the startup
jpayne@69 50 * script, prime the library or encoding paths, fiddle with the argv, etc.,
jpayne@69 51 * without needing to rewrite Tcl_Main()
jpayne@69 52 */
jpayne@69 53
jpayne@69 54 #ifdef TCL_LOCAL_MAIN_HOOK
jpayne@69 55 MODULE_SCOPE int TCL_LOCAL_MAIN_HOOK(int *argc, char ***argv);
jpayne@69 56 #endif
jpayne@69 57
jpayne@69 58 /*
jpayne@69 59 *----------------------------------------------------------------------
jpayne@69 60 *
jpayne@69 61 * main --
jpayne@69 62 *
jpayne@69 63 * This is the main program for the application.
jpayne@69 64 *
jpayne@69 65 * Results:
jpayne@69 66 * None: Tcl_Main never returns here, so this procedure never returns
jpayne@69 67 * either.
jpayne@69 68 *
jpayne@69 69 * Side effects:
jpayne@69 70 * Just about anything, since from here we call arbitrary Tcl code.
jpayne@69 71 *
jpayne@69 72 *----------------------------------------------------------------------
jpayne@69 73 */
jpayne@69 74
jpayne@69 75 int
jpayne@69 76 main(
jpayne@69 77 int argc, /* Number of command-line arguments. */
jpayne@69 78 char *argv[]) /* Values of command-line arguments. */
jpayne@69 79 {
jpayne@69 80 #ifdef TCL_XT_TEST
jpayne@69 81 XtToolkitInitialize();
jpayne@69 82 #endif
jpayne@69 83
jpayne@69 84 #ifdef TCL_LOCAL_MAIN_HOOK
jpayne@69 85 TCL_LOCAL_MAIN_HOOK(&argc, &argv);
jpayne@69 86 #elif (TCL_MAJOR_VERSION > 8 || TCL_MINOR_VERSION > 6) && (!defined(_WIN32) || defined(UNICODE))
jpayne@69 87 /* New in Tcl 8.7. This doesn't work on Windows without UNICODE */
jpayne@69 88 TclZipfs_AppHook(&argc, &argv);
jpayne@69 89 #endif
jpayne@69 90
jpayne@69 91 Tcl_Main(argc, argv, TCL_LOCAL_APPINIT);
jpayne@69 92 return 0; /* Needed only to prevent compiler warning. */
jpayne@69 93 }
jpayne@69 94
jpayne@69 95 /*
jpayne@69 96 *----------------------------------------------------------------------
jpayne@69 97 *
jpayne@69 98 * Tcl_AppInit --
jpayne@69 99 *
jpayne@69 100 * This procedure performs application-specific initialization. Most
jpayne@69 101 * applications, especially those that incorporate additional packages,
jpayne@69 102 * will have their own version of this procedure.
jpayne@69 103 *
jpayne@69 104 * Results:
jpayne@69 105 * Returns a standard Tcl completion code, and leaves an error message in
jpayne@69 106 * the interp's result if an error occurs.
jpayne@69 107 *
jpayne@69 108 * Side effects:
jpayne@69 109 * Depends on the startup script.
jpayne@69 110 *
jpayne@69 111 *----------------------------------------------------------------------
jpayne@69 112 */
jpayne@69 113
jpayne@69 114 int
jpayne@69 115 Tcl_AppInit(
jpayne@69 116 Tcl_Interp *interp) /* Interpreter for application. */
jpayne@69 117 {
jpayne@69 118 if ((Tcl_Init)(interp) == TCL_ERROR) {
jpayne@69 119 return TCL_ERROR;
jpayne@69 120 }
jpayne@69 121
jpayne@69 122 #ifdef TCL_XT_TEST
jpayne@69 123 if (Tclxttest_Init(interp) == TCL_ERROR) {
jpayne@69 124 return TCL_ERROR;
jpayne@69 125 }
jpayne@69 126 #endif
jpayne@69 127
jpayne@69 128 #ifdef TCL_TEST
jpayne@69 129 if (Tcltest_Init(interp) == TCL_ERROR) {
jpayne@69 130 return TCL_ERROR;
jpayne@69 131 }
jpayne@69 132 Tcl_StaticLibrary(interp, "Tcltest", Tcltest_Init, Tcltest_SafeInit);
jpayne@69 133 #endif /* TCL_TEST */
jpayne@69 134
jpayne@69 135 /*
jpayne@69 136 * Call the init procedures for included packages. Each call should look
jpayne@69 137 * like this:
jpayne@69 138 *
jpayne@69 139 * if (Mod_Init(interp) == TCL_ERROR) {
jpayne@69 140 * return TCL_ERROR;
jpayne@69 141 * }
jpayne@69 142 *
jpayne@69 143 * where "Mod" is the name of the module. (Dynamically-loadable packages
jpayne@69 144 * should have the same entry-point name.)
jpayne@69 145 */
jpayne@69 146
jpayne@69 147 /*
jpayne@69 148 * Call Tcl_CreateCommand for application-specific commands, if they
jpayne@69 149 * weren't already created by the init procedures called above.
jpayne@69 150 */
jpayne@69 151
jpayne@69 152 /*
jpayne@69 153 * Specify a user-specific startup file to invoke if the application is
jpayne@69 154 * run interactively. Typically the startup file is "~/.apprc" where "app"
jpayne@69 155 * is the name of the application. If this line is deleted then no
jpayne@69 156 * user-specific startup file will be run under any conditions.
jpayne@69 157 */
jpayne@69 158
jpayne@69 159 #ifdef DJGPP
jpayne@69 160 (Tcl_ObjSetVar2)(interp, Tcl_NewStringObj("tcl_rcFileName", -1), NULL,
jpayne@69 161 Tcl_NewStringObj("~/tclsh.rc", -1), TCL_GLOBAL_ONLY);
jpayne@69 162 #else
jpayne@69 163 (Tcl_ObjSetVar2)(interp, Tcl_NewStringObj("tcl_rcFileName", -1), NULL,
jpayne@69 164 Tcl_NewStringObj("~/.tclshrc", -1), TCL_GLOBAL_ONLY);
jpayne@69 165 #endif
jpayne@69 166
jpayne@69 167 return TCL_OK;
jpayne@69 168 }
jpayne@69 169
jpayne@69 170 /*
jpayne@69 171 * Local Variables:
jpayne@69 172 * mode: c
jpayne@69 173 * c-basic-offset: 4
jpayne@69 174 * fill-column: 78
jpayne@69 175 * End:
jpayne@69 176 */