ucspi-ssl  0.99e
TLS encryption for IPv6 communication
getln2.c
Go to the documentation of this file.
1 #include "byte.h"
2 #include "getln.h"
3 
4 int getln2(buffer *ss,stralloc *sa,char **cont,unsigned int *clen,int sep)
5 {
6  register char *x;
7  register unsigned int i;
8  int n;
9 
10  if (!stralloc_ready(sa,0)) return -1;
11  sa->len = 0;
12 
13  for (;;) {
14  n = buffer_feed(ss);
15  if (n < 0) return -1;
16  if (n == 0) { *clen = 0; return 0; }
17  x = buffer_PEEK(ss);
18  i = byte_chr(x,n,sep);
19  if (i < n) { buffer_SEEK(ss,*clen = i + 1); *cont = x; return 0; }
20  if (!stralloc_readyplus(sa,n)) return -1;
21  i = sa->len;
22  sa->len = i + buffer_get(ss,sa->s + i,n);
23  }
24 }
int buffer_feed(buffer *)
Definition: buffer_get.c:27
int getln2(buffer *ss, stralloc *sa, char **cont, unsigned int *clen, int sep)
Definition: getln2.c:4
#define buffer_SEEK(s, len)
Definition: buffer.h:42
int stralloc_readyplus(stralloc *, unsigned int)
#define buffer_PEEK(s)
Definition: buffer.h:41
unsigned int byte_chr(const char *, unsigned int n, int)
Definition: buffer.h:6
int buffer_get(buffer *, char *, unsigned int)
Definition: buffer_get.c:50