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.

209 lines
4.6 KiB

  1. /*++
  2. Copyright (c) 1991-1993 Microsoft Corporation
  3. Module Name:
  4. Disp.c
  5. Abstract:
  6. This file contains routines which display low-level data items in
  7. a consistent manner. The output is done in a fixed-width-column
  8. fashion, similar to some of the NET.EXE outputs. These routines are
  9. part of the RxTest program.
  10. Author:
  11. John Rogers (JohnRo) 03-May-1991
  12. Environment:
  13. Portable to any flat, 32-bit environment. (Uses Win32 typedefs.)
  14. Requires ANSI C extensions: slash-slash comments, long external names.
  15. Revision History:
  16. 03-May-1991 JohnRo
  17. Created.
  18. 15-May-1991 JohnRo
  19. Prevent possible errors in DisplayString if string has % in it.
  20. Added DisplayWord(), DisplayWordHex().
  21. 13-Jun-1991 JohnRo
  22. Moved from RxTest to NetLib; changed routine names.
  23. 05-Jul-1991 JohnRo
  24. Avoid FORMAT_WORD name (used by MIPS header files).
  25. 10-Sep-1991 JohnRo
  26. Made changes suggested by PC-LINT. (LmCons.h isn't needed.)
  27. 13-Sep-1991 JohnRo
  28. Use LPDEBUG_STRING instead of LPTSTR, to avoid UNICODE problems.
  29. 07-Jan-1992 JohnRo
  30. Added NetpDbgDisplayTStr() and NetpDbgDisplayWStr().
  31. 19-Jul-1992 JohnRo
  32. RAID 464 (old RAID 10324): net print vs. UNICODE.
  33. 17-Aug-1992 JohnRo
  34. RAID 2920: Support UTC timezone in net code.
  35. 05-Jan-1993 JohnRo
  36. Repl WAN support (get rid of repl name list limits).
  37. Avoid stack overflow on very long strings.
  38. --*/
  39. // These must be included first:
  40. #include <windef.h> // IN, DWORD, etc.
  41. // These may be included in any order:
  42. #include <netdebug.h> // FORMAT_ equates, NetpDbg routines.
  43. #include <tstr.h> // STRCAT(), ULTOA(), etc.
  44. // NT debug routines seem to die at around 255 chars.
  45. #define PARTIAL_NAME_LIST_LEN 250
  46. #define PARTIAL_NAME_LIST_FORMAT_A "%-.250s"
  47. #define PARTIAL_NAME_LIST_FORMAT_W "%-.250ws"
  48. #define EMPTY_STRING "(none)"
  49. #define FIXED_WIDTH_STRING "%-30s: "
  50. #define PARTIAL_FIXED_WIDTH_STRING "%-20s (partial): "
  51. #define INDENT " "
  52. #if DBG
  53. DBGSTATIC VOID
  54. NetpDbgDisplayTagForPartial(
  55. IN LPDEBUG_STRING Tag
  56. );
  57. DBGSTATIC VOID
  58. NetpDbgDisplayAnyStringType(
  59. IN LPDEBUG_STRING Tag,
  60. IN LPVOID Value,
  61. IN BOOL InputIsUnicode
  62. )
  63. {
  64. LPDEBUG_STRING Format;
  65. DWORD ValueLength;
  66. if (Value != NULL) {
  67. if (InputIsUnicode) {
  68. ValueLength = wcslen( Value );
  69. Format = FORMAT_LPWSTR;
  70. } else {
  71. ValueLength = strlen( Value );
  72. Format = FORMAT_LPSTR;
  73. }
  74. if ( ValueLength < PARTIAL_NAME_LIST_LEN ) { // normal
  75. NetpDbgDisplayTag( Tag );
  76. NetpKdPrint(( Format, Value ));
  77. } else { // string too long; just display partial...
  78. NetpDbgDisplayTagForPartial( Tag );
  79. if (InputIsUnicode) {
  80. Format = PARTIAL_NAME_LIST_FORMAT_W;
  81. } else {
  82. Format = PARTIAL_NAME_LIST_FORMAT_A;
  83. }
  84. NetpKdPrint(( Format, Value )); // print truncated version
  85. }
  86. } else {
  87. NetpDbgDisplayTag( Tag );
  88. NetpKdPrint(( EMPTY_STRING ));
  89. }
  90. NetpKdPrint(( "\n" ));
  91. } // NetpDbgDisplayAnyStringType
  92. #endif // DBG
  93. #undef NetpDbgDisplayDword
  94. VOID
  95. NetpDbgDisplayDword(
  96. IN LPDEBUG_STRING Tag,
  97. IN DWORD Value
  98. )
  99. {
  100. #if DBG
  101. NetpDbgDisplayTag( Tag );
  102. NetpKdPrint((FORMAT_DWORD, Value));
  103. NetpKdPrint(("\n"));
  104. #endif // DBG
  105. } // NetpDbgDisplayDword
  106. #if DBG
  107. VOID
  108. NetpDbgDisplayLong(
  109. IN LPDEBUG_STRING Tag,
  110. IN LONG Value
  111. )
  112. {
  113. NetpDbgDisplayTag( Tag );
  114. NetpKdPrint((FORMAT_LONG, Value));
  115. NetpKdPrint(("\n"));
  116. } // NetpDbgDisplayLong
  117. VOID
  118. NetpDbgDisplayString(
  119. IN LPDEBUG_STRING Tag,
  120. IN LPTSTR Value
  121. )
  122. {
  123. NetpDbgDisplayAnyStringType(
  124. Tag,
  125. Value,
  126. #ifndef UNICODE
  127. FALSE ); // input is not UNICODE
  128. #else
  129. TRUE ); // input is UNICODE
  130. #endif
  131. } // NetpDbgDisplayString
  132. VOID
  133. NetpDbgDisplayTag(
  134. IN LPDEBUG_STRING Tag
  135. )
  136. {
  137. NetpAssert( Tag != NULL );
  138. NetpKdPrint((INDENT FIXED_WIDTH_STRING, Tag));
  139. } // NetpDbgDisplayTag
  140. DBGSTATIC VOID
  141. NetpDbgDisplayTagForPartial(
  142. IN LPDEBUG_STRING Tag
  143. )
  144. {
  145. NetpAssert( Tag != NULL );
  146. NetpKdPrint(( INDENT PARTIAL_FIXED_WIDTH_STRING, Tag ));
  147. } // NetpDbgDisplayTagForPartial
  148. #endif // DBG