no way to seek on a pipe and the messages always appear.
#include <stdio.h>
#include <ctype.h>
+#include <errno.h>
#include <assert.h>
#include "bam.h"
#include "bam_endian.h"
int32_t i = 1, name_len;
// check EOF
i = bgzf_check_EOF(fp);
- if (i < 0) fprintf(stderr, "[bam_header_read] read from pipe; skip EOF checking.\n");
+ if (i < 0) {
+ // If the file is a pipe, checking the EOF marker will *always* fail
+ // with ESPIPE. Suppress the error message in this case.
+ if (errno != ESPIPE) perror("[bam_header_read] bgzf_check_EOF");
+ }
else if (i == 0) fprintf(stderr, "[bam_header_read] EOF marker is absent.\n");
// read "BAM1"
if (bam_read(fp, buf, 4) != 4) return 0;
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
+#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
* while fseek() returns zero on success. */
off_t offset = lseek(fp->fd, off, whence);
if (offset == -1) {
- perror("lseek");
return -1;
}
fp->offset = offset;
{
if (whence == SEEK_END) { // FIXME: can we allow SEEK_END in future?
fprintf(stderr, "[knet_seek] SEEK_END is not supported for HTTP. Offset is unchanged.\n");
+ errno = ESPIPE;
return -1;
}
if (whence==SEEK_CUR)
fp->is_ready = 0;
return fp->offset;
}
+ errno = EINVAL;
return -1;
}