summaryrefslogtreecommitdiff
path: root/libterm/examples
diff options
context:
space:
mode:
authorFreeArtMan <dos21h@gmail.com>2015-01-11 17:49:03 +0900
committerFreeArtMan <dos21h@gmail.com>2015-01-11 17:49:03 +0900
commit9b3d5f87e7718b00f786531b58bf102cdadc8264 (patch)
tree51c445bbfd347353bcbc1412aaec654819739555 /libterm/examples
parent4e148546810a2902dff9444526e47c9569c79b64 (diff)
downloadmicrobbs-9b3d5f87e7718b00f786531b58bf102cdadc8264.tar.gz
microbbs-9b3d5f87e7718b00f786531b58bf102cdadc8264.zip
Added primitive authentification support
Diffstat (limited to 'libterm/examples')
-rw-r--r--libterm/examples/Makefile3
-rw-r--r--libterm/examples/readline.c40
2 files changed, 42 insertions, 1 deletions
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 <stdio.h>
+#include <stdlib.h>
+
+#include <term.h>
+#include <term_io.h>
+
+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