*DECK NP$GSM
USETEXT AIPDEF
USETEXT NP$MODE
USETEXT NP$NWL
USETEXT NP$STAT
USETEXT NP$TAA
*IF,DEF,DEBUG
USETEXT NP$DB
*ENDIF
PROC NP$GSM;
*IF DEF,IMS
#
*1DC NP$GSM
*
* 1. PROC NAME AUTHOR DATE
* NP$GSM S.KRULEVITCH 77/05/23
*
* 2. FUNCTIONAL DESCRIPTION
* THIS ROUTINE IS CALLED FROM AIP. IT COPIES ONE SUPERVISORY
* MESSAGE (IF ANY) TO THE TEXT AREA (TA) OF THE APPLICATION. IF
* NO SUPERVISORY MESSAGES ARE LEFT, IT RETURNS A NULL BLOCK
*
* 3. METHOD USED
* THE SUPERVISOR MESSAGE BUFFER STARTS AT FIRST AND ENDS AT
* LAST. HEAD AND FOOT ARE INDICES WHICH POINT RESPECTIVELY
* TO THE START OF THE LIST OF SUPERVISORY MESSAGES AND TO THE
* WORD FOLLOWING THE LAST SUPERVISORY MESSAGE. THE MESSAGE LENGTH
* IS GIVEN BY GSM$TLC IN THE HEADER. THIS INFORMATION ALLOWS
* NP$GSM TO TRANSFER THE MESSAGE TO TA (TEXT AREA) AND UPDATE
* HEAD FOR THE NEXT CALL TO NP$GSM.
*
* 4. ENTRY CONDITIONS
* TLMX - MAXIMUM MESSAGE LENGTH
* LOC$HA - LOCATION OF HEADER AREA
* LOC$TA - LOCATION OF TEXT AREA
* HEAD - INDEX IN SMB OF THE CURRENT SUPERVISORY MESSAGE.
* HEAD = FOOT IF THERE ARE NO MESSAGES.
*
* 5. EXIT CONDITIONS
* HA - HEADER AREA, CONTAINS THE HEADER
* TA - TEXT AREA, CONTAINS THE SUPERVISORY BLOCK
* HEAD - INDEX IN SMB OF NEXT SUPERVISORY MESSAGE
*
* 6. COMDECKS CALLED AND SYMPL TEXTS USED.
* AIPDEF NP$CRT NP$DB NP$MODE
* NP$NWL NP$STAT NP$TAA
*
* 7. ROUTINES CALLED
* NP$DBG - LOGS DEBUG MESSAGE TO ZZZZZDN
* NP$ERR - PRINTS ERROR MESSAGES AND STOPS
* NP$SN - INCREMENTS STATISTICS COUNTER
*
* 8. DAYFILE MESSAGES
* NAM ERROR (UNDER E OPTION ONLY. INCORRECT CHARACTER TYPE)
*
#
*ENDIF
BEGIN
*CALL NP$CRT
# #
# EXTERNAL ROUTINES: #
# #
XREF BEGIN
*IF DEF,DEBUG
PROC NP$DBG; #LOG MESSAGE TO FILE ZZZZZDN #
*ENDIF
PROC NP$ERR; #ERROR PROCESSOR #
*IF DEF,STAT
PROC NP$SN; #INCREMENTS STATISTICS COUNTER#
*ENDIF
END
# #
# LOCAL DECLARATIONS: #
# #
ITEM
I I, #LOOP CONTROL VARIABLE #
J I, #TEMPORARY INDEX #
K I, #TEMPORARY INDEX #
N I, #WORDS OF SM TRANSFERRED - 1 #
*IF DEF,STAT
ST$TEMP I, #TEMPORARY LOCATION #
*ENDIF
TLW I, #ACTUAL SIZE OF SM #
TLWDIF I; #TLW - SUM OF TAASIZE[K] #
ITEM NOWHEAD I ;
BASED ARRAY MEM S(1);
ITEM
HA I (0), #HEADER AREA #
WORD I (0); #TEXT ARRAY #
#**********************************************************************#
# #
# NP$GSM EXECUTION BEGINS HERE #
# #
*IF DEF,DEBUG,1
# #
# IF NO SM"S, RETURN NULL BLOCK #
# #
P<MEM> = LOC$HA;
IF HEAD EQ FOOT
THEN
BEGIN
HA=0; #RETURN NULL BLOCK #
*IF DEF,STAT
# #
# UPDATE STATISTICS IF STATISTIC GATHERING IS ON #
# #
NP$SN(TYPE"INB");
*ENDIF
END
# #
# COPY NEXT SUPERVISORY MESSAGE TO TEXT ARRAY #
# #
ELSE
BEGIN
IF GSM[HEAD] EQ 0
THEN
HEAD = FIRST; #WRAP AROUND HAS OCCURRED #
NOWHEAD = HEAD ;
IF GSM$ACT[HEAD] EQ CT60TRANS
THEN
TLW = GSM$TLC[HEAD];
ELSE
TLW = (2*GSM$TLC[HEAD] + 14)/15;
IF TLW GR TLMX
THEN
BEGIN
GSM$IBU[HEAD] = TRUE ; # INPUT BLOCK UNDELIVERAB #
END
ELSE
BEGIN
GSM$IBU[HEAD] = FALSE ; # RESET IBU FROM PREVIOUS #
N = TLW - 1;
P<MEM> = LOC$TA;
P<TAA> = LOC$TA;
J = HEAD + 1;
TLWDIF = TLW;
CONTROL FASTLOOP;
FOR K = 1 STEP 1 UNTIL LTAA DO
BEGIN
IF LTAA NQ 0
THEN
BEGIN
P<MEM> = TAADDR[K];
N = TAASIZE[K] - 1;
IF N GR TLWDIF #MAKE SURE THAT AIP IS ONLY #
THEN #COPYING THE SUPERVISORY #
N = TLWDIF - 1; #MESSAGE TO THE FRAGMENTED #
#BUFFERS - NO MATTER WHAT SIZE#
#HAS BEEN SPECIFIED IN THE #
#TEXT AREA ARRAY. #
TLWDIF = TLWDIF - TAASIZE[K];
END
CONTROL SLOWLOOP;
FOR I = 0 STEP 1 UNTIL N DO
BEGIN
WORD[I] = GSM[I+J];
END
J = J + TAASIZE[K];
END
*IF DEF,STAT
# #
# UPDATE STATISTICS IF STATISTIC GATHERING IS TURNED ON #
# #
I = GSM$ABT[HEAD] + TYPE"INB";
NP$SN(I);
# INCREMENT ERROR COUNT IF THE LAST DELIVERED SUPERVISORY #
# MESSAGE WAS AN ERR/LGL (X"8401") OR A FC/NAK (X"8303") #
ST$TEMP = B<0,16>GSM[HEAD+1];
IF ST$TEMP EQ ERRLGL
THEN
BEGIN
NP$SN(TYPE"ERRS"); #INCREMENT COUNTER #
END
IF ST$TEMP EQ FCNAK
THEN
BEGIN
NP$SN(TYPE"NAKS"); #INCREMENT COUNTER #
END
*ENDIF
# #
# UPDATE POINTERS IF MESSAGE WAS SENT TO APP (TLW LQ TLMX) #
# #
HEAD = HEAD + TLW + 1; #TLW DOES NOT INCLUDE HEADER #
IF HEAD GR WLLEN
THEN
BEGIN
HEAD = FIRST;
END
END #SUPERVISORY MESSAGE DELIVERED#
P<MEM> = LOC$HA ;
HA = GSM[NOWHEAD] ; # RETURN HEADER #
*IF DEF,DEBUG
NP$DBG; #WRITE MSG TO AIP DEBUG FILE #
*ENDIF
IF HEAD EQ FOOT
THEN
BEGIN
HEAD = FIRST;
FOOT = FIRST;
END #EMPTY SMB#
END
RETURN;
END #NP$GSM#
TERM