1buffer_get_token_pred(3) Library Functions Manual buffer_get_token_pred(3)
2
3
4
6 buffer_get_token_pred - read token from buffer
7
9 #include <buffer.h>
10
11 ssize_t buffer_get_token_pred(buffer* b,char* x,size_t len,
12 int (*predicate)(const char* s,size_t len));
13
15 buffer_get_token_pred copies data from b to x[0], x[1], ..., x[len-1]
16 until len bytes have been read or predicate called on the destination
17 string returns nonzero.
18
19 predicate can also return 0 (indicating further input is required to
20 complete the token) or -1 (abort and return -1; use this if predicate
21 wants to enfore a maximum message size or does timeout handling or
22 detects a malformed message).
23
24 buffer_get_token_pred returns the number of bytes copied or -1 on error
25 (setting errno appropriately).
26
28 buffer_init(3), buffer_feed(3), buffer_peek(3), buffer_seek(3), buf‐
29 fer(3)
30
31
32
33 buffer_get_token_pred(3)