*DECK IPUGHBN
USETEXT TEXTIPL
FUNC IPUGHBN (HOST, IPADDR, HOSTUN) B;
*CALL COPYRITE CDCNET - COPYRIGHT CONTROL DATA. 1992.
# TITLE IPUGHBN - GET HOST BY NAME. #
BEGIN # IPUGHBN #
#
**** IPUGHBN - GET HOST BY NAME.
*
* THIS FUNCTION READS THE TCP HOST FILE, AND EXTRACTS THE IP
* ADDRESS OF THE SUPPLIED HOST NAME. THE FUNCTION RETURNS TRUE IF
* THE HOST WAS FOUND.
*
* FUNC IPUGHBN (HOST, IPADDR, HOSTUN)
*
* ENTRY HOST = 2 WORD HOST NAME, DISPLAY CODE,
* LEFT JUSTIFIED.
* HOSTUN = TCPHOST USERNAME, DISPLAY CODE,
* LEFT JUSTIFIED.
*
* EXIT IPUGHBN = TRUE IF HOST NAME FOUND.
* IPADDR = 3 WORD ADDRESS ARRAY.
*
* METHOD THE FET IS INITIALIZED AND THE FILE IS ATTACHED. BOTH
* A INDIRECT ACCESS FILE AND A DIRECT ACCESS FILE IS
* SEARCHED FOR. IF THE HOST FILE IS NOT FOUND, THE FUCTION
* RETURNS A FALSE CONDITION AND A DAYFILE MESSAGE IS ISSUED.
* THE FUNCTION *FINDHST* IS CALLED TO LOCATE THE HOST NAME
* *HOST*. IF NOT FOUND, A FALSE CONDITION IS RETURNED AND
* A DAYFILE MESSAGE IS ISSUED. ONCE THE HOST NAME IS
* LOCATED, THE FIRST ENTRY (IP ADDRESS) OF THE CURRENT LINE
* IS LOCATED. A SPACE IS ADDED TO THE END OF THE ENTRY TO
* MAKE SURE THE IP ADDRESS IS TERMINATED WITH A NON-NUMERIC.
* PROCEDURE *IPUCIAN* IS CALLED TO CONVERT THE DISPLAY CODED
* IP FORMATTED ADDRESS INTO A NUMERIC FORMAT USED TO
* COMMUNICATE WITH THE CDCNET TCP/IP GATEWAY.
*
#
#
**** PROC IPUGHBN - XREF LIST
#
XREF
BEGIN
FUNC IATTACH I; # ATTACH A PERMANENT FILE #
FUNC IGET I; # GET A PERMANENT FILE #
PROC IPUCIAN; # CONVERT IP ADDRESS TO NUMERIC #
PROC IPUMCLR; # CLEAR MEMORY #
PROC MESSAGE; # MESSAGE MACRO #
PROC READC; # READ CODED LINE #
PROC RETERN; # RETURN A LOCAL FILE #
END
#
**
#
ITEM HOST C(30); # HOST NAME SEARCHING FOR #
ITEM HOSTUN C(10); # TCPHOST USERNAME #
ARRAY IPADDR [00:00] S(1);; # ADDRESS IN NUMERIC FORM #
ITEM DIND I; # DESTINATION INDEX #
ITEM EOL B; # END OF LINE INDICATOR #
ITEM HOSTNM C(30); # HOST NAME FROM FILE #
ITEM INDEX I; # LOOP INDEX #
ITEM RESULT I; # RESULT FROM *READC* MACRO #
ITEM SIND I; # SOURCE INDEX #
ARRAY FNFMSG [00:00] S(3);
BEGIN
ITEM FNF$MSG C(00,00,23) = ["TCPHOST FILE NOT FOUND."];
ITEM FNF$ZBYTE U(02,18,42) = [0];
END
ARRAY HNFMSG [00:00] S(5);
BEGIN
ITEM HNF$MSG C(00,00,46) =
["HOST XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX NOT FOUND."];
ITEM HNF$HOST C(00,30,30);
ITEM HNF$ZBYTE U(04,36,24) = [0];
END
CONTROL EJECT;
PROC EXTHOST;
BEGIN # EXTHOST #
#
**** THIS PROCEDURE EXTRACTS A HOST NAME FROM A LINE OF DATA. THE
* THE HOST NAME IS PUT IN UPPERCASE DISPLAY.
*
#
ITEM SCHAR C(1); # CHARACTER READ FROM FILE #
HOSTNM = CHARSP$;
SCHAR = C<SIND,1>WORK$CHAR [0];
FOR INDEX = 0
WHILE (SCHAR NQ CHARSP$)
DO
BEGIN # EXAMINE LINE OF DATA READ #
IF SCHAR EQ ESC76$
THEN
BEGIN
IF (C<SIND+1,1>WORK$CHAR [0] GQ CHARA$) OR
(C<SIND+1,1>WORK$CHAR [0] LQ CHARZ$)
THEN
BEGIN # CONVERT TO UPPER CASE #
SIND = SIND + 1;
SCHAR = C<SIND,1>WORK$CHAR [0];
END
END
ELSE IF SCHAR EQ CHARNSIGN$
THEN
BEGIN # COMMENT TREATED AS END OF LINE#
EOL = TRUE;
RETURN;
END
ELSE IF SCHAR EQ CHARNUL$
THEN
BEGIN # CHECK FOR END OF LINE #
IF C<SIND+1,1>WORK$CHAR [0] EQ CHARNUL$
THEN
BEGIN
EOL = TRUE;
RETURN;
END
END
IF DIND LS HOSTSIZE$
THEN
BEGIN
C<DIND,1>HOSTNM = SCHAR;
DIND = DIND + 1;
END
SIND = SIND + 1;
SCHAR = C<SIND,1>WORK$CHAR [0];
END # EXAMINE LINE OF DATA READ #
SIND = SIND + 1; # NEXT CHARACTER IN LINE #
RETURN;
END # EXTHOST #
CONTROL EJECT;
FUNC FINDHST B;
BEGIN # FINDHST #
#
**** THIS FUNCTION SEARCHES THE TCPHOST FILE FOR AN ENTRY MATCHING THE
* SPECIFIED HOST NAME. IF FOUND, A TRUE RESULT IS RETURNED AND THE
* PROCEDURE TERMINATES.
*
#
ITEM INDEX1 I; # LOOP INDEX #
ITEM INDEX2 I; # LOOP INDEX #
FINDHST = FALSE; # DEFAULT TO NOT FOUND #
FET$STAT[0] = 1; # CLEAR STATUS + SET COMPLETION #
READC (FET [0], WORKBUF [0], WORKSIZ$, RESULT);# READ FIRST LINE #
FOR INDEX1 = 0
WHILE (RESULT EQ 0)
DO
BEGIN # LOOP TILL MATCH OR END #
SIND = 0; # INITIALIZE SOURCE INDEX #
EOL = FALSE;
FOR INDEX2 = 0 WHILE (NOT EOL)
DO
BEGIN # LOOP TILL END OF LINE OR MATCH#
DIND = 0; # DESTINATION INDEX #
EXTHOST;
IF DIND GR 0
THEN
BEGIN # HOST NAME ASSEMBLED #
IF (C<0,HOSTSIZE$>HOSTNM EQ C<0,HOSTSIZE$>HOST)
THEN
BEGIN # HOST NAME FOUND #
FINDHST = TRUE;
RETURN;
END
END
END # LOOP TILL END OF LINE OR MATCH#
#
**** IF MATCH NOT FOUND THEN READ NEXT LINE OF HOST NAME FILE.
#
READC (FET [0], WORKBUF [0], WORKSIZ$, RESULT);# READ LINE #
END # LOOP TILL MATCH OR END #
RETURN; # RETURN TO CALLER #
END # FINDHST #
CONTROL EJECT;
#
**** START MAIN PROCEDURE
#
IPUGHBN = FALSE; # HOST FILE/NAME NOT FOUND #
#
**** INITIALIZE THE FET ENTRY.
#
IPUMCLR (LOC (FET [0]), FETSIZ$); # CLEAR FET LOCATION #
FET$LFN [0] = TCPHFN$; # SET LOCAL FILE NAME #
FET$COMPB [0] = TRUE; # SET COMPLETION BIT #
FET$EP [0] = TRUE; # SET ERROR PROCESSING BIT #
FET$LEN [0] = FETSIZ$ - 5; # SET FET SIZE - 5 WORDS #
FET$FIRST [0] = LOC (CIOBUF [0]); # SET FIRST ADDRESS #
FET$IN [0] = FET$FIRST [0]; # SET IN ADDRESS #
FET$OUT [0] = FET$FIRST [0]; # SET OUT ADDRESS #
FET$LIMIT [0] = FET$FIRST [0] + FBUFSIZ$;# SET LIMIT ADDRESS #
FET$UN [0] = HOSTUN;
#
**** ATTEMPT TO ACCESS HOST NAME FILE.
#
IF IGET(FET[0]) NQ 0
THEN
BEGIN # COULD NOT GET HOST NAME FILE #
IF IATTACH(FET[0]) NQ 0
THEN
BEGIN # COULD NOT ATTACH HOST FILE #
MESSAGE(FNFMSG, 0); # ISSUE DAYFILE MESSAGE #
RETURN;
END
END # COULD NOT GET HOST NAME FILE #
#
**** FIND IP ADDRESS FOR SPECIFIED HOST NAME.
#
IF NOT FINDHST
THEN
BEGIN # HOST NAME SPECIFIED UNKNOWN #
HNF$HOST [0] = HOST;
MESSAGE (HNFMSG [0], 0); # ISSUE DAYFILE MESSAGE #
END
ELSE
#
**** CONVERT DISPLAY CODE FORM OF IP ADDRESS INTO INTERNET FORMAT AND
* STORE INTO IPADDRESS. SET RETURN STATUS TO HOST NAME FOUND.
#
BEGIN # HOST NAME KNOWN #
DIND = 0;
SIND = 0;
FOR INDEX = 0 WHILE (DIND EQ 0)
DO
BEGIN # EXTRACT HOST ADD IN DISPLAY #
EXTHOST;
END
C<DIND,1>HOSTNM = CHARSP$; # ADD TERMINATING SPACE TO ADDR #
IPUCIAN (HOSTNM, IPADDR); # CONVERT IP ADDRESS TO NUMERIC #
IPUGHBN = TRUE; # HOST NAME FOUND #
END # HOST NAME KNOWN #
RETERN (FET[0]); # RETURN HOST NAME FILE #
END # IPUGHBN #
TERM