示例#1
0
static pascal void
ExitToShellPatchRoutine()
{
    ExitToShellUPP oldETS;
    long oldA5;

    /*
     * Set up our A5 world.  This allows us to have
     * access to our global variables in the 68k world.
     */
    oldA5 = SetCurrentA5();
    SetA5(gExitToShellData->a5);

    /*
     * Call the function that invokes all
     * of the handlers.
     */
    TclMacExitHandler();

    /*
     * Call the origional ExitToShell routine.
     */
    oldETS = gExitToShellData->oldProc;
    DisposePtr((Ptr) gExitToShellData);
    SetA5(oldA5);
    CallExitToShellProc(oldETS);
    return;
}
示例#2
0
pascal void snd_channel_callback(SndChannelPtr theChannel,SndCommand* theCommand) {
	long theA5;
	short channel = -1,i,which_sound;
	
#ifndef EXILE_BIG_GUNS
	theA5 = SetA5(theCommand->param2);
#endif
	
	for (i = 0; i < 4; i++)
		if (chan[i] == theChannel)
			channel = i;
	which_sound = snd_played[channel];
	snd_played[channel] = -1;
	//if (in_startup_mode == false)
	//	print_num(0,snd_played[channel],channel);
  	if ((sound_going(which_sound) == false) && (load_when_play[which_sound] == true)) {
	  	HUnlock(sound_handles[which_sound]);
		//if (in_startup_mode == false)
		//	print_num(99,snd_played[channel],channel);
	}
	
#ifndef EXILE_BIG_GUNS
	theA5 = SetA5(theA5);
#endif
}
示例#3
0
/* Routine passed to NewSndChannel -- schedule a call to SndCh_CallCallBack */
static pascal void
SndCh_UserRoutine(SndChannelPtr chan, SndCommand *cmd)
{
	SndChannelObject *p = (SndChannelObject *)(chan->userInfo);
	if (p->ob_callback != NULL) {
		long A5 = SetA5(p->ob_A5);
		p->ob_cmd = *cmd;
		Py_AddPendingCall(SndCh_CallCallBack, (void *)p);
		SetA5(A5);
	}
}
示例#4
0
static pascal void
SPB_completion(SPBPtr my_spb)
{
	SPBObject *p = (SPBObject *)(my_spb->userLong);
	
	if (p && p->ob_completion) {
		long A5 = SetA5(p->ob_A5);
		p->ob_thiscallback = p->ob_completion;	/* Hope we cannot get two at the same time */
		Py_AddPendingCall(SPB_CallCallBack, (void *)p);
		SetA5(A5);
	}
}
示例#5
0
/*--------------------------------------------------------------------
 * FUNCTION NAME
 * callProgress - Macintosh Version
 *
 * DESCRIPTION
 * This function calls the user's call back function
 * must be done as separate subroutine so that progress function
 * address is addressed via the A6 stack
 *
 *--------------------------------------------------------------------*/
static PTErr_t FAR PASCAL
	callProgress (	callBack_p	callBack,
					KpInt32_t	percent)
{
initializedGlobals_p	iGP;
PTRelay_t		relay;
PTErr_t 		theReturn;

#if defined (KPMACPPC)
long			thisA5;
#endif

	if (callBack->progressFunc == NULL) {
		return KCP_SUCCESS;
	}

	iGP = getInitializedGlobals ();
	if (iGP == NULL) {
		return KCP_NO_PROCESS_GLOBAL_MEM;
	}

	relay = iGP->callBackRelay;

	/* do the progress call-back */
#if defined (KPMACPPC)
	thisA5 = SetA5 (callBack->gHostA5);
	
		/* PPC or 68K callback code? */
	if ( ((UniversalProcPtr)callBack->progressFunc)->goMixedModeTrap == _MixedModeMagic) {
		theReturn = (PTErr_t) CallUniversalProc ((UniversalProcPtr)callBack->progressFunc,
												uppCallProgressProcInfo, percent);
	}
	else {						/* callback code is 68K */
		theReturn = (PTErr_t) CallUniversalProc ((UniversalProcPtr)relay, upprelayProcInfo,
						callBack->gHostA5, callBack->gHostA4, callBack->progressFunc, percent);
	}
	SetA5 (thisA5);
#endif
#if defined (KPMAC68K)
		theReturn = (PTErr_t)relay (callBack->gHostA5, callBack->gHostA4, callBack->progressFunc, percent);
#endif

	return (theReturn);
}
示例#6
0
/*--------------------------------------------------------------------
 * DESCRIPTION
 *      Do progress callback. - MAC version
 *
 * AUTHOR
 *      mec
 *
 * DATE CREATED
 *      May 4, 1995
 *------------------------------------------------------------------*/
