]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/core/show-status.h
Merge pull request #17732 from yuwata/core-use-synthetic_errno
[thirdparty/systemd.git] / src / core / show-status.h
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3
4 #include <stdbool.h>
5
6 #include "macro.h"
7
8 /* Manager status */
9
10 typedef enum ShowStatus {
11 SHOW_STATUS_NO, /* printing of status is disabled */
12 SHOW_STATUS_ERROR, /* only print errors */
13 SHOW_STATUS_AUTO, /* disabled but may flip to _TEMPORARY */
14 SHOW_STATUS_TEMPORARY, /* enabled temporarily, may flip back to _AUTO */
15 SHOW_STATUS_YES, /* printing of status is enabled */
16 _SHOW_STATUS_MAX,
17 _SHOW_STATUS_INVALID = -1,
18 } ShowStatus;
19
20 typedef enum ShowStatusFlags {
21 SHOW_STATUS_ELLIPSIZE = 1 << 0,
22 SHOW_STATUS_EPHEMERAL = 1 << 1,
23 } ShowStatusFlags;
24
25 typedef enum StatusUnitFormat {
26 STATUS_UNIT_FORMAT_NAME,
27 STATUS_UNIT_FORMAT_DESCRIPTION,
28 _STATUS_UNIT_FORMAT_MAX,
29 _STATUS_UNIT_FORMAT_INVALID = -1,
30 } StatusUnitFormat;
31
32 static inline bool show_status_on(ShowStatus s) {
33 return IN_SET(s, SHOW_STATUS_TEMPORARY, SHOW_STATUS_YES);
34 }
35 ShowStatus show_status_from_string(const char *v) _const_;
36 const char* show_status_to_string(ShowStatus s) _pure_;
37 int parse_show_status(const char *v, ShowStatus *ret);
38
39 StatusUnitFormat status_unit_format_from_string(const char *v) _const_;
40 const char* status_unit_format_to_string(StatusUnitFormat s) _pure_;
41
42 int status_vprintf(const char *status, ShowStatusFlags flags, const char *format, va_list ap) _printf_(3,0);
43 int status_printf(const char *status, ShowStatusFlags flags, const char *format, ...) _printf_(3,4);