str_to_gensio(3)
π NAME π
okay bestie, gather round, because this one is genuinely iconic β it's the whole "make a gensio out of a string" situation. We're talking str_to_gensio, str_to_gensio_child, and gensio_acc_str_to_gensio, and fr fr, all three of them do one job: create a gensio from a string. It's giving Library Functions Manual, it's giving str_to_gensio(3), it's giving main character energy. π
β¨ SYNOPSIS β¨
First things first, you gotta pull in the header, no cap:
#include <gensio/gensio.h>
Then here's the whole lineup of functions, exactly as they live in the wild:
int str_to_gensio(const char *str,
struct gensio_os_funcs *o,
gensio_event cb, void *user_data,
struct gensio **io);
int str_to_gensio_child(struct gensio *child, const char *str,
struct gensio_os_funcs *o,
gensio_event cb, void *user_data,
struct gensio **io);
int gensio_acc_str_to_gensio(struct gensio_accepter *accepter,
const char *str, struct gensio_os_funcs *o,
gensio_event cb, void *user_data,
struct gensio **io);
int gensio_terminal_alloc(const char *gensiotype,
const void *gdata,
const char * const args[],
struct gensio_os_funcs *o,
gensio_event cb, void *user_data,
struct gensio **new_gensio);
int gensio_filter_alloc(const char *gensiotype,
struct gensio *child,
const char * const args[],
struct gensio_os_funcs *o,
gensio_event cb, void *user_data,
struct gensio **new_gensio);
π¦ DESCRIPTION π¦
So str_to_gensio allocates a new gensio stack based upon the given string str. That's it, that's the whole vibe. π
str_to_gensio_child is the little sibling situation: it allocates a partial gensio stack and stacks it on top of the given child. Now listen, important lore: if the child is already open, you should use gesnio_open_nochild() to open just this gensio. (Yes, that's spelled exactly like that in the source, we don't question the ancestors.) Also, heads up: this one can only be used to allocate filter gensios. Periodt.
gensio_acc_str_to_gensio is the accepter-flavored one β it allocates a gensio based upon the given accepter. The availability and use of this varies from gensio to gensio, iykyk, but lowkey the flex is that it can be used on UDP to create a gensio that uses the UDP ports that the accepter owns. The details are β¨specificβ¨:
- This will come from the first address/port that the accepter is on for TCP and UDP.
- It will bind to all the address/ports for SCTP.
And to use it, you must specify a string that exactly matches the layers of the accepter. For instance, if the accepter is "telnet,ssl(CA=x1,key=x2,cert=x3),sctp,3095", then the string must be in the form "telnet,ssl(CA=x2),sctp,otherserver,3820". The layers are exactly the same, but you can vary the options to the layers. π«Ά
π Direct Allocation π
If you wanna directly allocation gensios (yes, that's the original phrasing, we're keeping it, it ate), you can use gensio_terminal_alloc and gensio_filter_alloc.
A terminal gensio is one at the bottom of the stack. The gdata parameter depends on the particular gensio. For instance:
- For
serialdev, it is a string specifying the device and serial parameters. - For
stdio, it is an argv array.
Go see gensio.5 under "Direct Allocation" for the particular gensio to find out what gdata is. π
A filter gensio is one that has a child. You can use these two functions to allocate a gensio stack directly, not using a string format. No strings attached, literally.
π The Callback Situation π
The cb and user_data parameters set a function that will be called when events come in on the gensio.
user_datais unused by the gensio stack itself β it's there for you, the user, and may be anything the user wishes.cbmay beNULLbefore the gensio is opened, but must be set before it is opened.
π¨ bestie, listen: in particular, thecbdoes not need to be set if other gensios will be stacked on top of it in the future, because the gensios stacked on top will set thecbanduser_datavalues. So don't stress, the stacking handles it. π
The new gensio is returned in io. It will be in the closed state. She's allocated but not open, we love a reserved queen. π§
πΈ RETURN VALUES πΈ
Zero is returned on success, or a gensio error on failure. That's the whole thing. Zero = slay. Anything else = read the error, bestie. π
π₯ SEE ALSO π₯
Go read these next, they're all part of the same cinematic universe:
and that's the whole page, babe π This iconic little entry comes to you from the Library Functions Manual, dated 22 Feb 2019, and yes she's still serving str_to_gensio(3) realness. Obsessed. πβ¨π¦
π¦ where this page comes from
- alpine 3.22: gensio-doc 2.8.14-r0 Β· GPL-2.0-only AND LGPL-2.1-only AND Apache-2.0
- alpine 3.23: gensio-doc 2.8.14-r0 Β· GPL-2.0-only AND LGPL-2.1-only AND Apache-2.0
- alpine 3.24: gensio-doc 2.8.14-r0 Β· GPL-2.0-only AND LGPL-2.1-only AND Apache-2.0
- arch rolling: gensio 3.0.4-1 Β· GPL
- debian bookworm: libgensio-dev 2.6.2-4 Β· GPL-2.0-only
- debian trixie: libgensio-dev 2.8.13-7 Β· GPL-2.0-only
- epel 9: libgensio-devel 2.8.15-1.el9 Β· GPL-2.0-only AND LGPL-2.1-only AND Apache-2.0
- fedora 43: libgensio-devel 2.8.15-5.fc43 Β· GPL-2.0-only AND LGPL-2.1-only AND Apache-2.0
- fedora 43: libgensio-devel 2.8.15-5.fc43 Β· GPL-2.0-only AND LGPL-2.1-only AND Apache-2.0
- fedora 43: libgensio-devel 3.0.4-1.fc43 Β· GPL-2.0-only AND LGPL-2.1-only AND Apache-2.0
- fedora 43: libgensio-devel 3.0.4-1.fc43 Β· GPL-2.0-only AND LGPL-2.1-only AND Apache-2.0
- fedora 44: libgensio-devel 3.0.2-1.fc44 Β· GPL-2.0-only AND LGPL-2.1-only AND Apache-2.0
- fedora 44: libgensio-devel 3.0.2-1.fc44 Β· GPL-2.0-only AND LGPL-2.1-only AND Apache-2.0
- fedora 44: libgensio-devel 3.0.4-1.fc44 Β· GPL-2.0-only AND LGPL-2.1-only AND Apache-2.0
- fedora 44: libgensio-devel 3.0.4-1.fc44 Β· GPL-2.0-only AND LGPL-2.1-only AND Apache-2.0
- nixos 26.05: gensio 3.0.2
- nixpkgs unstable: gensio 3.0.2
- opensuse-leap 16.0: gensio-devel 2.8.2-bp160.1.13 Β· Apache-2.0 AND GPL-2.0-only AND LGPL-2.1-only
- opensuse-leap 16.0: gensio-devel 2.8.2-bp160.1.13 Β· Apache-2.0 AND GPL-2.0-only AND LGPL-2.1-only
- opensuse-leap 16.0: gensio-devel 2.8.2-bp160.1.13 Β· Apache-2.0 AND GPL-2.0-only AND LGPL-2.1-only
- opensuse-leap 16.0: gensio-devel 2.8.2-bp160.1.13 Β· Apache-2.0 AND GPL-2.0-only AND LGPL-2.1-only
- ubuntu noble: libgensio-dev 2.8.2-6.1build1 Β· GPL-2.0-only
- ubuntu questing: libgensio-dev 2.8.13-7
- ubuntu resolute: libgensio-dev 3.0.0-1build1 Β· GPL-2.0-only
- ubuntu stonking: libgensio-dev 3.0.0-1ubuntu1 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms