| line |
true |
false |
branch |
|
53
|
0 |
0 |
if ( writeFile ) { |
|
55
|
0 |
0 |
if ( fd->fd < 0 ) { |
|
62
|
0 |
0 |
if ( fd->fd < 0 ) return -1; |
|
63
|
0 |
0 |
if ( fd->compressLevel ) { |
|
64
|
0 |
0 |
if (deflateInit2(&fd->strm, compressLevel, Z_DEFLATED, MAX_WBITS, 8, |
|
74
|
0 |
0 |
if ( fd->fd < 0 ) return -1; |
|
75
|
0 |
0 |
if ( fd->compressLevel ) { |
|
76
|
0 |
0 |
if ( inflateInit(&fd->strm) != Z_OK ) { |
|
83
|
0 |
0 |
if ( DataBufferFreeList ) { |
|
89
|
0 |
0 |
if ( !fd->buf ) { |
|
93
|
0 |
0 |
if ( BPC_LogLevel >= 8 ) bpc_logMsgf("bpc_fileZIO_open(%s, %d, %d) -> %d\n", fileName, writeFile, compressLevel, fd->fd); |
|
126
|
0 |
0 |
if ( fd->fd < 0 ) return -1; |
|
129
|
0 |
0 |
if ( !(fd->buf = malloc(fd->bufSize)) ) { |
|
134
|
0 |
0 |
if ( fd->compressLevel ) { |
|
135
|
0 |
0 |
if ( writeFile ) { |
|
136
|
0 |
0 |
if (deflateInit2(&fd->strm, compressLevel, Z_DEFLATED, MAX_WBITS, 8, |
|
144
|
0 |
0 |
if ( inflateInit(&fd->strm) != Z_OK ) { |
|
151
|
0 |
0 |
if ( BPC_LogLevel >= 8 ) bpc_logMsgf("bpc_fileZIO_fdopen(%d, %d) -> %d\n", writeFile, compressLevel, fd->fd); |
|
167
|
0 |
0 |
if ( fd->write || fd->fd < 0 ) return -1; |
|
|
0 |
0 |
if ( fd->write || fd->fd < 0 ) return -1; |
|
168
|
0 |
0 |
if ( fd->compressLevel == 0 ) { |
|
170
|
0 |
0 |
while ( nRead > 0 ) { |
|
173
|
0 |
0 |
} while ( thisRead < 0 && errno == EINTR ); |
|
|
0 |
0 |
} while ( thisRead < 0 && errno == EINTR ); |
|
174
|
0 |
0 |
if ( thisRead < 0 ) return thisRead; |
|
175
|
0 |
0 |
if ( thisRead == 0 ) return totalRead; |
|
182
|
0 |
0 |
if ( fd->error ) return fd->error; |
|
183
|
0 |
0 |
while ( nRead > 0 ) { |
|
189
|
0 |
0 |
if ( fd->strm.avail_in == 0 ) { |
|
194
|
0 |
0 |
if ( !fd->eof && maxRead > 0 ) { |
|
|
0 |
0 |
if ( !fd->eof && maxRead > 0 ) { |
|
197
|
0 |
0 |
} while ( thisRead < 0 && errno == EINTR ); |
|
|
0 |
0 |
} while ( thisRead < 0 && errno == EINTR ); |
|
198
|
0 |
0 |
if ( thisRead < 0 ) { |
|
203
|
0 |
0 |
if ( thisRead == 0 ) { |
|
208
|
0 |
0 |
while ( nRead > 0 ) { |
|
214
|
0 |
0 |
if ( fd->first && fd->strm.avail_in > 0 ) { |
|
|
0 |
0 |
if ( fd->first && fd->strm.avail_in > 0 ) { |
|
219
|
0 |
0 |
if ( fd->strm.next_in[0] == 0xd6 || fd->strm.next_in[0] == 0xd7 ) { |
|
|
0 |
0 |
if ( fd->strm.next_in[0] == 0xd6 || fd->strm.next_in[0] == 0xd7 ) { |
|
226
|
0 |
0 |
} else if ( fd->strm.next_in[0] == 0xb3 ) { |
|
239
|
0 |
0 |
status = inflate(&fd->strm, fd->eof ? Z_SYNC_FLUSH : Z_NO_FLUSH); |
|
245
|
0 |
0 |
if ( BPC_LogLevel >= 10 ) bpc_logMsgf("inflate returns %d; thisRead = %d, avail_in = %d, numOut = %d\n", status, thisRead, fd->strm.avail_in, numOut); |
|
247
|
0 |
0 |
if ( fd->eof && fd->strm.avail_in == 0 && numOut == 0 ) return totalRead; |
|
|
0 |
0 |
if ( fd->eof && fd->strm.avail_in == 0 && numOut == 0 ) return totalRead; |
|
|
0 |
0 |
if ( fd->eof && fd->strm.avail_in == 0 && numOut == 0 ) return totalRead; |
|
248
|
0 |
0 |
if ( status == Z_OK && fd->strm.avail_in == 0 ) break; |
|
|
0 |
0 |
if ( status == Z_OK && fd->strm.avail_in == 0 ) break; |
|
249
|
0 |
0 |
if ( status == Z_BUF_ERROR && fd->strm.avail_in == 0 && numOut == 0 ) break; |
|
|
0 |
0 |
if ( status == Z_BUF_ERROR && fd->strm.avail_in == 0 && numOut == 0 ) break; |
|
|
0 |
0 |
if ( status == Z_BUF_ERROR && fd->strm.avail_in == 0 && numOut == 0 ) break; |
|
250
|
0 |
0 |
if ( status == Z_STREAM_END ) { |
|
254
|
0 |
0 |
if ( status < 0 ) { |
|
258
|
0 |
0 |
if ( totalRead <= 0 ) return status; |
|
276
|
0 |
0 |
if ( !fd->write || fd->fd < 0 ) return -1; |
|
|
0 |
0 |
if ( !fd->write || fd->fd < 0 ) return -1; |
|
277
|
0 |
0 |
if ( fd->eof ) return 0; |
|
278
|
0 |
0 |
if ( fd->writeTeeStderr && nWrite > 0 ) (void)fwrite((char*)buf, nWrite, 1, stderr); |
|
|
0 |
0 |
if ( fd->writeTeeStderr && nWrite > 0 ) (void)fwrite((char*)buf, nWrite, 1, stderr); |
|
279
|
0 |
0 |
if ( fd->compressLevel == 0 ) { |
|
281
|
0 |
0 |
while ( nWrite > 0 ) { |
|
284
|
0 |
0 |
} while ( thisWrite < 0 && errno == EINTR ); |
|
|
0 |
0 |
} while ( thisWrite < 0 && errno == EINTR ); |
|
285
|
0 |
0 |
if ( thisWrite < 0 ) return thisWrite; |
|
292
|
0 |
0 |
if ( fd->error ) return fd->error; |
|
294
|
0 |
0 |
if ( nWrite == 0 || (fd->strm.total_in > (1 << 23) && fd->strm.total_out < (1 << 18)) ) { |
|
|
0 |
0 |
if ( nWrite == 0 || (fd->strm.total_in > (1 << 23) && fd->strm.total_out < (1 << 18)) ) { |
|
|
0 |
0 |
if ( nWrite == 0 || (fd->strm.total_in > (1 << 23) && fd->strm.total_out < (1 << 18)) ) { |
|
300
|
0 |
0 |
if ( BPC_LogLevel >= 10 ) bpc_logMsgf("Flushing (nWrite = %d)\n", nWrite); |
|
312
|
0 |
0 |
while ( numOut > 0 ) { |
|
315
|
0 |
0 |
} while ( thisWrite < 0 && errno == EINTR ); |
|
|
0 |
0 |
} while ( thisWrite < 0 && errno == EINTR ); |
|
316
|
0 |
0 |
if ( thisWrite < 0 ) return thisWrite; |
|
320
|
0 |
0 |
if ( status != Z_OK ) break; |
|
324
|
0 |
0 |
if ( nWrite == 0 ) { |
|
331
|
0 |
0 |
while ( fd->strm.avail_in > 0 ) { |
|
340
|
0 |
0 |
while ( numOut > 0 ) { |
|
343
|
0 |
0 |
} while ( thisWrite < 0 && errno == EINTR ); |
|
|
0 |
0 |
} while ( thisWrite < 0 && errno == EINTR ); |
|
344
|
0 |
0 |
if ( thisWrite < 0 ) return thisWrite; |
|
354
|
0 |
0 |
if ( fd->fd < 0 ) return -1; |
|
356
|
0 |
0 |
if ( fd->compressLevel ) { |
|
357
|
0 |
0 |
if ( fd->write ) { |
|
367
|
0 |
0 |
if ( BPC_LogLevel >= 8 ) bpc_logMsgf("bpc_fileZIO_close(%d)\n", fd->fd); |
|
369
|
0 |
0 |
if ( fd->lineBuf ) free(fd->lineBuf); |
|
371
|
0 |
0 |
if ( fd->buf ) { |
|
382
|
0 |
0 |
if ( fd->write ) return -1; |
|
384
|
0 |
0 |
if ( fd->compressLevel ) { |
|
391
|
0 |
0 |
return lseek(fd->fd, 0, SEEK_SET) == 0 ? 0 : -1; |
|
400
|
0 |
0 |
if ( !fd->lineBuf ) { |
|
405
|
0 |
0 |
if ( !(fd->lineBuf = malloc(fd->lineBufSize)) ) { |
|
416
|
0 |
0 |
if ( fd->lineBufIdx < fd->lineBufLen ) { |
|
417
|
0 |
0 |
if ( (p = memchr(fd->lineBuf + fd->lineBufIdx, '\n', fd->lineBufLen - fd->lineBufIdx)) ) { |
|
426
|
0 |
0 |
} else if ( fd->lineBufEof ) { |
|
434
|
0 |
0 |
} else if ( fd->lineBufLen >= fd->lineBufSize ) { |
|
439
|
0 |
0 |
if ( fd->lineBufIdx > 0 ) { |
|
445
|
0 |
0 |
if ( !(fd->lineBuf = realloc(fd->lineBuf, fd->lineBufSize)) ) { |
|
452
|
0 |
0 |
if ( fd->lineBufIdx >= fd->lineBufLen && fd->lineBufEof ) { |
|
|
0 |
0 |
if ( fd->lineBufIdx >= fd->lineBufLen && fd->lineBufEof ) { |
|
460
|
0 |
0 |
if ( fd->lineBufIdx >= fd->lineBufLen ) { |
|
464
|
0 |
0 |
if ( fd->lineBufLen < fd->lineBufSize && !fd->lineBufEof ) { |
|
|
0 |
0 |
if ( fd->lineBufLen < fd->lineBufSize && !fd->lineBufEof ) { |
|
466
|
0 |
0 |
if ( nread < 0 ) { |
|
470
|
0 |
0 |
if ( nread == 0 ) fd->lineBufEof = 1; |