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