From 9b3d5f87e7718b00f786531b58bf102cdadc8264 Mon Sep 17 00:00:00 2001 From: FreeArtMan Date: Sun, 11 Jan 2015 17:49:03 +0900 Subject: Added primitive authentification support --- libterm/examples/Makefile | 3 ++- libterm/examples/readline.c | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 libterm/examples/readline.c (limited to 'libterm/examples') diff --git a/libterm/examples/Makefile b/libterm/examples/Makefile index 00583f8..ffc3d1d 100644 --- a/libterm/examples/Makefile +++ b/libterm/examples/Makefile @@ -1,6 +1,7 @@ CC=gcc CFLAGS=-I../ ../libterm.o -SOURCES=detect_resize.c detect_screen_size.c filtered_input.c invisible_input.c restore_screen.c print_8025.c +SOURCES=detect_resize.c detect_screen_size.c filtered_input.c invisible_input.c \ +readline.c restore_screen.c print_8025.c EXE=$(SOURCES:.c=) BUILD_DIR=. diff --git a/libterm/examples/readline.c b/libterm/examples/readline.c new file mode 100644 index 0000000..cd4467d --- /dev/null +++ b/libterm/examples/readline.c @@ -0,0 +1,40 @@ +#include +#include + +#include +#include + +int main() +{ + + const int sz = 31; + char name[sz]; + char passsword[sz]; + + struct term_screen ts; memset( &ts, 0, sizeof(ts) ); + + if ( term_init( &ts ) == -1 ) + printf("Some err when init\n"); + + term_set_raw_mode( &ts ); + + term_clr_scr( &ts ); + + term_cur_set_c( &ts, 0); + term_cur_set_r( &ts, 1 ); + term_readline( &ts, name, sz, READLINE_TEXT ); + + term_cur_set_c( &ts, 0 ); + term_cur_set_r( &ts, 2 ); + term_readline( &ts, passsword, sz, READLINE_HIDDEN ); + + + term_clr_scr( &ts ); + + term_set_orig_mode( &ts ); + + printf("Name:%s\n", name); + printf("passsword:%s\n", passsword ); + + return 0; +} \ No newline at end of file -- cgit v1.2.3