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.

177 lines
4.9 KiB

  1. /*++
  2. Copyright (c) 1991-1992 Microsoft Corporation
  3. Module Name:
  4. SvcInfo.c
  5. Abstract:
  6. This file contains NetpServiceStructureInfo().
  7. Author:
  8. John Rogers (JohnRo) 15-Aug-1991
  9. Environment:
  10. Portable to any flat, 32-bit environment. (Uses Win32 typedefs.)
  11. Requires ANSI C extensions: slash-slash comments, long external names.
  12. Revision History:
  13. 10-Sep-1991 JohnRo
  14. Downlevel NetService APIs.
  15. 20-Sep-1991 JohnRo
  16. Support non-native structure sizes.
  17. 21-Oct-1991 JohnRo
  18. Quiet normal debug output.
  19. 20-Nov-1991 JohnRo
  20. Removed NT dependencies to reduce recompiles.
  21. 31-Aug-1992 JohnRo
  22. Allow NT-sized service names.
  23. Use PREFIX_ equates.
  24. --*/
  25. // These must be included first:
  26. #include <windef.h> // IN, DWORD, etc.
  27. #include <lmcons.h> // LM20_ equates, NET_API_STATUS, etc.
  28. #include <rap.h> // LPDESC, needed by <strucinf.h>.
  29. // These may be included in any order:
  30. #include <debuglib.h> // IF_DEBUG().
  31. #include <lmerr.h> // ERROR_ and NERR_ equates.
  32. #include <lmsvc.h> // SERVICE_INFO_2, etc.
  33. #include <netlib.h> // NetpSetOptionalArg().
  34. #include <netdebug.h> // NetpKdPrint(()).
  35. #include <prefix.h> // PREFIX_ equates.
  36. #include <remdef.h> // REM16_, REM32_, REMSmb_ equates.
  37. #include <strucinf.h> // My prototype.
  38. #define MAX_SERVICE_0_STRING_LENGTH \
  39. (SNLEN+1)
  40. #define MAX_SERVICE_0_STRING_SIZE \
  41. (MAX_SERVICE_0_STRING_LENGTH * sizeof(TCHAR))
  42. #define MAX_SERVICE_1_STRING_LENGTH \
  43. (MAX_SERVICE_0_STRING_LENGTH)
  44. #define MAX_SERVICE_1_STRING_SIZE \
  45. (MAX_SERVICE_1_STRING_LENGTH * sizeof(TCHAR))
  46. //
  47. // The extra SNLEN+1 added below is for the display name.
  48. //
  49. #define MAX_SERVICE_2_STRING_LENGTH \
  50. (MAX_SERVICE_1_STRING_LENGTH + LM20_STXTLEN+1 + SNLEN+1)
  51. #define MAX_SERVICE_2_STRING_SIZE \
  52. (MAX_SERVICE_2_STRING_LENGTH * sizeof(TCHAR))
  53. NET_API_STATUS
  54. NetpServiceStructureInfo (
  55. IN DWORD Level,
  56. IN DWORD ParmNum, // Use PARMNUM_ALL if not applicable.
  57. IN BOOL Native, // Should sizes be native or RAP?
  58. OUT LPDESC * DataDesc16 OPTIONAL,
  59. OUT LPDESC * DataDesc32 OPTIONAL,
  60. OUT LPDESC * DataDescSmb OPTIONAL,
  61. OUT LPDWORD MaxSize OPTIONAL,
  62. OUT LPDWORD FixedSize OPTIONAL,
  63. OUT LPDWORD StringSize OPTIONAL
  64. )
  65. {
  66. LPDESC LocalDataDesc16, LocalDataDesc32, LocalDataDescSmb;
  67. DBG_UNREFERENCED_PARAMETER(ParmNum);
  68. //
  69. // Decide what to do based on the info level.
  70. //
  71. switch (Level) {
  72. #define SetSizes(fixed,variable) \
  73. { \
  74. NetpSetOptionalArg( MaxSize, (fixed) + (variable) ); \
  75. NetpSetOptionalArg( FixedSize, (fixed) ); \
  76. NetpSetOptionalArg( StringSize, (variable) ); \
  77. }
  78. case 0 :
  79. LocalDataDesc16 = REM16_service_info_0;
  80. LocalDataDesc32 = REM32_service_info_0;
  81. LocalDataDescSmb = REMSmb_service_info_0;
  82. if (Native) {
  83. SetSizes( sizeof(SERVICE_INFO_0), MAX_SERVICE_0_STRING_SIZE );
  84. } else {
  85. // RAP sizes set below.
  86. }
  87. break;
  88. case 1 :
  89. LocalDataDesc16 = REM16_service_info_1;
  90. LocalDataDesc32 = REM32_service_info_1;
  91. LocalDataDescSmb = REMSmb_service_info_1;
  92. if (Native) {
  93. SetSizes( sizeof(SERVICE_INFO_1), MAX_SERVICE_1_STRING_SIZE );
  94. } else {
  95. // RAP sizes set below.
  96. }
  97. break;
  98. case 2 :
  99. LocalDataDesc16 = REM16_service_info_2;
  100. LocalDataDesc32 = REM32_service_info_2;
  101. LocalDataDescSmb = REMSmb_service_info_2;
  102. if (Native) {
  103. SetSizes( sizeof(SERVICE_INFO_2), MAX_SERVICE_2_STRING_SIZE );
  104. } else {
  105. // RAP sizes set below.
  106. }
  107. break;
  108. default :
  109. return (ERROR_INVALID_LEVEL);
  110. }
  111. // Set RAP sizes
  112. if (Native == FALSE) {
  113. DWORD NonnativeFixedSize;
  114. NonnativeFixedSize = RapStructureSize (
  115. LocalDataDesc16,
  116. Both, // transmission mode
  117. FALSE); // not native
  118. NetpAssert( NonnativeFixedSize > 0 );
  119. SetSizes( NonnativeFixedSize, 0 );
  120. }
  121. NetpSetOptionalArg( DataDesc16, LocalDataDesc16 );
  122. NetpSetOptionalArg( DataDesc32, LocalDataDesc32 );
  123. NetpSetOptionalArg( DataDescSmb, LocalDataDescSmb );
  124. IF_DEBUG(STRUCINF) {
  125. if (DataDesc16) {
  126. NetpKdPrint(( PREFIX_NETLIB
  127. "NetpServiceStructureInfo: desc 16 is "
  128. FORMAT_LPDESC ".\n", *DataDesc16 ));
  129. }
  130. if (DataDesc32) {
  131. NetpKdPrint(( PREFIX_NETLIB
  132. "NetpServiceStructureInfo: desc 32 is "
  133. FORMAT_LPDESC ".\n", *DataDesc32 ));
  134. }
  135. if (DataDescSmb) {
  136. NetpKdPrint(( PREFIX_NETLIB
  137. "NetpServiceStructureInfo: desc Smb is "
  138. FORMAT_LPDESC ".\n", *DataDescSmb ));
  139. }
  140. }
  141. return (NERR_Success);
  142. } // NetpServiceStructureInfo