/* ElWhip.c
*
*
* Created by Eric Pooch on 1/26/14.
* Copyright 2014 __MyCompanyName__. All rights reserved.
*
*/#ifdef LIBS_OLD// This is for 3.1 Libraries/Headers
#include<Desk.h>#else// This is for 3.5 Libraries/Headers
#define OLDROUTINENAMES 1#include<Events.h>#include<Types.h>#include<Devices.h>#include<QuickDraw.h>QDGlobalsqd;#endif#include<Fonts.h>#include<Windows.h>#include<Menus.h>#include<Dialogs.h>#include<Files.h>#include<Traps.h>#include<ToolUtils.h>#include<Memory.h>#include<SegLoad.h>#include<OSUtils.h>#include"arch/macos_debug.h"#include<string.h>#include<stdlib.h>#include"ElWhip.h"#include"test.h"/* GMac is used to hold the result of a SysEnvirons call. This makes
it convenient for any routine to check the environment. */SysEnvRecgMac;/* set up by Initialize *//* GHasWaitNextEvent is set at startup, and tells whether the WaitNextEvent
trap is available. If it is false, we know that we must call GetNextEvent. *///Boolean gHasWaitNextEvent; /* set up by Initialize */
/* GInBackground is maintained by our osEvent handling routines. Any part of
the program can check it to find out if it is currently in the background. */BooleangInBackground;/* maintained by Initialize and DoEvent *//* Here are declarations for all of the C routines. In MPW 3.0 we can use
actual prototypes for parameter type checking. */voidEventLoop(void);voidDoEvent(EventRecord*event);voidDoMenuCommand(longmenuResult);voidMemoryInit(void);voidMacintoshInit(void);voidRestart(void);voidTerminate(void);voidGetTERect(WindowPtrwindow,Rect*teRect);BooleanTrapAvailable(shorttNumber,TrapTypetType);voidAlertUser(void);/* Define HiWrd and LoWrd macros for efficiency. */#define HiWrd(aLong) (((aLong) >> 16) & 0xFFFF)#define LoWrd(aLong) ((aLong) & 0xFFFF)/* This routine is part of the MPW runtime library. This external
reference to it is done so that we can unload its segment, %A5Init. */externvoid_DataInit();intmain(void){OSErrerror=0;FILE*fildes;charbuff[255];UnloadSeg((Ptr)_DataInit);MemoryInit();MacintoshInit();/* initialize the program */test_init();EventLoop();/* call the main event loop */return0;}/* Get events forever, and handle them by calling DoEvent.
Get the events by calling WaitNextEvent, if it's available, otherwise
by calling GetNextEvent. Also call AdjustCursor each time through the loop. */#pragma segment MainvoidEventLoop(){BooleangotEvent;EventRecordevent;RgnHandlecursorRgn;do{/* use WNE if it is available *///if ( gHasWaitNextEvent )
//{
// gotEvent = WaitNextEvent(everyEvent, &event, MAXLONG, cursorRgn);
//} else
//{
SystemTask();gotEvent=GetNextEvent(everyEvent,&event);//}
if(gotEvent){/* Handle the event */DoEvent(&event);}test_poll();}while(true);/* loop forever; we quit via ExitToShell */}/*EventLoop*//* Do the right thing for an event. Determine what kind of event it is, and call
the appropriate routines. */voidDoEvent(EventRecord*event){shortpart,err;WindowPtrwindow;Booleanhit;charkey;switch(event->what){casemouseDown:part=FindWindow(event->where,&window);switch(part){caseinMenuBar:/* process a mouse menu command (if any) */DoMenuCommand(MenuSelect(event->where));break;caseinSysWindow:/* let the system handle the mouseDown */SystemClick(event,window);break;}break;casekeyDown:caseautoKey:/* check for menukey equivalents */key=event->message&charCodeMask;if(event->modifiers&cmdKey)/* Command key down */{if(event->what==keyDown){DoMenuCommand(MenuKey(key));}}break;casekOSEvent:/* 1.02 - must BitAND with 0x0FF to get only low byte */switch((event->message>>24)&0x0FF){/* high byte of message */casekSuspendResumeMessage:/* suspend/resume is als