diff options
author | Ian Moffett <ian@osmora.org> | 2025-02-21 23:57:27 -0500 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2025-02-21 23:57:27 -0500 |
commit | 0a11a88075bc6e44c473d54334b61e7bc973e163 (patch) | |
tree | 50a4f27d54383e56da452cb8ea752f859e474b14 | |
parent | 17550e41d056a6e05a75ea686f1ee5f5d864a407 (diff) |
client: Print login information
Signed-off-by: Ian Moffett <ian@osmora.org>
-rw-r--r-- | src/client/client.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/client/client.c b/src/client/client.c index b711882..df90243 100644 --- a/src/client/client.c +++ b/src/client/client.c @@ -27,6 +27,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include <sys/ioctl.h> #include <ostp/session.h> #include <stdio.h> #include <stdlib.h> @@ -46,6 +47,25 @@ static char input[512]; static size_t input_i = 0; static struct termios orig_termios; +void set_title(const char *text) +{ + int rows, cols; + int col_position; + struct winsize w; + + ioctl(STDOUT_FILENO, TIOCGWINSZ, &w); + rows = w.ws_row; + cols = w.ws_col; + + col_position = (cols - strlen(text)) / 2; + + printf("\033[s"); + printf("\033[1;%dH%s", col_position, text); + printf("\033[3;1H"); + printf("\033[u"); +} + + static void enable_raw_mode(void) { @@ -65,6 +85,7 @@ disable_raw_mode(void) { tcsetattr(STDIN_FILENO, TCSAFLUSH, &orig_termios); } + static void * recv_td(void *args) { @@ -97,8 +118,12 @@ main(int argc, char **argv) { int error; char c, send_buf[2048]; + char title[256]; size_t len; + printf("\033c\n\n"); + set_title("OMOC - login"); + tcgetattr(STDIN_FILENO, &orig_termios); setbuf(stdin, NULL); setbuf(stdout, NULL); @@ -115,6 +140,9 @@ main(int argc, char **argv) return error; } + snprintf(title, sizeof(title), "OMOC - logged in as %s\n", s.username); + set_title(title); + atexit(disable_raw_mode); enable_raw_mode(); |