---
name: "str_to_gensio"
section: "3"
platform: "linux"
package: "gensio"
version: "3.0.4-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/str_to_gensio"
---

# str\_to\_gensio(3)

Create a gensio from a string

## NAME

str\_to\_gensio, str\_to\_gensio\_child, gensio\_acc\_str\_to\_gensio - Create a gensio from a string

## SYNOPSIS

**#include \<gensio/gensio.h\>**

- **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

**str\_to\_gensio** allocates a new gensio stack based upon the given string **str.**

**str\_to\_gensio\_child** allocates a partial gensio stack and stacks it on top of the given **child.** Note that if the child is already open, you should use **gesnio\_open\_nochild()** to open just this gensio.  This can only be used to allocate filter gensios.

**gensio\_acc\_str\_to\_gensio** allocates a gensio based upon the given accepter.  The availability and use of this varies from gensio to gensio, but it can be used on UDP to create a gensio that uses the UDP ports that the accepter owns. 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. To use this, you must specify a string that exactly matches the layers of the accepter.  So, 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.

To directly allocation gensios, 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.  See gensio.5 under "Direct Allocation" for the particular gensio for 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.

The **cb** and **user\_data** parameters set a function that will be called when events come in on the gensio. **user\_data** is unused by the gensio stack itself, it is there for the user and may be anything the user wishes. **cb** may be NULL before the gensio is opened, but must be set before it is opened.  In particular, the **cb** does not need to be set if other gensios will be stacked on top of it in the future, as the gensios stacked on top will set the **cb** and **user\_data** values.

The new gensio is returned in **io.** It will be in the closed state.

## RETURN VALUES

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

## SEE ALSO

[gensio\_set\_callback(3)](/gensio_set_callback/3.md), [gensio\_err(3)](/gensio_err/3.md), [gensio(5)](/gensio/5.md)
