]> git.ipfire.org Git - thirdparty/util-linux.git/blame - include/colors.h
findmnt: (verify) ignore passno for XFS
[thirdparty/util-linux.git] / include / colors.h
CommitLineData
dfa68ad1
OO
1/*
2 * Copyright (C) 2012 Ondrej Oprala <ooprala@redhat.com>
7a4704d8 3 * Copyright (C) 2012-2014 Karel Zak <kzak@redhat.com>
dfa68ad1
OO
4 *
5 * This file may be distributed under the terms of the
6 * GNU Lesser General Public License.
7 */
8#ifndef UTIL_LINUX_COLORS_H
9#define UTIL_LINUX_COLORS_H
10
11#include <stdio.h>
12#include <unistd.h>
13
0bef6f75 14#include "color-names.h"
62dc0ee8 15
a10c0434
KZ
16/* --color[=WHEN] */
17enum colortmode {
18 UL_COLORMODE_AUTO = 0,
19 UL_COLORMODE_NEVER,
20 UL_COLORMODE_ALWAYS,
d0c9ddc3 21 UL_COLORMODE_UNDEF,
a10c0434
KZ
22
23 __UL_NCOLORMODES /* last */
24};
25
62eea9ce 26#ifdef USE_COLORS_BY_DEFAULT
25c7b43e 27# define USAGE_COLORS_DEFAULT _("colors are enabled by default")
62dc0ee8 28#else
25c7b43e 29# define USAGE_COLORS_DEFAULT _("colors are disabled by default")
62dc0ee8
KZ
30#endif
31
a10c0434 32extern int colormode_from_string(const char *str);
b7faf991 33extern int colormode_or_err(const char *str, const char *errmsg);
a10c0434 34
d0c9ddc3
OO
35/* Initialize the global variable UL_COLOR_TERM_OK */
36extern int colors_init(int mode, const char *util_name);
dfa68ad1 37
80a1712f
KZ
38/* Returns 1 or 0 */
39extern int colors_wanted(void);
40
5db59623
KZ
41/* Returns UL_COLORMODE_* */
42extern int colors_mode(void);
43
e66a6627
KZ
44/* temporary enable/disable colors */
45extern void colors_off(void);
46extern void colors_on(void);
47
48
7a4704d8
KZ
49/* Set the color */
50extern void color_fenable(const char *seq, FILE *f);
b8731ebc 51
7a4704d8 52extern void color_scheme_fenable(const char *name, const char *dflt, FILE *f);
b8731ebc 53extern const char *color_scheme_get_sequence(const char *name, const char *dflt);
80a1712f 54
7a4704d8 55static inline void color_enable(const char *seq)
80a1712f 56{
7a4704d8
KZ
57 color_fenable(seq, stdout);
58}
59
60static inline void color_scheme_enable(const char *name, const char *dflt)
61{
62 color_scheme_fenable(name, dflt, stdout);
80a1712f 63}
dfa68ad1
OO
64
65/* Reset colors to default */
80a1712f
KZ
66extern void color_fdisable(FILE *f);
67
68static inline void color_disable(void)
69{
70 color_fdisable(stdout);
71}
72
dfa68ad1 73#endif /* UTIL_LINUX_COLORS_H */