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.

319 lines
8.0 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows NT **/
  3. /** Copyright(c) Microsoft Corp., 1993 **/
  4. /**********************************************************************/
  5. /*
  6. inline.hxx
  7. Contains simple inline functions that can't included inline due to
  8. circular dependencies
  9. FILE HISTORY:
  10. Johnl 10-Sept-1996 Created
  11. */
  12. #ifndef _INLINE_H_
  13. #define _INLINE_H_
  14. /*******************************************************************
  15. NAME: CLIENT_CONN::ReadFile
  16. SYNOPSIS: Simple wrapper around AtqReadSocket
  17. HISTORY:
  18. Johnl 24-Aug-1994 Created
  19. ********************************************************************/
  20. inline
  21. BOOL CLIENT_CONN::ReadFile( LPVOID lpBuffer,
  22. DWORD BytesToRead )
  23. {
  24. WSABUF wsaBuf = { BytesToRead, (CHAR * ) lpBuffer};
  25. Reference();
  26. if ( !AtqReadSocket( QueryAtqContext(),
  27. &wsaBuf,
  28. 1,
  29. NULL ))
  30. {
  31. Dereference();
  32. return FALSE;
  33. }
  34. return TRUE;
  35. }
  36. /*******************************************************************
  37. NAME: CLIENT_CONN::WriteFile
  38. SYNOPSIS: Simple wrapper around AtqWriteSocket
  39. HISTORY:
  40. Johnl 24-Aug-1994 Created
  41. ********************************************************************/
  42. inline
  43. BOOL CLIENT_CONN::WriteFile( LPVOID lpBuffer,
  44. DWORD BytesToWrite )
  45. {
  46. WSABUF wsaBuf = { BytesToWrite, (CHAR * ) lpBuffer};
  47. PATQ_CONTEXT pAtqContext = QueryAtqContext();
  48. Reference();
  49. if ( !AtqWriteSocket( pAtqContext,
  50. &wsaBuf,
  51. 1,
  52. &pAtqContext->Overlapped ))
  53. {
  54. Dereference();
  55. return FALSE;
  56. }
  57. return TRUE;
  58. }
  59. /*******************************************************************
  60. NAME: CLIENT_CONN::SyncWsaSend
  61. SYNOPSIS: Simple wrapper around AtqSyncWsaSend
  62. for writing an array of WSABUFs synchronously
  63. HISTORY:
  64. DaveK 5-Aug-1997 Created
  65. ********************************************************************/
  66. inline
  67. BOOL CLIENT_CONN::SyncWsaSend( WSABUF * rgWsaBuffers,
  68. DWORD cWsaBuffers,
  69. LPDWORD pcbWritten
  70. )
  71. {
  72. Reference();
  73. BOOL fRes = AtqSyncWsaSend( QueryAtqContext(),
  74. rgWsaBuffers,
  75. cWsaBuffers,
  76. pcbWritten );
  77. Dereference();
  78. return fRes;
  79. }
  80. /*******************************************************************
  81. NAME: CLIENT_CONN::TransmitFile
  82. SYNOPSIS: Simple wrapper around AtqTransmitFile
  83. HISTORY:
  84. Johnl 24-Aug-1994 Created
  85. ********************************************************************/
  86. inline
  87. BOOL CLIENT_CONN::TransmitFile( HANDLE hFile,
  88. DWORD Offset,
  89. DWORD BytesToWrite,
  90. DWORD dwFlags,
  91. PVOID pHead,
  92. DWORD HeadLength,
  93. PVOID pTail,
  94. DWORD TailLength )
  95. {
  96. TRANSMIT_FILE_BUFFERS tfb;
  97. dwFlags &= (TF_DISCONNECT | TF_REUSE_SOCKET);
  98. tfb.Head = pHead;
  99. tfb.HeadLength = HeadLength;
  100. tfb.Tail = pTail;
  101. tfb.TailLength = TailLength;
  102. Reference();
  103. QueryAtqContext()->Overlapped.Offset = Offset;
  104. if ( !AtqTransmitFile( QueryAtqContext(),
  105. hFile,
  106. BytesToWrite,
  107. &tfb,
  108. dwFlags ))
  109. {
  110. Dereference();
  111. return FALSE;
  112. }
  113. return TRUE;
  114. }
  115. /*******************************************************************
  116. NAME: CLIENT_CONN::TransmitFileAndRecv
  117. SYNOPSIS: Simple wrapper around AtqTransmitFileAndRecv
  118. HISTORY:
  119. JBallard 13-Nov-1996 Created
  120. ********************************************************************/
  121. inline
  122. BOOL CLIENT_CONN::TransmitFileAndRecv( HANDLE hFile,
  123. DWORD Offset,
  124. DWORD BytesToWrite,
  125. DWORD dwFlags,
  126. PVOID pHead,
  127. DWORD HeadLength,
  128. PVOID pTail,
  129. DWORD TailLength,
  130. LPVOID lpBuffer,
  131. DWORD BytesToRead )
  132. {
  133. DBG_ASSERT( g_fUseAndRecv );
  134. TRANSMIT_FILE_BUFFERS tfb;
  135. WSABUF wsaBuf = { BytesToRead, (CHAR * ) lpBuffer};
  136. dwFlags &= (TF_DISCONNECT | TF_REUSE_SOCKET);
  137. tfb.Head = pHead;
  138. tfb.HeadLength = HeadLength;
  139. tfb.Tail = pTail;
  140. tfb.TailLength = TailLength;
  141. Reference();
  142. QueryAtqContext()->Overlapped.Offset = Offset;
  143. if ( !AtqTransmitFileAndRecv( QueryAtqContext(),
  144. hFile,
  145. BytesToWrite,
  146. &tfb,
  147. dwFlags,
  148. &wsaBuf,
  149. 1 ))
  150. {
  151. Dereference();
  152. return FALSE;
  153. }
  154. return TRUE;
  155. }
  156. /*******************************************************************
  157. NAME: CLIENT_CONN::WriteFileAndRecv
  158. SYNOPSIS: Simple wrapper around AtqSendAndRecv
  159. HISTORY:
  160. JBallard 13-Nov-1996 Created
  161. ********************************************************************/
  162. inline
  163. BOOL CLIENT_CONN::WriteFileAndRecv( LPVOID lpSendBuffer,
  164. DWORD BytesToWrite,
  165. LPVOID lpRecvBuffer,
  166. DWORD BytesToRead )
  167. {
  168. DBG_ASSERT( g_fUseAndRecv );
  169. WSABUF wsaSendBuf = { BytesToWrite, (CHAR * ) lpSendBuffer};
  170. WSABUF wsaRecvBuf = { BytesToRead, (CHAR * ) lpRecvBuffer};
  171. Reference();
  172. if ( !AtqSendAndRecv( QueryAtqContext(),
  173. &wsaSendBuf,
  174. 1,
  175. &wsaRecvBuf,
  176. 1 ))
  177. {
  178. Dereference();
  179. return FALSE;
  180. }
  181. return TRUE;
  182. }
  183. inline
  184. BOOL
  185. CLIENT_CONN::PostCompletionStatus(
  186. DWORD BytesTransferred
  187. )
  188. /*++
  189. Routine Description:
  190. Posts a completion status to this connection's ATQ context
  191. Arguments:
  192. BytesTransferred - Count of bytes sent or received from buffer
  193. Return Value:
  194. TRUE on success, FALSE on failure (call GetLastError)
  195. --*/
  196. {
  197. Reference();
  198. if ( !AtqPostCompletionStatus( QueryAtqContext(),
  199. BytesTransferred ))
  200. {
  201. Dereference();
  202. return FALSE;
  203. }
  204. return TRUE;
  205. }
  206. /*******************************************************************
  207. NAME: HTTP_REQ_BASE::Disconnect
  208. SYNOPSIS: Forwards the disconnect request to the client connection
  209. ENTRY: Same as for CLIENT_CONN::Disconnect
  210. HISTORY:
  211. Johnl 24-Aug-1994 Created
  212. ********************************************************************/
  213. inline
  214. VOID HTTP_REQ_BASE::Disconnect( DWORD htResp,
  215. DWORD dwError2,
  216. BOOL fDoShutdown,
  217. LPBOOL pfFinished )
  218. {
  219. _pClientConn->Disconnect( this, htResp, dwError2, fDoShutdown, pfFinished );
  220. }
  221. inline
  222. DWORD HTTP_REQ_BASE::Reference( VOID )
  223. {
  224. return _pClientConn->Reference();
  225. }
  226. inline
  227. DWORD HTTP_REQ_BASE::Dereference( VOID )
  228. {
  229. return _pClientConn->Dereference();
  230. }
  231. inline
  232. DWORD HTTP_REQ_BASE::QueryRefCount( VOID )
  233. {
  234. return _pClientConn->QueryRefCount();
  235. }
  236. #pragma hdrstop
  237. #endif // _W3P_H_