MODULE USRLOG= !Write a user log file on request BEGIN ! !Conditionals ! COMPILETIME FTERTEXT=1; !Put text at end of user's log file so he can read it ! !Table of Contents ! FORWARD ROUTINE USRLOG, USRLHANDLE; ! ! LIBRARY & REQUIRE files ! REQUIRE 'INTR.REQ'; LIBRARY 'DAPLIB'; THIS_IS[USRL] VERSION[1] EDIT[2] DATE[14,AUG,78] ! ! Externals ! EXTERNAL ROUTINE FUNPARSE, WRNUMA, WRNUMF, UNWIND, ERTEXT, DAPCODE, MOVEAZ, RELEASE, WRSIXA, WRITE; ! ! Macros ! MACRO PREFIX='ULG'%; !For MESSAGE macro ! ! Literals ! LITERAL CR=%O'15', LF=%O'12'; ! ! Routines ! GLOBAL ROUTINE USRLOG(NB,CODE)= !Write a user's log file if he wants one !NB: address of NDB for request !CODE: System/NETSPL status code (1=success) (otherwise see TBL.BLI) BEGIN MAP NB: REF NDB; EXTERNAL ROUTINE WRDTM; BIND LOGFB=.NB[NDB$LOG_FB]: FILE_BLOCK; BIND FB=.NB[NDB$FB]: FILE_BLOCK; LOCAL LOGBUF: VECTOR[CH$ALLOCATION(300)], PTR; ESTABLISH(USRLHANDLE,NB); IF LOGFB EQL 0 THEN RETURN; !No log file was wanted LOGFB[FILE$ALIAS]=.FB[FILE$ALIAS]; !Copy PPN of requestor LOGFB[FILE$GODLY]=1; !Get no access at all otherwise OPEN_A(LOGFB); !Append to the file %( Format of user log entries is: NODEID TR 01 040060 05-APR-78 08:24 REMOTE_DEVICE:REMOTE-FILE.REMOTE-EXTENSION LOCAL.FIL[10,777] NODEID("NODEID") is the node name of the remote system DIRECTION ("TR") can be DISPOSITION ("01") can be TR for TRANSMIT 00 for success RT for RETRIEVE 01 for remote error RE for RENAME 02 for local error DE for DELETE 10 for abort by oper DAPCODE ("040060") will be 00000 unless there was an error in which case it is: 2 digits of DAP MACCODE, followed by 4 digits of DAP MICCODE. Refer to the DAP documentation or NETCOM.BLI for details. The next 2 lines are: The remote filespec The local filespec Please note that I did not design this format!!!!!!!!! /AWN )% PTR=CH$PTR(LOGBUF); !Init pointer !Write Nodeid followed by 1 blank WRSIXA(.NB[NDB$NODEID],PTR); CH$WCHAR_A(%C' ',PTR); !Now write the operation followed by a blank SELECT .NB[NDB$ACCFUNC] OF SET [ACC$CREATE]: (CH$WCHAR_A(%C'T',PTR);CH$WCHAR_A(%C'R',PTR)); [ACC$OPEN]: (CH$WCHAR_A(%C'R',PTR);CH$WCHAR_A(%C'T',PTR)); [ACC$RENAME]: (CH$WCHAR_A(%C'R',PTR);CH$WCHAR_A(%C'E',PTR)); [ACC$ERASE]: (CH$WCHAR_A(%C'D',PTR);CH$WCHAR_A(%C'E',PTR)); TES; CH$WCHAR_A(%C' ',PTR); !Now write the disposition code followed by another blank SELECT .CODE OF SET [WIN]: (CH$WCHAR_A(%C'0',PTR);CH$WCHAR_A(%C'0',PTR)); [RMTERR TO RMTERR+%O'177777']: (CH$WCHAR_A(%C'0',PTR);CH$WCHAR_A(%C'1',PTR)); [OPRABO]: (CH$WCHAR_A(%C'1',PTR);CH$WCHAR_A(%C'0',PTR)); [OTHERWISE]: (CH$WCHAR_A(%C'0',PTR);CH$WCHAR_A(%C'2',PTR)); TES; CH$WCHAR_A(%C' ',PTR); !Now write the DAP error code if there was an error otherwise 0 PTR=(WRNUMF((IF .CODE EQL WIN THEN 0 ELSE DAPCODE(.CODE)),8,.PTR,%C'0',6)); !Do not supress leading zeroes CH$WCHAR_A(CR,PTR); CH$WCHAR_A(LF,PTR); !and a CRLF !Now write the date & time PTR=WRDTM(.PTR); CH$WCHAR_A(CR,PTR);CH$WCHAR_A(LF,PTR); !Now write the remote filespec MOVEAZ(%REF(CH$PTR(NB[NDB$REMOTEFILE])),PTR); CH$WCHAR_A(CR,PTR); CH$WCHAR_A(LF,PTR); !and a CRLF !Now write the local filespec if there is one SELECTONE .NB[NDB$ACCFUNC] OF SET [ACC$ERASE]: ; !No local filespec [ACC$RENAME]: MOVEAZ(%REF(CH$PTR(NB[NDB$REMRENAME])),PTR); !New name [OTHERWISE]: PTR=FUNPARSE(FB,.PTR); TES; CH$WCHAR_A(CR,PTR); CH$WCHAR_A(LF,PTR); !always a CRLF !Now we may write the ASCII text of the message %IF FTERTEXT %THEN MOVEAZ(%REF(CH$PTR((IF .CODE EQL WIN THEN ( SELECTONE .NB[NDB$ACCFUNC] OF SET [ACC$ERASE]: UPLIT(%ASCIZ 'Successful Delete'); [ACC$RENAME]:UPLIT(%ASCIZ 'Successful Rename'); [OTHERWISE]: UPLIT(%ASCIZ 'Successful Transfer'); TES ) ELSE ERTEXT(.CODE)))) ,PTR); !ASCII error text CH$WCHAR_A(CR,PTR);CH$WCHAR_A(LF,PTR); !CRLF %FI !Finally a NULL character to make it an ASCIZ string CH$WCHAR_A(0,PTR); !Now write it out to the file WRITE(LOGFB,%REF(CH$PTR(LOGBUF)),300,0); CLOSE(LOGFB); !Close & release RELEASE(LOGFB); WIN END; !USRLOG ROUTINE USRLHANDLE(SIGNAL_ARGS,MECH_ARGS,ENABLE_ARGS)= !Handler for USRLOG BEGIN MAP SIGNAL_ARGS: REF VECTOR, MECH_ARGS: REF VECTOR, ENABLE_ARGS: REF VECTOR; SELECT .$CODE OF SET [FILERR TO FILOPN,INERROR,OUTERROR]: BEGIN MSG('%','','Error Writing user log file '); TSTR(ERTEXT(.$CODE)); TYPE(CRLF); UNWIND(.MECH_ARGS[MA_DEPTH]+1); END; [OTHERWISE]: RETURN SS$_RESIGNAL; TES; END; !USRLHANDLE END ELUDOM