Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!elroy.jpl.nasa.gov!spacm1!audit038 From: audit038@spacm1.spac.spc.com Newsgroups: comp.sys.mac.programmer Subject: AppleTalk & Think C -- Help sought Message-ID: <2245.279c7e47@spacm1.spac.spc.com> Date: 22 Jan 91 18:02:46 GMT Organization: Security Pacific Automation Co., LA, CA Lines: 79 HELP!!! The following Think C code is my attempt at registering a name on AppleTalk. This either blows up or registers garbage. I'm new to the MAC and I was wondering if someone could point out where I'm blowing it. Thanks in advance. ***************************************************** #include "AppleTalk.h" #define REMOVE_ALL_EVENTS 0 #define NIL_POINTER 0L main() { ABRecHandle myABRecHandle; EntityName myEntity; AddrBlock entityAddr; Ptr nbpNamePtr; Ptr myBuffer; int errCode; Boolean async; int nbpNameBufSize; int mySocket = 20; long memAmount; InitGraf( &thePort ); MaxApplZone(); InitFonts(); FlushEvents( everyEvent, REMOVE_ALL_EVENTS ); InitWindows(); InitMenus(); TEInit(); InitDialogs( NIL_POINTER ); InitCursor(); errCode = MPPOpen(); if ( errCode != noErr) { printf("MPPOpen didn't work"); } /* Call memory manager to allocate ABusRecord */ myABRecHandle = (ABRecHandle) NewHandle(nbpSize); MoveHHi( myABRecHandle ); HLock (myABRecHandle ); /* Set up our entity name to register */ strcpy( myEntity.objStr, "Johnny"); strcpy( myEntity.typeStr, "PrintSpooler"); strcpy( myEntity.zoneStr, "*"); nbpNamePtr = NewPtr( strlen(myEntity.objStr) + strlen(myEntity.typeStr) + strlen(myEntity.zoneStr) + 12 ); nbpNameBufSize = strlen(myEntity.objStr) + strlen(myEntity.typeStr) + strlen(myEntity.zoneStr) + 12; /* Set up the ABusRecord for the NBPRegister call */ (*myABRecHandle)->nbpProto.nbpEntityPtr = &myEntity; (*myABRecHandle)->nbpProto.nbpBufPtr = (Ptr) nbpNamePtr; /* buffer used by NBP internally */ (*myABRecHandle)->nbpProto.nbpBufSize = nbpNameBufSize; (*myABRecHandle)->nbpProto.nbpAddress.aSocket = mySocket; (*myABRecHandle)->nbpProto.nbpRetransmitInfo.retransInterval = 8; (*myABRecHandle)->nbpProto.nbpRetransmitInfo.retransCount = 3; async = FALSE; errCode = NBPRegister( &myABRecHandle, async ); if ( errCode != noErr ) { printf("NBPRegister failed"); } } -- John Coffman