From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 30-MAY-1991 19:23:43.46
To:	ARISIA::EVERHART
CC:	
Subj:	Re: LAT - is it possible to find the service name used to connect?

From:	RELAY-INFO-VAX@CRVAX.SRI.COM@SMTP@CRDGW2
To:	Everhart@Arisia@MRGATE

Received:  by crdgw1.ge.com (5.57/GE 1.99)
	 id AA17181; Thu, 30 May 91 18:46:02 EDT
Received: From CUNYVM.CUNY.EDU by CRVAX.SRI.COM with TCP; Thu, 30 MAY 91 10:14:45 PDT
Received: from UALR.BITNET by CUNYVM.CUNY.EDU (IBM VM SMTP R1.2.2MX) with BSMTP id 9555; Thu, 30 May 91 13:13:31 EDT
Date: Thu, 30 May 1991 12:12 CDT
From: Dale Miller <DOMILLER%UALR.BITNET@CUNYVM.CUNY.EDU>
Subject: Re: LAT - is it possible to find the service name used to connect?
To: INFO-VAX@SRI.COM
Message-Id: <FFFF1F0840800C65@UALR.BITNET>
X-Envelope-To: INFO-VAX@SRI.COM
X-Vms-To: IN%"INFO-VAX@SRI.COM"

Yehavi Bourvine 58-4279 <VMS.HUJI.AC.IL!yehavi@UCBVAX.BERKELEY.EDU> writes:
>  Suposse there is a system which publishes more than one LAT services. When
>a user connects to it, is there any way to find (from the host side) what
>service name was used? I think it is impossible, but maybe I miss something...
>                                                Thanks in advance, __Yehavi:
Since I have been doing well lately reposting old messages.  Here is one which
Ehud Gavron posted almost exactly 1 year ago (23-May-1990).  (It pays to keep
around old mail.)
        Dale
>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
>Yehavi Bourvine (4X6DD),     Phones: +972-2-584279,     H
>Computation Center,                          +5686      H
>The Hebrew University of Jerusalem,  +972-2-521574      H
>Givat-Ram,  Jerusalem  91904                            H H H
>                             Fax: +972-2-527349         HH H
>BITnet:    YEHAVI@HUJIVMS                               H   H
>InterNet:  YEHAVI@VMS.HUJI.AC.IL                       H
>Israeli DECnet:  HUJICC::YEHAVI                       H
>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
--------------------------------------------------------------------------
| Dale O. Miller                        | #   #  ###  #     ####         |
| University of Arkansas at Little Rock | #   # #   # #     #   #        |
| 2801 S. University                    | #   # ##### #     ####         |
| Little Rock, AR  72204-1099  USA      | #   # #   # #     #  #         |
| (501)569-8714                         |  ###  #   # ##### #   #        |
| DOMILLER@UALR.BITNET                  | Disclaimer: This does not      |
| 92-20-28 W,34-43-30 N.ICBMNET         | say what I say it doesn't say. |
--------------------------------------------------------------------------
Ehud's message begins:
In response to a flooded mailbox, and with apologies to those who
sent mail messages I cannot possibly answer all this year, and with
no further ado but to say that I think DECUS was a blast, here is the
code which returns LAT service names connected to by a terminal for VMS
V5.3 and greater:

        The following vms_share file includes getsrvnam.mar, a routine
        which returns the lat service name of the specified device in
        the logical name TT_SRVNAM.

        To assemble it: $ MACRO GETSRVNAM
        To link it:     $ LINK GETSRVNAM
        To run it, you can either run it directly, or use a symbol to
        run it as a foreign command specifying the terminal via
        symbol == "$location:getsrvnam"    $ symbol [terminal]

        Note that for nonprivileged users to use this, it needs to
        be installed with CMKNRL privilege.

        Also note that specifying reverse-lat terminals yields an
        invalid logical name error.  This is because the string is
        not stored by VMS, and is therefore null.

        If you have any improvements, comments, etcetera, please
        don't hesitate to send them my way.

/----------------------------------------------------------------------------\
| Ehud Gavron, Systems analyst  | sunquest!gavron@cs.arizona.edu (uucp)      |
| Sunquest Information Systems  | sunquest!gavron@uunet.uu.net   (alternate) |
| 930 N. Finance Center Drive   | gavron@sunquest.com            (domain)    |
| Tucson, Arizona, 85710        | (602)722-7546/885-7700 x.2546  (AT&Tnet)   |
|----------------------------------------------------------------------------|
| "I will not be pushed, filed, stamped, indexed, briefed, debriefed, or     |
|  numbered.  My life is my own. "                          -- the prisoner  |
\----------------------------------------------------------------------------/

