/********************************************************************
 ** NETWORK FILE SYSTEM SERVICE
 **
 ** (c) Spak, Darrell Tam, c9107253@ee.newcastle.edu.au (1994)
 ** phone (Australia) 049-829-710
 **                    49-829-710
 ** (c) SST Jan-Feb-Mar 1994
 **
 ** MISC stuff
 **
 ** TABS to 4
 ********************************************************************/

#include "/snd/everything.h"
#include <st/st_proto.h>

#include "nfsinternal.h"
#include "nfsglobs_protos.h"


/********************************************************************/
struct MsgPort *FindHandlerPort(char *fname,
				long il_perhaps, long il_majic, long *extra_lock_BCPL)
/********************************************************************
"fname" should be NULL terminated,
 il_perhaps should be the pointer-index to the internal lock
 extra_lock_BCPL is written into as the
      additional lock offset (eg assign)

 ********************************************************************/
{
register struct MsgPort *handlerport;
struct InternalLock *ilock;

	if(il_perhaps == 0 && (handlerport = DeviceProc(fname))) {
		*extra_lock_BCPL = IoErr();						/* tell me the offset */
		return(handlerport);
	}
	else if(ilock = GET_INTERNALLOCK(il_perhaps, il_majic)) {
		handlerport = ilock->reallock->fl_Task;
		*extra_lock_BCPL = CTOB(ilock->reallock);			/* "offset" lock */
		return(handlerport);
	}
	return(NULL);
}

