[comp.os.vms] USC PHOTO for new PTYs 2/2

KVC@BUSTER.NRC.COM (Kevin Carosso) (06/22/88)

+-+-+-+ Beginning of part 2 +-+-+-+
X    zrab.rab$l_rop= RAB$M_WBH;
X}
X
X
X
X
X
X
X
X
X
Xget_tt_info()
X{
X    $DESCRIPTOR(d_tt, "SYS$COMMAND");
X                   /* Get a channel & mailbox of terminal */
X    check(LIB$ASN_WTH_MBX(&d_tt,&mbsiz,&maxsiz,&tt_chn,&tt_mb_chn));
X                   /* Get the terminal characteristics. */
X    check(SYS$QIOW(0,tt_chn,IO$_SENSEMODE,0,0,0,&tt_chr,ttchrlen,0,0,0,0));
X    tt_sav_chr= tt_chr;
X    tt_chr.ttchr|= TT$M_NOECHO;           /* term will be Noecho */
X    tt_chr.ttchr&= ~TT$M_HOSTSYNC & ~TT$M_TTSYNC;   /* it will have ^S */
X    tt_chr.xchar|= TT2$M_PASTHRU;           /* it will be PASTRHU */
X    check(SYS$QIOW(0,tt_chn,IO$_SETMODE,0,0,0,&tt_chr,ttchrlen,0,0,0,0));
X}
X
X
X
X
X
X
X
Xfix_a_tw()                   /* Set up a Pseudo term */
X{
X    int efn=1, dev_depend, tw_chn;
X    struct CHARBLK tw_chr;
X    struct IOSBBLK iosb;
X    struct DVIBLK  dvi_stuff = {4, DVI$_DEVDEPEND, &dev_depend, 0, 0};
X
X
X    $DESCRIPTOR(d_pynam,"PYA0:");           /* Template. */
X    $DESCRIPTOR(d_finaltw, &finaltw);
X                       /* Assign a mailbox to PYA */
X    check(LIB$ASN_WTH_MBX(&d_pynam,&mbsiz,&maxsiz,&py_chn,&py_mb_chn));
X/*
X * Use $GETDVI to get the device dependent characteristics, which
X * contains the associated terminal device's unit number.
X */
X    check(SYS$GETDVI(0,py_chn,0,&dvi_stuff,&iosb,0,0,0));
X    check(iosb.stats);
X    sprintf(&finaltw,"TWA%d:",dev_depend);
X    tw_chr= tt_sav_chr;
X    tw_chr.xchar|= TT2$M_HANGUP;
X    d_finaltw.dsc$w_length= strlen(&finaltw);
X    check(SYS$ASSIGN(&d_finaltw,&tw_chn,0,0)); /* Get a channel on this TWA */
X                       /* Make it look like user's real terminal */
X    st = SYS$QIOW(0,tw_chn,IO$_SETCHAR,0,0,0,&tw_chr,ttchrlen,0,0,0,0);
X    if (st == SS$_NOPRIV)
V`009printf ("WARNING -- PHY_IO privilege required to propagate terminal charact
Xeristics!\n");
X    else
X`009check(st);
X    check(SYS$DASSGN(tw_chn));     /* We don't need it. only the mailbox */
X                                   /* in fact keeping it kills us. */
X}
X
X
X
X
X
X
X
X
X
Xpost_reads()                   /* This sets up ASTs */
X{
X                       /* Read AST on Pseudo-term */
X    check(SYS$QIO(0,py_mb_chn,IO$_READVBLK,&miosb,&tw_srv,0,
X                       &py_mb,mbsiz,0,0,0,0));
X                       /* Read AST on real term */
X    check(SYS$QIO(0,tt_mb_chn,IO$_READVBLK,&tiosb,&tt_srv,0,
X                       &tt_mb,mbsiz,0,0,0,0));
X}
X
X
X
X
X
X
X
X
X
Xbegin_session()
X{
X    int j;
X
X    for(;;) {          /* Read/write forever loop */
X                       /* Read the pseudo-term dry */
X        check(SYS$QIOW(0,py_chn,IO$_READVBLK,&piosb,0,0,
X                                    &twline,linesz,0,0,0,0));
X        check(piosb.stats);             /* everything fine? */
X        j= piosb.tmoff + piosb.tmsiz;   /* How much stuff did we read? */
X                       /* Write the stuff to the terminal */
X        check(SYS$QIO(1,tt_chn,IO$_WRITEVBLK,&tiosb,0,0,&twline,j,0,0,0,0));
V        check(SYS$WAITFR(1));           /* for some reason QIOW does not work *
X/
X        if (log) {
X            log_line(j);               /* If we're looging, log it. */
X            if ((tim) && (com)) {
X                sprintf(&time,"%s\r\n",&time);   /* Time stamp */
X                check(SYS$QIOW(0,tt_chn,IO$_WRITEVBLK,0,0,0,
X                                    &time,strlen(&time),0,0,0,0));
X                com= 0;
X            }
X        }
X    }
X}
X
X
X
X
X
X
X
X
X
Xmain(how_many,rscan)
X    int how_many;
X    char *rscan[];
X{
X    int  exit_handler[4]= {0,quit,0,&st};
X    char filnam[40];
X
X    check(SYS$DCLEXH(&exit_handler));  /* Define Exit handler (quit) */
X    if (how_many > 1)
X      strcpy(&filnam,rscan[1]);
X    else
X      strcpy(&filnam,"Photo.Log");     /* default log file if none specified */
X    get_file(filnam);                  /* Open the file */
X    get_tt_info();                     /* Get terminal channel & info */
X    fix_a_tw();                        /* Set a pseudo terminal by TT info */
X    check(SYS$CANCEL(py_chn));         /* Don't need this Half of pseudo-ter */
X    check(low_lib_spawn(&finaltw,&pid));   /* Spawn a subprocess. */
X    post_reads();
X    enable_hangups= 1;
X    puts ("Begin PHOTO subprocess");
X    begin_session();
X}
$ GOSUB UNPACK_FILE
$ FILE_IS = "PHOTO.CLD"
$ CHECKSUM_IS = 1040204513
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
Xdefine verb PHOTO
X`009image sys$system:photo
X`009parameter p1 value(type=$rest_of_line)
X
X`009`009
$ GOSUB UNPACK_FILE
$ FILE_IS = "PHOTO.HLP"
$ CHECKSUM_IS = 85935070
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
X1 Photo
X
X!********************************************************
X
X!*                                                      *  
X
X!*                                                      *  
X
X!*                      Photo                           *  
X
X!*                                                      *  
X
X!*                                                      *  
X
X!********************************************************
X
X
X
XPhoto copies all of the Input/Output (IO) that  appears  on  the
X
Xterminal  to  a  file.   It  is  useful  for turning in homework
X
Xassignments, which do most of their IO to the terminal.
X
X
X
XFormat:
X
X
X
X           $ PHOTO [FILENAME.EXT]
X
X
X
XThis starts recording, and creates a file called FILENAME.EXT in
X
Xthe  user's  current directory.  If a filename is not specified,
X
Xthe  default  filename  is  PHOTO.LOG,  in  the  user's  current
X
Xdirectory.  To end PHOTO, either LOGOUT or POP.
X
X2 Author
X
XPhoto was written by Asbed Bedrossian.   The  program  uses  the
X
XPTDRIVER   PYDRIVER   combination  to  trap  terminal  IO  on  a
X
Xpseudoterminal.  The PT/PY package is  the  latest  update  from
X
XKevin Carosso (@Hughes) on the old PTYDRIVER.
X
X2 Usage
X
XPhoto is a predefined command.  The character ^\ toggles logging
X
Xto  the  photo  file.   The  character ^] toggles Time stamping.
X
XTime stamping will  appear  as  the  date  and  time  in  square
X
Xbrackets after every command the user types on the terminal.
X
$ GOSUB UNPACK_FILE
$ FILE_IS = "PHOTO.README"
$ CHECKSUM_IS = 189871340
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
X  Pertinent files: PHOTO.C PHOTO.CLD PHOTO.HLP
X
X  follow compile & link instructions at the top of the PHOTO.C. Then place the
Xthe image in your local SYS$SYSTEM:. Install it with PHY_IO and then set the
XCLD verb in your DCLTABLES so users can access it. Put the HLP file through
Xthe dcl command LIBRAR/CREATE/HELP PHOTO.HLB PHOTO.HLP. Now insert the
XHLB file into your system (or local) help library. Install your drivers
Xand there you go.
X Let me know if you have problems.
X
X_________________________________________________________________________
XAsbed Bedrossian, University Computing Services, U of Southern California
X  ARPA: asbed@oberon.usc.edu              BITNET: asbed@uscvaxq
X  UUCP: {sdcrdcf, cit-vax}!oberon!asbed   PHONE: (213) 743-4266
$ GOSUB UNPACK_FILE
$ FILE_IS = "PHOTOMSG.MSG"
$ CHECKSUM_IS = 1701455525
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
X.title          error messages for PHOTO
X.facility       PHOTO,1 /prefix=PHOTO_
X.severity       FATAL
XINUSE           <You are already in a PHOTO session>
X.end
$ GOSUB UNPACK_FILE
$ EXIT
-+-+-+-+-+ End of part 2 +-+-+-+-+-