Index: branches/ariel/xmldumps-backup/mwbzutils/dumpbz2filefromoffset.c |
— | — | @@ -38,7 +38,7 @@ |
39 | 39 | |
40 | 40 | b = init_buffer(length); |
41 | 41 | bfile.bytes_read = 0; |
42 | | - bfile.position = 0; |
| 42 | + bfile.position = (off_t)0; |
43 | 43 | |
44 | 44 | while ((get_buffer_of_uncompressed_data(b, fin, &bfile, FORWARD)>=0) && (! bfile.eof) && (!done)) { |
45 | 45 | /* fixme either we don't check the return code right or we don't notice no bytes read or we don't clear the bytes read */ |
— | — | @@ -124,7 +124,7 @@ |
125 | 125 | 0 on success, |
126 | 126 | -1 on error |
127 | 127 | */ |
128 | | -int dump_from_first_page_id_after_offset(int fin, int position) { |
| 128 | +int dump_from_first_page_id_after_offset(int fin, off_t position) { |
129 | 129 | int res; |
130 | 130 | regmatch_t *match_page; |
131 | 131 | regex_t compiled_page; |
— | — | @@ -229,7 +229,8 @@ |
230 | 230 | BZ_OK on success, various BZ_ errors otherwise. |
231 | 231 | */ |
232 | 232 | int main(int argc, char **argv) { |
233 | | - int fin, position, res; |
| 233 | + int fin, res; |
| 234 | + off_t position; |
234 | 235 | |
235 | 236 | if (argc != 3) { |
236 | 237 | fprintf(stderr,"usage: %s infile position\n", argv[0]); |
— | — | @@ -242,8 +243,8 @@ |
243 | 244 | exit(-1); |
244 | 245 | } |
245 | 246 | |
246 | | - position = atoi(argv[2]); |
247 | | - if (position <0) { |
| 247 | + position = atoll(argv[2]); |
| 248 | + if (position <(off_t)0) { |
248 | 249 | fprintf(stderr,"please specify a position >= 0.\n"); |
249 | 250 | fprintf(stderr,"usage: %s infile position\n", argv[0]); |
250 | 251 | exit(-1); |
Index: branches/ariel/xmldumps-backup/mwbzutils/findpageidinbz2xml.c |
— | — | @@ -8,6 +8,7 @@ |
9 | 9 | #include <errno.h> |
10 | 10 | #include <sys/types.h> |
11 | 11 | #include <regex.h> |
| 12 | +#include <inttypes.h> |
12 | 13 | #include "mwbzutils.h" |
13 | 14 | |
14 | 15 | |
— | — | @@ -42,7 +43,7 @@ |
43 | 44 | 0 if no pageid found, |
44 | 45 | -1 on error |
45 | 46 | */ |
46 | | -int get_first_page_id_after_offset(int fin, int position, page_info_t *pinfo) { |
| 47 | +int get_first_page_id_after_offset(int fin, off_t position, page_info_t *pinfo) { |
47 | 48 | int res; |
48 | 49 | regmatch_t *match_page, *match_page_id; |
49 | 50 | regex_t compiled_page, compiled_page_id; |
— | — | @@ -64,12 +65,12 @@ |
65 | 66 | b = init_buffer(length); |
66 | 67 | |
67 | 68 | pinfo->bits_shifted = -1; |
68 | | - pinfo->position = -1; |
| 69 | + pinfo->position = (off_t)-1; |
69 | 70 | pinfo->page_id = -1; |
70 | 71 | |
71 | 72 | bfile.bytes_read = 0; |
72 | 73 | |
73 | | - if (find_first_bz2_block_from_offset(&bfile, fin, position, FORWARD) <= 0) { |
| 74 | + if (find_first_bz2_block_from_offset(&bfile, fin, position, FORWARD) <= (off_t)0) { |
74 | 75 | /* fprintf(stderr,"failed to find block in bz2file (1)\n"); */ |
75 | 76 | return(-1); |
76 | 77 | } |
— | — | @@ -162,21 +163,21 @@ |
163 | 164 | */ |
164 | 165 | int do_iteration(iter_info_t *iinfo, int fin, page_info_t *pinfo) { |
165 | 166 | int res; |
166 | | - int new_position; |
167 | | - int interval; |
| 167 | + off_t new_position; |
| 168 | + off_t interval; |
168 | 169 | |
169 | 170 | /* |
170 | 171 | last_position is somewhere in the interval, perhaps at an end |
171 | 172 | last_value is the value we had at that position |
172 | 173 | */ |
173 | 174 | |
174 | | - interval = (iinfo->right_end - iinfo->left_end)/2; |
175 | | - if (interval == 0) { |
176 | | - interval = 1; |
| 175 | + interval = (iinfo->right_end - iinfo->left_end)/(off_t)2; |
| 176 | + if (interval == (off_t)0) { |
| 177 | + interval = (off_t)1; |
177 | 178 | } |
178 | | - /* fprintf(stderr,"interval size is %ld, left end %ld, right end %ld, last val %d\n",interval, iinfo->left_end, iinfo->right_end, iinfo->last_value); */ |
| 179 | + /* fprintf(stderr,"interval size is %"PRId64", left end %"PRId64", right end %"PRId64", last val %d\n",interval, iinfo->left_end, iinfo->right_end, iinfo->last_value); */ |
179 | 180 | /* if we're this close, we'll check this value and be done with it */ |
180 | | - if (iinfo->right_end -iinfo->left_end < 2) { |
| 181 | + if (iinfo->right_end -iinfo->left_end < (off_t)2) { |
181 | 182 | new_position = iinfo->left_end; |
182 | 183 | iinfo->right_end = iinfo->left_end; |
183 | 184 | } |
— | — | @@ -231,7 +232,8 @@ |
232 | 233 | returns: 0 on success, -1 on error |
233 | 234 | */ |
234 | 235 | int main(int argc, char **argv) { |
235 | | - int fin, position, res, interval, page_id, oldmarker, file_size; |
| 236 | + int fin, res, page_id; |
| 237 | + off_t position, interval, file_size; |
236 | 238 | page_info_t pinfo; |
237 | 239 | iter_info_t iinfo; |
238 | 240 | |
— | — | @@ -256,28 +258,27 @@ |
257 | 259 | file_size = get_file_size(fin); |
258 | 260 | |
259 | 261 | interval = file_size; |
260 | | - position = 0; |
261 | | - oldmarker = -1; |
| 262 | + position = (off_t)0; |
262 | 263 | pinfo.bits_shifted = -1; |
263 | | - pinfo.position = -1; |
| 264 | + pinfo.position = (off_t)-1; |
264 | 265 | pinfo.page_id = -1; |
265 | 266 | |
266 | | - iinfo.left_end = 0; |
| 267 | + iinfo.left_end = (off_t)0; |
267 | 268 | file_size = get_file_size(fin); |
268 | 269 | iinfo.right_end = file_size; |
269 | 270 | iinfo.value_wanted = page_id; |
270 | 271 | |
271 | | - res = get_first_page_id_after_offset(fin, 0, &pinfo); |
| 272 | + res = get_first_page_id_after_offset(fin, (off_t)0, &pinfo); |
272 | 273 | if (res > 0) { |
273 | 274 | iinfo.last_value = pinfo.page_id; |
274 | | - iinfo.last_position = 0; |
| 275 | + iinfo.last_position = (off_t)0; |
275 | 276 | } |
276 | 277 | else { |
277 | 278 | fprintf(stderr,"failed to get anything useful from the beginning of the file even, bailing.\n"); |
278 | 279 | exit(1); |
279 | 280 | } |
280 | 281 | if (pinfo.page_id == page_id) { |
281 | | - fprintf(stdout,"position:%d page_id:%d\n",pinfo.position, pinfo.page_id); |
| 282 | + fprintf(stdout,"position:%"PRId64" page_id:%d\n",pinfo.position, pinfo.page_id); |
282 | 283 | exit(0); |
283 | 284 | } |
284 | 285 | |
— | — | @@ -285,7 +286,7 @@ |
286 | 287 | res = do_iteration(&iinfo, fin, &pinfo); |
287 | 288 | /* things to check: bad return? interval is 0 bytes long? */ |
288 | 289 | if (iinfo.left_end == iinfo.right_end) { |
289 | | - fprintf(stdout,"position:%d page_id:%d\n",pinfo.position, pinfo.page_id); |
| 290 | + fprintf(stdout,"position:%"PRId64" page_id:%d\n",pinfo.position, pinfo.page_id); |
290 | 291 | exit(0); |
291 | 292 | } |
292 | 293 | else if (res < 0) { |
Index: branches/ariel/xmldumps-backup/mwbzutils/dumplastbz2block.c |
— | — | @@ -6,6 +6,7 @@ |
7 | 7 | #include <fcntl.h> |
8 | 8 | #include <stdlib.h> |
9 | 9 | #include <errno.h> |
| 10 | +#include <inttypes.h> |
10 | 11 | #include "mwbzutils.h" |
11 | 12 | |
12 | 13 | |
— | — | @@ -54,9 +55,9 @@ |
55 | 56 | bfile.position = bfile.file_size; |
56 | 57 | } |
57 | 58 | else { |
58 | | - bfile.position = bfile.file_size - 11; /* size of footer, perhaps with 1 byte extra */ |
| 59 | + bfile.position = bfile.file_size - (off_t)11; /* size of footer, perhaps with 1 byte extra */ |
59 | 60 | } |
60 | | - bfile.position -=6; /* size of marker */ |
| 61 | + bfile.position -=(off_t)6; /* size of marker */ |
61 | 62 | bfile.initialized = 0; |
62 | 63 | b = init_buffer(length); |
63 | 64 | bfile.bytes_read = 0; |
— | — | @@ -64,11 +65,11 @@ |
65 | 66 | /* init_bz2_file(&bfile, fin, BACKWARD); */ |
66 | 67 | firstblock = 1; |
67 | 68 | |
68 | | - if (find_first_bz2_block_from_offset(&bfile, fin, bfile.position, BACKWARD) <= 0) { |
| 69 | + if (find_first_bz2_block_from_offset(&bfile, fin, bfile.position, BACKWARD) <= (off_t)0) { |
69 | 70 | fprintf(stderr,"failed to find block in bz2file\n"); |
70 | 71 | exit(-1); |
71 | 72 | } |
72 | | - while ((get_buffer_of_uncompressed_data(b, fin, &bfile, FORWARD)>=0) && (! bfile.eof) && (! bfile.position ==0)) { |
| 73 | + while ((get_buffer_of_uncompressed_data(b, fin, &bfile, FORWARD)>=0) && (! bfile.eof) && (! bfile.position == (off_t)0)) { |
73 | 74 | if (bfile.bytes_read) { |
74 | 75 | fwrite(b->next_to_read,b->bytes_avail,1,stdout); |
75 | 76 | b->next_to_read = b->end; |
Index: branches/ariel/xmldumps-backup/mwbzutils/mwbzutils.h |
— | — | @@ -7,7 +7,7 @@ |
8 | 8 | typedef struct { |
9 | 9 | int page_id; /* first id in the block */ |
10 | 10 | int bits_shifted; /* block is right shifted this many bits */ |
11 | | - int position; /* position in file of block */ |
| 11 | + off_t position; /* position in file of block */ |
12 | 12 | } page_info_t; |
13 | 13 | |
14 | 14 | #define BUFINSIZE 5000 |
— | — | @@ -27,7 +27,7 @@ |
28 | 28 | |
29 | 29 | int initialized; /* whether bz2file has been initialized (header processed, seek to |
30 | 30 | some bz2 block in the file and input buffer filled) */ |
31 | | - int block_start; /* position of bz2 block in file from which we started to read (we |
| 31 | + off_t block_start; /* position of bz2 block in file from which we started to read (we |
32 | 32 | read a sequence of bz2 blocks from a given position, this is |
33 | 33 | the offset to the first one) */ |
34 | 34 | |
— | — | @@ -44,12 +44,12 @@ |
45 | 45 | unsigned char **footer; /* bzip2 end of stream footer, plus bit-shifted versions of it for |
46 | 46 | locating the footer in a stream of compressed data */ |
47 | 47 | |
48 | | - int position; /* current offset into file from start of file */ |
| 48 | + off_t position; /* current offset into file from start of file */ |
49 | 49 | |
50 | 50 | int bytes_read; /* number of bytes of compressed data read from file (per read) */ |
51 | 51 | int bytes_written; /* number of bytes of decompressed data written into output buffer (per decompress) */ |
52 | 52 | int eof; /* nonzero if eof reached */ |
53 | | - int file_size; /* length of file, so we don't search past it for blocks */ |
| 53 | + off_t file_size; /* length of file, so we don't search past it for blocks */ |
54 | 54 | } bz_info_t; |
55 | 55 | |
56 | 56 | #define MASKLEFT 0 |
— | — | @@ -76,11 +76,11 @@ |
77 | 77 | position and checking the first pageid (if any) contained in it. |
78 | 78 | */ |
79 | 79 | typedef struct { |
80 | | - int left_end; /* left end of interval to search (bytes from start of file) */ |
81 | | - int right_end; /* right end of interval to search */ |
| 80 | + off_t left_end; /* left end of interval to search (bytes from start of file) */ |
| 81 | + off_t right_end; /* right end of interval to search */ |
82 | 82 | int value_wanted; /* pageid desired */ |
83 | 83 | int last_value; /* pageid we found in last iteration */ |
84 | | - int last_position; /* position in file for last iteration */ |
| 84 | + off_t last_position; /* position in file for last iteration */ |
85 | 85 | } iter_info_t; |
86 | 86 | |
87 | 87 | int bit_mask(int numbits, int end); |
— | — | @@ -114,7 +114,7 @@ |
115 | 115 | |
116 | 116 | int buffer_is_full(buf_info_t *b); |
117 | 117 | |
118 | | -int get_file_size(int fin); |
| 118 | +off_t get_file_size(int fin); |
119 | 119 | |
120 | 120 | int init_bz2_file(bz_info_t *bfile, int fin, int direction); |
121 | 121 | |
— | — | @@ -134,6 +134,6 @@ |
135 | 135 | |
136 | 136 | void clear_buffer(unsigned char *buf, int length); |
137 | 137 | |
138 | | -int find_first_bz2_block_from_offset(bz_info_t *bfile, int fin, int position, int direction); |
| 138 | +off_t find_first_bz2_block_from_offset(bz_info_t *bfile, int fin, off_t position, int direction); |
139 | 139 | |
140 | 140 | #endif |
Index: branches/ariel/xmldumps-backup/mwbzutils/mwbzlib.c |
— | — | @@ -8,11 +8,11 @@ |
9 | 9 | #include <errno.h> |
10 | 10 | #include <sys/types.h> |
11 | 11 | #include <regex.h> |
| 12 | +#include <inttypes.h> |
12 | 13 | #include "bzlib.h" |
13 | 14 | #include "mwbzutils.h" |
14 | 15 | |
15 | 16 | |
16 | | - |
17 | 17 | /* return n ones either at left or right end */ |
18 | 18 | int bit_mask(int numbits, int end) { |
19 | 19 | if (end == MASKRIGHT) { |
— | — | @@ -130,11 +130,12 @@ |
131 | 131 | |
132 | 132 | /* return: 1 if found, 0 if not, -1 on error */ |
133 | 133 | int find_next_bz2_block_marker(int fin, bz_info_t *bfile, int direction) { |
134 | | - int result; |
| 134 | + off_t seekresult; |
| 135 | + int res; |
135 | 136 | |
136 | 137 | bfile->bits_shifted = -1; |
137 | | - result = read(fin, bfile->marker_buffer, 7); |
138 | | - if (result == -1) { |
| 138 | + res = read(fin, bfile->marker_buffer, 7); |
| 139 | + if (res == -1) { |
139 | 140 | fprintf(stderr,"read of file failed\n"); |
140 | 141 | return(-1); |
141 | 142 | } |
— | — | @@ -149,13 +150,13 @@ |
150 | 151 | else { |
151 | 152 | bfile->position--; |
152 | 153 | } |
153 | | - result = lseek(fin, (bfile->position), SEEK_SET); |
154 | | - if (result == -1) { |
155 | | - fprintf(stderr,"lseek of file to %ld failed (2)\n",(long int) bfile->position); |
| 154 | + seekresult = lseek(fin, bfile->position, SEEK_SET); |
| 155 | + if (seekresult == (off_t)-1) { |
| 156 | + fprintf(stderr,"lseek of file to %"PRId64" failed (2)\n",bfile->position); |
156 | 157 | return(-1); |
157 | 158 | } |
158 | | - result = read(fin, bfile->marker_buffer, 7); |
159 | | - if (result < 7) { |
| 159 | + res = read(fin, bfile->marker_buffer, 7); |
| 160 | + if (res < 7) { |
160 | 161 | /* fprintf(stderr,"read of file failed\n"); */ |
161 | 162 | return(-1); |
162 | 163 | } |
— | — | @@ -194,15 +195,14 @@ |
195 | 196 | } |
196 | 197 | |
197 | 198 | /* FIXME do this right. whatever. */ |
198 | | -int get_file_size(int fin) { |
199 | | - int res; |
| 199 | +off_t get_file_size(int fin) { |
| 200 | + off_t seekresult; |
200 | 201 | |
201 | | - res = lseek(fin, 0, SEEK_END); |
202 | | - if (res == -1) { |
| 202 | + seekresult = lseek(fin, (off_t)0, SEEK_END); |
| 203 | + if (seekresult == (off_t)-1) { |
203 | 204 | fprintf(stderr,"lseek of file to 0 failed (6)\n"); |
204 | | - return(-1); |
205 | 205 | } |
206 | | - return(res); |
| 206 | + return(seekresult); |
207 | 207 | } |
208 | 208 | |
209 | 209 | /* |
— | — | @@ -217,10 +217,11 @@ |
218 | 218 | various BZ_ errors or -1 on failure (see bzlib.h) |
219 | 219 | */ |
220 | 220 | int decompress_header(int fin, bz_info_t *bfile) { |
221 | | - int ret, res; |
| 221 | + int res; |
| 222 | + off_t seekresult; |
222 | 223 | |
223 | | - res = lseek(fin,0,SEEK_SET); |
224 | | - if (res == -1) { |
| 224 | + seekresult = lseek(fin,(off_t)0,SEEK_SET); |
| 225 | + if (seekresult == (off_t)-1) { |
225 | 226 | fprintf(stderr,"lseek of file to 0 failed (3)\n"); |
226 | 227 | return(-1); |
227 | 228 | } |
— | — | @@ -232,12 +233,12 @@ |
233 | 234 | bfile->strm.next_in = (char *)bfile->header_buffer; |
234 | 235 | bfile->strm.avail_in = 4; |
235 | 236 | |
236 | | - ret = BZ2_bzDecompress_mine ( &(bfile->strm) ); |
237 | | - if (BZ_OK != ret && BZ_STREAM_END != ret) { |
| 237 | + res = BZ2_bzDecompress_mine ( &(bfile->strm) ); |
| 238 | + if (BZ_OK != res && BZ_STREAM_END != res) { |
238 | 239 | fprintf(stderr,"Corrupt bzip2 header\n"); |
239 | 240 | return(-1); |
240 | 241 | } |
241 | | - return(ret); |
| 242 | + return(res); |
242 | 243 | } |
243 | 244 | |
244 | 245 | /* |
— | — | @@ -256,19 +257,19 @@ |
257 | 258 | -1 on error |
258 | 259 | */ |
259 | 260 | int setup_first_buffer_to_decompress(int fin, bz_info_t *bfile) { |
260 | | - int res; |
| 261 | + off_t seekresult; |
261 | 262 | |
262 | 263 | if (bfile->bits_shifted == 0) { |
263 | | - res = lseek(fin,bfile->position+1,SEEK_SET); |
264 | | - if (res == -1) { |
265 | | - fprintf(stderr,"lseek of file to %ld failed (4)\n",(long int) bfile->position+1); |
| 264 | + seekresult = lseek(fin,bfile->position+(off_t)1,SEEK_SET); |
| 265 | + if (seekresult == -1) { |
| 266 | + fprintf(stderr,"lseek of file to %"PRId64" failed (4)\n",bfile->position+(off_t)1); |
266 | 267 | return(-1); |
267 | 268 | } |
268 | 269 | } |
269 | 270 | else { |
270 | | - res = lseek(fin,bfile->position,SEEK_SET); |
271 | | - if (res == -1) { |
272 | | - fprintf(stderr,"lseek of file to %ld failed (5)\n",(long int) bfile->position); |
| 271 | + seekresult = lseek(fin,bfile->position,SEEK_SET); |
| 272 | + if (seekresult == -1) { |
| 273 | + fprintf(stderr,"lseek of file to %"PRId64" failed (5)\n",bfile->position); |
273 | 274 | return(-1); |
274 | 275 | } |
275 | 276 | } |
— | — | @@ -294,7 +295,7 @@ |
295 | 296 | -1 if no marker or other error, position of next read if ok |
296 | 297 | */ |
297 | 298 | int init_bz2_file(bz_info_t *bfile, int fin, int direction) { |
298 | | - int res; |
| 299 | + off_t seekresult; |
299 | 300 | |
300 | 301 | bfile->bufin_size = BUFINSIZE; |
301 | 302 | bfile->marker = init_marker(); |
— | — | @@ -309,9 +310,9 @@ |
310 | 311 | fprintf(stderr,"asked for position past end of file\n"); |
311 | 312 | return(-1); |
312 | 313 | } |
313 | | - res = lseek(fin, bfile->position, SEEK_SET); |
314 | | - if (res == -1) { |
315 | | - fprintf(stderr,"lseek of file to %ld failed (7)\n",(long int) bfile->position); |
| 314 | + seekresult = lseek(fin, bfile->position, SEEK_SET); |
| 315 | + if (seekresult == (off_t)-1) { |
| 316 | + fprintf(stderr,"lseek of file to %"PRId64" failed (7)\n",bfile->position); |
316 | 317 | return(-1); |
317 | 318 | } |
318 | 319 | |
— | — | @@ -451,7 +452,7 @@ |
452 | 453 | bfile->eof++; |
453 | 454 | /* should we actually change the file position? |
454 | 455 | bfile->position = bfile->filesize; |
455 | | - lseek(fin,0,SEEK_END); |
| 456 | + lseek(fin,(off_t)0,SEEK_END); |
456 | 457 | */ |
457 | 458 | } |
458 | 459 | return(0); |
— | — | @@ -559,10 +560,11 @@ |
560 | 561 | } |
561 | 562 | |
562 | 563 | int read_footer(unsigned char *buffer, int fin) { |
| 564 | + off_t seekresult; |
563 | 565 | int res; |
564 | 566 | |
565 | | - res = lseek(fin, -11, SEEK_END); |
566 | | - if (res == -1) { |
| 567 | + seekresult = lseek(fin, (off_t)-11, SEEK_END); |
| 568 | + if (seekresult == (off_t)-1) { |
567 | 569 | fprintf(stderr,"lseek of file failed\n"); |
568 | 570 | return(-1); |
569 | 571 | } |
— | — | @@ -621,13 +623,14 @@ |
622 | 624 | 0 if no marker |
623 | 625 | -1 on error |
624 | 626 | */ |
625 | | -int find_first_bz2_block_from_offset(bz_info_t *bfile, int fin, int position, int direction) { |
| 627 | +off_t find_first_bz2_block_from_offset(bz_info_t *bfile, int fin, off_t position, int direction) { |
| 628 | + off_t seekresult; |
626 | 629 | int res; |
627 | 630 | |
628 | 631 | bfile->bufin_size = BUFINSIZE; |
629 | 632 | bfile->marker = init_marker(); |
630 | 633 | bfile->position = position; |
631 | | - bfile->block_start = -1; |
| 634 | + bfile->block_start = (off_t)-1; |
632 | 635 | bfile->bytes_read = 0; |
633 | 636 | bfile->bytes_written = 0; |
634 | 637 | bfile->eof = 0; |
— | — | @@ -639,9 +642,9 @@ |
640 | 643 | if (bfile->position > bfile->file_size) { |
641 | 644 | return(0); |
642 | 645 | } |
643 | | - res = lseek(fin, bfile->position, SEEK_SET); |
644 | | - if (res < 0) { |
645 | | - fprintf(stderr,"lseek of file to %ld failed (7)\n",(long int) bfile->position); |
| 646 | + seekresult = lseek(fin, bfile->position, SEEK_SET); |
| 647 | + if (seekresult == (off_t)-1) { |
| 648 | + fprintf(stderr,"lseek of file to %"PRId64" failed (7)\n",bfile->position); |
646 | 649 | return(-1); |
647 | 650 | } |
648 | 651 | res = find_next_bz2_block_marker(fin, bfile,direction); |
— | — | @@ -663,19 +666,19 @@ |
664 | 667 | bfile->bytes_written = 0; |
665 | 668 | bfile->eof = 0; |
666 | 669 | /* leave the file at the right position */ |
667 | | - res = lseek(fin, bfile->block_start, SEEK_SET); |
668 | | - if (res < 0) { |
669 | | - fprintf(stderr,"lseek of file to %ld failed (7)\n",(long int) bfile->position); |
| 670 | + seekresult = lseek(fin, bfile->block_start, SEEK_SET); |
| 671 | + if (seekresult == (off_t)-1) { |
| 672 | + fprintf(stderr,"lseek of file to %"PRId64" failed (7)\n",bfile->position); |
670 | 673 | return(-1); |
671 | 674 | } |
672 | | - bfile->position = res; |
| 675 | + bfile->position = seekresult; |
673 | 676 | return(bfile->position); |
674 | 677 | } |
675 | 678 | /* right bytes, but there by chance, skip and try again */ |
676 | 679 | else { |
677 | | - bfile->position+=6; |
| 680 | + bfile->position+=(off_t)6; |
678 | 681 | bfile->bits_shifted = -1; |
679 | | - bfile->block_start = -1; |
| 682 | + bfile->block_start = (off_t)-1; |
680 | 683 | } |
681 | 684 | } |
682 | 685 | else { |