jpayne@69: /* jpayne@69: * tclAppInit.c -- jpayne@69: * jpayne@69: * Provides a default version of the main program and Tcl_AppInit jpayne@69: * procedure for tclsh and other Tcl-based applications (without Tk). jpayne@69: * jpayne@69: * Copyright (c) 1993 The Regents of the University of California. jpayne@69: * Copyright (c) 1994-1997 Sun Microsystems, Inc. jpayne@69: * Copyright (c) 1998-1999 Scriptics Corporation. jpayne@69: * jpayne@69: * See the file "license.terms" for information on usage and redistribution of jpayne@69: * this file, and for a DISCLAIMER OF ALL WARRANTIES. jpayne@69: */ jpayne@69: jpayne@69: #undef BUILD_tcl jpayne@69: #undef STATIC_BUILD jpayne@69: #include "tcl.h" jpayne@69: #if TCL_MAJOR_VERSION < 9 && TCL_MINOR_VERSION < 7 jpayne@69: # define Tcl_LibraryInitProc Tcl_PackageInitProc jpayne@69: # define Tcl_StaticLibrary Tcl_StaticPackage jpayne@69: #endif jpayne@69: jpayne@69: #ifdef TCL_TEST jpayne@69: extern Tcl_LibraryInitProc Tcltest_Init; jpayne@69: extern Tcl_LibraryInitProc Tcltest_SafeInit; jpayne@69: #endif /* TCL_TEST */ jpayne@69: jpayne@69: #ifdef TCL_XT_TEST jpayne@69: extern void XtToolkitInitialize(void); jpayne@69: extern Tcl_LibraryInitProc Tclxttest_Init; jpayne@69: #endif /* TCL_XT_TEST */ jpayne@69: jpayne@69: /* jpayne@69: * The following #if block allows you to change the AppInit function by using jpayne@69: * a #define of TCL_LOCAL_APPINIT instead of rewriting this entire file. The jpayne@69: * #if checks for that #define and uses Tcl_AppInit if it does not exist. jpayne@69: */ jpayne@69: jpayne@69: #ifndef TCL_LOCAL_APPINIT jpayne@69: #define TCL_LOCAL_APPINIT Tcl_AppInit jpayne@69: #endif jpayne@69: #ifndef MODULE_SCOPE jpayne@69: # define MODULE_SCOPE extern jpayne@69: #endif jpayne@69: MODULE_SCOPE int TCL_LOCAL_APPINIT(Tcl_Interp *); jpayne@69: MODULE_SCOPE int main(int, char **); jpayne@69: jpayne@69: /* jpayne@69: * The following #if block allows you to change how Tcl finds the startup jpayne@69: * script, prime the library or encoding paths, fiddle with the argv, etc., jpayne@69: * without needing to rewrite Tcl_Main() jpayne@69: */ jpayne@69: jpayne@69: #ifdef TCL_LOCAL_MAIN_HOOK jpayne@69: MODULE_SCOPE int TCL_LOCAL_MAIN_HOOK(int *argc, char ***argv); jpayne@69: #endif jpayne@69: jpayne@69: /* jpayne@69: *---------------------------------------------------------------------- jpayne@69: * jpayne@69: * main -- jpayne@69: * jpayne@69: * This is the main program for the application. jpayne@69: * jpayne@69: * Results: jpayne@69: * None: Tcl_Main never returns here, so this procedure never returns jpayne@69: * either. jpayne@69: * jpayne@69: * Side effects: jpayne@69: * Just about anything, since from here we call arbitrary Tcl code. jpayne@69: * jpayne@69: *---------------------------------------------------------------------- jpayne@69: */ jpayne@69: jpayne@69: int jpayne@69: main( jpayne@69: int argc, /* Number of command-line arguments. */ jpayne@69: char *argv[]) /* Values of command-line arguments. */ jpayne@69: { jpayne@69: #ifdef TCL_XT_TEST jpayne@69: XtToolkitInitialize(); jpayne@69: #endif jpayne@69: jpayne@69: #ifdef TCL_LOCAL_MAIN_HOOK jpayne@69: TCL_LOCAL_MAIN_HOOK(&argc, &argv); jpayne@69: #elif (TCL_MAJOR_VERSION > 8 || TCL_MINOR_VERSION > 6) && (!defined(_WIN32) || defined(UNICODE)) jpayne@69: /* New in Tcl 8.7. This doesn't work on Windows without UNICODE */ jpayne@69: TclZipfs_AppHook(&argc, &argv); jpayne@69: #endif jpayne@69: jpayne@69: Tcl_Main(argc, argv, TCL_LOCAL_APPINIT); jpayne@69: return 0; /* Needed only to prevent compiler warning. */ jpayne@69: } jpayne@69: jpayne@69: /* jpayne@69: *---------------------------------------------------------------------- jpayne@69: * jpayne@69: * Tcl_AppInit -- jpayne@69: * jpayne@69: * This procedure performs application-specific initialization. Most jpayne@69: * applications, especially those that incorporate additional packages, jpayne@69: * will have their own version of this procedure. jpayne@69: * jpayne@69: * Results: jpayne@69: * Returns a standard Tcl completion code, and leaves an error message in jpayne@69: * the interp's result if an error occurs. jpayne@69: * jpayne@69: * Side effects: jpayne@69: * Depends on the startup script. jpayne@69: * jpayne@69: *---------------------------------------------------------------------- jpayne@69: */ jpayne@69: jpayne@69: int jpayne@69: Tcl_AppInit( jpayne@69: Tcl_Interp *interp) /* Interpreter for application. */ jpayne@69: { jpayne@69: if ((Tcl_Init)(interp) == TCL_ERROR) { jpayne@69: return TCL_ERROR; jpayne@69: } jpayne@69: jpayne@69: #ifdef TCL_XT_TEST jpayne@69: if (Tclxttest_Init(interp) == TCL_ERROR) { jpayne@69: return TCL_ERROR; jpayne@69: } jpayne@69: #endif jpayne@69: jpayne@69: #ifdef TCL_TEST jpayne@69: if (Tcltest_Init(interp) == TCL_ERROR) { jpayne@69: return TCL_ERROR; jpayne@69: } jpayne@69: Tcl_StaticLibrary(interp, "Tcltest", Tcltest_Init, Tcltest_SafeInit); jpayne@69: #endif /* TCL_TEST */ jpayne@69: jpayne@69: /* jpayne@69: * Call the init procedures for included packages. Each call should look jpayne@69: * like this: jpayne@69: * jpayne@69: * if (Mod_Init(interp) == TCL_ERROR) { jpayne@69: * return TCL_ERROR; jpayne@69: * } jpayne@69: * jpayne@69: * where "Mod" is the name of the module. (Dynamically-loadable packages jpayne@69: * should have the same entry-point name.) jpayne@69: */ jpayne@69: jpayne@69: /* jpayne@69: * Call Tcl_CreateCommand for application-specific commands, if they jpayne@69: * weren't already created by the init procedures called above. jpayne@69: */ jpayne@69: jpayne@69: /* jpayne@69: * Specify a user-specific startup file to invoke if the application is jpayne@69: * run interactively. Typically the startup file is "~/.apprc" where "app" jpayne@69: * is the name of the application. If this line is deleted then no jpayne@69: * user-specific startup file will be run under any conditions. jpayne@69: */ jpayne@69: jpayne@69: #ifdef DJGPP jpayne@69: (Tcl_ObjSetVar2)(interp, Tcl_NewStringObj("tcl_rcFileName", -1), NULL, jpayne@69: Tcl_NewStringObj("~/tclsh.rc", -1), TCL_GLOBAL_ONLY); jpayne@69: #else jpayne@69: (Tcl_ObjSetVar2)(interp, Tcl_NewStringObj("tcl_rcFileName", -1), NULL, jpayne@69: Tcl_NewStringObj("~/.tclshrc", -1), TCL_GLOBAL_ONLY); jpayne@69: #endif jpayne@69: jpayne@69: return TCL_OK; jpayne@69: } jpayne@69: jpayne@69: /* jpayne@69: * Local Variables: jpayne@69: * mode: c jpayne@69: * c-basic-offset: 4 jpayne@69: * fill-column: 78 jpayne@69: * End: jpayne@69: */