home *** CD-ROM | disk | FTP | other *** search
/ Ultra Pack / UltraComputing Partner Applications.iso / SunLabs / tclTK / src / tcl7.4 / tclAppInit.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-08  |  2.7 KB  |  105 lines

  1. /* 
  2.  * tclAppInit.c --
  3.  *
  4.  *    Provides a default version of the main program and Tcl_AppInit
  5.  *    procedure for Tcl applications (without Tk).
  6.  *
  7.  * Copyright (c) 1993 The Regents of the University of California.
  8.  * Copyright (c) 1994-1995 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.  
  14. static char sccsid[] = "@(#) tclAppInit.c 1.13 95/06/08 10:55:54";
  15.  
  16. #include "tcl.h"
  17.  
  18. /*
  19.  * The following variable is a special hack that is needed in order for
  20.  * Sun shared libraries to be used for Tcl.
  21.  */
  22.  
  23. extern int matherr();
  24. int *tclDummyMathPtr = (int *) matherr;
  25.  
  26. /*
  27.  *----------------------------------------------------------------------
  28.  *
  29.  * main --
  30.  *
  31.  *    This is the main program for the application.
  32.  *
  33.  * Results:
  34.  *    None: Tcl_Main never returns here, so this procedure never
  35.  *    returns either.
  36.  *
  37.  * Side effects:
  38.  *    Whatever the application does.
  39.  *
  40.  *----------------------------------------------------------------------
  41.  */
  42.  
  43. int
  44. main(argc, argv)
  45.     int argc;            /* Number of command-line arguments. */
  46.     char **argv;        /* Values of command-line arguments. */
  47. {
  48.     Tcl_Main(argc, argv, Tcl_AppInit);
  49.     return 0;            /* Needed only to prevent compiler warning. */
  50. }
  51.  
  52. /*
  53.  *----------------------------------------------------------------------
  54.  *
  55.  * Tcl_AppInit --
  56.  *
  57.  *    This procedure performs application-specific initialization.
  58.  *    Most applications, especially those that incorporate additional
  59.  *    packages, will have their own version of this procedure.
  60.  *
  61.  * Results:
  62.  *    Returns a standard Tcl completion code, and leaves an error
  63.  *    message in interp->result if an error occurs.
  64.  *
  65.  * Side effects:
  66.  *    Depends on the startup script.
  67.  *
  68.  *----------------------------------------------------------------------
  69.  */
  70.  
  71. int
  72. Tcl_AppInit(interp)
  73.     Tcl_Interp *interp;        /* Interpreter for application. */
  74. {
  75.     if (Tcl_Init(interp) == TCL_ERROR) {
  76.     return TCL_ERROR;
  77.     }
  78.  
  79.     /*
  80.      * Call the init procedures for included packages.  Each call should
  81.      * look like this:
  82.      *
  83.      * if (Mod_Init(interp) == TCL_ERROR) {
  84.      *     return TCL_ERROR;
  85.      * }
  86.      *
  87.      * where "Mod" is the name of the module.
  88.      */
  89.  
  90.     /*
  91.      * Call Tcl_CreateCommand for application-specific commands, if
  92.      * they weren't already created by the init procedures called above.
  93.      */
  94.  
  95.     /*
  96.      * Specify a user-specific startup file to invoke if the application
  97.      * is run interactively.  Typically the startup file is "~/.apprc"
  98.      * where "app" is the name of the application.  If this line is deleted
  99.      * then no user-specific startup file will be run under any conditions.
  100.      */
  101.  
  102.     tcl_RcFileName = "~/.tclshrc";
  103.     return TCL_OK;
  104. }
  105.