$! ------------------ CUT HERE ----------------------- $ v='f$verify(f$trnlnm("SHARE_VERIFY"))' $! $! This archive created by VMS_SHARE Version 7.2-007 22-FEB-1990 $! On 18-JAN-1991 10:47:25.45 By user PEIRCE $! $! This VMS_SHARE Written by: $! Andy Harper, Kings College London UK $! $! Acknowledgements to: $! James Gray - Original VMS_SHARE $! Michael Bednarek - Original Concept and implementation $! $!+ THIS PACKAGE DISTRIBUTED IN 6 PARTS, TO KEEP EACH PART $! BELOW 75 BLOCKS $! $! TO UNPACK THIS SHARE FILE, CONCATENATE ALL PARTS IN ORDER $! AND EXECUTE AS A COMMAND PROCEDURE ( @name ) $! $! THE FOLLOWING FILE(S) WILL BE CREATED AFTER UNPACKING: $! 1. BUILD.COM;1 $! 2. COPYRIGHT.TXT;1 $! 3. DESCRIP.MMS;1 $! 4. DOC.TXT;1 $! 5. JOBLOG.C;1 $! 6. JOBLOG.HLP;1 $! 7. JOBLOGCLD.CLD;1 $! 8. JOBLOGMSG.MSG;1 $! 9. MANIFEST.TXT;1 $! 10. README.TXT;1 $! 11. SUBS.C;1 $! $set="set" $set symbol/scope=(nolocal,noglobal) $f=f$parse("SHARE_TEMP","SYS$SCRATCH:.TMP_"+f$getjpi("","PID")) $e="write sys$error ""%UNPACK"", " $w="write sys$output ""%UNPACK"", " $ if f$trnlnm("SHARE_LOG") then $ w = "!" $ ve=f$getsyi("version") $ if ve-f$extract(0,1,ve) .ges. "4.4" then $ goto START $ e "-E-OLDVER, Must run at least VMS 4.4" $ v=f$verify(v) $ exit 44 $UNPACK: SUBROUTINE ! P1=filename, P2=checksum $ if f$search(P1) .eqs. "" then $ goto file_absent $ e "-W-EXISTS, File ''P1' exists. Skipped." $ delete 'f'* $ exit $file_absent: $ if f$parse(P1) .nes. "" then $ goto dirok $ dn=f$parse(P1,,,"DIRECTORY") $ w "-I-CREDIR, Creating directory ''dn'." $ create/dir 'dn' $ if $status then $ goto dirok $ e "-E-CREDIRFAIL, Unable to create ''dn'. File skipped." $ delete 'f'* $ exit $dirok: $ w "-I-PROCESS, Processing file ''P1'." $ if .not. f$verify() then $ define/user sys$output nl: $ EDIT/TPU/NOSEC/NODIS/COM=SYS$INPUT 'f'/OUT='P1' PROCEDURE Unpacker ON_ERROR ENDON_ERROR;SET(FACILITY_NAME,"UNPACK");SET( SUCCESS,OFF);SET(INFORMATIONAL,OFF);f:=GET_INFO(COMMAND_LINE,"file_name");b:= CREATE_BUFFER(f,f);p:=SPAN(" ")@r&LINE_END;POSITION(BEGINNING_OF(b)); LOOP EXITIF SEARCH(p,FORWARD)=0;POSITION(r);ERASE(r);ENDLOOP;POSITION( BEGINNING_OF(b));g:=0;LOOP EXITIF MARK(NONE)=END_OF(b);x:=ERASE_CHARACTER(1); IF g=0 THEN IF x="X" THEN MOVE_VERTICAL(1);ENDIF;IF x="V" THEN APPEND_LINE; MOVE_HORIZONTAL(-CURRENT_OFFSET);MOVE_VERTICAL(1);ENDIF;IF x="+" THEN g:=1; ERASE_LINE;ENDIF;ELSE IF x="-" THEN IF INDEX(CURRENT_LINE,"+-+-+-+-+-+-+-+")= 1 THEN g:=0;ENDIF;ENDIF;ERASE_LINE;ENDIF;ENDLOOP;t:="0123456789ABCDEF"; POSITION(BEGINNING_OF(b));LOOP r:=SEARCH("`",FORWARD);EXITIF r=0;POSITION(r); ERASE(r);x1:=INDEX(t,ERASE_CHARACTER(1))-1;x2:=INDEX(t,ERASE_CHARACTER(1))-1; COPY_TEXT(ASCII(16*x1+x2));ENDLOOP;WRITE_FILE(b,GET_INFO(COMMAND_LINE, "output_file"));ENDPROCEDURE;Unpacker;QUIT; $ delete/nolog 'f'* $ CHECKSUM 'P1' $ IF CHECKSUM$CHECKSUM .eqs. P2 THEN $ EXIT $ e "-E-CHKSMFAIL, Checksum of ''P1' failed." $ ENDSUBROUTINE $START: $ create 'f' X$! BUILD.COM -- build JOBLOG X$! X$! Copyright (c) 1990, Leonard J. Peirce X$! X$ IF P1 .EQS. "OBJ" THEN GOTO BUILD_OBJ X$! X$! build JOBLOG from the sources X$! X$ write sys$output "Building JOBLOG from the sources....." X$ write sys$output "" X$ write sys$output "CC:`09JOBLOG.C" X$! /OPTIMIZE=NOINLINE specified to overcome a bug in VAX C 3.0 X$ cc/optimize=noinline joblog.c X$ write sys$output "CC:`09SUBS.C" X$ cc/optimize=noinline subs.c X$ write sys$output "MESSAGE:`09JOBLOGMSG.MSG" X$ message/nolist/object=joblogmsg.obj joblogmsg.msg X$ write sys$output "SET COMMAND:`09JOBLOGCLD.CLD" X$ set command/object joblogcld.cld X$BUILD_OBJ: X$ write sys$output "" X$ write sys$output "Linking JOBLOG....." X$ link/notrace joblog,subs,joblogcld,joblogmsg,sys$share:vaxcrtl.opt/opt X$ write sys$output "" X$ write sys$output "*** JOBLOG built ***" X$ exit $ CALL UNPACK BUILD.COM;1 506007006 $ create 'f' X JOBLOG General Public License X X (C) Copyright 1990 by Leonard J. Peirce X X X`09`09`09 `09COPYING POLICIES X X Permission is hereby granted for copying and distribution of copies of t Vhe XJOBLOG source files, and that of any part thereof, subject to the followi Vng Xlicense conditions: X X 1. You may, without additional permission from the author, distribute`2 V0 X JOBLOG or components of JOBLOG, with or without additions developed X by you or by others at no charge. You may also distribute JOBLOG X along with any other product for sale, provided that the cost of X the bundled package is the same regardless of whether JOBLOG is in- X cluded, and provided that those interested only in JOBLOG must be X notified that it is a product freely available from the author. X X 2. Furthermore, if you distribute JOBLOG software or parts of JOBLOG, X with or without additions developed by you or others, then you must`2 V0 X either make available the source to all portions of the JOBLOG X system (exclusive of any additions made by you or by others) upon X request, or instead you may notify anyone requesting source that it X is freely available from the author. X X 3. In addition, you may not omit any of the copyright notices on X either the source files, the executable file, or the documentation. X X 4. Also, you may not omit transmission of this License agreement with`2 V0 X whatever portions of JOBLOG that are distributed. X X 5. Lastly, any users of this software must be notified that it is X without warrantee or guarantee of any nature, express or implied,`2 V0 X nor is there any fitness for use represented. X XSoftware is a malleable thing and the author can in no way guarantee th Vat Xusing this program will not cause grevious damage to your system. Of cour Vse Xthis isn't anticipated, but if it does happen, the author cannot be he Vld Xliable for any damages either directly or indirectly caused by this event. X XModification of the system is encouraged, providing that the portions of t Vhe Xsystem that are from the original still carry the appropriate copyright n Vo- Xtices and that the changed sections are clearly delimited as such. T Vhe Xauthor requests copies of any changes made to ensure that the various versio Vns Xstay reasonably in sync with each other. X XNote that it is not permitted to copy, sublicense, distribute or transfer a Vny Xof the JOBLOG software except as expressly indicated herein. Any attempts V to Xdo otherwise will be considered a violation of this license and your rights V to Xthe JOBLOG software will be voided. X X XComments on the system and/or this licensing agreement are encouraged. Se Vnd Xelectronic mail to peirce@gw.wmich.edu. The text of this copyright licen Vse Xwas borrowed from the ELM(tm) Mail System with permission from Dave Taylor. $ CALL UNPACK COPYRIGHT.TXT;1 911876202 $ create 'f' X############################################################################ V## X############################################################################ V## X# X# Installation: Western Michigan University Academic Computer Center X# X# System:`09JOBLOG X# X# Version=01`09Level=00`0901/05/90`09Leonard J. Peirce X# X# Purpose: Description file for building JOBLOG X# X# Version=01`09Level=01`0901/18/91`09Leonard J. Peirce X# X# Purpose: Change install to replace the help file instead of inserting X#`09`09it. X# X# Syntax:`09mms`09`09`09to build JOBLOG X#`09`09mms install`09`09to build/install JOBLOG X#`09`09mms clean`09`09to clean up after ourselves X# X############################################################################ V## X############################################################################ V## X XPROG = joblog X XSOURCES = joblog.c,subs.c,joblogcld.cld,joblogmsg.msg X XOBJECTS = joblog.obj,subs.obj,joblogcld.obj,joblogmsg.obj X XERRORS = error.dat`09`09`09! where error messages are sent X XBINDIR = sys$common:`5Bsysexe`5D`09`09! where the executable lives XPROT = prot=(s:rwed,o:rwed,g:e,w:e) X X# VAX C 3.0 has a problem with inline code generation; make sure that X# /optimize has =noinline if you are using it X XCFLAGS=/optimize=noinline XLINKFLAGS=/notrace XLINKOPTIONS=,sys$share:vaxcrtl.opt/opt X X$(PROG).exe :`09$(OBJECTS) X`09`09$(LINK) $(LINKFLAGS)/exec=$(PROG) $(OBJECTS) $(LINKOPTIONS) X Xclean : X`09`09- delete/nolog/noconfirm *.obj;*,*.exe;* X Xinstall :`09$(PROG).exe X`09`09copy $(PROG).exe $(BINDIR)/$(PROT) X`09`09library/help/replace sys$help:helplib.hlb joblog.hlp X X# default rule -- .C to .OBJ X X.c.obj : X`09`09$(CC) $(CFLAGS) $*.C X X.FIRST X`09`09@- define/nolog sys$error $(ERRORS) X X.LAST X`09`09@- define/nolog sys$error sys$output X X# individual dependencies -- make sure to update these if you change somethi Vng! X Xjoblog.obj : Xjoblogcld.obj : Xjoblogmsg.obj : $ CALL UNPACK DESCRIP.MMS;1 2032360335 $ create 'f' XJOBLOG: an bonafide terminal logging facility X---------------------------------------------- X XJOBLOG, a facility for logging terminal sessions, is now available. X XThere are two types of JOBLOG log files: VERIFIED and UNVERIFIED. VERIFIED Xlog files are guaranteed to be unedited by anyone, including the person who Xcreated it. Since the log files themselves are never accessible to the user V while running JOBLOG, the only opportunity for modification Xis if logging is disabled while in JOBLOG, which immediately makes the log Xfile UNVERIFIED. X XThe difference between VERIFIED and UNVERIFIED log files becomes important Xfor printed and mailed log files, especially for class assignments. X XThis also corrects a major shortcoming of the SET HOST/LOG implementation Xsince the file is never where a user can modify it. X XTo start JOBLOG, enter: X X $ JOBLOG X XAs a reminder, while in JOBLOG, your prompt will be JOBLOG. To exit JOBLOG, Xsimply enter: X X $ LOGOUT X XRemember that after exiting JOBLOG, you are still logged in to the VAX and Xneed to enter LOGOUT to end your session. X XThere are two commands that can be specified while running JOBLOG: 1) turnin Vg Xtime stamping of DCL commands on/off, and 2) turning logging on/off. X XTo toggle time stamping of DCL commands on/off, enter Control-`5D. Time- Xstamping is initially turned off when you enter JOBLOG unless you specified Xthe /TIME_STAMP identifier when JOBLOG is started. The time stamps for the XDCL commands will only appear in the log file and will not appear on the Xscreen. X XTo toggle between logging on/off, enter Control-\. Logging is initially Xturned on when JOBLOG is started. If logging is ever turned off, the log Xfile immediately becomes UNVERIFIED. X XThe disposition of the log file upon exiting JOBLOG can be handled in two Xways. You can either specify it when invoking JOBLOG or you can wait for XJOBLOG to ask what should be done. The different dispositions for the log Xfile are: X X 1) Print the log file. You will be prompted for the print queue to be X used. The /PRINT qualifier can be specified upon startup to have X the log file automatically printed upon exit from JOBLOG. The queue X can be specified upon startup by using /PRINT=queue where queue X is the print queue to be used. If the queue is not specified, you X will be prompted for it after exiting JOBLOG.`20 X X 2) Save the log file. You will be prompted for the name of the log X file. The /SAVE qualifier can be specified upon startup to have X log file automatically saved upon exit from JOBLOG. The filename X can be specified upon startup by using /SAVE=filename where X filename is the name of the file to which the log file is to be X saved. If the filename is not specified, you will be prompted X for it after exiting JOBLOG. X X 3) Mail notification of a pending log file. You will be prompted for X the user that is to receive the log file. The /MAIL qualifier can X be specified upon startup to have the notification automatically X mailed upon exit from JOBLOG. The person to receive the notifi- X cation can be specified upon startup by using /MAIL=username X where username is the name of the user to receive the notification. X If the username is not specified, you will be prompted for it X after exiting JOBLOG. X X The log file notification will contain instructions on how to re- X trieve the log file as well as whether or not the log file was X VERIFIED or UNVERIFIED. X X There are certain restrictions on who can receive mailed log files. X To be able to mail a log file to a user, the intended recipient X must be faculty, staff, or hold the JOBLOG_RECIPIENT identifier. X It is also not possible to send a log file to yourself. X `20 X 4) Delete the log file. This is the default and can be used when you X want to start over. X XRetrieving log files X-------------------- XOnce you have received a log file notification, the log file can be retrieve Vd Xby using the /RETRIEVE qualifier. Either /USER or /CLASS must be specified Xalong with /RETRIEVE. For example, to retrieve a log file from user 620SMIT VH, Xthe syntax would be: X X $ JOBLOG/RETRIEVE/USER=620SMITH X XThe resulting filename would be 620SMITH.JOBLOG if the log file was VERIFIED Xand 620SMITH.UNVERIFIED_JOBLOG if the log file was UNVERIFIED. X XThe /CLASS qualifier would normally only be used by instructors. For exampl Ve, Xif an instructor wanted to retrieve all of the log files for one's CS 105 Xclass, the syntax would be X X`09$ JOBLOG/RETRIEVE/CLASS=CS105 X XThere are no spaces in the class specification. X XSince a user can only retrieve log files that were "mailed" specifically Xto him/her, the problem of retrieving log files for another instructor's XCS 105 class is avoided. X XMailed log files will be deleted after a certain length of time, currently Xten days. After seven days, both the sender and the recipient will be warne Vd Xthat the log file hasn't been picked up and that it will be deleted. X XWhile running JOBLOG it is best to avoid doing full-screen applications such Xas editing. Sometimes they are not logged correctly, and such files also Xcause problems if they are printed. X XIt is also not possible to run JOBLOG while in JOBLOG. X XFor more information about JOBLOG, enter: X X $ HELP JOBLOG $ CALL UNPACK DOC.TXT;1 189931992 $ create 'f' X/*************************************************************************** V**** X**************************************************************************** V**** X X Installation: Western Michigan University Academic Computing Services X X System:`09JOBLOG X `20 X Program:`09JOBLOG X X Version=01`09Level=00`0907/02/90`09Leonard J. Peirce X X Purpose:`09JOBLOG will capture the output for a terminal session, place X`09`09it in a file, and, upon exit, give the option of printing it, X`09`09saving it, storing the log file in a secure area and sending X`09`09notification of it to another user, or deleting it. X X`09`09There are essentially two types of JOBLOG log files: VERIFIED X`09`09and UNVERIFIED. VERIFIED log files are guaranteed to be un- X`09`09touched by the person who created them. Since the log files X`09`09themselves are never accessible to the user while running X`09`09JOBLOG, the only opportunity for modification is if logging X`09`09is disabled while in JOBLOG. While this is often a nice X`09`09feature, it immediately makes the log file UNVERIFIED. X X`09`09The difference between VERIFIED and UNVERIFIED log files be- X`09`09comes important for printed and mailed log files, especially X`09`09for class assignments and such.`20 X X Version=01`09Level=01`0912/03/90`09Leonard J. Peirce X X Purpose:`09Fix /SKIM so that it actually works. X X`09`09Add a second exit handler that is called in quit() so that X`09`09if a user hangs up or disconnects their log file is deleted. X X`09`09Make sure to override the user's default protection for the X`09`09log file so that it can be deleted. X X`09`09Make sure that the log file is deleted on any ungraceful exit. X X`09`09Clean up some comments that were misleading or just plain X`09`09wrong. X X Version=01`09Level=02`0901/18/91`09Leonard J. Peirce X X Purpose:`09Quit using mailboxes to detect input on the TTY and PTY. X`09`09No more dropped reads on the TTY and a big win in performance. X X`09`09Fix warn() so that it will actually warn both the sender X`09`09and the recipient. Add the delete date to the mail message X`09`09sent to the sender and recipient. X X`09`09Add PHOTO_MODE so that users don't have to go through all of X`09`09the hassle of INSTALLing JOBLOG, creating logicals/directories, X`09`09etc., if all they want to do is log files. The log file is X`09`09called JOBLOG.LOG and is created in the user's current dir- X`09`09ectory. X X`09`09Put in a fix for SMP. This was borrowed from the SMP version X`09`09of PHOTO. X X`09`09Remove the code for exact logging, leaving comments in place X`09`09in case some brave soul decides to implement it. X X Arguments:`09See JOBLOG.HLP X X External variables: X X`09`09joblog_cld`09`09.CLD file for parsing X`09`09JLG_*`09`09`09for JOBLOGMSG.MSG X`09`09LIB$M_CLI_CTRLY`09`09for trapping control-Y X X WMU external functions: X X Defined:`09none X X Called:`09cat,strins,strlu,strmcpy,str_post_trim,str_pref_trim X X Files accessed:`09files in staging area and secure area X X Logical names accessed: X X Return codes:`09none X X Compiling instructions:`09See DESCRIP.MMS X X Linking instructions:`09See DESCRIP.MMS X X Other information:`09Privileges needed when INSTALLed: SYSPRV, PHY_IO, X`09`09`09CMKRNL. X X`09`09`09The PTY drivers (PY and TW) must be installed for X`09`09`09this program to work. X X`09`09`09This program borrows some code and ideas from PHOTO, X`09`09`09written by Asbed Bedrossian at the University of X`09`09`09Southern California. X X`09`09`09Thanks to FK for his immeasurable patience and X`09`09`09knowledge. X X**************************************************************************** V**** X**************************************************************************** V***/ X X/*************************************************************************** V***/ X/* V `20 V */ X/* # I N C L U D E F I L E S V */ X/* V `20 V */ X/*************************************************************************** V***/ X X#include file X#include stat X#include descrip X#include rms X#include rmsdef X#include ssdef X#include climsgdef X#include jpidef X#include ttdef X#include tt2def X#include prvdef X#include prcdef X#include dvidef X#include iodef X#include uaidef X#include lnmdef X#include libdef X#include syidef X#include ctype X#include time X#include sjcdef X X/*************************************************************************** V***/ X/* V `20 V */ X/* # D E F I N E S V */ X/* V `20 V */ X/*************************************************************************** V***/ X X#define NULL (void *) 0 X#define DEFAULT_PRINT_QUEUE "SYS$PRINT" X X#define STATUS_STR_MAX 255`09`09/* max. length of SNDJBC status mess. */ X#define DATE_STR_MAX 10`09`09`09/* max. length of date string we use */ X#define COMMAND_MAX 512`09`09`09/* max. length of command line`09 */ X#define ACCOUNT_MAX 12`09`09`09/* max. length of account string */ X#define LOGFILE_MAX 255`09`09`09/* max. length of filename`09 */ X#define PTYNAME_MAX 15`09`09`09/* max. length of PTY device name */ X#define PNAME_MAX 15`09`09`09/* max. length of a process name */ X#define USERNAME_MAX 15`09`09`09/* max. length of a username`09 */ X#define QUEUE_MAX 39 X#define CARRIAGE_RETURN 13 X#define LINE_FEED 10 X#define CONTROL_Z 26 X#define TOGGLE_LOG 28`09`09`09/* toggle logging`09`09 */ X#define TOGGLE_STAMP 30`09`09`09/* toggle time stamping`09`09 */ X#define TIME_MAX 23`09`09`09/* for full time string`09`09 */ X#define MAX_REC 1024`09`09`09/* max. length of log file record */ X#define PY_BUF_MAX 100`09`09`09/* max. length of read from PY device */ X#define PY_WRITE_MAX 16`09`09`09/* max. we should write to PTY`09 */ X#define TTY_BUF_MAX 512`09`09`09/* max. length of read from TTY`09 */ X#define MBX_BUF_MAX 40 X#define IN_BUF_MAX 4096`09`09`09/* max. length of read/write to file */ X#define TEMPBUF_MAX 512`09`09`09/* for formatting messages`09 */ X#define DEVICE_NAME_MAX 32 X#define BUFSIZ 512 X#define ON 1 X#define OFF 0 X#define TRUE 1 X#define FALSE 0 X#define CANCEL 3 X#define NO_INPUT 2 X#define SUCCESS 1 X#define FAILURE 0 X#define SECONDS_IN_DAY 86400 X#define INT_STR_MAX 15 X X/*************************************************************************** V***/ X/* V `20 V */ X/* S T R U C T U R E S , U N I O N S , T Y P E D E F S V */ X/* V `20 V */ X/*************************************************************************** V***/ X Xtypedef`09 unsigned int UINT;`09`09/* for unsigned integers`09 */ Xtypedef`09 unsigned long ULONG;`09`09/* for unsigned long integers`09 V */ Xtypedef`09 unsigned short USHORT;`09/* for unsigned short integers`09 V */ Xtypedef`09 unsigned char UCHAR;`09`09/* for unsigned characters`09 */ Xtypedef`09 unsigned char TINY;`09`09/* more descriptive for using un- V */ X`09`09`09`09`09/* characters as integers`09 */ X Xtypedef`09 struct`09 ITM_TYPE `7B X`09 USHORT`09 buf_len, X`09`09 itm_code; X`09 char `09 *buf_addr; X`09 USHORT`09 *ret_len; X`7D ITM_LST; X Xtypedef`09 struct`09 `7B`09`09`09/* run-time and computed flags`09 */ X`09 UCHAR`09 expert,`09`09/* no welcome message`09`09 */ X`09`09 exact,`09`09/* do exact logging?`09`09 */ X`09`09 delete,`09`09/* deleting a log file?`09`09 */ X`09`09 time_stamp,`09`09/* start with time-stamping enabled? */ X`09`09 retrieve,`09`09/* someone retrieving a log file? */ X`09`09 skim,`09`09`09/* set if /SKIMming old logs`09 */ X`09`09 mail,`09`09`09/* set if /MAILing a log file`09 */ X`09`09 save,`09`09`09/* set if /SAVEing a log file`09 */ X`09`09 print;`09`09/* set if /PRINT specified`09 */ X`7D ARG_DEF; X Xtypedef`09 struct`09 `7B`09`09`09/* program flags`09`09 */ X`09 UCHAR`09 hangups,`09`09/* hangups enabled?`09`09 */ X`09`09 logging,`09`09/* are we logging?`09`09 */ X`09`09 time_stamp,`09`09/* are we time-stamping?`09 */ X`09`09 verify,`09`09/* are we still verified?`09 */ X`09`09 command;`09`09/* set if input from TTY is a command */ X`09 char`09 filename`5BNAM$C_MAXRSS+1`5D; /* logfile name without dev/dir. V */ X`7D FLAG_DEF; X Xtypedef`09 struct`09 SENSE_TYPE `7B`09`09/* SENSEMODE structure for termina Vls */ X`09 UCHAR`09 class,`09`09/* device class`09`09`09 */ X`09`09 type;`09`09`09/* device type`09`09`09 */ X`09 USHORT`09 buf_size;`09`09/* buffer size`09`09`09 */ X`09 UINT`09 characts : 24;`09/* terminal characteristics`09 */ X`09 UCHAR`09 page_len;`09`09/* page length`09`09`09 */ X`09 ULONG`09 ext_char;`09`09/* extended characteristics`09 */ X`7D SENS_DEF; X Xtypedef`09 struct`09 SET_TYPE `7B`09`09/* SETMODE structure for terminals V */ X`09 UCHAR`09 class,`09`09/* device class`09`09`09 */ X`09`09 type;`09`09`09/* device type`09`09`09 */ X`09 USHORT`09 page_wid;`09`09/* page width for terminals`09 */ Xunion`09 ttdef`09 characts;`09`09/* terminal characteristics`09 */ Xunion`09 tt2def`09 ext_char;`09`09/* extended characteristics`09 */ X`7D SET_DEF; X Xtypedef`09 struct`09 IO2_TYPE `7B`09`09/* SENSEMODE I/O status block`09 V */ X`09 USHORT`09 status;`09`09/* status value`09`09`09 */ X`09 UCHAR`09 t_speed,`09`09/* transmit baud rate`09`09 */ X`09`09 r_speed,`09`09/* receive baud rate`09`09 */ X`09`09 cr_fill,`09`09/* CR fill count`09`09 */ X`09`09 lf_fill,`09`09/* LF fill count`09`09 */ X`09`09 parity,`09`09/* parity flags`09`09`09 */ X`09`09 dummy;`09`09/* dummy padding variable`09 */ X`7D IO2_DEF; X Xtypedef`09 struct`09 ITEM_TYPE `7B`09`09/* message item type`09`09 */ X`09 short`09 size,`09`09`09/* item size`09`09`09 */ X`09`09 code;`09`09`09/* item code`09`09`09 */ X`09 char`09 *ptr;`09`09`09/* variable-length message`09 */ X`7D ITEM_DEF; X Xtypedef`09 struct`09 IOSB_TYPE `7B`09 `09/* I/O status block type`09 V */ X`09 USHORT`09 status,`09`09/* completion status`09`09 */ X`09 `09 count,`09`09/* byte count`09`09`09 */ X`09`09 terminator,`09`09/* terminator character`09`09 */ X`09`09 term_count;`09`09/* number of characters in terminator */ X`7D IOSB_DEF; X Xtypedef`09 struct`09 `7B`09`09`09/* exit handler block`09`09 */ X`09 ULONG`09 forward_link;`09`09/* used by VMS`09`09`09 */ X`09 ULONG`09 (*routine)();`09`09/* address of exit handler routine */ X`09 UCHAR`09 arg_count,`09`09/* argument count`09`09 */ X`09`09 dummy`5B3`5D;`09`09/* must be zeros!`09`09 */ X`09 ULONG`09 *condition;`09`09/* address of condition value`09 */ X`7D EXH_DEF; X Xtypedef`09 struct`09 `7B`09`09`09/* holds ASCII/longword id pairs */ X`09 char`09 *id_string;`09`09/* ASCII identifer`09`09 */ X`09 ULONG`09 id;`09`09`09/* integer identifier value`09 */ X`7D ID_DEF; X Xtypedef`09 struct`09 `7B`09`09`09/* terminator character mask`09 */ X`09 USHORT`09 size, X`09`09 unused; X`09 USHORT`09 *ptr; X`7D TERM_DEF; X X/*************************************************************************** V***/ X/* V `20 V */ X/* E X T E R N A L D E F I N I T I O N S & D E C L A R A T I O N S V */ X/* V `20 V */ X/*************************************************************************** V***/ X Xglobalref`09 joblog_cld; X Xglobalvalue`09 CLI$M_NOWAIT, X`09`09 JLG_NO_LOGICAL, X`09`09 JLG_NO_LOGFILE, X`09`09 JLG_NO_EXH, X`09`09 JLG_CANT_QUEUE, X`09`09 JLG_CANT_REQUEUE, X`09`09 JLG_CANT_WRITE, X`09`09 JLG_INUSE, X`09`09 JLG_NO_SPAWN, X`09`09 JLG_CANT_CANCEL_IO, X`09`09 JLG_CANT_DELETE, X`09`09 JLG_CANT_DASSGN, X`09`09 JLG_CANT_RESET, X`09`09 JLG_CANT_DELETE_LOG, X`09`09 JLG_CANT_PROPAGATE, X`09`09 LIB$M_CLI_CTRLY; X Xextern`09 char`09 *mktemp(), X`09`09 *cat(), X`09`09 *strmcpy(), X`09`09 *str_post_trim(), X`09`09 *str_pref_trim(); X Xextern`09 ULONG`09 LIB$ASN_WTH_MBX(), X`09`09 LIB$DISABLE_CTRL(), X`09`09 LIB$ENABLE_CTRL(), X`09`09 LIB$FIND_FILE(), X`09`09 LIB$FIND_FILE_END(), X`09`09 LIB$GET_INPUT(), X`09`09 LIB$GETJPI(), X`09`09 LIB$SPAWN(), X`09`09 LIB$STOP(), X`09`09 SYS$ASCTIM(), X`09`09 SYS$ASCTOID(), X`09`09 SYS$ASSIGN(), X`09`09 SYS$CANCEL(), X`09`09 SYS$CANEXH(), X`09`09 SYS$CLOSE(), X`09`09 SYS$CONNECT(), X`09`09 SYS$DASSGN(), X`09`09 SYS$DCLEXH(), X`09`09 SYS$EXIT(), X`09`09 SYS$FAO(), X`09`09 SYS$FINISH_RDB(), X`09`09 SYS$FIND_HELD(), X`09`09 SYS$GETDVI(), X`09`09 SYS$GETUAI(), X`09`09 SYS$QIO(), X`09`09 SYS$QIOW(), X`09`09 SYS$OPEN(), X`09`09 SYS$PUT(), X`09`09 SYS$READ(), X`09`09 SYS$SETPRV(), X`09`09 SYS$TRNLNM(), X`09`09 SYS$WRITE(); X Xextern`09 int`09 delete(); X Xextern`09 void`09 strlu(); X X/*************************************************************************** V***/ X/* V `20 V */ X/* S T A T I C D E F I N I T I O N S & D E C L A R A T I O N S V */ X/* V `20 V */ X/*************************************************************************** V***/ X Xstatic`09 ULONG`09 write_tt(short,char *,ULONG), X`09`09 get_file(char *,char *,struct FAB *,struct RAB *, X`09`09`09 struct XABPRO *,ARG_DEF *,FLAG_DEF *), X`09`09 copy_file(char *,char *), X`09`09 print_log(char *,USHORT,UCHAR), X`09`09 retrieve_log(char *,ARG_DEF *,USHORT *), X`09`09 delete_mlog(char *,USHORT *), X`09`09 class_retrieve(char *,char *), X`09`09 user_retrieve(char *,char *), X`09`09 ctrlc_trap(void), X`09`09 ctrly_trap(USHORT), X`09`09 write_py(short,char *,ULONG,IOSB_DEF *), X`09`09 save_log(char *,USHORT), X`09`09 my_gets(USHORT,char *,char *,USHORT *,USHORT), X`09`09 mail_log(char *,char *,USHORT,UCHAR), X`09`09 tt_r_efn, X`09`09 py_efn, X`09`09 wait_efn; X Xstatic`09 long`09 bintim`5B2`5D = `7B-5*10*100*100,-1`7D; X Xstatic`09 USHORT`09 py_chan,`09`09/* channel to PTY control device */ X`09`09 tt_chan,`09`09/* channel to TTY`09`09 */ X`09`09 py_mbx_chan,`09`09/* channel to PTY mailbox`09 */ X`09`09 disp_failed = FALSE,`09/* set if disposition of log fails */ X`09`09 clean_exit = FALSE,`09/* set if good exit of subprocess */ X`09`09 term_mask`5B8`5D = `7B0,0,0,0,0,0,0,0`7D, X`09`09 valid_recip(char *), X`09`09 tw_chan;`09`09/* channel for TWA device`09 */ X Xstatic`09 void`09 get_args(ARG_DEF *), X`09`09 get_channels(USHORT *,USHORT *,USHORT *), X`09`09 py_ast(void), X`09`09 log_session(USHORT,USHORT,USHORT), X`09`09 write_log(char *,USHORT,struct RAB *,FLAG_DEF *), X`09`09 ask_disposition(char *,char *,FLAG_DEF *,ARG_DEF *), X`09`09 welcome(ARG_DEF *), X`09`09 ctrlc_ast(void), X`09`09 ctrly_ast(void), X`09`09 skim(char *), X`09`09 squeeze_str(register char *), X`09`09 quit(void), X`09`09 quit2(void), X`09`09 spawn(char *,ULONG *,union prvdef *), X`09`09 parse_filename(char *,char *,char *,USHORT *), X`09`09 warn(char *,UINT,int,int,int), X`09`09 dev_chg_ast(void), X`09`09 get_logicals(char *,char *), X`09`09 my_puts(char *), X`09`09 joblog_check(void), X`09`09 xon_ast(void), X`09`09 xoff_ast(void), X`09`09 kill_log(void), X`09`09 py_mbx_ast(void); X `20 Xstatic`09 char`09 twname`5BPTYNAME_MAX+1`5D, /* name of control device`09 V */ X`09`09 stamp_buf`5BTIME_MAX+3`5D, /* for holding time stamp string */ X`09`09 logfile`5BNAM$C_MAXRSS`5D, /* log file name`09`09 */ X`09`09 log_dir`5BNAM$C_MAXRSS`5D, /* where log files are created`09 */ X`09`09 stage_dir`5BNAM$C_MAXRSS`5D, /* where mailed log files live */ X`09`09 py_buf`5BPY_BUF_MAX+1`5D, /* buffer for reading from PTY`09 */ X`09`09 tt_buf`5BTTY_BUF_MAX+1`5D, X`09`09 py_mbx_buf`5BMBX_BUF_MAX+1`5D, X`09`09 *get_stamp(char *); X Xstatic`09 IOSB_DEF py_read_iosb,`09`09/* read I/O status block for PTY V */ X`09`09 tt_read_iosb,`09`09/* read I/O status block for TTY */ X`09`09 py_write_iosb,`09/* write I/O status block for PTY */ X`09`09 tt_write_iosb,`09/* write I/O status block for TTY */ X`09`09 py_mbx_iosb,`09`09/* read I/O status block for PTY mbx */ X`09`09 py_line_iosb,`09`09/* I/O status block for device change */ X`09`09 py_xoff_iosb; X Xstatic`09 SENS_DEF tty_save_char;`09/* for saving TTY characteristics */ X Xstatic`09 TERM_DEF term_block = `7B32,0,&term_mask`7D; X Xstatic`09 struct`09 FAB`09 log_fab; X Xstatic`09 struct`09 RAB`09 log_rab; X Xstatic`09 struct`09 XABPRO log_xabpro; X Xstatic`09 FLAG_DEF flags;`09`09/* global flags`09`09`09 */ X Xstatic`09 ARG_DEF args;`09`09`09/* run-time arguments`09`09 */ X Xstatic $DESCRIPTOR(py_d,"PYA0:"); Xstatic $DESCRIPTOR(tt_d,"TT:"); Xstatic $DESCRIPTOR(tw_d,twname); Xstatic $DESCRIPTOR(mess_d,""); X`0C X/*************************************************************************** V***/ X/* V `20 V */ X/* M A I N P R O C E S S I N G V */ X/* V `20 V */ X/*************************************************************************** V***/ X Xmain() X X`7B`09/*** main ***/ `20 X`09`09`09`09`09/******** LOCAL VARIABLES ********/ X`09 ULONG`09 status,`09`09/* return code status holder`09 */ X`09`09 subproc_pid;`09`09/* PID of spawned subprocess`09 */ X `09 EXH_DEF exh_blk = `7B0L,quit,0,0,0,0,&status`7D; Xstatic`09 union`09 prvdef _align(longword) oldprivs; X X#ifndef PHOTO_MODE X X get_args(&args); `09`09`09/* get run-time arguments`09 */ X X /* get logicals for the log and staging directories */ X X get_logicals(log_dir,stage_dir); X X#endif X X if(args.retrieve)`09`09`09/* someone retrieving a logfile? */ X retrieve_log(stage_dir,&args,&tt_chan); X else if(args.delete) X delete_mlog(stage_dir,&tt_chan);`09/* deleting a mailed logfile?`09 V */ X else if(args.skim) X skim(stage_dir);`09`09`09/* skim old JOBLOG files`09 */ X else X `7B X joblog_check();`09`09`09/* don't let user run JOBLOG twice */ X X status = LIB$GET_EF(&tt_r_efn); X X if(!(status & SS$_NORMAL)) X`09 LIB$STOP(status); X X status = LIB$GET_EF(&wait_efn); X X if(!(status & SS$_NORMAL)) X`09 LIB$STOP(status); X X status = LIB$GET_EF(&py_efn); X X if(!(status & SS$_NORMAL)) X`09 LIB$STOP(status); X X /* someone is actually logging a session here */ X X flags.verify = TRUE;`09`09/* assume we are verified to start */ X flags.time_stamp = args.time_stamp; X X /* open the log file */ X X status = get_file(logfile,log_dir,&log_fab,&log_rab,&log_xabpro,&args, X`09`09`09&flags); X X if(status != RMS$_NORMAL) X`09 LIB$STOP(JLG_NO_LOGFILE);`09/* major problems here`09`09 */ X X /* set up channels to everything we will need */ X X get_channels(&tt_chan,&py_chan,&py_mbx_chan); X X /* write welcome message */ X X welcome(&args); X X /* declare an exit handler */ X X status = SYS$DCLEXH(&exh_blk); X X if(!(status & SS$_NORMAL)) X `7B X`09 kill_log(); X`09 LIB$STOP(JLG_NO_EXH); X `7D X X /* spawn a subprocess that the PTY will use */ X X spawn(twname,&subproc_pid,&oldprivs); X X flags.logging = TRUE; `09`09/* start out by logging stuff`09 */ X flags.command = FALSE; X X /* log the session */ X X log_session(py_chan,tt_chan,py_mbx_chan); X `7D X X`7D`09/*** main ***/ X`0C X/*************************************************************************** V**** X**************************************************************************** V**** X X Function:`09get_args X X Purpose:`09Get run-time arguments and store in structure. X X Formal Parameters: X X`09Name`09`09`09Description X`09----`09`09`09----------- X`09args`09`09`09command-line argument flags X X Global variables: X X`09Name`09`09`09Examine/Modify/Use/Read/Write X`09----`09`09`09----------------------------- X`09none X X Return Codes: X X`09Code`09`09`09Reason X`09----`09`09`09------ X`09none X X**************************************************************************** V**** X**************************************************************************** V***/ X Xstatic void get_args(ARG_DEF *args) X X`7B`09/*** get_args ***/ X`09 `09`09`09`09/******** LOCAL VARIABLES ********/ X`09 ULONG`09 status;`09`09/* return code status holder`09 */ X`09 USHORT`09 length;`09`09/* length of command line`09 */ Xstatic`09 char`09 buffer`5BBUFSIZ`5D,`09/* for holding values that are pars Ved */ X`09`09 command`5BCOMMAND_MAX+1`5D; /* for building a command to parse */ +-+-+-+-+-+-+-+- END OF PART 1 +-+-+-+-+-+-+-+-