home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C / Applications / Telnet 2.7b5 / source / network / mydnr.c < prev    next >
Encoding:
Text File  |  1995-08-28  |  5.0 KB  |  82 lines  |  [TEXT/CWIE]

  1. tInfoPtr)
  2.     netputevent(USERCLASS,DOMAIN_DONE,info->screen, (long)info);
  3. }
  4.  
  5. SIMPLE_UPP(DNRDoneInit, Result);
  6. pascal void DNRDoneInit(struct hostInfo *hostInfoPtr, DNRDelayStruct *info)
  7. {
  8.     long saveA5;
  9.     DNRDelayStruct *mptr;
  10.     struct hostInfo *hptr;
  11.     
  12.     mptr = info;
  13.     hptr = hostInfoPtr;
  14.  
  15. #ifndef    __powerpc__
  16.     saveA5 = SetA5(mptr->MyA5);
  17. #endif
  18.  
  19.     DNRDone(hptr, mptr);
  20.     
  21. #ifndef    __powerpc__
  22.     SetA5(saveA5);
  23. #endif
  24. }
  25.  
  26. OSErr    DoTheDNR(StringPtr hostname, short window)
  27. {
  28.     DNRDelayStruct        *Info;
  29.     struct hostInfo        *HInfo;
  30.     ip_addr                ip;
  31.     
  32.     Info = (DNRDelayStruct *)myNewPtr(sizeof(DNRDelayStruct));
  33.     HInfo = (struct hostInfo *)myNewPtr(sizeof(struct hostInfo));
  34.     
  35.     if ((Info == NULL) || (HInfo == NULL)) return(memFullErr);
  36.     
  37.     Info->screen = window;
  38. #ifndef __powerpc__
  39.     Info->MyA5 = MyA5;
  40. #endif
  41.     Info->hinfo = HInfo;
  42.         
  43.     BlockMove(hostname, Info->hostname, Length(hostname)+1);
  44.     
  45.     if (DotToNum(hostname, &ip)) {
  46.         Info->hinfo->rtnCode = noErr;
  47.         Info->hinfo->addr[0] = ip;
  48.         DNRDone(HInfo, Info);
  49.         return(noErr);
  50.         }
  51.         
  52.     PtoCstr(Info->hostname);
  53.     Info->theError = StrToAddr((char *)Info->hostname, HInfo,
  54.                                 DNRDoneInitUPP, (Ptr)Info);
  55.     
  56.     if ((Info->theError != cacheFault) && (Info->theError != inProgress))
  57.         DNRDone(HInfo, Info);
  58.     
  59.     return(noErr);
  60. }
  61.  
  62. //    The event queue routines send us the screen number that DNRDone sent.  We demangle
  63. //    this mess of data and call CompleteConnectionOpening to do all of the port and screen
  64. //    stuff that we shouldn't know about at this level.  We are merely a non-interrupt level
  65. //    flow control point. (i.e. I would do this from DNRDone, but that's interrupt time)
  66. void    HandleDomainDoneMessage(short screen, long data2)
  67. {
  68.     DNRDelayStruct    *MyData = (DNRDelayStruct *)data2;
  69.     ip_addr            the_IP;
  70.     OSErr            theErr;        // The error, if any
  71.     
  72.     the_IP = MyData->hinfo->addr[0];
  73.     theErr = MyData->hinfo->rtnCode;
  74.     
  75.     CompleteConnectionOpening(screen, the_IP, theErr, MyData->hinfo->cname);
  76.  
  77.     //    We also dispose of the DNR memory allocations
  78.         
  79.     DisposePtr((Ptr)MyData->hinfo);
  80.     DisposePtr((Ptr)MyData);
  81. }
  82.