audit038@spacm1.spac.spc.com (01/24/91)
I recently posted a request for help with writing AppleTalk calls in Think C. Some responses explained part of the problem using the alternate calls and other responses explained part of the problem using the prefered calls. Now that I'm totally confused I'll ask for help one more time. Can someone please post a complete example of how to register a name on AppleTalk using the prefered calls and C. Please assume i know nothing about this. :-) I'm especially confused about the description in IM V-515 about the NBPSetNTE call. I know each Mac has a names table and that I want to register a names table entry, but how does a names table entry look in C? Perhaps someone can also point me in the direction of some C AppleTalk source code so I can save bandwidth by solving my questions by reading examples. Thanks in advance for your patience and help.
peirce@outpost.UUCP (Michael Peirce) (01/25/91)
In article <2253.279ed669@spacm1.spac.spc.com>, audit038@spacm1.spac.spc.com writes: > > I recently posted a request for help with writing AppleTalk calls in Think C. > > Some responses explained part of the problem using the alternate calls and > other responses explained part of the problem using the prefered calls. > > Now that I'm totally confused I'll ask for help one more time. > > Can someone please post a complete example of how to register a name on > AppleTalk using the prefered calls and C. Please assume i know nothing about > this. :-) > > I'm especially confused about the description in IM V-515 about the NBPSetNTE > call. I know each Mac has a names table and that I want to register a names > table entry, but how does a names table entry look in C? > > Perhaps someone can also point me in the direction of some C AppleTalk source > code so I can save bandwidth by solving my questions by reading examples. Well, it's not THINK C, but MPW C, but here is some working code. The first routine registers the hard wired name "name" and uses NBP type "type". The second routine will unregister this name - important for surviving after your program is run. Disclaimers apply, all my AppleTalk code is in Pascal, but I did test this C code to see if it worked. There still could be a bug lurking under the surface though. If someone spots a problem, please post it! Hope this helps... ______________________________________________________ #include <Types.h> #include <Memory.h> #include <AppleTalk.h> #define kSYNC false #define kNTEsize 109 static EntityName myEntity; static EntityPtr NTEstorage; void RegisterName() { ATPParamBlock myATPPB; MPPParamBlock myMPPPB; // Open an ATP socket myATPPB.ATP.atpSocket = 0; // ask for any available // Clear the address myATPPB.ATP.addrBlock.aNet = 0; myATPPB.ATP.addrBlock.aNode = 0; myATPPB.ATP.addrBlock.aSocket = 0; // Do the POpenATPSkt if (POpenATPSkt(&myATPPB,kSYNC) != noErr) debugstr("POpenATPSkt failed"); // allocate the NTE NTEstorage = (EntityPtr)NewPtr(kNTEsize); if (NTEstorage == 0) debugstr("NewPtr failed"); // I never deallocate this :-( // Set the NTE NBPSetNTE((Ptr)NTEstorage,"\pname","\ptype","\p*",myATPPB.ATP.atpSocket); // Save a "real" entity for removal BlockMove("\pname",&myEntity.objStr,5); BlockMove("\ptype",&myEntity.typeStr,5); BlockMove("\p*",&myEntity.zoneStr,2); // Setup & Do the register call myMPPPB.NBP.NBPPtrs.entityPtr = (Ptr)NTEstorage; myMPPPB.NBP.interval = 3; myMPPPB.NBP.count = 3; myMPPPB.NBP.parm.verifyFlag = 255; if (PRegisterName(&myMPPPB,kSYNC) != noErr) debugstr("PRegisterName failed"); } void unregisterit() { if (NBPRemove(&myEntity) != noErr) debugstr("NBPRemoveName failed"); } -- michael -- Michael Peirce -- outpost!peirce@claris.com -- Peirce Software -- Suite 301, 719 Hibiscus Place -- Macintosh Programming -- San Jose, California 95117 -- & Consulting -- (408) 244-6554, AppleLink: PEIRCE