25 #ifndef HTSLIB_HFILE_H
26 #define HTSLIB_HFILE_H
30 #include <sys/types.h>
80 static inline int herrno(
hFILE *fp)
88 static inline void hclearerr(
hFILE *fp)
104 static inline off_t htell(
hFILE *fp)
113 static inline int hgetc(
hFILE *fp)
138 static inline ssize_t HTS_RESULT_USED
139 hread(
hFILE *fp,
void *buffer,
size_t nbytes)
141 extern ssize_t
hread2(
hFILE *,
void *,
size_t,
size_t);
144 if (n > nbytes) n = nbytes;
145 memcpy(buffer, fp->
begin, n);
147 return (n == nbytes)? (ssize_t) n :
hread2(fp, buffer, nbytes, n);
154 static inline int hputc(
int c,
hFILE *fp)
166 static inline int hputs(
const char *text,
hFILE *fp)
168 extern int hputs2(
const char *,
size_t,
size_t,
hFILE *);
170 size_t nbytes = strlen(text), n = fp->
limit - fp->
begin;
171 if (n > nbytes) n = nbytes;
172 memcpy(fp->
begin, text, n);
174 return (n == nbytes)? 0 :
hputs2(text, nbytes, n, fp);
182 static inline ssize_t HTS_RESULT_USED
183 hwrite(
hFILE *fp,
const void *buffer,
size_t nbytes)
185 extern ssize_t
hwrite2(
hFILE *,
const void *,
size_t,
size_t);
188 if (n > nbytes) n = nbytes;
189 memcpy(fp->
begin, buffer, n);
191 return (n==nbytes)? (ssize_t) n :
hwrite2(fp, buffer, nbytes, n);
ssize_t hpeek(hFILE *fp, void *buffer, size_t nbytes) HTS_RESULT_USED
Definition: hfile.c:135
int has_errno
Definition: hfile.h:47
int hflush(hFILE *fp) HTS_RESULT_USED
Definition: hfile.c:200
off_t hseek(hFILE *fp, off_t offset, int whence) HTS_RESULT_USED
Definition: hfile.c:249
hFILE * hdopen(int fd, const char *mode) HTS_RESULT_USED
Definition: hfile.c:407
char * limit
Definition: hfile.h:43
void hclose_abruptly(hFILE *fp)
Definition: hfile.c:284
int at_eof
Definition: hfile.h:46
char * buffer
Definition: hfile.h:43
hFILE * hopen(const char *filename, const char *mode) HTS_RESULT_USED
Definition: hfile.c:519
int hputs2(const char *text, size_t totalbytes, size_t ncopied, hFILE *fp)
Definition: hfile.c:244
#define HTS_RESULT_USED
Definition: hts_defs.h:38
int hclose(hFILE *fp) HTS_RESULT_USED
Definition: hfile.c:269
Definition: hfile_internal.h:30
const struct hFILE_backend * backend
Definition: hfile.h:44
ssize_t hread2(hFILE *fp, void *destv, size_t nbytes, size_t nread)
Definition: hfile.c:152
off_t offset
Definition: hfile.h:45
int hputc2(int c, hFILE *fp)
Definition: hfile.c:208
char * begin
Definition: hfile.h:43
ssize_t hwrite2(hFILE *fp, const void *srcv, size_t totalbytes, size_t ncopied)
Definition: hfile.c:217
char * end
Definition: hfile.h:43
int hgetc2(hFILE *fp)
Definition: hfile.c:130