User Tools

Site Tools


cdc:nos2.source:nam5871:ipughbn

IPUGHBN

Table Of Contents

  • [00003] FUNC IPUGHBN (HOST, IPADDR, HOSTUN) B
  • [00005] IPUGHBN - GET HOST BY NAME.
  • [00046] FUNC IATTACH I
  • [00047] FUNC IGET I
  • [00048] PROC IPUCIAN
  • [00049] PROC IPUMCLR
  • [00050] PROC MESSAGE
  • [00051] PROC READC
  • [00052] PROC RETERN
  • [00083] PROC EXTHOST
  • [00145] FUNC FINDHST B

Source Code

IPUGHBN.txt
  1. *DECK IPUGHBN
  2. USETEXT TEXTIPL
  3. FUNC IPUGHBN (HOST, IPADDR, HOSTUN) B;
  4. *CALL COPYRITE CDCNET - COPYRIGHT CONTROL DATA. 1992.
  5. # TITLE IPUGHBN - GET HOST BY NAME. #
  6.  
  7. BEGIN # IPUGHBN #
  8. #
  9. **** IPUGHBN - GET HOST BY NAME.
  10. *
  11. * THIS FUNCTION READS THE TCP HOST FILE, AND EXTRACTS THE IP
  12. * ADDRESS OF THE SUPPLIED HOST NAME. THE FUNCTION RETURNS TRUE IF
  13. * THE HOST WAS FOUND.
  14. *
  15. * FUNC IPUGHBN (HOST, IPADDR, HOSTUN)
  16. *
  17. * ENTRY HOST = 2 WORD HOST NAME, DISPLAY CODE,
  18. * LEFT JUSTIFIED.
  19. * HOSTUN = TCPHOST USERNAME, DISPLAY CODE,
  20. * LEFT JUSTIFIED.
  21. *
  22. * EXIT IPUGHBN = TRUE IF HOST NAME FOUND.
  23. * IPADDR = 3 WORD ADDRESS ARRAY.
  24. *
  25. * METHOD THE FET IS INITIALIZED AND THE FILE IS ATTACHED. BOTH
  26. * A INDIRECT ACCESS FILE AND A DIRECT ACCESS FILE IS
  27. * SEARCHED FOR. IF THE HOST FILE IS NOT FOUND, THE FUCTION
  28. * RETURNS A FALSE CONDITION AND A DAYFILE MESSAGE IS ISSUED.
  29. * THE FUNCTION *FINDHST* IS CALLED TO LOCATE THE HOST NAME
  30. * *HOST*. IF NOT FOUND, A FALSE CONDITION IS RETURNED AND
  31. * A DAYFILE MESSAGE IS ISSUED. ONCE THE HOST NAME IS
  32. * LOCATED, THE FIRST ENTRY (IP ADDRESS) OF THE CURRENT LINE
  33. * IS LOCATED. A SPACE IS ADDED TO THE END OF THE ENTRY TO
  34. * MAKE SURE THE IP ADDRESS IS TERMINATED WITH A NON-NUMERIC.
  35. * PROCEDURE *IPUCIAN* IS CALLED TO CONVERT THE DISPLAY CODED
  36. * IP FORMATTED ADDRESS INTO A NUMERIC FORMAT USED TO
  37. * COMMUNICATE WITH THE CDCNET TCP/IP GATEWAY.
  38. *
  39. #
  40.  
  41. #
  42. **** PROC IPUGHBN - XREF LIST
  43. #
  44. XREF
  45. BEGIN
  46. FUNC IATTACH I; # ATTACH A PERMANENT FILE #
  47. FUNC IGET I; # GET A PERMANENT FILE #
  48. PROC IPUCIAN; # CONVERT IP ADDRESS TO NUMERIC #
  49. PROC IPUMCLR; # CLEAR MEMORY #
  50. PROC MESSAGE; # MESSAGE MACRO #
  51. PROC READC; # READ CODED LINE #
  52. PROC RETERN; # RETURN A LOCAL FILE #
  53. END
  54. #
  55. **
  56. #
  57.  
  58. ITEM HOST C(30); # HOST NAME SEARCHING FOR #
  59. ITEM HOSTUN C(10); # TCPHOST USERNAME #
  60. ARRAY IPADDR [00:00] S(1);; # ADDRESS IN NUMERIC FORM #
  61.  
  62. ITEM DIND I; # DESTINATION INDEX #
  63. ITEM EOL B; # END OF LINE INDICATOR #
  64. ITEM HOSTNM C(30); # HOST NAME FROM FILE #
  65. ITEM INDEX I; # LOOP INDEX #
  66. ITEM RESULT I; # RESULT FROM *READC* MACRO #
  67. ITEM SIND I; # SOURCE INDEX #
  68.  
  69. ARRAY FNFMSG [00:00] S(3);
  70. BEGIN
  71. ITEM FNF$MSG C(00,00,23) = ["TCPHOST FILE NOT FOUND."];
  72. ITEM FNF$ZBYTE U(02,18,42) = [0];
  73. END
  74.  
  75. ARRAY HNFMSG [00:00] S(5);
  76. BEGIN
  77. ITEM HNF$MSG C(00,00,46) =
  78. ["HOST XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX NOT FOUND."];
  79. ITEM HNF$HOST C(00,30,30);
  80. ITEM HNF$ZBYTE U(04,36,24) = [0];
  81. END
  82. CONTROL EJECT;
  83. PROC EXTHOST;
  84. BEGIN # EXTHOST #
  85. #
  86. **** THIS PROCEDURE EXTRACTS A HOST NAME FROM A LINE OF DATA. THE
  87. * THE HOST NAME IS PUT IN UPPERCASE DISPLAY.
  88. *
  89. #
  90.  
  91. ITEM SCHAR C(1); # CHARACTER READ FROM FILE #
  92.  
  93. HOSTNM = CHARSP$;
  94. SCHAR = C<SIND,1>WORK$CHAR [0];
  95. FOR INDEX = 0
  96. WHILE (SCHAR NQ CHARSP$)
  97. DO
  98. BEGIN # EXAMINE LINE OF DATA READ #
  99. IF SCHAR EQ ESC76$
  100. THEN
  101. BEGIN
  102. IF (C<SIND+1,1>WORK$CHAR [0] GQ CHARA$) OR
  103. (C<SIND+1,1>WORK$CHAR [0] LQ CHARZ$)
  104. THEN
  105. BEGIN # CONVERT TO UPPER CASE #
  106. SIND = SIND + 1;
  107. SCHAR = C<SIND,1>WORK$CHAR [0];
  108. END
  109. END
  110.  
  111. ELSE IF SCHAR EQ CHARNSIGN$
  112. THEN
  113. BEGIN # COMMENT TREATED AS END OF LINE#
  114. EOL = TRUE;
  115. RETURN;
  116. END
  117.  
  118. ELSE IF SCHAR EQ CHARNUL$
  119. THEN
  120. BEGIN # CHECK FOR END OF LINE #
  121. IF C<SIND+1,1>WORK$CHAR [0] EQ CHARNUL$
  122. THEN
  123. BEGIN
  124. EOL = TRUE;
  125. RETURN;
  126. END
  127. END
  128.  
  129. IF DIND LS HOSTSIZE$
  130. THEN
  131. BEGIN
  132. C<DIND,1>HOSTNM = SCHAR;
  133. DIND = DIND + 1;
  134. END
  135.  
  136. SIND = SIND + 1;
  137. SCHAR = C<SIND,1>WORK$CHAR [0];
  138. END # EXAMINE LINE OF DATA READ #
  139.  
  140. SIND = SIND + 1; # NEXT CHARACTER IN LINE #
  141. RETURN;
  142.  
  143. END # EXTHOST #
  144. CONTROL EJECT;
  145. FUNC FINDHST B;
  146. BEGIN # FINDHST #
  147. #
  148. **** THIS FUNCTION SEARCHES THE TCPHOST FILE FOR AN ENTRY MATCHING THE
  149. * SPECIFIED HOST NAME. IF FOUND, A TRUE RESULT IS RETURNED AND THE
  150. * PROCEDURE TERMINATES.
  151. *
  152. #
  153. ITEM INDEX1 I; # LOOP INDEX #
  154. ITEM INDEX2 I; # LOOP INDEX #
  155.  
  156. FINDHST = FALSE; # DEFAULT TO NOT FOUND #
  157. FET$STAT[0] = 1; # CLEAR STATUS + SET COMPLETION #
  158.  
  159. READC (FET [0], WORKBUF [0], WORKSIZ$, RESULT);# READ FIRST LINE #
  160.  
  161. FOR INDEX1 = 0
  162. WHILE (RESULT EQ 0)
  163. DO
  164. BEGIN # LOOP TILL MATCH OR END #
  165. SIND = 0; # INITIALIZE SOURCE INDEX #
  166. EOL = FALSE;
  167. FOR INDEX2 = 0 WHILE (NOT EOL)
  168. DO
  169. BEGIN # LOOP TILL END OF LINE OR MATCH#
  170. DIND = 0; # DESTINATION INDEX #
  171. EXTHOST;
  172. IF DIND GR 0
  173. THEN
  174. BEGIN # HOST NAME ASSEMBLED #
  175. IF (C<0,HOSTSIZE$>HOSTNM EQ C<0,HOSTSIZE$>HOST)
  176. THEN
  177. BEGIN # HOST NAME FOUND #
  178. FINDHST = TRUE;
  179. RETURN;
  180. END
  181. END
  182. END # LOOP TILL END OF LINE OR MATCH#
  183. #
  184. **** IF MATCH NOT FOUND THEN READ NEXT LINE OF HOST NAME FILE.
  185. #
  186. READC (FET [0], WORKBUF [0], WORKSIZ$, RESULT);# READ LINE #
  187. END # LOOP TILL MATCH OR END #
  188.  
  189. RETURN; # RETURN TO CALLER #
  190.  
  191. END # FINDHST #
  192. CONTROL EJECT;
  193. #
  194. **** START MAIN PROCEDURE
  195. #
  196.  
  197. IPUGHBN = FALSE; # HOST FILE/NAME NOT FOUND #
  198.  
  199. #
  200. **** INITIALIZE THE FET ENTRY.
  201. #
  202.  
  203. IPUMCLR (LOC (FET [0]), FETSIZ$); # CLEAR FET LOCATION #
  204. FET$LFN [0] = TCPHFN$; # SET LOCAL FILE NAME #
  205. FET$COMPB [0] = TRUE; # SET COMPLETION BIT #
  206. FET$EP [0] = TRUE; # SET ERROR PROCESSING BIT #
  207. FET$LEN [0] = FETSIZ$ - 5; # SET FET SIZE - 5 WORDS #
  208. FET$FIRST [0] = LOC (CIOBUF [0]); # SET FIRST ADDRESS #
  209. FET$IN [0] = FET$FIRST [0]; # SET IN ADDRESS #
  210. FET$OUT [0] = FET$FIRST [0]; # SET OUT ADDRESS #
  211. FET$LIMIT [0] = FET$FIRST [0] + FBUFSIZ$;# SET LIMIT ADDRESS #
  212. FET$UN [0] = HOSTUN;
  213.  
  214. #
  215. **** ATTEMPT TO ACCESS HOST NAME FILE.
  216. #
  217.  
  218. IF IGET(FET[0]) NQ 0
  219. THEN
  220. BEGIN # COULD NOT GET HOST NAME FILE #
  221. IF IATTACH(FET[0]) NQ 0
  222. THEN
  223. BEGIN # COULD NOT ATTACH HOST FILE #
  224. MESSAGE(FNFMSG, 0); # ISSUE DAYFILE MESSAGE #
  225. RETURN;
  226. END
  227. END # COULD NOT GET HOST NAME FILE #
  228. #
  229. **** FIND IP ADDRESS FOR SPECIFIED HOST NAME.
  230. #
  231.  
  232. IF NOT FINDHST
  233. THEN
  234. BEGIN # HOST NAME SPECIFIED UNKNOWN #
  235. HNF$HOST [0] = HOST;
  236. MESSAGE (HNFMSG [0], 0); # ISSUE DAYFILE MESSAGE #
  237. END
  238. ELSE
  239.  
  240. #
  241. **** CONVERT DISPLAY CODE FORM OF IP ADDRESS INTO INTERNET FORMAT AND
  242. * STORE INTO IPADDRESS. SET RETURN STATUS TO HOST NAME FOUND.
  243. #
  244.  
  245. BEGIN # HOST NAME KNOWN #
  246. DIND = 0;
  247. SIND = 0;
  248. FOR INDEX = 0 WHILE (DIND EQ 0)
  249. DO
  250. BEGIN # EXTRACT HOST ADD IN DISPLAY #
  251. EXTHOST;
  252. END
  253.  
  254. C<DIND,1>HOSTNM = CHARSP$; # ADD TERMINATING SPACE TO ADDR #
  255.  
  256. IPUCIAN (HOSTNM, IPADDR); # CONVERT IP ADDRESS TO NUMERIC #
  257.  
  258. IPUGHBN = TRUE; # HOST NAME FOUND #
  259.  
  260. END # HOST NAME KNOWN #
  261.  
  262. RETERN (FET[0]); # RETURN HOST NAME FILE #
  263. END # IPUGHBN #
  264.  
  265. TERM
cdc/nos2.source/nam5871/ipughbn.txt ยท Last modified: 2023/08/05 17:22 by Site Administrator