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.

156 lines
3.6 KiB

  1. /*++
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. dmplog.c
  5. Abstract:
  6. Test app for the cluster registry logging component
  7. Dumps out a log file
  8. Author:
  9. John Vert (jvert) 15-Dec-1995
  10. Revision History:
  11. --*/
  12. #include "windows.h"
  13. #include "lmp.h"
  14. #include "stdio.h"
  15. #include "stdlib.h"
  16. #define CsLogModule 0xffff
  17. HLOG MyLog;
  18. LPWSTR LogName = L"c:\\TLOG.LOG";
  19. BOOL WINAPI ScanCb (
  20. IN PVOID Context,
  21. IN RMID RmId,
  22. IN TRID Trid,
  23. IN const PVOID Buffer,
  24. IN DWORD DataSize
  25. );
  26. int __cdecl
  27. main (argc, argv)
  28. int argc;
  29. char *argv[];
  30. {
  31. LSN CurrentLsn;
  32. LSN NextLsn;
  33. DWORD Status;
  34. DWORD i,j;
  35. PDWORD Buffer;
  36. RMID RmId;
  37. RMTYPE RmType;
  38. DWORD DataSize;
  39. TRID Trid;
  40. LSN LastLsn;
  41. MyLog = LogCreate(LogName, 0, NULL, NULL, &LastLsn);
  42. if (MyLog == INVALID_HANDLE_VALUE) {
  43. fprintf(stderr, "DMPLOG: LogCreate failed %d\n",GetLastError());
  44. return(0);
  45. }
  46. if (LastLsn == NULL_LSN) {
  47. fprintf(stderr, "DMPLOG: Log file did not exist\n",LastLsn);
  48. return(0);
  49. }
  50. Buffer = malloc(1000 * sizeof(DWORD));
  51. if (Buffer == NULL) {
  52. fprintf(stderr, "DMPLOG: couldn't allocate buffer\n");
  53. return(0);
  54. }
  55. if (argc == 1)
  56. {
  57. //read all the records
  58. CurrentLsn = NULL_LSN;
  59. do {
  60. DataSize = 1000 * sizeof(DWORD);
  61. NextLsn = LogRead(MyLog,
  62. CurrentLsn,
  63. &RmId,
  64. &RmType,
  65. &Trid,
  66. &TrType,
  67. Buffer,
  68. &DataSize);
  69. if (NextLsn != NULL_LSN) {
  70. printf("LSN %08lx: RMID %d \tTRID %d size: %d",
  71. CurrentLsn,
  72. RmId,
  73. Trid,
  74. DataSize);
  75. for (i=0; i<DataSize/sizeof(DWORD); i++) {
  76. if ((i % 4) == 0) {
  77. printf("\n\t");
  78. }
  79. printf("%08lx ",Buffer[i]);
  80. }
  81. printf("\n");
  82. } else {
  83. printf("END OF LOG\n");
  84. }
  85. CurrentLsn = NextLsn;
  86. } while ( CurrentLsn != NULL_LSN );
  87. }
  88. else
  89. {
  90. CurrentLsn = atoi(argv[1]);
  91. //scan the records from the lsn specified
  92. if (LogScan(MyLog, CurrentLsn, TRUE, (PLOG_SCAN_CALLBACK)ScanCb, NULL) != ERROR_SUCCESS)
  93. printf("LogScan returned error\r\n");
  94. }
  95. Status = LogClose(MyLog);
  96. if (Status != ERROR_SUCCESS) {
  97. fprintf(stderr, "DMPLOG: LogClose failed %d\n",Status);
  98. return(0);
  99. }
  100. }
  101. BOOL WINAPI ScanCb (
  102. IN PVOID Context,
  103. IN RMID RmId,
  104. IN TRID Trid,
  105. IN const PVOID Buffer,
  106. IN DWORD DataSize
  107. )
  108. {
  109. int i;
  110. PDWORD pData=Buffer;
  111. if (!pData)
  112. {
  113. printf("Error - scancb got a null buffer\r\n");
  114. }
  115. printf("LSN %08lx: RMID %d \tTRID %d size: %d",
  116. (LSN)(*pData),
  117. RmId,
  118. Trid,
  119. DataSize);
  120. for (i=0; i<(int)(DataSize/sizeof(DWORD)); i++) {
  121. if ((i % 4) == 0) {
  122. printf("\n\t");
  123. }
  124. printf("%08lx ",pData[i]);
  125. }
  126. printf("\n");
  127. return (TRUE);
  128. }