Google
 

Trailing-Edge - PDP-10 Archives - decuslib10-08 - 43,50512/terror.b36
There are no other files named terror.b36 in the archive.
MODULE TERROR(			!Error message printing routines
	IDENT='1(3) 21-Sep-79' 
	)=

BEGIN
!
!			  COPYRIGHT (c) 1978, 1978 BY
!	      DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.
!
! THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED AND  COPIED
! ONLY  IN  ACCORDANCE  WITH  THE  TERMS  OF  SUCH  LICENSE AND WITH THE
! INCLUSION OF THE ABOVE COPYRIGHT NOTICE.  THIS SOFTWARE OR  ANY  OTHER
! COPIES  THEREOF MAY NOT BE PROVIDED OR OTHERWISE MADE AVAILABLE TO ANY
! OTHER PERSON.  NO TITLE TO AND OWNERSHIP OF  THE  SOFTWARE  IS  HEREBY
! TRANSFERRED.
!
! THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE  WITHOUT  NOTICE
! AND  SHOULD  NOT  BE  CONSTRUED  AS  A COMMITMENT BY DIGITAL EQUIPMENT
! CORPORATION.
!
! DIGITAL ASSUMES NO RESPONSIBILITY FOR THE USE OR  RELIABILITY  OF  ITS
! SOFTWARE ON EQUIPMENT WHICH IS NOT SUPPLIED BY DIGITAL.
!

