home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / include / util.h < prev    next >
C/C++ Source or Header  |  1998-04-25  |  3KB  |  101 lines

  1.  
  2. #if !defined(UTIL_H)
  3. #define UTIL_H
  4.  
  5. /*
  6. ================================================================================
  7.     ========================================================================
  8.     ========================================================================
  9.  
  10.     File:           util.h
  11.     Description:    
  12.     Created:        9/3/1997
  13.     Author:         Matthijs Gates
  14.     Mail:           mgates@microsoft.com
  15.  
  16.     Copyright (C) 1997  Microsoft Corporation.  All Rights Reserved.
  17.  
  18.     ========================================================================
  19.     ========================================================================
  20. ================================================================================
  21. */
  22.  
  23. #include "brtest.h"
  24. #include <string.h>
  25. #include "util.h"
  26.  
  27. //==============================================================================
  28. //
  29. //  Class:  CUtil
  30. //
  31. //------------------------------------------------------------------------------
  32. //  Description:
  33. //
  34. //  Public methods:
  35. //
  36. //  Public properties:
  37. //
  38. //  9/4/1997
  39. //  mgates
  40. //
  41. //==============================================================================
  42. class CUtil
  43. {
  44.     // P U B L I C
  45.  
  46.     public :
  47.     
  48.         static INT BandwidthThrottledSend(CSession   &session,
  49.                                           CData      &data,
  50.                                           DWORD      &cBytesSentToNow,
  51.                                           DWORD      &dwFirstSendTick,
  52.                                           DWORD      &dwLastSendTick,
  53.                                           DWORD      dwBitsPerSec,
  54.                                           HANDLE     hAbortEvent = NULL) ;
  55.         
  56.         static BOOL IsValidIP(char *szIP) { return inet_addr(szIP) != INADDR_NONE ; }
  57.         static BOOL IsValidIP(CString &cstrIP) { return inet_addr(cstrIP) != INADDR_NONE ; }
  58.         static BOOL ChangeIP(CString &cstrIP, long ulIncrement) ;
  59.         static BOOL IncrementIP(CString &cstrIP) { return ChangeIP(cstrIP, 1) ; }
  60.         static BOOL DecrementIP(CString &cstrIP) { return ChangeIP(cstrIP, -1) ; }
  61.         static BOOL ulIPtoCString(u_long ip, CString &cstrIP) ;
  62.         enum { ABORTEVENT = -1 
  63.              } ;
  64. } ;
  65.  
  66. //==============================================================================
  67. //
  68. //  Class:  CNetworkInterface
  69. //
  70. //------------------------------------------------------------------------------
  71. //  Description:        provides a class for an array of NIC IP addresses for
  72. //                      the host
  73. //
  74. //  Public methods:
  75. //
  76. //  Public properties:
  77. //
  78. //  9/14/1997
  79. //  mgates@microsoft.com
  80. //
  81. //==============================================================================
  82. class CNIC
  83. {
  84.     CString **m_ppNIC ;
  85.     INT        m_cNIC ;
  86.     CString &Get_(INT index) ;
  87.     
  88.     // P U B L I C -------------------------------------------------------------
  89.  
  90.     public :
  91.     
  92.         CNIC() ;
  93.         ~CNIC() ;
  94.         
  95.         INT Enumerate()    { return m_cNIC ; }
  96.         CString &Get(INT index) ;
  97.         CString &operator[](INT index) ;
  98. } ;
  99.  
  100. #endif  // UTIL_H
  101.