fmt_netstring(3)

fmt_netstring3

Convert a memory buffer into a netstring

Usage

#include <libowfat/fmt.h>

size_t fmt_netstring(char *dest,const char *source,
size_t len);

Overview

fmt_netstring creates a netstring from a raw memory buffer and returns the length.

fmt_netstring does not append \0.

If dest equals FMT_LEN (i.e. is zero), fmt_netstring returns the number of bytes it would have written.

Return value

fmt_netstring returns the number of bytes written (or that would have been written, had the destination pointer not pointed to NULL).

If the input buffer is implausibly large, fmt_netstring returns 0 instead.

Examples

The raw memory buffer "foo" would become the netstring "3:foo,"

Spec

http://cr.yp.to/proto/netstrings.txt

Releases

Unchanged in 2 releases since Debian 12 (Bookworm).

  1. 12–13

From libowfat-dev 0.32-5 in Debian 13 (Trixie). Parsed by carta from the page's man source.