os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/unix/tclTestInit.c
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 /* 
     2  * tclTestInit.c --
     3  *
     4  *	Provides a default version of the main program and Tcl_AppInit
     5  *	procedure for Tcl applications (without Tk). Based on tclAppInit.c
     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 by Scriptics Corporation.
    10  * Portions Copyright (c) 2007 Nokia Corporation and/or its subsidiaries. All rights reserved.   
    11  *
    12  * See the file "license.terms" for information on usage and redistribution
    13  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
    14  *
    15  * RCS: @(#) $Id: tclAppInit.c,v 1.11 2002/05/31 22:20:22 dgp Exp $
    16  */
    17 
    18 #include "tcl.h"
    19 #if defined(__SYMBIAN32__)
    20 #include "tclPort.h"
    21 #endif
    22 
    23 #ifdef TCL_TEST
    24 
    25 #include "tclInt.h"
    26 
    27 extern int		Procbodytest_Init _ANSI_ARGS_((Tcl_Interp *interp));
    28 extern int		Procbodytest_SafeInit _ANSI_ARGS_((Tcl_Interp *interp));
    29 extern int		TclObjTest_Init _ANSI_ARGS_((Tcl_Interp *interp));
    30 extern int		Tcltest_Init _ANSI_ARGS_((Tcl_Interp *interp));
    31 #ifdef TCL_THREADS
    32 extern int		TclThread_Init _ANSI_ARGS_((Tcl_Interp *interp));
    33 #endif
    34 
    35 #endif /* TCL_TEST */
    36 
    37 #ifdef TCL_XT_TEST
    38 extern void		XtToolkitInitialize _ANSI_ARGS_((void));
    39 extern int		Tclxttest_Init _ANSI_ARGS_((Tcl_Interp *interp));
    40 #endif
    41 
    42 /*
    43  *----------------------------------------------------------------------
    44  *
    45  * main --
    46  *
    47  *	This is the main program for the application.
    48  *
    49  * Results:
    50  *	None: Tcl_Main never returns here, so this procedure never
    51  *	returns either.
    52  *
    53  * Side effects:
    54  *	Whatever the application does.
    55  *
    56  *----------------------------------------------------------------------
    57  */
    58 
    59 int
    60 main(argc, argv)
    61     int argc;			/* Number of command-line arguments. */
    62     char **argv;		/* Values of command-line arguments. */
    63 {
    64     /*
    65      * The following #if block allows you to change the AppInit
    66      * function by using a #define of TCL_LOCAL_APPINIT instead
    67      * of rewriting this entire file.  The #if checks for that
    68      * #define and uses Tcl_AppInit if it doesn't exist.
    69      */
    70 #ifndef TCL_LOCAL_APPINIT
    71 #define TCL_LOCAL_APPINIT Tcl_AppInit    
    72 #endif
    73     extern int TCL_LOCAL_APPINIT _ANSI_ARGS_((Tcl_Interp *interp));
    74 
    75     /*
    76      * The following #if block allows you to change how Tcl finds the startup
    77      * script, prime the library or encoding paths, fiddle with the argv,
    78      * etc., without needing to rewrite Tcl_Main()
    79      */
    80 
    81 #ifdef TCL_LOCAL_MAIN_HOOK
    82     extern int TCL_LOCAL_MAIN_HOOK _ANSI_ARGS_((int *argc, char ***argv));
    83 #endif
    84 
    85 #ifdef TCL_XT_TEST
    86     XtToolkitInitialize();
    87 #endif
    88 
    89 #ifdef TCL_LOCAL_MAIN_HOOK
    90     TCL_LOCAL_MAIN_HOOK(&argc, &argv);
    91 #endif
    92 
    93     Tcl_Main(argc, argv, TCL_LOCAL_APPINIT);
    94     
    95     return 0;			/* Needed only to prevent compiler warning. */
    96 }
    97 
    98 /*
    99  *----------------------------------------------------------------------
   100  *
   101  * Tcl_AppInit --
   102  *
   103  *	This procedure performs application-specific initialization.
   104  *	Most applications, especially those that incorporate additional
   105  *	packages, will have their own version of this procedure.
   106  *
   107  * Results:
   108  *	Returns a standard Tcl completion code, and leaves an error
   109  *	message in the interp's result if an error occurs.
   110  *
   111  * Side effects:
   112  *	Depends on the startup script.
   113  *
   114  *----------------------------------------------------------------------
   115  */
   116 
   117 int
   118 Tcl_AppInit(interp)
   119     Tcl_Interp *interp;		/* Interpreter for application. */
   120 {
   121     if (Tcl_Init(interp) == TCL_ERROR) {
   122 	return TCL_ERROR;
   123     }
   124 
   125 #ifdef TCL_TEST
   126 #ifdef TCL_XT_TEST 
   127      if (Tclxttest_Init(interp) == TCL_ERROR) {
   128 	 return TCL_ERROR;
   129      }
   130 #endif
   131     if (Tcltest_Init(interp) == TCL_ERROR) {
   132 	return TCL_ERROR;
   133     }
   134     Tcl_StaticPackage(interp, "Tcltest", Tcltest_Init,
   135             (Tcl_PackageInitProc *) NULL);
   136     if (TclObjTest_Init(interp) == TCL_ERROR) {
   137 	return TCL_ERROR;
   138     }
   139 #ifdef TCL_THREADS
   140     if (TclThread_Init(interp) == TCL_ERROR) {
   141 	return TCL_ERROR;
   142     }
   143 #endif
   144     if (Procbodytest_Init(interp) == TCL_ERROR) {
   145 	return TCL_ERROR;
   146     }
   147     Tcl_StaticPackage(interp, "procbodytest", Procbodytest_Init,
   148             Procbodytest_SafeInit);
   149 #endif /* TCL_TEST */
   150 
   151     /*
   152      * Call the init procedures for included packages.  Each call should
   153      * look like this:
   154      *
   155      * if (Mod_Init(interp) == TCL_ERROR) {
   156      *     return TCL_ERROR;
   157      * }
   158      *
   159      * where "Mod" is the name of the module.
   160      */
   161 
   162     /*
   163      * Call Tcl_CreateCommand for application-specific commands, if
   164      * they weren't already created by the init procedures called above.
   165      */
   166 
   167     /*
   168      * Specify a user-specific startup file to invoke if the application
   169      * is run interactively.  Typically the startup file is "~/.apprc"
   170      * where "app" is the name of the application.  If this line is deleted
   171      * then no user-specific startup file will be run under any conditions.
   172      */
   173 
   174 #ifdef DJGPP
   175     Tcl_SetVar(interp, "tcl_rcFileName", "~/tclsh.rc", TCL_GLOBAL_ONLY);
   176 #else
   177     Tcl_SetVar(interp, "tcl_rcFileName", "~/.tclshrc", TCL_GLOBAL_ONLY);
   178 #endif
   179     return TCL_OK;
   180 }