BIO_PARSE_HOSTSERV(3ossl)
π BIO_PARSE_HOSTSERV π
okay bestie, so this one is from the OpenSSL manual, section 3ossl β yes the whole BIO_PARSE_HOSTSERV(3ossl) situation β and it's genuinely the comfiest little utility page. it's giving "small but mighty" fr fr π
β¨ NAME β¨
BIO_hostserv_priorities, BIO_parse_hostserv β utility routines to parse a standard host and service string π¦
πΈ 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 π
so BIO_parse_hostserv() takes whatever string you hand it in hostserv, parses the info out of it, builds fresh strings holding the hostname and the service name, and hands them back to you through host and service. and bestie, those strings are yours now β you have to free them once you're done with them, no cap π
hostserv_prio is the tiebreaker: it tells the function whether an ambiguous hostserv should be read primarily as a hostname or as a service name. main character energy for a single enum, honestly π
here's the syntax that BIO_parse_hostserv() recognises π«Ά
host + ':' + service
host + ':' + '*'
host + ':'
':' + service
'*' + ':' + service
host
service
the host part can be a name or an IP address. if it's an IPv6 address, it MUST be enclosed in brackets, like '[::1]' β like, that's not a suggestion, that's the law π
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(). slay, the system does the lookup for you β¨
so what you actually get back depends on the hostserv string and hostserv_prio, like this:
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"
and in case there's no ':' anywhere in the string, the result depends on hostserv_prio, like so:
when hostserv_prio == BIO_PARSE_PRIO_HOST
host => *host = "host", *service untouched
when hostserv_prio == BIO_PARSE_PRIO_SERV
service => *host untouched, *service = "service"
untouched literally means untouched, btw β it doesn't get written to at all, so don't be out here expecting a fresh NULL in there π
β RETURN VALUES β
BIO_parse_hostserv() returns 1 on success or 0 on error. cute and binary, we love a simple vibe check π
π¦ SEE ALSO π¦
BIO_ADDRINFO(3) β go read that one next, bestie, iykyk π
π 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 whole page, no crumbs left π mwah π β this was version 3.5.0, dated 2026-09-25, straight from the BIO_PARSE_HOSTSERV(3ossl) manual, and yes she ate ππ§
π¦ where this page comes from
- opensuse-leap 16.0: openssl-3-doc 3.5.0-160000.11.1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms