home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / languages / tcl / tk3.3b1 / tkAppInit.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-07-09  |  3.0 KB  |  93 lines

  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.  * All rights reserved.
  9.  *
  10.  * Permission is hereby granted, without written agreement and without
  11.  * license or royalty fees, to use, copy, modify, and distribute this
  12.  * software and its documentation for any purpose, provided that the
  13.  * above copyright notice and the following two paragraphs appear in
  14.  * all copies of this software.
  15.  * 
  16.  * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
  17.  * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
  18.  * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
  19.  * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  20.  *
  21.  * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
  22.  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
  23.  * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
  24.  * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
  25.  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  26.  */
  27.  
  28. #ifndef lint
  29. static char rcsid[] = "$Header: /user6/ouster/wish/RCS/tkAppInit.c,v 1.4 93/07/09 10:41:32 ouster Exp $ SPRITE (Berkeley)";
  30. #endif /* not lint */
  31.  
  32. #include "tk.h"
  33.  
  34. /*
  35.  * The variable below holds a startup script to be executed at the
  36.  * beginning of the application.
  37.  */
  38.  
  39. char initCmd[] =
  40. "if [file exists $tk_library/wish.tcl] {\n\
  41.     source $tk_library/wish.tcl\n\
  42. } else {\n\
  43.     set msg \"can't find $tk_library/wish.tcl; perhaps you need to\\n\"\n\
  44.     append msg \"install Tk or set your TK_LIBRARY environment \"\n\
  45.     append msg \"variable?\"\n\
  46.     error $msg\n\
  47. }";
  48.  
  49. /*
  50.  * The following variable is a special hack that allows applications
  51.  * to be linked using the procedure "main" from the Tk library.  The
  52.  * variable generates a reference to "main", which causes main to
  53.  * be brought in from the library (and all of Tk and Tcl with it).
  54.  */
  55.  
  56. extern int main();
  57. int *tclDummyMainPtr = (int *) main;
  58.  
  59. /*
  60.  *----------------------------------------------------------------------
  61.  *
  62.  * Tcl_AppInit --
  63.  *
  64.  *    This procedure performs application-specific initialization.
  65.  *    Most applications, especially those that incorporate additional
  66.  *    packages, will have their own version of this procedure.
  67.  *
  68.  * Results:
  69.  *    Returns a standard Tcl completion code, and leaves an error
  70.  *    message in interp->result if an error occurs.
  71.  *
  72.  * Side effects:
  73.  *    Depends on the startup script.
  74.  *
  75.  *----------------------------------------------------------------------
  76.  */
  77.  
  78. int
  79. Tcl_AppInit(interp)
  80.     Tcl_Interp *interp;        /* Interpreter for application. */
  81. {
  82.     /*
  83.      * Calls to init procedures for various included packages should
  84.      * appear below, if there are any included packages:
  85.      */
  86.  
  87.     /*
  88.      * Execute a start-up script.
  89.      */
  90.  
  91.     return Tcl_Eval(interp, initCmd);
  92. }
  93.