From:	CSBVAX::CSBVAX::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 18-MAR-1989 23:05
To:	MRGATE::"ARISIA::EVERHART"
Subj:	Termlock v1.16, part 2 of 5


Received: From KL.SRI.COM by CRVAX.SRI.COM with TCP; Tue, 14 MAR 89 09:01:30 PDT
Received: from ucbvax.Berkeley.EDU by KL.SRI.COM with TCP; Tue, 14 Mar 89 08:59:24 PST
Received: by ucbvax.Berkeley.EDU (5.61/1.36)
	id AA05054; Tue, 14 Mar 89 08:39:40 -0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews
	for info-vax@kl.sri.com (info-vax@kl.sri.com)
	(contact usenet@ucbvax.Berkeley.EDU if you have questions)
Date: 9 Mar 89 05:14:56 GMT
From: ssbell!mcmi!amperif!unocss!dent@uunet.uu.net  (Dave Caplinger)
Organization: U. of Nebraska at Omaha
Subject: Termlock v1.16, part 2 of 5
Message-Id: <703@unocss.UUCP>
Sender: info-vax-request@kl.sri.com
To: info-vax@kl.sri.com


+-+-+-+ Beginning of part 2 +-+-+-+
X
X[]`009Remote command execution: (for the user running Termlock only)
X`009  By sending messages "to himself" a person running Termlock on
X`009  another terminal than the one he is currently on can perform a
X`009  few functions...
X
X`009[]`009:status`009`009sends back info on number of msgs of what type
X`009[]`009:message`009allows re-definition of the reply-message
X`009[]`009:logout`009`009log out the Termlock process from afar
X`009[]`009:help`009`009display the list of remote commands
X
X[]`009User-defined location (and name of) Termlock log file.
X`009  (via the TERMLOCK$LOGFILE logical)
X
X[]`009System-wide timeout that will restrict the maximum amount of time
X`009  that a Termlock process can run (settable by the system manager
X`009  at a specific site).  (via the TERMLOCK$SYSTEM_TIMEOUT logical)
X
X[]`009User-defined timeout (restricted by the system-wide one above).
X`009  (via the TERMLOCK$TIMEOUT logical)
X
X[]`009"improved" (but still VT-100 specific) screen layout.
X
X[]`009Properly handles the NODE::USER bug in JNET's SEND command that
X`009  previously would cause Termlock's subprocess to commit suicide.
X`009  Now, JNET 3.3 users have PHONE replies disabled (until JNET
X`009  fixes the bug) via #ifdef's.
X
X[]`009Fixes the "F6" bug that previously caused Termlock to drop to DCL
X`009  (no questions asked), and get around to the exit handler later.
X`009  Now, F6 does nothing.
X
X[]`009Fixed a minor bug where receiving a message while locking would
X`009  lock the terminal by default (whether or not the password was
X`009  confirmed).  Now, it unlocks by default.
X
X[]`009Included a BUILD.COM to automate compilation of Termlock.  (This
X`009  command file also determines which version of JNET you are
X`009  running.)
X
XPlease note, if you were on my "update distribution list" and have received
Xan interim version of Termlock, please update!  Otherwise, you will still
Xhave some of the bugs fixed above (the F6 bug has been in there since the
Xbeginning!).  In other words, if you have anything other than v1.16 now,
Xyou should upgrade.  :-)
X
XThe 5-part VMS_SHARE file includes TERMLOCK.C, the source code, TERMLOCK.DOC,
Xthe ducumentaion in text format, and BUILD.COM, the compilation command file,
Xas well as a copy of this message (as TERMLOCK.UPDATE).
X
XI hope you enjoy the program!
X
XQuestions, comments, criticisms, suggestions, etc to:
X
X-/ Dave Caplinger /------------------+-----------------------------------
X Microcomputer Specialist            `124  Internet: unocc07@zeus.unl.edu
X "Computing and Data Communications" `124  UUCP:     uunet!btni!unocss!dent
X University of Nebraska at Omaha     `124  Bitnet:   UNOCC07@UNOMA1
X Omaha, NE 68182                     `124    or      dc3a+@andrew.cmu.edu
X
$ GOSUB UNPACK_FILE

$ FILE_IS = "TERMLOCK.C"
$ CHECKSUM_IS = 791669923
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
X/*   NOTE!  You MUST define JNET32 for the phone reply to work.        */
X/*   (The BUILD.COM file will do this for you...)                      */
X
X/***********************************************************************/
X/*                                                                     */
X/*   TERMLOCK`009`009`009`009`009`009`009       */
X/*`009`009`009`009`009`009`009`009       */
X/*`009This program will automatically reply to user messages, phone  */
X/*   requests, and network files with a different message depending on */
X/*   the type of message received.  The standard user-message reply    */
X/*   can be redefined by the user by 1) defining TERMLOCK as a foreign */
X/*   command (i.e. $ termlock :== $the$disk:[the.path]the.file ), and  */
X/*   2) adding an additional argument in quotes.  The TERMLOCK program */
X/*   additionally provides the ability to lock the terminal with a     */
X/*   user-defined password, so the user can run the program with a msg */
X/*   like: TERMLOCK "I'm at lunch right now, be back at 12:45.", lock  */
X/*   the terminal, and leave the office without having to worry about  */
X/*   someone walking in, hitting 'Q', and damaging his or her account. */
X/*`009TERMLOCK logs all messages it receives in a file called        */
X/*   TERMLOCK.LOG in the user's login directory (sys$login).  The file */
X/*   can be deleted when the log is no longer wanted.`009`009       */
X/*`009`009`009`009`009`009`009`009       */
X/*   (See the file TERMLOCK.DOC for more detailed information...)      */
X/*`009`009`009`009`009`009`009`009       */
X/*   Many thanks to Eric Rostetter of the University of Toledo for the */
X/*   original program "REPLY", which was the inspiriation for (and     */
X/*   indeed the very basis of) this program.  Several of the routines  */
X/*   included here are written by him.  (The majority of, as a matter  */
X/*   of fact! :-)  Many thanks also to Tim Russell, CONSLT32@UNOMA1,   */
X/*   for his invaluble help in programming and extensive testing.      */
X/*
X
X-/ Dave Caplinger /------------------+-----------------------------------
X Microcomputer Specialist            `124  Internet: unocc07@zeus.unl.edu
X "Computing and Data Communications" `124  UUCP:     uunet!btni!unocss!dent
X University of Nebraska at Omaha     `124  Bitnet:   UNOCC07@UNOMA1
X Omaha, NE 68182                     `124    or      dc3a+@andrew.cmu.edu
X                                                                       */
X/***********************************************************************/
X/*                                                                     */
X/* Modification History: (For REPLY, written by Eric Rostetter)        */
X/*                                                                     */
X/*      21-JAN-1986     Finished initial coding of program version 1.0 */
X/*      21-APR-1986     Update for the new version of JNET (user@node) */
X/*      18-JUN-1986     Fix GET_NAME bug,  make it ignore csnews@maine */
X/*      16-SEP-1986     Added code to save and restore terminal stuffs */
X/*      19-SEP-1986     Added code to allow the user to supply message */
X/*      23-SEP-1986     Added code to display time and date on  screen */
X/*       9-OCT-1986     Removed SMG routines and added mailbox routine */
X/*      14-OCT-1986     Cleaned up the screen I/O and what have you... */
X/*      20-OCT-1986     Add code to stop the infinite loop problems... */
X/*       2-DEC-1986     Fixed reply_to_msg so screen is always updated */
X/*      17-DEC-1986     Fixed 'logout' bug caused by network/blank msg */
V/*      11-FEB-1987     Kludged bug in UPDATE_TIME,  added `094C/`094Y traps
X */
X/*      31-MAR-1987     Added logical name translation,  fixed isvalid */
X/*       9-APR-1987     Removed reference to LNMDEF.H for compatibilty */
X/*      13-APR-1987     Added third counter, reset counters code, etc. */
X/*      14-APR-1987     Cleaned up the code, made slight modifications */
X/*      19-AUG-1987     Changed logicals for JNET version 3.2 supports */
X/*      14-DEC-1987     Add startup message to let one know it's going */
X/*       8-FEB-1988     Changed editor command to use callable editors */
X/*       9-FEB-1988     Added '$' to list of good node/name characters */
X/*      29-JUN-1988     Cleaned up code some, added reply for files... */
X/*                                                                     */
X/***********************************************************************/
X/*                                                                     */
X/* Modifications made for TERMLOCK.C by Dave Caplinger and Tim Russell */
X/*                                                                     */
X/*`00918-JUL-1988`009Changed reply message to indicate program      */
X/*`009`009`009Modified reply_to_file to only reply to        */
X/*`009`009`009`009users on the same node.                */
X/*`009`009`009Disabled `094Y and `094C completely - bell rings     */
X/*`009`009`009Removed editor support - added MORE-like view. */
X/*`009`009`009Added password support to lock terminal.       */
X/*`009`009`009Added log of # of failed unlock attempts       */
X/*`009`009`009Disabled control-t so people can't fill file   */
X/*`00920-JUL-1988`009Cleaned up 'V' option to add percent and 'Q'.  */
X/*`009`009`009Added control-w to redraw screen (usefull for  */
X/*`009`009`009`009multi-session terminals).              */
X/*`00924-JUL-1988`009Added special handling for (local) PHONE msgs. */
X/*`009`009`009Ignored messages from user running TERMLOCK.   */
X/*`009 7-AUG-1988`009Finished version 1.0 of TERMLOCK.C, including  */
X/*`009`009`009`009automatic prepending reply message     */
X/*`009`009`009`009with "* " if not there (to follow the  */
X/*`009`009`009`009convention of messages beginning with  */
X/*`009`009`009`009"*" coming from programs, servers, and */
X/*`009`009`009`009the like.  Special handling of REPLY   */
X/*`009`009`009`009messages from an OPERATOR; REPLY msgs  */
X/*`009`009`009`009are now echoed to the screen as well   */
X/*`009`009`009`009in case of system down-time notices,   */
X/*`009`009`009`009etc.  (Still logged.)`009`009       */
X/*`00911-AUG-1988`009Fixed bug with user-defined reply message not  */
X/*`009`009`009`009being allowed to be > `12660 chars, fixed */
X/*`009`009`009`009idiotic bug of using '\013' for <CR>   */
X/*`009`009`009`009instead of '\0x0D' or whatever. :-)    */
X/*`00915-AUG-1988`009Reincarnated the EDIT command, "back by        */
X/*`009`009`009`009popular demand".  Minor bug fixes.     */
X/*`00920-AUG-1988`009Replies to SEND/FILE now include remote sites  */
X/*`00924-AUG-1988`009Introduced "bad_signal()" generic exception    */
X/*`009`009`009`009handler to log out the TERMLOCK        */
X/*`009`009`009`009process(s) if something happens that   */
X/*`009`009`009`009TERMLOCK wasn't designed to handle (In */
X/*`009`009`009`009other words, bail out as a last resort */
X/*`009`009`009`009instead of stack-dump) (up to v1.05)   */
X/*`00927-OCT-1988`009Fixed logout routine, added $DCLEXH routine.   */
X/*`009`009`009`009(now v1.07)`009`009`009       */
X/*      17-JAN-1989     Added remote commands HELP, STATUS, LOGOUT,    */
X/*                              and MESSAGE.                           */
X/*`009 2-FEB-1989`009Added $TIMEOUT and $SYSTEM_TIMEOUT for auto-   */
X/*`009`009`009`009logout after a specified time.`009       */
X/*`009 3-FEB-1989`009Fixed bug with very big or negative TIMEOUTs   */
X/*`009 6-FEB-1989`009Reworked I/O routines for easier modification  */
X/*`009 7-FEB-1989`009Tried to fix message-while-confirm bug...      */
X/*`00914-FEB-1989`009JNET 3.3 broke the PHONE reply! (confirmed)    */
X/*`009`009`009`009added an #ifdef to disable phone reply */
X/*`00927-FEB-1989`009Added TERMLOCK$LOGFILE logical...`009       */
X/*`009 8-MAR-1989`009Fixed F6 "drop to DCL" bug by adding in a      */
X/*`009`009`009`009"`124 TT$M_PASSALL" into the terminal     */
X/*`009`009`009`009definition...                          */
X/*                                                                     */
X/***********************************************************************/
X
X#include <stdio>
X#include <descrip>
X#include <ctype>
X#include <iodef>
X#include <ttdef>
X#include <tt2def>
X#include <ssdef>
X#include <jpidef>
X#include <errno>
X
X#define esc 27
X#define odd( stat )`009( (stat) & 1 )
X#define LNM$_STRING 2
X#define LNM$M_CASE_BLIND 33554432
X`032
X/***********************************************************************/
X/* First define all the needed global data structures for the programs */
X/***********************************************************************/
X
Xchar    *VERSION = "v1.16";
X
Xchar`009LOGFILE[80];
X
Xchar    reply_string[110] =
X`009"* Away from terminal -- Message logged, Will reply ASAP.";
Xchar`009phone_string[110] =
X`009"* Away from terminal -- cannot answer phone.  Please send a message.";
X`032
XFILE    *fp;                            /* output file id for messages. */
X
Xint`009START_TIME, TIME_OUT;`009`009/* timeout variables...         */
X`032
Xint     status;                         /* return status from functions */
Xint     user_cnt, sys_cnt, old_cnt;`009/* number of messages that came */
Xint     tt_chan,mbx_chan,msg_chan,pid;  /* kb and mbx luns, process ids */
Xint     old_term_char,old_extended;     /* old terminal characteristics */
Xint`009bad_tries = 0;`009`009`009/* number of unsuccessfull 'U's */
Xint`009ignore,self,send,file,phone,mail,job,local,reply,cmd; /* type flags */
X
Xunsigned old_ctrl, no_ctrlt = 1048576;`009/* control enable masks         */
X
Xchar`009date_string[40];                /* the date and time, formatted */
Xchar`009myprocname[16];
Xchar    password[11];`009`009`009/* lock password                */
Xchar`009who[9],where[9],what[20];`009/* who@where sent what.         */
X
Xchar    *decnet_node,
X`009*bitnet_node;
Xchar`009myself[L_cuserid];`009`009/* The user running this prgm   */
X
Xchar    *tranlog( char *s, int flag);   /* tranlate logicals subroutine */
X
Xchar`009send_msg[110];
X
Xstruct  `123                               /* the date and time of message */
X        char    weekday[10];            /* --> the day of the week here */
X        char    filler[1];              /* --> always contains a space! */
X        char    date[12];               /* --> the date in ascii please */
X        char    time[08];               /* --> the time in ascii please */
X        `125 header;
X`032
Xstruct `123unsigned class          :8;     /* --> terminal class goes here */
X        unsigned type           :8;     /* --> the terminal type please */
X        unsigned page_width     :16;    /* --> terminal width goes here */
X        unsigned term_char      :24;    /* --> terminal characteristics */
X        unsigned page_length    :8;     /* --> page length goes in here */
X        unsigned extended       :32;    /* --> extended characteristics */
X        `125 charbuf;                      /* terminal characteristics buf */
X`032
Xstruct  `123
X        char    buffer[20];             /* the mailbox message info blk */
X        char    length;                 /* the current message's length */
X        char    filler;                 /* for some reason this is null */
X        char    message[150];           /* the messages sent to mailbox */
X        `125 mbx;
X`032
Xstruct dsc `123    long int len;           /* descriptors needed sometimes */
X                char     *addr;         /* using only a len and address */
X           `125;                           /* instead of the whole descrip */
X`032
Xunion  pointer  `123                       /* defines pointer type used in */
X                int  *intbuf;           /* in item lists of certain sys */
X                char *charbuf;          /* routines and stuff like that */
X                `125;
X`032
Xstruct itmlst   `123
X                unsigned short int bufferlength;
X                unsigned short int item_code;
X                union pointer  addr;
X                int  *retlength;
X                `125;                      /* used in some system services */
Xstruct itmlst trnlist[2];               /* Used in translating logicals */
X
Xstruct `123
X`009unsigned forward_link   :32;
X`009unsigned address        :32;
X`009unsigned arg_count      :32;
-+-+-+-+-+ End of part 2 +-+-+-+-+-

