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