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.

96 lines
2.6 KiB

  1. //--------------------------------------------------------------------------------------------
  2. //
  3. // Copyright (c) Microsoft Corporation, 1996
  4. //
  5. // Description:
  6. //
  7. // Microsoft Internet LDAP Client.
  8. //
  9. // Classes that manage connections with an LDAP server.
  10. //
  11. // Authors:
  12. //
  13. // RobertC 04/18/96
  14. //
  15. //--------------------------------------------------------------------------------------------
  16. // NOTE: this class is responsible for buffering all data until complete top-level structures
  17. // are received.
  18. #ifndef _LSWINSOC_H
  19. #define _LSWINSOC_H
  20. //--------------------------------------------------------------------------------------------
  21. //
  22. // DEFINITIONS
  23. //
  24. //--------------------------------------------------------------------------------------------
  25. typedef void (*PFNRECEIVEDATA)(PVOID pvCookie, PVOID pv, int cb, int *pcbReceived);
  26. //--------------------------------------------------------------------------------------------
  27. //
  28. // CONSTANTS
  29. //
  30. //--------------------------------------------------------------------------------------------
  31. const int CBBUFFERGROW = 4096;
  32. //--------------------------------------------------------------------------------------------
  33. //
  34. // FUNCTIONS
  35. //
  36. //--------------------------------------------------------------------------------------------
  37. extern BOOL FInitSocketDLL();
  38. extern void FreeSocketDLL();
  39. //--------------------------------------------------------------------------------------------
  40. //
  41. // CLASSES
  42. //
  43. //--------------------------------------------------------------------------------------------
  44. class CLdapWinsock
  45. {
  46. //
  47. // Interfaces
  48. //
  49. public:
  50. CLdapWinsock();
  51. ~CLdapWinsock(void);
  52. STDMETHODIMP HrConnect(PFNRECEIVEDATA pfnReceive, PVOID pvCookie, char *szServer, USHORT usPort = IPPORT_LDAP);
  53. STDMETHODIMP HrDisconnect(void);
  54. STDMETHODIMP HrIsConnected(void);
  55. STDMETHODIMP HrSend(PVOID pv, int cb);
  56. protected:
  57. friend DWORD __stdcall DwReadThread(PVOID pvData);
  58. DWORD DwReadThread(void);
  59. private:
  60. void Receive(PVOID pv, int cb, int *pcbReceived);
  61. HRESULT HrCreateReadThread(void);
  62. HRESULT HrLastWinsockError(void);
  63. CRITICAL_SECTION m_cs;
  64. SOCKET m_sc;
  65. BOOL m_fConnected;
  66. HANDLE m_hthread;
  67. DWORD m_dwTid;
  68. PFNRECEIVEDATA m_pfnReceive;
  69. PVOID m_pvCookie;
  70. // read buffer
  71. HRESULT HrGrowBuffer();
  72. BYTE *m_pbBuf; // buffer for socket to read into
  73. int m_cbBuf; // current amount of data in the buffer
  74. int m_cbBufMax; // total size of buffer
  75. };
  76. #endif