1/* `dir', `vdir' and `ls' directory listing programs for GNU.
2
3   Modified by Chet Ramey for Readline.
4
5   Copyright (C) 1985, 1988, 1990-1991, 1995-2010, 2012, 2015
6   Free Software Foundation, Inc.
7
8   This program is free software: you can redistribute it and/or modify
9   it under the terms of the GNU General Public License as published by
10   the Free Software Foundation, either version 3 of the License, or
11   (at your option) any later version.
12
13   This program is distributed in the hope that it will be useful,
14   but WITHOUT ANY WARRANTY; without even the implied warranty of
15   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16   GNU General Public License for more details.
17
18   You should have received a copy of the GNU General Public License
19   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
20
21/* Written by Richard Stallman and David MacKenzie.  */
22
23/* Color support by Peter Anvin <Peter.Anvin@linux.org> and Dennis
24   Flaherty <dennisf@denix.elk.miles.com> based on original patches by
25   Greg Lee <lee@uhunix.uhcc.hawaii.edu>.  */
26
27#ifndef _COLORS_H_
28#define _COLORS_H_
29
30#include <stdio.h> // size_t
31
32#if defined(__TANDEM) && defined(HAVE_STDBOOL_H) && (__STDC_VERSION__ < 199901L)
33typedef int _Bool;
34#endif
35
36#if defined (HAVE_STDBOOL_H)
37#  include <stdbool.h> // bool
38#else
39typedef int _rl_bool_t;
40
41#ifdef bool
42#  undef bool
43#endif
44#define bool _rl_bool_t
45
46#ifndef true
47#  define true 1
48#  define false 0
49#endif
50
51#endif /* !HAVE_STDBOOL_H */
52
53/* Null is a valid character in a color indicator (think about Epson
54   printers, for example) so we have to use a length/buffer string
55   type. */
56struct bin_str
57  {
58    size_t len;
59    const char *string;
60  };
61
62/* file type indicators (dir, sock, fifo, ...)
63   Default value is initialized in parse-colors.c.
64   It is then modified from the values of $LS_COLORS. */
65extern struct bin_str _rl_color_indicator[];
66
67/* The LS_COLORS variable is in a termcap-like format. */
68typedef struct _color_ext_type
69  {
70    struct bin_str ext;         	/* The extension we're looking for */
71    struct bin_str seq;         	/* The sequence to output when we do */
72    struct _color_ext_type *next;	/* Next in list */
73  } COLOR_EXT_TYPE;
74
75/* file extensions indicators (.txt, .log, .jpg, ...)
76   Values are taken from $LS_COLORS in rl_parse_colors(). */
77extern COLOR_EXT_TYPE *_rl_color_ext_list;
78
79#define FILETYPE_INDICATORS				\
80  {							\
81    C_ORPHAN, C_FIFO, C_CHR, C_DIR, C_BLK, C_FILE,	\
82    C_LINK, C_SOCK, C_FILE, C_DIR			\
83  }
84
85/* Whether we used any colors in the output so far.  If so, we will
86   need to restore the default color later.  If not, we will need to
87   call prep_non_filename_text before using color for the first time. */
88
89enum indicator_no
90  {
91    C_LEFT, C_RIGHT, C_END, C_RESET, C_NORM, C_FILE, C_DIR, C_LINK,
92    C_FIFO, C_SOCK,
93    C_BLK, C_CHR, C_MISSING, C_ORPHAN, C_EXEC, C_DOOR, C_SETUID, C_SETGID,
94    C_STICKY, C_OTHER_WRITABLE, C_STICKY_OTHER_WRITABLE, C_CAP, C_MULTIHARDLINK,
95    C_CLR_TO_EOL
96  };
97
98
99#if !S_IXUGO
100# define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH)
101#endif
102
103enum filetype
104  {
105    unknown,
106    fifo,
107    chardev,
108    directory,
109    blockdev,
110    normal,
111    symbolic_link,
112    sock,
113    whiteout,
114    arg_directory
115  };
116
117/* Prefix color, currently same as socket */
118#define C_PREFIX	C_SOCK
119
120extern void _rl_put_indicator (const struct bin_str *ind);
121extern void _rl_set_normal_color (void);
122extern bool _rl_print_prefix_color (void);
123extern bool _rl_print_color_indicator (const char *f);
124extern void _rl_prep_non_filename_text (void);
125
126#endif /* !_COLORS_H_ */
127