$Cut_Here:
$! ------------------ CUT HERE -----------------------
$ v='f$verify(f$trnlnm("SHARE_VERIFY"))'
$!
$! This archive created by VMS_SHARE Version 7.2-007  22-FEB-1990
$!   On 21-MAY-1990 13:09:17.47   By user GAVRON
$!
$! This VMS_SHARE Written by:
$!    Andy Harper, Kings College London UK
$!
$! Acknowledgements to:
$!    James Gray       - Original VMS_SHARE
$!    Michael Bednarek - Original Concept and implementation
$!
$! TO UNPACK THIS SHARE FILE, CONCATENATE ALL PARTS IN ORDER
$! AND EXECUTE AS A COMMAND PROCEDURE  (  @name  )
$!
$! THE FOLLOWING FILE(S) WILL BE CREATED AFTER UNPACKING:
$!       1. GETSRVNAM.MAR;2
$!
$set="set"
$set symbol/scope=(nolocal,noglobal)
$f=f$parse("SHARE_TEMP","SYS$SCRATCH:.TMP_"+f$getjpi("","PID"))
$e="write sys$error  ""%UNPACK"", "
$w="write sys$output ""%UNPACK"", "
$ if f$trnlnm("SHARE_LOG") then $ w = "!"
$ ve=f$getsyi("version")
$ if ve-f$extract(0,1,ve) .ges. "4.4" then $ goto START
$ e "-E-OLDVER, Must run at least VMS 4.4"
$ v=f$verify(v)
$ exit 44
$UNPACK: SUBROUTINE ! P1=filename, P2=checksum
$ if f$search(P1) .eqs. "" then $ goto file_absent
$ e "-W-EXISTS, File ''P1' exists. Skipped."
$ delete 'f'*
$ exit
$file_absent:
$ if f$parse(P1) .nes. "" then $ goto dirok
$ dn=f$parse(P1,,,"DIRECTORY")
$ w "-I-CREDIR, Creating directory ''dn'."
$ create/dir 'dn'
$ if $status then $ goto dirok
$ e "-E-CREDIRFAIL, Unable to create ''dn'. File skipped."
$ delete 'f'*
$ exit
$dirok:
$ w "-I-PROCESS, Processing file ''P1'."
$ if .not. f$verify() then $ define/user sys$output nl:
$ EDIT/TPU/NOSEC/NODIS/COM=SYS$INPUT 'f'/OUT='P1'
PROCEDURE Unpacker ON_ERROR ENDON_ERROR;SET(FACILITY_NAME,"UNPACK");SET(
SUCCESS,OFF);SET(INFORMATIONAL,OFF);f:=GET_INFO(COMMAND_LINE,"file_name");b:=
CREATE_BUFFER(f,f);p:=SPAN(" ")@r&LINE_END;POSITION(BEGINNING_OF(b));
LOOP EXITIF SEARCH(p,FORWARD)=0;POSITION(r);ERASE(r);ENDLOOP;POSITION(
BEGINNING_OF(b));g:=0;LOOP EXITIF MARK(NONE)=END_OF(b);x:=ERASE_CHARACTER(1);
IF g=0 THEN IF x="X" THEN MOVE_VERTICAL(1);ENDIF;IF x="V" THEN APPEND_LINE;
MOVE_HORIZONTAL(-CURRENT_OFFSET);MOVE_VERTICAL(1);ENDIF;IF x="+" THEN g:=1;
ERASE_LINE;ENDIF;ELSE IF x="-" THEN IF INDEX(CURRENT_LINE,"+-+-+-+-+-+-+-+")=
1 THEN g:=0;ENDIF;ENDIF;ERASE_LINE;ENDIF;ENDLOOP;t:="0123456789ABCDEF";
POSITION(BEGINNING_OF(b));LOOP r:=SEARCH("`",FORWARD);EXITIF r=0;POSITION(r);
ERASE(r);x1:=INDEX(t,ERASE_CHARACTER(1))-1;x2:=INDEX(t,ERASE_CHARACTER(1))-1;
COPY_TEXT(ASCII(16*x1+x2));ENDLOOP;WRITE_FILE(b,GET_INFO(COMMAND_LINE,
"output_file"));ENDPROCEDURE;Unpacker;QUIT;
$ delete/nolog 'f'*
$ CHECKSUM 'P1'
$ IF CHECKSUM$CHECKSUM .eqs. P2 THEN $ EXIT
$ e "-E-CHKSMFAIL, Checksum of ''P1' failed."
$ ENDSUBROUTINE
$START:
$ create 'f'
X`09.title`09getsrvnam  Get Lat Service Name
X`09.ident`09/1.0/
X;
X; This is a small routine which gets the lat service name the specified
X; terminal was connected to.  This is useful for doing different things
X; based on which service one connected to, even if all services are
X; offered by the same host.
X;
X; V1.0`0916-May-1990 Ehud Gavron.  Created.  See ZDEC.MAR for reference.
X;`09`09`09`09`09    Also VARY.MAR for reference.
X;
X; NOTE: The ucb$t_lt_srvnam definition below was received over info-vax
X;`09from someone with source fiche.  I do not make a claim that this
X;`09will ever work, change, or neither... It does however work under
X;`09V5.3-1.
X;
X`09.sbttl`09include section
X
X`09.library`09"sys$library:lib.mlb"
X`09.link`09`09"sys$system:sys.stb"`09/selective_search
X
X`09$tpadef`09`09; lib$tparse definitions
X`09$ssdef`09`09; system service statu return definitions
X`09$ucbdef`09`09; unit control block definitions
X`09$stsdef`09`09; status codes
X`09$dvidef`09`09; device item codes
X`09$dcdef`09`09; device types
X
X`09.psect`09getsrvnam_data,rd,wrt,noexe,long,shr,pic
X
Xservice_name:`09`09.blkb`0932`09; LAT service name buffer
Xservice_len = . - service_name`09`09; Its length
Xservice_desc:`09`09`09`09; Its descriptor
X`09.long`09`09service_len
X`09.address `09service_name
Xcmd_buf:`09`09.blkb`0980`09; Command line buffer
Xcmd_buf_siz = . - cmd_buf`09`09; Its length
Xcmd_buf_desc:`09`09`09`09; Its descriptor
X`09.long`09`09cmd_buf_siz
X`09.address`09cmd_buf
Xdev_buf:`09`09.blkb`0940`09; Device name buffer
Xdev_buf_siz = . - dev_buf`09`09; Its length
Xdev_buf_desc:`09`09`09`09; Its descriptor
X`09.long`09`09dev_buf_siz
X`09.address`09dev_buf
Xk_arg:`09`09`09`09`09; Kernel mode argument list
X`09.long`09`091`09`09; # of arguments
X`09.address`09dev_buf_desc`09; Device name descriptor
Xtt_srvnam:`09.ascid`09/TT_SRVNAM/`09; Logical name to define
Xlnm_logtab:`09.ascid`09/LNM$PROCESS/`09; Logical name table to define in
Xprompt:`09`09.ascid`09/LAT Term: /`09; Prompt for lib$get_foreign
X
Xucb$t_lt_srvnam = `5Ex1aa`09`09`09; Offset to service name (V5.3 fiche)
X
Xdev_class:`09.long`091`09`09; Device class gotten
Xlog_dev_desc:`09.blkq`091`09`09; Descriptor for device requested
X
Xparse_blk:`09`09`09`09; Parse block for lib$tparse
X`09.long`09tpa$k_count0
X`09.long`09tpa$m_abbrev
X`09.blkb`09tpa$k_length0-8
X
Xdev_item_list:`09`09`09`09; Itemlist for $getdvi
X`09.word`09`09dev_buf_siz
X`09.word`09`09dvi$_devnam`09; Get physical device name
X`09.address `09dev_buf
X`09.address `09dev_buf_desc
X`09.word`09`094`09`09; Check device class for terminal
X`09.word`09`09dvi$_devclass
X`09.address`09dev_class
X`09.long`09`090
X`09.long`09`090`09`09; End of itemlist.
X
Xtt_item_list:`09`09`09`09; Itemlist for terminal physical name
X`09.word`09`09dev_buf_siz
X`09.word`09`09dvi$_tt_phydevnam
X`09.address`09dev_buf
X`09.address`09dev_buf_desc
X`09.long`09`090
X
X`09.sbttl`09State Table
X`09.psect`09getsrvnam_states,rd,nowrt,exe,long,shr,pic
X
X`09$init_state`09state_table,key_table
X
X`09$state`09start
X`09$tran`09tpa$_symbol,dev,,,log_dev_desc
X`09$tran`09tpa$_eos,tpa$_exit
X
X`09$state`09dev
X`09$tran`09tpa$_eos,tpa$_exit
X`09$tran`09':',colon
X
X`09$state `09colon
X`09$tran`09tpa$_eos,tpa$_exit
X
X`09$state
X`09$tran`09tpa$_symbol,dev,,,log_dev_desc
X`09$tran`09tpa$_eos,tpa$_exit
X
X`09$end_state
X`0C
X`09.page
X`09.sbttl`09Main Program
X`09.psect`09getsrvnam_code,rd,nowrt,exe,long,shr,pic
X`09.entry  getsrvnam,`5Em<r2,r3,r4,r5>
X;
X; Get the command line:
X;
X`09pushal`09cmd_buf_desc`09`09; Return length
X`09pushal`09prompt`09`09`09; Prompt if not entered before
X`09pushal`09cmd_buf_desc`09`09; Place to put line
X`09calls`09#3,g`5Elib$get_foreign`09; Get command line
X`09blbs`09r0,10$`09`09`09; Continue if ok
X`09brw `09exit`09`09`09; Exit with errors
X
X10$:
X;
X; Parse it to extract the device name:
X;
X`09movl`09cmd_buf_desc,parse_blk+tpa$l_stringcnt ; Set length
X`09movl`09cmd_buf_desc+4,parse_blk+tpa$l_stringptr ; set address
X`09pushal`09key_table
X`09pushal`09state_table
X`09pushal`09parse_blk
X`09calls`09#3,g`5Elib$tparse
X`09blbs`09r0,20$
X`09brw`09exit
X20$:
X;
X; Make sure there is such a device:
X;
X`09$getdvi_s`09devnam=log_dev_desc,itmlst=dev_item_list
X`09blbs`09r0,30$
X`09brw`09exit
X
X30$:
X;
X; Get the physical device name:
X;
X`09$getdvi_s`09devnam=log_dev_desc,itmlst=tt_item_list
X`09blbc`09r0,exit`09`09`09
X;
X; Make sure it's a terminal:
X;
X`09cmpl`09#dc$_term,dev_class
X`09beql`0940$
X`09movl`09#ss$_ivdevnam,r0
X`09brw`09exit
X
X40$:
X;
X; Call Kernel-mode routine to move string to unprivileged readable area...
X;
X
X`09$cmkrnl_s routin=getucbstr,arglst=k_arg`20
X;
X; Find zero-terminated string's length and store in descriptor:
X;
X`09clrl`09r1
X50$:`09cmpb`09#0,service_name(r1)`09`09; is it a nul?
X`09beql`0960$`09`09`09`09; Yup, found end of string
X`09aobleq`09#service_len,r1,50$`09`09; Nope, add one, try again
X60$:`09movl`09r1,service_desc`09`09`09; Update descriptor length
X
X;
X; Define process logical name TT_SRVNAM to be the service name
X;
X`09pushl`09#0`09`09`09`09; attributes
X`09pushl`09#0`09`09`09`09; itemlist
X`09pushal`09lnm_logtab`09`09`09; table
X`09pushal`09service_desc`09`09`09; value
X`09pushal`09tt_srvnam`09`09`09; name
X`09calls`09#5,g`5Elib$set_logical
Xexit:
X`09ret`09`09`09`09; and exit
X`0C
X`09.page
X`09.sbttl`09getucbstr `09; Get string from the ucb
X;
X; GETUCBSTR -- Gets the UCB address, finds the lat service name given
X;`09       the ucb$t_lt_srvnam offset, and copies that string to
X;`09       an area of memory that an outer access mode may read.
X
X`09.entry`09getucbstr,`5Em<r2,r3,r4,r5> ; MOVC3 destroys these
X
X`09lock`09lockname=sched`09; Lock scheduling datbase at ipl$_sched
X`09movl`094(ap),r1`09; Address of device name descriptor into r1
X`09jsb`09g`5Eioc$searchdev ; returns ucb address into r1.
X`09blbc`09r0,k_exit`09; bug out on error...
X`09movc3`09#16,ucb$t_lt_srvnam(r1),service_name ; copy it to local space
X`09movl`09#ss$_normal,r0`09; fake a fantastically ok return status
Xk_exit:
X`09unlock `09lockname=sched`09; resume scheduling, lower ipl
X`09ret`09`09`09; and exit
X`09.end`09getsrvnam
$ CALL UNPACK GETSRVNAM.MAR;2 1611225803
$ v=f$verify(v)
$ EXIT

--
| Ehud Gavron, Systems analyst  | sunquest!gavron@cs.arizona.edu (uucp)      |
| Sunquest Information Systems  | sunquest!gavron@uunet.uu.net   (alternate) |
| 930 N. Finance Center Drive   | gavron@sunquest.com            (domain)    |
| Tucson, Arizona, 85710        | (602)885-7700 x.2546           (AT&Tnet)   |

