---
name: "scan_netstring"
section: "3"
platform: "linux"
package: "libowfat-dev"
version: "0.32-5"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/scan_netstring"
---

# scan\_netstring(3)

parse a netstring

## NAME

scan\_netstring - parse a netstring

## SYNTAX

**#include \<libowfat/scan.h\>**

size\_t **scan\_netstring**(const char \**in*,size\_t len,char\*\* *dest*, size\_t \**slen*);

## DESCRIPTION

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.

## EXAMPLE

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

## SPEC

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

## SEE ALSO

[fmt\_netstring(3)](/fmt_netstring/3.md)
