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.

251 lines
4.6 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows NT **/
  3. /** Copyright(c) Microsoft Corp., 1994 **/
  4. /**********************************************************************/
  5. /*
  6. tcpproc.hxx
  7. Exports misc. bits of TCP services helper DLL stuff
  8. FILE HISTORY:
  9. Johnl 09-Oct-1994 Created.
  10. MuraliK 31-July-1995 ReadRegistryString added +
  11. Schedule items function decls moved out.
  12. MuraliK 23-Feb-1996 Added IslFormatDate()
  13. */
  14. #ifndef _TCPPROC_H_
  15. #define _TCPPROC_H_
  16. //
  17. // Heap Routines
  18. //
  19. #ifdef __cplusplus
  20. #include <string.hxx>
  21. extern "C" {
  22. dllexp
  23. BOOL
  24. ReadRegistryStr(
  25. IN HKEY hkeyReg,
  26. OUT STR & str,
  27. IN LPCTSTR lpszValueName,
  28. IN LPCTSTR lpszDefaultValue = NULL,
  29. IN BOOL fExpand = FALSE);
  30. #endif // __cplusplus
  31. #define TCP_ALLOC(cb) (VOID *)LocalAlloc( LPTR, cb )
  32. #define TCP_FREE(p) LocalFree( (HLOCAL) p )
  33. #define TCP_DUMP_RESIDUE() /* NOTHING */
  34. //
  35. // Registry functions
  36. //
  37. dllexp
  38. LPSTR
  39. ConvertUnicodeToAnsi(
  40. IN LPCWSTR lpszUnicode,
  41. IN LPSTR lpszAnsi,
  42. IN DWORD cbAnsi
  43. );
  44. //
  45. // Quick macro to initialize a unicode string
  46. //
  47. #define InitUnicodeString( pUnicode, pwch ) \
  48. { \
  49. (pUnicode)->Buffer = pwch; \
  50. (pUnicode)->Length = wcslen( pwch ) * sizeof(WCHAR); \
  51. (pUnicode)->MaximumLength = (pUnicode)->Length + sizeof(WCHAR);\
  52. }
  53. dllexp
  54. DWORD
  55. ReadRegistryDwordA(
  56. HKEY hkey,
  57. LPCSTR pszValueName,
  58. DWORD dwDefaultValue
  59. );
  60. dllexp
  61. DWORD
  62. WriteRegistryDwordA(
  63. HKEY hkey,
  64. LPCSTR pszValueName,
  65. DWORD dwDefaultValue
  66. );
  67. dllexp
  68. DWORD
  69. WriteRegistryStringA(
  70. HKEY hkey,
  71. LPCSTR pszValueName,
  72. LPCSTR pszValue, // null-terminated string
  73. DWORD cbValue, // including terminating null character
  74. DWORD fdwType // REG_SZ, REG_MULTI_SZ ...
  75. );
  76. dllexp
  77. DWORD
  78. WriteRegistryStringW(
  79. HKEY hkey,
  80. LPCWSTR pszValueName,
  81. LPCWSTR pszValue, // null-terminated string
  82. DWORD cbValue, // including terminating null character
  83. DWORD fdwType // REG_SZ, REG_MULTI_SZ ...
  84. );
  85. #define ReadRegistryDword ReadRegistryDwordA
  86. #define WriteRegistryDword WriteRegistryDwordA
  87. #define WriteRegistryString WriteRegistryStringA
  88. dllexp
  89. TCHAR *
  90. ReadRegistryString(
  91. HKEY hkey,
  92. LPCTSTR pszValueName,
  93. LPCTSTR pszDefaultValue,
  94. BOOL fExpand
  95. );
  96. dllexp
  97. TCHAR *
  98. KludgeMultiSz(
  99. HKEY hkey,
  100. LPDWORD lpdwLength
  101. );
  102. //
  103. // Simple wrapper around ReadRegistryString that restores ppchstr if the
  104. // call fails for any reason. Environment variables are always expanded
  105. //
  106. dllexp
  107. BOOL
  108. ReadRegString(
  109. HKEY hkey,
  110. CHAR * * ppchstr,
  111. LPCSTR pchValue,
  112. LPCSTR pchDefault
  113. );
  114. //
  115. // MIDL_user_allocates space for pch and does a unicode conversion into *ppwch
  116. //
  117. dllexp
  118. BOOL
  119. ConvertStringToRpc(
  120. WCHAR * * ppwch,
  121. LPCSTR pch
  122. );
  123. //
  124. // MIDL_user_frees string allocated with ConvertStringToRpc. Noop if pwch is
  125. // NULL
  126. //
  127. dllexp
  128. VOID
  129. FreeRpcString(
  130. WCHAR * pwch
  131. );
  132. dllexp
  133. DWORD
  134. InetNtoa( IN struct in_addr inaddr,
  135. OUT CHAR * pchBuffer /* at least 16 byte buffer */
  136. );
  137. //
  138. // Async Socket send/recv with timeouts
  139. //
  140. BOOL
  141. TcpSockSend(
  142. SOCKET sock,
  143. LPVOID pBuffer,
  144. DWORD cbBuffer,
  145. PDWORD nSent,
  146. DWORD nTimeout
  147. );
  148. BOOL
  149. TcpSockRecv(
  150. SOCKET sock,
  151. LPVOID pBuffer,
  152. DWORD cbBuffer,
  153. PDWORD nReceived,
  154. DWORD nTimeout
  155. );
  156. dllexp
  157. INT
  158. WaitForSocketWorker(
  159. IN SOCKET sockRead,
  160. IN SOCKET sockWrite,
  161. IN LPBOOL pfRead,
  162. IN LPBOOL pfWrite,
  163. IN DWORD nTimeout
  164. );
  165. //
  166. // Test socket if still connected
  167. //
  168. dllexp
  169. BOOL
  170. TcpSockTest(
  171. SOCKET sock
  172. );
  173. //
  174. // Do synchronous readfile
  175. //
  176. dllexp
  177. BOOL
  178. DoSynchronousReadFile(
  179. IN HANDLE hFile,
  180. IN PCHAR Buffer,
  181. IN DWORD nBuffer,
  182. OUT PDWORD nRead,
  183. IN LPOVERLAPPED Overlapped
  184. );
  185. //
  186. // Dll initialization and termination
  187. //
  188. dllexp
  189. BOOL
  190. InitCommonDlls(
  191. VOID
  192. );
  193. dllexp
  194. BOOL
  195. TerminateCommonDlls(
  196. VOID
  197. );
  198. #ifdef __cplusplus
  199. }; // extern "C"
  200. #endif // __cplusplus
  201. #endif // !_TCPPROC_H_