diff options
author | Martin Willi <martin@revosec.ch> | 2013-03-04 15:04:56 +0100 |
---|---|---|
committer | Martin Willi <martin@revosec.ch> | 2013-03-04 15:04:56 +0100 |
commit | 4d17427205e550780d5d4c58c2ed992c18171e4b (patch) | |
tree | dee8d82648b958b2c36d1f38e03188beb1e9a5ef /src/libstrongswan/utils/utils.h | |
parent | c88104aa25da002eb98345a97a70ee8bd43b0803 (diff) | |
download | strongswan-4d17427205e550780d5d4c58c2ed992c18171e4b.tar.bz2 strongswan-4d17427205e550780d5d4c58c2ed992c18171e4b.tar.xz |
Add a utility function to resolve TTY color escape codes dynamically
Diffstat (limited to 'src/libstrongswan/utils/utils.h')
-rw-r--r-- | src/libstrongswan/utils/utils.h | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/libstrongswan/utils/utils.h b/src/libstrongswan/utils/utils.h index 6c24a261f..c66c665e0 100644 --- a/src/libstrongswan/utils/utils.h +++ b/src/libstrongswan/utils/utils.h @@ -314,6 +314,46 @@ enum status_t { */ extern enum_name_t *status_names; +typedef enum tty_escape_t tty_escape_t; + +/** + * Excape codes for tty colors + */ +enum tty_escape_t { + /** text properties */ + TTY_RESET, + TTY_BOLD, + TTY_UNDERLINE, + TTY_BLINKING, + + /** foreground colors */ + TTY_FG_BLACK, + TTY_FG_RED, + TTY_FG_GREEN, + TTY_FG_YELLOW, + TTY_FG_BLUE, + TTY_FG_MAGENTA, + TTY_FG_CYAN, + TTY_FG_WHITE, + TTY_FG_DEF, + + /** background colors */ + TTY_BG_BLACK, + TTY_BG_RED, + TTY_BG_GREEN, + TTY_BG_YELLOW, + TTY_BG_BLUE, + TTY_BG_MAGENTA, + TTY_BG_CYAN, + TTY_BG_WHITE, + TTY_BG_DEF, +}; + +/** + * Get the escape string for a given TTY color, empty string on non-tty fd + */ +char* tty_escape_get(int fd, tty_escape_t escape); + /** * deprecated pluto style return value: * error message, NULL for success |