1/* 2 * tkXAppInit.c -- 3 * 4 * Provides a default version of the Tcl_AppInit procedure for use with 5 * applications built with Extended Tcl and Tk on Unix systems. This is based 6 * on the the UCB Tk file tkAppInit.c 7 *----------------------------------------------------------------------------- 8 * Copyright 1991-1996 Karl Lehenbauer and Mark Diekhans. 9 * 10 * Permission to use, copy, modify, and distribute this software and its 11 * documentation for any purpose and without fee is hereby granted, provided 12 * that the above copyright notice appear in all copies. Karl Lehenbauer and 13 * Mark Diekhans make no representations about the suitability of this 14 * software for any purpose. It is provided "as is" without express or 15 * implied warranty. 16 *----------------------------------------------------------------------------- 17 * $OpenLDAP$ 18 *----------------------------------------------------------------------------- 19 */ 20 21#include "tclExtend.h" 22#include "tk.h" 23 24/* 25 * The following variable is a special hack that insures the tcl 26 * version of matherr() is used when linking against shared libraries 27 * Even if matherr is not used on this system, there is a dummy version 28 * in libtcl. 29 */ 30EXTERN int matherr (); 31int (*tclDummyMathPtr)() = matherr; 32 33 34/*----------------------------------------------------------------------------- 35 * main -- 36 * 37 * This is the main program for the application. 38 *----------------------------------------------------------------------------- 39 */ 40#ifdef __cplusplus 41int 42main (int argc, 43 char **argv) 44#else 45int 46main (argc, argv) 47 int argc; 48 char **argv; 49#endif 50{ 51#ifdef USE_TCLX 52 TkX_Main(argc, argv, Tcl_AppInit); 53#else 54 Tk_Main(argc, argv, Tcl_AppInit); 55#endif 56 return 0; /* Needed only to prevent compiler warning. */ 57} 58 59/*----------------------------------------------------------------------------- 60 * Tcl_AppInit -- 61 * 62 * This procedure performs application-specific initialization. Most 63 * applications, especially those that incorporate additional packages, will 64 * have their own version of this procedure. 65 * 66 * Results: 67 * Returns a standard Tcl completion code, and leaves an error message in 68 * interp->result if an error occurs. 69 *----------------------------------------------------------------------------- 70 */ 71#ifdef __cplusplus 72int 73Tcl_AppInit (Tcl_Interp *interp) 74#else 75int 76Tcl_AppInit (interp) 77 Tcl_Interp *interp; 78#endif 79{ 80 if (Tcl_Init (interp) == TCL_ERROR) { 81 return TCL_ERROR; 82 } 83#ifdef USE_TCLX 84 if (Tclx_Init(interp) == TCL_ERROR) { 85 return TCL_ERROR; 86 } 87 Tcl_StaticPackage(interp, "Tclx", Tclx_Init, Tclx_SafeInit); 88#endif 89 if (Tk_Init(interp) == TCL_ERROR) { 90 return TCL_ERROR; 91 } 92 Tcl_StaticPackage(interp, "Tk", Tk_Init, (Tcl_PackageInitProc *) NULL); 93#ifdef USE_TCLX 94 if (Tkx_Init(interp) == TCL_ERROR) { 95 return TCL_ERROR; 96 } 97 Tcl_StaticPackage(interp, "Tkx", Tkx_Init, (Tcl_PackageInitProc *) NULL); 98#endif 99 100 if (Ldaptcl_Init(interp) == TCL_ERROR) { 101 return TCL_ERROR; 102 } 103 Tcl_StaticPackage(interp, "Ldaptcl", Ldaptcl_Init, 104 (Tcl_PackageInitProc *) NULL); 105 106 /* 107 * Call Tcl_CreateCommand for application-specific commands, if 108 * they weren't already created by the init procedures called above. 109 */ 110 111 /* 112 * Specify a user-specific startup file to invoke if the application 113 * is run interactively. Typically the startup file is "~/.apprc" 114 * where "app" is the name of the application. If this line is deleted 115 * then no user-specific startup file will be run under any conditions. 116 */ 117 Tcl_SetVar(interp, "tcl_rcFileName", "~/.wishxrc", TCL_GLOBAL_ONLY); 118 return TCL_OK; 119} 120