home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / usr / share / tcltk / tk8.5 / tkAppInit.c < prev    next >
Encoding:
C/C++ Source or Header  |  2009-11-17  |  3.8 KB  |  144 lines

  1. /*
  2.  * tkAppInit.c --
  3.  *
  4.  *    Provides a default version of the Tcl_AppInit procedure for use in
  5.  *    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 of
  11.  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  12.  *
  13.  * RCS: @(#) $Id: tkAppInit.c,v 1.8 2007/02/22 13:56:33 dkf 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 returns
  32.  *    either.
  33.  *
  34.  * Side effects:
  35.  *    Whatever the application does.
  36.  *
  37.  *----------------------------------------------------------------------
  38.  */
  39.  
  40. int
  41. main(
  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 function by
  47.      * using a #define of TCL_LOCAL_APPINIT instead of rewriting this entire
  48.      * file. The #if checks for that #define and uses Tcl_AppInit if it
  49.      * 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. Most
  78.  *    applications, especially those that incorporate additional packages,
  79.  *    will have their own version of this procedure.
  80.  *
  81.  * Results:
  82.  *    Returns a standard Tcl completion code, and leaves an error message in
  83.  *    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(
  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.      * Call the init procedures for included packages. Each call should look
  112.      * like this:
  113.      *
  114.      * if (Mod_Init(interp) == TCL_ERROR) {
  115.      *     return TCL_ERROR;
  116.      * }
  117.      *
  118.      * where "Mod" is the name of the module.
  119.      */
  120.  
  121.     /*
  122.      * Call Tcl_CreateCommand for application-specific commands, if they
  123.      * weren't already created by the init procedures called above.
  124.      */
  125.  
  126.     /*
  127.      * Specify a user-specific startup file to invoke if the application is
  128.      * run interactively. Typically the startup file is "~/.apprc" where "app"
  129.      * is the name of the application. If this line is deleted then no user-
  130.      * -specific startup file will be run under any conditions.
  131.      */
  132.  
  133.     Tcl_SetVar(interp, "tcl_rcFileName", "~/.wishrc", TCL_GLOBAL_ONLY);
  134.     return TCL_OK;
  135. }
  136.  
  137. /*
  138.  * Local Variables:
  139.  * mode: c
  140.  * c-basic-offset: 4
  141.  * fill-column: 78
  142.  * End:
  143.  */
  144.