From c85f569daf3e0e99c9e8941d0234711afdb58cd7 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Thu, 16 Mar 2017 23:01:00 -0400 Subject: Give struct expr a CFILE* instead of just a FILE* This unifies the behaviour of -print and -fprint /dev/stdout. --- color.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'color.h') diff --git a/color.h b/color.h index c3b3e41..6ba6fb0 100644 --- a/color.h +++ b/color.h @@ -13,6 +13,7 @@ #define BFS_COLOR_H #include "bftw.h" +#include #include /** @@ -45,8 +46,21 @@ typedef struct CFILE { FILE *file; /** The color table to use, if any. */ const struct colors *colors; + /** Whether to close the underlying stream. */ + bool close; } CFILE; +/** + * Open a file for colored output. + * + * @param path + * The path to the file to open. + * @param colors + * The color table to use if file is a TTY. + * @return A colored file stream. + */ +CFILE *cfopen(const char *path, const struct colors *colors); + /** * Make a colored copy of an open file. * -- cgit v1.2.3