Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/sqlite/blob/master/tool/extract.c # sqlite [Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `sqlite / tool / extract.c` 46 lines ยท 856 bytes Raw Blame History 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 11 #include 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