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