==========================start of makefile.================================== opcom_catcher.exe : opcom_catcher.obj poke_pcb.obj link opcom_catcher,poke_pcb,slib:vaxcrtl/lib opcom_catcher.obj : opcom_catcher.c cc/deb opcom_catcher poke_pcb.obj : poke_pcb.mar mac/deb poke_pcb ===========================start of opcom_catcher.c=========================== /* * OPCOM catcher */ /* * include files */ #include iodef /* definitions for the function codes */ #include descrip /* definitions for the descriptor structure */ #include ttdef /* terminal characteristics */ #include tt2def /* extended terminal characteristics */ #include opcdef /* sndopr message fields */ #include ctype /* character type */ #define global /* dummy */ #define routine /* dummy */ #define Try(f) { int sts; if (((sts = (f)) & 1) == 0) return sts; } struct IOSB { /* structure for iosb */ unsigned short status; unsigned short len; unsigned short terminator; unsigned short terminator_size; }; static readonly $DESCRIPTOR( device_name, "LTA4444:" ); static readonly $DESCRIPTOR( mailbox_name, "mailbox" ); extern poke_pcb(); extern poke_jib(); main(argc, argv) char *argv[]; { char inbuf[256]; struct dsc$descriptor_s outbuff = {0, DSC$K_DTYPE_T, DSC$K_CLASS_S, &inbuf[21]}; struct IOSB iosb; int chan; int mbchan; int sts; int ef; char *arglist[2] = { 1,&device_name }; int characteristics_buff[3]; /* three longwords for terminal * characteristics */ Try(lib$get_ef(&ef)); Try(SYS$CMKRNL(&poke_jib,&arglist)); Try(SYS$ALLOC(&device_name,0, 0, 0, 0)); Try(SYS$CREMBX(0,&mbchan,0,0,0,0,&mailbox_name)); /* assigns channel to terminal, if not successful, then exit */ Try(SYS$ASSIGN(&device_name,&chan,0, &mailbox_name)); /* * Get the current termial characteristics */ Try(SYS$QIOW(ef, (int)chan,IO$_SENSEMODE, &iosb, 0, 0, &characteristics_buff, sizeof(characteristics_buff), 0, 0, 0, 0)); /* * Allow broadcast */ characteristics_buff[1] &= ~(TT$M_NOBRDCST); /* * Set brdcstbx */ characteristics_buff[2] |= TT2$M_BRDCSTMBX; /* * Set the new device characteristics */ Try(SYS$QIOW(ef, (int)chan,IO$_SETMODE, &iosb, 0, 0, &characteristics_buff, sizeof(characteristics_buff), 0, 0, 0, 0)); Try(SYS$CMKRNL(&poke_pcb,&arglist)); Try(enable_opcom(&device_name)); while(1) { Try(SYS$QIOW(ef, (int)mbchan,IO$_READVBLK, &iosb, 0,0,inbuf,sizeof(inbuf), 0, 0, 0, 0)); if(iosb.len > 22) { outbuff.dsc$w_length = iosb.len - 22; /* * Here is our bloody OPCOM message * Anything being able to filter the OPCOM message could be inserted here * */ Try(lib$put_output(&outbuff)); } } } routine enable_opcom( device_name ) struct dsc$descriptor_s *device_name; { struct OPC buffer; struct dsc$descriptor_s oprdesc = {0, DSC$K_DTYPE_T, DSC$K_CLASS_S, &buffer}; int dec; int len; int unumber; char *ptr; ptr = device_name->dsc$a_pointer + device_name->dsc$w_length - 1; if (*ptr-- != ':') ptr++; dec = 1; unumber = 0; while(isdigit(*ptr)) { unumber += (*ptr-- - '0') * dec; dec *= 10; } buffer.opc$b_ms_type = OPC$_RQ_TERME; buffer.opc$b_ms_enab = 1; buffer.opc$l_ms_rqstid = OPC$M_NM_PRINT; buffer.opc$w_ms_ounit = unumber; len = ptr - device_name->dsc$a_pointer + 1; buffer.opc$t_ms_oname[0] = len; strncpy(&buffer.opc$t_ms_oname[1],device_name->dsc$a_pointer,len); oprdesc.dsc$w_length = (&buffer.opc$t_ms_oname[0] - &buffer.opc$b_ms_type) + len + 1; return (sys$sndopr(&oprdesc,0)); } ===============================start of poke_pcb.mar========================== .title poke_pcb .library "sys$share:lib.mlb" $pcbdef $jibdef .psect code .entry poke_pcb,^m movl 4(ap),r0 movzbl (r0),r1 movl 4(r0),r0 movb r1, pcb$t_terminal(r4) movc3 r1, (r0), pcb$t_terminal+1(r4) movl #ss$_normal, r0 ret .entry poke_jib,^m movl pcb$l_jib(r4),r0 MOVC5 #0,#0,#^A/ /,#JIB$S_USERNAME-1,jib$t_username+1(r0) movl #ss$_normal, r0 ret .end ==========================start of run_opcom.com============================== $!+ $! This procedure must be edited to reflect the devices/directories $! for FOO on your system. $!- $ run opcom_catcher /detach/dump/buffer=20000/proc="OPCOM catcher" - /page_file=10000 - /priv=all - /input=nl: - /output=opcom_catcher.log - /error=opcom_catcher.log/uic=[1,4] ==========================start of make_lat4444.com=========================== $!+ $! Command file to create the terminal port to which FOO will attach $! its mailbox. This procedure need be run only once after the system $! has booted. $! $! If you choose a different lat terminal, FOO.MAR must be modified $! to reflect the different choice. $!+ $ Run Sys$System:latcp create port lta4444:/application