c------------------------------------------------------------------------------
	Character*25	Function Get_Location(Terminal,TTType,PID)
c  This routine returns the location and terminal type, giver the
c  terminal name.  It user the data in the shared common section.
c  ! site-specific
c  If the terminal begins with RT it is considered a DECnet terminal.
c  If it begins with PT is ia assumed to be a pseudoterminal.  We use
c  these to connect to a network called jnet.  These can be ignored
c  if you don't have them, otherwise change appropriately.
c  If the terminal begins with VT its considered a VMS V4.x virtual
c  terminal and the associated physical terminal is used.
c  In the normal situation, the 25 characters returned are
c  the location and 25 for the type.  Obviously these can be 
c  can be shortened for printing (I normally print 15 + 25)
	Include		'FingerCom.For'
c Site-specific
c LAT ident stuff
c [rph] 01-06-88 - Server names and port names can be as large as
c		   16 and 12 characters respectively. By default only
c		   the first 8 characters of each are displayed. This
c		   can easily be changed.
	Include 'fingerdef.inc'
	Include '($JPIDEF)'
	Character Server*16, Port*12, Make_Pretty*70
	Integer Session, Status, LAT_Info, colon
	Integer		Privilege(2) /0,0/
	External LAT_Info
c end LAT ident data
	Character	Terminal*8, TTType*25
	Character	Network*20,	Get_Network*20
	Character	Node*12,	Get_Decnet_Node*6
	Character	Get_jnet_Node*8
	Integer		Btrim,		PID
	Integer		I_Device(4)
	Byte		B_Device(16), B_Device_Len
	Character	C_Device*15
	Equivalence	(I_Device, B_Device)
	Equivalence	(B_Device(1), B_Device_Len)
	Equivalence	(B_Device(2), C_Device)
	Integer		Lib$GetDVI
	External	Lib$GetDVI
	Integer DVI$_TT_PhyDevNam/274/
	Character	Phy_Terminal*8
	Integer		L_Phy_Terminal
	Get_Location = ' '	! If location can't be found
	TTType = ' '
c  first see if a VT (virtual terminal) is connected to a physical
c  terminal.
	If ( Terminal(1:2) .eq. 'VT' ) then
	    terminal='_'//terminal
	    Call Lib$GetDVI(DVI$_TT_PhyDevNam,,Terminal,,
     1	      Phy_Terminal,L_Phy_Terminal)
	    If (L_Phy_Terminal.gt.0)
     1	      Terminal = Phy_Terminal(2:L_Phy_Terminal)//':'
	Endif

	If ( Terminal(1:2) .eq. 'RT' ) Then
	    Node = Get_DECnet_Node(PID)
	    Network = Get_Network('D')
	    If ( Network .eq. '?' ) Network = 'DECnet'
	    Get_Location = Node(:Btrim(Node))//
	1	'.'//Network(:Btrim(Network))
	ElseIf ( Terminal(1:2) .eq. 'PT' ) Then	! Site-specific
	    Node = Get_jnet_Node(Terminal)
	    Network = Get_Network('J')
	    If ( Network .eq. '?' ) Network = 'jnet'
	    Get_Location = Node(:Btrim(Node))//
	1	'.'//Network(:Btrim(Network))
	ElseIf ( Terminal(2:3) .eq. 'VT' ) then
	    Get_Location = '<disconnected>'
	ElseIf ( Terminal(1:2) .eq. 'LT' ) then
	    Get_Location = 'Lat'
c ** Site-Specific
c  Call routine to get LAT info
		colon = Index(terminal,':')
		terminal = terminal(1:colon)
c  Turn on CMKRNL privilege
		Privilege(1) =  Prv$M_Cmkrnl
		Call Sys$Setprv(%Val(1),Privilege,,)
c  The LAT session number is returned also. You might find it useful.
		Status = LAT_info (Terminal(1:colon), Session, Server,
     1			Port)
c  Turn off CMKRNL privilege
		Call Sys$Setprv(,Privilege,,)
		If (Status) then
		  Server = Make_Pretty(Server)
		  Port = Make_Pretty(Port)
		  Get_Location = Server(1:8) // ' ' // Port(1:8)
		endif
	ElseIf ( Terminal(1:2) .eq. 'PX' ) then
	    Get_Location = 'PC Network'
	Else
c	  search for Terminal in shared common database
	    Do ii = 1,Loc$I_Last
		If ( Loc$C_Terminal(ii) .eq. Terminal ) then
		    Get_Location = Loc$C_Location(ii)
		    TTType = Loc$C_TTType(ii)
		    Return
	    	End if
	    End do
	EndIf
	Return
	End
