diff options
author | Werner Fink | 2013-01-08 15:38:40 +0100 |
---|---|---|
committer | Karel Zak | 2013-01-08 15:42:12 +0100 |
commit | f5664477cbc7c5f94bf6e640adf01e47880a9b12 (patch) | |
tree | 5d5f90a1be010cb56470da4ad73d33fa49554beb /include/ttyutils.h | |
parent | include: cleanup copyright headers (diff) | |
download | kernel-qcow2-util-linux-f5664477cbc7c5f94bf6e640adf01e47880a9b12.tar.gz kernel-qcow2-util-linux-f5664477cbc7c5f94bf6e640adf01e47880a9b12.tar.xz kernel-qcow2-util-linux-f5664477cbc7c5f94bf6e640adf01e47880a9b12.zip |
include/ttyutils: add default chardata
this one moves the init_chardata to include/ttyutils.h as well as to
lib/include/ttyutils.c. Also the macros CTL/CTRL are fixed in
agetty.c and sulogin.c to use the XOR variant CTL.
[kzak@redhat.com: use macro rather than global variable for default
chardata]
Signed-off-by: Werner Fink <werner@suse.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'include/ttyutils.h')
-rw-r--r-- | include/ttyutils.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/include/ttyutils.h b/include/ttyutils.h index 3ed788359..021156d3e 100644 --- a/include/ttyutils.h +++ b/include/ttyutils.h @@ -14,6 +14,22 @@ #include <sys/ioctl.h> #endif +/* Some shorthands for control characters. */ +#define CTL(x) ((x) ^ 0100) /* Assumes ASCII dialect */ +#define CR CTL('M') /* carriage return */ +#define NL CTL('J') /* line feed */ +#define BS CTL('H') /* back space */ +#define DEL CTL('?') /* delete */ + +/* Defaults for line-editing etc. characters; you may want to change these. */ +#define DEF_ERASE DEL /* default erase character */ +#define DEF_INTR CTL('C') /* default interrupt character */ +#define DEF_QUIT CTL('\\') /* default quit char */ +#define DEF_KILL CTL('U') /* default kill char */ +#define DEF_EOF CTL('D') /* default EOF char */ +#define DEF_EOL 0 +#define DEF_SWITCH 0 /* default switch char */ + /* Storage for things detected while the login name was read. */ struct chardata { int erase; /* erase character */ @@ -23,6 +39,14 @@ struct chardata { int capslock; /* upper case without lower case */ }; +#define INIT_CHARDATA(ptr) do { \ + (ptr)->erase = DEF_ERASE; \ + (ptr)->kill = DEF_KILL; \ + (ptr)->eol = CTRL('r'); \ + (ptr)->parity = 0; \ + (ptr)->capslock = 0; \ + } while (0) + extern int get_terminal_width(void); extern int get_terminal_name(const char **path, const char **name, const char **number); |