scan_netstring(3)

scan_netstring3

Parse a netstring

Usage

#include <libowfat/scan.h>

size_t scan_netstring(const char *in,size_t len,char** dest, size_t *slen);

Overview

scan_netstring attempts to parse the netstring in the input buffer (in,len). If the buffer contains a valid netstring, then (*dest,*slen) is set to the start and length of the transported string.

Note that this string is not zero terminated. No copy is made. scan_netstring points it inside the input buffer.

Return value

scan_netstring returns the number of bytes in the netstring (the outer representation, not the transported inner string) if parsing worked, or 0 if the input buffer did not contain a valid (or full) netstring.

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.