!++
! FACILITY:	FTS-10 NETSPL
!
! ABSTRACT:	This provides the routine TERROR, to print out error messages
!		TERROR takes same arguments as a standard condition handler,
!		i.e. TERROR(SIGNAL_ARGS,MECH_ARGS,ENABLE_ARGS)
!		ENABLE_ARGS is not used, however.
!
! ENVIRONMENT:
!
! AUTHOR:	Andrew Nourse, CREATION DATE: 21-Sep-79
!
! MODIFIED BY:
!
! 	, : VERSION
! 01	- The beginning
! 02	- Print out DAP errors as MACCODE=nn, MICCODE=nnnn if no text for msg.
! 03	- Add "Remote System Rejected Connection"
!--
!
! Table of Contents
!
FORWARD ROUTINE
TERROR,	!Type an error message (called from a condition handler)
TFBFUN,	!Type out function attempted
FBFUN,	!Fill in name of function attempted
TFB,	!Type out a filespec from a file block
TNPFX,	!Type out (NODEID#sequence_number)
NPFX,	!Build (NODEID#sequence_number) string
IOICOD;	!Get error code for IOINT conditions

!
! Library & Require declarations
!
REQUIRE 'INTR.REQ';
LIBRARY 'DAPLIB';

!
! Version info
!
THIS_IS [TERR]		VERSION [1]	EDIT [3]	DATE [21,SEP,79]

!
! Revision History
!
![3]	Add RMTREJ Remote system rejected connection
![2]	Print out DAP status codes as MACCODE & MICCODE if we don't have
!	text for them
![1]	The beginning

!
! Externals
!
EXTERNAL ROUTINE
WRNUMA,
ERTEXT,
LOGS,
WRSIXA,
MOVEAZ,
FUNPARSE;

EXTERNAL RUN: REF PROCESS_BLOCK;
EXTERNAL
	ERRUEC,		!Undefined error code
	RMTUEC;		!Undefined error code from remote system
EXTERNAL G$DBUG;

!
! Macros
!
MACRO PTR_ATEXT(ADDR)=
	BEGIN
	EXTERNAL ROUTINE MOVEAZ;
	MOVEAZ(%REF(CH$PTR(ADDR)),PTR);
	END %;
MACRO	TEXT[]=UPLIT(%ASCIZ %STRING(%REMAINING)) %;
MACRO	PTR_TEXT[]=PTR_ATEXT(TEXT(%REMAINING)) %;
MACRO	OFFLINE=.REASON<%FIELDEXPAND(INT$OFFLINE,1),1>%,
	IN_ERROR=.REASON<%FIELDEXPAND(INT$IN_ERROR,1),1>%,
	OUT_ERROR=.REASON<%FIELDEXPAND(INT$OUT_ERROR,1),1>%,
	QUOTA_EX=.REASON<%FIELDEXPAND(INT$QUOTA_EX,1),1>%,
	FULL=.REASON<%FIELDEXPAND(INT$FULL,1),1>%,
	END_OF_FILE=.REASON<%FIELDEXPAND(INT$EOF,1),1>%;

!
! Literals
!
LITERAL
	SPACE=%O'40';

!
! Routines
!

GLOBAL ROUTINE TERROR(SIGNAL_ARGS,ENABLE_ARGS,MECH_ARGS)=

BEGIN

!++
! FUNCTIONAL DESCRIPTION:
!
!	Routine to type out error messages from a condition handler
!	takes same arguments as a standard condition handler,
!	and would be typically passed te exact same ones
!	i.e. TERROR(.SIGNAL_ARGS,.MECH_ARGS,.ENABLE_ARGS)
!	ENABLE_ARGS is not used, however.
!
! FORMAL PARAMETERS:
!
!	SIGNAL_ARGS:	Addr of args to SIGNAL
!	MECH_ARGS:	Addr of args proviede by CHF
!	ENABLE_ARGS:	Addr of args provided at ENABLE time (ignored)
!
! IMPLICIT INPUTS:
!
!	NONE
!
! IMPLICIT OUTPUTS:
!
!	NONE
!
! ROUTINE VALUE:
! COMPLETION CODES:
!
!	NONE
!
! SIDE EFFECTS:
!
!	NONE
!
!--
MAP	SIGNAL_ARGS:	REF BLOCK FIELD(SA_FIELDS),
	MECH_ARGS:	REF VECTOR,
	ENABLE_ARGS:	REF VECTOR;

EXTERNAL ROUTINE
WRSIXA;

EXTERNAL RUN: REF PROCESS_BLOCK;

LOCAL	PTR,
	STR: VECTOR[CH$ALLOCATION(133)],
	FB: REF NDB,	!The file block or NDB involved in the error
	NB: REF NDB;	!The process's NDB

FB=.SIGNAL_ARGS[SA$FB];	!Assume that the file block is here

PTR=CH$PTR(STR);
PTR_ATEXT(
	 SELECT .$SEVERITY OF SET
	 [SS$_WARN]:		UPLIT(%ASCIZ %STRING( '%',PPREFIX));
	 [SS$_ERROR]:		UPLIT(%ASCIZ %STRING( '%%',PPREFIX));
	 [SS$_SEVEREERROR]:	UPLIT(%ASCIZ %STRING( '?',PPREFIX));
	 [SS$_NORMAL]:		UPLIT(%ASCIZ %STRING( '[',PPREFIX));
	 [OTHERWISE]:		UPLIT(%ASCIZ %STRING( '???',PPREFIX));
	 TES
	 );
!Check for IOINT (special case)
IF .$CODE EQL IOINT
THEN	BEGIN

	$CODE=IOICOD(.SIGNAL_ARGS[SA$REASON]); !Convert if necessary

	!Since interrupts don't put the file block in SA$FB
	FB=.SIGNAL_ARGS[SA$FILBLK];
	END;

IF FB[FILE$START] EQL .RUN[P$NDB]	!Network link error
THEN $CODE=(	SELECTONE .$CODE OF SET
		[INERROR,OUTERROR]:	RMTOFF;	!Network connect lost
		[ENDFILE]:		RMTDIS;	!Remote aborted
		[OTHERWISE]:		.$CODE;
		TES
	   );

PTR_ATEXT (
	  SELECTONE .$CODE OF SET
	  [FILERR TO FILDTB,FILOPN]:	TEXT( 'COF');
	  [OPRABO]:			TEXT( 'ABO');
	  [OPRDEF]:			TEXT( 'RQO');
	  [LNKNAV]:			TEXT( 'LNA'); !Data link not available
	  [USRABO]:			TEXT( 'ABU');
	  [CMDERR TO CMDERR+15]:	TEXT( 'CER');
	  [NODUNN]:			TEXT( 'NIN');
	  [NODERR TO NODERR+15]:	TEXT( 'NOD');
	  [TIMOUT]:			TEXT( 'TMO');
	  [RMTABO]:			TEXT( 'CBT');
	  [RMTREJ]:			TEXT( 'RJC'); !Rejected Connection
	  [RMTERR+ER$TELLOPR]:		TEXT( 'OPR');
	  [RMTERR TO RMTERR+%O'177777']:TEXT( 'RDE');
	  [INERROR]:			TEXT( 'RER');
	  [OUTERROR]:			TEXT( 'WER');
	  [RMTOFF]:			TEXT( 'NCL');
	  [EXQUOTA]:			TEXT( 'QEX');
	  [DEVFULL]:			TEXT( 'DFL');
	  [OTHERWISE]:			TEXT( 'XXX');
	  TES
	  );

IF (NB=.RUN[P$NDB]) NEQ 0 THEN	!Add (NODEID#sequence_number)
	BEGIN
	NPFX(NB[FILE$START],PTR);
	END;

CH$WCHAR_A(SPACE,PTR);

SELECT .$CODE OF SET
[FILERR TO FILDTB,FILOPN]:
	BEGIN
	EXTERNAL ROUTINE FUNPARSE,FBFUN;

	PTR_TEXT('Can''t ');

	PTR_ATEXT(
		 SELECTONE .FB[FILE$FUNCTION] OF SET
		 [_FOCLS]:		TEXT( 'Close ');
		 [_FOPRE]:		TEXT( 'Pre-allocate ');
		 [_FORED TO _FOAPP]:	TEXT( 'Open ');
		 [_FORNM]:		TEXT( 'Rename ');
		 [_FODLT]:		TEXT( 'Delete ');
		 [OTHERWISE]:		TEXT( '??UNKNOWN FUNCTION?? ');
		 TES
		 );

	PTR=FUNPARSE(FB[FILE$START],.PTR);	!to what

	SELECT .FB[FILE$FUNCTION] OF SET
	[_FORED TO _FOAPP]:	BEGIN
				PTR_TEXT('  for ');
				FBFUN(FB[FILE$START],PTR);!What kind of access
				CH$WCHAR_A(SPACE,PTR);
				END;
	TES;
	END;
[INERROR,OUTERROR,EXQUOTA,DEVFULL]:
	BEGIN
	PTR_ATEXT(ERTEXT(.$CODE));
	PTR_TEXT(' for ');
	PTR=FUNPARSE(FB[FILE$START],.PTR);	!Put in filespec
	END;
[NODTOD,NODDIS,NODLIM,RMTDIS,RMTOFF,RMTABO,LNKNAV,RMTREJ]:
	BEGIN
	PTR_ATEXT(ERTEXT(.$CODE));
!This would say something useless like "for TSKnn:NETSPL."
!	PTR_TEXT(' for ');
!	PTR=FUNPARSE(FB[FILE$START],.PTR);	!Put in filespec
	END;
[RMTERR TO RMTERR+%O'177777']:
	PTR_TEXT('Remote system detected error -- ');
[CMDERR TO CMDERR+%O'777']:
	PTR_TEXT('Command Error -- ');
[TIMOUT,OPRABO,OPRDEF,USRABO]:	;	!Message is self-explanatory
[OTHERWISE]:
	PTR_TEXT('??UNEXPECTED ERROR -- ');
TES;


SELECT .$CODE OF SET		!Type details of error text
[FILERR TO FILDTB,FILOPN]:
			BEGIN
			CH$WCHAR_A(%C'(',PTR);
			PTR_ATEXT(ERTEXT(.$CODE));
			CH$WCHAR_A(%C')',PTR);
			END;
[INERROR,OUTERROR,EXQUOTA,DEVFULL,NODLIM,NODTOD,NODDIS
 ,LNKNAV,RMTDIS,RMTOFF,RMTABO,RMTREJ]:;	!Already typed it
[OTHERWISE]:		BEGIN
			LOCAL TEXTADR;
			TEXTADR=ERTEXT(.$CODE);
			PTR_ATEXT(.TEXTADR);	!Type out the message
			SELECTONE .TEXTADR OF SET
			[ERRUEC]:
				BEGIN	!Code is undefined, type out number
				PTR_TEXT(' (');
				WRNUMA(.$CODE,8,PTR);
				CH$WCHAR_A(%C')',PTR);
				END;
			[RMTUEC]:	!DAP code we don't have text for
				BEGIN	!Code is undefined, type out number
				LOCAL CODE;
				CODE=.$CODE;	!Make copy of Status code
				PTR_TEXT(' (Maccode=');
				!Make this back into a DAP code
				WRNUMA(.CODE<12,4>,8,PTR); !MACCODE
				PTR_TEXT(', Miccode=');
				WRNUMA(.CODE AND %O'7777',8,PTR); !MICCODE
				CH$WCHAR_A(%C')',PTR);
				END;
			TES;
			END;
TES;

SELECT .$SEVERITY OF SET
[SS$_NORMAL]: PTR_TEXT(']',CRLF);
[OTHERWISE]:  PTR_TEXT(CRLF);
TES;
CH$WCHAR_A(0,PTR);

LOGS(STR);		!Always log it

	BEGIN		!Decide whether to print it out or not
	LOCAL TYPEIT;
	TYPEIT=0;
	IF .NB[NDB$MASTER]
	 THEN IFMSG(LJOB,(TYPEIT=1))
	 ELSE IFMSG(RJOB,(TYPEIT=1));
	IF .$SEVERITY NEQ SS$_NORMAL	!If an error, use the ERROR bits
	 THEN	BEGIN
		IF .NB[NDB$MASTER]
		 THEN IFMSG(LJERR,(TYPEIT=1))
		 ELSE IFMSG(RJERR,(TYPEIT=1));
		END;
	IF .TYPEIT THEN TSTR_NOLOG(STR);
	END;
END;	!TERROR
GLOBAL ROUTINE TFBFUN(FB)=
!Type out the function we last executed on this file
!FB: address of FILE BLOCK
!Returns: none
BEGIN
LOCAL STR: VECTOR[CH$ALLOCATION(40)],
	PTR;
MAP	FB: REF FILE_BLOCK;

PTR=CH$PTR(STR);
FBFUN(FB[FILE$START],PTR);
TSTR(STR);
END;	!TFBFUN
GLOBAL ROUTINE FBFUN(FB,PTR)=
!Fill in name of operation that was attempted
!FB: addr of file block
!PTR: addr of byte pointer (for output)
BEGIN
MAP FB: REF FILE_BLOCK;

MOVEAZ(%REF(CH$PTR(
	CASE .FB[FILE$FUNCTION] FROM 0 TO 14 OF SET
	[_FORED]:		TEXT('Read');
	[_FOCRE]:		TEXT('create');
	[_FOWRT]:		TEXT('Create');
	[_FOSAU]:		TEXT('Update');
	[_FOMAU]:		TEXT('Simultaneous Update');
	[_FOAPP]:		TEXT('Append');
	[_FOCLS]:		TEXT('Close');
	[_FOURB]:		TEXT('Checkpoint');
	[_FOUSI]:		TEXT('USETI');
	[_FOUSO]:		TEXT('USETO');
	[_FORNM]:		TEXT('Rename');
	[_FODLT]:		TEXT('Delete');
	[_FOPRE]:		TEXT('Preallocate');
	[INRANGE,OUTRANGE]:	TEXT(' ????? ');
	TES)),.PTR);
END;	!FBFUN
GLOBAL ROUTINE TFB(FB)=
!Type a filespec on terminal
BEGIN
MAP FB: REF NDB;
LOCAL STR: VECTOR[CH$ALLOCATION(200)];
EXTERNAL ROUTINE FUNPARSE;

FUNPARSE(FB[FILE$START],CH$PTR(STR));
TSTR(STR);
END;
GLOBAL ROUTINE TNPFX(NB)=
	BEGIN
	MAP NB: REF NDB;
	LOCAL PTR,STR: VECTOR[CH$ALLOCATION(20)];

	PTR=CH$PTR(STR);
	NPFX(NB[FILE$START],PTR);	!Get the node prefix stuff
	TSTR(STR);
	END; !TNPFX
GLOBAL ROUTINE NPFX(NB,PTR)=
!Build the node & sequence number part of a message prefix
!NB: addr of NDB
!PTR: addr of byte pointer for output
	BEGIN
	MAP NB: REF NDB;
	IF .NB[NDB$NODEID] NEQ 0 THEN
		BEGIN
		LOCAL EQ: REF QSR_EQ;
		EXTERNAL ROUTINE WRSIXA,WRNUMA;
		CH$WCHAR_A(%C'(',.PTR);
		WRSIXA(.NB[NDB$NODEID],.PTR);
		IF (EQ=.NB[NDB$EQ]) NEQ 0 THEN
			BEGIN
			CH$WCHAR_A(%C'#',.PTR);
			WRNUMA(.EQ[QSR$EQ_SEQ],10,.PTR);
			END;
		CH$WCHAR_A(%C')',.PTR);
		END;
	CH$WCHAR(0,..PTR);
	END;	!NPFX
GLOBAL ROUTINE IOICOD(REASON)=
BEGIN
!Convert the REASON bits from software interrupt system
!into an error code (which we return)

!
! Formal Parameters
!

!REASON: the reason bits from an I/O interrupt 

!
! Implicit parameters
!

!none

!
! Returned value
!

!error code

!
! Implicit outputs
!

!none

IF IN_ERROR
THEN	RETURN INERROR
ELSE	IF OUT_ERROR
	THEN	RETURN OUTERROR
	ELSE	IF QUOTA_EX
			THEN	RETURN EXQUOTA
			ELSE	IF FULL
				THEN	RETURN FULL
				ELSE	IF END_OF_FILE
					THEN	RETURN ENDFILE
					ELSE	RETURN 0;
END; !IOICOD

END ELUDOM