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 = -EINVAL,
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_COMBINED,
29 _STATUS_UNIT_FORMAT_MAX,
30 _STATUS_UNIT_FORMAT_INVALID = -EINVAL,
31 } StatusUnitFormat;
32
show_status_on(ShowStatus s)33 static inline bool show_status_on(ShowStatus s) {
34 return IN_SET(s, SHOW_STATUS_TEMPORARY, SHOW_STATUS_YES);
35 }
36 ShowStatus show_status_from_string(const char *v) _const_;
37 const char* show_status_to_string(ShowStatus s) _pure_;
38 int parse_show_status(const char *v, ShowStatus *ret);
39
40 StatusUnitFormat status_unit_format_from_string(const char *v) _const_;
41 const char* status_unit_format_to_string(StatusUnitFormat s) _pure_;
42
43 int status_vprintf(const char *status, ShowStatusFlags flags, const char *format, va_list ap) _printf_(3,0);
44 int status_printf(const char *status, ShowStatusFlags flags, const char *format, ...) _printf_(3,4);
45