1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3
4 #include "glyph-util.h"
5 #include "terminal-util.h"
6
7 void print_separator(void);
8
9 int file_url_from_path(const char *path, char **ret);
10
11 bool urlify_enabled(void);
12
13 int terminal_urlify(const char *url, const char *text, char **ret);
14 int terminal_urlify_path(const char *path, const char *text, char **ret);
15 int terminal_urlify_man(const char *page, const char *section, char **ret);
16
17 typedef enum CatFlags {
18 CAT_FLAGS_MAIN_FILE_OPTIONAL = 1 << 0,
19 } CatFlags;
20
21 int cat_files(const char *file, char **dropins, CatFlags flags);
22 int conf_files_cat(const char *root, const char *name);
23
24 #define RED_CROSS_MARK_MAX (STRLEN(ANSI_HIGHLIGHT_RED) + STRLEN("✗") + STRLEN(ANSI_NORMAL) + 1)
25 #define GREEN_CHECK_MARK_MAX (STRLEN(ANSI_HIGHLIGHT_GREEN) + STRLEN("✓") + STRLEN(ANSI_NORMAL) + 1)
26
red_cross_mark_internal(char buffer[static RED_CROSS_MARK_MAX])27 static inline const char *red_cross_mark_internal(char buffer[static RED_CROSS_MARK_MAX]) {
28 assert(buffer);
29 assert_se(stpcpy(stpcpy(stpcpy(buffer, ansi_highlight_red()), special_glyph(SPECIAL_GLYPH_CROSS_MARK)), ansi_normal()) < buffer + RED_CROSS_MARK_MAX);
30 return buffer;
31 }
32
green_check_mark_internal(char buffer[static GREEN_CHECK_MARK_MAX])33 static inline const char *green_check_mark_internal(char buffer[static GREEN_CHECK_MARK_MAX]) {
34 assert(buffer);
35 assert_se(stpcpy(stpcpy(stpcpy(buffer, ansi_highlight_green()), special_glyph(SPECIAL_GLYPH_CHECK_MARK)), ansi_normal()) < buffer + GREEN_CHECK_MARK_MAX);
36 return buffer;
37 }
38
39 #define RED_CROSS_MARK() red_cross_mark_internal((char[RED_CROSS_MARK_MAX]) {})
40 #define GREEN_CHECK_MARK() green_check_mark_internal((char[GREEN_CHECK_MARK_MAX]) {})
41
42 #define COLOR_MARK_BOOL(b) ((b) ? GREEN_CHECK_MARK() : RED_CROSS_MARK())
43