home *** CD-ROM | disk | FTP | other *** search
- // e_cgi_main.c
- // 14May97 e
-
- // a substitute MacOS pacifier and AppleEvent Handler for mosml cgi programs
-
- #include "os_mac.h"
- #include <signal.h>
-
- #define CRLF_TRANSLATE 1
-
- long next_eventchk_ticks;
- long gWaitTicksBG = 6; /* in ticks, should be 6..60 */
- long gWaitTicksFG = 1; /* in ticks, should be 1..15 */
- long gMaxSleep = 18;
-
- char *image_name = NULL;
- FSSpec appFSS;
-
- RgnHandle gCursorRgn;
-
- short interrupted = 0;
-
- char gReceivedAE = 0;
- Boolean gMadeAppFSS = false;
- Boolean gDoQuit = false;
- Boolean gInBackground = false;
- Boolean gHasAppleEvents = false;
- Boolean gAESuspn = false;
- AppleEvent gAEEvent;
- AppleEvent gAEReply;
-
- MenuRef f_menu, a_menu;
-
- // utils
-
- static void ParamText1( Str255 text )
- {
- ParamText( text, "\p", "\p", "\p" );
- }
-
- static void path_too_long_err( Str255 name )
- { ParamText( "\pPath to file \"", name, "\p\" is too long.", "\p" );
- SysBeep( 10 );
- StopAlert( ok_alertID, 0L );
- }
-
- void io_err( short io )
- { unsigned char errnostr[16];
- switch (io)
- { case wrPermErr : ParamText1( "\pCan't write file!" ); break;
- case dupFNErr : ParamText1( "\pDuplicate file name!" ); break;
- case fBsyErr : ParamText1( "\pFile is busy!" ); break;
- case vLckdErr : ParamText1( "\pVolume is locked!" ); break;
- case fLckdErr : ParamText1( "\pFile is locked!" ); break;
- case fnfErr : ParamText1( "\pFile not found!" ); break;
- case bdNamErr : ParamText1( "\pBad filename!" ); break;
- case ioErr : ParamText1( "\pIO transfer error!" ); break;
- case dskFulErr : ParamText1( "\pDisk full!" ); break;
- case dirFulErr : ParamText1( "\pDirectory full!" ); break;
- case mFulErr : ParamText1( "\pFile is too large for memory!" ); break;
-
- case -4101 : ParamText1( "\pNo printer selected. Use the Chooser." ); break;
- default : NumToString( io, errnostr );
- ParamText( "\pIO Error! Mac error number: ", errnostr, "\p", "\p" );
- break;
- }
- SysBeep( 10 );
- StopAlert( ok_alertID, 0L );
- }
-
- short getfullpath(
- short vRefNum,
- long dirID,
- Str255 fName,
- char *Path,
- short MaxLength,
- short warn )
- {
- char *p, *q;
- long len;
- CInfoPBRec block;
- Str255 directoryName;
-
- p = &Path[MaxLength];
- *--p = '\0';
-
- len = (unsigned char)fName[0];
- p -= len;
- if (p < Path) goto too_long;
- BlockMove( &fName[1], p, len );
-
- block.dirInfo.ioNamePtr = directoryName;
- block.dirInfo.ioDrParID = dirID;
-
- do
- { block.dirInfo.ioVRefNum = vRefNum;
- block.dirInfo.ioFDirIndex = -1;
- block.dirInfo.ioDrDirID = block.dirInfo.ioDrParID;
-
- if (PBGetCatInfoSync( &block ) != noErr) return 0;
- *--p = ':';
- len = (unsigned char)directoryName[0];
- p -= len;
- if (p < Path) goto too_long;
- BlockMove( &directoryName[1], p, len );
- } while ( block.dirInfo.ioDrDirID != fsRtDirID );
-
- q = Path;
- while (*p != '\0') *q++ = *p++;
- *q = '\0';
-
- return (short )( q - Path );
-
- too_long:
- if (warn) path_too_long_err( fName );
- return 0;
- }
-
- // ********************* events **********************
-
- long os_get_next_event( EventRecord *event )
- { long result = 0;
- if (1) // do_tasks()
- { beg_mf_time();
- result = (long)( gInBackground
- ? gWaitTicksBG
- : (long )( (gWaitTicksFG > gMaxSleep) ? gMaxSleep : gWaitTicksFG) );
- result = WaitNextEvent( everyEvent, event, result, gCursorRgn );
- end_mf_time();
- }
- return result;
- }
-
- long os_handle_event( EventRecord *event )
- {
- WindowPtr window;
- short theItem, theMenu;
-
- switch (event->what)
- {
- case keyDown:
- case autoKey:
- { unsigned char c = event->message & charCodeMask;
- if( (event->modifiers & cmdKey) != 0 && (c == 'q' || c == 'Q') )
- { gDoQuit = 1;
- os_quit();
- }
- break;
- }
-
- case mouseDown:
- if (FindWindow( event->where, &window ) == inMenuBar)
- {
- long menuChoice = MenuSelect( event->where );
- theItem = LoWord(menuChoice);
- theMenu = HiWord(menuChoice);
- if( theMenu == fileID && theItem == 1 )
- {
- gDoQuit = 1;
- os_quit();
- }
- else if( theMenu == appleID && theItem > 2 )
- {
- Str255 name;
- GetMenuItemText( a_menu, theItem, name );
- OpenDeskAcc( name );
- }
- //else SysBeep( 3 );
- HiliteMenu(0);
- }
- break;
-
- case kHighLevelEvent:
- AEProcessAppleEvent(event);
- if (gDoQuit) os_quit();
- break;
-
- default: ;
- }
- return 1;
- }
-
- void os_event_check( void )
- { EventRecord event;
- os_get_next_event( &event );
- os_handle_event( &event );
- #if USE_EVENTCHK_TIMER
- next_eventchk_ticks = 0;
- #else
- next_eventchk_ticks = LMGetTicks() + TicksBetweenEventChecks;
- #endif
- if ( interrupted ) { interrupted = 0; raise(SIGINT); }
- }
-
- // ********************* console **********************
-
- static void init_all(void);
-
- static short console_initialized = 0;
- static long handleSizeOut;
- static long stringSizeOut;
- static Handle the_output;
- static long stringSizeIn;
- static long stringUsedIn;
- static Handle the_input;
-
- #define osc_INIT_SIZE 4096
- #define osc_RESIZE_ADD 4096
-
- void os_quit()
- {
- #if ANSIquitP
- exit(0);
- #else
- #if USE_EVENTCHK_TIMER
- cancel_eck_timer();
- #endif
- ExitToShell();
- #endif
- }
-
- // stub
-
- int ecommand(unsigned char ***av)
- {
- #pragma unused( av )
- return 0;
- }
-
- WindowPeek os_console_new( unsigned char *name )
- {
- #pragma unused( name )
- WindowPeek wp;
- if( !console_initialized )
- { init_all();
- console_initialized = 1;
- }
- wp = (WindowPeek )NewHandle(osc_INIT_SIZE); // what a hack
- the_output = (Handle )wp;
- if( wp )
- {
- **(char **)wp = 0;
- handleSizeOut = osc_INIT_SIZE;
- stringSizeOut = 0;
- stringSizeIn = 0;
- stringUsedIn = 0;
- the_input = NULL;
- }
- return(wp);
- }
-
- long os_console_read_nohang( WindowPeek wp, unsigned char *ptr, long cnt )
- {
- #pragma unused(wp)
- long room;
- os_event_check();
- if( the_input == NULL ) cnt = 0;
- room = stringSizeIn - stringUsedIn;
- if( cnt > room ) cnt = room;
- if( cnt > 0 )
- {
- HLock( the_input );
- strncpy( (char *)ptr, &((char *)(*the_input))[stringUsedIn], cnt );
- stringUsedIn += cnt;
- HUnlock( the_input );
- }
- return cnt;
- }
-
- long os_console_write( WindowPeek wp, unsigned char *ptr, long cnt)
- {
- Handle h = (Handle )wp; // what a hack
- long room;
- // another hack to accommodate main()'s use of puts() to init console
- if( stringSizeOut == 0 && cnt == 2 && ptr[0] == ' ' && ptr[1] == '\r' )
- return 2;
- if( stringSizeOut + cnt > handleSizeOut )
- {
- SetHandleSize( h, stringSizeOut + cnt + osc_RESIZE_ADD );
- handleSizeOut = GetHandleSize( h );
- }
- room = handleSizeOut - stringSizeOut - 1;
- if( cnt > room ) cnt = room; // only if resize failed
- if( cnt > 0 )
- {
- HLock( h );
- strncpy( &((char *)(*h))[stringSizeOut], (char *)ptr, cnt );
- stringSizeOut += cnt;
- ((char *)(*h))[stringSizeOut] = 0;
- HUnlock( h );
- }
- return cnt;
- }
-
- /*--------------------------------------------------------------------------*/
-
- /* Used to check for any unread required parameters. Returns true if we
- ** missed at least one. */
-
- static Boolean MissedAnyParameters(AppleEvent *message)
- {
- OSErr err;
- DescType ignoredActualType;
- AEKeyword missedKeyword;
- Size ignoredActualSize;
- EventRecord event;
-
- err = AEGetAttributePtr( // SEE IF PARAMETERS ARE ALL USED UP.
- message, // AppleEvent to check.
- keyMissedKeywordAttr, // Look for unread parameters.
- typeWildCard, // So we can see what type we missed, if any.
- &ignoredActualType, // What it would have been if not coerced.
- (Ptr)&missedKeyword, // Data area. (Keyword not handled.)
- sizeof(missedKeyword),// Size of data area.
- &ignoredActualSize // Actual data size.
- );
- /* No error means that we found some unused parameters. */
- if (err == noErr)
- {
- event.message = *(long *) &ignoredActualType;
- event.where = *(Point *) &missedKeyword;
- err = errAEEventNotHandled;
- }
- /* errAEDescNotFound means that there are no more parameters. If we get
- ** an error code other than that, flag it. */
- return(err != errAEDescNotFound);
- }
-
- static OSErr OpenDocEventHandler(AppleEvent *message, AppleEvent *reply, short mode)
- {
- #pragma unused( reply, mode )
- OSErr err;
- OSErr err2;
- AEDesc theDesc;
- FSSpec theFSS;
- short loop;
- long numFilesToOpen;
- AEKeyword ignoredKeyWord;
- DescType ignoredType;
- Size ignoredSize;
- char path[512];
- short w;
- FInfo theFInfo;
-
- theDesc.dataHandle = nil;
- /* Make sure disposing of the descriptors is okay in all cases.
- ** This will not be necessary after 7.0b3, since the calls that
- ** attempt to create the descriptors will nil automatically
- ** upon failure. */
-
- if ( (err = AEGetParamDesc( message, keyDirectObject, typeAEList, &theDesc )) != 0 )
- return(err);
-
- if ( ! MissedAnyParameters( message ) && !(err = AECountItems(&theDesc, &numFilesToOpen)))
- { /* We have numFilesToOpen that need opening, as either a window
- ** or to be printed. Go to it... */
-
- for (loop = 1; ((loop <= numFilesToOpen) && (!err)); ++loop)
- { err = AEGetNthPtr(// GET NEXT IN THE LIST...
- &theDesc, // List of file names.
- loop, // Item # in the list.
- typeFSS, // Item is of type FSSpec.
- &ignoredKeyWord, // Returned keyword -- we know.
- &ignoredType, // Returned type -- we know.
- (Ptr)&theFSS, // Where to put the FSSpec info.
- sizeof(theFSS), // Size of the FSSpec info.
- &ignoredSize // Actual size -- we know.
- );
- if (err) break;
-
- FSpGetFInfo( &theFSS, &theFInfo );
- if ( theFInfo.fdType != 'TEXT' )
- {
- w = getfullpath( theFSS.vRefNum, theFSS.parID, theFSS.name, path, 511, 1 );
- if( theFInfo.fdType == 'BINA' && theFInfo.fdCreator == 'Moml' )
- {
- image_name = malloc( w + 1 );
- if( image_name ) strncpy( image_name, path, w + 1 );
- }
- else
- SysBeep( 3 );
- continue;
- }
- else SysBeep( 3 ); // err = errAEEventNotHandled;
- }
- }
- err2 = AEDisposeDesc(&theDesc);
- return(err ? err : err2);
- }
-
- static pascal OSErr DoAEOpenApplication( AppleEvent *message, AppleEvent *reply, long refcon )
- {
- #pragma unused( message, reply, refcon )
- //DebugStr( "\pDoAEOpenApplication" );
- return(noErr);
- }
-
- static pascal OSErr DoAEOpenDocuments( AppleEvent *message, AppleEvent *reply, long refcon )
- {
- #pragma unused( refcon )
- return( OpenDocEventHandler( message, reply, 0 ) ); /* 0 means regular open document */
- }
-
- static pascal OSErr DoAEPrintDocuments(AppleEvent *message, AppleEvent *reply, long refcon)
- {
- #pragma unused( message, reply, refcon )
- return(noErr);
- }
-
- static pascal OSErr DoAEQuitApplication( AppleEvent *message, AppleEvent *reply, long refcon )
- {
- #pragma unused( message, reply, refcon )
- gDoQuit = 1;
- return noErr;
- }
-
- static pascal OSErr DoAEwww2( AppleEvent *theAEEvent, AppleEvent *theAEReply, long *theRefCon)
- {
- #pragma unused( theAEEvent, theRefCon )
- OSErr theErr = noErr;
- //char ourScriptText[256];
-
- if( gAESuspn )
- {
- int i;
- char *p, c;
- Handle h = the_output; // what a hack
- HLock( h );
- p = *h;
- #if ( CRLF_TRANSLATE )
- for( i = 0; i < stringSizeOut; i++ )
- { c = p[i];
- if ( c == '\r' ) p[i] = '\n';
- else if( c == '\n' ) p[i] = '\r';
- }
- #endif
- /* */
- //sprintf( ourScriptText+1, "www: %x", *h );
- //ourScriptText[0] = strlen(ourScriptText+1);
- //DebugStr( (unsigned char *)ourScriptText );
- /* */
- theErr = AEPutParamPtr( theAEReply, keyDirectObject, typeChar, (Ptr)p, stringSizeOut+1);
- HUnlock( h );
- gAESuspn = 0;
- }
- return theErr;
- }
-
- #define ARG_SIZE 4096
- extern int e_setenv(const char *name, const char *text, int rewrite);
-
- static OSErr aeparm_to_env( AppleEvent *inEvent, AEKeyword kwrd, char *envname )
- {
- OSErr err = noErr;
- DescType theType;
- Size theSize;
- char theArg[ARG_SIZE];
-
- err = AEGetParamPtr(inEvent, kwrd, typeChar, &theType, theArg, ARG_SIZE, &theSize);
- if( theSize != 0 && theSize < ARG_SIZE )
- {
- theArg[theSize] = '\0';
- e_setenv( envname, theArg, 0 );
- }
- //else ???
- return err;
- }
-
- static OSErr aeparm_to_stdin( AppleEvent *inEvent, AEKeyword kwrd )
- {
- OSErr err = noErr;
- DescType theType;
- Size theSize;
- char theArg[ARG_SIZE];
-
- stringUsedIn = 0;
- the_input = NULL;
- err = AEGetParamPtr( inEvent, kwrd, typeChar, &theType, theArg, ARG_SIZE, &theSize );
- if( theSize == 0 )
- {
- stringSizeIn = 0;
- }
- else
- {
- the_input = NewHandle( theSize );
- if( the_input == NULL )
- {
- stringSizeIn = 0;
- }
- else
- { int i;
- char *p, c;
- p = *the_input;
- stringSizeIn = theSize;
- if( theSize <= ARG_SIZE )
- {
- HLock( the_input );
- strncpy( p, theArg, theSize );
- }
- else
- {
- HLock( the_input );
- err = AEGetParamPtr( inEvent, kwrd, typeChar, &theType, p, theSize, &theSize );
- // what if stringSizeIn != theSize ??
- }
- #if ( CRLF_TRANSLATE )
- for( i = 0; i < stringSizeIn; i++ )
- { c = p[i];
- if ( c == '\r' ) p[i] = '\n';
- else if( c == '\n' ) p[i] = '\r';
- }
- #endif
- HUnlock( the_input );
- sprintf( theArg, "%d", stringSizeIn );
- e_setenv( "CONTENT_LENGTH", theArg, 0 );
- }
- }
- return err;
- }
-
- static void cgi_get_app_name( void )
- {
- //unsigned char *CurApName = LMGetCurApName();
- ProcessInfoRec pir;
- ProcessSerialNumber psn;
- char path[512];
- short w;
-
- psn.highLongOfPSN = 0;
- psn.lowLongOfPSN = kCurrentProcess;
- pir.processInfoLength = sizeof(pir);
- pir.processName = 0;
- pir.processAppSpec = &appFSS;
- GetProcessInformation( &psn, &pir );
- w = getfullpath( appFSS.vRefNum, appFSS.parID, appFSS.name, path, 511, 1 );
- e_setenv( "PATH_TRANSLATED", path, 0 );
- if( strcmp( ".cgi", &path[w-4] ) == 0 && w < 510 )
- { // make image name from app name: app.cgi => app.image
- strcpy( &path[w-3], "image" );
- image_name = malloc( w + 3 );
- if( image_name ) strncpy( image_name, path, w + 3 );
- }
- gMadeAppFSS = true;
- }
-
- static pascal OSErr DoAEwww( AppleEvent *inEvent, AppleEvent *outReply, long *theRefCon)
- {
- #pragma unused( theRefCon )
- OSErr err = noErr;
-
- // env vars
- // missing: SERVER_SOFTWARE SERVER_PROTOCOL AUTH_TYPE REMOTE_IDENT
- // questionable: GATEWAY_INTERFACE PATH_TRANSLATED
- // wrong: REMOTE_HOST (can be same as REMOTE_ADDR if resolution turned off)
- // invented: REMOTE_PASS
-
- // SERVER_SOFTWARE = NCSA/1.5.2
- // SERVER_PROTOCOL = HTTP/1.0
- // GATEWAY_INTERFACE = CGI/1.1
-
- // create PATH_TRANSLATED and maybe set image_name
- cgi_get_app_name();
-
- // Path Arguments ('----') PATH_INFO
- // This the data following the '$' in a URL, but preceding the '?', if one is present.
- // This is a common method of passing arguments to a CGI.
- // Note that the path arguments in a UNIX server a delimited by a '/', not a '$'.
- // The '$' is a peculiarity of the Macintosh CGI "standard"
- err = aeparm_to_env( inEvent, '----', "PATH_INFO" );
-
- // Search Arguments ('kfor') QUERY_STRING
- // This is the data that follows the '?' in a URL, if any is present.
- // Search arguments
- err = aeparm_to_env( inEvent, 'kfor', "QUERY_STRING" );
-
- // Post Arguments ('post') -> std_in
- // The post parameter contains the data passed in the body of a POST request,
- // usually data from a form.
- err = aeparm_to_stdin( inEvent, 'post' );
-
- // Username ('user') REMOTE_USER
- // If the user supplied a username for authentication, this filed contains the name entered.
- err = aeparm_to_env( inEvent, 'user', "REMOTE_USER" );
-
- // Password ('pass') ???? AUTH_TYPE? REMOTE_IDENT?
- // The password the user entered, if authentication was required.
- err = aeparm_to_env( inEvent, 'pass', "REMOTE_PASS" );
-
- // Method ('meth') REQUEST_METHOD
- // The HTTP method that was used for the request, usually 'GET' or 'POST'.
- err = aeparm_to_env( inEvent, 'meth', "REQUEST_METHOD" );
-
- // Client Address ('addr') REMOTE_HOST -- but only if it's a host name?
- // The IP address or domain name of the client, depending on whether or not the
- // "Lookup Client Address with DNS" option is enabled, and the client has a DNS entry.
- err = aeparm_to_env( inEvent, 'addr', "REMOTE_HOST" );
-
- // Client IP ('Kcip') REMOTE_ADDR
- // The IP address of the client.
- err = aeparm_to_env( inEvent, 'Kcip', "REMOTE_ADDR" );
-
- // Server Name ('svnm') SERVER_NAME
- // The name of the web server.
- err = aeparm_to_env( inEvent, 'svnm', "SERVER_NAME" );
-
- // Server Port ('svpt') SERVER_PORT
- // The TCP port on which the server is listening for connections (usually 80)
- err = aeparm_to_env( inEvent, 'svpt', "SERVER_PORT" );
-
- // Script Name ('scnm') SCRIPT_NAME
- // This is the URL path to the CGI application. If the CGI is running as an action,
- // this parameter contains the path to the file specified by the URL.
- err = aeparm_to_env( inEvent, 'scnm', "SCRIPT_NAME" );
-
- // Referrer ('refr') HTTP_REFERER e.g., "http://208.146.140.3/html/cgiexamples.html"
- // The URL of the page that the user was on when she clicked on the CGI's URL.
- err = aeparm_to_env( inEvent, 'refr', "HTTP_REFERER" );
-
- // User Agent ('Agnt') HTTP_USER_AGENT e.g., "Mozilla/3.01 (Macintosh; U; PPC)"
- // The name of the client software, such as "Mozilla" for Netscape Navigator.
- err = aeparm_to_env( inEvent, 'Agnt', "HTTP_USER_AGENT" );
-
- // Content Type ('ctyp') CONTENT_TYPE
- // The MIME type of the POST data, if present.
- err = aeparm_to_env( inEvent, 'ctyp', "CONTENT_TYPE" );
-
- // Action ('Kact') ???? GATEWAY_INTERFACE?
- // The type of CGI that is being run, such as "CGI", "ACGI", "PREPROCESSOR", or
- // "POSTPROCESSOR". If the CGI is running as an action, this contains the name of the action.
- // Action name
- err = aeparm_to_env( inEvent, 'Kact', "GATEWAY_INTERFACE" );
-
- // Action Path ('Kapt') ???? punt?
- // When running as an action, this contains the path to the action.
- // If running as a CGI, this is identical to the Script Name ('scnm') parameter.
- //err = aeparm_to_env( inEvent, 'Kapt', "" );
- // We don't do anything with the Action Path.
-
- // Full Request ('Kfrq')
- // The entire text of the request as received by the server, with no processing whatsoever.
- // Full, unprocessed request (including the HTTP header)
- //err = aeparm_to_env( inEvent, 'Kfrq', "" );
- // We don't do anything with the Full Request.
-
- // From User ('frmu') ???? (obsolete)
- // If the HTTP header of the client request contained a "From:" field,
- // this parameter contains the information from that field,
- // usually the user's email address.
- //err = aeparm_to_env( inEvent, 'frmu', "" );
-
- // Connection ID ('Kcid')
- // A long integer identifying the connection corresponding to the CGI request.
- // This is the only parameter that is not typeChar. It's used for partial replies.
- // We don't do anything with the Connection ID.
-
- gAEEvent = *inEvent;
- gAEReply = *outReply;
- gAESuspn = 1;
- gReceivedAE = 1;
- return AESuspendTheCurrentEvent( inEvent );
- }
-
- OSErr finish_AEDoScript( void )
- {
- if( gAESuspn )
- {
- //int i;
- AEEventHandlerUPP upp = NewAEEventHandlerProc(DoAEwww2);
- OSErr err = AEResumeTheCurrentEvent( &gAEEvent, &gAEReply, upp, 0 );
- //if( gAESuspn && err == noErr )
- // for( i = 0; gAESuspn && i < 10; i++ ) os_event_check();
- return err;
- }
- return errAEEventNotHandled;
- }
-
- // ********************* init **********************
-
- //static GrowZoneUPP mem_full_errUPP;
-
- static Boolean install_aehandler( AEEventClass cl, AEEventID id, ProcPtr p )
- { OSErr err;
- AEEventHandlerUPP upp = NewAEEventHandlerProc(p);
-
- if ( upp == NULL ) err = memFullErr;
- else err = AEInstallEventHandler( cl, id, upp, 0L, false );
- if (err)
- { io_err(err);
- return false;
- }
- return true;
- }
-
- static void init_ae()
- {
- long result;
-
- gHasAppleEvents = (Gestalt(gestaltAppleEventsAttr, &result) ? false : result != 0);
-
- if (gHasAppleEvents)
- install_aehandler( kCoreEventClass, kAEOpenApplication, (ProcPtr )DoAEOpenApplication )
- && install_aehandler( kCoreEventClass, kAEOpenDocuments, (ProcPtr )DoAEOpenDocuments )
- && install_aehandler( kCoreEventClass, kAEPrintDocuments, (ProcPtr )DoAEPrintDocuments )
- && install_aehandler( kCoreEventClass, kAEQuitApplication, (ProcPtr )DoAEQuitApplication )
- && install_aehandler( 'WWWΩ', 'sdoc', (ProcPtr )DoAEwww )
- ;
- else ExitToShell();
- }
-
- static void hack_remove_console( void )
- {
- gDoQuit = 1; // prevents RemoveConsole from doing SetWTitle on wp
- }
-
- static void init_all(void)
- { short i;
-
- MaxApplZone();
- for (i = 0; i < 10; i++) MoreMasters();
- // mem_full_errUPP = NewGrowZoneProc(mem_full_err);
- // SetGrowZone( mem_full_errUPP );
-
- InitGraf( &qd.thePort );
- InitFonts();
- //FlushEvents( everyEvent, 0 );
- InitWindows();
- InitMenus();
- TEInit();
- InitDialogs( 0L );
- InitCursor();
-
- gCursorRgn = NewRgn();
- SetRectRgn(gCursorRgn, -32768, -32768, 32766, 32766);
-
- a_menu = GetMenu( appleID );
- AppendResMenu( a_menu, 'DRVR' );
- f_menu = GetMenu( fileID );
- ClearMenuBar();
- InsertMenu( a_menu, 0);
- InsertMenu( f_menu, 0);
- DrawMenuBar();
-
- atexit(hack_remove_console);
-
- init_ae();
-
- #if USE_EVENTCHK_TIMER
- init_eck_timer();
- #endif
- }
-
- // end.
-