home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tkisrc04.zip / tcl / os2 / tclAppInit.c < prev    next >
C/C++ Source or Header  |  1998-08-07  |  3KB  |  122 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-1996 Sun Microsystems, Inc.
  9.  * Copyright (c) 1996-1997 Illya Vaes
  10.  *
  11.  * See the file "license.terms" for information on usage and redistribution
  12.  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  13.  */
  14.  
  15.  
  16. #include "tcl.h"
  17. #include <locale.h>
  18.  
  19. /*
  20.  * The following variable is a special hack that is needed in order for
  21.  * Sun shared libraries to be used for Tcl.
  22.  */
  23. extern int _matherr();
  24. int *tclDummyMathPtr = (int *) _matherr;
  25.  
  26. #ifdef TCL_TEST
  27. EXTERN int        Tcltest_Init _ANSI_ARGS_((Tcl_Interp *interp));
  28. #endif /* TCL_TEST */
  29.  
  30. /*
  31.  *----------------------------------------------------------------------
  32.  *
  33.  * main --
  34.  *
  35.  *    This is the main program for the application.
  36.  *
  37.  * Results:
  38.  *    None: Tcl_Main never returns here, so this procedure never
  39.  *    returns either.
  40.  *
  41.  * Side effects:
  42.  *    Whatever the application does.
  43.  *
  44.  *----------------------------------------------------------------------
  45.  */
  46.  
  47. int
  48. main(argc, argv)
  49.     int argc;            /* Number of command-line arguments. */
  50.     char **argv;        /* Values of command-line arguments. */
  51. {
  52.     /*
  53.      * Set up the default locale.
  54.      */
  55.     setlocale(LC_ALL, "");
  56.  
  57.     Tcl_Main(argc, argv, Tcl_AppInit);
  58.     return 0;            /* Needed only to prevent compiler warning. */
  59. }
  60.  
  61. /*
  62.  *----------------------------------------------------------------------
  63.  *
  64.  * Tcl_AppInit --
  65.  *
  66.  *    This procedure performs application-specific initialization.
  67.  *    Most applications, especially those that incorporate additional
  68.  *    packages, will have their own version of this procedure.
  69.  *
  70.  * Results:
  71.  *    Returns a standard Tcl completion code, and leaves an error
  72.  *    message in interp->result if an error occurs.
  73.  *
  74.  * Side effects:
  75.  *    Depends on the startup script.
  76.  *
  77.  *----------------------------------------------------------------------
  78.  */
  79.  
  80. int
  81. Tcl_AppInit(interp)
  82.     Tcl_Interp *interp;        /* Interpreter for application. */
  83. {
  84.     if (Tcl_Init(interp) == TCL_ERROR) {
  85.     return TCL_ERROR;
  86.     }
  87.  
  88. #ifdef TCL_TEST
  89.     if (Tcltest_Init(interp) == TCL_ERROR) {
  90.     return TCL_ERROR;
  91.     }
  92.     Tcl_StaticPackage(interp, "Tcltest", Tcltest_Init,
  93.             (Tcl_PackageInitProc *) NULL);
  94. #endif /* TCL_TEST */
  95.  
  96.     /*
  97.      * Call the init procedures for included packages.  Each call should
  98.      * look like this:
  99.      *
  100.      * if (Mod_Init(interp) == TCL_ERROR) {
  101.      *     return TCL_ERROR;
  102.      * }
  103.      *
  104.      * where "Mod" is the name of the module.
  105.      */
  106.  
  107.     /*
  108.      * Call Tcl_CreateCommand for application-specific commands, if
  109.      * they weren't already created by the init procedures called above.
  110.      */
  111.  
  112.     /*
  113.      * Specify a user-specific startup file to invoke if the application
  114.      * is run interactively.  Typically the startup file is "~/.apprc"
  115.      * where "app" is the name of the application.  If this line is deleted
  116.      * then no user-specific startup file will be run under any conditions.
  117.      */
  118.  
  119.     Tcl_SetVar(interp, "tcl_rcFileName", "~/.tclshrc", TCL_GLOBAL_ONLY);
  120.     return TCL_OK;
  121. }
  122.