BIO_parse_hostserv3ssl
Utility routines to parse a standard host and service string
Usage
#include <openssl/bio.h>enum BIO_hostserv_priorities {BIO_PARSE_PRIO_HOST, BIO_PARSE_PRIO_SERV};int BIO_parse_hostserv(const char *hostserv, char **host, char **service,enum BIO_hostserv_priorities hostserv_prio);
Overview
BIO_parse_hostserv() will parse the information given in hostserv, create strings with the hostname and service name and give those back via host and service. Those will need to be freed after they are used. hostserv_prio helps determine if hostserv shall be interpreted primarily as a hostname or a service name in ambiguous cases.
The syntax the BIO_parse_hostserv() recognises is:
host + ':' + servicehost + ':' + '*'host + ':'':' + service'*' + ':' + servicehostservice
The host part can be a name or an IP address. If it's a IPv6 address, it MUST be enclosed in brackets, such as '[::1]'.
The service part can be a service name or its port number. A service name will be mapped to a port number using the system function getservbyname().
The returned values will depend on the given hostserv string and hostserv_prio, as follows:
host + ':' + service => *host = "host", *service = "service"host + ':' + '*' => *host = "host", *service = NULLhost + ':' => *host = "host", *service = NULL':' + service => *host = NULL, *service = "service"'*' + ':' + service => *host = NULL, *service = "service"in case no ':' is present in the string, the result depends onhostserv_prio, as follows:when hostserv_prio == BIO_PARSE_PRIO_HOSThost => *host = "host", *service untouchedwhen hostserv_prio == BIO_PARSE_PRIO_SERVservice => *host untouched, *service = "service"
Return values
BIO_parse_hostserv() returns 1 on success or 0 on error.
Releases
6 releases since Debian 9 (Stretch); the text changed 5 times.