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.

90 lines
1.9 KiB

  1. /*++
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. tlog.c
  5. Abstract:
  6. Test app for the cluster registry logging component
  7. Author:
  8. John Vert (jvert) 15-Dec-1995
  9. Revision History:
  10. --*/
  11. #include "windows.h"
  12. #include "lmp.h"
  13. #include "stdio.h"
  14. #include "stdlib.h"
  15. HLOG MyLog;
  16. LPWSTR LogName = L"c:\\TLOG.LOG";
  17. #define LOG_RECORDS 1000
  18. int __cdecl
  19. main (argc, argv)
  20. int argc;
  21. char *argv[];
  22. {
  23. LSN LastLsn;
  24. DWORD Status;
  25. int i,j;
  26. PDWORD Buffer;
  27. DeleteFileW(LogName);
  28. MyLog = LogCreate(LogName, 0,
  29. NULL, NULL, &LastLsn);
  30. if (MyLog == INVALID_HANDLE_VALUE) {
  31. fprintf(stderr, "TLOG: LogCreate failed %d\n",GetLastError);
  32. return(0);
  33. }
  34. if (LastLsn != NULL_LSN) {
  35. fprintf(stderr, "TLOG: new log file returned LastLsn == %08lx\n",LastLsn);
  36. return(0);
  37. }
  38. Buffer = malloc(1000 * sizeof(DWORD));
  39. if (Buffer == NULL) {
  40. fprintf(stderr, "TLOG: couldn't allocate buffer\n");
  41. return(0);
  42. }
  43. for (i=0; i<1000; i++) {
  44. Buffer[i] = i;
  45. }
  46. LastLsn = NULL_LSN;
  47. for (i=0; i<LOG_RECORDS; i++) {
  48. Buffer[0] = LastLsn;
  49. printf("Logging TRID %d size %d\n",i,(sizeof(DWORD)*i));
  50. LastLsn = LogWrite(MyLog,
  51. (TRID)i,
  52. (RMID)3,
  53. (RMTYPE)0,
  54. Buffer,
  55. sizeof(DWORD) * i);
  56. printf("LSN of the last record %d\r\n",LastLsn);
  57. if (LastLsn == NULL_LSN) {
  58. fprintf(stderr,
  59. "TLOG: LogWrite TRID %d, %d bytes failed %d\n",
  60. i,
  61. sizeof(DWORD) * i,
  62. GetLastError());
  63. return(0);
  64. }
  65. }
  66. Status = LogClose(MyLog);
  67. if (Status != ERROR_SUCCESS) {
  68. fprintf(stderr, "TLOG: LogClose failed %d\n",Status);
  69. return(0);
  70. }
  71. }