POP3CTX.H
上传用户:bangxh
上传日期:2007-01-31
资源大小:42235k
文件大小:6k
源码类别:

Windows编程

开发平台:

Visual C++

  1. /******************************************************************************
  2. *       This is a part of the Microsoft Source Code Samples.
  3. *       Copyright (C) 1992-1997 Microsoft Corporation.
  4. *       All rights reserved. 
  5. *       This source code is only intended as a supplement to 
  6. *       Microsoft Development Tools and/or WinHelp documentation.
  7. *       See these sources for detailed information regarding the 
  8. *       Microsoft samples programs.
  9. ******************************************************************************/
  10. //+---------------------------------------------------------------------------
  11. //
  12. //  File:       pop3ctx.h
  13. //
  14. //  Contents:
  15. //
  16. //  Classes:
  17. //
  18. //  Functions:
  19. //
  20. //----------------------------------------------------------------------------
  21. #ifndef __POP3CTX_H__
  22. #define __POP3CTX_H__
  23. #define POP3_MESSAGE_DELETE     0x00000001  // Message has been "deleted"
  24. typedef enum _LAST_CLIENT_IO {
  25.     ClientIoRead,
  26.     ClientIoWrite,
  27.     ClientIoTransmitFile
  28. } LAST_CLIENT_IO, *PLAST_CLIENT_IO;
  29. typedef struct _CLIENT_CONTEXT {
  30.     SOCKET Socket;
  31.     PVOID Context;
  32.     LAST_CLIENT_IO LastClientIo;
  33.     DWORD BytesReadSoFar;
  34.     HANDLE TransmittedFile;
  35.     HANDLE TransmittedBuffer;
  36.     OVERLAPPED Overlapped;
  37.     CHAR Buffer[8192];
  38. } CLIENT_CONTEXT, *PCLIENT_CONTEXT;
  39. typedef struct _PopMessageHeader {
  40.     DWORD       Flags;                  // Flags about this message
  41.     DWORD       Size;                   // Size of this message
  42.     PWSTR       pszFileName;            // File name containing message
  43. } PopMessageHeader, * PPopMessageHeader;
  44. typedef struct _PopMailDirectory {
  45.     DWORD               Flags;          // Flags about this directory
  46.     DWORD               cMessages;      // Number of messages
  47.     DWORD               NextMessage;    // Next message number
  48.     DWORD               TotalSize;      // Total size of directory, in bytes
  49.     DWORD               cAvailMessages; // Number of messages not deleted
  50.     DWORD               AvailSize;      // Size of available messages
  51.     PWSTR               pBaseDir;       // Base directory
  52.     PPopMessageHeader   Messages;       // Array of message headers
  53. } PopMailDirectory, * PPopMailDirectory;
  54. typedef enum _PopState {
  55.     PopNegotiate,
  56.     PopAuthorization,                   // Authorization State (wait for USER)
  57.     PopAuthorization2,                  // Waiting for PASS
  58.     PopTransact,                        // Transact State
  59.     PopUpdate,                          // Update state
  60.     PopShutdown                         // Rundown state
  61. } PopState, * PPopState;
  62. #define USERNAME_LENGTH 32
  63. typedef struct _PopContext {
  64.     PopState            State;          // State of the connection
  65.     HANDLE              hUserToken;     // Token for impersonation
  66.     HANDLE              hDirectoryLock; // Lock for directory
  67.     DWORD               LastError;      // Last error occurred
  68.     DWORD               RetryCount;     // Number of retries
  69.     PPopMailDirectory   pDirectory;     // Directory for retrieval
  70.     CHAR                UserName[USERNAME_LENGTH];   // User Name for auth
  71. } PopContext, * PPopContext;
  72. typedef enum _Pop3Disposition {
  73.     Pop3_Discard,                       // Discard the request
  74.     Pop3_SendError,                     // Send the error string
  75.     Pop3_SendBuffer,                    // Send the buffer returned
  76.     Pop3_SendFile,                      // Send the File returned
  77.     Pop3_SendBufferThenFile,            // Send the buffer, then the file
  78.     Pop3_SendFileThenBuffer             // Send the file, then the buffer
  79. } Pop3Disposition;
  80. typedef Pop3Disposition
  81. (* Pop3DispatchFn)(
  82.     PPopContext pContext,               // Client's connection context
  83.     PUCHAR      InputBuffer,            // Buffer sent from client
  84.     DWORD       InputBufferLen,         // Size of buffer
  85.     PHANDLE     SendHandle,             // Handle of file to send
  86.     PUCHAR *    OutputBuffer,           // Output buffer to send
  87.     PDWORD      OutputBufferLen         // Size of output buffer
  88.     );
  89. Pop3Disposition
  90. HeloDispatch(
  91.     PPopContext pContext,
  92.     PUCHAR      InputBuffer,
  93.     DWORD       InputBufferLen,
  94.     PHANDLE     SendHandle,
  95.     PUCHAR *    OutputBuffer,
  96.     PDWORD      OutputBufferLen
  97.     );
  98. Pop3Disposition
  99. UserDispatch(
  100.     PPopContext pContext,
  101.     PUCHAR      InputBuffer,
  102.     DWORD       InputBufferLen,
  103.     PHANDLE     SendHandle,
  104.     PUCHAR *    OutputBuffer,
  105.     PDWORD      OutputBufferLen
  106.     );
  107. Pop3Disposition
  108. PassDispatch(
  109.     PPopContext pContext,
  110.     PUCHAR      InputBuffer,
  111.     DWORD       InputBufferLen,
  112.     PHANDLE     SendHandle,
  113.     PUCHAR *    OutputBuffer,
  114.     PDWORD      OutputBufferLen
  115.     );
  116. Pop3Disposition
  117. QuitDispatch(
  118.     PPopContext pContext,
  119.     PUCHAR      InputBuffer,
  120.     DWORD       InputBufferLen,
  121.     PHANDLE     SendHandle,
  122.     PUCHAR *    OutputBuffer,
  123.     PDWORD      OutputBufferLen
  124.     );
  125. Pop3Disposition
  126. StatDispatch(
  127.     PPopContext pContext,
  128.     PUCHAR      InputBuffer,
  129.     DWORD       InputBufferLen,
  130.     PHANDLE     SendHandle,
  131.     PUCHAR *    OutputBuffer,
  132.     PDWORD      OutputBufferLen
  133.     );
  134. Pop3Disposition
  135. ListDispatch(
  136.     PPopContext pContext,
  137.     PUCHAR      InputBuffer,
  138.     DWORD       InputBufferLen,
  139.     PHANDLE     SendHandle,
  140.     PUCHAR *    OutputBuffer,
  141.     PDWORD      OutputBufferLen
  142.     );
  143. Pop3Disposition
  144. RetrDispatch(
  145.     PPopContext pContext,
  146.     PUCHAR      InputBuffer,
  147.     DWORD       InputBufferLen,
  148.     PHANDLE     SendHandle,
  149.     PUCHAR *    OutputBuffer,
  150.     PDWORD      OutputBufferLen
  151.     );
  152. Pop3Disposition
  153. DeleDispatch(
  154.     PPopContext pContext,
  155.     PUCHAR      InputBuffer,
  156.     DWORD       InputBufferLen,
  157.     PHANDLE     SendHandle,
  158.     PUCHAR *    OutputBuffer,
  159.     PDWORD      OutputBufferLen
  160.     );
  161. Pop3Disposition
  162. LastDispatch(
  163.     PPopContext pContext,
  164.     PUCHAR      InputBuffer,
  165.     DWORD       InputBufferLen,
  166.     PHANDLE     SendHandle,
  167.     PUCHAR *    OutputBuffer,
  168.     PDWORD      OutputBufferLen
  169.     );
  170. Pop3Disposition
  171. RsetDispatch(
  172.     PPopContext pContext,
  173.     PUCHAR      InputBuffer,
  174.     DWORD       InputBufferLen,
  175.     PHANDLE     SendHandle,
  176.     PUCHAR *    OutputBuffer,
  177.     PDWORD      OutputBufferLen
  178.     );
  179. #endif