Back to index

openldap  2.4.31
tclAppInit.c
Go to the documentation of this file.
00001 /* 
00002  * tclAppInit.c --
00003  *
00004  *     Provides a default version of the main program and Tcl_AppInit
00005  *     procedure for Tcl applications (without Tk).
00006  *
00007  * Copyright (c) 1993 The Regents of the University of California.
00008  * Copyright (c) 1994-1995 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  * SCCS: @(#) tclAppInit.c 1.17 96/03/26 12:45:29
00014  */
00015 
00016 #include "tcl.h"
00017 
00018 /*
00019  * The following variable is a special hack that is needed in order for
00020  * Sun shared libraries to be used for Tcl.
00021  */
00022 
00023 extern int matherr();
00024 int *tclDummyMathPtr = (int *) matherr;
00025 
00026 #ifdef TCL_TEST
00027 EXTERN int           Tcltest_Init _ANSI_ARGS_((Tcl_Interp *interp));
00028 #endif /* TCL_TEST */
00029 
00030 /*
00031  *----------------------------------------------------------------------
00032  *
00033  * main --
00034  *
00035  *     This is the main program for the application.
00036  *
00037  * Results:
00038  *     None: Tcl_Main never returns here, so this procedure never
00039  *     returns either.
00040  *
00041  * Side effects:
00042  *     Whatever the application does.
00043  *
00044  *----------------------------------------------------------------------
00045  */
00046 
00047 int
00048 main(argc, argv)
00049     int argc;               /* Number of command-line arguments. */
00050     char **argv;            /* Values of command-line arguments. */
00051 {
00052 #ifdef USE_TCLX
00053     TclX_Main(argc, argv, Tcl_AppInit);
00054 #else
00055     Tcl_Main(argc, argv, Tcl_AppInit);
00056 #endif
00057     return 0;               /* Needed only to prevent compiler warning. */
00058 }
00059 
00060 /*
00061  *----------------------------------------------------------------------
00062  *
00063  * Tcl_AppInit --
00064  *
00065  *     This procedure performs application-specific initialization.
00066  *     Most applications, especially those that incorporate additional
00067  *     packages, will have their own version of this procedure.
00068  *
00069  * Results:
00070  *     Returns a standard Tcl completion code, and leaves an error
00071  *     message in interp->result if an error occurs.
00072  *
00073  * Side effects:
00074  *     Depends on the startup script.
00075  *
00076  *----------------------------------------------------------------------
00077  */
00078 
00079 int
00080 Tcl_AppInit(interp)
00081     Tcl_Interp *interp;            /* Interpreter for application. */
00082 {
00083     if (Tcl_Init(interp) == TCL_ERROR) {
00084        return TCL_ERROR;
00085     }
00086 
00087 #ifdef USE_ITCL
00088     if (Itcl_Init(interp) == TCL_ERROR) {
00089        return TCL_ERROR;
00090     }
00091     Tcl_StaticPackage (interp, "Itcl", Itcl_Init, NULL);
00092 #endif
00093 
00094 #ifdef TCL_TEST
00095     if (Tcltest_Init(interp) == TCL_ERROR) {
00096        return TCL_ERROR;
00097     }
00098     Tcl_StaticPackage(interp, "Tcltest", Tcltest_Init,
00099             (Tcl_PackageInitProc *) NULL);
00100 #endif /* TCL_TEST */
00101 
00102 #ifdef USE_TCLX
00103     if (Tclx_Init (interp) == TCL_ERROR) {
00104        return TCL_ERROR;
00105     }   
00106     Tcl_StaticPackage (interp, "Tclx", Tclx_Init, NULL);
00107 #endif
00108 
00109     if (Ldaptcl_Init(interp) == TCL_ERROR) {
00110        return TCL_ERROR;
00111     }
00112     Tcl_StaticPackage(interp, "Ldaptcl", Ldaptcl_Init,
00113             (Tcl_PackageInitProc *) NULL);
00114 
00115     /*
00116      * Call the init procedures for included packages.  Each call should
00117      * look like this:
00118      *
00119      * if (Mod_Init(interp) == TCL_ERROR) {
00120      *     return TCL_ERROR;
00121      * }
00122      *
00123      * where "Mod" is the name of the module.
00124      */
00125 
00126     /*
00127      * Call Tcl_CreateCommand for application-specific commands, if
00128      * they weren't already created by the init procedures called above.
00129      */
00130 
00131     /*
00132      * Specify a user-specific startup file to invoke if the application
00133      * is run interactively.  Typically the startup file is "~/.apprc"
00134      * where "app" is the name of the application.  If this line is deleted
00135      * then no user-specific startup file will be run under any conditions.
00136      */
00137 
00138     Tcl_SetVar(interp, "tcl_rcFileName", "~/.tclshrc", TCL_GLOBAL_ONLY);
00139     return TCL_OK;
00140 }