Start anew
[msysgit.git] / mingw / lib / tk8.4 / tkAppInit.c
blob3a215fea589b332501960ba6163a41d667a0bf9d
1 /*
2 * tkAppInit.c --
4 * Provides a default version of the Tcl_AppInit procedure for
5 * use in 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
11 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
13 * RCS: @(#) $Id: tkAppInit.c,v 1.7 2002/06/21 20:24:29 dgp Exp $
16 #include "tk.h"
17 #include "locale.h"
19 #ifdef TK_TEST
20 extern int Tktest_Init _ANSI_ARGS_((Tcl_Interp *interp));
21 #endif /* TK_TEST */
24 *----------------------------------------------------------------------
26 * main --
28 * This is the main program for the application.
30 * Results:
31 * None: Tk_Main never returns here, so this procedure never
32 * returns either.
34 * Side effects:
35 * Whatever the application does.
37 *----------------------------------------------------------------------
40 int
41 main(argc, argv)
42 int argc; /* Number of command-line arguments. */
43 char **argv; /* Values of command-line arguments. */
46 * The following #if block allows you to change the AppInit
47 * function by using a #define of TCL_LOCAL_APPINIT instead
48 * of rewriting this entire file. The #if checks for that
49 * #define and uses Tcl_AppInit if it doesn't exist.
52 #ifndef TK_LOCAL_APPINIT
53 #define TK_LOCAL_APPINIT Tcl_AppInit
54 #endif
55 extern int TK_LOCAL_APPINIT _ANSI_ARGS_((Tcl_Interp *interp));
58 * The following #if block allows you to change how Tcl finds the startup
59 * script, prime the library or encoding paths, fiddle with the argv,
60 * etc., without needing to rewrite Tk_Main()
63 #ifdef TK_LOCAL_MAIN_HOOK
64 extern int TK_LOCAL_MAIN_HOOK _ANSI_ARGS_((int *argc, char ***argv));
65 TK_LOCAL_MAIN_HOOK(&argc, &argv);
66 #endif
68 Tk_Main(argc, argv, TK_LOCAL_APPINIT);
69 return 0; /* Needed only to prevent compiler warning. */
73 *----------------------------------------------------------------------
75 * Tcl_AppInit --
77 * This procedure performs application-specific initialization.
78 * Most applications, especially those that incorporate additional
79 * packages, will have their own version of this procedure.
81 * Results:
82 * Returns a standard Tcl completion code, and leaves an error
83 * message in the interp's result if an error occurs.
85 * Side effects:
86 * Depends on the startup script.
88 *----------------------------------------------------------------------
91 int
92 Tcl_AppInit(interp)
93 Tcl_Interp *interp; /* Interpreter for application. */
95 if (Tcl_Init(interp) == TCL_ERROR) {
96 return TCL_ERROR;
98 if (Tk_Init(interp) == TCL_ERROR) {
99 return TCL_ERROR;
101 Tcl_StaticPackage(interp, "Tk", Tk_Init, Tk_SafeInit);
102 #ifdef TK_TEST
103 if (Tktest_Init(interp) == TCL_ERROR) {
104 return TCL_ERROR;
106 Tcl_StaticPackage(interp, "Tktest", Tktest_Init,
107 (Tcl_PackageInitProc *) NULL);
108 #endif /* TK_TEST */
112 * Call the init procedures for included packages. Each call should
113 * look like this:
115 * if (Mod_Init(interp) == TCL_ERROR) {
116 * return TCL_ERROR;
119 * where "Mod" is the name of the module.
123 * Call Tcl_CreateCommand for application-specific commands, if
124 * they weren't already created by the init procedures called above.
128 * Specify a user-specific startup file to invoke if the application
129 * is run interactively. Typically the startup file is "~/.apprc"
130 * where "app" is the name of the application. If this line is deleted
131 * then no user-specific startup file will be run under any conditions.
134 Tcl_SetVar(interp, "tcl_rcFileName", "~/.wishrc", TCL_GLOBAL_ONLY);
135 return TCL_OK;