1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
10 char* get_default_hostname(void);
11 char* gethostname_malloc(void);
12 char* gethostname_short_malloc(void);
13 int gethostname_strict(char **ret
);
15 bool valid_ldh_char(char c
) _const_
;
17 typedef enum ValidHostnameFlags
{
18 VALID_HOSTNAME_TRAILING_DOT
= 1 << 0, /* Accept trailing dot on multi-label names */
19 VALID_HOSTNAME_DOT_HOST
= 1 << 1, /* Accept ".host" as valid hostname */
22 bool hostname_is_valid(const char *s
, ValidHostnameFlags flags
) _pure_
;
23 char* hostname_cleanup(char *s
);
25 bool is_localhost(const char *hostname
);
27 static inline bool is_gateway_hostname(const char *hostname
) {
28 /* This tries to identify the valid syntaxes for the our synthetic "gateway" host. */
29 return STRCASE_IN_SET(hostname
, "_gateway", "_gateway.");