1*549b59edSchristos /* $NetBSD: tkAppInit.c,v 1.2 2021/08/14 16:14:50 christos Exp $ */
24e6df137Slukem
32de962bdSlukem /*
42de962bdSlukem * tkXAppInit.c --
52de962bdSlukem *
62de962bdSlukem * Provides a default version of the Tcl_AppInit procedure for use with
72de962bdSlukem * applications built with Extended Tcl and Tk on Unix systems. This is based
82de962bdSlukem * on the the UCB Tk file tkAppInit.c
92de962bdSlukem *-----------------------------------------------------------------------------
102de962bdSlukem * Copyright 1991-1996 Karl Lehenbauer and Mark Diekhans.
112de962bdSlukem *
122de962bdSlukem * Permission to use, copy, modify, and distribute this software and its
132de962bdSlukem * documentation for any purpose and without fee is hereby granted, provided
142de962bdSlukem * that the above copyright notice appear in all copies. Karl Lehenbauer and
152de962bdSlukem * Mark Diekhans make no representations about the suitability of this
162de962bdSlukem * software for any purpose. It is provided "as is" without express or
172de962bdSlukem * implied warranty.
182de962bdSlukem *-----------------------------------------------------------------------------
19d11b170bStron * $OpenLDAP$
202de962bdSlukem *-----------------------------------------------------------------------------
212de962bdSlukem */
222de962bdSlukem
232de962bdSlukem #include "tclExtend.h"
242de962bdSlukem #include "tk.h"
252de962bdSlukem
262de962bdSlukem /*
272de962bdSlukem * The following variable is a special hack that insures the tcl
282de962bdSlukem * version of matherr() is used when linking against shared libraries
292de962bdSlukem * Even if matherr is not used on this system, there is a dummy version
302de962bdSlukem * in libtcl.
312de962bdSlukem */
322de962bdSlukem EXTERN int matherr ();
332de962bdSlukem int (*tclDummyMathPtr)() = matherr;
342de962bdSlukem
352de962bdSlukem
362de962bdSlukem /*-----------------------------------------------------------------------------
372de962bdSlukem * main --
382de962bdSlukem *
392de962bdSlukem * This is the main program for the application.
402de962bdSlukem *-----------------------------------------------------------------------------
412de962bdSlukem */
422de962bdSlukem #ifdef __cplusplus
432de962bdSlukem int
main(int argc,char ** argv)442de962bdSlukem main (int argc,
452de962bdSlukem char **argv)
462de962bdSlukem #else
472de962bdSlukem int
482de962bdSlukem main (argc, argv)
492de962bdSlukem int argc;
502de962bdSlukem char **argv;
512de962bdSlukem #endif
522de962bdSlukem {
532de962bdSlukem #ifdef USE_TCLX
542de962bdSlukem TkX_Main(argc, argv, Tcl_AppInit);
552de962bdSlukem #else
562de962bdSlukem Tk_Main(argc, argv, Tcl_AppInit);
572de962bdSlukem #endif
582de962bdSlukem return 0; /* Needed only to prevent compiler warning. */
592de962bdSlukem }
602de962bdSlukem
612de962bdSlukem /*-----------------------------------------------------------------------------
622de962bdSlukem * Tcl_AppInit --
632de962bdSlukem *
642de962bdSlukem * This procedure performs application-specific initialization. Most
652de962bdSlukem * applications, especially those that incorporate additional packages, will
662de962bdSlukem * have their own version of this procedure.
672de962bdSlukem *
682de962bdSlukem * Results:
692de962bdSlukem * Returns a standard Tcl completion code, and leaves an error message in
702de962bdSlukem * interp->result if an error occurs.
712de962bdSlukem *-----------------------------------------------------------------------------
722de962bdSlukem */
732de962bdSlukem #ifdef __cplusplus
742de962bdSlukem int
Tcl_AppInit(Tcl_Interp * interp)752de962bdSlukem Tcl_AppInit (Tcl_Interp *interp)
762de962bdSlukem #else
772de962bdSlukem int
782de962bdSlukem Tcl_AppInit (interp)
792de962bdSlukem Tcl_Interp *interp;
802de962bdSlukem #endif
812de962bdSlukem {
822de962bdSlukem if (Tcl_Init (interp) == TCL_ERROR) {
832de962bdSlukem return TCL_ERROR;
842de962bdSlukem }
852de962bdSlukem #ifdef USE_TCLX
862de962bdSlukem if (Tclx_Init(interp) == TCL_ERROR) {
872de962bdSlukem return TCL_ERROR;
882de962bdSlukem }
892de962bdSlukem Tcl_StaticPackage(interp, "Tclx", Tclx_Init, Tclx_SafeInit);
902de962bdSlukem #endif
912de962bdSlukem if (Tk_Init(interp) == TCL_ERROR) {
922de962bdSlukem return TCL_ERROR;
932de962bdSlukem }
942de962bdSlukem Tcl_StaticPackage(interp, "Tk", Tk_Init, (Tcl_PackageInitProc *) NULL);
952de962bdSlukem #ifdef USE_TCLX
962de962bdSlukem if (Tkx_Init(interp) == TCL_ERROR) {
972de962bdSlukem return TCL_ERROR;
982de962bdSlukem }
992de962bdSlukem Tcl_StaticPackage(interp, "Tkx", Tkx_Init, (Tcl_PackageInitProc *) NULL);
1002de962bdSlukem #endif
1012de962bdSlukem
1022de962bdSlukem if (Ldaptcl_Init(interp) == TCL_ERROR) {
1032de962bdSlukem return TCL_ERROR;
1042de962bdSlukem }
1052de962bdSlukem Tcl_StaticPackage(interp, "Ldaptcl", Ldaptcl_Init,
1062de962bdSlukem (Tcl_PackageInitProc *) NULL);
1072de962bdSlukem
1082de962bdSlukem /*
1092de962bdSlukem * Call Tcl_CreateCommand for application-specific commands, if
1102de962bdSlukem * they weren't already created by the init procedures called above.
1112de962bdSlukem */
1122de962bdSlukem
1132de962bdSlukem /*
1142de962bdSlukem * Specify a user-specific startup file to invoke if the application
1152de962bdSlukem * is run interactively. Typically the startup file is "~/.apprc"
1162de962bdSlukem * where "app" is the name of the application. If this line is deleted
1172de962bdSlukem * then no user-specific startup file will be run under any conditions.
1182de962bdSlukem */
1192de962bdSlukem Tcl_SetVar(interp, "tcl_rcFileName", "~/.wishxrc", TCL_GLOBAL_ONLY);
1202de962bdSlukem return TCL_OK;
1212de962bdSlukem }
122