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.

125 lines
3.5 KiB

  1. //+--------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997.
  5. //
  6. // File: getcli.h
  7. //
  8. // Contents: Get clients for a test
  9. //
  10. // Functions: GetClients
  11. //
  12. // History: 02-Jun-97 MikeW Created
  13. //
  14. //---------------------------------------------------------------------------
  15. #ifndef _GETCLI_H_
  16. #define _GETCLI_H_
  17. #pragma once
  18. //+--------------------------------------------------------------------------
  19. //
  20. // Class: ClientData
  21. //
  22. // Synopsis: Encapsulate data about each client (or peer) the host is
  23. // working with.
  24. //
  25. // History: 02-Jun-97 MikeW Created
  26. //
  27. // Notes: To allocate, call "p = new(x) ClientData" where x is the
  28. // maximum number of clients. To deallocate call "delete p"
  29. //
  30. //---------------------------------------------------------------------------
  31. struct ClientData
  32. {
  33. int client_count; // Number of clients
  34. struct PerClientData // Info for each client
  35. {
  36. DWORD context; // context (local, remote, etc)
  37. LPWSTR machine_name; // machine name for remote clients
  38. }
  39. client[ANYSIZE_ARRAY];
  40. //
  41. // a ClientData is a variable sized structure. Define some routines
  42. // to make using them easier.
  43. //
  44. HRESULT SetMachineName(UINT client, LPCWSTR machine_name);
  45. inline void * operator new(size_t /* UNREF bytes */, UINT client_count);
  46. inline void operator delete(void *_this);
  47. };
  48. //+--------------------------------------------------------------------------
  49. //
  50. // Method: ClientData::operator new
  51. //
  52. // Synopsis: Allocate the variable sized ClientData structure
  53. //
  54. // Parameters: [client_count] -- The number of clients
  55. //
  56. // Returns: A pointer to the storage for the new object
  57. //
  58. // History: 02-Jun-97 MikeW Created
  59. //
  60. //---------------------------------------------------------------------------
  61. inline void * ClientData::operator new(
  62. size_t /* UNREF bytes */,
  63. UINT client_count)
  64. {
  65. return new BYTE[sizeof(ClientData)
  66. + sizeof(PerClientData)
  67. * (client_count - ANYSIZE_ARRAY)
  68. + (MAX_COMPUTERNAME_LENGTH + 1)
  69. * client_count * sizeof(WCHAR)];
  70. }
  71. //+--------------------------------------------------------------------------
  72. //
  73. // Method: ClientData::operator delete
  74. //
  75. // Synopsis: De-allocate the variable sized ClientData structure
  76. //
  77. // Parameters: [_this] -- "this" pointer
  78. //
  79. // Returns: void
  80. //
  81. // History: 02-Jun-97 MikeW Created
  82. //
  83. //---------------------------------------------------------------------------
  84. inline void ClientData::operator delete(void *_this)
  85. {
  86. delete [] (BYTE *) _this;
  87. }
  88. //
  89. // Functions to discover clients
  90. //
  91. HRESULT GetClients(
  92. ClientData **pp_client_data,
  93. DWORD contexts,
  94. int client_count,
  95. const GUID &test_id = GUID_NULL,
  96. LPWSTR test_description = NULL);
  97. HRESULT GetRemoteClients(
  98. ClientData *client_data,
  99. const GUID &test_id,
  100. LPWSTR test_description);
  101. #endif // _GETCLI_H_