figenc

[RADIOACTIVE] rsa and symmetric key encryption scripts and executables
git clone git://git.figbert.com/figenc.git
Log | Files | Refs | README

tclAppInit.c (4511B)


      1 /*
      2  * tclAppInit.c --
      3  *
      4  *	Provides a default version of the main program and Tcl_AppInit
      5  *	procedure for tclsh and other Tcl-based applications (without Tk).
      6  *
      7  * Copyright (c) 1993 The Regents of the University of California.
      8  * Copyright (c) 1994-1997 Sun Microsystems, Inc.
      9  * Copyright (c) 1998-1999 Scriptics Corporation.
     10  *
     11  * See the file "license.terms" for information on usage and redistribution of
     12  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
     13  */
     14 
     15 #undef BUILD_tcl
     16 #undef STATIC_BUILD
     17 #include "tcl.h"
     18 
     19 #ifdef TCL_TEST
     20 extern Tcl_PackageInitProc Tcltest_Init;
     21 extern Tcl_PackageInitProc Tcltest_SafeInit;
     22 #endif /* TCL_TEST */
     23 
     24 #ifdef TCL_XT_TEST
     25 extern void                XtToolkitInitialize(void);
     26 extern Tcl_PackageInitProc Tclxttest_Init;
     27 #endif /* TCL_XT_TEST */
     28 
     29 /*
     30  * The following #if block allows you to change the AppInit function by using
     31  * a #define of TCL_LOCAL_APPINIT instead of rewriting this entire file. The
     32  * #if checks for that #define and uses Tcl_AppInit if it does not exist.
     33  */
     34 
     35 #ifndef TCL_LOCAL_APPINIT
     36 #define TCL_LOCAL_APPINIT Tcl_AppInit
     37 #endif
     38 #ifndef MODULE_SCOPE
     39 #   define MODULE_SCOPE extern
     40 #endif
     41 MODULE_SCOPE int TCL_LOCAL_APPINIT(Tcl_Interp *);
     42 MODULE_SCOPE int main(int, char **);
     43 
     44 /*
     45  * The following #if block allows you to change how Tcl finds the startup
     46  * script, prime the library or encoding paths, fiddle with the argv, etc.,
     47  * without needing to rewrite Tcl_Main()
     48  */
     49 
     50 #ifdef TCL_LOCAL_MAIN_HOOK
     51 MODULE_SCOPE int TCL_LOCAL_MAIN_HOOK(int *argc, char ***argv);
     52 #endif
     53 
     54 /*
     55  *----------------------------------------------------------------------
     56  *
     57  * main --
     58  *
     59  *	This is the main program for the application.
     60  *
     61  * Results:
     62  *	None: Tcl_Main never returns here, so this procedure never returns
     63  *	either.
     64  *
     65  * Side effects:
     66  *	Just about anything, since from here we call arbitrary Tcl code.
     67  *
     68  *----------------------------------------------------------------------
     69  */
     70 
     71 int
     72 main(
     73     int argc,			/* Number of command-line arguments. */
     74     char *argv[])		/* Values of command-line arguments. */
     75 {
     76 #ifdef TCL_XT_TEST
     77     XtToolkitInitialize();
     78 #endif
     79 
     80 #ifdef TCL_LOCAL_MAIN_HOOK
     81     TCL_LOCAL_MAIN_HOOK(&argc, &argv);
     82 #endif
     83 
     84     Tcl_Main(argc, argv, TCL_LOCAL_APPINIT);
     85     return 0;			/* Needed only to prevent compiler warning. */
     86 }
     87 
     88 /*
     89  *----------------------------------------------------------------------
     90  *
     91  * Tcl_AppInit --
     92  *
     93  *	This procedure performs application-specific initialization. Most
     94  *	applications, especially those that incorporate additional packages,
     95  *	will have their own version of this procedure.
     96  *
     97  * Results:
     98  *	Returns a standard Tcl completion code, and leaves an error message in
     99  *	the interp's result if an error occurs.
    100  *
    101  * Side effects:
    102  *	Depends on the startup script.
    103  *
    104  *----------------------------------------------------------------------
    105  */
    106 
    107 int
    108 Tcl_AppInit(
    109     Tcl_Interp *interp)		/* Interpreter for application. */
    110 {
    111     if ((Tcl_Init)(interp) == TCL_ERROR) {
    112 	return TCL_ERROR;
    113     }
    114 
    115 #ifdef TCL_XT_TEST
    116     if (Tclxttest_Init(interp) == TCL_ERROR) {
    117 	return TCL_ERROR;
    118     }
    119 #endif
    120 
    121 #ifdef TCL_TEST
    122     if (Tcltest_Init(interp) == TCL_ERROR) {
    123 	return TCL_ERROR;
    124     }
    125     Tcl_StaticPackage(interp, "Tcltest", Tcltest_Init, Tcltest_SafeInit);
    126 #endif /* TCL_TEST */
    127 
    128     /*
    129      * Call the init procedures for included packages. Each call should look
    130      * like this:
    131      *
    132      * if (Mod_Init(interp) == TCL_ERROR) {
    133      *     return TCL_ERROR;
    134      * }
    135      *
    136      * where "Mod" is the name of the module. (Dynamically-loadable packages
    137      * should have the same entry-point name.)
    138      */
    139 
    140     /*
    141      * Call Tcl_CreateCommand for application-specific commands, if they
    142      * weren't already created by the init procedures called above.
    143      */
    144 
    145     /*
    146      * Specify a user-specific startup file to invoke if the application is
    147      * run interactively. Typically the startup file is "~/.apprc" where "app"
    148      * is the name of the application. If this line is deleted then no
    149      * user-specific startup file will be run under any conditions.
    150      */
    151 
    152 #ifdef DJGPP
    153     (Tcl_ObjSetVar2)(interp, Tcl_NewStringObj("tcl_rcFileName", -1), NULL,
    154 	    Tcl_NewStringObj("~/tclsh.rc", -1), TCL_GLOBAL_ONLY);
    155 #else
    156     (Tcl_ObjSetVar2)(interp, Tcl_NewStringObj("tcl_rcFileName", -1), NULL,
    157 	    Tcl_NewStringObj("~/.tclshrc", -1), TCL_GLOBAL_ONLY);
    158 #endif
    159 
    160     return TCL_OK;
    161 }
    162 
    163 /*
    164  * Local Variables:
    165  * mode: c
    166  * c-basic-offset: 4
    167  * fill-column: 78
    168  * End:
    169  */