Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

208 lines
3.6 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows NT **/
  3. /** Copyright(c) Microsoft Corporation, 1991 - 1998 **/
  4. /**********************************************************************/
  5. /*
  6. utils.h
  7. Utility routine header file for DHCPSNAP.DLL
  8. FILE HISTORY:
  9. DavidHov 6/15/93 Created
  10. EricDav 2/13/97 Updated
  11. */
  12. #if !defined(_DHCPUTIL_H_)
  13. #define _DHCPUTIL_H_
  14. enum ENUM_HOST_NAME_TYPE
  15. {
  16. HNM_TYPE_INVALID,
  17. HNM_TYPE_IP,
  18. HNM_TYPE_DNS,
  19. HNM_TYPE_NB,
  20. HNM_TYPE_MAX
  21. };
  22. #define DHCPSNAP_STRING_MAX 256
  23. #define DHCPSNAP_COMPUTER_NAME_MAX 20
  24. extern wchar_t rgchHex[];
  25. typedef struct
  26. {
  27. DHCP_IP_ADDRESS _dhipa ; // IP Address
  28. TCHAR _chHostName [DHCPSNAP_STRING_MAX*2] ; // Host DNS name
  29. TCHAR _chNetbiosName [DHCPSNAP_STRING_MAX*2] ; // Host NetBIOS name (if known)
  30. } DHC_HOST_INFO_STRUCT ;
  31. int
  32. UtilGetOptionPriority(int nOpt1, int nOpt2);
  33. BOOL
  34. UtilGetFolderName(CString & strInitialPath, CString& strHelpText, CString& strSelectedPath);
  35. void
  36. UtilConvertLeaseTime(DWORD dwLeaseTime, int *pnDays, int *pnHours, int *pnMinutes);
  37. DWORD
  38. UtilConvertLeaseTime(int pnDays, int pnHours, int pnMinutes);
  39. ENUM_HOST_NAME_TYPE
  40. UtilCategorizeName (LPCTSTR pszName);
  41. // Convert a string to an IP address
  42. extern DHCP_IP_ADDRESS
  43. UtilCvtStringToIpAddr
  44. (
  45. const CHAR * pszString
  46. );
  47. extern DHCP_IP_ADDRESS
  48. UtilCvtWstrToIpAddr
  49. (
  50. const LPCWSTR pcwString
  51. );
  52. // Convert an IP address into a displayable string
  53. extern void
  54. UtilCvtIpAddrToString
  55. (
  56. DHCP_IP_ADDRESS dhipa,
  57. CHAR * pszString,
  58. UINT cBuffSize
  59. );
  60. extern BOOL
  61. UtilCvtIpAddrToWstr
  62. (
  63. DHCP_IP_ADDRESS dhipa,
  64. CString * pstrIpAddress
  65. );
  66. extern BOOL
  67. UtilCvtIpAddrToWstr
  68. (
  69. DHCP_IP_ADDRESS dhipa,
  70. WCHAR * pwcszString,
  71. INT cBuffCount
  72. );
  73. extern WCHAR *
  74. UtilDupIpAddrToWstr
  75. (
  76. DHCP_IP_ADDRESS dhipa
  77. );
  78. // "strdup" for C++ wcstrs.
  79. extern WCHAR *
  80. UtilWcstrDup
  81. (
  82. const WCHAR * pwcsz,
  83. INT * pccwLength = NULL
  84. );
  85. extern WCHAR *
  86. UtilWcstrDup
  87. (
  88. const CHAR * psz,
  89. INT * pccwLength = NULL
  90. );
  91. extern CHAR *
  92. UtilCstrDup
  93. (
  94. const WCHAR * pwcsz
  95. );
  96. extern CHAR *
  97. UtilCstrDup
  98. (
  99. const CHAR * psz
  100. );
  101. // Return a standard information structure for the given
  102. // host IP address
  103. extern DWORD
  104. UtilGetHostInfo
  105. (
  106. DHCP_IP_ADDRESS dhipa,
  107. DHC_HOST_INFO_STRUCT * pdhsrvi
  108. );
  109. // Return the IP address of this host machine
  110. extern HRESULT
  111. UtilGetLocalHostAddress
  112. (
  113. DHCP_IP_ADDRESS * pdhipa
  114. );
  115. extern HRESULT
  116. UtilGetHostAddressFQDN
  117. (
  118. LPCTSTR pszHostName,
  119. CString * pstrFQDN,
  120. DHCP_IP_ADDRESS * pdhipa
  121. );
  122. extern HRESULT
  123. UtilGetHostAddress
  124. (
  125. LPCTSTR pszHostName,
  126. DHCP_IP_ADDRESS * pdhipa
  127. );
  128. extern HRESULT
  129. UtilGetLocalHostName
  130. (
  131. CString * pstrName
  132. );
  133. extern HRESULT
  134. UtilGetNetbiosAddress
  135. (
  136. LPCTSTR pszNetbiosName,
  137. DHCP_IP_ADDRESS * pdhipa
  138. );
  139. extern BOOL
  140. UtilCvtHexString
  141. (
  142. LPCTSTR pszNum,
  143. CByteArray & cByte
  144. );
  145. extern BOOL
  146. UtilCvtByteArrayToString
  147. (
  148. const CByteArray & abAddr,
  149. CString & str
  150. );
  151. WCHAR *
  152. PchParseUnicodeString
  153. (
  154. CONST WCHAR * szwString,
  155. DWORD dwLength,
  156. CString& rString
  157. );
  158. BOOL FGetCtrlDWordValue(HWND hwndEdit, DWORD * pdwValue, DWORD dwMin, DWORD dwMax);
  159. // Convert ASCII string of decimal or hex numbers to binary integer
  160. BOOL FCvtAsciiToInteger(IN const TCHAR * pszNum, OUT DWORD * pdwValue);
  161. void UtilConvertStringToDwordDword(LPCTSTR pszString, DWORD_DWORD * pdwdw);
  162. void UtilConvertDwordDwordToString(DWORD_DWORD * pdwdw, CString * pstrString, BOOL bDecimal);
  163. #endif // _DHCPUTIL_H_
  164. // End of DHCPUTIL.H