static SpStatus_t SpDoIter (
			SpTagIter_t	ProgressFunc,
			SpIterState_t	State,
			SpProfile_t	Profile,
			SpTagId_t	TagId,
			void		FAR *Data)
{
#if defined(KPMAC68K)
	volatile long	hostA4, hostA5;
	volatile long	thisA4, thisA5;
#endif
	SpStatus_t	status;
 
	if (NULL == ProgressFunc)
		return SpStatSuccess;
 
#if defined(KPMAC68K)
	/* restore host's global world - we don't know if its an A4 or A5*/
	SPretrieveCallbackA4A5(&hostA4, &hostA5);
	if (hostA5 != 0)
		thisA5 = SetA5(hostA5);
	if (hostA4 != 0)
		thisA4 = SetA4(hostA4);
#endif
 
	status = CallSPIterCallBackFunc((spIterCallBackUPP)ProgressFunc,
					State, Profile, TagId, Data);
 
#if defined (KPMAC68K)
	/* reset our global world */
	if (hostA5 != 0)
		SetA5(thisA5);
	if (hostA4 != 0)
		SetA4(thisA4);
#endif
 
	return status;
}
示例#7
0
pascal void OTTCPNotifier(void* vobj, OTEventCode code, OTResult result, void* cookie) {
	OTTCP *x = (OTTCP *) vobj;
	long oldA5;
	OSStatus s;
		
	EnterCallback();
	oldA5 = SetA5(x->o_a5);

	post("*** OTTCPNotifier(code %x, result %ld)", (long) code, (long) result);
	
	if (code == T_OPENCOMPLETE) {
		if (result != noErr) {
			post("OTTCPNotifier got a T_OPENCOMPLETE code with error %ld", result);
		}

		// Even if we got an error, we'll use the endpoint.  
		x->o_tcp_ep = (EndpointRef) cookie;
		
		if (x->o_inetHostName != 0) {
			BindTheEndpoint(x);
			// Now we expect a T_BINDCOMPLETE message.
		}
		
	} else if (code == T_BINDCOMPLETE) {
		TCall sndCall;
		InetAddress inAddr;
		
		// See what ephemeral port number OT gave us
		x->o_receiveInetPort = x->o_addrWeActuallyGot.fPort;
		
		// Now the endpoint has been bound; next trick is connecting
		OTInitInetAddress(&inAddr, x->o_inetPort, x->o_inetHost);
		OTMemzero(&sndCall, sizeof(TCall));
		sndCall.addr.buf = (void *) &inAddr;
		sndCall.addr.len = sizeof(InetAddress);

		post("** About to OTConnect");
		s = OTConnect(x->o_tcp_ep, &sndCall, NULL);
		if (s == kOTNoDataErr) {
			// No problem; that means connection is in progress
			post("** OTConnect returned kOTNoDataErr - good");
		} else {
			post("е OTTCP: error: OTConnect returned %ld; not connecting.", s);
		}
		// Now we expect T_CONNECT
		
	} else if (code == T_CONNECT) {
		if (result == kOTBadAddressErr) {
			post("е OTTCP: error: bad address.  Disconnecting");
			x->o_inetHost = 0;
			change_connection(x);
		} else {
			post("** Got T_CONNECT");
			post("** Result passed to notifier: %ld", (long) result);
			post("** Endpoint state before OTRcvConnect: %ld", (long) OTGetEndpointState(x->o_tcp_ep));
			// We could pass in buffers to find out the actual address we connected to, etc.
			s = OTRcvConnect(x->o_tcp_ep, nil);
			if (s != kOTNoError) {
				post("е OTTCP: error: RcvConnect returned %ld", s);
			}
			post("** Endpoint state after OTRcvConnect: %ld", (long) OTGetEndpointState(x->o_tcp_ep));
			ChangeState(x, NO_REQUEST);
			x->o_connectionSymbol = ps_connected;
			clock_delay(x->o_connectedclock, 0);
		}
	} else if (code == T_UNBINDCOMPLETE) {
		// If we have a new inetHost, try to bind it
		if (x->o_inetHost != 0) {
			BindTheEndpoint(x);
			// Now we expect T_BINDCOMPLETE
		} else {
			// No inetHost, so we're disonnected
			x->o_connectionSymbol = ps_disconnected;
			clock_delay(x->o_connectedclock, 0);
		}
	} else if (code == T_DISCONNECTCOMPLETE) {
		// We always want to rebind when we reconnect, so after disconnecting we unbind
		s = OTUnbind(x->o_tcp_ep);
		if (s != kOTNoError) {
			post("OTTCP: warning: OTUnbind returned %ld", s);
		}		
	} else if (code == T_DATA) {
		ottcp_handleIncomingData(x);
	} else if (code == T_UDERR) {
		if (x->o_errorreporting) {
			PostUDERR("OTTCPNotifier was called for a T_UDERR code", x->o_tcp_ep);
		} else {
			/* We still have to receive the error to clear the condition */
			OTRcvUDErr(x->o_tcp_ep, 0);
		}
	} else if (code == T_GODATA) {
		// Flow control restriction has lifted; now it's OK to send more data.
		do_write(x, 0, 0);
	} else if (code == T_DISCONNECT) {
		// The other dude wants to disconnect
		post("OTTCP: peer wants to disconnect");
		s = OTRcvDisconnect(x->o_tcp_ep, NULL);
		if (s == kOTNoError) {
			x->o_inetHost = 0;
			change_connection(x);
		} else if (s == kOTNoDisconnectErr) {
			// false alarm
		} else {
			post("е OTTCP: error: OTRcvDisconnect returned %ld", s);
		}
	} else if (code == T_ORDREL) {
		post("*** Got T_ORDREL");
		s = OTRcvOrderlyDisconnect(x->o_tcp_ep);
		if (s == kOTNoReleaseErr) {
			post("...false alarm!");
		} else if (s == kOTNoError) {
			x->o_inetHost = 0;
			change_connection(x);
		} else {
			post("е OTTCP: error: OTRcvOrderlyDisconnect returned %ld", s);
		}
	} else {
	 	if (x->o_errorreporting) {
			post("OTTCP: Unrecognized OTEventCode %ld in event handler.  Oh well.", (long) code);
		}
	}

done:
	SetA5(oldA5);
	ExitCallback();
}