4 * Provides a default version of the main program and Tcl_AppInit
5 * procedure for Tcl applications (without Tk).
7 * Copyright (c) 1993 The Regents of the University of California.
8 * Copyright (c) 1994-1997 Sun Microsystems, Inc.
9 * Copyright (c) 1998-1999 by Scriptics Corporation.
11 * See the file "license.terms" for information on usage and redistribution
12 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
20 * The following variable is a special hack that is needed in order for
21 * Sun shared libraries to be used for Tcl.
25 int *tclDummyMathPtr = (int *) matherr;
32 extern int Procbodytest_Init _ANSI_ARGS_((Tcl_Interp *interp));
33 extern int Procbodytest_SafeInit _ANSI_ARGS_((Tcl_Interp *interp));
34 extern int TclObjTest_Init _ANSI_ARGS_((Tcl_Interp *interp));
35 extern int Tcltest_Init _ANSI_ARGS_((Tcl_Interp *interp));
37 extern int TclThread_Init _ANSI_ARGS_((Tcl_Interp *interp));
43 extern void XtToolkitInitialize _ANSI_ARGS_((void));
44 extern int Tclxttest_Init _ANSI_ARGS_((Tcl_Interp *interp));
48 *----------------------------------------------------------------------
52 * This is the main program for the application.
55 * None: Tcl_Main never returns here, so this procedure never
59 * Whatever the application does.
61 *----------------------------------------------------------------------
66 int argc; /* Number of command-line arguments. */
67 char **argv; /* Values of command-line arguments. */
70 * The following #if block allows you to change the AppInit
71 * function by using a #define of TCL_LOCAL_APPINIT instead
72 * of rewriting this entire file. The #if checks for that
73 * #define and uses Tcl_AppInit if it doesn't exist.
76 #ifndef TCL_LOCAL_APPINIT
77 #define TCL_LOCAL_APPINIT Tcl_AppInit
79 extern int TCL_LOCAL_APPINIT _ANSI_ARGS_((Tcl_Interp *interp));
82 * The following #if block allows you to change how Tcl finds the startup
83 * script, prime the library or encoding paths, fiddle with the argv,
84 * etc., without needing to rewrite Tcl_Main()
87 #ifdef TCL_LOCAL_MAIN_HOOK
88 extern int TCL_LOCAL_MAIN_HOOK _ANSI_ARGS_((int *argc, char ***argv));
92 XtToolkitInitialize();
95 #ifdef TCL_LOCAL_MAIN_HOOK
96 TCL_LOCAL_MAIN_HOOK(&argc, &argv);
99 Tcl_Main(argc, argv, TCL_LOCAL_APPINIT);
101 return 0; /* Needed only to prevent compiler warning. */
105 *----------------------------------------------------------------------
109 * This procedure performs application-specific initialization.
110 * Most applications, especially those that incorporate additional
111 * packages, will have their own version of this procedure.
114 * Returns a standard Tcl completion code, and leaves an error
115 * message in the interp's result if an error occurs.
118 * Depends on the startup script.
120 *----------------------------------------------------------------------
125 Tcl_Interp *interp; /* Interpreter for application. */
127 if (Tcl_Init(interp) == TCL_ERROR) {
133 if (Tclxttest_Init(interp) == TCL_ERROR) {
137 if (Tcltest_Init(interp) == TCL_ERROR) {
140 Tcl_StaticPackage(interp, "Tcltest", Tcltest_Init,
141 (Tcl_PackageInitProc *) NULL);
142 if (TclObjTest_Init(interp) == TCL_ERROR) {
146 if (TclThread_Init(interp) == TCL_ERROR) {
150 if (Procbodytest_Init(interp) == TCL_ERROR) {
153 Tcl_StaticPackage(interp, "procbodytest", Procbodytest_Init,
154 Procbodytest_SafeInit);
155 #endif /* TCL_TEST */
158 * Call the init procedures for included packages. Each call should
161 * if (Mod_Init(interp) == TCL_ERROR) {
165 * where "Mod" is the name of the module.
169 * Call Tcl_CreateCommand for application-specific commands, if
170 * they weren't already created by the init procedures called above.
174 * Specify a user-specific startup file to invoke if the application
175 * is run interactively. Typically the startup file is "~/.apprc"
176 * where "app" is the name of the application. If this line is deleted
177 * then no user-specific startup file will be run under any conditions.
180 Tcl_SetVar(interp, "tcl_rcFileName", "~/.tclshrc", TCL_GLOBAL_ONLY);