os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/unix/tclTestInit.c
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/unix/tclTestInit.c Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,180 @@
1.4 +/*
1.5 + * tclTestInit.c --
1.6 + *
1.7 + * Provides a default version of the main program and Tcl_AppInit
1.8 + * procedure for Tcl applications (without Tk). Based on tclAppInit.c
1.9 + *
1.10 + * Copyright (c) 1993 The Regents of the University of California.
1.11 + * Copyright (c) 1994-1997 Sun Microsystems, Inc.
1.12 + * Copyright (c) 1998-1999 by Scriptics Corporation.
1.13 + * Portions Copyright (c) 2007 Nokia Corporation and/or its subsidiaries. All rights reserved.
1.14 + *
1.15 + * See the file "license.terms" for information on usage and redistribution
1.16 + * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
1.17 + *
1.18 + * RCS: @(#) $Id: tclAppInit.c,v 1.11 2002/05/31 22:20:22 dgp Exp $
1.19 + */
1.20 +
1.21 +#include "tcl.h"
1.22 +#if defined(__SYMBIAN32__)
1.23 +#include "tclPort.h"
1.24 +#endif
1.25 +
1.26 +#ifdef TCL_TEST
1.27 +
1.28 +#include "tclInt.h"
1.29 +
1.30 +extern int Procbodytest_Init _ANSI_ARGS_((Tcl_Interp *interp));
1.31 +extern int Procbodytest_SafeInit _ANSI_ARGS_((Tcl_Interp *interp));
1.32 +extern int TclObjTest_Init _ANSI_ARGS_((Tcl_Interp *interp));
1.33 +extern int Tcltest_Init _ANSI_ARGS_((Tcl_Interp *interp));
1.34 +#ifdef TCL_THREADS
1.35 +extern int TclThread_Init _ANSI_ARGS_((Tcl_Interp *interp));
1.36 +#endif
1.37 +
1.38 +#endif /* TCL_TEST */
1.39 +
1.40 +#ifdef TCL_XT_TEST
1.41 +extern void XtToolkitInitialize _ANSI_ARGS_((void));
1.42 +extern int Tclxttest_Init _ANSI_ARGS_((Tcl_Interp *interp));
1.43 +#endif
1.44 +
1.45 +/*
1.46 + *----------------------------------------------------------------------
1.47 + *
1.48 + * main --
1.49 + *
1.50 + * This is the main program for the application.
1.51 + *
1.52 + * Results:
1.53 + * None: Tcl_Main never returns here, so this procedure never
1.54 + * returns either.
1.55 + *
1.56 + * Side effects:
1.57 + * Whatever the application does.
1.58 + *
1.59 + *----------------------------------------------------------------------
1.60 + */
1.61 +
1.62 +int
1.63 +main(argc, argv)
1.64 + int argc; /* Number of command-line arguments. */
1.65 + char **argv; /* Values of command-line arguments. */
1.66 +{
1.67 + /*
1.68 + * The following #if block allows you to change the AppInit
1.69 + * function by using a #define of TCL_LOCAL_APPINIT instead
1.70 + * of rewriting this entire file. The #if checks for that
1.71 + * #define and uses Tcl_AppInit if it doesn't exist.
1.72 + */
1.73 +#ifndef TCL_LOCAL_APPINIT
1.74 +#define TCL_LOCAL_APPINIT Tcl_AppInit
1.75 +#endif
1.76 + extern int TCL_LOCAL_APPINIT _ANSI_ARGS_((Tcl_Interp *interp));
1.77 +
1.78 + /*
1.79 + * The following #if block allows you to change how Tcl finds the startup
1.80 + * script, prime the library or encoding paths, fiddle with the argv,
1.81 + * etc., without needing to rewrite Tcl_Main()
1.82 + */
1.83 +
1.84 +#ifdef TCL_LOCAL_MAIN_HOOK
1.85 + extern int TCL_LOCAL_MAIN_HOOK _ANSI_ARGS_((int *argc, char ***argv));
1.86 +#endif
1.87 +
1.88 +#ifdef TCL_XT_TEST
1.89 + XtToolkitInitialize();
1.90 +#endif
1.91 +
1.92 +#ifdef TCL_LOCAL_MAIN_HOOK
1.93 + TCL_LOCAL_MAIN_HOOK(&argc, &argv);
1.94 +#endif
1.95 +
1.96 + Tcl_Main(argc, argv, TCL_LOCAL_APPINIT);
1.97 +
1.98 + return 0; /* Needed only to prevent compiler warning. */
1.99 +}
1.100 +
1.101 +/*
1.102 + *----------------------------------------------------------------------
1.103 + *
1.104 + * Tcl_AppInit --
1.105 + *
1.106 + * This procedure performs application-specific initialization.
1.107 + * Most applications, especially those that incorporate additional
1.108 + * packages, will have their own version of this procedure.
1.109 + *
1.110 + * Results:
1.111 + * Returns a standard Tcl completion code, and leaves an error
1.112 + * message in the interp's result if an error occurs.
1.113 + *
1.114 + * Side effects:
1.115 + * Depends on the startup script.
1.116 + *
1.117 + *----------------------------------------------------------------------
1.118 + */
1.119 +
1.120 +int
1.121 +Tcl_AppInit(interp)
1.122 + Tcl_Interp *interp; /* Interpreter for application. */
1.123 +{
1.124 + if (Tcl_Init(interp) == TCL_ERROR) {
1.125 + return TCL_ERROR;
1.126 + }
1.127 +
1.128 +#ifdef TCL_TEST
1.129 +#ifdef TCL_XT_TEST
1.130 + if (Tclxttest_Init(interp) == TCL_ERROR) {
1.131 + return TCL_ERROR;
1.132 + }
1.133 +#endif
1.134 + if (Tcltest_Init(interp) == TCL_ERROR) {
1.135 + return TCL_ERROR;
1.136 + }
1.137 + Tcl_StaticPackage(interp, "Tcltest", Tcltest_Init,
1.138 + (Tcl_PackageInitProc *) NULL);
1.139 + if (TclObjTest_Init(interp) == TCL_ERROR) {
1.140 + return TCL_ERROR;
1.141 + }
1.142 +#ifdef TCL_THREADS
1.143 + if (TclThread_Init(interp) == TCL_ERROR) {
1.144 + return TCL_ERROR;
1.145 + }
1.146 +#endif
1.147 + if (Procbodytest_Init(interp) == TCL_ERROR) {
1.148 + return TCL_ERROR;
1.149 + }
1.150 + Tcl_StaticPackage(interp, "procbodytest", Procbodytest_Init,
1.151 + Procbodytest_SafeInit);
1.152 +#endif /* TCL_TEST */
1.153 +
1.154 + /*
1.155 + * Call the init procedures for included packages. Each call should
1.156 + * look like this:
1.157 + *
1.158 + * if (Mod_Init(interp) == TCL_ERROR) {
1.159 + * return TCL_ERROR;
1.160 + * }
1.161 + *
1.162 + * where "Mod" is the name of the module.
1.163 + */
1.164 +
1.165 + /*
1.166 + * Call Tcl_CreateCommand for application-specific commands, if
1.167 + * they weren't already created by the init procedures called above.
1.168 + */
1.169 +
1.170 + /*
1.171 + * Specify a user-specific startup file to invoke if the application
1.172 + * is run interactively. Typically the startup file is "~/.apprc"
1.173 + * where "app" is the name of the application. If this line is deleted
1.174 + * then no user-specific startup file will be run under any conditions.
1.175 + */
1.176 +
1.177 +#ifdef DJGPP
1.178 + Tcl_SetVar(interp, "tcl_rcFileName", "~/tclsh.rc", TCL_GLOBAL_ONLY);
1.179 +#else
1.180 + Tcl_SetVar(interp, "tcl_rcFileName", "~/.tclshrc", TCL_GLOBAL_ONLY);
1.181 +#endif
1.182 + return TCL_OK;
1.183 +}