typedef struct xbra
{
	LONG	xbra_id;
	LONG	app_id;
	VOID 	(*oldvec)();
} XBRA;

LONG
unhook_xbra( WORD vecnum, LONG app_id )
{
	XBRA *rx;
	LONG vecadr, *stepadr, lret = 0L;
	char *savessp;

	vecadr = Setexc( vecnum, VEC_INQUIRE );
	rx = (XBRA *)(vecadr - sizeof( XBRA ));

	/* Set supervisor mode for search just in case. */
	savessp = Super( SUP_SET );

	/* Special Case: Vector to remove is first in chain. */
	if( rx->xbra_id == ‘XBRA’ && rx->app_id == app_id )
	{
		Setexc( vecnum, rx->oldvec );
		return vecadr;
	}

	stepadr = (LONG *)&rx->oldvec;
	rx = (XBRA *)((LONG)rx->oldvec - sizeof( XBRA ));
	while( rx->xbra_id == ‘XBRA’ )
	{
		if( rx->app_id == app_id )
		{
			*stepadr = lret = (LONG)rx->oldvec;
			break;
		}

		stepadr = (LONG *)&rx->oldvec;
		rx = (XBRA *)((LONG)rx->oldvec - sizeof( XBRA ));
	}

	Super( savessp );
	return lret;
}
