opengetlnclose_at.c (491B)
1 /* ISC license. */ 2 3 #include <skalibs/allreadwrite.h> 4 #include <skalibs/buffer.h> 5 #include <skalibs/djbunix.h> 6 #include <skalibs/skamisc.h> 7 #include <skalibs/unix-transactional.h> 8 9 int opengetlnclose_at (int dirfd, char const *fn, stralloc *sa, int sep) 10 { 11 char buf[BUFFER_INSIZE] ; 12 buffer b ; 13 int r ; 14 int fd = openc_readatb(dirfd, fn) ; 15 if (fd < 0) return -1 ; 16 buffer_init(&b, &buffer_read, fd, buf, BUFFER_INSIZE) ; 17 r = skagetln(&b, sa, sep) ; 18 fd_close(fd) ; 19 return r ; 20 }