[comp.sys.mac] C source examples of the new preferred AppleTalk interface?

mike@shogun.cc.umich.edu (Michael Nowak) (01/26/89)

I'm trying to experiment with AppleTalk with my shiny new Lightspeed C
compiler and I'm having trouble using the new "preferred interface" to
AppleTalk listed in Volume V.  Specifically, I'm trying to write some
code to register an entity on the network, and then look for entities of
that type.  I can't get it to work - it usually crashes big time with
a call to PLookupName().
 
Does anyone have any source code which might do such a thing that I can
use as an example?  Or if someone can point me to an ftp server which
might have such an example, I'd appreciate that too.  I looked at sumex
but only found an example using the "alternate" or old interface.
 
If you can send me mail, that'd be great.

 -----------------------------------------------------------------------------
 Michael Nowak                                          ...mailrus!shogun!mike
 Workstation Consultant                               mike@shogun.cc.umich.edu
 U of M Computing Center User Services              Mike_Nowak@um.cc.umich.edu

    ...working for but in no way representing the University of Michigan...

mike@shogun.cc.umich.edu (Michael Nowak) (01/30/89)

I've had several messages in the mail, many from people who are interested
in the same topic.  I've also received some related examples but none using
PLookupName().  LKet me state specifically what I am doing, in hopes that
someone will see the error of my ways.  Here's what the call to PLookupName()
looks like:

	search_name.objStr[0] = 0x01;
	search_name.objStr[1] = '=';
	search_name.typeStr[0] = 0x01;
	search_name.typeStr[1] = '=';
	search_name.zoneStr[0] = 0x01;
	search_name.zoneStr[1] = '*';
	
	mpp_pb_ptr = (MPPPBptr)NewPtr(sizeof(MPPParamBlock));
	if (mpp_pb_ptr == (MPPPBptr)0) {
		err_code = app_memoryErr;
		goto nomppptr;
	}
	
	mpp_pb_ptr->ioCompletion = (ProcPtr)0;
	mpp_pb_ptr->NBPentityPtr = (Ptr)&search_name;
	mpp_pb_ptr->NBPretBuffPtr = (Ptr)entity_buffer;
	mpp_pb_ptr->NBPretBuffSize = 1080;
	mpp_pb_ptr->NBPmaxToGet = 10;
	mpp_pb_ptr->NBPinterval = 8;
	mpp_pb_ptr->NBPcount = 3;
		
	err_code = PLookupName(mpp_pb_ptr, false);

entity_buffer is defined as char entity_buffer[1080].  I originally
tried using NBPSetEntity to set up search_name but have used this surer
approach to cut down on places where I could mess up.  The code crashes
in the PLookupName call, with an odd address exception at 0x4345a0.

Any advice would be appreciated.
 -----------------------------------------------------------------------------
 Michael Nowak                                          ...mailrus!shogun!mike
 Workstation Consultant                               mike@shogun.cc.umich.edu
 U of M Computing Center User Services              Mike_Nowak@um.cc.umich.edu

    ...working for but in no way representing the University of Michigan...