home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / devel / tcl / tclx7_31.z / tclx7_31 / tcldev / tclX7.3a-p1 / src / tclXAppInit.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-15  |  4.4 KB  |  123 lines

  1. /* 
  2.  * tclXAppInit.c --
  3.  *
  4.  *      Provides a default version of the Tcl_AppInit procedure for use with
  5.  *      applications built with Extended Tcl.  This is based on the the UCB
  6.  *      Tcl file tclAppInit.c
  7.  *
  8.  *-----------------------------------------------------------------------------
  9.  * Copyright 1991-1993 Karl Lehenbauer and Mark Diekhans.
  10.  *
  11.  * Permission to use, copy, modify, and distribute this software and its
  12.  * documentation for any purpose and without fee is hereby granted, provided
  13.  * that the above copyright notice appear in all copies.  Karl Lehenbauer and
  14.  * Mark Diekhans make no representations about the suitability of this
  15.  * software for any purpose.  It is provided "as is" without express or
  16.  * implied warranty.
  17.  *-----------------------------------------------------------------------------
  18.  * $Id: tclXAppInit.c,v 3.2 1993/12/15 09:28:07 markd Exp $
  19.  *-----------------------------------------------------------------------------
  20.  * Copyright (c) 1993 The Regents of the University of California.
  21.  * All rights reserved.
  22.  *
  23.  * Permission is hereby granted, without written agreement and without
  24.  * license or royalty fees, to use, copy, modify, and distribute this
  25.  * software and its documentation for any purpose, provided that the
  26.  * above copyright notice and the following two paragraphs appear in
  27.  * all copies of this software.
  28.  * 
  29.  * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
  30.  * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
  31.  * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
  32.  * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  33.  *
  34.  * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
  35.  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
  36.  * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
  37.  * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
  38.  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  39.  */
  40.  
  41. #include "tclExtend.h"
  42. #include <math.h>
  43.  
  44. /*
  45.  * The following variable is a special hack that allows applications
  46.  * to be linked using the procedure "main" from the Tcl library.  The
  47.  * variable generates a reference to "main", which causes main to
  48.  * be brought in from the library (and all of Tcl with it).
  49.  */
  50.  
  51. EXTERN int main _ANSI_ARGS_((int     argc,
  52.                              char  **argv));
  53. int (*tclXDummyMainPtr)() = (int (*)()) main;
  54.  
  55. /*
  56.  * The following variable is a special hack that insures the tcl
  57.  * version of matherr() is used when linking against shared libraries.
  58.  * Only define if matherr is used on this system.
  59.  */
  60.  
  61. #if defined(DOMAIN) && defined(SING)
  62. EXTERN int matherr _ANSI_ARGS_((struct exception *));
  63. int (*tclDummyMathPtr)() = (int (*)()) matherr;
  64. #endif
  65.  
  66.  
  67. /*
  68.  *----------------------------------------------------------------------
  69.  *
  70.  * Tcl_AppInit --
  71.  *
  72.  *      This procedure performs application-specific initialization.
  73.  *      Most applications, especially those that incorporate additional
  74.  *      packages, will have their own version of this procedure.
  75.  *
  76.  * Results:
  77.  *      Returns a standard Tcl completion code, and leaves an error
  78.  *      message in interp->result if an error occurs.
  79.  *
  80.  * Side effects:
  81.  *      Depends on the startup script.
  82.  *
  83.  *----------------------------------------------------------------------
  84.  */
  85.  
  86. int
  87. Tcl_AppInit(interp)
  88.     Tcl_Interp *interp;         /* Interpreter for application. */
  89. {
  90.     /*
  91.      * Call the init procedures for included packages.  Each call should
  92.      * look like this:
  93.      *
  94.      * if (Mod_Init(interp) == TCL_ERROR) {
  95.      *     return TCL_ERROR;
  96.      * }
  97.      *
  98.      * where "Mod" is the name of the module.
  99.      */
  100.  
  101.     /*
  102.      * Add in Extended Tcl commands and source TclX initialization file.
  103.      */
  104.     if (TclX_Init (interp) == TCL_ERROR) {
  105.         return TCL_ERROR;
  106.     }
  107.  
  108.     /*
  109.      * Call Tcl_CreateCommand for application-specific commands, if
  110.      * they weren't already created by the init procedures called above.
  111.      */
  112.  
  113.     /*
  114.      * Specify a user-specific startup file to invoke if the application
  115.      * is run interactively.  Typically the startup file is "~/.apprc"
  116.      * where "app" is the name of the application.  If this line is deleted
  117.      * then no user-specific startup file will be run under any conditions.
  118.      */
  119.  
  120.     tcl_RcFileName = "~/.tclrc";
  121.     return TCL_OK;
  122. }
  123.