User Tools

Site Tools


cdc:nos2.source:nam5871:ns_hcp

NS$HCP

Table Of Contents

  • [00009] PROC NS$HCP(CMDTEXT,(CC),ERRCODE,KC)
  • [00011] NS$HCP - HOP COMMAND PROCESSOR.
  • [00015] HOP COMMAND PROCESSOR.
  • [00059] PROC NS$DBG
  • [00065] PROC EXREDUC
  • [00066] PROC MOVEI
  • [00067] PROC MOVEOK
  • [00068] FUNC NS$FEC U
  • [00069] PROC NS$MSG
  • [00070] PROC NS$TKD
  • [00071] PROC TSBINFO

Source Code

NS$HCP.txt
  1. *DECK NS$HCP
  2. USETEXT COM$NS
  3. USETEXT DEF$NS
  4. USETEXT ERR$NS
  5. USETEXT HOC$NS
  6. USETEXT KDS$NS
  7. USETEXT LIN$NS
  8. USETEXT SMB$NS
  9. PROC NS$HCP(CMDTEXT,(CC),ERRCODE,KC); # HOP COMMAND PREPROCESSOR #
  10.  
  11. # TITLE NS$HCP - HOP COMMAND PROCESSOR. #
  12.  
  13. BEGIN # NS$HCP #
  14. #
  15. ** NS$HCP - HOP COMMAND PROCESSOR.
  16. *
  17. * J.C. LEE 1981
  18. *
  19. * THIS ROUTINE PROCESS ALL HOP COMMANDS.
  20. *
  21. * PROC NS$HCP(CMDTEXT,(CC),ERRCODE,KC)
  22. *
  23. * ENTRY:
  24. * CMDTEXT = HOP COMMAND TEXT
  25. * CC = CHARACTER COUNT OF TEXT.
  26. *
  27. * EXIT:
  28. * ERRCODE = ERROR CODE VALUE.
  29. * KC = HOP COMMAND ERROR REASON CODE.
  30. *
  31. * METHOD:
  32. * SAVE HOP COMMAND TEXT IN LOCAL ARRAY AND ZERO FILLED LAST
  33. * WORD OF COMMAND TEXT.
  34. * IF K-DISPLAY NOT ASSIGNED, FLAG ERROR AND EXIT.
  35. * DISCARD LINES CURRENTLY QUEUED IN PAGE-WAIT BUFFER.
  36. * ECHO HOP COMMAND BACK TO K-DISPLAY.
  37. * TOKENIZE HOP COMMAND AND PERFORM SYNTAX CHECKING.
  38. * IF PASSED SYNTAX CHECKING, PROCEED TO RECOGNIZE THE COMMAND.
  39. * IF VALID COMMAND VERB FOUND, PROCEED TO VALIDATE HOP COMMAND
  40. * PARAMETERS.
  41. * IF PASSED ALL CHECKINGS, PUT PARAMETERIZED COMMAND IN
  42. * COMMON BLOCK.
  43. * IN ALL CASES, IF ERROR DETECTED, FLAG ERRCODE AND KC,
  44. * AND EXIT.
  45. *
  46. #
  47.  
  48. ARRAY CMDTEXT; # HOP COMMAND TEXT #
  49. BEGIN
  50. ITEM CMDTXTWORD U(00,00,60);
  51. END
  52. ITEM CC U; # COMMAND TEXT DISPLAY CODE CHAR COUNT #
  53. ITEM ERRCODE U; # ERROR CODE VALUE #
  54. ITEM KC U; # HOP COMMAND ERROR REASON CODE #
  55.  
  56. $BEGIN
  57. XREF
  58. BEGIN
  59. PROC NS$DBG; # TRACE CALL #
  60. END
  61. $END
  62.  
  63. XREF
  64. BEGIN
  65. PROC EXREDUC; # REDUCE TSB SIZE #
  66. PROC MOVEI; # MOVE DATA #
  67. PROC MOVEOK; # ALLOW TSB TO MOVE #
  68. FUNC NS$FEC U; # FORMAT ERROR CODE #
  69. PROC NS$MSG; # DISPATCH MESSAGE #
  70. PROC NS$TKD; # TRANSFER DATA TO K DISPLAY BUFFER #
  71. PROC TSBINFO; # LOCATE TSB #
  72. END
  73.  
  74. DEF CHAR$A # O"01" #; # ALPHA A #
  75. DEF CHAR$9 # O"44" #; # NUMERAL 9 #
  76. DEF CHAR$COMMA # O"56" #; # COMMA #
  77. DEF CHAR$EQUAL # O"54" #; # EQUAL #
  78. DEF CHAR$TERM # O"57" #; # PERIOD #
  79.  
  80. ITEM BLANK C(7) = " ";
  81. ITEM CHAR U; # HOP COMMAND TEXT CHARACTER #
  82. ITEM CMDORDINAL U; # HOP COMMAND ORDINAL #
  83. ITEM CNT U; # TOKEN COUNT #
  84. ITEM COUNT U; # TOKEN CHARACTER COUNT #
  85. ITEM DONE B; # DONE FLAG #
  86. ITEM I I; # LOOP VARIABLE #
  87. ITEM INDEX U; # INDEX #
  88. ITEM J I; # LOOP VARIABLE #
  89. ITEM K I; # TEMPORARY #
  90. ITEM M I; # TEMPORARY #
  91. ITEM PWBTSBN U; # PAGE WAIT BUFFER TSB NUMBER #
  92. ITEM TEMP U; # TEMPORARY #
  93. ITEM TLC U; # TEXT LENGTH IN CHARACTERS #
  94. ITEM TLW U; # TEXT LENGTH IN WORDS #
  95. ITEM TSBFWA U; # TSB FWA #
  96. ITEM TSBSIZE U; # TSB SIZE #
  97.  
  98. DEF MAX$CMDKEY # 8 #; # MAX HOP COMMAND VERBS ALLOWED #
  99. ARRAY HOPCMDVERB[1:MAX$CMDKEY]S(1);
  100. BEGIN # VALID HOP COMMAND VERB TABLE #
  101. ITEM HC$KEYWORD C(0,0,8) = [ # VALID COMMAND VERB #
  102. "STATUS",
  103. "ST",
  104. "HISTORY",
  105. "HI",
  106. "FILE",
  107. "FI",
  108. "NOFILE",
  109. "NO",
  110. ];
  111. ITEM HC$ORDINAL S:HCT(0,48,12) = [ #CORR CMD ORDINAL #
  112. S"CMD$STATUS",
  113. S"CMD$STATUS",
  114. S"CMD$HIST",
  115. S"CMD$HIST",
  116. S"CMD$FILE",
  117. S"CMD$FILE",
  118. S"CMD$NOFILE",
  119. S"CMD$NOFILE",
  120. ];
  121. END
  122.  
  123. DEF MAX$CMDPRM # 9 #; # MAX HOP COMMAND PARAMETERS ALLOWED #
  124. ARRAY HOPCMDPARM[1:MAX$CMDPRM]S(1);
  125. BEGIN # VALID HOP COMMAND PARAMETER TABLE #
  126. ITEM HCP$PARAM C(0,0,8) = [ # VALID HOP CMD PARAMETERS #
  127. "NPU =",
  128. "NP =",
  129. "ALL",
  130. "NLF =",
  131. "NL =",
  132. "UN =",
  133. "PW =",
  134. "NPUS",
  135. "NPS",
  136. ];
  137. ITEM HCP$SEPAR C(0,42,1); # SEPARATOR CHARACTER #
  138. ITEM HCP$PARORD U(0,48,12) = [ # CORR PARAMETER ORD #
  139. PAR$NPU,
  140. PAR$NPU,
  141. PAR$ALL,
  142. PAR$NLF,
  143. PAR$NLF,
  144. PAR$UN,
  145. PAR$PW,
  146. PAR$NPUS,
  147. PAR$NPUS,
  148. ];
  149. END
  150.  
  151. DEF L$TOKENTAB # 10 #; # SIZE OF TOKEN TABLE #
  152. ARRAY TOKENTAB[0:L$TOKENTAB]S(1);
  153. BEGIN # TABLE OF HOP COMMAND TOKENS/SEPARATORS #
  154. ITEM TT$WORD C(0,0,10); # WHOLE WORD #
  155. ITEM TT$TCOUNT U(0,0,60); # TOKEN COUNT #
  156. ITEM TT$TOKEN C(0,0,8); # TOKEN PLUS SEPARATOR #
  157. ITEM TT$ATOKEN C(0,0,7); # TOKEN #
  158. ITEM TT$SEP C(0,42,1); # SEPARATOR #
  159. END
  160.  
  161. ARRAY VALIDPARAM [HCT"CMD$STATUS":HCT"CMD$NOFILE"] S(1);
  162. BEGIN # MAP OF VALID PARAMETER FOR EACH HOP COMMAND #
  163. #
  164.   A TRUE SETTING INDICATES THE CORRESPONDING PARAMETER IS VALID
  165.   FOR THE COMMAND,
  166.   VALIDPARAM[1] IS FOR STATUS COMMAND
  167.   VALIDPARAM[2] IS FOR HISTORY COMMAND
  168.   VALIDPARAM[3] IS FOR FILE COMMMAND
  169.   VALIDPARAM[4] IS FOR NOFILE COMMAND
  170. #
  171. ITEM PARM$NPU U(00,01,01) = [1,0,1,0]; # NPU= PARAMETER #
  172. ITEM PARM$ALL U(00,02,01) = [0,1,0,0]; # ALL PARAMETER #
  173. ITEM PARM$NLF U(00,03,01) = [0,0,1,0]; # NLF PARAMETER #
  174. ITEM PARM$UN U(00,04,01) = [0,0,1,0]; # UN PARAMETER #
  175. ITEM PARM$PW U(00,05,01) = [0,0,1,0]; # PW PARAMETER #
  176. ITEM PARM$NPUS U(00,06,01) = [1,0,0,0]; # NPUS PARAMETER #
  177. ITEM PARM$WORD U(00,00,60); # WHOLE WORD #
  178. END
  179.  
  180. ARRAY LINHEADER [0:0] S(LIN$HDRL);
  181. BEGIN # HOP COMMAND LINE HEADER #
  182. ITEM LINE$ID U(00,00,24);
  183. ITEM LINE$SIZE U(00,42,18);
  184. END
  185.  
  186. DEF MAX$CMDTLC # 50 #; # MAX COMMAND TEXT DISPLAY CODE CHARACTERS#
  187. DEF MAX$CMDTLW # 05 #; # MAX COMMAND TEXT LENGTH IN WORDS #
  188. ARRAY HCMDTEXT [0:MAX$CMDTLW] S(1);
  189. BEGIN # HOP COMMAND TEXT #
  190. ITEM HCMD$WORD U(00,00,60) = [MAX$CMDTLW(0)];
  191. END
  192.  
  193. CONTROL EJECT;
  194.  
  195. $BEGIN
  196. NS$DBG("HCP"); # TRACE CALL #
  197. $END
  198.  
  199. ERRCODE = 0;
  200. KC = 0;
  201. #
  202.   SAVE HOP COMMAND TEXT IN LOCAL ARRAY
  203. #
  204. IF MAX$CMDTLC LS CC
  205. THEN # COMMAND TEXT CHARACTER COUNT EXCEEEDS LIMIT #
  206. CC = MAX$CMDTLC; # SET CHARACTER COUNT TO LIMIT ALLOWED #
  207.  
  208. TLW = (CC+9)/10; # TEXT LENGTH IN CM WORDS #
  209. IF TLW EQ 0
  210. THEN # RECEIVED NO HOP COMMAND TEXT #
  211. TLW = 1; # SET TEXT LENGTH TO 1 TO GENERATE SYNTAX ERROR #
  212. ELSE # RECEIVED HOP COMMAND TEXT #
  213. MOVEI(TLW,LOC(CMDTEXT),LOC(HCMDTEXT)); # MOVE TEXT #
  214. K = (TLW*10) - CC;
  215. IF K NQ 0
  216. THEN # ZERO-FILLED LAST WORD OF COMMAND TEXT #
  217. B<(10-K)*6,K*6>HCMD$WORD[TLW-1] = 0;
  218. IF K LS 2
  219. THEN # ASSURE LINE TERMINATOR 6-66 BITS OF BINARY ZEROES #
  220. BEGIN
  221. HCMD$WORD[TLW] = 0;
  222. TLW = TLW + 1;
  223. END
  224.  
  225. IF DCW$F$ASS[0] # K DISPLAY IS ASSIGNED #
  226. AND DCW$F$IA[0] # AND INPUT IS ALLOWED #
  227. THEN
  228. BEGIN
  229. #
  230.   DISCARD LINES CURRENTLY QUEUED IN PAGE WAIT BUFFER
  231. #
  232. PWBTSBN = DCW$PWBTSB[0]; # PAGE WAIT BUFFER TSB NUMBER #
  233. TSBINFO(TSBSIZE,TSBFWA,PWBTSBN); # LOCATE PWB FWA #
  234. P<PWB$BUFFER> = 0;
  235. IF PWB$LC[TSBFWA] NQ 0
  236. THEN # LINES QUEUED IN PAGE WAIT BUFFER #
  237. BEGIN # DISCARD ALL LINES QUEUED #
  238. EXREDUC(PWB$WC[TSBFWA]-PWB$HDRL,PWBTSBN,FALSE,TSBFWA);
  239. PWB$LC[TSBFWA] = 0; # RESET LINE COUNT #
  240. PWB$WC[TSBFWA] = PWB$HDRL; # RESET WORD COUNT #
  241. END
  242.  
  243. MOVEOK(PWBTSBN); # ALLOW PAGE WAIT BUFFER TO MOVE #
  244. #
  245.   ECHO HOP COMMAND BACK TO K DISPLAY
  246. #
  247.  
  248. DCW$F$IA[0] = FALSE; # SET INPUT NOT ALLOWED #
  249. DCW$LC[0] =0; # RESET NAM K-DISPLAY LINE COUNT #
  250. P<LIN$HEADER> = LOC(LINHEADER); # FWA OF LINE HEADER #
  251. LIN$HDRWD[0] = 0;
  252. LIN$ID[0] = LIN$IDENT; # LINE IDENTIFIER #
  253. LIN$LNSIZE[0] = TLW + LIN$HDRL; # SET LINE SIZE OF HOP COMMAND #
  254. NS$TKD(LINHEADER,TLW+LIN$HDRL,1); # ECHO HOP COMMAND TO K DIS #
  255. #
  256.   TOKENIZE HOP COMMAND
  257. #
  258. COUNT = 0; # INITIALIZE CHARACTER COUNT OF TOKEN #
  259. CNT =0; # INITIALIZE TOKEN COUNT #
  260. INDEX = 0; # INITIALIZE WORD INDEX OF HOP COMMAND TEXT #
  261.  
  262. FOR I=0 STEP 1 UNTIL L$TOKENTAB
  263. DO # REINITIALIZE TOKEN TABLE #
  264. TT$WORD[I] = " ";
  265.  
  266. FOR I=0 STEP 1 WHILE I LS CC
  267. AND KC EQ 0 # NO ERROR OCCURRED #
  268. DO # UNPACK HOP COMMAND TEXT INTO TOKENS/SEPARATORS #
  269. BEGIN
  270.  
  271. J = I - (INDEX * 10); # BIT POSITION OF WORD #
  272. IF J GQ 10
  273. THEN # GO TO NEXT WORD OF HOP COMMAND TEXT #
  274. BEGIN
  275. INDEX = INDEX + 1;
  276. J = 0; # RESET BIT POSITION OF WORD #
  277. END
  278. CHAR = C<J,1>HCMD$WORD[INDEX]; # CURRENT CHARACTER #
  279.  
  280. IF CHAR GQ CHAR$A
  281. AND CHAR LQ CHAR$9
  282. THEN # CHARACTER IS ALPHANUMERIC #
  283. BEGIN # ASSEMBLE TOKEN #
  284.  
  285. IF CNT LS L$TOKENTAB # TOKEN COUNT WITHIN LIMIT #
  286. AND COUNT LS 7 # TOKEN CHARACTER COUNT OK #
  287. THEN
  288. BEGIN # ASSEMBLE CHARACTER INTO TOKEN #
  289. C<COUNT,1>TT$WORD[CNT+1] = CHAR;
  290. COUNT = COUNT + 1; # INCREMENT TOKEN CHARACTER COUNT #
  291. END
  292.  
  293. ELSE # BAD TOKEN, SYNTAX ERROR #
  294. KC = HOPCMDERR"SYNTAX";
  295. END
  296.  
  297. ELSE # CHARACTER IS NON-ALPHANUMERIC #
  298. BEGIN
  299.  
  300. IF CHAR EQ CHAR$COMMA
  301. OR CHAR EQ CHAR$EQUAL
  302. THEN # CHARACTER IS A LEGAL SEPARATOR #
  303. BEGIN
  304.  
  305. IF TT$WORD[CNT+1] NQ BLANK
  306. THEN # TOKEN EXISTS #
  307. BEGIN
  308. IF CHAR EQ CHAR$EQUAL
  309. THEN
  310. TT$SEP[CNT+1] = CHAR$EQUAL; # STORE EQUAL ONLY #
  311.  
  312. CNT = CNT + 1; # INCREMENT TOKEN COUNT #
  313. COUNT = 0; # RESET TOKEN CHARACTER COUNT #
  314. END
  315.  
  316. ELSE # TWO SEPARATORS IN A ROW #
  317. KC = HOPCMDERR"SYNTAX"; # HOP COMMAND SYNTAX ERROR #
  318. END
  319.  
  320. ELSE # CHARACTER NOT A SEPARATOR #
  321. BEGIN
  322. IF CHAR EQ CHAR$TERM
  323. THEN # ITS A PERIOD #
  324. I = CC; # TERMINATE UNPACKING COMMAND #
  325.  
  326. ELSE # ILLEGAL CHARACTER IN HOP COMMAND #
  327. KC = HOPCMDERR"SYNTAX";
  328. END
  329.  
  330. END
  331.  
  332. END # END I FOR LOOP #
  333.  
  334. IF KC EQ 0
  335. THEN
  336. BEGIN
  337. IF TT$WORD[CNT+1] NQ BLANK
  338. THEN # LAST TOKEN EXISTS #
  339. TT$TCOUNT[0] = CNT + 1; # SET TOKEN COUNT #
  340.  
  341. ELSE # HOP COMMAND NOT PROPERLY TERMINATED #
  342. KC = HOPCMDERR"SYNTAX";
  343. END
  344. #
  345.   RECOGNIZE HOP COMMAND
  346. #
  347. IF KC EQ 0
  348. THEN
  349. BEGIN
  350.  
  351. FOR I=0 STEP 1 UNTIL PAR$NPUS
  352. DO # CLEAR HOP COMMAND ARRAY IN COMMON #
  353. BEGIN
  354. CMD$WORD[I] = 0;
  355. END
  356.  
  357. DONE = FALSE;
  358. FOR I=1 STEP 1 WHILE I LQ MAX$CMDKEY
  359. AND NOT DONE
  360. DO # CHECK IF COMMAND VERB IS A VALID ONE #
  361. BEGIN
  362. IF HC$KEYWORD[I] EQ TT$TOKEN[1]
  363. THEN # MATCH WITH A VALID COMMAND VERB #
  364. BEGIN
  365. CMDORDINAL = HC$ORDINAL[I];
  366. CMD$ORD[0] = CMDORDINAL;
  367. DONE = TRUE;
  368. END
  369. END # END FOR LOOP #
  370.  
  371. IF DONE
  372. THEN # VALID COMMAND VERB FOUND, PROCEED #
  373. BEGIN # VALIDATE HOP COMMAND PARAMETERS #
  374. COUNT = TT$TCOUNT[0]; # TOKEN COUNT #
  375.  
  376. FOR I=2 STEP M+1 WHILE I LQ COUNT
  377. AND DONE
  378. DO
  379. BEGIN
  380. M = 0;
  381. DONE = FALSE;
  382.  
  383. FOR J=1 STEP 1 WHILE J LQ MAX$CMDPRM
  384. AND NOT DONE
  385. DO
  386. BEGIN # SCAN VALID PARAMETER LIST #
  387.  
  388. IF TT$TOKEN[I] EQ HCP$PARAM[J]
  389. THEN # PARAMETER MATCH #
  390. BEGIN # STORE VALID PARAMETER IN COMMON #
  391. K = HCP$PARORD[J]; # PARAMETER ORDINAL/BIT POSITION #
  392.  
  393. IF B<K,1>PARM$WORD[CMDORDINAL] NQ 0
  394. THEN # SIGN BIT SET #
  395. BEGIN # PARAMETER VALID FOR THIS COMMAND #
  396.  
  397. IF HCP$SEPAR[J] EQ CHAR$EQUAL
  398. THEN # NEXT TOKEN IS AN EQUATE VALUE #
  399. BEGIN # STORE VALUE IN HOPCOMMAND ARRAY #
  400. CMD$WORD[K] = TT$WORD[I+1];
  401. M =1; # INCREMENT STEP COUNT #
  402. END
  403.  
  404. ELSE
  405. CMD$WORD[K] = 1; # INDICATE PARAMETER SPECIFIED #
  406.  
  407. DONE = TRUE;
  408. END
  409. END
  410.  
  411. END # END J FOR LOOP #
  412.  
  413. END # END I FOR LOOP #
  414.  
  415. IF NOT DONE
  416. THEN # ERROR DETECTED IN HOP COMMAND PARAMETER #
  417. KC = HOPCMDERR"PARAMETER";
  418.  
  419. END
  420.  
  421. ELSE # ERROR DETECTED IN COMMAND VERB #
  422. KC = HOPCMDERR"CMDVERB";
  423.  
  424. END
  425.  
  426. IF KC EQ 0
  427. THEN # NO ERRORS DETECTED IN HOP COMMAND #
  428. BEGIN # LOG VALID COMMAND IN NETWORK LOG FILE #
  429. NS$MSG(HCMDTEXT, TLW, DM$NAMLOG+DM$HOPCMD+DM$LOCAL);
  430. END
  431.  
  432. END
  433.  
  434. ELSE # NAM ERROR, HOP/CMD NOT ALLOWED #
  435. ERRCODE = NS$FEC(EC"ERR$SM",SMEC"HSM$HOPSM");
  436.  
  437. RETURN;
  438. END # NS$HCP #
  439. TERM
cdc/nos2.source/nam5871/ns_hcp.txt ยท Last modified: 2023/08/05 17:22 by Site Administrator