audit038@spacm1.spac.spc.com (01/26/91)
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 <MacTypes.h> #include <MemoryMgr.h> #include <AppleTalk.h> #include <nAppleTalk.h> #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