/* * tkAppInit.c -- * * Provides a default version of the Tcl_AppInit procedure for * use in wish and similar Tk-based applications. * * Copyright (c) 1993 The Regents of the University of California. * Copyright (c) 1994 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ /* # Copyright 1996 # Authors # Lakshmi Sastry # Computing and Information Systems Department # Rutherford Appleton Laboratory, Chilton, Didcot. OX11 0QX # lakshmi.sastry@rl.ac.uk # and # Venkat VSS Sastry # Department of Applied Mathematics and Operational Research # Cranfield University, RMCS Shrivenham, Swindon, SN6 8LA # sastry@rmcs.cran.ac.uk # Permission to use, copy, modify, and distribute this # software and its documentation for any purpose and without # fee is hereby granted, provided that this copyright # notice appears in all copies. # The authors, RAL, RMCS Shrivenham and Cranfield University # make no representations about the suitability of this # software for any purpose. It is provided "as is" without # express or implied warranty. Likewise they accept no responsibility # whatsoever for any public domain software modules used (which are # hereby acknowledged) in this software */ #include "tcl.h" #include "tk.h" Tcl_Interp * interp; int *inPipePtr; int PopMosaic( ClientData clientdata, Tcl_Interp *interp, int argc, char *argv[]) { int np; char nv[6]; char *vv; np = Tcl_CreatePipeline ( interp,argc-1, argv+1, &inPipePtr,NULL,NULL,NULL); sprintf(nv,"%d",inPipePtr[0]); vv= Tcl_SetVar(interp,argv[3],nv,TCL_LEAVE_ERR_MSG); Tcl_DetachPids(np,inPipePtr); interp->result =vv; } void ClearZombie (ClientData clientdata, Tcl_Interp *interp, int argc, char *argv[]) { Tcl_ReapDetachedProcs(); } /* * The following variable is a special hack that is needed in order for * Sun shared libraries to be used for Tcl. */ #ifdef NEED_MATHERR extern int matherr(); int *tclDummyMathPtr = (int *) matherr; #endif /* *---------------------------------------------------------------------- * * Tcl_AppInit -- * * This procedure performs application-specific initialization. * Most applications, especially those that incorporate additional * packages, will have their own version of this procedure. * * Results: * Returns a standard Tcl completion code, and leaves an error * message in interp->result if an error occurs. * * Side effects: * Depends on the startup script. * *---------------------------------------------------------------------- */ int Tcl_AppInit(interp) Tcl_Interp *interp; /* Interpreter for application. */ { Tk_Window mainwin; int done =0; mainwin = Tk_MainWindow(interp); if (Tcl_Init(interp) == TCL_ERROR) { return TCL_ERROR; } if (Tk_Init(interp) == TCL_ERROR) { return TCL_ERROR; } /* * Call the init procedures for included packages. Each call should * look like this: * * if (Mod_Init(interp) == TCL_ERROR) { * return TCL_ERROR; * } * * where "Mod" is the name of the module. */ /* * Call Tcl_CreateCommand for application-specific commands, if * they weren't already created by the init procedures called above. */ Tcl_CreateCommand(interp, "PopM", (Tcl_CmdProc *)PopMosaic,(ClientData )NULL, (Tcl_CmdDeleteProc *) NULL); Tcl_CreateCommand(interp, "ClZ", (Tcl_CmdProc *)ClearZombie,(ClientData )NULL, (Tcl_CmdDeleteProc *) NULL); /* * Specify a user-specific startup file to invoke if the application * is run interactively. Typically the startup file is "~/.apprc" * where "app" is the name of the application. If this line is deleted * then no user-specific startup file will be run under any conditions. */ tcl_RcFileName ="~/.myapprc"; return TCL_OK; } /* *---------------------------------------------------------------------- * * main -- * * This is the main program for the application. * * Results: * None: Tk_Main never returns here, so this procedure never * returns either. * * Side effects: * Whatever the application does. * *---------------------------------------------------------------------- */ int main(argc, argv) int argc; /* Number of command-line arguments. */ char **argv; /* Values of command-line arguments. */ { Tk_Main(argc, argv,Tcl_AppInit); return 0; /* Needed only to prevent compiler warning. */ }