]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/basic/hostname-util.h
core,journald: use quoted commandlines
[thirdparty/systemd.git] / src / basic / hostname-util.h
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3
4 #include <stdbool.h>
5 #include <stdio.h>
6
7 #include "macro.h"
8 #include "strv.h"
9
10 char* get_default_hostname(void);
11 char* gethostname_malloc(void);
12 char* gethostname_short_malloc(void);
13 int gethostname_strict(char **ret);
14
15 bool valid_ldh_char(char c) _const_;
16
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 */
20 } ValidHostnameFlags;
21
22 bool hostname_is_valid(const char *s, ValidHostnameFlags flags) _pure_;
23 char* hostname_cleanup(char *s);
24
25 bool is_localhost(const char *hostname);
26
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.");
30 }