1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3 
4 #include <stdbool.h>
5 #include <stdio.h>
6 
7 typedef enum HostnameSource {
8         HOSTNAME_STATIC,     /* from /etc/hostname */
9         HOSTNAME_TRANSIENT,  /* a transient hostname set through systemd, hostnamed, the container manager, or otherwise */
10         HOSTNAME_DEFAULT,    /* the os-release default or the compiled-in fallback were used */
11         _HOSTNAME_INVALID = -EINVAL,
12 } HostnameSource;
13 
14 const char* hostname_source_to_string(HostnameSource source) _const_;
15 HostnameSource hostname_source_from_string(const char *str) _pure_;
16 
17 int sethostname_idempotent(const char *s);
18 
19 int shorten_overlong(const char *s, char **ret);
20 
21 int read_etc_hostname_stream(FILE *f, char **ret);
22 int read_etc_hostname(const char *path, char **ret);
23 
24 void hostname_update_source_hint(const char *hostname, HostnameSource source);
25 int hostname_setup(bool really);
26