/* File: Topograph.c */ /**************************************************************** Topograph - A function browser Copyright (C) 1996 Marc Culler culler@math.uic.edu Department of Mathematics (M/C 249) University of Illinois at Chicago 851 S. Morgan St. Chicago, IL 60607-7045 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ******************************************************************/ #include "Topograph.h" #include /* Defined in CP.c */ extern struct CPMessage CPmsg; /* Our standard io window */ char __stdiowin[]= "CON:15/50/640/200/Topograph"; char __stdiov37[]= "/AUTO/CLOSE/WAIT/SIMPLE"; long __oslibversion = 37; char notice[] = "\n\ Topograph version 1.1 Copyright \251 1996 Marc Culler\n\n\ ====================================================\n\ | Topograph 1.1 comes with ABSOLUTELY NO WARRANTY. |\n\ | This is free software which can be redistributed |\n\ | under the terms of the GNU General Public License. |\n\ | See the accompanying documentation for details. |\n\ ====================================================\n\n"; /* Defined in this module */ int main(int argc, char *argv[]); /* Defined in graphtask.c */ extern void __saveds grapher(void); extern void graphMessage(int command); /* Defined in UI.c */ extern int openUI(ULONG *CPSignal, ULONG *graphSignal); extern void closeUI(void); extern int bailOut(char *userMessage); /* Defined in CP.c */ extern void CP_displayDomain(void); extern void CP_displayRange(void); extern void CP_buttons(int flags); extern void CP_menusOff(void); extern void CP_menusOn(void); /* Defined in CPEvents.c */ extern BOOL processCPIDCMP(void); /* Defined in graphevents.c */ extern void processGraphIDCMP(void); /* Defined in parseIO.c */ extern BOOL getFunction(char *); extern void freeFunction(void); int main(int argc, char *argv[]){ struct WBStartup *startupMsg; struct MsgPort *rexxPort, *graphReplyPort; struct Message *rexxMsg; struct Task *graphTask; ULONG CPIDCMPSignal, graphIDCMPSignal, graphReplySignal, rexxSignal, signals; BOOL doingFine = TRUE; if (FindPort("Topograph") != NULL) return bailOut("Topograph is already running."); /* Process Arguments */ if (argc == 0){ /* Workbench startup */ startupMsg = (struct WBStartup *)argv; /*Should check for tooltypes here */ } if (rexxPort = CreateMsgPort()){ rexxPort->mp_Node.ln_Name = "Topograph"; rexxPort->mp_Node.ln_Pri = 0; AddPort(rexxPort); rexxSignal = 1L << rexxPort->mp_SigBit; } graphReplyPort = CreateMsgPort(); if (graphReplyPort == NULL) return bailOut("Could not open message port."); else CPmsg.message.mn_ReplyPort = graphReplyPort; graphReplySignal = 1L << graphReplyPort->mp_SigBit; /* Launch the graphTask. */ graphTask = CreateTask("Topograph_Graph",0,grapher,10000); if (openUI(&CPIDCMPSignal,&graphIDCMPSignal) == RETURN_WARN) exit(RETURN_WARN); /* If we don't have a function from the args: */ CP_displayDomain(); CP_displayRange(); CP_buttons(0L); CP_menusOff(); if (getFunction(notice) == TRUE){ graphMessage(NEWFUNCTION_CMD); /* The main event loop. */ while (doingFine){ signals = Wait(CPIDCMPSignal | graphIDCMPSignal); if (signals & CPIDCMPSignal) doingFine = processCPIDCMP(); if (signals & graphIDCMPSignal) processGraphIDCMP(); } } graphMessage(QUIT_CMD); freeFunction(); /* Destroy the graphTask. */ Forbid(); DeleteTask(graphTask); Permit(); closeUI(); if (graphReplyPort) DeleteMsgPort(graphReplyPort); if (rexxPort){ RemPort(rexxPort); while (rexxMsg = GetMsg(rexxPort)) ReplyMsg(rexxMsg); DeleteMsgPort(rexxPort); } exit(RETURN_OK); }