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