Debian Codegraph @

generic/bltUnixMain.c

raw symbols SCIP
1 /*
2 * bltUnixMain.c --
3 *
4 * Provides a default version of the Tcl_AppInit procedure for
5 * use in wish and similar Tk-based applications.
6 *
7 * Copyright (c) 1993 The Regents of the University of California.
8 * All rights reserved.
9 *
10 * Permission is hereby granted, without written agreement and without
11 * license or royalty fees, to use, copy, modify, and distribute this
12 * software and its documentation for any purpose, provided that the
13 * above copyright notice and the following two paragraphs appear in
14 * all copies of this software.
15 *
16 * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
17 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
18 * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
19 * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
20 *
21 * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
22 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
23 * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
24 * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
25 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
26 *
27 * Copyright 1991-1998 by Bell Labs Innovations for Lucent Technologies.
28 *
29 * Permission to use, copy, modify, and distribute this software and
30 * its documentation for any purpose and without fee is hereby
31 * granted, provided that the above copyright notice appear in all
32 * copies and that both that the copyright notice and warranty
33 * disclaimer appear in supporting documentation, and that the names
34 * of Lucent Technologies any of their entities not be used in
35 * advertising or publicity pertaining to distribution of the software
36 * without specific, written prior permission.
37 *
38 * Lucent Technologies disclaims all warranties with regard to this
39 * software, including all implied warranties of merchantability and
40 * fitness. In no event shall Lucent Technologies be liable for any
41 * special, indirect or consequential damages or any damages
42 * whatsoever resulting from loss of use, data or profits, whether in
43 * an action of contract, negligence or other tortuous action, arising
44 * out of or in connection with the use or performance of this
45 * software.
46 */
47
48 #include <tcl.h>
49 #ifndef TCL_ONLY
50 #include <tk.h>
51 #endif
52
53 #if HAVE_ITCL_H
54 #include "itcl.h"
55 #endif
56 #if HAVE_ITK_H
57 #include "itk.h"
58 #endif
59
60 extern int Blt_Init _ANSI_ARGS_((Tcl_Interp *interp));
61 extern int Blt_SafeInit _ANSI_ARGS_((Tcl_Interp *interp));
62
63 /*
64 * The following variable is a special hack that is needed in order for
65 * Sun shared libraries to be used for Tcl.
66 */
67
68 #ifdef NEED_MATHERR
69 extern int matherr();
70 int *tclDummyMathPtr = (int *)matherr;
71 #endif
72
73
74 /*
75 *----------------------------------------------------------------------
76 *
77 * main --
78 *
79 * This is the main program for the application.
80 *
81 * Results:
82 * None: Tk_Main never returns here, so this procedure never
83 * returns either.
84 *
85 * Side effects:
86 * Whatever the application does.
87 *
88 *----------------------------------------------------------------------
89 */
90 int
91 main(argc, argv)
92 int argc; /* Number of command-line arguments. */
93 char **argv; /* Vector of command-line arguments. */
94 {
95
96 #ifdef TCL_ONLY
97 Tcl_Main(argc, argv, Tcl_AppInit);
98 #else
99 Tk_Main(argc, argv, Tcl_AppInit);
100 #endif
101 return 0; /* Needed only to prevent compiler warning. */
102 }
103
104
105 /*
106 *----------------------------------------------------------------------
107 *
108 * Tcl_AppInit --
109 *
110 * This procedure performs application-specific initialization.
111 * Most applications, especially those that incorporate additional
112 * packages, will have their own version of this procedure.
113 *
114 * Results:
115 * Returns a standard Tcl completion code, and leaves an error
116 * message in interp->result if an error occurs.
117 *
118 * Side effects:
119 * Depends on the startup script.
120 *
121 *----------------------------------------------------------------------
122 */
123
124 int
125 Tcl_AppInit(interp)
126 Tcl_Interp *interp; /* Interpreter for application. */
127 {
128 #ifdef TCLLIBPATH
129 /*
130 * It seems that some distributions of Tcl don't compile-in a
131 * default location of the library. This causes Tcl_Init to fail
132 * if bltwish and bltsh are moved to another directory. The
133 * workaround is to set the magic variable "tclDefaultLibrary".
134 */
135 Tcl_SetVar(interp, "tclDefaultLibrary", TCLLIBPATH, TCL_GLOBAL_ONLY);
136 #endif
137 if (Tcl_Init(interp) == TCL_ERROR) {
138 return TCL_ERROR;
139 }
140 #ifndef TCL_ONLY
141 if (Tk_Init(interp) == TCL_ERROR) {
142 return TCL_ERROR;
143 }
144 #endif
145 /*
146 * Call the init procedures for included packages. Each call should
147 * look like this:
148 *
149 * if (Mod_Init(interp) == TCL_ERROR) {
150 * return TCL_ERROR;
151 * }
152 *
153 * where "Mod" is the name of the module.
154 */
155 if (Blt_Init(interp) == TCL_ERROR) {
156 return TCL_ERROR;
157 }
158 Tcl_StaticPackage(interp, "BLT", Blt_Init, Blt_SafeInit);
159 /*
160
161 * Call Tcl_CreateCommand for application-specific commands, if
162 * they weren't already created by the init procedures called above.
163 */
164
165 /*
166 * Specify a user-specific startup file to invoke if the application
167 * is run interactively. Typically the startup file is "~/.apprc"
168 * where "app" is the name of the application. If this line is deleted
169 * then no user-specific startup file will be run under any conditions.
170 */
171
172 Tcl_SetVar(interp, "tcl_rcFileName", "~/.wishrc", TCL_GLOBAL_ONLY);
173 return TCL_OK;
174 }