C Collections

cyaml · Section 3

cyaml_parse_n_mp, cyaml_parse_n

cyaml_parse_n_mp, cyaml_parse_n - parse a bounded YAML buffer

C Collections (libccollections, -lccollections)

#include <ccollections/cyaml.h>
 
cyaml cyaml_parse_n_mp(const char *yaml_str, size_t len,
                       char **err_str, ccol_memmgmt_procs *mp);
cyaml cyaml_parse_n(const char *yaml_str, size_t len, char **err_str);

Works like cyaml_parse_mp(), but reads at most len bytes from
yaml_str, which doesn't need a null terminator.  That makes it handy
for parsing one part of a larger buffer.  A multi-document stream
follows the same rules as in cyaml_parse_mp().
 
The character rules of cyaml_parse_mp() apply to each of the len
bytes, so a null byte, any other character outside c-printable, or a
UTF-8 sequence that len cuts short is a parse error, and the message
gives the line and the column.  No byte past len is ever read.

yaml_str   Input buffer, which doesn't need a null terminator.
len        Number of bytes to parse.
err_str    Out-parameter for the error string, or NULL to ignore it.
           It has the same rules as in cyaml_parse_mp(): The library
           owns the string, and the message is printable ASCII
           whatever the len bytes hold.
mp         Custom allocator, or NULL for the default.
           The library keeps its own copy of the struct, so the caller
           may release or reuse the struct once this call returns.
           The functions that it names must stay callable until the
           last node built with them is destroyed.  A process can use
           at most 64 distinct sets of four functions, and a call that
           would need a 65th fails and returns NULL.

The root cyaml node on success, or NULL on failure.  cyaml_parse_mp()
describes what happens with more than one document.

cyaml_parse_mp(3), cyaml_destroy(3)