tkAppInit.cpp

Go to the documentation of this file.
00001 /* 
00002  * tkAppInit.c --
00003  *
00004  *      Provides a default version of the Tcl_AppInit procedure for
00005  *      use in wish and similar Tk-based applications.
00006  *
00007  * Copyright (c) 1993 The Regents of the University of California.
00008  * Copyright (c) 1994-1997 Sun Microsystems, Inc.
00009  *
00010  * See the file "license.terms" for information on usage and redistribution
00011  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
00012  *
00013  * RCS: @(#) $Id: tkAppInit.cpp,v 1.5 2006/09/26 21:29:35 fmk Exp $
00014  */
00015 
00016 extern "C" {
00017 #include "tk.h"
00018 #include "locale.h"
00019 }
00020 
00021 
00022 extern void
00023 Tk_MainOpenSees(int argc, char **argv, Tcl_AppInitProc *appInitProc, Tcl_Interp *interp);
00024 
00025 #include "commands.h"
00026 
00027 /*
00028  * The following variable is a special hack that is needed in order for
00029  * Sun shared libraries to be used for Tcl.
00030  */
00031 
00032 #ifdef _UNIX
00033 //extern "C" int matherr();
00034 //int *tclDummyMathPtr = (int *) matherr;
00035 #endif
00036 
00037 
00038 #ifdef TK_TEST
00039 extern "C" int          Tcltest_Init _ANSI_ARGS_((Tcl_Interp *interp));
00040 extern "C" int          Tktest_Init _ANSI_ARGS_((Tcl_Interp *interp));
00041 #endif /* TK_TEST */
00042 
00043 /*
00044  *----------------------------------------------------------------------
00045  *
00046  * main --
00047  *
00048  *      This is the main program for the application.
00049  *
00050  * Results:
00051  *      None: Tk_Main never returns here, so this procedure never
00052  *      returns either.
00053  *
00054  * Side effects:
00055  *      Whatever the application does.
00056  *
00057  *----------------------------------------------------------------------
00058  */
00059 
00060 int
00061 main(int argc, char **argv)
00062 {
00063     /*
00064      * The following #if block allows you to change the AppInit
00065      * function by using a #define of TCL_LOCAL_APPINIT instead
00066      * of rewriting this entire file.  The #if checks for that
00067      * #define and uses Tcl_AppInit if it doesn't exist.
00068      */
00069     
00070 #ifndef TK_LOCAL_APPINIT
00071 #define TK_LOCAL_APPINIT Tcl_AppInit    
00072 #endif
00073   /*
00074     extern int TK_LOCAL_APPINIT _ANSI_ARGS_((Tcl_Interp *interp));
00075   */
00076 
00077     /*
00078      * The following #if block allows you to change how Tcl finds the startup
00079      * script, prime the library or encoding paths, fiddle with the argv,
00080      * etc., without needing to rewrite Tk_Main()
00081      */
00082     
00083 #ifdef TK_LOCAL_MAIN_HOOK
00084     extern int TK_LOCAL_MAIN_HOOK _ANSI_ARGS_((int *argc, char ***argv));
00085     TK_LOCAL_MAIN_HOOK(&argc, &argv);
00086 #endif
00087 
00088     Tk_MainOpenSees(argc, argv, TK_LOCAL_APPINIT, Tcl_CreateInterp());
00089     return 0;                   /* Needed only to prevent compiler warning. */
00090 }
00091 
00092 /*
00093  *----------------------------------------------------------------------
00094  *
00095  * Tcl_AppInit --
00096  *
00097  *      This procedure performs application-specific initialization.
00098  *      Most applications, especially those that incorporate additional
00099  *      packages, will have their own version of this procedure.
00100  *
00101  * Results:
00102  *      Returns a standard Tcl completion code, and leaves an error
00103  *      message in the interp's result if an error occurs.
00104  *
00105  * Side effects:
00106  *      Depends on the startup script.
00107  *
00108  *----------------------------------------------------------------------
00109  */
00110 
00111 int
00112 Tcl_AppInit(Tcl_Interp *interp)
00113 {
00114     if (Tcl_Init(interp) == TCL_ERROR) {
00115         return TCL_ERROR;
00116     }
00117     if (Tk_Init(interp) == TCL_ERROR) {
00118         return TCL_ERROR;
00119     }
00120     Tcl_StaticPackage(interp, "Tk", Tk_Init, Tk_SafeInit);
00121 #ifdef TK_TEST
00122     if (Tcltest_Init(interp) == TCL_ERROR) {
00123         return TCL_ERROR;
00124     }
00125     Tcl_StaticPackage(interp, "Tcltest", Tcltest_Init,
00126             (Tcl_PackageInitProc *) NULL);
00127     if (Tktest_Init(interp) == TCL_ERROR) {
00128         return TCL_ERROR;
00129     }
00130     Tcl_StaticPackage(interp, "Tktest", Tktest_Init,
00131             (Tcl_PackageInitProc *) NULL);
00132 #endif /* TK_TEST */
00133 
00134 
00135     /*
00136      * Call the init procedures for included packages.  Each call should
00137      * look like this:
00138      *
00139      * if (Mod_Init(interp) == TCL_ERROR) {
00140      *     return TCL_ERROR;
00141      * }
00142      *
00143      * where "Mod" is the name of the module.
00144      */
00145 
00146     /*
00147      * Call Tcl_CreateCommand for application-specific commands, if
00148      * they weren't already created by the init procedures called above.
00149      */
00150 
00151     if (g3AppInit(interp) < 0)
00152         return TCL_ERROR;
00153 
00154     /*
00155      * Specify a user-specific startup file to invoke if the application
00156      * is run interactively.  Typically the startup file is "~/.apprc"
00157      * where "app" is the name of the application.  If this line is deleted
00158      * then no user-specific startup file will be run under any conditions.
00159      */
00160 
00161     Tcl_SetVar(interp, "tcl_rcFileName", "~/.wishrc", TCL_GLOBAL_ONLY);
00162     return TCL_OK;
00163 }
00164 
00165 
00166 
00167 
00168 
00169 
00170 /*
00171 int OpenSeesExit(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv)
00172 {
00173   return 0;
00174 }
00175 */

Generated on Mon Oct 23 15:05:31 2006 for OpenSees by doxygen 1.5.0