Leaked source code of windows server 2003
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.

206 lines
4.3 KiB

  1. /*++
  2. Copyright (c) 1994 Microsoft Corporation
  3. Module Name:
  4. buffer.h
  5. Abstract:
  6. Contains manifests, macros, types and typedefs for buffer.c
  7. Author:
  8. Richard L Firth (rfirth) 31-Oct-1994
  9. Revision History:
  10. 31-Oct-1994 rfirth
  11. Created
  12. --*/
  13. #if defined(__cplusplus)
  14. extern "C" {
  15. #endif
  16. //
  17. // manifests
  18. //
  19. //
  20. // LOOK_AHEAD_LENGTH - read enough characters to comprise the maximum (32-bit)
  21. // length returned by gopher+
  22. //
  23. #define LOOK_AHEAD_LENGTH sizeof("+4294967296\r\n") // 12
  24. //
  25. // BUFFER_INFO - structure maintains information about responses from gopher
  26. // server. The same data can be shared amongst many requests
  27. //
  28. typedef struct {
  29. //
  30. // ReferenceCount - number of VIEW_INFO structures referencing this buffer
  31. //
  32. LONG ReferenceCount;
  33. //
  34. // Flags - information about the buffer
  35. //
  36. DWORD Flags;
  37. //
  38. // RequestEvent - the owner of this event is the only thread which can
  39. // make the gopher request that creates this buffer info. All other
  40. // requesters for the same information wait for the first thread to signal
  41. // the event, then just read the data returned by the first thread
  42. //
  43. // HANDLE RequestEvent;
  44. //
  45. // RequestWaiters - used in conjunction with RequestEvent. If this field
  46. // is 0 by the time the initial requester thread comes to signal the
  47. // event, it can do away with the event altogether, since it was only
  48. // required to stop those other threads from making a redundant request
  49. //
  50. // DWORD RequestWaiters;
  51. //
  52. // ConnectedSocket - contains socket we are using to receive the data in
  53. // the buffer, and the index into the parent SESSION_INFO's
  54. // ADDRESS_INFO_LIST of the address used to connect the socket
  55. //
  56. // CONNECTED_SOCKET ConnectedSocket;
  57. ICSocket * Socket;
  58. //
  59. // ResponseLength - the response length as told to us by the gopher+ server
  60. //
  61. int ResponseLength;
  62. //
  63. // BufferLength - length of Buffer
  64. //
  65. DWORD BufferLength;
  66. //
  67. // Buffer - containing response
  68. //
  69. LPBYTE Buffer;
  70. //
  71. // ResponseInfo - we read the gopher+ header information (i.e. length) here.
  72. // The main reason is so that we can determine the length of a gopher+ file
  73. // even though we were given a zero-length user buffer
  74. //
  75. char ResponseInfo[LOOK_AHEAD_LENGTH];
  76. //
  77. // BytesRemaining - number of bytes left in ResponseInfo that are data
  78. //
  79. int BytesRemaining;
  80. //
  81. // DataBytes - pointer into ResponseInfo where data bytes start
  82. //
  83. LPBYTE DataBytes;
  84. //
  85. // CriticalSection - used to serialize readers
  86. //
  87. // CRITICAL_SECTION CriticalSection;
  88. } BUFFER_INFO, *LPBUFFER_INFO;
  89. //
  90. // BUFFER_INFO flags
  91. //
  92. #define BI_RECEIVE_COMPLETE 0x00000001 // receiver thread has finished
  93. #define BI_DOT_AT_END 0x00000002 // buffer terminated with ".\r\n"
  94. #define BI_BUFFER_RESPONSE 0x00000004 // response is buffered internally
  95. #define BI_ERROR_RESPONSE 0x00000008 // the server responded with an error
  96. #define BI_MOVEABLE 0x00000010 // buffer is moveable memory
  97. #define BI_FIRST_RECEIVE 0x00000020 // this is the first receive
  98. #define BI_OWN_BUFFER 0x00000040 // set if we own the buffer (directory)
  99. //
  100. // external data
  101. //
  102. DEBUG_DATA_EXTERN(LONG, NumberOfBuffers);
  103. //
  104. // prototypes
  105. //
  106. LPBUFFER_INFO
  107. CreateBuffer(
  108. OUT LPDWORD Error
  109. );
  110. VOID
  111. DestroyBuffer(
  112. IN LPBUFFER_INFO BufferInfo
  113. );
  114. VOID
  115. AcquireBufferLock(
  116. IN LPBUFFER_INFO BufferInfo
  117. );
  118. VOID
  119. ReleaseBufferLock(
  120. IN LPBUFFER_INFO BufferInfo
  121. );
  122. VOID
  123. ReferenceBuffer(
  124. IN LPBUFFER_INFO BufferInfo
  125. );
  126. LPBUFFER_INFO
  127. DereferenceBuffer(
  128. IN LPBUFFER_INFO BufferInfo
  129. );
  130. //
  131. // macros
  132. //
  133. #if INET_DEBUG
  134. #define BUFFER_CREATED() ++NumberOfBuffers
  135. #define BUFFER_DESTROYED() --NumberOfBuffers
  136. #define ASSERT_NO_BUFFERS() \
  137. if (NumberOfBuffers != 0) { \
  138. INET_ASSERT(FALSE); \
  139. }
  140. #else
  141. #define BUFFER_CREATED() /* NOTHING */
  142. #define BUFFER_DESTROYED() /* NOTHING */
  143. #define ASSERT_NO_BUFFERS() /* NOTHING */
  144. #endif
  145. #if defined(__cplusplus)
  146. }
  147. #endif