Debian Codegraph @

pTk/mTk/tixUnix/samAppInit.c

raw symbols SCIP
1
2 /* $Id: samAppInit.c,v 1.1.1.1 2000/05/17 11:08:54 idiscovery Exp $ */
3
4 /*
5 * samAppInit.c --
6 *
7 * Provides a default version of the Tcl_AppInit procedure for
8 * use in stand-alone Tcl, Tk or Tix applications.
9 *
10 * Copyright (c) 1996, Expert Interface Technologies
11 * Copyright (c) 1995 Ioi K Lam
12 * Copyright (c) 1993 The Regents of the University of California.
13 * Copyright (c) 1994 Sun Microsystems, Inc.
14 *
15 * See the file "license.terms" for information on usage and redistribution
16 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
17 */
18
19 #include <tcl.h>
20
21 #ifdef USE_TIX
22 # ifndef USE_TK
23 # define USE_TK
24 # endif
25 #endif
26
27 #ifdef USE_TK
28 #include <tk.h>
29 #endif
30
31 #ifdef USE_TIX
32 # include <tix.h>
33 #else
34 # if (TCL_MAJOR_VERSION > 7)
35 # define TCL_7_5_OR_LATER
36 # else
37 # if ((TCL_MAJOR_VERSION == 7) && (TCL_MINOR_VERSION >= 5))
38 # define TCL_7_5_OR_LATER
39 # endif
40 # endif
41 #endif
42
43 EXTERN int Tclsam_Init _ANSI_ARGS_((Tcl_Interp *interp));
44 EXTERN int Tksam_Init _ANSI_ARGS_((Tcl_Interp *interp));
45 EXTERN int Tixsam_Init _ANSI_ARGS_((Tcl_Interp *interp));
46
47 /*
48 * The following variable is a special hack that is needed in order for
49 * Sun shared libraries to be used for Tcl.
50 */
51
52 extern int matherr();
53 int *tclDummyMathPtr = (int *) matherr;
54
55 /*
56 *----------------------------------------------------------------------
57 *
58 * main --
59 *
60 * This is the main program for the application.
61 *
62 * Results:
63 * None: Tk_Main never returns here, so this procedure never
64 * returns either.
65 *
66 * Side effects:
67 * Whatever the application does.
68 *
69 *----------------------------------------------------------------------
70 */
71
72 int
73 main(argc, argv)
74 int argc; /* Number of command-line arguments. */
75 char **argv; /* Values of command-line arguments. */
76 {
77 #ifdef USE_TK
78 Tk_Main(argc, argv, Tcl_AppInit);
79 #else
80 Tcl_Main(argc, argv, Tcl_AppInit);
81 #endif
82
83 return 0; /* Needed only to prevent compiler warning. */
84 }
85
86 /*
87 *----------------------------------------------------------------------
88 *
89 * Tcl_AppInit --
90 *
91 * This procedure performs application-specific initialization.
92 * Most applications, especially those that incorporate additional
93 * packages, will have their own version of this procedure.
94 *
95 * Results:
96 * Returns a standard Tcl completion code, and leaves an error
97 * message in interp->result if an error occurs.
98 *
99 * Side effects:
100 * Depends on the startup script.
101 *
102 *----------------------------------------------------------------------
103 */
104
105 int
106 Tcl_AppInit(interp)
107 Tcl_Interp *interp; /* Interpreter for application. */
108 {
109 if (Tclsam_Init(interp) == TCL_ERROR) {
110 return TCL_ERROR;
111 }
112 #ifdef USE_TK
113 if (Tksam_Init(interp) == TCL_ERROR) {
114 return TCL_ERROR;
115 }
116 #endif
117
118 #ifdef USE_TIX
119 if (Tixsam_Init(interp) == TCL_ERROR) {
120 return TCL_ERROR;
121 }
122 #endif
123
124 #ifdef TCL_7_5_OR_LATER
125 Tcl_StaticPackage(interp, "Tclsam", Tclsam_Init, NULL);
126 #ifdef USE_TK
127 Tcl_StaticPackage(interp, "Tk", Tk_Init, NULL);
128 Tcl_StaticPackage(interp, "Tksam", Tksam_Init, NULL);
129 #endif
130 #ifdef USE_TIX
131 Tcl_StaticPackage(interp, "Tix", Tix_Init, NULL);
132 Tcl_StaticPackage(interp, "Tixsam", Tixsam_Init, NULL);
133 #endif
134 #endif
135
136 /*
137 * Call the init procedures for included packages. Each call should
138 * look like this:
139 *
140 * if (Mod_Init(interp) == TCL_ERROR) {
141 * return TCL_ERROR;
142 * }
143 *
144 * where "Mod" is the name of the module.
145 */
146
147 /*
148 * Call Tcl_CreateCommand for application-specific commands, if
149 * they weren't already created by the init procedures called above.
150 */
151
152 /*
153 * Specify a user-specific startup file to invoke if the application
154 * is run interactively. Typically the startup file is "~/.apprc"
155 * where "app" is the name of the application. If this line is deleted
156 * then no user-specific startup file will be run under any conditions.
157 */
158 #if defined(USE_TIX)
159 # define RC_FILENAME "~/.tixwishrc"
160 #else
161 # if defined(USE_TK)
162 # define RC_FILENAME "~/.wishrc"
163 # else
164 # define RC_FILENAME "~/.tclshrc"
165 # endif
166 #endif
167
168 #ifdef TCL_7_5_OR_LATER
169 /*
170 * Starting from TCL 7.5, the symbol tcl_rcFileName is no longer
171 * exported by libtcl.a. Instead, this variable must be set using
172 * a TCL global variable
173 */
174 Tcl_SetVar(interp, "tcl_rcFileName", RC_FILENAME, TCL_GLOBAL_ONLY);
175 #else
176 tcl_RcFileName = RC_FILENAME;
177 #endif
178
179 return TCL_OK;
180 }