Source code of Windows XP (NT5)
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.

122 lines
3.0 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1996.
  5. //
  6. // File:clusbrow.cpp
  7. //
  8. // Contents: To list all the clusters in the network.
  9. //
  10. //
  11. // Classes:
  12. //
  13. // Functions:
  14. //
  15. // Coupling:
  16. //
  17. // Notes:
  18. //
  19. // History: 3-24-1997 sivapad Created
  20. //
  21. //----------------------------------------------------------------------------
  22. #define UNICODE 1
  23. #define _UNICODE 1
  24. #include <windows.h>
  25. #include <lmcons.h>
  26. #include <lmerr.h>
  27. #include <lmserver.h>
  28. #include <windns.h>
  29. #include <stdio.h>
  30. #include <stdlib.h>
  31. #define SRV101_ENTRY_COUNT 1024
  32. void Usage ()
  33. {
  34. wprintf (L"clusbrow [domain:<Domain name>] [servertype:CORE|VS]\n") ;
  35. exit (1) ;
  36. }
  37. int __cdecl
  38. wmain (DWORD argc, WCHAR *argv[])
  39. {
  40. PSERVER_INFO_101 srvInfo;
  41. DWORD i, dwRet, entriesRead, totalEntries ;
  42. DWORD serverType = SV_TYPE_CLUSTER_NT | SV_TYPE_CLUSTER_VS_NT ;
  43. DWORD entryCount;
  44. WCHAR blanks[] = L" ";
  45. DWORD numBlanks;
  46. WCHAR szDomainName [DNS_MAX_NAME_BUFFER_LENGTH] ;
  47. LPTSTR pszDomainName = NULL ;
  48. // Process the command line arguments
  49. for (i=1; i<argc; i++)
  50. {
  51. if (_wcsnicmp (argv[i], L"domain:", 7) == 0)
  52. {
  53. swprintf (szDomainName, L"%hs", argv[i]+7) ;
  54. pszDomainName = szDomainName ;
  55. }
  56. else if (_wcsnicmp (argv[i], L"servertype:", 11) == 0)
  57. {
  58. serverType = 0;
  59. if (_wcsnicmp( argv[i]+11, L"core", 4 ) == 0 ) {
  60. serverType = SV_TYPE_CLUSTER_NT;
  61. }
  62. if (_wcsnicmp( argv[i]+11, L"vs", 2 ) == 0 ) {
  63. serverType |= SV_TYPE_CLUSTER_VS_NT;
  64. }
  65. }
  66. else
  67. {
  68. Usage () ;
  69. }
  70. }
  71. dwRet = NetServerEnum (NULL,
  72. 101,
  73. (LPBYTE *)&srvInfo,
  74. MAX_PREFERRED_LENGTH,
  75. &entriesRead,
  76. &totalEntries,
  77. serverType,
  78. pszDomainName,
  79. 0) ;
  80. if (dwRet == NERR_Success)
  81. {
  82. wprintf(L"Number of Entries found = %u\n", totalEntries );
  83. for (i=0; i < entriesRead; i++) {
  84. numBlanks = 20 - wcslen( srvInfo->sv101_name );
  85. wprintf (L"%ws%.*ws", srvInfo->sv101_name, numBlanks, blanks );
  86. if ( srvInfo->sv101_type & SV_TYPE_CLUSTER_NT &&
  87. srvInfo->sv101_type & SV_TYPE_CLUSTER_VS_NT )
  88. {
  89. wprintf(L"CORE, VS");
  90. } else if ( srvInfo->sv101_type & SV_TYPE_CLUSTER_NT ) {
  91. wprintf(L"CORE");
  92. } else if ( srvInfo->sv101_type & SV_TYPE_CLUSTER_VS_NT ) {
  93. wprintf(L"VS");
  94. }
  95. else {
  96. wprintf(L"????");
  97. }
  98. wprintf(L"\n");
  99. ++srvInfo;
  100. }
  101. }
  102. else
  103. {
  104. wprintf (L"Error, making the actual call to NetServerEnum dwRet=%d\n", dwRet) ;
  105. exit (1) ;
  106. }
  107. return 0 ;
  108. }