mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-01-23 02:14:37 +00:00
bfd: add breadchr
Reading stops after an EOF or a specified charecter. Signed-off-by: Andrew Vagin <avagin@openvz.org> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
parent
64b00b3b09
commit
1d8fcb6b94
2 changed files with 7 additions and 1 deletions
7
bfd.c
7
bfd.c
|
|
@ -168,6 +168,11 @@ static char *strnchr(char *str, unsigned int len, char c)
|
|||
}
|
||||
|
||||
char *breadline(struct bfd *f)
|
||||
{
|
||||
return breadchr(f, '\n');
|
||||
}
|
||||
|
||||
char *breadchr(struct bfd *f, char c)
|
||||
{
|
||||
struct xbuf *b = &f->b;
|
||||
bool refilled = false;
|
||||
|
|
@ -175,7 +180,7 @@ char *breadline(struct bfd *f)
|
|||
unsigned int ss = 0;
|
||||
|
||||
again:
|
||||
n = strnchr(b->data + ss, b->sz - ss, '\n');
|
||||
n = strnchr(b->data + ss, b->sz - ss, c);
|
||||
if (n) {
|
||||
char *ret;
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ int bfdopenr(struct bfd *f);
|
|||
int bfdopenw(struct bfd *f);
|
||||
void bclose(struct bfd *f);
|
||||
char *breadline(struct bfd *f);
|
||||
char *breadchr(struct bfd *f, char c);
|
||||
int bwrite(struct bfd *f, const void *buf, int sz);
|
||||
struct iovec;
|
||||
int bwritev(struct bfd *f, const struct iovec *iov, int cnt);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue