diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2016-02-14 14:42:54 -0500 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2016-02-14 14:45:32 -0500 |
commit | 0d6c12cbc8370dafcfcb2c1882303ab2610175c6 (patch) | |
tree | e43350ff1e022fe904a4a10446132daf30d8e685 /color.h | |
parent | c40f26a15c0dce60ee365ee3f6d0779ef19cd947 (diff) | |
download | bfs-0d6c12cbc8370dafcfcb2c1882303ab2610175c6.tar.xz |
Refactor color handling.
The main benefit is colored warnings/errors during parsing.
Diffstat (limited to 'color.h')
-rw-r--r-- | color.h | 30 |
1 files changed, 24 insertions, 6 deletions
@@ -38,17 +38,35 @@ struct color_table *parse_colors(const char *ls_colors); */ void pretty_print(const struct color_table *colors, const struct BFTW *ftwbuf); +#if __GNUC__ +# define BFS_PRINTF_ATTRIBUTE(f, v) __attribute__((format(printf, f, v))) +#else +# define BFS_PRINTF_ATTRIBUTE(f, v) +#endif + +/** + * Pretty-print a warning message. + * + * @param colors + * The color table to use. + * @param format + * The format string. + * @param ... + * The format string's arguments. + */ +void pretty_warning(const struct color_table *colors, const char *format, ...) BFS_PRINTF_ATTRIBUTE(2, 3); + /** - * Pretty-print an error. + * Pretty-print an error message. * * @param colors * The color table to use. - * @param path - * The file path in error. - * @param error - * The error code that occurred. + * @param format + * The format string. + * @param ... + * The format string's arguments. */ -void print_error(const struct color_table *colors, const char *path, int error); +void pretty_error(const struct color_table *colors, const char *format, ...) BFS_PRINTF_ATTRIBUTE(2, 3); /** * Free a color table. |