Trailing-Edge
-
PDP-10 Archives
-
BB-L054E-RK
-
apxtbl.b36
There are no other files named apxtbl.b36 in the archive.
MODULE APXTBL (
LANGUAGE(BLISS36),
ENTRY (
GET_VALUE,
GET_KEY,
T_DELETE,
T_ENTER,
T_LOOKUP,
A_LOOKUP,
A_ENTER
)
) =
BEGIN
!
! COPYRIGHT (c) 1980 BY
! Digital Equipment Corporation, Maynard, MA.
!
! 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: Autopatch Exec Table Processing Support Routines
!
! ABSTRACT:
!
!
!
!
! ENVIRONMENT: TOPS-20 / TOPS-10
!
! AUTHOR: Donald R. Brandt, CREATION DATE: 19 March 1980
!
! MODIFIED BY:
!
! Revision history follows
!
!--
!
! Edit History for APXTBL
!
! TBL001 by DRB on 10-Feb-81
! Fixed routine T_DELETE so that a meaningful error message
! is generated if the item to be deleted is not in the table.
!
GLOBAL BIND EDTTBL = %O'01' ; ! Edit level of this module
!
! TABLE OF CONTENTS:
!
FORWARD ROUTINE
GET_VALUE,
GET_KEY,
T_DELETE,
T_ENTER,
T_LOOKUP,
A_LOOKUP,
A_ENTER ;
!
! INCLUDE FILES:
!
LIBRARY 'BLI:TENDEF' ; !PDP-10 Definitions
LIBRARY 'BLI:MONSYM' ; !TOPS-20 Monitor Symbols
LIBRARY 'APEX' ; !APEX definitions
REQUIRE 'DEBUG.R36' ; !Debugging macros
!
! EXTERNAL REFERENCES:
!
GLOBAL BIND EDTAPX = APEX_EDT ; ! Edit level of APEX.R36
!
! The BLISS interface routines to the GALAXY library
! These are defined in BLSGLX.B36
!
EXTERNAL ROUTINE $K_SOUT ; !String output routine
EXTERNAL ROUTINE $M_GMEM ; !Memory allocation routine
EXTERNAL ROUTINE $M_RMEM ; !Memory deallocation routine
EXTERNAL ROUTINE $S_TBAD ; !Add entry to table
EXTERNAL ROUTINE $S_TBDL ; !Delete entry from table
EXTERNAL ROUTINE $S_TBLK ; !Lookup string in table
EXTERNAL ROUTINE $FMT$ERR ; !Format GALAXY error message
EXTERNAL ROUTINE $FMT$NUM ; !Format a number
GLOBAL ROUTINE GET_VALUE(n,table,value_adr) =
!++
! FUNCTIONAL DESCRIPTION:
!
! This routine obtains the value of a specified item in a
! TABLE data structure. The table portion of this structure
! is in TOPS-20 TBLUK format.
!
! FORMAL PARAMETERS:
!
! n: the item # of the table entry
! (1 <= n <= entries)
!
! table: the address of the TABLE$$
!
! value_adr:
! the address to return the retrieved value in
!
! IMPLICIT INPUTS:
!
! None
!
! IMPLICIT OUTPUTS:
!
! Stores the retrieved value at the address contained in
! value_adr.
!
! ROUTINE VALUE:
!
! Returns TRUE if no errors.
! Returns FALSE if n is not a valid item number.
!
! SIDE EFFECTS:
!
! None
!
!--
BEGIN
MAP
table: REF TABLE$$ ;
$TRACE('Beginning','GET_VALUE') ;
IF ((.n GTR .table[tbl_actual_entries]) OR (.n LEQ 0))
THEN
RETURN false ;
.value_adr = .table[.n, tbl_item_value] ;
RETURN true ;
END ; !End of GET_VALUE
GLOBAL ROUTINE GET_KEY(n,table,key_adr) =
!++
! FUNCTIONAL DESCRIPTION:
!
! This routine obtains the key field of a specified item in a
! TABLE data structure. The table portion of this structure
! is in TOPS-20 TBLUK format.
!
! FORMAL PARAMETERS:
!
! n: the item # of the table entry
! (1 <= n <= entries)
!
! table: the address of the TABLE$$
!
! key_adr:
! the address to return the contents of the
! retrieved key field in
!
! IMPLICIT INPUTS:
!
! None
!
! IMPLICIT OUTPUTS:
!
! Stores the contents of the key field of the retrieved item
! at the address contained in key_adr.
!
! ROUTINE KEY:
!
! Returns TRUE if no errors.
! Returns FALSE if n is not a valid item number.
!
! SIDE EFFECTS:
!
! None
!
!--
BEGIN
MAP
table: REF TABLE$$ ;
$TRACE('Beginning','GET_KEY') ;
IF ((.n GTR .table[TBL_ACTUAL_ENTRIES]) OR (.n LEQ 0))
THEN
RETURN false ;
.key_adr = .table[.n, tbl_item_adr] ;
RETURN true ;
END ; !End of GET_KEY
GLOBAL ROUTINE T_DELETE(table,string_adr) =
!++
! FUNCTIONAL DESCRIPTION:
!
! This routine deletes an entry in a TABLE data structure.
! The table portion of this structure is in TOPS-20 TBLUK
! format.
!
! FORMAL PARAMETERS:
!
! table: the address of the TABLE
!
! string_adr:
! the address of an ASCIZ string that is the key
! of the entry to be deleted from the table
!
! IMPLICIT INPUTS:
!
! None
!
! IMPLICIT OUTPUTS:
!
! Outputs any associated error messages
!
! ROUTINE VALUE:
!
! Returns TRUE if no errors.
! Returns FALSE if entry can't be deleted from table
!
! SIDE EFFECTS:
!
! None
!
!--
BEGIN
LOCAL
address,
error ;
MAP
table: REF TABLE$$ ;
$TRACE('Beginning','T_DELETE') ;
CK_DATATYPE(table,TABLE) ;
IF $S_TBLK(.table[TABLE_REF],CH$PTR(.string_adr),address)
THEN
BEGIN
IF $S_TBDL(.table[TABLE_REF],.address,error)
THEN
RETURN true
END
ELSE
RETURN $ERROR(W$DEF,*,.string_adr,S(' (Entry not in table)')) ;
$ERROR(W$DEF,*,.string_adr,$GERROR(.error))
END ; !End of T_DELETE
GLOBAL ROUTINE T_ENTER(table,string_adr,value) =
!++
! FUNCTIONAL DESCRIPTION:
!
! This routine adds an entry to a TABLE data structure. The
! table portion of this structure is in TOPS-20 TBLUK format.
!
! FORMAL PARAMETERS:
!
! table: the address of the TABLE
!
! string_adr:
! the address of the ASCIZ string to associate with
! this entry
!
! value: the value associated with the entry
!
! IMPLICIT INPUTS:
!
! None
!
! IMPLICIT OUTPUTS:
!
! Outputs any associated error messages.
!
! ROUTINE VALUE:
!
! Returns TRUE if no errors.
! Returns FALSE if entry can't be made in table
!
! SIDE EFFECTS:
!
! If the table is full, this routine will attempt to expand
! the table and then make the entry.
!
!--
BEGIN
STACKLOCAL
error ;
MAP
table: REF TABLE$$ ;
$TRACE('Beginning','T_ENTER') ;
CK_DATATYPE(table,TABLE) ;
IF $S_TBAD(.table[TABLE_REF],.string_adr,.value,error)
THEN
RETURN true ;
IF .error EQL ERTBF$
THEN
IF EXPAND_TABLE(table)
THEN
IF T_ENTER(.table,.string_adr,.value)
THEN
RETURN true ;
$ERROR(W$TEF,*,.string_adr,$GERROR(.error))
END ; !End of T_ENTER
GLOBAL ROUTINE T_LOOKUP(table,string_adr,value_adr) =
!++
! FUNCTIONAL DESCRIPTION:
!
! This routine looks up an entry in a TABLE data structure.
! The table portion of this structure is in TOPS-20 TBLUK
! format.
!
! FORMAL PARAMETERS:
!
! table: the address of the TABLE
!
! string_adr:
! the address of the ASCIZ string to lookup in
! the table
!
! value_adr:
! the address to store the value associated with
! the entry
!
! IMPLICIT INPUTS:
!
! None
!
! IMPLICIT OUTPUTS:
!
! None
!
! ROUTINE VALUE:
!
! 0 if no match (false)
! 1 if exact match (true)
! 2 if ambiguous (false)
! 3 if unique abbreviation (true)
! 4 if internal error (false)
!
! SIDE EFFECTS:
!
! None
!
!--
BEGIN
LOCAL
address,
ret ;
MAP
table: REF TABLE$$ ;
$TRACE('Beginning','T_LOOKUP') ;
CK_DATATYPE(table,TABLE) ;
ret = $S_TBLK(.table[TABLE_REF],CH$PTR(.string_adr),address) ;
.value_adr = .table[(.address - .table[TABLE_REF]),TBL_ITEM_VALUE] ;
.ret
END ; !End of T_LOOKUP
GLOBAL ROUTINE A_LOOKUP(table,address,value_adr) =
!++
! FUNCTIONAL DESCRIPTION:
!
! This routine looks up an address in the address field of a
! TABLE data structure. The table portion of this structure
! is in TOPS-20 TBLUK format. If the specified address is
! found, the value associated with that address is returned.
!
! FORMAL PARAMETERS:
!
! table: the address of the TABLE$$
!
! address:
! the address to find in the table
!
! value_adr:
! the address to return the retrieved value in
!
! IMPLICIT INPUTS:
!
! None
!
! IMPLICIT OUTPUTS:
!
! Stores the retrieved value at the address contained in
! value_adr.
!
! ROUTINE VALUE:
!
! Returns TRUE if the address is found.
! Returns FALSE if the address is not in the table.
!
! SIDE EFFECTS:
!
! None
!
!--
BEGIN !Beginning ROUTINE A_LOOKUP
LOCAL
n ;
MAP
table: REF TABLE$$ ;
$TRACE('Beginning','A_LOOKUP') ;
!
! Do linear search of list of addresses in table
! If specified address is in table, return true.
!
n = 0 ;
WHILE (n=.n+1) LEQ .table[TBL_ACTUAL_ENTRIES] DO
BEGIN
IF .table[.n,TBL_ITEM_ADR] EQLA .address
THEN
BEGIN
.value_adr = .table[.n,TBL_ITEM_VALUE] ;
RETURN true ;
END ;
END ;
!
! Entry not found
!
false
END ; !End ROUTINE A_LOOKUP
GLOBAL ROUTINE A_ENTER(table,address,value) =
!++
! FUNCTIONAL DESCRIPTION:
!
! This routine enters an address and an associated value in
! the respective address and value fields of a TABLE data
! structure. The entry is made at the end of the table. The
! table portion of this structure is in TOPS-20 TBLUK format.
!
! FORMAL PARAMETERS:
!
! table: the address of the TABLE$$
!
! address:
! the address to enter in the table
!
! value:
! the value to enter
!
! IMPLICIT INPUTS:
!
! None
!
! IMPLICIT OUTPUTS:
!
! Error message if entry fails.
!
! ROUTINE VALUE:
!
! Returns TRUE if the entry succeeds.
! Returns FALSE if the entry operation fails.
!
! SIDE EFFECTS:
!
! None
!
!--
BEGIN !Beginning ROUTINE A_ENTER
LOCAL
n ;
MAP
table: REF TABLE$$ ;
$TRACE('Beginning','A_ENTER') ;
IF .table[TBL_ACTUAL_ENTRIES] EQL .table[TBL_MAX_ENTRIES]
THEN
IF NOT EXPAND_TABLE(table)
THEN
RETURN $ERROR(C$TEF,*,S('entering address')) ;
table[(.table[TBL_ACTUAL_ENTRIES]+1),TBL_ITEM_ADR] = .address ;
table[(.table[TBL_ACTUAL_ENTRIES]+1),TBL_ITEM_VALUE] = .value ;
table[TBL_ACTUAL_ENTRIES] = .table[TBL_ACTUAL_ENTRIES] + 1 ;
true
END; !End ROUTINE A_ENTER
END
ELUDOM