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.

133 lines
3.6 KiB

  1. /*++
  2. Copyright (c) 1991-1993 Microsoft Corporation
  3. Module Name:
  4. DispTime.c
  5. Abstract:
  6. This file contains;
  7. NetpDbgDisplayFileTime
  8. NetpDbgDisplayFileIntegerTime
  9. NetpDbgDisplayTimestamp
  10. NetpDbgDisplayTod
  11. Author:
  12. John Rogers (JohnRo) 25-Mar-1991
  13. Environment:
  14. Portable to any flat, 32-bit environment. (Uses Win32 typedefs.)
  15. Requires ANSI C extensions: slash-slash comments, long external names.
  16. This code assumes that time_t is expressed in seconds since 1970 (GMT).
  17. ANSI C does not require this, although POSIX (IEEE 1003.1) does.
  18. Revision History:
  19. 25-Mar-1991 JohnRo
  20. Created as part of RpcXlate TOD (time of day) tests.
  21. 26-Feb-1992 JohnRo
  22. Extracted this routine for general use.
  23. 27-Feb-1992 JohnRo
  24. Improved handling of times 0 and -1.
  25. 20-Aug-1992 JohnRo
  26. RAID 2920: Support UTC timezone in net code.
  27. 01-Oct-1992 JohnRo
  28. RAID 3556: Avoid failure if ctime() returns NULL.
  29. 04-Mar-1993 JohnRo
  30. RAID 12237: replicator tree depth exceeded (add display of FILETIME
  31. and LARGE_INTEGER time).
  32. 16-Apr-1993 JohnRo
  33. Fixed infinite loop in NetpDbgDisplayFileTime().
  34. --*/
  35. // These must be included first:
  36. #include <nt.h> // NtOpenFile(), ULONG, etc.
  37. #include <ntrtl.h> // PLARGE_INTEGER, TIME_FIELDS, etc.
  38. #include <nturtl.h> // Needed for ntrtl.h and windows.h to co-exist.
  39. #include <windows.h> // GetLastError(), LPFILETIME, CompareFileTime(), etc.
  40. #include <windef.h> // IN, DWORD, etc.
  41. #include <lmcons.h> // NET_API_STATUS, etc.
  42. // These may be included in any order:
  43. #include <lmremutl.h> // LPTIME_OF_DAY_INFO.
  44. #include <netdebug.h> // My prototypes, NetpAssert(), FORMAT_ equates, etc.
  45. #include <string.h> // strlen().
  46. #include <time.h> // ctime().
  47. #undef NetpDbgDisplayTimestamp
  48. VOID
  49. NetpDbgDisplayTimestamp(
  50. IN LPDEBUG_STRING Tag,
  51. IN DWORD Time // Seconds since 1970.
  52. )
  53. {
  54. #if DBG
  55. NetpAssert( Tag != NULL );
  56. if (Time == 0) {
  57. NetpDbgDisplayDword( Tag, (DWORD) 0 );
  58. } else if (Time == (DWORD) -1) {
  59. NetpDbgDisplayString( Tag, TEXT("-1") );
  60. } else {
  61. LPSTR TimeStringPtr;
  62. NetpAssert( sizeof(time_t) == sizeof(DWORD) );
  63. TimeStringPtr = (LPSTR) ctime( (time_t *) &Time );
  64. if (TimeStringPtr == NULL) {
  65. // 1234567890123456789012345
  66. TimeStringPtr = "*********INVALID********\n";
  67. }
  68. NetpDbgDisplayTag( Tag );
  69. // TimeStringPtr points to str ending with "\n\0".
  70. NetpAssert( strlen(TimeStringPtr) == 25 ); // string is
  71. NetpKdPrint(( "%24s (" FORMAT_DWORD ")\n", TimeStringPtr, Time ));
  72. }
  73. #endif // DBG
  74. }
  75. #undef NetpDbgDisplayTod
  76. VOID
  77. NetpDbgDisplayTod(
  78. IN LPDEBUG_STRING Tag,
  79. IN LPVOID TimePtr // LPTIME_OF_DAY_INFO.
  80. )
  81. {
  82. #if DBG
  83. LPTIME_OF_DAY_INFO Tod = TimePtr;
  84. NetpAssert( Tag != NULL );
  85. NetpAssert( Tod != NULL );
  86. NetpKdPrint(( " " FORMAT_LPDEBUG_STRING "\n", Tag ));
  87. NetpDbgDisplayTimestamp( " (from elapsed time)", Tod->tod_elapsedt );
  88. NetpDbgDisplayTag( " (from other fields)" );
  89. NetpKdPrint((
  90. "%04ld-%02ld-%02ld %02ld:%02ld:%02ld\n",
  91. Tod->tod_year, Tod->tod_month, Tod->tod_day,
  92. Tod->tod_hours, Tod->tod_mins, Tod->tod_secs ));
  93. NetpDbgDisplayLong( " (timezone)", Tod->tod_timezone );
  94. #endif // DBG
  95. } // NetpDbgDisplayTod