Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!mcvax!ukc!dcl-cs!sslvax!gdw From: gdw@ssl-macc.co.uk (Grenville Whelan) Newsgroups: net.sources Subject: TLOCK - a terminal lock-up program for VT200s Message-ID: <368@ssl-macc.co.uk> Date: Mon, 22-Sep-86 13:42:49 EDT Article-I.D.: ssl-macc.368 Posted: Mon Sep 22 13:42:49 1986 Date-Received: Tue, 23-Sep-86 22:46:08 EDT Reply-To: gdw@sslvax.UUCP (Grenville Whelan) Organization: Software Sciences Ltd, Macclesfield, UK Lines: 232 A terminal lock-up program designed for VT200's follows. It's designed to immitate the VT200 set-up screen whilst waiting for a password to unlock. It simply asks you for a password, and then verification; if successful, the screen will "lock" until interrupted with a CONTROL-C; a password to "unlock" will then be prompted. See source for more information. This will probably not run on any non-VT100 compatible terminals, (and maybe even not on your VT100 compatible terminals either :-> ). ---- CUT HERE ----- CUT HERE ----- CUT HERE ----- CUT HERE ----- CUT HERE ---- #! /bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #! /bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create the files: # tlock.c # This archive created: Mon Sep 22 17:31:33 1986 export PATH; PATH=/bin:$PATH if test -f 'tlock.c' then echo shar: will not over-write existing file "'tlock.c'" else cat << \SHAR_EOF > 'tlock.c' /* ** Program: TLOCK ** ** Function: VT200 terminal lock program. ** ** Author: Grenville Whelan 1986, (gdw@uk.co.ssl-macc) ** ** Description: TLOCK is basically another 'lock' program, but with screen ** layout designed to look like a VT200 set-up screen. When ** called, the user is prompted for a key, (or password), and ** verification of that key; the terminal then "locks" up ** until the same key is re-entered. A prompt for this "unlock" ** key will appear once "CONTROL-C" is entered. If the key is ** incorrect, the screen will be re-drawn, and will continue ** to "lock" until the correct key is given. If the key has been ** forgotten, the "tlock" process must be "killed" from another ** terminal. On a successful key, the terminal will be reset, ** and the user can continue what he was doing prior to the lock. ** ** Arguments: None read. ** ** Compile: cc tlock.c -o tlock -lcurses -ltermlib ** ** Notes: This utility will also work on VT100 compatibles and probably ** most other VT100 compatible terminals as well, although the ** Set-up feature that this is designed to immitate will be ** inaccurate. ** */ #include #include #include #define MAXNAMELEN 256 /* Max name length */ #define CLEAR "\33[H\33[J" /* DEC ESC to clear screen */ #define BELL "\7" /* DEC ESC to ring bell */ #define PROMPTLINE "\33[24;28f" /* Cursor position for prompt line */ #define CLETOEOL "\33[K" /* Clear to end of line escape */ #define ATTOFF "\33[0m" /* Turn video attributes off */ #define BOLDON "\33[1m" /* Turn bold attribute on */ #define CURSON "\33[?25h" /* Make cursor visible */ #define CURSOFF "\33[?25l" /* Make cursor invisible */ long random(); /* Random number generator */ char key[MAXNAMELEN]; /* User-input lock-key */ int ok; /* Set-up options */ char *ops[] = { "\33[7m Display \33[0m", "\33[7m General \33[0m", "\33[7m Comm \33[0m", "\33[7m Printer \33[0m", "\33[7m Keyboard \33[0m", "\33[7m Tab \33[0m", "\33[7m On Line \33[0m", "\33[7m Clear Display \33[0m", "\33[7m Clear Comm \33[0m", "\33[7m Reset Terminal \33[0m", "\33[7m Recall \33[0m", "\33[7m Save \33[0m", "\33[7m Set-Up=English \33[0m", "\33[7m North American Keyboard \33[0m", "\33[7m Default \33[0m", "\33[7m Exit \33[0m" }; /* Cursor positions for Set-up options */ char *ps[] = { "\33[18;1f", "\33[18;11f", "\33[18;21f", "\33[18;28f", "\33[18;38f", "\33[18;49f", "\33[20;1f", "\33[20;11f", "\33[20;27f", "\33[20;40f", "\33[20;57f", "\33[20;66f", "\33[22;1f", "\33[22;18f", "\33[22;46f", "\33[22;56f" }; main() { int i=0, sig, sig_trap(), n=0; char again[MAXNAMELEN]; initscr(); /* Initialise interrupt routine */ for(sig=0; sig