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.

80 lines
2.2 KiB

  1. /************************************************************************************************
  2. Copyright (c) 2001 Microsoft Corporation
  3. File Name: IOContext.hxx
  4. Abstract: Defines the IO_CONTEXT Structure
  5. Notes:
  6. History: 08/01/2001 Created by Hao Yu (haoyu)
  7. ************************************************************************************************/
  8. #ifndef __POP3_IO_CONTEXT__
  9. #define __POP3_IO_CONTEXT__
  10. #include <windows.h>
  11. #include <winsock2.h>
  12. #include <mswsock.h>
  13. #include <winnt.h>
  14. class POP3_CONTEXT;
  15. typedef POP3_CONTEXT *PPOP3_CONTEXT;
  16. #ifndef CONTAINING_RECORD
  17. //
  18. // Calculate the address of the base of the structure given its type, and an
  19. // address of a field within the structure.
  20. //
  21. #define CONTAINING_RECORD(address, type, field) \
  22. ((type *)((PCHAR)(address) - (ULONG_PTR)(&((type *)0)->field)))
  23. #endif // CONTAINING_RECORD
  24. #define HANDLE_TO_SOCKET(h) ((SOCKET)(h))
  25. #define SOCKET_TO_HANDLE(s) ((HANDLE)(s))
  26. #define POP3_REQUEST_BUF_SIZE 1042 // No single POP3 request should exceed this size
  27. #define POP3_RESPONSE_BUF_SIZE 1042 // including NTLM requests/responses
  28. #define DEFAULT_TIME_OUT 600000 //600 seconds or 10 minutes
  29. #define SHORTENED_TIMEOUT 10000 //10 seconds
  30. #define UNLOCKED 0
  31. #define LOCKED_TO_PROCESS_POP3_CMD 1
  32. #define LOCKED_FOR_TIMEOUT 2
  33. typedef void (*CALLBACKFUNC) (PULONG_PTR pCompletionKey ,LPOVERLAPPED pOverlapped, DWORD dwBytesRcvd);
  34. enum IO_TYPE
  35. {
  36. LISTEN_SOCKET,
  37. CONNECTION_SOCKET,
  38. FILE_IO,
  39. DELETE_PENDING,
  40. TOTAL_IO_TYPE
  41. };
  42. // Data structure associated with each async socket or file IO
  43. // for the IO completion port.
  44. struct IO_CONTEXT
  45. {
  46. SOCKET m_hAsyncIO;
  47. OVERLAPPED m_Overlapped;
  48. LIST_ENTRY m_ListEntry;
  49. IO_TYPE m_ConType;
  50. PPOP3_CONTEXT m_pPop3Context;
  51. DWORD m_dwLastIOTime;
  52. DWORD m_dwConnectionTime;
  53. LONG m_lLock;
  54. CALLBACKFUNC m_pCallBack;
  55. char m_Buffer[POP3_REQUEST_BUF_SIZE];
  56. };
  57. typedef IO_CONTEXT *PIO_CONTEXT;
  58. #endif //__POP3_IO_CONTEXT__