050e226754f3ff09999353d6b84bc248628d3eb3
[msysgit.git] / mingw / lib / tk8.5 / tkAppInit.c
blob050e226754f3ff09999353d6b84bc248628d3eb3
1 /*
2 * tkAppInit.c --
4 * Provides a default version of the Tcl_AppInit procedure for use in
5 * wish and similar Tk-based applications.
7 * Copyright (c) 1993 The Regents of the University of California.
8 * Copyright (c) 1994-1997 Sun Microsystems, Inc.
10 * See the file "license.terms" for information on usage and redistribution of
11 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
14 #include "tk.h"
15 #include "locale.h"
17 #ifdef TK_TEST
18 extern int Tktest_Init _ANSI_ARGS_((Tcl_Interp *interp));
19 #endif /* TK_TEST */
22 *----------------------------------------------------------------------
24 * main --
26 * This is the main program for the application.
28 * Results:
29 * None: Tk_Main never returns here, so this procedure never returns
30 * either.
32 * Side effects:
33 * Whatever the application does.
35 *----------------------------------------------------------------------
38 int
39 main(
40 int argc, /* Number of command-line arguments. */
41 char **argv) /* Values of command-line arguments. */
44 * The following #if block allows you to change the AppInit function by
45 * using a #define of TCL_LOCAL_APPINIT instead of rewriting this entire
46 * file. The #if checks for that #define and uses Tcl_AppInit if it
47 * doesn't exist.
50 #ifndef TK_LOCAL_APPINIT
51 #define TK_LOCAL_APPINIT Tcl_AppInit
52 #endif
53 extern int TK_LOCAL_APPINIT _ANSI_ARGS_((Tcl_Interp *interp));
56 * The following #if block allows you to change how Tcl finds the startup
57 * script, prime the library or encoding paths, fiddle with the argv,
58 * etc., without needing to rewrite Tk_Main()
61 #ifdef TK_LOCAL_MAIN_HOOK
62 extern int TK_LOCAL_MAIN_HOOK _ANSI_ARGS_((int *argc, char ***argv));
63 TK_LOCAL_MAIN_HOOK(&argc, &argv);
64 #endif
66 Tk_Main(argc, argv, TK_LOCAL_APPINIT);
67 return 0; /* Needed only to prevent compiler warning. */
71 *----------------------------------------------------------------------
73 * Tcl_AppInit --
75 * This procedure performs application-specific initialization. Most
76 * applications, especially those that incorporate additional packages,
77 * will have their own version of this procedure.
79 * Results:
80 * Returns a standard Tcl completion code, and leaves an error message in
81 * the interp's result if an error occurs.
83 * Side effects:
84 * Depends on the startup script.
86 *----------------------------------------------------------------------
89 int
90 Tcl_AppInit(
91 Tcl_Interp *interp) /* Interpreter for application. */
93 if (Tcl_Init(interp) == TCL_ERROR) {
94 return TCL_ERROR;
96 if (Tk_Init(interp) == TCL_ERROR) {
97 return TCL_ERROR;
99 Tcl_StaticPackage(interp, "Tk", Tk_Init, Tk_SafeInit);
100 #ifdef TK_TEST
101 if (Tktest_Init(interp) == TCL_ERROR) {
102 return TCL_ERROR;
104 Tcl_StaticPackage(interp, "Tktest", Tktest_Init,
105 (Tcl_PackageInitProc *) NULL);
106 #endif /* TK_TEST */
109 * Call the init procedures for included packages. Each call should look
110 * like this:
112 * if (Mod_Init(interp) == TCL_ERROR) {
113 * return TCL_ERROR;
116 * where "Mod" is the name of the module.
120 * Call Tcl_CreateCommand for application-specific commands, if they
121 * weren't already created by the init procedures called above.
125 * Specify a user-specific startup file to invoke if the application is
126 * run interactively. Typically the startup file is "~/.apprc" where "app"
127 * is the name of the application. If this line is deleted then no user-
128 * -specific startup file will be run under any conditions.
131 Tcl_SetVar(interp, "tcl_rcFileName", "~/.wishrc", TCL_GLOBAL_ONLY);
132 return TCL_OK;
136 * Local Variables:
137 * mode: c
138 * c-basic-offset: 4
139 * fill-column: 78
140 * End: