summaryrefslogtreecommitdiff
path: root/src/libexecline/el_parse_from_buffer.c
blob: f0d057878776e094f84d0413ca80f4cabb447150 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/* ISC license. */

#include <sys/types.h>
#include <skalibs/buffer.h>
#include <skalibs/stralloc.h>
#include <execline/execline.h>

static int next (unsigned char *c, void *p)
{
  ssize_t r = buffer_get((buffer *)p, (char *)c, 1) ;
  if (r < 0) return 0 ;
  if (!r) *c = 0 ;
  return 1 ;
}

int el_parse_from_buffer (stralloc *sa, buffer *b)
{
  return el_parse(sa, &next, b) ;
}