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