Provided by: libgensio-dev_2.8.2-6.1build1_amd64 bug

NAME

       gensio_add_default,  gensio_set_default,  gensio_get_default, gensio_get_defaultaddr, gensio_del_default,
       gensio_reset_defaults - Handle default values for gensios

SYNOPSIS

       #include <gensio/gensio.h>
       struct gensio_enum_val {
           char *name;
           int val;
       };

       int gensio_add_default(struct gensio_os_funcs *o,
                           const char *name,
                           enum gensio_default_type type,
                           const char *strval, int intval,
                           int minval, int maxval,
                           const struct gensio_enum_val *enums);

       int gensio_set_default(struct gensio_os_funcs *o,
                           const char *class, const char *name,
                           const char *strval, int intval);

       int gensio_get_default(struct gensio_os_funcs *o,
                           const char *class, const char *name,
                           bool classonly,
                           enum gensio_default_type type,
                           char **strval, int *intval);

       int gensio_get_defaultaddr(struct gensio_os_funcs *o,
                           const char *class, const char *name,
                           bool classonly,
                           int iprotocol, bool listen,
                           bool require_port,
                           struct addrinfo **rai);

       int gensio_del_default(struct gensio_os_funcs *o,
                           const char *class, const char *name,
                           bool delclasses);

       int gensio_reset_defaults(struct gensio_os_funcs *o);

DESCRIPTION

       Defaults provide a way to set overall or class-based defaults for gensio  options  (or  you  can  use  it
       yourself to create your own defaults).  The various options for gensios are described in gensio(5).

       For  default  values,  each  class  will use gensio_get_default with their class (serialdev, telnet, ssl,
       etc.) with the name as the given option name.  If a value has been set for its class, it  will  use  that
       value.   If  a value has been set with class set to NULL (a "global" default) then the value will be used
       from there.  Otherwise the code will use it's own internal default value.

       Any option provided in the gensio string will override any default value, of course.

       The classonly parameter means to not look in the global defaults.  If you use this for your own defaults,
       it is recommended that you use your own class and set classonly to true.

       Defaults  come  in  one  of  four  formats  defined  by  type:  GENSIO_DEFAULT_INT,  GENSIO_DEFAULT_BOOL,
       GENSIO_DEFAULT_ENUM,  GENSIO_DEFAULT_STR, GENSIO_DEFAULT_DATA.  int and bool are pretty self-explanatory.
       Except that if you pass in a non-NULL strval when setting one, the code will attempt  to  get  the  value
       from  the strval and will return NULL if the value is not valid.  It will attempt to translate "true" and
       "false" for bool values.  If the value is <minval or >maxval, GE_OUTOFRANGE  is  returned  from  any  set
       operation.

       When setting a str, the value is copied, you don't have to keep the copy around for yourself.

       When  getting  a  string  value,  the  value  is  duplicated  with gensio_strdup, you should free it with
       o->free().

       Data is like strings, except the length is passed in intval and it is returned the same way.   This  will
       hold arbitrary raw data.  Like strings, when you get a data value you should free it with o->free().

       If  it's  a  enum,  setting  the  value  you will pass in a string and a table of possible values in enum
       (terminated with a NULL name).  The code will look up the string you pass in in the enums table, and  set
       the  value to the integer value.  If the string is not in the enums table, it will return GE_INVAL.  When
       you get the value, it will return the value in intval.

       When getting the value, the type must match what is set in the set call.   If  the  name  is  not  found,
       GE_NOTFOUND is returned.  If the type does not match, then GE_INVAL is returned.  Note that if you save a
       value as an enum, you can fetch it as an int.

       Setting the same default again will replace the old value.

       gensio_del_default  deletes the given default.  You can only delete user-added defaults, not ones created
       by the gensio library.  If there are any class-specific default registered against the default, this call
       will fail with GE_INUSE unless delclasses is true, which will cause all the class defaults to be deleted,
       too.

       gensio_reset_defaults will reset all defaults to the value set  when  gensio_add_default  was  called  to
       create the default, or the built-in default value.

       gesnio_get_defaultaddr  gets  an  address  from the given default string.  See gensi_scan_network_port in
       gensio/gensio.h for details on how the string is formatted, what the parameters mean, and how  to  handle
       the addrinfo struct.

RETURN VALUES

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

SEE ALSO

       gensio_err(3), gensio(5)

                                                   27 Feb 2019                             gensio_add_default(3)