str_to_gensio_accepter(3)

πŸ’– str_to_gensio_accepter β€” the gensio accepter manual, bestie edition πŸ’–

okay so this is str_to_gensio_accepter(3), from the Library Functions Manual, and it's genuinely one of the most useful little pages in the gensio family. if you're building accepters out of strings, you are SO in the right place. let's get into it 🫢


✨ NAME ✨

str_to_gensio_accepter β€” Create a gensio accepter from a string

like, the whole vibe of the function is literally in the name. string in, accepter out. iconic behavior. πŸ‘‘


🌸 SYNOPSIS 🌸

#include <gensio/gensio.h>

int str_to_gensio_accepter(const char *str,
                    struct gensio_os_funcs *o,
                    gensio_accepter_event cb,
                    void *user_data,
                    struct gensio_accepter **acc);

int str_to_gensio_accepter_child(struct gensio_accepter *child,
                    const char *str,
                    struct gensio_os_funcs *o,
                    gensio_accepter_event cb,
                    void *user_data,
                    struct gensio_accepter **acc);

int gensio_terminal_acc_alloc(const char *gensiotype,
                    const void *gdata,
                    const char * const args[],
                    struct gensio_os_funcs *o,
                    gensio_accepter_event cb, void *user_data,
                    struct gensio_accepter **accepter);

int gensio_filter_acc_alloc(const char *gensiotype,
                    struct gensio_accepter *child,
                    const char * const args[],
                    struct gensio_os_funcs *o,
                    gensio_accepter_event cb, void *user_data,
                    struct gensio_accepter **accepter);

four functions. one header. <gensio/gensio.h> carrying the whole friend group fr fr. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

str_to_gensio_accepter allocates a brand-new gensio accepter stack, and it builds the whole thing based on the string you hand it in str. that's the tea. you give it a string, it gives you a whole accepter stack. ✨

str_to_gensio_accepter_child does the same allocate-a-new-gensio-accepter-stack-based-on-str thing, but then it stacks that new stack on top of the child accepter you already have. it's giving "we're adding a layer, and the layer has a parent." main character stacking energy. 🌈


πŸ’œ allocating directly (no string, just vibes)

if you wanna allocate an accepter directly instead of going through a string, you use one of gensio_terminal_acc_alloc or gensio_filter_acc_alloc. pick your fighter.

  • a terminal accepter is one sitting at the bottom of the stack. it's the foundation, the bedrock, the one holding everyone up. πŸ‘‘
  • the gdata parameter depends on the particular gensio. like, it is NOT one-size-fits-all, bestie. for instance:
    • for tcp it's a pointer to a gensio_addr structure.
    • for stdio it's an argv array.
    • and for the specifics of what gdata is for whatever particular gensio you're using, go read gensio.5 under "Direct Allocation". that's where the answers live. πŸ”

a filter accepter is one that has a child. yes, exactly like str_to_gensio_accepter_child sets up. so if you want to allocate an accepter stack directly β€” no string format involved at all β€” these two functions are your girls. πŸŽ€


πŸ“ the callback situation

the cb and user_data parameters set up a function that gets called when events come in on the gensio accepter. so like, events happen, your function hears about it. very demure, very mindful.

and here's the cute part: user_data is unused by the gensio stack itself. it's there purely for you. it can be anything the user wishes. literally anything. it's your little pocket of personal space and gensio will not touch it. πŸ™ˆ


⭐ the return

the new gensio accepter comes back to you in acc.

and important detail bestie, do not skip this: it will be in the shutdown state. so don't expect it to be up and running the second you get it back, okay? it's freshly allocated and it's chillin in shutdown. 😭


πŸ”₯ RETURN VALUES πŸ”₯

zero is returned on success, or a gensio error on failure.

that's it. 0 = slay. anything else = a gensio error, go check it. ✨


πŸ’€ SEE ALSO πŸ’€

go read these. iykyk. πŸ“š


and that's the whole page, bestie!! this one's from the Library Functions Manual, dated 27 Feb 2019, and it ate, no crumbs. now go build an accepter stack and be the main character of your own network code. periodt. πŸ’…πŸ’–βœ¨

πŸ“¦ where this page comes from