Welcome to little lamb

Code » limb » master » tree

[master] / src / doc / buffer.h / buffer_putescall.3.md

% limb manual
% buffer_putescall(3)
% limb 0.1.0
% 2023-07-24

# NAME

buffer\_putescall, buffer\_putesc, buffer\_putescs - write escaped text to a
buffer

# SYNOPSIS

    #include <limb/buffer.h>

```pre hl
int buffer_putescall(buffer *<em>b</em>, const char *<em>s</em>, size_t <em>len</em>, size_t *<em>w</em>, size_t *<em>r</em>)
ssize_t buffer_putesc(buffer *<em>b</em>, const char *<em>s</em>, size_t <em>len</em>)
ssize_t buffer_putescs(buffer *<em>b</em>, const char *<em>s</em>)
```

# DESCRIPTION

The `buffer_putescall`() function will write the content of `s` of length `len`
starting at position pointed by `r` (usually 0) into buffer `b`, whilst
taking care of escaping characters as needed. This means more characters might
be written into `b` than present in `s`.

The value pointed by `r` will be updated to reflect the position inside
`s` afterwards, while the value pointed by `w` will be updated with the length
actually written into the buffer.

The `buffer_putesc`() function does the same always processing `s` from the
start.

The `buffer_putescs`() function does the same as `buffer_putesc`() but expects
`s` to be a NUL-terminated string.

For more about the escaping performed, refer to [esc_fmt](3).

# RETURN VALUE

The `buffer_putescall`() function returns 1 on success, otherwise it returns 0
and sets `errno` to indicate the error.

The `buffer_putesc`() and `buffer_putescs`() functions return the number of
bytes written into `buf` on success. Otherwise they returns -1 and sets `errno`
to indicate the error.

# ERRORS

The `buffer_putescall`() function may fail if :

: *EINVAL*
:: `r` was too high (i.e. more than `len`).

All of these may also fail and set `errno` for any of the errors specified for
[buffer_flush](3).

# NOTES

The behavior of these functions depend on the *LC_CTYPE* category of the current
locale.