BIO_PARSE_HOSTSERV(3SSL)
π BIO_PARSE_HOSTSERV(3SSL) β bestie, it's giving host-and-service parsing β¨
okay so you're in the 3SSL section of the OpenSSL manuals, and today we're doing BIO_parse_hostserv and its lil enum bestie BIO_hostserv_priorities. This is one of those "utility routine" pages that doesn't sound cute but is actually doing so much heavy lifting for you. π
πΈ NAME πΈ
BIO_hostserv_priorities, BIO_parse_hostserv β utility routines to parse a standard host and service string. literally what it says on the tin, no notes. π
β¨ SYNOPSIS β¨
#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);
π¦ DESCRIPTION π¦
BIO_parse_hostserv() takes the info you handed it in hostserv and parses it, creates strings for the hostname and the service name, and hands those back to you through host and service. And because nothing in C is free (emotionally or memory-wise), those strings need to be freed after they are used. yes bestie, OPENSSL_free() them, don't just ghost them. π
hostserv_prio is the tiebreaker β it helps determine whether hostserv gets interpreted primarily as a hostname or as a service name in those ambiguous little cases. π«Ά
The syntax that BIO_parse_hostserv() recognises is:
host + ':' + service
host + ':' + '*'
host + ':'
':' + service
'*' + ':' + service
host
service
The host part can be a name or an IP address. And if it's a IPv6 address, it MUST be enclosed in brackets, like '[::1]'. no cap, the brackets are not optional, they are the whole vibe. π
The service part can be a service name or its port number. A service name gets mapped to a port number using the system function getservbyname(). iconic system-call behaviour honestly. π
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 = NULL
host + ':' => *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 on hostserv_prio, as follows:
when hostserv_prio == BIO_PARSE_PRIO_HOST
host => *host = "host", *service untouched
when hostserv_prio == BIO_PARSE_PRIO_SERV
service => *host untouched, *service = "service"
β οΈ notice the "untouched" ones bestie β those pointers don't get written to, so don't go reading them expecting anything new. π
π₯ RETURN VALUES π₯
BIO_parse_hostserv() returns 1 on success or 0 on error. that's it, that's the whole story. binary. slay. β¨
π SEE ALSO π
π COPYRIGHT π
Copyright 2016-2021 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.
and that's the page, bestie π«Ά go free your strings, mind your brackets, and remember: this was OpenSSL 4.0.3, dated 2026-09-29, from the BIO_PARSE_HOSTSERV(3SSL) manual. mwah. πβ¨π
π¦ where this page comes from
- ubuntu stonking: libssl-doc 4.0.3-1ubuntu1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms