Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!usc!elroy.jpl.nasa.gov!spacm1!audit038 From: audit038@spacm1.spac.spc.com Newsgroups: comp.sys.mac.programmer Subject: Re: AppleTalk NBP problem - ( SOLVED! ) Message-ID: <2262.27a05c9f@spacm1.spac.spc.com> Date: 25 Jan 91 16:28:15 GMT Organization: Security Pacific Automation Co., LA, CA Lines: 110 Thanks to Michael Peirce, I was able to write this Think C program that registers and unregisters a name. The parameter block equates are slightly different in Think C. (Don't know why) but here's the code. I tested it using Interpol and it WORKS! Thanks much. _______________________________________________________ #include #include #include #include #define kSYNC false #define kNTEsize 109 static EntityName myEntity; static EntityPtr NTEstorage; #define REMOVE_ALL_EVENTS 0 #define NIL_POINTER 0L /* prototypes */ void RegisterName(); void UnRegisterIt(); void debugstr( char *str ); main() { int errCode; InitGraf( &thePort ); MaxApplZone(); InitFonts(); FlushEvents( everyEvent, REMOVE_ALL_EVENTS ); InitWindows(); InitMenus(); TEInit(); InitDialogs( NIL_POINTER ); InitCursor(); if ( MPPOpen() != noErr) { debugstr("MPPOpen didn't work"); } RegisterName(); UnRegisterIt(); } void RegisterName() { ATPParamBlock myATPPB; MPPParamBlock myMPPPB; /* Open an ATP socket */ myATPPB.atpSocket = 0; /* ask for any available */ /* Clear the address */ myATPPB.addrBlock.aNet = 0; myATPPB.addrBlock.aNode = 0; myATPPB.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,"\pJohnny","\pHeyMac!","\p*",myATPPB.atpSocket); /* Save a "real" entity for removal */ BlockMove("\pJohnny",&myEntity.objStr,7); BlockMove("\pHeyMac!",&myEntity.typeStr,8); BlockMove("\p*",&myEntity.zoneStr,2); /* Setup & Do the register call */ myMPPPB.MPP.NBP.entityPtr = (Ptr)NTEstorage; myMPPPB.MPP.NBP.interval = 3; myMPPPB.MPP.NBP.count = 3; myMPPPB.MPP.NBP.NBP1.verifyFlag = 255; if (PRegisterName(&myMPPPB,kSYNC) != noErr) debugstr("PRegisterName failed"); } void UnRegisterIt() { if (NBPRemove(&myEntity) != noErr) debugstr("NBPRemoveName failed"); } void debugstr( str ) char *str; { printf( str ); } -- John Coffman