Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: third_party/sqlite/src/tool/showjournal.c

Issue 1610963002: Import SQLite 3.10.2. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/sqlite/src/tool/showdb.c ('k') | third_party/sqlite/src/tool/showlocks.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 ** A utility for printing an SQLite database journal. 2 ** A utility for printing an SQLite database journal.
3 */ 3 */
4 #include <stdio.h> 4 #include <stdio.h>
5 #include <ctype.h> 5 #include <ctype.h>
6 #include <stdlib.h> 6 #include <stdlib.h>
7 #include <string.h> 7 #include <string.h>
8 8
9 /* 9 /*
10 ** state information 10 ** state information
(...skipping 12 matching lines...) Expand all
23 23
24 /* 24 /*
25 ** Read N bytes of memory starting at iOfst into space obtained 25 ** Read N bytes of memory starting at iOfst into space obtained
26 ** from malloc(). 26 ** from malloc().
27 */ 27 */
28 static unsigned char *read_content(int N, int iOfst){ 28 static unsigned char *read_content(int N, int iOfst){
29 int got; 29 int got;
30 unsigned char *pBuf = malloc(N); 30 unsigned char *pBuf = malloc(N);
31 if( pBuf==0 ) out_of_memory(); 31 if( pBuf==0 ) out_of_memory();
32 fseek(db, iOfst, SEEK_SET); 32 fseek(db, iOfst, SEEK_SET);
33 got = fread(pBuf, 1, N, db); 33 got = (int)fread(pBuf, 1, N, db);
34 if( got<0 ){ 34 if( got<0 ){
35 fprintf(stderr, "I/O error reading %d bytes from %d\n", N, iOfst); 35 fprintf(stderr, "I/O error reading %d bytes from %d\n", N, iOfst);
36 memset(pBuf, 0, N); 36 memset(pBuf, 0, N);
37 }else if( got<N ){ 37 }else if( got<N ){
38 fprintf(stderr, "Short read: got only %d of %d bytes from %d\n", 38 fprintf(stderr, "Short read: got only %d of %d bytes from %d\n",
39 got, N, iOfst); 39 got, N, iOfst);
40 memset(&pBuf[got], 0, N-got); 40 memset(&pBuf[got], 0, N-got);
41 } 41 }
42 return pBuf; 42 return pBuf;
43 } 43 }
44 44
45 /* Print a line of decode output showing a 4-byte integer. 45 /* Print a line of decode output showing a 4-byte integer.
46 */ 46 */
47 static unsigned print_decode_line( 47 static unsigned print_decode_line(
48 const unsigned char *aData, /* Content being decoded */ 48 const unsigned char *aData, /* Content being decoded */
49 int ofst, int nByte, /* Start and size of decode */ 49 int ofst, int nByte, /* Start and size of decode */
50 const char *zMsg /* Message to append */ 50 const char *zMsg /* Message to append */
51 ){ 51 ){
52 int i, j; 52 int i, j;
53 unsigned val = aData[ofst]; 53 unsigned val = aData[ofst];
54 char zBuf[100]; 54 char zBuf[100];
55 sprintf(zBuf, " %05x: %02x", ofst, aData[ofst]); 55 sprintf(zBuf, " %05x: %02x", ofst, aData[ofst]);
56 i = strlen(zBuf); 56 i = (int)strlen(zBuf);
57 for(j=1; j<4; j++){ 57 for(j=1; j<4; j++){
58 if( j>=nByte ){ 58 if( j>=nByte ){
59 sprintf(&zBuf[i], " "); 59 sprintf(&zBuf[i], " ");
60 }else{ 60 }else{
61 sprintf(&zBuf[i], " %02x", aData[ofst+j]); 61 sprintf(&zBuf[i], " %02x", aData[ofst+j]);
62 val = val*256 + aData[ofst+j]; 62 val = val*256 + aData[ofst+j];
63 } 63 }
64 i += strlen(&zBuf[i]); 64 i += (int)strlen(&zBuf[i]);
65 } 65 }
66 sprintf(&zBuf[i], " %10u", val); 66 sprintf(&zBuf[i], " %10u", val);
67 printf("%s %s\n", zBuf, zMsg); 67 printf("%s %s\n", zBuf, zMsg);
68 return val; 68 return val;
69 } 69 }
70 70
71 /* 71 /*
72 ** Read and print a journal header. Store key information (page size, etc) 72 ** Read and print a journal header. Store key information (page size, etc)
73 ** in global variables. 73 ** in global variables.
74 */ 74 */
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 iOfst += sectorSize; 129 iOfst += sectorSize;
130 while( cnt && iOfst<fileSize ){ 130 while( cnt && iOfst<fileSize ){
131 print_page(iOfst); 131 print_page(iOfst);
132 iOfst += pageSize+8; 132 iOfst += pageSize+8;
133 } 133 }
134 iOfst = (iOfst/sectorSize + 1)*sectorSize; 134 iOfst = (iOfst/sectorSize + 1)*sectorSize;
135 } 135 }
136 fclose(db); 136 fclose(db);
137 return 0; 137 return 0;
138 } 138 }
OLDNEW
« no previous file with comments | « third_party/sqlite/src/tool/showdb.c ('k') | third_party/sqlite/src/tool/showlocks.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698