Debian Codegraph @

src/core/show-status.h

raw
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3
4 #include "core-forward.h"
5
6 /* Manager status */
7
8 typedef enum ShowStatus {
9 SHOW_STATUS_NO, /* printing of status is disabled */
10 SHOW_STATUS_ERROR, /* only print errors */
11 SHOW_STATUS_AUTO, /* disabled but may flip to _TEMPORARY */
12 SHOW_STATUS_TEMPORARY, /* enabled temporarily, may flip back to _AUTO */
13 SHOW_STATUS_YES, /* printing of status is enabled */
14 _SHOW_STATUS_MAX,
15 _SHOW_STATUS_INVALID = -EINVAL,
16 } ShowStatus;
17
18 typedef enum ShowStatusFlags {
19 SHOW_STATUS_ELLIPSIZE = 1 << 0,
20 SHOW_STATUS_EPHEMERAL = 1 << 1,
21 } ShowStatusFlags;
22
23 typedef enum StatusUnitFormat {
24 STATUS_UNIT_FORMAT_NAME,
25 STATUS_UNIT_FORMAT_DESCRIPTION,
26 STATUS_UNIT_FORMAT_COMBINED,
27 _STATUS_UNIT_FORMAT_MAX,
28 _STATUS_UNIT_FORMAT_INVALID = -EINVAL,
29 } StatusUnitFormat;
30
31 static inline bool show_status_on(ShowStatus s) {
32 return IN_SET(s, SHOW_STATUS_TEMPORARY, SHOW_STATUS_YES);
33 }
34 DECLARE_STRING_TABLE_LOOKUP(show_status, ShowStatus);
35 int parse_show_status(const char *s, ShowStatus *ret);
36
37 DECLARE_STRING_TABLE_LOOKUP(status_unit_format, StatusUnitFormat);
38
39 int status_vprintf(const char *status, ShowStatusFlags flags, const char *format, va_list ap) _printf_(3,0);
40 int status_printf(const char *status, ShowStatusFlags flags, const char *format, ...) _printf_(3,4);