Back to index

openldap  2.4.31
tkAppInit.c
Go to the documentation of this file.
00001 /* 
00002  * tkXAppInit.c --
00003  *
00004  * Provides a default version of the Tcl_AppInit procedure for use with
00005  * applications built with Extended Tcl and Tk on Unix systems.  This is based
00006  * on the the UCB Tk file tkAppInit.c
00007  *-----------------------------------------------------------------------------
00008  * Copyright 1991-1996 Karl Lehenbauer and Mark Diekhans.
00009  *
00010  * Permission to use, copy, modify, and distribute this software and its
00011  * documentation for any purpose and without fee is hereby granted, provided
00012  * that the above copyright notice appear in all copies.  Karl Lehenbauer and
00013  * Mark Diekhans make no representations about the suitability of this
00014  * software for any purpose.  It is provided "as is" without express or
00015  * implied warranty.
00016  *-----------------------------------------------------------------------------
00017  * $OpenLDAP$
00018  *-----------------------------------------------------------------------------
00019  */
00020 
00021 #include "tclExtend.h"
00022 #include "tk.h"
00023 
00024 /*
00025  * The following variable is a special hack that insures the tcl
00026  * version of matherr() is used when linking against shared libraries
00027  * Even if matherr is not used on this system, there is a dummy version
00028  * in libtcl.
00029  */
00030 EXTERN int matherr ();
00031 int (*tclDummyMathPtr)() = matherr;
00032 
00033 
00034 /*-----------------------------------------------------------------------------
00035  * main --
00036  *
00037  * This is the main program for the application.
00038  *-----------------------------------------------------------------------------
00039  */
00040 #ifdef __cplusplus
00041 int
00042 main (int    argc,
00043       char **argv)
00044 #else
00045 int
00046 main (argc, argv)
00047     int    argc;
00048     char **argv;
00049 #endif
00050 {
00051 #ifdef USE_TCLX
00052     TkX_Main(argc, argv, Tcl_AppInit);
00053 #else
00054     Tk_Main(argc, argv, Tcl_AppInit);
00055 #endif
00056     return 0;                   /* Needed only to prevent compiler warning. */
00057 }
00058 
00059 /*-----------------------------------------------------------------------------
00060  * Tcl_AppInit --
00061  *
00062  * This procedure performs application-specific initialization. Most
00063  * applications, especially those that incorporate additional packages, will
00064  * have their own version of this procedure.
00065  *
00066  * Results:
00067  *    Returns a standard Tcl completion code, and leaves an error message in
00068  * interp->result if an error occurs.
00069  *-----------------------------------------------------------------------------
00070  */
00071 #ifdef __cplusplus
00072 int
00073 Tcl_AppInit (Tcl_Interp *interp)
00074 #else
00075 int
00076 Tcl_AppInit (interp)
00077     Tcl_Interp *interp;
00078 #endif
00079 {
00080     if (Tcl_Init (interp) == TCL_ERROR) {
00081         return TCL_ERROR;
00082     }
00083 #ifdef USE_TCLX
00084     if (Tclx_Init(interp) == TCL_ERROR) {
00085         return TCL_ERROR;
00086     }
00087     Tcl_StaticPackage(interp, "Tclx", Tclx_Init, Tclx_SafeInit);
00088 #endif
00089     if (Tk_Init(interp) == TCL_ERROR) {
00090         return TCL_ERROR;
00091     }
00092     Tcl_StaticPackage(interp, "Tk", Tk_Init, (Tcl_PackageInitProc *) NULL);
00093 #ifdef USE_TCLX
00094     if (Tkx_Init(interp) == TCL_ERROR) {
00095         return TCL_ERROR;
00096     }
00097     Tcl_StaticPackage(interp, "Tkx", Tkx_Init, (Tcl_PackageInitProc *) NULL);
00098 #endif
00099 
00100     if (Ldaptcl_Init(interp) == TCL_ERROR) {
00101        return TCL_ERROR;
00102     }
00103     Tcl_StaticPackage(interp, "Ldaptcl", Ldaptcl_Init,
00104             (Tcl_PackageInitProc *) NULL);
00105 
00106     /*
00107      * Call Tcl_CreateCommand for application-specific commands, if
00108      * they weren't already created by the init procedures called above.
00109      */
00110 
00111     /*
00112      * Specify a user-specific startup file to invoke if the application
00113      * is run interactively.  Typically the startup file is "~/.apprc"
00114      * where "app" is the name of the application.  If this line is deleted
00115      * then no user-specific startup file will be run under any conditions.
00116      */
00117     Tcl_SetVar(interp, "tcl_rcFileName", "~/.wishxrc", TCL_GLOBAL_ONLY);
00118     return TCL_OK;
00119 }