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

Side by Side Diff: third_party/sqlite/sqlite-src-3080704/tool/extract.c

Issue 883353008: [sql] Import reference version of SQLite 3.8.7.4. (Closed) Base URL: http://chromium.googlesource.com/chromium/src.git@master
Patch Set: Hold back encoding change which is messing up patch. Created 5 years, 10 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
OLDNEW
(Empty)
1 /*
2 ** Extract a range of bytes from a file.
3 **
4 ** Usage:
5 **
6 ** extract FILENAME OFFSET AMOUNT
7 **
8 ** The bytes are written to standard output.
9 */
10 #include <stdio.h>
11 #include <stdlib.h>
12
13 int main(int argc, char **argv){
14 FILE *f;
15 char *zBuf;
16 int ofst;
17 int n;
18 size_t got;
19
20 if( argc!=4 ){
21 fprintf(stderr, "Usage: %s FILENAME OFFSET AMOUNT\n", *argv);
22 return 1;
23 }
24 f = fopen(argv[1], "rb");
25 if( f==0 ){
26 fprintf(stderr, "cannot open \"%s\"\n", argv[1]);
27 return 1;
28 }
29 ofst = atoi(argv[2]);
30 n = atoi(argv[3]);
31 zBuf = malloc( n );
32 if( zBuf==0 ){
33 fprintf(stderr, "out of memory\n");
34 return 1;
35 }
36 fseek(f, ofst, SEEK_SET);
37 got = fread(zBuf, 1, n, f);
38 fclose(f);
39 if( got<n ){
40 fprintf(stderr, "got only %d of %d bytes\n", got, n);
41 return 1;
42 }else{
43 fwrite(zBuf, 1, n, stdout);
44 }
45 return 0;
46 }
OLDNEW
« no previous file with comments | « third_party/sqlite/sqlite-src-3080704/tool/diffdb.c ('k') | third_party/sqlite/sqlite-src-3080704/tool/fast_vacuum.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698