[37] | 1 | /* |
---|
| 2 | * tkAppInit.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 | * Copyright (c) 1994-1997 Sun Microsystems, Inc. |
---|
| 9 | * |
---|
| 10 | * See the file "license.terms" for information on usage and redistribution |
---|
| 11 | * of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
---|
| 12 | * |
---|
| 13 | * RCS: @(#) $Id: tkAppInit.c,v 1.7 2002/06/21 20:24:29 dgp Exp $ |
---|
| 14 | */ |
---|
| 15 | |
---|
| 16 | #include "tk.h" |
---|
| 17 | #include "locale.h" |
---|
| 18 | |
---|
| 19 | #ifdef TK_TEST |
---|
| 20 | extern int Tktest_Init _ANSI_ARGS_((Tcl_Interp *interp)); |
---|
| 21 | #endif /* TK_TEST */ |
---|
| 22 | |
---|
| 23 | /* |
---|
| 24 | *---------------------------------------------------------------------- |
---|
| 25 | * |
---|
| 26 | * main -- |
---|
| 27 | * |
---|
| 28 | * This is the main program for the application. |
---|
| 29 | * |
---|
| 30 | * Results: |
---|
| 31 | * None: Tk_Main never returns here, so this procedure never |
---|
| 32 | * returns either. |
---|
| 33 | * |
---|
| 34 | * Side effects: |
---|
| 35 | * Whatever the application does. |
---|
| 36 | * |
---|
| 37 | *---------------------------------------------------------------------- |
---|
| 38 | */ |
---|
| 39 | |
---|
| 40 | int |
---|
| 41 | main(argc, argv) |
---|
| 42 | int argc; /* Number of command-line arguments. */ |
---|
| 43 | char **argv; /* Values of command-line arguments. */ |
---|
| 44 | { |
---|
| 45 | /* |
---|
| 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. |
---|
| 50 | */ |
---|
| 51 | |
---|
| 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)); |
---|
| 56 | |
---|
| 57 | /* |
---|
| 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() |
---|
| 61 | */ |
---|
| 62 | |
---|
| 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 |
---|
| 67 | |
---|
| 68 | Tk_Main(argc, argv, TK_LOCAL_APPINIT); |
---|
| 69 | return 0; /* Needed only to prevent compiler warning. */ |
---|
| 70 | } |
---|
| 71 | |
---|
| 72 | /* |
---|
| 73 | *---------------------------------------------------------------------- |
---|
| 74 | * |
---|
| 75 | * Tcl_AppInit -- |
---|
| 76 | * |
---|
| 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. |
---|
| 80 | * |
---|
| 81 | * Results: |
---|
| 82 | * Returns a standard Tcl completion code, and leaves an error |
---|
| 83 | * message in the interp's result if an error occurs. |
---|
| 84 | * |
---|
| 85 | * Side effects: |
---|
| 86 | * Depends on the startup script. |
---|
| 87 | * |
---|
| 88 | *---------------------------------------------------------------------- |
---|
| 89 | */ |
---|
| 90 | |
---|
| 91 | int |
---|
| 92 | Tcl_AppInit(interp) |
---|
| 93 | Tcl_Interp *interp; /* Interpreter for application. */ |
---|
| 94 | { |
---|
| 95 | if (Tcl_Init(interp) == TCL_ERROR) { |
---|
| 96 | return TCL_ERROR; |
---|
| 97 | } |
---|
| 98 | if (Tk_Init(interp) == TCL_ERROR) { |
---|
| 99 | return TCL_ERROR; |
---|
| 100 | } |
---|
| 101 | Tcl_StaticPackage(interp, "Tk", Tk_Init, Tk_SafeInit); |
---|
| 102 | #ifdef TK_TEST |
---|
| 103 | if (Tktest_Init(interp) == TCL_ERROR) { |
---|
| 104 | return TCL_ERROR; |
---|
| 105 | } |
---|
| 106 | Tcl_StaticPackage(interp, "Tktest", Tktest_Init, |
---|
| 107 | (Tcl_PackageInitProc *) NULL); |
---|
| 108 | #endif /* TK_TEST */ |
---|
| 109 | |
---|
| 110 | |
---|
| 111 | /* |
---|
| 112 | * Call the init procedures for included packages. Each call should |
---|
| 113 | * look like this: |
---|
| 114 | * |
---|
| 115 | * if (Mod_Init(interp) == TCL_ERROR) { |
---|
| 116 | * return TCL_ERROR; |
---|
| 117 | * } |
---|
| 118 | * |
---|
| 119 | * where "Mod" is the name of the module. |
---|
| 120 | */ |
---|
| 121 | |
---|
| 122 | /* |
---|
| 123 | * Call Tcl_CreateCommand for application-specific commands, if |
---|
| 124 | * they weren't already created by the init procedures called above. |
---|
| 125 | */ |
---|
| 126 | |
---|
| 127 | /* |
---|
| 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. |
---|
| 132 | */ |
---|
| 133 | |
---|
| 134 | Tcl_SetVar(interp, "tcl_rcFileName", "~/.wishrc", TCL_GLOBAL_ONLY); |
---|
| 135 | return TCL_OK; |
---|
| 136 | } |
---|