home *** CD-ROM | disk | FTP | other *** search
/ Mac Expert 1995 Winter / Mac Expert - Winter 95.iso / Les fichiers / Communications / Internet / TurboTCP 2.1 ƒ / TurboTCP core / CTCPResolverCall.h < prev    next >
Encoding:
Text File  |  1995-01-06  |  4.9 KB  |  142 lines  |  [TEXT/MMCC]

  1. //
  2. // CTCPResolverCall.h
  3. //
  4. //    TurboTCP library
  5. //    TCP resolver class
  6. //
  7. //    Copyright © 1993-95, FrostByte Design / Eric Scouten
  8. //
  9.  
  10. #pragma once
  11.  
  12. #include "TurboTCP.buildflags.h"
  13. #include "CTCPDriver.h"
  14. #include "CTCPEndpoint.h"
  15.  
  16.  
  17. #if TurboTCP_UH2
  18.     #include <MacTCP.h>
  19. #else
  20.     #include <MacTCPCommonTypes.h>
  21.     #include <AddressXlation.h>
  22.     #define Result2UPP ResultProc2UPP
  23.     #define NewResult2Proc NewResultProc2Proc
  24. #endif
  25.  
  26.  
  27. //***********************************************************
  28.  
  29. class CTCPResolverCall {
  30.  
  31. // This class implements the core DNR calls. It is like the CTCPAsyncCall in that the call
  32. // object is created to allow the call to persist beyond the scope of originating method.
  33. // However, access to this object is not restricted; your application classes can and often
  34. // will interact with the CTCPResolverCall object.
  35.  
  36. // Each resolver object may support only one asynchronous resolver call at a time.
  37. // You may create several resolver objects to simultaneously process several calls,
  38. // so long as you respect MacTCP’s limit of 8 resolver calls open at once. The CTCPDriver
  39. // acts as a referee to prohibit more than 8 simultaneous calls.
  40.  
  41. // One set of methods (Do...) is called to initiate resolver calls. These are the methods you
  42. // will typically call from your application classes. These methods initiate asynchronous
  43. // calls to the DNR code resource. When the calls are completed, the notification is passed
  44. // to another set of methods (Handle...). The Handle… methods return notification to your
  45. // class through the Handle… methods in CTCPProtcolInterp. The exception to this is the
  46. // DoAddrToStr method which returns the result immediately.
  47.  
  48. // The userDataPtr fields of each of the calls are used by the resolver object to get
  49. // notification of completion, and are not available to the caller.
  50.  
  51. // The CTCPDriver object takes care of opening and closing the DNR code resource; it uses
  52. // the OpenResolver and CloseResolver methods. You should not call these methods from your
  53. // application classes.
  54.  
  55. // The EnumCache call is not implemented in TurboTCP.
  56.  
  57. // TurboTCP 1.0 NOTE: This class is no longer a descendant of CCollaborator. It now
  58. // communicates only with the CTCPEndpoint mix-in class.
  59.  
  60.     friend class CTCPDriver;
  61.     friend class CTCPResolverList;
  62.     friend class UTurboTCP;
  63.  
  64.  
  65. public:
  66.                         CTCPResolverCall(CTCPEndpoint& theEndpoint);
  67.     void                    Dispose();
  68. private:
  69.     virtual                ~CTCPResolverCall() {}        // use Dispose() instead
  70.  
  71.     // initiate resolver calls
  72.  
  73. public:    
  74.     void                    DoStrToAddr(char* theHostName);
  75.     static void            DoAddrToStr(ip_addr theIPaddr, char* theString);
  76.     void                    DoAddrToName(ip_addr theIPaddr);
  77.     void                    DoHInfo(char* theHostName);
  78.     void                    DoMXInfo(char* theHostName);
  79.  
  80.     // respond to completion of resolver calls
  81.  
  82. private:
  83.     void                    ProcessNotify();
  84.     inline void            HandleStrToAddr()
  85.                             { if (itsEndpoint) itsEndpoint->HandleStrToAddr(&theHostInfo); }
  86.     inline void            HandleAddrToName()
  87.                             { if (itsEndpoint) itsEndpoint->HandleAddrToName(&theHostInfo); }
  88.     inline void            HandleHInfo()
  89.                             { if (itsEndpoint) itsEndpoint->HandleHInfo(&theHMXInfo); }
  90.     inline void            HandleMXInfo()
  91.                             { if (itsEndpoint) itsEndpoint->HandleMXInfo(&theHMXInfo); }
  92.  
  93.     // open/close TCP resolver
  94.  
  95.     static void            OpenResolver();
  96.     static void            CloseResolver();
  97.     static short            OpenTheDNR();
  98.     static short            SearchFolderForDNRP(long targetType, long targetCreator, short vRefNum, long dirID);
  99.     static void            GetSystemFolder(short* vRefNumP, long* dirIDP);
  100.     static void            GetCPanelFolder(short* vRefNumP, long* dirIDP);
  101.  
  102.     // interrupt-level methods: delay processing for non-interrupt status
  103.     
  104.     void                    PostponeNotify(short theNotifType);
  105.     static pascal void        PostponeStrToAddr(hostInfo* hostInfoPtr, char* userDataPtr);
  106.     static pascal void        PostponeAddrToName(hostInfo* hostInfoPtr, char* userDataPtr);
  107.     static pascal void        PostponeHInfo(returnRec* returnRecPtr, char* userDataPtr);
  108.     static pascal void        PostponeMXInfo(returnRec* returnRecPtr, char* userDataPtr);
  109.  
  110.  
  111.     // data members
  112.     
  113. private:
  114.     CTCPEndpoint*            itsEndpoint;            // endpoint object for this resolver
  115.     Boolean                inUse;                // resolver in use; can’t accept calls
  116.     Boolean                disposeOnCompletion;    // dispose of resolver call once completed
  117.     hostInfo                theHostInfo;            // parms for StrToAddr
  118.     returnRec                theHMXInfo;            // parms for HInfo or MXInfo
  119.     char                hostName[255];        // name of user host
  120.     short                pendingNotify;            // resolver is in ProcessNotify queue
  121.     static Handle            macDNRcode;            // the DNR code resource’s handle
  122.     static UniversalProcPtr    macDNRentry;            // the DNR code entry point
  123.     TurboTCPQElem            qEntry;                // completion queue entry
  124.     TurboTCPQElem            activeResListEntry;        // completion queue entry
  125.  
  126. #if TurboTCP_CFM
  127.     static ResultUPP        StrToAddrUPP;            // UPPs for all DNR callbacks
  128.     static ResultUPP        AddrToNameUPP;
  129.     static Result2UPP        HInfoUPP;
  130.     static Result2UPP        MXInfoUPP;
  131. #endif
  132.  
  133.     enum {
  134.         notifNone,
  135.         notifStrToAddr,
  136.         notifAddrToName,
  137.         notifHInfo,
  138.         notifMXInfo
  139.     };
  140.     
  141. };
  142.