runit

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

openreadclose.c (352B)


      1 /* Public domain. */
      2 
      3 #include "error.h"
      4 #include "open.h"
      5 #include "readclose.h"
      6 #include "openreadclose.h"
      7 
      8 int openreadclose(const char *fn,stralloc *sa,unsigned int bufsize)
      9 {
     10   int fd;
     11   fd = open_read(fn);
     12   if (fd == -1) {
     13     if (errno == error_noent) return 0;
     14     return -1;
     15   }
     16   if (readclose(fd,sa,bufsize) == -1) return -1;
     17   return 1;
     18 }