summaryrefslogtreecommitdiff
path: root/src/libexecline/el_parse_from_buffer.c
blob: 83862f318925b73ed3915451ca348acb57b463c8 (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)
{
  register 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) ;
}