cl_hp_get_field(3)

✨ cl_hp_get_field ✨

okay so bestie, this is a page from the canlock-hp 3.3.2 manual, and it's all about one little function that goes and grabs a header field for you πŸ’…


πŸ’– NAME πŸ’–

cl_hp_get_field β€” literally just executes the header parser, that's the whole job πŸŽ€


🌸 SYNOPSIS 🌸

#include <libcanlock-3/canlock-hp.h>

char *cl_hp_get_field(const char *data, size_t data_len,
                      const char *field);

πŸ¦‹ DESCRIPTION πŸ¦‹

πŸ’‘ quick note bestie: if the header field was already pulled out by some other header parser (but it might still have folding in it), go look at cl_hp_unfold_field() instead, ok?

So cl_hp_get_field() runs the header parser to extract and unfold a single header field. And here's the tea: this implementation does it by running the canlock-mhp utility in a separate process. wild, i know.

The data parameter should point to the beginning of the input data. You tell it how long that input is with the data_len parameter. And the name of the one single header field you want? That goes in the field parameter. one field. just one. don't get greedy πŸ“

The input data must be a message in canonical format (with US-ASCII encoded CRLF line breaks). If your message is in some local format (like EBCDIC encoded, or with LF line breaks), you gotta convert it to canonical format before it can be used as input. no shortcuts, sorry 😭

The input data may be a naked header with no message body, but the empty line separator after the header must always be present. Like, always. Also, the syntax of the extracted header field is not checked beyond the folding. The rest of the message doesn't need to be fully RFC 5536 conformant either, as long as all header fields start on new lines (and are correctly folded, so there's no ambiguity). Common syntax errors (like 8-bit characters in the header) are just ignored. we love a chill parser πŸ’œ


⭐ RETURN VALUE ⭐

If the parser reports success, you get a pointer to the NUL-terminated output data. Slay. Otherwise? NULL. πŸ’€

On success, the caller is responsible to free() the memory block allocated for the output data. that means you, bestie. don't forget. 🫢


πŸ‘‘ AUTHORS πŸ‘‘

Michael Baeuerle


πŸ™ˆ REPORTING BUGS πŸ™ˆ

Report bugs to <mailto:michael.baeuerle@gmx.net>.


🌈 STANDARDS 🌈

cl_hp_get_field() tries to comply with the following standards:


πŸ”₯ SEE ALSO πŸ”₯

free(3), cl_hp_parse_field(3), cl_hp_unfold_field(3), canlock-hfp(1), canlock-mhp(1), canlock(1)


and that's the whole page, periodt πŸ’… this was the Unix manual page from 2024-05-11, part of the canlock-hp 3.3.2 manual β€” go off and parse those headers, icon πŸŽ€βœ¨

πŸ“¦ where this page comes from