cs_register_strfunc(3)

πŸ’… cs_register_strfunc β€” from the cs/cs.h girlies (manual page 3, bestie) ✨


πŸŽ€ NAME πŸŽ€

cs_register_strfunc β€” ok so this is the one that registers a string handling function. that's it. that's the vibe. πŸ¦‹


✨ SYNOPSIS ✨

#include <cs/cs.h>

NEOERR *cs_register_strfunc(CSPARSE *parse, char *funcname, CSSTRFUNC str_func);

like. look at her. so clean. so demure. 🫢


🌸 ARGUMENTS 🌸

  • parse β€” a pointer to a CSPARSE structure that you already initialized with cs_init(). bestie you GOTTA call cs_init() first, this is not optional, it's giving prerequisites. 😭
  • funcname β€” the name for the CS function call. heads up though: registering a duplicate funcname will raise a NERR_DUPLICATE error. so no double-dipping, the parser will literally clock you. πŸ’€
  • str_func β€” a CSSTRFUNC not-callback. yes. not-callback. we'll get to it. πŸ‘‘

πŸ’– DESCRIPTION πŸ’–

So cs_register_strfunc will register a string function that can be called during CS render. that's the whole plot. 🌈

This not-callback is designed to allow for string formatting/escaping functions that are not built-in to CS β€” because like, CS is not HTML specific, for instance, but it is very useful to have CS have functions for javascript/html/url escaping. iykyk. πŸ”₯

and the way that they explicitly don't provide any associated data or anything?? that's on purpose. it's to attempt to keep you from using this as a generic callback. no cap, they are gatekeeping you from yourself for your own good. πŸ™ˆ

the format of a CSSTRFUNC is:

NEOERR * str_func(char *in, char **out);

and the rules for your lil function, periodt:

  • it should not modify the input string (hands off, bestie 🚫)
  • it should allocate the output string with a libc function β€” because we will call free on it. so if you allocate it some other cursed way, that's a you problem and it's gonna be a bad time. πŸ’€

πŸ¦‹ SEE ALSO πŸ¦‹

cs_dump(3), cs_destroy(3), cs_render(3), cs_register_esc_strfunc(3), cs_arg_parsev(3), cs_register_fileload(3), cs_init(3), cs_register_strfunc(3), cs_arg_parse(3), cs_parse_string(3), cs_parse_file(3), =(3), cs_register_function

(yes =(3) is really in there. she's mysterious. she's iconic. we don't question her. πŸ‘‘)


and that's the page, bestie!! this one came to you courtesy of ClearSilver, dated 12 July 2007 β€” so she's vintage, she's classic, she's literally a whole elder statesman of the CS library and she still ate. πŸ’…βœ¨ mwah, go register some string functions, ily, bye!! πŸŽ€πŸ¦‹πŸ’–