Welcome to little lamb

Code » limb » master » tree

[master] / src / doc / stralloc.h / stralloc_cat.3.md

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

# NAME

stralloc_catb, stralloc_cats, stralloc_cats0, stralloc_catv, stralloc_cat,
stralloc_copyb, stralloc_copys, stralloc_copys0, stralloc_copy,
stralloc_insertb, stralloc_inserts, stralloc_inserts0, stralloc_insert,
stralloc_append, stralloc_0 - adding data into a stralloc

# SYNOPSIS

    #include <limb/stralloc.h>

```pre hl
int stralloc_catb(stralloc *<em>sa</em>, const char *<em>data</em>, size_t <em>dlen</em>)
int stralloc_cats(stralloc *<em>sa</em>, const char *<em>str</em>)
int stralloc_cats0(stralloc *<em>sa</em>, const char *<em>str</em>)
int stralloc_catv(stralloc *<em>sa</em>, const struct iovec *<em>v</em>, unsigned <em>n</em>)
int stralloc_cat(stralloc *<em>sa</em>, const stralloc *<em>sasce</em>)

int stralloc_copyb(stralloc *<em>sa</em>, const char *<em>data</em>, size_t <em>dlen</em>)
int stralloc_copys(stralloc *<em>sa</em>, const char *<em>str</em>)
int stralloc_copys0(stralloc *<em>sa</em>, const char *<em>str</em>)
int stralloc_copy(stralloc *<em>sa</em>, const stralloc *<em>sasce</em>)

int stralloc_insertb(stralloc *<em>sa</em>, size_t <em>offset</em>, const char *<em>data</em>, size_t <em>dlen</em>)
int stralloc_inserts(stralloc *<em>sa</em>, size_t <em>offset</em>, const char *<em>str</em>)
int stralloc_inserts0(stralloc *<em>sa</em>, size_t <em>offset</em>, const char *<em>str</em>)
int stralloc_insert(stralloc *<em>sa</em>, size_t <em>offset</em>, const stralloc *<em>sasce</em>)

int stralloc_append(stralloc *<em>sa</em>, char <em>c</em>)
int stralloc_0(stralloc *<em>sa</em>)
```

# DESCRIPTION

The `stralloc_catb`() function appends the content of memory pointed by `data`
of length `dlen` into the stralloc `sa`.

The `stralloc_cats`() function is similar to `stralloc_catb`() but appending
the NUL-terminated string pointed by `str`, not including said NUL-terminating
byte.

The `stralloc_cats0`() function is similar to `stralloc_cats`() but including
the NUL-terminating byte.

The `stralloc_catv`() function is similar to `stralloc_catb`() but gathering the
data to add from the array of vectors `v` of `n` elements.

The `stralloc_cat`() function is similar to `stralloc_catb`() function but
appending the content of stralloc `sasce`.


The `stralloc_copyb`() function copies the content of memory pointed by `data`
of length `dlen` into the stralloc `sa`. That is, the stralloc will only contain
`data` afterwards.

The `stralloc_copys`() function is similar to `stralloc_copyb`() but copying
the NUL-terminated string pointed by `str`, not including said NUL-terminating
byte.

The `stralloc_copys0`() function is similar to `stralloc_copys`() but including
the NUL-terminating byte.

The `stralloc_copy`() function is similar to `stralloc_copyb`() function but
copying the content of stralloc `sasce`.


The `stralloc_insertb`() function inserts the content of memory pointed by
`data` of length `dlen` into the stralloc `sa` at offset `offset`.

The `stralloc_inserts`() function is similar to `stralloc_insertb`() but
inserting the NUL-terminated string pointed by `str`, not including said
NUL-terminating byte.

The `stralloc_inserts0`() function is similar to `stralloc_inserts`() but
including the NUL-terminating byte.

The `stralloc_insert`() function is similar to `stralloc_insertb`() function but
inserting the content of stralloc `sasce`.


The `stralloc_append`() function appends byte `c` into the stralloc `sa`.

The `stralloc_0`() function appends a NUL-byte into stralloc `sa`.

! NOTE:
! Obviously all these function ensure that there is enough room available in the
! stralloc `sa` before writing data into it.

# RETURN VALUE

These functions return 1 on success. Otherwise they return 0 and set `errno` to
indicate the error.

# ERRORS

These functions may fail if :

: *ENOMEM*
:: Out of memory.

The `stralloc_insertb`(), `stralloc_inserts`(), `stralloc_inserts0`() and
`stralloc_insert`() functions may also fail if :

: *EINVAL*
:: The `offset` is too high.