| OLD | NEW |
| 1 /* | 1 /* |
| 2 ** A utility for printing content from a write-ahead log file. | 2 ** A utility for printing content from a write-ahead log file. |
| 3 */ | 3 */ |
| 4 #include <stdio.h> | 4 #include <stdio.h> |
| 5 #include <ctype.h> | 5 #include <ctype.h> |
| 6 #include <sys/types.h> | 6 #include <sys/types.h> |
| 7 #include <sys/stat.h> | 7 #include <sys/stat.h> |
| 8 #include <fcntl.h> | 8 #include <fcntl.h> |
| 9 | 9 |
| 10 #define ISDIGIT(X) isdigit((unsigned char)(X)) |
| 11 #define ISPRINT(X) isprint((unsigned char)(X)) |
| 12 |
| 10 #if !defined(_MSC_VER) | 13 #if !defined(_MSC_VER) |
| 11 #include <unistd.h> | 14 #include <unistd.h> |
| 12 #else | 15 #else |
| 13 #include <io.h> | 16 #include <io.h> |
| 14 #endif | 17 #endif |
| 15 | 18 |
| 16 #include <stdlib.h> | 19 #include <stdlib.h> |
| 17 #include <string.h> | 20 #include <string.h> |
| 18 | 21 |
| 19 | 22 |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 if( i+j>nByte ){ | 155 if( i+j>nByte ){ |
| 153 fprintf(stdout, " "); | 156 fprintf(stdout, " "); |
| 154 }else{ | 157 }else{ |
| 155 fprintf(stdout,"%02x ", aData[i+j]); | 158 fprintf(stdout,"%02x ", aData[i+j]); |
| 156 } | 159 } |
| 157 } | 160 } |
| 158 for(j=0; j<perLine; j++){ | 161 for(j=0; j<perLine; j++){ |
| 159 if( i+j>nByte ){ | 162 if( i+j>nByte ){ |
| 160 fprintf(stdout, " "); | 163 fprintf(stdout, " "); |
| 161 }else{ | 164 }else{ |
| 162 fprintf(stdout,"%c", isprint(aData[i+j]) ? aData[i+j] : '.'); | 165 fprintf(stdout,"%c", ISPRINT(aData[i+j]) ? aData[i+j] : '.'); |
| 163 } | 166 } |
| 164 } | 167 } |
| 165 fprintf(stdout,"\n"); | 168 fprintf(stdout,"\n"); |
| 166 } | 169 } |
| 167 } | 170 } |
| 168 | 171 |
| 169 /* Print a line of decode output showing a 4-byte integer. | 172 /* Print a line of decode output showing a 4-byte integer. |
| 170 */ | 173 */ |
| 171 static void print_decode_line( | 174 static void print_decode_line( |
| 172 unsigned char *aData, /* Content being decoded */ | 175 unsigned char *aData, /* Content being decoded */ |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 } | 546 } |
| 544 }else{ | 547 }else{ |
| 545 int i; | 548 int i; |
| 546 for(i=2; i<argc; i++){ | 549 for(i=2; i<argc; i++){ |
| 547 int iStart, iEnd; | 550 int iStart, iEnd; |
| 548 char *zLeft; | 551 char *zLeft; |
| 549 if( strcmp(argv[i], "header")==0 ){ | 552 if( strcmp(argv[i], "header")==0 ){ |
| 550 print_wal_header(0); | 553 print_wal_header(0); |
| 551 continue; | 554 continue; |
| 552 } | 555 } |
| 553 if( !isdigit(argv[i][0]) ){ | 556 if( !ISDIGIT(argv[i][0]) ){ |
| 554 fprintf(stderr, "%s: unknown option: [%s]\n", argv[0], argv[i]); | 557 fprintf(stderr, "%s: unknown option: [%s]\n", argv[0], argv[i]); |
| 555 continue; | 558 continue; |
| 556 } | 559 } |
| 557 iStart = strtol(argv[i], &zLeft, 0); | 560 iStart = strtol(argv[i], &zLeft, 0); |
| 558 if( zLeft && strcmp(zLeft,"..end")==0 ){ | 561 if( zLeft && strcmp(zLeft,"..end")==0 ){ |
| 559 iEnd = mxFrame; | 562 iEnd = mxFrame; |
| 560 }else if( zLeft && zLeft[0]=='.' && zLeft[1]=='.' ){ | 563 }else if( zLeft && zLeft[0]=='.' && zLeft[1]=='.' ){ |
| 561 iEnd = strtol(&zLeft[2], 0, 0); | 564 iEnd = strtol(&zLeft[2], 0, 0); |
| 562 }else if( zLeft && zLeft[0]=='b' ){ | 565 }else if( zLeft && zLeft[0]=='b' ){ |
| 563 int ofst, nByte, hdrSize; | 566 int ofst, nByte, hdrSize; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 587 } | 590 } |
| 588 while( iStart<=iEnd ){ | 591 while( iStart<=iEnd ){ |
| 589 print_frame(iStart); | 592 print_frame(iStart); |
| 590 iStart++; | 593 iStart++; |
| 591 } | 594 } |
| 592 } | 595 } |
| 593 } | 596 } |
| 594 close(fd); | 597 close(fd); |
| 595 return 0; | 598 return 0; |
| 596 } | 599 } |
| OLD | NEW |