ucspi-ssl  0.99e
TLS encryption for IPv6 communication
readclose.c
Go to the documentation of this file.
1 /* Public domain. */
2 
3 #include <unistd.h>
4 #include "error.h"
5 #include "readclose.h"
6 
7 int readclose_append(int fd,stralloc *sa,unsigned int bufsize)
8 {
9  int r;
10  for (;;) {
11  if (!stralloc_readyplus(sa,bufsize)) { close(fd); return -1; }
12  r = read(fd,sa->s + sa->len,bufsize);
13  if (r == -1) if (errno == error_intr) continue;
14  if (r <= 0) { close(fd); return r; }
15  sa->len += r;
16  }
17 }
18 
19 int readclose(int fd,stralloc *sa,unsigned int bufsize)
20 {
21  if (!stralloc_copys(sa,"")) { close(fd); return -1; }
22  return readclose_append(fd,sa,bufsize);
23 }
int stralloc_readyplus(stralloc *, unsigned int)
int readclose_append(int fd, stralloc *sa, unsigned int bufsize)
Definition: readclose.c:7
int error_intr
Definition: error.c:8
int readclose(int fd, stralloc *sa, unsigned int bufsize)
Definition: readclose.c:19
int stralloc_copys(stralloc *, const char *)
Definition: stralloc_opys.c:7