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)
138 static inline ssize_t HTS_RESULT_USED
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);
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);