home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / checkurl.zip / CHECKURL.CMD < prev    next >
OS/2 REXX Batch file  |  2002-02-22  |  73KB  |  3,079 lines

  1. /**+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+
  2. * Generator   : PPWIZARD version 02.038
  3. *             : FREE tool for Windows, OS/2, DOS and UNIX by Dennis Bareis (dbareis@labyrinth.net.au)
  4. *             : http://www.labyrinth.net.au/~dbareis/ppwizard.htm
  5. * Time        : Saturday, 23 Feb 2002 3:13:44pm
  6. * Input File  : C:\DBAREIS\PROJECTS\MultiOs\checkurl\checkurl.x
  7. * Output File : C:\DBAREIS\PROJECTS\MultiOs\checkurl\out\checkurl.rex
  8. *+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*/
  9.  
  10. if arg(1)="!CheckSyntax!" then exit(21924)
  11.  
  12. /*
  13. *$Header:C:/DBAREIS/Projects.PVCS/MultiOs/checkurl/checkurl.x.pvcs 1.3 23 Feb 2002 15:13:34 USER "Dennis" $
  14. */
  15. UserRequest=strip(arg(1))
  16. if translate(UserRequest)="DEBUG" then
  17. exit(0)
  18. trace off
  19. PgmVersion='02.054'
  20. LastLineWasBlank='Y'
  21. PragmaSrcUrl=";PRAGMA(URL_SOURCE)="
  22. ProcessingThisUrl=''
  23. DebugFileName=''
  24. IniFileName=''
  25. CopyrightDisplayed='N'
  26. Beep=d2c(7)
  27. Dying='N'
  28. CrLf='0D0A'x
  29. Cr='0D'x
  30. Lf='0A'x
  31. call SetupMovedText ""
  32. call SetupMovedText "Site Has Moved"
  33. call SetupMovedText "Document Has Moved"
  34. call SetupMovedText "Page Has Moved"
  35. call SetupMovedText "Page Now At"
  36. call SetupMovedText "Update all Links"
  37. call SetupMovedText "Update your Links"
  38. call SetupMovedText "We can't find your page"
  39. call SetupMovedText "Page no longer exists"
  40. /*
  41. *ADDCOMMA.XH Version 01.001 by Dennis Bareis
  42. *http://www.labyrinth.net.au/~dbareis/index.htm
  43. *dbareis@labyrinth.net.au
  44. */
  45. signal AddComma_1
  46.  
  47. AddCommasToDecimalNumber:
  48. parse arg a_PassedValue,a_MinDigits
  49. a_PassedValue=strip(a_PassedValue)
  50. if a_MinDigits='' then
  51. a_MinDigits=4
  52. parse var a_PassedValue a_Number 1 a_Integer . '.' +0 a_Fraction .
  53. if 0<>verify(strip(a_Number),'0123456789-+.') | ^Datatype(a_Number,'Number')then
  54. return(a_PassedValue)
  55. a_MaskCondensed='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWX'
  56. a_MaskSpread='abc,def,ghi,jkl,mno,pqr,stu,vwx,yzA,BCD,EFG,HIJ,KLM,NOP,QRS,TUV,WX'
  57. a_MaxDigits=length(a_MaskCondensed)
  58. a_Initial=substr(a_Integer,verify(a_Integer,'-+'),1)
  59. parse var a_Integer a_Sign (a_Initial) +0 a_Integer
  60. if length(a_Integer)<a_MinDigits then
  61. return(a_PassedValue)
  62. if length(a_Integer)>a_MaxDigits then
  63. return(a_PassedValue)
  64. return(a_Sign||strip(reverse(translate(a_MaskSpread,reverse(a_Integer),a_MaskCondensed, ',')), 'L', ',')||a_Fraction)
  65.  
  66. AddComma_1:
  67. /*
  68. *REXXTRAP.XH Version 99.287 by Dennis Bareis
  69. *http://www.labyrinth.net.au/~dbareis/index.htm(db0@anz.com)
  70. */
  71. signal on NOVALUE name _RexxTrapUninitializedVariable
  72. signal on SYNTAX name _RexxTrapSyntaxError
  73. /*
  74. *DUMPVAR.XH Version 02.036 by Dennis Bareis
  75. *http://www.labyrinth.net.au/~dbareis/index.htm(db0@anz.com)
  76. */
  77. /*
  78. *BIN2REXP.XH Version 99.134 by Dennis Bareis
  79. *http://www.labyrinth.net.au/~dbareis/index.htm(db0@anz.com)
  80. */
  81. b2rNewSingleQuote="' || " || '"' || "'" || '" || ' || "'"
  82. b2rAllHexCodes=''
  83. b2rAllAsciiCodes=''
  84. do b2rCharCode=0 to 31
  85. b2rAllHexCodes=b2rAllHexCodes||d2c(b2rCharCode)
  86. end
  87. do b2rCharCode=32 to 126
  88. b2rAllAsciiCodes=b2rAllAsciiCodes||d2c(b2rCharCode)
  89. end
  90. do b2rCharCode=127 to 255
  91. b2rAllHexCodes=b2rAllHexCodes||d2c(b2rCharCode)
  92. end
  93. signal EndBIN2REXPXh
  94.  
  95. _QuoteAscii:
  96. b2rAscii2Quote=arg(1)
  97. if pos("'",b2rAscii2Quote)=0 then
  98. return("'" || b2rAscii2Quote || "'")
  99. else
  100. do
  101. if pos('"',b2rAscii2Quote)=0 then
  102. return('"' || b2rAscii2Quote || '"')
  103. else
  104. do
  105. return("'" || ReplaceString(b2rAscii2Quote, "'", b2rNewSingleQuote) || "'")
  106. end
  107. end
  108.  
  109. _FormatHex:
  110. b2rHexString=arg(1)
  111. b2rLengthHex=length(b2rHexString)
  112. b2rFormattedHex="'"
  113. if b2rLengthHex>7 then
  114. do
  115. b2rLeft1=left(b2rHexString,1)
  116. b2rLeft1Pos=verify(b2rHexString,b2rLeft1)
  117. if b2rLeft1Pos=0 then
  118. return( "copies('" || c2x(b2rLeft1) || "'x, " || b2rLengthHex || ")" )
  119. else
  120. do
  121. if b2rLeft1Pos>7 then
  122. do
  123. b2rFormattedHex="copies('" || c2x(b2rLeft1) || "'x, " || b2rLeft1Pos-1 || ") || '"
  124. b2rHexString=substr(b2rHexString,b2rLeft1Pos)
  125. b2rLengthHex=b2rLengthHex-(b2rLeft1Pos-1)
  126. end
  127. end
  128. end
  129. do b2rCharPosn=1 to b2rLengthHex
  130. if(b2rCharPosn//8)=1 then
  131. do
  132. if b2rCharPosn<>1 then
  133. b2rFormattedHex=b2rFormattedHex|| ' '
  134. end
  135. b2rFormattedHex=b2rFormattedHex||c2x(substr(b2rHexString,b2rCharPosn,1))
  136. end
  137. b2rFormattedHex=b2rFormattedHex|| "'x"
  138. return(b2rFormattedHex)
  139.  
  140. _QuoteAsciiBreakIfRequired:
  141. qabAscii=arg(1)
  142. qabLength=length(qabAscii)
  143. qabReturn=''
  144. do while qabLength>256
  145. qabLeft=left(qabAscii,256)
  146. qabAscii=substr(qabAscii,256+1)
  147. qabLength=qabLength-256
  148. if qabReturn='' then
  149. qabReturn=_QuoteAscii(qabLeft)
  150. else
  151. qabReturn=qabReturn|| " || " ||_QuoteAscii(qabLeft)
  152. end
  153. if qabLength=0 then
  154. return(qabReturn)
  155. else
  156. do
  157. if qabReturn='' then
  158. return(_QuoteAscii(qabAscii))
  159. else
  160. return(qabReturn|| " || " ||_QuoteAscii(qabAscii))
  161. end
  162.  
  163. _FormatHexBreakIfRequired:
  164. fhbHex=arg(1)
  165. fhbLength=length(fhbHex)
  166. fhbReturn=''
  167. do while fhbLength>80
  168. fhbLeft=left(fhbHex,80)
  169. fhbHex=substr(fhbHex,80+1)
  170. fhbLength=fhbLength-80
  171. if fhbReturn='' then
  172. fhbReturn=_FormatHex(fhbLeft)
  173. else
  174. fhbReturn=fhbReturn|| " || " ||_FormatHex(fhbLeft)
  175. end
  176. if fhbLength=0 then
  177. return(fhbReturn)
  178. else
  179. do
  180. if fhbReturn='' then
  181. return(_FormatHex(fhbHex))
  182. else
  183. return(fhbReturn|| " || " ||_FormatHex(fhbHex))
  184. end
  185.  
  186. BIN2REXP:
  187. call BIN2REXP_START
  188. b2rValue=arg(1)
  189. b2rValueLength=length(b2rValue)
  190. if b2rValueLength=0 then
  191. call BIN2REXP_ONEBIT '""'
  192. else
  193. do
  194. do while b2rValue\==''
  195. b2rEndAsciiPos=verify(b2rValue,b2rAllAsciiCodes)
  196. if b2rEndAsciiPos=0 then
  197. do
  198. call BIN2REXP_ONEBIT _QuoteAsciiBreakIfRequired(b2rValue)
  199. b2rValue=''
  200. end
  201. else
  202. do
  203. if b2rEndAsciiPos<>1 then
  204. do
  205. call BIN2REXP_ONEBIT _QuoteAsciiBreakIfRequired(left(b2rValue,b2rEndAsciiPos-1))
  206. b2rValue=substr(b2rValue,b2rEndAsciiPos)
  207. end
  208. else
  209. do
  210. b2rEndBinaryPos=verify(b2rValue,b2rAllHexCodes)
  211. if b2rEndBinaryPos=0 then
  212. do
  213. call BIN2REXP_ONEBIT _FormatHexBreakIfRequired(b2rValue)
  214. b2rValue=''
  215. end
  216. else
  217. do
  218. call BIN2REXP_ONEBIT _FormatHexBreakIfRequired(left(b2rValue,b2rEndBinaryPos-1))
  219. b2rValue=substr(b2rValue,b2rEndBinaryPos)
  220. end
  221. end
  222. end
  223. end
  224. end
  225. call BIN2REXP_END
  226. return
  227.  
  228. EndBIN2REXPXh:
  229. signal EndDUMPVARXh
  230.  
  231. DumpVarsInExpression:
  232. dv_RexxExp=arg(1)
  233. dv_Stem=translate(arg(2))
  234. dv_VarHeading=arg(3)
  235. dv_LineRoutine=arg(4)
  236. if dv_Stem<> '' then
  237. do
  238. dv_AutoDump='N'
  239. dv_StemDot=dv_Stem|| '.'
  240. if symbol(dv_StemDot|| '0') = 'VAR' then
  241. dv_VarCount=value(dv_StemDot|| '0')
  242. else
  243. do
  244. call _DumpVarsLineOutput 'DumpVar: Could not find "' || dv_StemDot || '0' || '"'
  245. return(0)
  246. end
  247. end
  248. else
  249. do
  250. dv_AutoDump='Y'
  251. dv_Stem='DV_VARLIST'
  252. dv_StemDot=dv_Stem|| '.'
  253. dv_VarCount=0
  254. end
  255. if dv_VarCount=0 then
  256. dv_MaxVarLng=0
  257. do while dv_RexxExp<> ''
  258. parse value strip(dv_RexxExp, 'L')with dv_1stChar+1 dv_RexxExp
  259. select
  260. when datatype(dv_1stChar, 'S')then
  261. do
  262. dv_OneVar=dv_1stChar
  263. do while dv_RexxExp<> ''
  264. parse var dv_RexxExp dv_1stChar+1 dv_RexxExp
  265. if datatype(dv_1stChar, 'S')then
  266. dv_OneVar=dv_OneVar||dv_1stChar
  267. else
  268. do
  269. dv_RexxExp=dv_1stChar||dv_RexxExp
  270. leave
  271. end
  272. end
  273. call _RememberDumpedVar dv_OneVar
  274. if pos('.',dv_OneVar)<>0 then
  275. do
  276. do while dv_OneVar<> ''
  277. parse var dv_OneVar dv_ThisBit '.' dv_OneVar
  278. call _RememberDumpedVar dv_ThisBit
  279. end
  280. end
  281. end
  282. when dv_1stChar='"' | dv_1stChar = "'" then
  283. do
  284. dv_EndQuotePos=pos(dv_1stChar,dv_RexxExp)
  285. if dv_EndQuotePos=0 then
  286. dv_RexxExp=''
  287. else
  288. dv_RexxExp=substr(dv_RexxExp,dv_EndQuotePos+1)
  289. end
  290. otherwise
  291. nop
  292. end
  293. end
  294. call value dv_StemDot|| '0',dv_VarCount
  295. if dv_AutoDump='Y' then
  296. call DumpVarsInExpressionNow dv_Stem,dv_VarHeading,dv_LineRoutine
  297. return(dv_VarCount)
  298.  
  299. DumpVarsInExpressionNow:
  300. dv_StemDot=arg(1)|| '.'
  301. dv_VarHeading=arg(2)
  302. dv_LineRoutine=arg(3)
  303. if symbol(dv_StemDot|| '0') = 'VAR' then
  304. dv_VarCount=value(dv_StemDot|| '0')
  305. else
  306. do
  307. call _DumpVarsLineOutput 'DumpVar: could not find "' || dv_StemDot || '0' || '"'
  308. return(0)
  309. end
  310. if dv_VarCount<>0&dv_VarHeading<> '' then
  311. do
  312. call _DumpVarsLineOutput ''
  313. call _DumpVarsLineOutput dv_VarHeading
  314. call _DumpVarsLineOutput copies('~',length(dv_VarHeading))
  315. end
  316. dv_ShowVarLng=dv_MaxVarLng
  317. if dv_MaxVarLng>30 then
  318. dv_ShowVarLng=30
  319. do dv_Index=1 to dv_VarCount
  320. dv_OneVar=value(dv_StemDot||dv_Index)
  321. if length(dv_OneVar)>=dv_ShowVarLng then
  322. ShowVar=dv_OneVar
  323. else
  324. ShowVar=right(dv_OneVar,dv_ShowVarLng)
  325. dv_OneVarValue=value(translate(dv_OneVar))
  326. if datatype(dv_OneVarValue, 'N')=0 then
  327. do
  328. call BIN2REXP dv_OneVarValue
  329. dv_OneVarValue=dv_Value
  330. end
  331. call _DumpVarsLineOutput ShowVar|| ' = ' ||dv_OneVarValue
  332. end
  333. return
  334.  
  335. _RememberDumpedVar:
  336. dv_ThisVar=arg(1)
  337. if symbol(dv_ThisVar)='VAR' then
  338. do
  339. dv_AlreadyHave='N'
  340. dv_ThisVarUpper=translate(dv_ThisVar)
  341. do dv_Index=1 to dv_VarCount
  342. if dv_ThisVarUpper=translate(value(dv_StemDot||dv_Index))then
  343. do
  344. dv_AlreadyHave='Y'
  345. leave
  346. end
  347. end
  348. if dv_AlreadyHave='N' then
  349. do
  350. dv_VarCount=dv_VarCount+1
  351. call value dv_StemDot||dv_VarCount,dv_ThisVar
  352. if length(dv_ThisVar)>dv_MaxVarLng then
  353. dv_MaxVarLng=length(dv_ThisVar)
  354. end
  355. end
  356. return
  357.  
  358. _DumpVarsLineOutput:
  359. if dv_LineRoutine='' then
  360. say arg(1)
  361. else
  362. interpret 'call ' || dv_LineRoutine || ' arg(1)'
  363. return
  364.  
  365. BIN2REXP_START:
  366. dv_Value=''
  367. return
  368.  
  369. BIN2REXP_ONEBIT:
  370. if dv_Value<> '' then
  371. dv_Value=dv_Value|| ' || '
  372. dv_Value=dv_Value||arg(1)
  373. return
  374.  
  375. BIN2REXP_END:
  376. return
  377.  
  378. EndDUMPVARXh:
  379. signal RexxTrap_2
  380.  
  381. _FindLastLabel:
  382. FailedOnLine=arg(1)
  383. TryLine=FailedOnLine
  384. do while TryLine>1
  385. TryLine=TryLine-1
  386. TheLine=sourceline(TryLine)
  387. ColonPos=pos(':',TheLine)
  388. if ColonPos<>0 then
  389. do
  390. MaybeLabel=strip(left(TheLine,ColonPos-1))
  391. if symbol(MaybeLabel)<> 'BAD' then
  392. do
  393. FoundLabelOnLine=TryLine
  394. return(MaybeLabel|| ':  (line #' || AddCommasToDecimalNumber(TryLine) || ')')
  395. end
  396. end
  397. end
  398. FoundLabelOnLine=0
  399. return('')
  400.  
  401. TrapHeadingColonData:
  402. if arg(1)='' then
  403. TrapMiddle='  '
  404. else
  405. TrapMiddle=': '
  406. call SayAndDebugLine left(arg(1),16)||TrapMiddle||arg(2), '$S'
  407. return
  408.  
  409. _CommonTrapHandler:
  410. FailingLine=arg(1)
  411. TrapHeading='BUG: ' ||arg(2)
  412. TextDescription=arg(3)
  413. Text=arg(4)
  414. FailingLineText=AddCommasToDecimalNumber(FailingLine)
  415. call SayAndDebugLine copies('=+', 39), '$+'
  416. parse source . . SourceFileName
  417. call SayAndDebugLine TrapHeading, '$S'
  418. call SayAndDebugLine copies('~', length(TrapHeading)), '$S'
  419. call TrapHeadingColonData TextDescription,Text
  420. BettaOnRegina=condition('D')
  421. if BettaOnRegina<> '' &BettaOnRegina<>Text then
  422. call TrapHeadingColonData '',BettaOnRegina
  423. call RexxTrapAddInfo FailingLine
  424. parse version TheRexVer
  425. parse source TheOpSys .
  426. call TrapHeadingColonData "Environment", TheOpSys || ' using ' ||TheRexVer
  427. if pos('REGINA',translate(TheRexVer))<>0 then
  428. do
  429. call TrapHeadingColonData '',uname()
  430. end
  431. call TrapHeadingColonData "Failing Module",SourceFileName
  432. call TrapHeadingColonData "Failing Line #",FailingLineText
  433. InRoutine=_FindLastLabel(FailingLine)
  434. StartAt=(FailingLine-5)+1
  435. if FoundLabelOnLine<>0 then
  436. do
  437. if FoundLabelOnLine>StartAt then
  438. StartAt=FoundLabelOnLine
  439. else
  440. do
  441. if FoundLabelOnLine<>0 then
  442. do
  443. if(FailingLine-FoundLabelOnLine)<10 then
  444. StartAt=FoundLabelOnLine
  445. else
  446. call TrapHeadingColonData "After label",InRoutine
  447. end
  448. end
  449. end
  450. if StartAt<1 then
  451. StartAt=1
  452. call SayAndDebugLine '',       '$SH'
  453. call SayAndDebugLine 'SOURCE', '$SH'
  454. call SayAndDebugLine '~~~~~~', '$SH'
  455. vlist.0=0
  456. do ShowLine=StartAt to FailingLine
  457. FailingSrcLineTxt=strip(SourceLine(ShowLine))
  458. call SayAndDebugLine left(AddCommasToDecimalNumber(ShowLine),length(FailingLineText))|| ' : ' || FailingSrcLineTxt, '$SC'
  459. call DumpVarsInExpression FailingSrcLineTxt, 'vlist'
  460. end
  461. call DumpVarsInExpressionNow 'vlist', 'VARIABLE LIST', 'SayAndDebugLine'
  462. call SayAndDebugLine copies('=+', 39), '$+'
  463. call RexxTrapDying FailingLine
  464.  
  465. _RexxTrapSyntaxError:
  466. ReginaBug=SIGL
  467. call _CommonTrapHandler ReginaBug, 'SYNTAX ERROR!', 'Reason',errortext(Rc)
  468.  
  469. _RexxTrapUninitializedVariable:
  470. ReginaBug=SIGL
  471. call _CommonTrapHandler ReginaBug, 'UNKNOWN VARIABLE!', 'Unknown Variable', condition('D')
  472.  
  473. RexxTrap_2:
  474. signal on HALT name RexxCtrlC
  475. call DisplayCopyright
  476. /*
  477. *REXSYSTM.XH Version 02.034 By Dennis Bareis
  478. *http://www.labyrinth.net.au/~dbareis/index.htm(db0@anz.com)
  479. */
  480. trace off
  481. RexSystmRexxPgmName='?'
  482. if '1' == 'F1'x then
  483. RexIsAscii='N'
  484. else
  485. RexIsAscii='Y'
  486. parse version RexVersionInfo
  487. if pos('REGINA',translate(RexVersionInfo))<>0 then
  488. do
  489. RexWhich='REGINA'
  490. parse value translate(RexVersionInfo)with . 'REGINA_' RexVerRegina ' '
  491. RexVerRegina=translate(RexVerRegina, '.', '_')
  492. end
  493. else
  494. do
  495. RexVerRegina=''
  496. if pos('REXX370',translate(RexVersionInfo))<>0 then
  497. do
  498. RexWhich='REXX370'
  499. end
  500. else
  501. do
  502. RexWhich='STANDARD_OS/2'
  503. end
  504. end
  505. parse source RexSystemOpSys .
  506. RexSystemOpSysREAL=RexSystemOpSys
  507. if RexWhich='REGINA' then
  508. do
  509. if RexSystemOpSys="WIN32" then
  510. parse value uname()with RexSystemOpSysREAL .
  511. if RexSystemOpSys="UNIX" then
  512. parse value uname()with RexSystemOpSysREAL .
  513. end
  514. if RexSystemOpSys="BEOS" then
  515. RexSystemOpSys="UNIX"
  516. if RexSystemOpSys="TSO" then
  517. do
  518. call syscalls 'ON'
  519. RexSystemOpSys="UNIX"
  520. end
  521. RexSystmRexxPgmName=RexGetFullSourceName()
  522. if RexIsAscii='N' then
  523. do
  524. RexEOL='15'x
  525. end
  526. else
  527. do
  528. if RexSystemOpSys="UNIX" then
  529. RexEOL='0A'x
  530. else
  531. RexEOL='0D0A'x
  532. end
  533. if translate(strip(arg(1)))='DEBUG' then
  534. do
  535. call RexDumpSystemInfo
  536. exit(0)
  537. end
  538. if RexWhich='STANDARD_OS/2' then
  539. do
  540. call RxFuncAdd 'SysSleep',        'RexxUtil', 'SysSleep'
  541. call RxFuncAdd 'SysFileDelete',   'RexxUtil', 'SysFileDelete'
  542. call RxFuncAdd 'SysSearchPath',   'RexxUtil', 'SysSearchPath'
  543. call RxFuncAdd 'SysFileTree',     'RexxUtil', 'SysFileTree'
  544. call RxFuncAdd 'SysTempFileName', 'RexxUtil', 'SysTempFileName'
  545. call SetLocal
  546. RexEnvVarPool='OS2ENVIRONMENT'
  547. RexStdoutStream='STDOUT'
  548. RexStderrStream='STDERR'
  549. RexTmpFileCntr=random(90000)
  550. end
  551. else
  552. do
  553. OPTIONS 'NOEXT_COMMANDS_AS_FUNCS'
  554. numeric digits 11
  555. RexEnvVarPool='SYSTEM'
  556. RexStdoutStream='<stdout>'
  557. RexStderrStream='<stderr>'
  558. end
  559. if RexSystemOpSys<> "UNIX" then
  560. do
  561. RexDirChar='\'
  562. RexOptionChar='/'
  563. end
  564. else
  565. do
  566. RexDirChar='/'
  567. RexOptionChar='-'
  568. end
  569. signal REXSYSTM_3
  570.  
  571. RexDumpSystemInfo:
  572. say 'Program Name  : ' ||RexSystmRexxPgmName
  573. say 'Op System     : ' ||RexSystemOpSys
  574. say 'Rexx Ver      : ' ||RexVersionInfo
  575. say 'Which System  : ' ||RexWhich
  576. if RexWhich='REGINA' then
  577. say 'regina uname(): ' ||uname()
  578. return
  579.  
  580. RexNeedReginaWorkAround:
  581. if RexWhich='STANDARD_OS/2' then
  582. return('N')
  583. else
  584. return('Y')
  585.  
  586. RexGetFullSourceName:
  587. parse source . . TmpRexxSrc
  588. if RexWhich='REGINA' then
  589. TmpRexxSrc=FileQueryExists(strip(TmpRexxSrc))
  590. if RexSystemOpSysREAL="TSO" then
  591. do
  592. TmpRexxSrc=word(TmpRexxSrc,1)
  593. TmpRexxSrc=FileQueryExists(TmpRexxSrc)
  594. end
  595. return(TmpRexxSrc)
  596.  
  597. RexGetNameOfTmpDir:
  598. TmpDir=strip(GetEnv('TMP'))
  599. if TmpDir='' then
  600. TmpDir=strip(GetEnv('TEMP'))
  601. if TmpDir='' then
  602. do
  603. if RexSystemOpSys="UNIX" then
  604. TmpDir='/tmp'
  605. end
  606. if right(TmpDir,1)==RexDirChar then
  607. TmpDir=left(TmpDir,length(TmpDir)-1)
  608. if RexWhich='REXX370' then
  609. do
  610. if TmpDir="SYSTEM" then
  611. TmpDir="TMP"
  612. end
  613. return(TmpDir)
  614.  
  615. RedirectStdOutAndErr2:
  616. if RexSystemOpSys="DOS" | RexSystemOpSysREAL = "WIN95" | RexSystemOpSysREAL = "WIN98" | RexSystemOpSysREAL = "WINME" then
  617. do
  618. return(' >' ||arg(1))
  619. end
  620. else
  621. do
  622. return(' > "' || arg(1) || '" 2>&1')
  623. end
  624.  
  625. NameOfNulDevice:
  626. if RexSystemOpSys="UNIX" then
  627. return('/dev/null')
  628. else
  629. return('nul')
  630.  
  631. AllCmdOutput2Nul:
  632. return(RedirectStdOutAndErr2(NameOfNulDevice()))
  633.  
  634. AddressCmd:
  635. SysCmd2Exec=arg(1)
  636. if RexWhich='STANDARD_OS/2' then
  637. SysCmd2Exec='@' ||SysCmd2Exec
  638. call DebugAddressCmdBefore SysCmd2Exec
  639. SysCmd2Exec
  640. SysCmdRc=Rc
  641. FileIndex=2
  642. SysCmdFile=arg(FileIndex)
  643. do while SysCmdFile<> ''
  644. call DebugAddressCmdOutput SysCmdFile, 'H1'
  645. call DebugAddressCmdOutput copies('~', length(SysCmdFile)), 'H2'
  646. if FileQueryExists(SysCmdFile)='' then
  647. call DebugAddressCmdOutput '*File does not exist*',     '!'
  648. else
  649. do
  650. SysCmdLine=0
  651. call FileClose SysCmdFile
  652. do while lines(SysCmdFile)<>0
  653. SysCmdLine=SysCmdLine+1
  654. call DebugAddressCmdOutput linein(SysCmdFile),SysCmdLine
  655. end
  656. call FileClose SysCmdFile
  657. end
  658. FileIndex=FileIndex+1
  659. SysCmdFile=arg(FileIndex)
  660. end
  661. call DebugAddressCmdAfter SysCmdRc
  662. Rc=SysCmdRc
  663. return(SysCmdRc)
  664.  
  665. _filespec:
  666. fsCmd=translate(arg(1))
  667. select
  668. when fsCmd='D' | fsCmd = 'DRIVE' then
  669. do
  670. if RexSystemOpSys="UNIX" then
  671. return('')
  672. fsPos=pos(':',arg(2))
  673. if fsPos=0 then
  674. return('')
  675. else
  676. return(left(arg(2),fsPos))
  677. end
  678. when fsCmd='P' | fsCmd = 'PATH' then
  679. do
  680. fsStartWith=substr(arg(2),length(_filespec('D',arg(2)))+1)
  681. fsPos=lastpos(RexDirChar,fsStartWith)
  682. if fsPos=0 then
  683. return('')
  684. else
  685. return(left(fsStartWith,fsPos))
  686. end
  687. when fsCmd='N' | fsCmd = 'NAME' then
  688. do
  689. return(substr(arg(2),length(_filespec('L',arg(2)))+1))
  690. end
  691. when fsCmd='L' | fsCmd = 'LOCATION' then
  692. do
  693. return(_filespec('D', arg(2)) || _filespec('P',arg(2)))
  694. end
  695. when fsCmd='E' | fsCmd = 'EXTN' then
  696. do
  697. fsDotPos=lastpos('.',arg(2))
  698. if fsDotPos=0 then
  699. return('')
  700. else
  701. return(substr(arg(2),fsDotPos+1))
  702. end
  703. when fsCmd='W' | fsCmd = 'WITHOUTEXTN' then
  704. do
  705. fsDotPos=lastpos('.',arg(2))
  706. if fsDotPos=0 then
  707. return(arg(2))
  708. else
  709. return(left(arg(2),fsDotPos-1))
  710. end
  711. when fsCmd='B' | fsCmd = 'BASENAME' then
  712. do
  713. return(_filespec('W', _filespec('N',arg(2))))
  714. end
  715. otherwise
  716. end
  717. return
  718.  
  719. _SysFileTree:
  720. b_Mask=arg(1)
  721. b_Stem=arg(2)
  722. if pos('D',arg(3))<>0 then
  723. b_Type='D'
  724. else
  725. b_Type='F'
  726. if RexWhich='STANDARD_OS/2' then
  727. do
  728. b_P3=b_Type|| 'O'
  729. if pos('S',arg(3))<>0 then
  730. b_P3=b_P3|| 'S'
  731. return(SysFileTree(b_Mask,b_Stem,b_P3))
  732. end
  733. b_TmpFile=RexGetTmpFileName()
  734. if RexSystemOpSys<> "UNIX" then
  735. do
  736. b_Cmd='dir /B '
  737. if pos('S',arg(3))<>0 then
  738. b_Cmd=b_Cmd|| "/S "
  739. if b_Type='F' then
  740. b_Cmd=b_Cmd|| "/A-D "
  741. else
  742. b_Cmd=b_Cmd|| "/AD "
  743. if RexSystemOpSys="DOS" then
  744. b_CmdMask=b_Mask
  745. else
  746. b_CmdMask='"' || b_Mask || '"'
  747. b_Cmd=b_Cmd||b_CmdMask||RedirectStdOutAndErr2(b_TmpFile)
  748. end
  749. else
  750. do
  751. b_Cmd='find ' || _filespec('L', b_Mask) || ' '
  752. if RexSystemOpSysREAL<> "FREEBSD" & RexSystemOpSysREAL <> "Darwin" & RexSystemOpSysREAL <> "TSO" then
  753. b_Cmd=b_Cmd|| '-noleaf '
  754. if pos('S',arg(3))=0 then
  755. do
  756. if RexSystemOpSysREAL<> "FREEBSD" & RexSystemOpSysREAL <> "Darwin" & RexSystemOpSysREAL <> "TSO" then
  757. b_Cmd=b_Cmd|| '-maxdepth 1 '
  758. else
  759. b_Cmd=b_Cmd|| '-prune '
  760. end
  761. if b_Type='F' then
  762. b_Cmd=b_Cmd|| "-type f "
  763. else
  764. b_Cmd=b_Cmd|| "-type d "
  765. stfSName=_filespec('N',b_Mask)
  766. if stfSName<> '' then
  767. b_Cmd=b_Cmd|| '-name "' || stfSName || '"'
  768. b_Cmd=b_Cmd||RedirectStdOutAndErr2(b_TmpFile)
  769. end
  770. Rc=AddressCmd(b_Cmd,b_TmpFile)
  771. LastSlash=lastpos(RexDirChar,b_Mask)
  772. call FileClose b_TmpFile
  773. b_FileCnt=0
  774. do while lines(b_TmpFile)<>0
  775. b_AFile=linein(b_TmpFile)
  776. if b_AFile='' | b_AFile = '.' | b_AFile = '..' then
  777. iterate
  778. if RexSystemOpSys="UNIX" & b_Type = 'D' then
  779. do
  780. if b_AFile=_filespec('L',b_Mask)then
  781. iterate
  782. end
  783. if LastSlash<>0 then
  784. do
  785. if pos(RexDirChar,b_AFile)==0 then
  786. b_AFile=left(b_Mask,LastSlash)||b_AFile
  787. end
  788. if b_Type='F' then
  789. do
  790. b_AFile=FileQueryExists(b_AFile)
  791. if b_AFile='' then
  792. iterate
  793. end
  794. else
  795. do
  796. if RexWhich='REGINA' then
  797. do
  798. if DirQueryExists(b_AFile)='' then
  799. iterate
  800. end
  801. else
  802. do
  803. if pos(' ',b_AFile)<>0 then
  804. iterate
  805. end
  806. end
  807. b_FileCnt=b_FileCnt+1
  808. call _valueS b_Stem|| '.' ||b_FileCnt,strip(b_AFile)
  809. end
  810. call FileClose b_TmpFile
  811. DeleteRc=_SysFileDelete(b_TmpFile)
  812. call _valueS b_Stem|| '.0',b_FileCnt
  813. return(0)
  814.  
  815. _SysFileDelete:
  816. if RexWhich='STANDARD_OS/2' then
  817. return(SysFileDelete(arg(1)))
  818. c_F=arg(1)
  819. if RexSystemOpSys<> "DOS" then
  820. c_F='"' || c_F || '"'
  821. if RexSystemOpSys="DOS" | RexSystemOpSysREAL = "WIN95" | RexSystemOpSysREAL = "WIN98" | RexSystemOpSysREAL = "WINME" then
  822. return(AddressCmd('if exist ' || c_F || ' del ' ||c_F||AllCmdOutput2Nul()))
  823. else
  824. do
  825. if RexSystemOpSys="UNIX" then
  826. return(AddressCmd('rm -f ' ||c_F||AllCmdOutput2Nul()))
  827. else
  828. return(AddressCmd('del ' ||c_F||AllCmdOutput2Nul()))
  829. end
  830.  
  831. RexGetTmpFileName:
  832. if arg(1)<> '' then
  833. TmpFileM=arg(1)
  834. else
  835. do
  836. if RexSystemOpSys<> "UNIX" then
  837. TmpFileM='RSTM????.TMP'
  838. else
  839. do
  840. TmpFileM=GetEnv('USER')
  841. if TmpFileM='' then
  842. TmpFileM=GetEnv('user')
  843. if TmpFileM='' then
  844. TmpFileM='?????.rstm'
  845. else
  846. TmpFileM=TmpFileM|| '_?????.rstm'
  847. end
  848. end
  849. TmpFileM=RexGetNameOfTmpDir()||RexDirChar||TmpFileM
  850. if RexWhich='STANDARD_OS/2' then
  851. do
  852. TmpFileF=SysTempFileName(TmpFileM)
  853. if TmpFileF='' then
  854. do
  855. RexTmpFileCntr=RexTmpFileCntr+1
  856. TmpFileF='C_' || right(RexTmpFileCntr, 6, '0') || '.TMP'
  857. end
  858. return(TmpFileF)
  859. end
  860. TmpRandom=right(time('S'),3)||random(99999)
  861. TmpRandomAdd=0
  862. do until FileQueryExists(TmpFileA)=''
  863. TmpRandomS=reverse(d2x(TmpRandom+TmpRandomAdd))
  864. TmpRandomAdd=TmpRandomAdd+1
  865. TmpFileA=TmpFileM
  866. TmpWhich=1
  867. QmPos=pos('?',TmpFileA)
  868. do while QmPos<>0
  869. TmpReplace=substr(TmpRandomS,TmpWhich,1)
  870. TmpWhich=TmpWhich+1
  871. if TmpReplace='' then
  872. TmpWhich=1
  873. else
  874. do
  875. TmpFileA=overlay(TmpReplace,TmpFileA,QmPos)
  876. QmPos=pos('?',TmpFileA)
  877. end
  878. end
  879. end
  880. return(TmpFileA)
  881.  
  882. GetEnv:
  883. if RexWhich<> 'REXX370' then
  884. rsGetEnv=value(arg(1),,RexEnvVarPool)
  885. else
  886. do
  887. rsGetEnv=''
  888. end
  889. return(rsGetEnv)
  890.  
  891. _valueS:
  892. if RexWhich='STANDARD_OS/2' then
  893. return(value(arg(1),arg(2)))
  894. return(value(translate(arg(1)),arg(2)))
  895.  
  896. _valueG:
  897. if RexWhich='STANDARD_OS/2' then
  898. return(value(arg(1)))
  899. return(value(arg(1)))
  900. /*
  901.  * DB$STUBS - Keep indent (not so easy for comments)
  902.  *            for this bit until finished!
  903.  */
  904.  
  905. DirGetCurrent:
  906.    return( directory() )
  907.  
  908. DirQueryExists:
  909.    if  arg(1) = '' then
  910.        return('')
  911.    select
  912.        when RexWhich =  'REGINA' then
  913.        do
  914.            return( stream(arg(1) || '\.', 'c', 'query exists') )
  915.        end
  916.        when RexWhich =  'STANDARD_OS/2' then
  917.        do
  918.            d_CDir = directory()
  919.            d_NewDir = directory(arg(1))
  920.            call directory d_CDir
  921.            return(d_NewDir)
  922.        end
  923.        when RexWhich =  'REXX370' then
  924.        do
  925.            /* DB$390 - return passed name (BAD! - ppwizard might fail in parts)
  926.             */
  927.            return(arg(1))
  928.        end
  929.        otherwise
  930.        do
  931.            return(arg(1))
  932.        end
  933.    end
  934.  
  935. FileQueryExists:
  936.    if  arg(1) = '' then
  937.        return('')
  938.    if  RexWhich <> 'REXX370' then
  939.        return( stream(arg(1), 'c', 'query exists') )
  940.    else
  941.    do
  942.        /* DB$390 - return passed name (BAD! - ppwizard might fail in parts)
  943.        */
  944.        return(arg(1))
  945.    end
  946.  
  947. FileQueryDateTime:
  948.    if  RexWhich <> 'REXX370' then
  949.        return( stream(arg(1), 'c', 'query datetime') )
  950.    else
  951.    do
  952.        /* DB$390 - Return valid but fixed value
  953.        */
  954.        return('01-01-01 12:00:00')
  955.    end
  956.  
  957. FileQuerySize:
  958.    if  RexWhich <> 'REXX370' then
  959.        return( stream(arg(1), 'c', 'query size') )
  960.    else
  961.    do
  962.        /* DB$390 - Return valid but fixed value
  963.        */
  964.        return('219')
  965.    end
  966.  
  967. FileOpenReadOnly:
  968.    if  RexWhich <> 'REXX370' then
  969.        return( stream(arg(1), 'c', 'open read') )
  970.    else
  971.    do
  972.        /* DB$390 - For now do nothing (so file opens read/write - so what)
  973.        */
  974.        return('')
  975.    end
  976.  
  977. FileClose:
  978.    if  RexWhich <> 'REXX370' then
  979.        return( stream(arg(1), 'c', 'close') )
  980.    else
  981.    do
  982.        /* DB$390 - Worth a try
  983.        */
  984.        call lineout arg(1)
  985.        return('')
  986.    end
  987.  
  988. FileState:
  989.    if  RexWhich <> 'REXX370' then
  990.        return( stream(arg(1), 'State') )
  991.    else
  992.    do
  993.        /* DB$390 - Stream Description
  994.        */
  995.        return('')
  996.    end
  997.  
  998. FileDescription:
  999.    if  RexWhich <> 'REXX370' then
  1000.        return( stream(arg(1), 'Description') )
  1001.    else
  1002.    do
  1003.        /* DB$390 - Stream Description
  1004.        */
  1005.        return('')
  1006.    end
  1007. /*
  1008.    REXSYSTM.XH - a few stream there (need to move stubs there)
  1009.    DirMake
  1010.    FileCharin    ?
  1011.    FileCharout   ?
  1012.    FileLinein    ?
  1013.    FileLineOut   ?
  1014. */
  1015.  
  1016. REXSYSTM_3:
  1017. /*
  1018. *KEYEDVAR.XH Version 00.085 by Dennis Bareis
  1019. *http://www.labyrinth.net.au/~dbareis/index.htm(db0@anz.com)
  1020. */
  1021. RxKvMaxCheck=20000
  1022. RxKvStartIndex=1
  1023. RxKvOkIndex=1
  1024. RxKvStep=10000
  1025. do forever
  1026. do RxKvIndex=RxKvStartIndex to RxKvMaxCheck by RxKvStep
  1027. if symbol(copies('A', RxKvIndex)) = 'BAD' then
  1028. leave
  1029. else
  1030. RxKvOkIndex=RxKvIndex
  1031. end
  1032. if RxKvStep=1 then
  1033. leave
  1034. else
  1035. do
  1036. RxKvStartIndex=RxKvOkIndex
  1037. RxKvStep=RxKvStep%10
  1038. if RxKvStep=0 then
  1039. RxKvStep=1
  1040. end
  1041. end
  1042. RxKvTrunc2=RxKvOkIndex-10
  1043. signal EndKeyedVarXH
  1044.  
  1045. KeySaveInfo:
  1046. RxKvKeyVar='KV_' || c2x(arg(1)) || '?' ||c2x(arg(2))
  1047. if length(RxKvKeyVar)<=RxKvOkIndex then
  1048. call value RxKvKeyVar,arg(3)
  1049. else
  1050. do
  1051. RxKvStem='T' || left(RxKvKeyVar, RxKvTrunc2)    || '.'
  1052. RxKvRest=substr(RxKvKeyVar,RxKvTrunc2+1)
  1053. RxKv0V=RxKvStem|| '0'
  1054. if symbol(RxKv0V)<> 'VAR' then
  1055. do
  1056. call value RxKv0V,1
  1057. call value RxKvStem|| '1.0R',RxKvRest
  1058. call value RxKvStem|| '1.0D',arg(3)
  1059. end
  1060. else
  1061. do
  1062. RxKv0=value(RxKv0V)
  1063. RxKvFnd='N'
  1064. do RxKvIndex=1 to RxKv0
  1065. if value(RxKvStem||RxKvIndex|| '.0R')==RxKvRest then
  1066. do
  1067. RxKvFnd='Y'
  1068. RxKv0=RxKvIndex
  1069. end
  1070. end
  1071. if RxKvFnd='N' then
  1072. do
  1073. RxKv0=RxKv0+1
  1074. call value RxKv0V,RxKv0
  1075. call value RxKvStem||RxKv0|| '.0R',RxKvRest
  1076. end
  1077. call value RxKvStem||RxKv0|| '.0D',arg(3)
  1078. end
  1079. end
  1080. return("")
  1081.  
  1082. KeyGetInfo:
  1083. RxKvKeyVar='KV_' || c2x(arg(1)) || '?' ||c2x(arg(2))
  1084. if length(RxKvKeyVar)<=RxKvOkIndex then
  1085. do
  1086. if symbol(RxKvKeyVar)<> 'VAR' then
  1087. return("<KeyedVarUnknown>")
  1088. else
  1089. return(value(RxKvKeyVar))
  1090. end
  1091. else
  1092. do
  1093. RxKvStem='T' || left(RxKvKeyVar, RxKvTrunc2)    || '.'
  1094. RxKvRest=substr(RxKvKeyVar,RxKvTrunc2+1)
  1095. RxKv0V=RxKvStem|| '0'
  1096. if symbol(RxKv0V)<> 'VAR' then
  1097. return("<KeyedVarUnknown>")
  1098. else
  1099. do
  1100. RxKv0=value(RxKv0V)
  1101. do RxKvIndex=1 to RxKv0
  1102. if value(RxKvStem||RxKvIndex|| '.0R')==RxKvRest then
  1103. do
  1104. return(value(RxKvStem||RxKvIndex|| '.0D'))
  1105. end
  1106. end
  1107. return("<KeyedVarUnknown>")
  1108. end
  1109. end
  1110.  
  1111. EndKeyedVarXH:
  1112. DebugFileName=ReplaceAnyFileNameSymbols(GetEnv('CHECKURL_DEBUG'))
  1113. if left(DebugFileName,1)='+' then
  1114. DebugFileName=substr(DebugFileName,2)
  1115. else
  1116. do
  1117. if DebugFileName<> '' then
  1118. DosDelRc=CloseAndDeleteFile(DebugFileName)
  1119. end
  1120. call DebugLine ''
  1121. call DebugLine ''
  1122. call DebugLine copies('=',79)
  1123. call DebugLine '        Time: ' ||date()
  1124. call DebugLine 'Command Line: ' ||UserRequest
  1125. call DebugLine '   Op System: ' ||RexSystemOpSys
  1126. call DebugLine ' Interpreter: ' ||RexVersionInfo
  1127. call DebugLine copies('=',79)
  1128. call DebugLine ''
  1129. signal URLINHTM_4
  1130.  
  1131. CheckUrlsInHtml:
  1132. PgmRc=GetInputFilesMatchingMasks()
  1133. if PgmRc<> '' then
  1134. return(PgmRc)
  1135. Dangerous='"' || "'" ||d2c(9)||d2c(27)
  1136. UrlCount=0
  1137. do Index=1 to NumberFiles
  1138. UrlSourceFile=FileList.Index
  1139. LineNumber=0
  1140. Urls=0
  1141. CloseRc=stream(UrlSourceFile, 'c', 'close')
  1142. do while lines(UrlSourceFile)<>0
  1143. CurrentLine=linein(UrlSourceFile)
  1144. LineNumber=LineNumber+1
  1145. CurrentLine=translate(CurrentLine, '', Dangerous, ' ')
  1146. do WordIndex=1 to words(CurrentLine)
  1147. MaybeUrl=word(CurrentLine,WordIndex)
  1148. if abbrev(MaybeUrl, 'http://') | abbrev(MaybeUrl, 'ftp://')then
  1149. do
  1150. UrlCount=UrlCount+1
  1151. Url.UrlCount=MaybeUrl
  1152. UrlSrc.UrlCount=UrlSourceFile|| '(' || LineNumber || ')'
  1153. end
  1154. end
  1155. end
  1156. CloseRc=stream(UrlSourceFile, 'c', 'close')
  1157. end
  1158. Url.0=UrlCount
  1159. UrlSrc.0=UrlCount
  1160. call ProcessUrlArray
  1161. return(PgmRc)
  1162.  
  1163. URLINHTM_4:
  1164. /*
  1165. *BASEDATE.XH Version 01.081 by Dennis Bareis
  1166. *http://www.labyrinth.net.au/~dbareis/index.htm(dbareis@labyrinth.net.au)
  1167. */
  1168. signal EndBASEDATEXh
  1169.  
  1170. FileBaseDate:procedure
  1171. FileName=arg(1)
  1172. FileTime=stream(FileName, 'c', 'query datetime')
  1173. if FileTime='' then
  1174. return(-1)
  1175. FileTime=space(FileTime)
  1176. parse var FileTime Month'-'Day'-'Year' 'Rest
  1177. if Year<80 then
  1178. Year=100+Year
  1179. Year=1900+Year
  1180. return(BaseDate(Year||Month||Day))
  1181.  
  1182. BaseDate:procedure
  1183. TheDate=translate(arg(1), ' ', '/-')
  1184. if TheDate='' then
  1185. TheDate=date('Sorted')
  1186. parse var TheDate Year MM DD
  1187. if length(Year)>=8 then
  1188. do
  1189. DD=substr(Year,7,2)
  1190. MM=substr(Year,5,2)
  1191. Year=left(Year,4)
  1192. end
  1193. DaysInMonth='31  28  31  30  31  30  31  31  30  31  30  31'
  1194. if datatype(Year, 'WholeNumber')<>1 then
  1195. return(-10)
  1196. if datatype(MM, 'WholeNumber')<>1 then
  1197. return(-20)
  1198. if datatype(DD, 'WholeNumber')<>1 then
  1199. return(-30)
  1200. if MM<0|MM>12 then
  1201. return(-21)
  1202. DaysThisMonth=word(DaysInMonth,MM)
  1203. if MM=2 then
  1204. DaysThisMonth=DaysThisMonth+1
  1205. if DD<0|DD>DaysThisMonth then
  1206. return(-31)
  1207. if length(strip(Year))=2 then
  1208. do
  1209. if Year>=80 then
  1210. Year='19' ||Year
  1211. else
  1212. Year='20' ||Year
  1213. end
  1214. y=Year;m=MM;d=DD
  1215. z=y+(m-14)%12
  1216. f=word('306 337 0 31 61 92 122 153 184 214 245 275',m)
  1217. b=d+f+365*z+z%4-z%100+z%400-307
  1218. return(b)
  1219.  
  1220. BD2DATE:procedure
  1221. parse arg rd,Format,Delimiter
  1222. z=rd+307
  1223. h=100*z-25
  1224. a=h%3652425
  1225. b=a-a%4
  1226. year=(100*b+h)%36525
  1227. c=b+z-365*year-year%4
  1228. month=(5*c+456)%153
  1229. day=c-word('0 31 61 92 122 153 184 214 245 275 306 337',month-2)
  1230. if month>12 then
  1231. do
  1232. year=year+1
  1233. month=month-12
  1234. end
  1235. yyyy=right(year,4, '0')
  1236. mm=right(month,2, '0')
  1237. dd=right(day,2, '0')
  1238. return(yyyy||Delimiter||mm||Delimiter||dd)
  1239.  
  1240. EndBASEDATEXh:
  1241. /*
  1242. *FASTINI.XH Version 98.147 by Dennis Bareis
  1243. *http://www.labyrinth.net.au/~dbareis/index.htm(db0@anz.com)
  1244. */
  1245. _FiOpenCount=0
  1246. call RxFuncAdd 'FastIniStart',   'FastIni',  'FastIniStart'
  1247. call RxFuncAdd 'FastIniEnd',     'FastIni',  'FastIniEnd'
  1248. call RxFuncAdd 'FastIniVersion', 'FastIni',  'FastIniVersion'
  1249. _fiAvailable=_FastIniOk()
  1250. signal EndFASTINIXh
  1251.  
  1252. FastIniIsFast:
  1253. return(_fiAvailable)
  1254.  
  1255. FastIniOpenIni:
  1256. _fiFile=arg(1)
  1257. _fiHandleVar=arg(2)
  1258. if _fiAvailable='N' then
  1259. do
  1260. interpret _fiHandleVar|| ' = 0'
  1261. return('OK')
  1262. end
  1263. interpret _fiHandleVar|| ' = ""'
  1264. _fiFastRc=FastIniStart(_fiFile,_fiHandleVar)
  1265. interpret '_FiHandle = ' ||_fiHandleVar
  1266. if _FiHandle<> '' then
  1267. do
  1268. _FiOpenCount=_FiOpenCount+1
  1269. _FiOpenedList._FiOpenCount=_FiHandle
  1270. end
  1271. return(_fiFastRc)
  1272.  
  1273. FastIniCloseIni:
  1274. if _fiAvailable='N' then
  1275. return('OK')
  1276. return(FastIniEnd(arg(1)))
  1277.  
  1278. FastIniGetVersion:
  1279. if _fiAvailable='Y' then
  1280. return(FastIniVersion(arg(1)))
  1281. else
  1282. do
  1283. interpret arg(1)|| ' = "00.000 http://www.labyrinth.net.au/~dbareis/index.htm db0@anz.com Dennis Bareis"'
  1284. return('OK')
  1285. end
  1286.  
  1287. FastIniCleanup:
  1288. if _fiAvailable='N' then
  1289. return('OK')
  1290. do _fi=1 to _FiOpenCount
  1291. call FastIniEnd(_FiOpenedList._fi)
  1292. _FiOpenedList._fi=0
  1293. end
  1294. _FiOpenCount=0
  1295. return('OK')
  1296.  
  1297. _FastIniOk:
  1298. signal on SYNTAX name _FastIniNotOk
  1299. interpret "_fiRc = FastIniVersion('_fiVersion')"
  1300. return('Y')
  1301.  
  1302. _FastIniNotOk:
  1303. return('N')
  1304.  
  1305. EndFASTINIXh:
  1306. TryQuotes='"' || "'" ||xrange(d2c(127),d2c(255))||xrange(d2c(1),d2c(31))
  1307. UrlCount=0
  1308. UrlInfoNeedsWriting='N'
  1309. MemoryBackupLevel=3
  1310. signal MEMORY_5
  1311.  
  1312. GetQuotedText:
  1313. parse arg TheString,RestVarName
  1314. TheString=strip(TheString, 'L')
  1315. if TheString='' then
  1316. return('')
  1317. QuoteChar=left(TheString,1)
  1318. do
  1319. SecondQuotePosn=pos(QuoteChar,TheString,2)
  1320. if SecondQuotePosn=0 then
  1321. return('')
  1322. QuotedString=substr(TheString,2,SecondQuotePosn-2)
  1323. TheRest=substr(TheString,SecondQuotePosn+1)
  1324. end
  1325. TheRest=strip(TheRest, 'L')
  1326. if RestVarName<> '' then
  1327. call _valueS RestVarName,TheRest
  1328. return(QuotedString)
  1329.  
  1330. CreateUrl2IndexMapping:
  1331. call KeySaveInfo "U2I",arg(2),arg(1)
  1332. return
  1333.  
  1334. GetInfoIndex4Url:
  1335. giUrl=arg(1)
  1336. giAdding=arg(2)
  1337. giIndex=KeyGetInfo("U2I",giUrl)
  1338. if giIndex=="<KeyedVarUnknown>" then
  1339. do
  1340. if giAdding<> 'Y' then
  1341. giIndex=0
  1342. else
  1343. do
  1344. UrlIniCount=UrlIniCount+1
  1345. giIndex=UrlIniCount
  1346. call CreateUrl2IndexMapping giIndex,giUrl
  1347. end
  1348. end
  1349. return(giIndex)
  1350.  
  1351. MemoryOpen:
  1352. UrlIniCount=0
  1353. UrlInfoNeedsWriting='N'
  1354. if IniFileName='' then
  1355. return
  1356. CloseRc=stream(IniFileName, 'c', 'close')
  1357. do while lines(IniFileName)<>0
  1358. CurrentLine=strip(linein(IniFileName))
  1359. if CurrentLine='' | left(CurrentLine,1) = ';' then
  1360. iterate
  1361. UrlIniCount=UrlIniCount+1
  1362. if left(CurrentLine,1)='+' then
  1363. StatusOk='Y'
  1364. else
  1365. StatusOk='N'
  1366. URL=GetQuotedText(substr(CurrentLine,2), "Rest")
  1367. !URL.UrlIniCount.!UrlStatusOk=StatusOk
  1368. !URL.UrlIniCount.!Url=URL
  1369. !URL.UrlIniCount.!LastChecked=GetQuotedText(Rest, "Rest")
  1370. if StatusOk='Y' then
  1371. !URL.UrlIniCount.!LastModified=GetQuotedText(Rest, "Rest")
  1372. else
  1373. !URL.UrlIniCount.!Reason=GetQuotedText(Rest, "Rest")
  1374. !URL.UrlIniCount.!Updated='N'
  1375. call CreateUrl2IndexMapping UrlIniCount,Url
  1376. end
  1377. CloseRc=stream(IniFileName, 'c', 'close')
  1378. return
  1379.  
  1380. QuoteIt:
  1381. Quote4=arg(1)
  1382. TryQuoteLng=length(TryQuotes)
  1383. do QuoteIndex=1 to TryQuoteLng
  1384. PossibleQuote=substr(TryQuotes,QuoteIndex,1)
  1385. if pos(PossibleQuote,Quote4)=0 then
  1386. leave
  1387. end
  1388. return(PossibleQuote||arg(1)||PossibleQuote)
  1389.  
  1390. MemoryNeedsUpdating:
  1391. if IniFileName='' then
  1392. return('N')
  1393. else
  1394. do
  1395. if UrlInfoNeedsWriting='N' then
  1396. return('N')
  1397. else
  1398. return('Y')
  1399. end
  1400.  
  1401. _MemoryCloseWrite:
  1402. WriteWhatIndex=arg(1)
  1403. if !URL.WriteWhatIndex.!UrlStatusOk='Y' then
  1404. do
  1405. OkCount=OkCount+1
  1406. if OkCount=1 then
  1407. do
  1408. call _lineout IniFileName, ';-----------------------------'
  1409. call _lineout IniFileName, ';--- URLS without problems ---'
  1410. call _lineout IniFileName, ';-----------------------------'
  1411. call _lineout IniFileName, ''
  1412. end
  1413. Output='+  '  || QuoteIT(!URL.WriteWhatIndex.!Url)          || '  '
  1414. Output=Output||QuoteIT(!URL.WriteWhatIndex.!LastChecked)|| '  '
  1415. Output=Output||QuoteIT(!URL.WriteWhatIndex.!LastModified)
  1416. end
  1417. else
  1418. do
  1419. ErrCount=ErrCount+1
  1420. if ErrCount=1 then
  1421. do
  1422. call _lineout IniFileName, ';--------------------------'
  1423. call _lineout IniFileName, ';--- URLS with problems ---'
  1424. call _lineout IniFileName, ';--------------------------'
  1425. call _lineout IniFileName, ''
  1426. end
  1427. Output='-  '  || QuoteIT(!URL.WriteWhatIndex.!Url)          || '  '
  1428. Output=Output||QuoteIT(!URL.WriteWhatIndex.!LastChecked)|| '  '
  1429. Output=Output||QuoteIT(!URL.WriteWhatIndex.!Reason)
  1430. end
  1431. call _lineout IniFileName,Output
  1432. return
  1433.  
  1434. WantToForgetUrl:
  1435. wfuIndex=arg(1)
  1436. DateChecked=!URL.wfuIndex.!LastChecked
  1437. if datatype(DateChecked, 'W')=0 then
  1438. return('Y')
  1439. if(BaseDate()-DateChecked)>ForgetDays then
  1440. return('Y')
  1441. else
  1442. return('N')
  1443.  
  1444. MemoryClose:
  1445. if MemoryNeedsUpdating()='N' then
  1446. return
  1447. if MemoryBackupLevel=0|stream(IniFileName, 'c', 'query exists') = '' then
  1448. BackupMem='N'
  1449. else
  1450. do
  1451. if BaseDate()=FileBaseDate(IniFileName)then
  1452. BackupMem='N'
  1453. else
  1454. BackupMem='Y'
  1455. end
  1456. if BackupMem='Y' then
  1457. do
  1458. BaseLess1=_filespec('name',IniFileName)
  1459. BaseLess1=left(BaseLess1,length(BaseLess1)-1)
  1460. WholeLess1=left(IniFileName,length(IniFileName)-1)
  1461. OldestFile=WholeLess1||MemoryBackupLevel
  1462. call CloseAndDeleteFile OldestFile
  1463. do BackupIndex=0 to MemoryBackupLevel-1
  1464. ToChar=MemoryBackupLevel-BackupIndex
  1465. FromChar=ToChar-1
  1466. if FromChar=0 then
  1467. FromChar=right(IniFileName,1)
  1468. call AddressCmd 'ren ' || WholeLess1 || FromChar || ' ' ||BaseLess1||ToChar||AllCmdOutput2Nul()
  1469. end
  1470. MemoryBackupLevel=0
  1471. end
  1472. call CloseAndDeleteFile IniFileName
  1473. OkCount=0
  1474. ErrCount=0
  1475. do CloseIndex=1 to UrlIniCount
  1476. if !URL.CloseIndex.!UrlStatusOk='Y' & !URL.CloseIndex.!Updated = 'Y' then
  1477. call _MemoryCloseWrite CloseIndex
  1478. end
  1479. do CloseIndex=1 to UrlIniCount
  1480. if !URL.CloseIndex.!UrlStatusOk='Y' & !URL.CloseIndex.!Updated = 'N' & WantToForgetUrl(CloseIndex) = 'N' then
  1481. call _MemoryCloseWrite CloseIndex
  1482. end
  1483. if OkCount<>0 then
  1484. do
  1485. call _lineout IniFileName, ';  ' || OkCount || ' Url(s) are OK'
  1486. call _lineout IniFileName, ''
  1487. call _lineout IniFileName, ''
  1488. end
  1489. do CloseIndex=1 to UrlIniCount
  1490. if !URL.CloseIndex.!UrlStatusOk='N' & !URL.CloseIndex.!Updated = 'Y' then
  1491. call _MemoryCloseWrite CloseIndex
  1492. end
  1493. do CloseIndex=1 to UrlIniCount
  1494. if !URL.CloseIndex.!UrlStatusOk='N' & !URL.CloseIndex.!Updated = 'N'  & WantToForgetUrl(CloseIndex) = 'N' then
  1495. call _MemoryCloseWrite CloseIndex
  1496. end
  1497. if ErrCount<>0 then
  1498. call _lineout IniFileName, ';  ' || ErrCount || ' Url(s) have problems'
  1499. if OkCount=0&ErrCount=0 then
  1500. call _lineout IniFileName, ';--- NO URLS ---'
  1501. UrlInfoNeedsWriting='N'
  1502. return
  1503.  
  1504. NeedToReTestUrl:
  1505. if IniFileName='' then
  1506. return('NO MEMORY FILE BEING USED')
  1507. TestUrl=arg(1)
  1508. UrlIndex=GetInfoIndex4Url(TestUrl)
  1509. if UrlIndex=0 then
  1510. do
  1511. call DebugLine 'This is a new URL (not known): ' ||TestUrl
  1512. return('NEW URL')
  1513. end
  1514. if !URL.UrlIndex.!UrlStatusOk='N' then
  1515. do
  1516. call DebugLine 'This URL failed on last test : ' ||TestUrl
  1517. call DebugLine '     REASON : ' ||!URL.UrlIndex.!Reason
  1518. return('FAILED')
  1519. end
  1520. if CheckDays='' then
  1521. return('WANT TO DO ALL')
  1522. BaseDateNow=BaseDate()
  1523. BaseDateOk=!URL.UrlIndex.!LastChecked
  1524. CheckDaysThisUrl=random(CheckDaysMin,CheckDaysMax)
  1525. PeriodSinceLastCheck=BaseDateNow-BaseDateOk
  1526. call DebugLine 'URL: ' || TestUrl || ' last checked ' || PeriodSinceLastCheck || ' days ago (CheckDays[Random]=' || CheckDaysThisUrl || ').'
  1527. if PeriodSinceLastCheck<0|PeriodSinceLastCheck>CheckDaysThisUrl then
  1528. do
  1529. return('NEED TO RETEST')
  1530. end
  1531. else
  1532. do
  1533. return('')
  1534. end
  1535.  
  1536. SaveUrlOkInformation:
  1537. if IniFileName='' then
  1538. return
  1539. SaveUrl=arg(1)
  1540. UrlIndex=GetInfoIndex4Url(SaveUrl, 'Y')
  1541. !URL.UrlIndex.!UrlStatusOk='Y'
  1542. !URL.UrlIndex.!Url=SaveUrl
  1543. !URL.UrlIndex.!LastChecked=BaseDate()
  1544. !URL.UrlIndex.!LastModified=!CheckUrl.!LastModified
  1545. !URL.UrlIndex.!Updated='Y'
  1546. UrlInfoNeedsWriting='Y'
  1547. return
  1548.  
  1549. SaveUrlFailedInformation:
  1550. if IniFileName='' then
  1551. return
  1552. parse arg FailedUrl,Reason
  1553. UrlIndex=GetInfoIndex4Url(FailedUrl, 'Y')
  1554. !URL.UrlIndex.!UrlStatusOk='N'
  1555. !URL.UrlIndex.!Url=FailedUrl
  1556. !URL.UrlIndex.!LastChecked=BaseDate()
  1557. !URL.UrlIndex.!Reason=Reason
  1558. !URL.UrlIndex.!Updated='Y'
  1559. UrlInfoNeedsWriting='Y'
  1560. return
  1561.  
  1562. MEMORY_5:
  1563. parse source . . RexxSrcName
  1564. ShortRexxSrcName=_filespec('name',RexxSrcName)
  1565. DotPos=lastpos('.',ShortRexxSrcName)
  1566. if DotPos=0 then
  1567. ShortRexxSrcNameNoExtn=ShortRexxSrcName
  1568. else
  1569. ShortRexxSrcNameNoExtn=left(ShortRexxSrcName,DotPos-1)
  1570. MaxLineDump=10
  1571. if DebugFileName<> '' then
  1572. MaxLineDump=MaxLineDump*2
  1573. OptionsCmdLine=strip(arg(1))
  1574. OptionsEnvironment=GetEnv('CHECKURL_OPTIONS')
  1575. UserRequest=OptionsEnvironment|| ' ' ||OptionsCmdLine
  1576. ErrorFileName=''
  1577. CheckDays=''
  1578. ForgetDays=''
  1579. ReadTimeout=''
  1580. ReadTimeout2=''
  1581. OnlineTestUrl='http://www.labyrinth.net.au/~dbareis/index.htm'
  1582. UseHead='N'
  1583. FtpEmailAddress=''
  1584. DoHttpUrls='Y'
  1585. DoFtpUrls='Y'
  1586. CheckPointFrequency=20
  1587. MaxBytesInPage=3000
  1588. IgnoreFor=0
  1589. ErrorTypeCnt=0
  1590. ParmCount=0
  1591. TheCmdLine=UserRequest
  1592. HttpUserAgent=''
  1593. do while TheCmdLine<> ''
  1594. TheCmdLine=strip(TheCmdLine)
  1595. if left(TheCmdLine,1)='"' then
  1596. do
  1597. BeforeParse=TheCmdLine
  1598. parse value substr(TheCmdLine,2)with ThisParm'"'TheCmdLine
  1599. if TheCmdLine<> '' then
  1600. do
  1601. if left(TheCmdLine,1)\==' ' then
  1602. CryAndDie('Invalid quoted parameter at ==> ' ||BeforeParse)
  1603. end
  1604. end
  1605. else
  1606. do
  1607. parse var TheCmdLine ThisParm TheCmdLine
  1608. end
  1609. call DebugLine 'Option: "' || ThisParm || '"'
  1610. if left(ThisParm,1)<>RexOptionChar then
  1611. do
  1612. ParmCount=ParmCount+1
  1613. Parm.ParmCount=ThisParm
  1614. iterate
  1615. end
  1616. parse var ThisParm ThisCmd':'ThisCmdOptions
  1617. ThisCmd=translate(substr(ThisCmd,2))
  1618. ThisCmdOptions=ReplaceCommandLineCodes(ThisCmdOptions)
  1619. select
  1620. when ThisCmd='OKRESPONSES' then
  1621. do
  1622. ExceptionFile=ThisCmdOptions
  1623. if stream(ExceptionFile, 'c', 'query exists') = '' then
  1624. CryAndDie('The file "' || ExceptionFile || '" does not exist!')
  1625. call DebugLine ''
  1626. call DebugLine 'Have list of OK server responses'
  1627. CloseRc=stream(ExceptionFile, 'c', 'close')
  1628. OpenRc=stream(ExceptionFile, 'c', 'open read')
  1629. do while lines(ExceptionFile)<>0
  1630. UrlLine=strip(linein(ExceptionFile))
  1631. if UrlLine='' then
  1632. iterate
  1633. if left(UrlLine,1)=';' then
  1634. iterate
  1635. call DebugLine '   | ' ||UrlLine
  1636. parse var UrlLine OkReturnCode Url e_Rest
  1637. if translate(OkReturnCode)<> 'IGNORE' then
  1638. do
  1639. call KeySaveInfo "OK" || c2x(translate(OkReturnCode)), strip(Url, 'L'),e_Rest
  1640. end
  1641. else
  1642. do
  1643. parse var e_Rest e_ResumeDate e_ReasonText
  1644. e_ResumeBd=BaseDate(e_ResumeDate)
  1645. if e_ResumeBd<0 then
  1646. CryAndDie('Invalid date of "' || e_ResumeDate || '" specified, expected YYYY/MM/DD!')
  1647. e_ToGo=e_ResumeBd-BaseDate()
  1648. if e_ToGo<0 then
  1649. do
  1650. call SayAndDebugLine 'EXPIRED "IGNORE COMMAND" for : ' ||Url
  1651. end
  1652. else
  1653. do
  1654. call SayAndDebugLine 'Ignoring (for ' || abs(e_ToGo)+1 || ' more days) : ' ||Url
  1655. call KeySaveInfo "IGNORE", strip(Url, 'L'),e_ReasonText
  1656. end
  1657. end
  1658. end
  1659. CloseRc=stream(ExceptionFile, 'c', 'close')
  1660. end
  1661. when ThisCmd='ERRORFILE' then
  1662. do
  1663. if ThisCmdOptions='' then
  1664. ErrorFileName=''
  1665. else
  1666. do
  1667. ErrorFileName=ReplaceAnyFileNameSymbols(ThisCmdOptions)
  1668. if left(ErrorFileName,1)='+' then
  1669. ErrorFileName=substr(ErrorFileName,2)
  1670. else
  1671. do
  1672. if ErrorFileName<> '' then
  1673. DosDelRc=CloseAndDeleteFile(ErrorFileName)
  1674. end
  1675. end
  1676. end
  1677. when ThisCmd='MEMORYFILE' then
  1678. do
  1679. if ThisCmdOptions='' then
  1680. IniFileName=''
  1681. else
  1682. IniFileName=ReplaceAnyFileNameSymbols(ThisCmdOptions)
  1683. end
  1684. when ThisCmd='GETENV' then
  1685. do
  1686. MoreOptions=GetEnv(ThisCmdOptions)
  1687. if MoreOptions='' then
  1688. UserSyntaxError('The environment variable "' || ThisCmdOptions || '" is unknown')
  1689. TheCmdLine=MoreOptions|| ' ' ||TheCmdLine
  1690. end
  1691. when ThisCmd='PAGEMOVED' then
  1692. do
  1693. if ThisCmdOptions='' then
  1694. UserSyntaxError('No page moved text supplied')
  1695. call SetupMovedText ThisCmdOptions
  1696. end
  1697. when ThisCmd='IGNOREFOR' then
  1698. do
  1699. if ThisCmdOptions='' then
  1700. UserSyntaxError('No ignore for period (in days) supplied')
  1701. IgnoreFor=GetInteger(ThisCmd,ThisCmdOptions)
  1702. end
  1703. when ThisCmd='MAXPAGELNG' then
  1704. do
  1705. if ThisCmdOptions='' then
  1706. MaxBytesInPage=3000
  1707. else
  1708. do
  1709. MaxBytesInPage=GetInteger(ThisCmd,ThisCmdOptions)
  1710. if MaxBytesInPage<800 then
  1711. MaxBytesInPage=800
  1712. end
  1713. end
  1714. when ThisCmd='CHECKPOINT' then
  1715. do
  1716. if ThisCmdOptions='' then
  1717. CheckPointFrequency=20
  1718. else
  1719. CheckPointFrequency=GetInteger(ThisCmd,ThisCmdOptions)
  1720. end
  1721. when ThisCmd='CHECKDAYS' then
  1722. do
  1723. CheckDays=ThisCmdOptions
  1724. if CheckDays<> '' then
  1725. do
  1726. parse var CheckDays CheckDaysMin '-' CheckDaysMax
  1727. if CheckDaysMax='' then
  1728. do
  1729. if CheckDaysMin=1 then
  1730. CheckDaysMax=1
  1731. else
  1732. do
  1733. if CheckDaysMin<6 then
  1734. CheckDaysMax=CheckDaysMin+1
  1735. else
  1736. CheckDaysMax=CheckDaysMin+((CheckDaysMin%3)+1)
  1737. end
  1738. end
  1739. call DebugLine 'INI Check Days = ' || CheckDaysMin || ' to ' ||CheckDaysMax
  1740. end
  1741. end
  1742. when ThisCmd='READTIMEOUT' then
  1743. do
  1744. if ThisCmdOptions='' then
  1745. ReadTimeout=''
  1746. else
  1747. do
  1748. Value=GetInteger(ThisCmd,ThisCmdOptions)
  1749. if Value>=1 then
  1750. ReadTimeout=Value
  1751. end
  1752. end
  1753. when ThisCmd='TIMEOUTRETRY' then
  1754. do
  1755. if ThisCmdOptions='' then
  1756. ReadTimeout2=''
  1757. else
  1758. do
  1759. ReadTimeout2=GetInteger(ThisCmd,ThisCmdOptions)
  1760. if ReadTimeout2<0 then
  1761. ReadTimeout2=0
  1762. end
  1763. end
  1764. when ThisCmd='MEMORYBACKUPLEVEL' then
  1765. do
  1766. if ThisCmdOptions='' then
  1767. MemoryBackupLevel=3
  1768. else
  1769. do
  1770. MemoryBackupLevel=GetInteger(ThisCmd,ThisCmdOptions)
  1771. if MemoryBackupLevel>9 then
  1772. MemoryBackupLevel=9
  1773. end
  1774. end
  1775. when ThisCmd='FORGETDAYS' then
  1776. do
  1777. if ThisCmdOptions='' then
  1778. ForgetDays=''
  1779. else
  1780. do
  1781. Value=GetInteger(ThisCmd,ThisCmdOptions)
  1782. if Value<50 then
  1783. Value=50
  1784. ForgetDays=Value
  1785. end
  1786. end
  1787. when ThisCmd='MAXLINEDUMP' then
  1788. do
  1789. MaxLineDump=GetInteger(ThisCmd,ThisCmdOptions)
  1790. end
  1791. when ThisCmd='TESTURL' then
  1792. OnlineTestUrl=ThisCmdOptions
  1793. when ThisCmd='HTTPUSERAGENT' then
  1794. HttpUserAgent=ThisCmdOptions
  1795. when ThisCmd='FTPEMAIL' then
  1796. do
  1797. FtpEmailAddress=ThisCmdOptions
  1798. end
  1799. when ThisCmd='USEHEADREQUEST' then
  1800. do
  1801. UseHead=SwitchWantsYesOrNo(ThisCmd,ThisCmdOptions, 'Y')
  1802. if UseHead='Y' then
  1803. do
  1804. call SayAndDebugLine ''
  1805. call SayAndDebugLine '***'
  1806. call SayAndDebugLine "*** Note some servers don't seem to correctly handle"
  1807. call SayAndDebugLine '*** the HEAD request!  According to RFC 1945 the format'
  1808. call SayAndDebugLine '*** of the head request is the same as that for the GET'
  1809. call SayAndDebugLine '*** request which always seems to be correctly handled!'
  1810. call SayAndDebugLine '***'
  1811. call SayAndDebugLine '*** If you get a 404 this could be a server malfunction!'
  1812. call SayAndDebugLine '***'
  1813. call SayAndDebugLine ''
  1814. end
  1815. end
  1816. when ThisCmd='EXCLUDE' then
  1817. do
  1818. ThisMask=ThisCmdOptions
  1819. if left(ThisMask,1)<> '+' then
  1820. SubDirFlag=''
  1821. else
  1822. do
  1823. SubDirFlag='S'
  1824. ThisMask=substr(ThisMask,2)
  1825. end
  1826. ThisList.0=0
  1827. call _SysFileTree ThisMask, 'ThisList', 'F' ||SubDirFlag
  1828. call DebugLine 'Excluding the ' || ThisList.0 || ' file(s) that matched: ' ||ThisCmdOptions
  1829. do Index=1 to ThisList.0
  1830. call KeySaveInfo "EXFILE", ThisList.Index, ''
  1831. call DebugLine '  * ' ||ThisList.Index
  1832. end
  1833. end
  1834. otherwise
  1835. UserSyntaxError('Unknown switch of "' || RexOptionChar || ThisCmd || '" specified')
  1836. end
  1837. end
  1838. if HttpUserAgent='' then
  1839. HttpUserAgent="Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)"
  1840. if MaxLineDump>99 then
  1841. MaxLineDump=99
  1842. if ReadTimeout='' then
  1843. ReadTimeout=15
  1844. if ReadTimeout2='' then
  1845. do
  1846. if ReadTimeout<60 then
  1847. ReadTimeout2=60
  1848. else
  1849. ReadTimeout2=ReadTimeout+30
  1850. end
  1851. if IniFileName<> '' then
  1852. do
  1853. if ForgetDays='' then
  1854. ForgetDays=365
  1855. if CheckDays='' then
  1856. call DebugLine 'INI will be updated, all URLs will be processed reguardless of age'
  1857. end
  1858. else
  1859. do
  1860. if CheckDays<> '' then
  1861. call SayAndDebugLine 'Option "' || RexOptionChar || 'CheckIni:' || CheckDays || '" ignored.'
  1862. if ForgetDays<> '' then
  1863. call SayAndDebugLine 'Option "' || RexOptionChar || 'ForgetDays:' || ForgetDays || '" ignored.'
  1864. end
  1865. HaveSockets=InitializeSocketSupport()
  1866. HaveFtp=InitializeFtpSupport()
  1867. if ParmCount=0 then
  1868. UserSyntaxError('No parameters supplied!')
  1869. TheCmd=translate(Parm.1)
  1870. select
  1871. when TheCmd="VERSION?" then
  1872. PgmRc=ShortRexxSrcName|| ' ' ||PgmVersion
  1873. when TheCmd="SOCKETVERSION?" then
  1874. do
  1875. if HaveSockets<> '' then
  1876. PgmRc=HaveSockets
  1877. else
  1878. do
  1879. if RexWhich='STANDARD_OS/2' then
  1880. PgmRc='RxSock.DLL ' || SockVersion()   || ' - OS/2'
  1881. else
  1882. PgmRc='RxSock.DLL ' || RxSockVersion() || ' - Regina'
  1883. end
  1884. end
  1885. when TheCmd="FTPVERSION?" then
  1886. do
  1887. if HaveFtp<> '' then
  1888. PgmRc=HaveFtp
  1889. else
  1890. do
  1891. call FtpVersion 'Version'
  1892. PgmRc='RxFtp.DLL ' ||Version
  1893. end
  1894. end
  1895. when TheCmd="SOCKETREADY?" then
  1896. do
  1897. if HaveSockets<> '' then
  1898. PgmRc=HaveSockets
  1899. else
  1900. PgmRc='OK'
  1901. end
  1902. when TheCmd="FTPREADY?" then
  1903. do
  1904. if HaveFtp<> '' then
  1905. PgmRc=HaveFtp
  1906. else
  1907. PgmRc='OK'
  1908. end
  1909. when TheCmd="CHECK1URL" then
  1910. do
  1911. MaxLineDump=0
  1912. if ParmCount<>2 then
  1913. UserSyntaxError('Incorrect Number of parameters!')
  1914. PgmRc=CheckUrl(Parm.2)
  1915. end
  1916. when TheCmd="CHECKURLSINHTML" then
  1917. do
  1918. if HaveSockets='' then
  1919. PgmRc=CheckUrlsInHtml(Parm.2)
  1920. else
  1921. do
  1922. PgmRc=HaveSockets
  1923. call SayAndDebugLine PgmRc
  1924. end
  1925. end
  1926. when TheCmd="CHECKLISTEDURLS" then
  1927. do forever
  1928. if HaveSockets<> '' then
  1929. do
  1930. PgmRc=HaveSockets
  1931. call SayAndDebugLine PgmRc
  1932. leave
  1933. end
  1934. PgmRc=GetInputFilesMatchingMasks()
  1935. if PgmRc<> '' then
  1936. leave
  1937. UrlCount=0
  1938. do Index=1 to NumberFiles
  1939. ThisFile=FileList.Index
  1940. UrlSrcFile=ThisFile
  1941. call DebugLine 'PROCESSING URL LIST: "' || ThisFile || '"'
  1942. CloseRc=stream(ThisFile, 'c', 'close')
  1943. OpenRc=stream(ThisFile, 'c', 'open read')
  1944. IeUrlObject='N'
  1945. ThisLineNumber=0
  1946. do while lines(ThisFile)<>0
  1947. OneUrl=strip(linein(ThisFile))
  1948. ThisLineNumber=ThisLineNumber+1
  1949. if ThisLineNumber=1 then
  1950. do
  1951. if right(translate(ThisFile),4)='.URL' & left(strip(OneUrl), 1) = '[' then
  1952. do
  1953. UrlSrcFile='IE SHORTCUT: ' ||left(UrlSrcFile,length(UrlSrcFile)-4)
  1954. IeUrlObject='Y'
  1955. end
  1956. end
  1957. if OneUrl='' then
  1958. iterate
  1959. call DebugLine '#' || ThisLineNumber || ' ' ||OneUrl
  1960. if left(OneUrl,1)=';' then
  1961. do
  1962. if left(OneUrl,length(PragmaSrcUrl))=PragmaSrcUrl then
  1963. do
  1964. UrlSrcFile=substr(OneUrl,length(PragmaSrcUrl)+1)
  1965. end
  1966. iterate
  1967. end
  1968. if IeUrlObject='N' then
  1969. do
  1970. UrlCount=UrlCount+1
  1971. Url.UrlCount=OneUrl
  1972. UrlSrc.UrlCount=UrlSrcFile
  1973. end
  1974. else
  1975. do
  1976. OneUrl=strip(OneUrl)
  1977. OneUrlU=translate(OneUrl)
  1978. if left(OneUrlU,4)='URL=' then
  1979. do
  1980. OneUrl=substr(OneUrl,5)
  1981. UrlCount=UrlCount+1
  1982. Url.UrlCount=OneUrl
  1983. UrlSrc.UrlCount=UrlSrcFile
  1984. leave
  1985. end
  1986. end
  1987. end
  1988. CloseRc=stream(ThisFile, 'c', 'close')
  1989. end
  1990. Url.0=UrlCount
  1991. UrlSrc.0=UrlCount
  1992. call ProcessUrlArray
  1993. leave
  1994. end
  1995. otherwise
  1996. PgmRc='Unknown command of "' || TheCmd || '"!'
  1997. end
  1998. call LoggedExit(PgmRc)
  1999.  
  2000. GetInputFilesMatchingMasks:
  2001. NumberOfMasks=0
  2002. NumberFiles=0
  2003. do ParmIndex=2 to ParmCount
  2004. NumberOfMasks=NumberOfMasks+1
  2005. ThisMask=Parm.ParmIndex
  2006. if left(ThisMask,1)<> '+' then
  2007. SubDirFlag=''
  2008. else
  2009. do
  2010. SubDirFlag='S'
  2011. ThisMask=substr(ThisMask,2)
  2012. end
  2013. ThisList.0=0
  2014. call _SysFileTree ThisMask, 'ThisList', 'F' ||SubDirFlag
  2015. do Index=1 to ThisList.0
  2016. ThisInFile=ThisList.Index
  2017. if KeyGetInfo("EXFILE", ThisInFile) == "<KeyedVarUnknown>" then
  2018. do
  2019. NumberFiles=NumberFiles+1
  2020. FileList.NumberFiles=ThisInFile
  2021. end
  2022. end
  2023. end
  2024. if NumberOfMasks=0 then
  2025. return('No file masks for URL lists were supplied!')
  2026. if NumberFiles=0 then
  2027. return('No files matched any of the URL list masks!')
  2028. return('')
  2029.  
  2030. ProcessUrlArray:
  2031. if UrlCount>1 then
  2032. do
  2033. call SayAndDebugLine 'Sorting ' || AddCommasToDecimalNumber(UrlCount) || ' URLs...'
  2034. SrtM=1
  2035. SrtCount=URL.0
  2036. do while(9*SrtM+4)<SrtCount
  2037. SrtM=SrtM*3+1
  2038. end
  2039. do while SrtM>0
  2040. SrtK=SrtCount-SrtM
  2041. do SrtJ=1 to SrtK
  2042. SrtIndex1=SrtJ
  2043. do while SrtIndex1>0
  2044. SrtIndex2=SrtIndex1+SrtM
  2045. SrtGreater=URL.SrtIndex1>URL.SrtIndex2
  2046. if SrtGreater then
  2047. do
  2048. SrtTemp=URL.SrtIndex1;URL.SrtIndex1=URL.SrtIndex2;URL.SrtIndex2=SrtTemp;SrtTemp=URLSRC.SrtIndex1;URLSRC.SrtIndex1=URLSRC.SrtIndex2;URLSRC.SrtIndex2=SrtTemp
  2049. end
  2050. else
  2051. leave
  2052. SrtIndex1=SrtIndex1-SrtM
  2053. end
  2054. end
  2055. SrtM=SrtM%3
  2056. end
  2057. end
  2058. UrlUniqueCount=0
  2059. LastUrl=''
  2060. do Index=1 to UrlCount
  2061. OneUrl=Url.Index
  2062. if OneUrl=LastUrl then
  2063. iterate
  2064. LastUrl=OneUrl
  2065. UrlUniqueCount=UrlUniqueCount+1
  2066. end
  2067. call SayAndDebugLine 'Have ' || AddCommasToDecimalNumber(UrlUniqueCount) || ' unique URLs...'
  2068. call SayAndDebugLine ''
  2069. call MemoryOpen
  2070. PgmRc=0
  2071. LastUrl=''
  2072. LastUrlRc='OK'
  2073. UrlNumber=0
  2074. UrlTimedOutCount=0
  2075. ErrorsInRow=0
  2076. NumbSinceCheckpoint=0
  2077. do Index=1 to UrlCount
  2078. OneUrl=Url.Index
  2079. if OneUrl=LastUrl then
  2080. do
  2081. if LastUrlRc<> 'OK' then
  2082. do
  2083. ThisSrc=UrlSrc.Index
  2084. SameSrc='N'
  2085. do CheckIndex=ErrorUrlIndex to Index-1
  2086. if UrlSrc.CheckIndex=ThisSrc then
  2087. do
  2088. SameSrc='Y'
  2089. leave
  2090. end
  2091. end
  2092. if SameSrc='N' then
  2093. do
  2094. call SayAndDebugLine '     Src: ' ||ThisSrc
  2095. call Line2ErrorFile ';      URL from ' ||ThisSrc
  2096. end
  2097. end
  2098. iterate
  2099. end
  2100. LastUrl=OneUrl
  2101. if NeedToReTestUrl(OneUrl)='' then
  2102. do
  2103. LastUrlRc='OK'
  2104. iterate
  2105. end
  2106. IgnoreThis=KeyGetInfo("IGNORE",OneUrl)
  2107. if IgnoreThis<> "<KeyedVarUnknown>" then
  2108. do
  2109. LastUrlRc='OK'
  2110. iterate
  2111. end
  2112. UrlNumber=UrlNumber+1
  2113. if ErrorsInRow>=5|UrlNumber=1 then
  2114. do
  2115. ErrorsInRow=0
  2116. if OnlineTestUrl<> '' then
  2117. do
  2118. if UrlNumber<>1 then
  2119. do
  2120. call MemoryClose
  2121. end
  2122. call SayAndDebugLine ''
  2123. call SayAndDebugLine 'Oneline? - Testing "' || OnlineTestUrl || '"'
  2124. TestUrlRc=CheckUrl(OnlineTestUrl)
  2125. if TestUrlRc='OK' then
  2126. call SayAndDebugLine '   * We seem to be online!'
  2127. else
  2128. do
  2129. call SayAndDebugLine '   * Failed: ' ||TestUrlRc
  2130. call SayAndDebugLine '   * Assuming not online'
  2131. PgmRc=9999
  2132. leave
  2133. end
  2134. end
  2135. end
  2136. call SayAndDebugLine ''
  2137. call SayAndDebugLine 'Checking: #' || UrlNumber || ' "' || OneUrl || '"'
  2138. UrlRc=CheckUrl(OneUrl)
  2139. call SayAndDebugLine '      Rc: ' ||UrlRc
  2140. call DebugLine ''
  2141. call DebugLine ''
  2142. if UrlRc='OK' then
  2143. do
  2144. call SaveUrlOkInformation OneUrl
  2145. ErrorsInRow=0
  2146. end
  2147. else
  2148. do
  2149. PgmRc=PgmRc+1
  2150. ErrorUrlIndex=Index
  2151. ErrorsInRow=ErrorsInRow+1
  2152. call SaveUrlFailedInformation OneUrl,UrlRc
  2153. call Line2ErrorFile ''
  2154. call Line2ErrorFile PragmaSrcUrl||UrlSrc.Index
  2155. call Line2ErrorFile OneUrl
  2156. call Line2ErrorFile ';      ' ||UrlRc
  2157. call Line2ErrorFile ';      URL from ' ||UrlSrc.Index
  2158. call SayAndDebugLine '     Src: ' ||UrlSrc.Index
  2159. ErrType=!CheckUrl.!ErrorType
  2160. if !CheckUrl.!ErrorType='Timeout' then
  2161. do
  2162. UrlTimedOutCount=UrlTimedOutCount+1
  2163. !UrlTimedOut.UrlTimedOutCount.!URL=OneUrl
  2164. end
  2165. else
  2166. do
  2167. if !CheckUrl.!CanOverride='Y' then
  2168. do
  2169. OrErrType=ReplaceString(ErrType, " ", "_")
  2170. Override=';      /OKRESPONSES: ' || OrErrType || '  ' ||OneUrl
  2171. if !CheckUrl.!UrlMovedTo<> '' then
  2172. do
  2173. Override=Override|| '  ' ||!CheckUrl.!UrlMovedTo
  2174. end
  2175. call Line2ErrorFile Override
  2176. end
  2177. end
  2178. if IgnoreFor<>0 then
  2179. do
  2180. IgYYYYMMDD=bd2date(basedate()+IgnoreFor)
  2181. parse var IgYYYYMMDD IgYYYY+4 IgMM+2 IgDD
  2182. IgDate=IgYYYY|| '/' || IgMM || '/' ||IgDD
  2183. ForCusPaste=';      IGNORE ' || OneUrl || '   ' || IgDate || '  ' ||UrlRc
  2184. call Line2ErrorFile ForCusPaste
  2185. end
  2186. do
  2187. if ErrType='' then
  2188. ErrType="UNKNOWN!"
  2189. if !CheckUrl.!UrlMovedTo<> '' then
  2190. ErrType="Url Moved"
  2191. ErrTypeDesc=GetServerErrorDescription(ErrType)
  2192. if ErrTypeDesc<> '' then
  2193. ErrType=ErrType|| ' (' || ErrTypeDesc || ')'
  2194. ErrKey='EK_' ||c2x(ErrType)
  2195. if symbol(ErrKey)<> 'VAR' then
  2196. do
  2197. call value ErrKey, "0"
  2198. ErrorTypeCnt=ErrorTypeCnt+1
  2199. !ErrorTypeLst.ErrorTypeCnt=ErrType
  2200. end
  2201. NewValue=value(ErrKey)+1
  2202. call value ErrKey,NewValue
  2203. end
  2204. end
  2205. LastUrlRc=UrlRc
  2206. NumbSinceCheckpoint=NumbSinceCheckpoint+1
  2207. if NumbSinceCheckpoint>=CheckPointFrequency then
  2208. do
  2209. NumbSinceCheckpoint=0
  2210. call DebugLine ''
  2211. call DebugLine 'Checkpointing again for safety!'
  2212. call MemoryClose
  2213. end
  2214. end
  2215. if UrlTimedOutCount<>0&ReadTimeout2<>0 then
  2216. do
  2217. call MemoryClose
  2218. ToTestCnt=UrlTimedOutCount
  2219. ReadTimeout=ReadTimeout2
  2220. do TimedOutIndex=1 to ToTestCnt
  2221. OneUrl=!UrlTimedOut.TimedOutIndex.!URL
  2222. call SayAndDebugLine ''
  2223. call SayAndDebugLine 'ReTesting: "' || OneUrl || '"'
  2224. UrlRc=CheckUrl(OneUrl)
  2225. call SayAndDebugLine '       Rc: ' ||UrlRc
  2226. if UrlRc='OK' then
  2227. do
  2228. PgmRc=PgmRc-1
  2229. UrlTimedOutCount=UrlTimedOutCount-1
  2230. call SaveUrlOkInformation OneUrl
  2231. end
  2232. else
  2233. do
  2234. call SaveUrlFailedInformation OneUrl,UrlRc
  2235. end
  2236. end
  2237. end
  2238. if PgmRc<>9999 then
  2239. do
  2240. call SayAndDebugLine ''
  2241. call SayAndDebugLine ''
  2242. if PgmRc<>0 then
  2243. do
  2244. if ErrorTypeCnt<>0 then
  2245. do
  2246. call SayAndDebugLine ""
  2247. call SayAndDebugLine ""
  2248. Title=PgmRc|| ' Failures out of ' || UrlNumber || ' URLs tested'
  2249. call SayAndDebugLine Title
  2250. call SayAndDebugLine copies('~',length(Title))
  2251. NumberWidth=length(ErrorTypeCnt)
  2252. do ErrIndex=1 to ErrorTypeCnt
  2253. ErrType=!ErrorTypeLst.ErrIndex
  2254. ErrKey='EK_' ||c2x(ErrType)
  2255. ErrNum=value(ErrKey)
  2256. call SayAndDebugLine right(ErrNum,NumberWidth)|| ' x ' ||ErrType
  2257. end
  2258. end
  2259. end
  2260. else
  2261. do
  2262. if UrlNumber=0 then
  2263. call SayAndDebugLine 'No URLs needed checking.'
  2264. else
  2265. call SayAndDebugLine 'No failures (' || UrlNumber || ' urls checked)'
  2266. end
  2267. end
  2268. call MemoryClose
  2269. return
  2270.  
  2271. GetInteger:
  2272. if datatype(arg(2), 'W')=0 then
  2273. CryAndDie(RexOptionChar||arg(1)|| ' given an invalid value of "' || arg(2) || '"')
  2274. return(strip(arg(2)))
  2275.  
  2276. SwitchOptionsValidateAgainstList:
  2277. TheCmd=arg(1)
  2278. TheOption=translate(arg(2))
  2279. ValidList=',' || translate(arg(3)) || ','
  2280. if pos(',' || TheOption || ',',ValidList)<>0 then
  2281. return(TheOption)
  2282. UserSyntaxError('An invalid parameter of "' || TheOption || '" was specified on the "' || RexOptionChar || TheCmd || '" switch!')
  2283.  
  2284. SwitchWantsYesOrNo:
  2285. TheCmd=arg(1)
  2286. TheOption=translate(arg(2))
  2287. Default=arg(3)
  2288. if TheOption='' then
  2289. return(Default)
  2290. else
  2291. return(left(SwitchOptionsValidateAgainstList(TheCmd,TheOption, "Y,N,YES,NO"),1))
  2292.  
  2293. Line2ErrorFile:
  2294. if ErrorFileName<> '' then
  2295. do
  2296. call _lineout ErrorFileName,arg(1)
  2297. call stream ErrorFileName, 'c', 'close'
  2298. end
  2299. return
  2300.  
  2301. SayAndDebugLine:
  2302. if arg(1)<> '' then
  2303. LastLineWasBlank='N'
  2304. else
  2305. do
  2306. if LastLineWasBlank='Y' then
  2307. return
  2308. else
  2309. LastLineWasBlank='Y'
  2310. end
  2311. say arg(1)
  2312. call DebugLine 'SAID: ' ||arg(1)
  2313. return
  2314.  
  2315. DebugLine:
  2316. call DebugLineNoTime time()|| ': ' ||arg(1)
  2317. return
  2318.  
  2319. DebugLineNoTime:
  2320. if DebugFileName<> '' then
  2321. do
  2322. call _lineout DebugFileName,arg(1)
  2323. call stream DebugFileName, 'c', 'close'
  2324. end
  2325. return
  2326.  
  2327. DebugChars:
  2328. if DebugFileName<> '' then
  2329. do
  2330. call charout DebugFileName,arg(1)
  2331. call stream DebugFileName, 'c', 'close'
  2332. end
  2333. return
  2334.  
  2335. ValidIpByte:
  2336. IpByte=arg(1)
  2337. if datatype(IpByte, 'W')=0 then
  2338. return('N')
  2339. if IpByte<0|IpByte>255 then
  2340. return('N')
  2341. return('Y')
  2342.  
  2343. CheckUrl:
  2344. !CheckUrl.!LastModified=''
  2345. !CheckUrl.!ErrorType=''
  2346. !CheckUrl.!CanOverride='N'
  2347. !CheckUrl.!UrlMovedTo=''
  2348. ProcessingThisUrl=arg(1)
  2349. if abbrev(ProcessingThisUrl, 'ftp://')then
  2350. do
  2351. if left(RexSystemOpSys,3)="WIN" then
  2352. do
  2353. call DebugLine "Can't check FTP urls under windows yet - flagging as OK"
  2354. return("OK")
  2355. end
  2356. if HaveFtp<> '' then
  2357. CurlRc=HaveFtp
  2358. else
  2359. CurlRc=CheckUrlFtp(ProcessingThisUrl)
  2360. end
  2361. else
  2362. do
  2363. if HaveSockets<> '' then
  2364. CurlRc=HaveSockets
  2365. else
  2366. CurlRc=CheckUrlHttp(ProcessingThisUrl)
  2367. end
  2368. ProcessingThisUrl=''
  2369. return(CurlRc)
  2370.  
  2371. CheckUrlFtp:
  2372. FullUrl=arg(1)
  2373. parse var FullUrl 'ftp://' FtpServer '/' FullFileName
  2374. SlashPos=lastpos('/',FullFileName)
  2375. if SlashPos=0 then
  2376. do
  2377. FileDir='/'
  2378. FileShort=FullFileName
  2379. end
  2380. do
  2381. FileDir='/' ||left(FullFileName,SlashPos)
  2382. FileShort=substr(FullFileName,SlashPos+1)
  2383. end
  2384. if FtpEmailAddress<> '' then
  2385. EmailAddress=FtpEmailAddress
  2386. else
  2387. EmailAddress=ShortRexxSrcName|| '@email.address.not.known'
  2388. FtpRc=FtpSetUser(FtpServer, 'Anonymous',EmailAddress)
  2389. if FtpRc=0 then
  2390. return('Could not set up the user info (email address etc)')
  2391. FtpRc=ftpchdir(FileDir)
  2392. if FtpRc<>0 then
  2393. FtpExit='Could not change to "' || FileDir || '" (' || GetFtpError() || ')'
  2394. else
  2395. do
  2396. if FileShort='' then
  2397. FtpExit='OK'
  2398. else
  2399. do
  2400. FtpFile.0=0
  2401. call FTPLs FileShort, "FtpFile."
  2402. if FtpRc<>0 then
  2403. FtpExit='Could not find "' || FileShort || '" (' || GetFtpError() || ')'
  2404. else
  2405. do
  2406. if FtpFile.0=1 then
  2407. FtpExit='OK'
  2408. else
  2409. do
  2410. FtpRc=ftpchdir('/' ||FullFileName)
  2411. if FtpRc<>0 then
  2412. FtpExit='Could not find "' || FileShort || '" in directory ' ||FileDir
  2413. else
  2414. FtpExit='OK'
  2415. end
  2416. end
  2417. end
  2418. end
  2419. call FtpLogoff
  2420. return(FtpExit)
  2421.  
  2422. CheckUrlHttp:
  2423. FullUrl=arg(1)
  2424. parse var FullUrl HttpPrefix '://' httpServer '/' HttpPageAddr
  2425. parse var httpServer httpServer ':' HttpPort
  2426. if HttpPort='' then
  2427. HttpPort=80
  2428. parse var HttpPageAddr HttpPageAddr '#'
  2429. parse var httpServer Byte1 '.' Byte2 '.' Byte3 '.' Byte4
  2430. if ValidIpByte(Byte1)='Y' & ValidIpByte(Byte2) = 'Y' & ValidIpByte(Byte3) = 'Y' & ValidIpByte(Byte4) = 'Y' then
  2431. httpServerDotted=httpServer
  2432. else
  2433. do
  2434. SocketRc=SockGetHostByName(httpServer, 'httpServer_')
  2435. if SocketRc=0 then
  2436. do
  2437. call DebugLine 'SockGetHostByName(' || httpServer || ') failed - ' || GetSockError() || ', DNS unavailable?'
  2438. !CheckUrl.!ErrorType="Server Name Unknown"
  2439. return('Server name "' || httpServer || '" unknown')
  2440. end
  2441. httpServerDotted=httpServer_addr
  2442. end
  2443. if DebugFileName<> '' then
  2444. do
  2445. call DebugLine ''
  2446. call DebugLine copies('=',79)
  2447. call DebugLine ''
  2448. call DebugLine 'Details'
  2449. call DebugLine '~~~~~~~'
  2450. call DebugLine 'Full URL    :' ||FullUrl
  2451. call DebugLine 'Server Name :' ||httpServer
  2452. call DebugLine 'Server IP   :' ||httpServerDotted
  2453. call DebugLine 'Port        :' ||httpPort
  2454. call DebugLine 'Page        :' ||HttpPageAddr
  2455. call DebugLine ''
  2456. end
  2457. SocketHandle=SockSocket('AF_INET', 'SOCK_STREAM', 'IPPROTO_TCP')
  2458. SvrAddr.!family='AF_INET'
  2459. SvrAddr.!port=HttpPort
  2460. SvrAddr.!addr=httpServerDotted
  2461. SocketRc=SockConnect(SocketHandle, 'SvrAddr.!')
  2462. if SocketRc=-1 then
  2463. do
  2464. SocketRc=SockClose(SocketHandle)
  2465. !CheckUrl.!ErrorType="Could Not Open Socket"
  2466. return('Could not open socket for "' || httpServer || '"')
  2467. end
  2468. if UseHead='Y' then
  2469. do
  2470. RequestMsg='HEAD /' || HttpPageAddr || ' HTTP/1.0' ||CrLf||,
  2471. 'User-Agent: ' ||HttpUserAgent||CrLf||,
  2472. 'Host: ' || httpServer || ':' ||HttpPort||CrLf||,
  2473. 'Accept: */*' ||CrLf||,
  2474. CrLf
  2475. end
  2476. else
  2477. do
  2478. RequestMsg='GET /' || HttpPageAddr || ' HTTP/1.0' ||CrLf||,
  2479. 'User-Agent: ' ||HttpUserAgent||CrLf||,
  2480. 'Host: ' || httpServer || ':' ||HttpPort||CrLf||,
  2481. 'Accept: */*' ||CrLf||,
  2482. CrLf
  2483. end
  2484. SocketRc=SockSend(SocketHandle,RequestMsg)
  2485. if(SocketRc=-1)then
  2486. do
  2487. SocketRc=SockClose(SocketHandle)
  2488. !CheckUrl.!ErrorType="Error Sending Page Request"
  2489. return('Error sending page request to "' || httpServer || '" (' || GetSockError() || ')')
  2490. end
  2491. call Time('R')
  2492. if DebugFileName<> '' then
  2493. do
  2494. call DebugLine 'Sent'
  2495. call DebugLine '~~~~'
  2496. call DebugLine RequestMsg
  2497. call DebugLine ''
  2498. end
  2499. ServersResponse=''
  2500. WaitFor=ReadTimeout
  2501. do until ThisBit==''
  2502. if length(ServersResponse)>=MaxBytesInPage then
  2503. do
  2504. ServersResponse=ServersResponse|| '<=Truncated here, page too long!'
  2505. leave
  2506. end
  2507. WaitRead.0=1
  2508. WaitRead.1=SocketHandle
  2509. SocketRc=SockSelect( "WaitRead.", "", "",WaitFor)
  2510. if SocketRc=0 then
  2511. do
  2512. if WaitFor=1 then
  2513. leave
  2514. SocketRc=SockClose(SocketHandle)
  2515. !CheckUrl.!ErrorType='Timeout'
  2516. return('Timed out (waited ' || ReadTimeout || ' seconds).')
  2517. end
  2518. WaitFor=1
  2519. ThisBit=''
  2520. SocketRc=SockRecv(SocketHandle, 'ThisBit',1024)
  2521. ServersResponse=ServersResponse||ThisBit
  2522. end
  2523. ReadTook=GetElapsedTime()
  2524. SocketRc=SockClose(SocketHandle)
  2525. if(SocketRc=-1)then
  2526. do
  2527. !CheckUrl.!ErrorType="Error Reading Server Response"
  2528. return('Error reading response from "' || httpServer || '" (' || GetSockError() || ')')
  2529. end
  2530. ServersResponseLng=length(ServersResponse)
  2531. ServersResponse=ReplaceString(ServersResponse,Cr, '')
  2532. if DebugFileName<> '' then
  2533. do
  2534. MsgTxt='Received ' || AddCommasToDecimalNumber(ServersResponseLng) || ' bytes, Took ' || ReadTook || ' seconds'
  2535. call DebugLine MsgTxt
  2536. call DebugLine copies('~',length(MsgTxt))
  2537. call DebugChars ReplaceString(ServersResponse,Lf,CrLf)||CrLf
  2538. call DebugLine ''
  2539. end
  2540. EolPos=EolPos(ServersResponse)
  2541. if EolPos=0 then
  2542. ServersResponse1stLine=ServersResponse
  2543. else
  2544. ServersResponse1stLine=left(ServersResponse,EolPos-1)
  2545. ServerRc=word(ServersResponse1stLine,2)
  2546. AddCode='Y'
  2547. if ServerRc='200' then
  2548. do
  2549. ServersResponseU=translate(ServersResponse)
  2550. do TxtIndex=1 to MovedTxt.0
  2551. if pos(MovedTxtU.TxtIndex,ServersResponseU)<>0 then
  2552. do
  2553. !CheckUrl.!UrlMovedTo='?'
  2554. ServerRc='MOVED?'
  2555. UrlRcText=ServerRc|| ' - Page contained "' || MovedTxt.TxtIndex || '"'
  2556. leave
  2557. end
  2558. end
  2559. Look4=translate('http-equiv="Refresh"')
  2560. Look4Pos=pos(Look4,ServersResponseU)
  2561. if Look4Pos<>0 then
  2562. do
  2563. EndMetaTagPos=pos('>',ServersResponseU,Look4Pos)
  2564. if EndMetaTagPos<>0 then
  2565. do
  2566. LeftBit=left(ServersResponseU,EndMetaTagPos)
  2567. MetaTagPos=lastpos('<',LeftBit)
  2568. if MetaTagPos<>0 then
  2569. do
  2570. MetaTag=substr(ServersResponse,MetaTagPos,(EndMetaTagPos-MetaTagPos)+1)
  2571. MetaTagU=substr(ServersResponseU,MetaTagPos,(EndMetaTagPos-MetaTagPos)+1)
  2572. ContPos=pos('CONTENT=',MetaTagU)
  2573. if ContPos<>0 then
  2574. do
  2575. ContPos=ContPos+7
  2576. SearchIn=substr(MetaTag,ContPos)
  2577. parse var SearchIn '="' ContentValue ';' . '=' MetaNewUrl '"' MetaRest
  2578. if MetaRest<> '' then
  2579. do
  2580. if datatype(ContentValue, 'W')then
  2581. do
  2582. if ContentValue<=10 then
  2583. do
  2584. !CheckUrl.!UrlMovedTo=MetaNewUrl
  2585. ServerRc='MOVED?'
  2586. UrlRcText=ServerRc|| ' - Meta tag = ' ||MetaTag
  2587. end
  2588. end
  2589. end
  2590. end
  2591. end
  2592. end
  2593. end
  2594. end
  2595. select
  2596. when ServerRc='200' then
  2597. do
  2598. AddCode='N'
  2599. UrlRcText='OK'
  2600. call GetLastModifiedTimeFromOkResponse
  2601. end
  2602. when ServerRc='MOVED?' then
  2603. do
  2604. AddCode='N'
  2605. end
  2606. when ServerRc='400' then
  2607. UrlRcText='BAD REQUEST'
  2608. when ServerRc='403' then
  2609. do
  2610. UrlRcText='ACCESS DENIED'
  2611. if translate(HttpPrefix)='HTTPS' then
  2612. do
  2613. AddCode='N'
  2614. UrlRcText='OK'
  2615. end
  2616. end
  2617. when ServerRc='404' then
  2618. UrlRcText='URL NOT FOUND'
  2619. when ServerRc='503' then
  2620. UrlRcText='SERVICE UNAVAILABLE'
  2621. when ServerRc='301' | ServerRc='302' then
  2622. do
  2623. if ServerRc='301' then
  2624. UrlRcText='PERMANENT'
  2625. else
  2626. UrlRcText='TEMPORARY'
  2627. parse var ServersResponse . 'Location: ' Rest
  2628. CrPos=pos('0D'x,Rest)
  2629. NlPos=pos('0A'x,Rest)
  2630. if CrPos<>0 then
  2631. EndPos=CrPos
  2632. else
  2633. EndPos=NlPos
  2634. if EndPos=0 then
  2635. NewLocation='?'
  2636. else
  2637. NewLocation=left(Rest,EndPos-1)
  2638. if left(NewLocation,1)='/' then
  2639. do
  2640. NewLocation=HttpPrefix|| '://' ||httpServer
  2641. end
  2642. if NewLocation=FullUrl|| '/' then
  2643. UrlRcText='Add terminating "/" for performance'
  2644. else
  2645. do
  2646. if NewLocation=FullUrl then
  2647. do
  2648. call DebugLine 'Stupid Site returned #' || ServerRc || ', but returned same address!'
  2649. AddCode='N'
  2650. UrlRcText='OK'
  2651. call GetLastModifiedTimeFromOkResponse
  2652. end
  2653. else
  2654. do
  2655. MsgFormatted='N'
  2656. if pos('?',FullUrl)<>0 then
  2657. do
  2658. parse var FullUrl BeforeQm '?' AfterQm
  2659. TestUrl=BeforeQm|| '/?' ||AfterQm
  2660. if NewLocation=TestUrl then
  2661. do
  2662. UrlRcText='Add "/" before "?" for performance'
  2663. MsgFormatted='Y'
  2664. end
  2665. end
  2666. if MsgFormatted='N' then
  2667. do
  2668. if NewLocation|| '/' =FullUrl then
  2669. do
  2670. call DebugLine 'Stupid Site returned #' || ServerRc || ', but returned same address minus terminating slash!'
  2671. AddCode='N'
  2672. UrlRcText='OK'
  2673. MsgFormatted='Y'
  2674. call GetLastModifiedTimeFromOkResponse
  2675. end
  2676. end
  2677. if MsgFormatted='N' then
  2678. do
  2679. UrlRcText=UrlRcText|| ' move to ' ||NewLocation
  2680. !CheckUrl.!UrlMovedTo=NewLocation
  2681. end
  2682. end
  2683. end
  2684. end
  2685. otherwise
  2686. do
  2687. if translate(left(ServersResponse1stLine,5))='HTTP/' & datatype(ServerRc, 'W')=1 then
  2688. do
  2689. UrlRcText=subword(ServersResponse1stLine,3)
  2690. end
  2691. else
  2692. do
  2693. if MaxLineDump<>0 then
  2694. do
  2695. LineCounter=0
  2696. StartPos=1
  2697. say ' ------- UNKNOWN RESPONSE DUMP - START -------'
  2698. do until EolPos=0|LineCounter>MaxLineDump
  2699. EolPos=EolPos(ServersResponse,StartPos)
  2700. if EolPos=0 then
  2701. LineTxt=substr(ServersResponse,StartPos)
  2702. else
  2703. do
  2704. LineTxt=substr(ServersResponse,StartPos,EolPos-StartPos)
  2705. StartPos=EolPos+1
  2706. do while EolPos(ServersResponse,StartPos)=StartPos
  2707. StartPos=StartPos+1
  2708. end
  2709. end
  2710. if LineTxt<> '' then
  2711. do
  2712. LineCounter=LineCounter+1
  2713. call SayAndDebugLine right(LineCounter,2, '0') || ': ' ||LineTxt
  2714. end
  2715. end
  2716. say ' ------- UNKNOWN RESPONSE DUMP - END ---------'
  2717. end
  2718. AddCode='N'
  2719. UrlRcText='Problem unknown ==>' ||ServersResponse1stLine
  2720. end
  2721. end
  2722. end
  2723. if ServerRc<> '200' then
  2724. do
  2725. !CheckUrl.!CanOverride='Y'
  2726. ReallyOk=KeyGetInfo("OK" ||c2x(translate(ServerRc)),FullUrl)
  2727. if ReallyOk<> "<KeyedVarUnknown>" then
  2728. do
  2729. if ServerRc<> '301' & ServerRc <> '302' & ServerRc <> 'MOVED?' then
  2730. ServerRc='200'
  2731. else
  2732. do
  2733. if ReallyOk='' |ReallyOk=!CheckUrl.!UrlMovedTo then
  2734. ServerRc='200'
  2735. end
  2736. if ServerRc='200' then
  2737. do
  2738. call DebugLine "Ignoring server's response of " || ServerRc || ' (in OK list)'
  2739. AddCode='N'
  2740. UrlRcText='OK'
  2741. !CheckUrl.!UrlMovedTo=''
  2742. call GetLastModifiedTimeFromOkResponse
  2743. end
  2744. end
  2745. end
  2746. !CheckUrl.!ErrorType=ServerRc
  2747. if AddCode='Y' then
  2748. HttpRc='#' || ServerRc || ' - ' ||UrlRcText
  2749. else
  2750. HttpRc=UrlRcText
  2751. return(HttpRc)
  2752.  
  2753. GetLastModifiedTimeFromOkResponse:
  2754. LookFor="Last-Modified:"
  2755. LastModPos=pos(LookFor,ServersResponse)
  2756. if LastModPos=0 then
  2757. do
  2758. call DebugLine 'Could not find "' || LookFor || '"'
  2759. !CheckUrl.!LastModified=''
  2760. end
  2761. else
  2762. do
  2763. StartPos=LastModPos+length(LookFor)
  2764. EolPos=EolPos(ServersResponse,StartPos)
  2765. if EolPos=0 then
  2766. !CheckUrl.!LastModified=substr(ServersResponse,StartPos)
  2767. else
  2768. !CheckUrl.!LastModified=substr(ServersResponse,StartPos,EolPos-StartPos)
  2769. !CheckUrl.!LastModified=strip(!CheckUrl.!LastModified)
  2770. call DebugLine 'Page last modified "' || !CheckUrl.!LastModified || '"'
  2771. end
  2772. return
  2773.  
  2774. GetSockError:
  2775. if RexWhich='STANDARD_OS/2' then
  2776. SockRc=errno|| '/' ||h_errno
  2777. else
  2778. SockRc=SockSock_Errno()
  2779. return(SockRc)
  2780.  
  2781. GetFtpError:
  2782. select
  2783. when FTPERRNO="FTPHOST"       then return("unknown host")
  2784. when FTPERRNO="FTPCONNECT"    then return("unable to connect to server")
  2785. when FTPERRNO="FTPLOGIN"      then return("login failed")
  2786. when FTPERRNO="FTPPROXYTHIRD" then return("proxy server does not support 3rd party transfers")
  2787. when FTPERRNO="FTPNOPRIMARY"  then return("no primary connection for proxy transfer")
  2788. otherwise return(FTPERRNO)
  2789. end
  2790.  
  2791. EolPos:
  2792. _StartPos=arg(2)
  2793. if _StartPos='' then
  2794. _StartPos=1
  2795. _CrPos=pos('0D'x,arg(1),_StartPos)
  2796. _LfPos=pos('0A'x,arg(1),_StartPos)
  2797. if _CrPos=0|_LfPos=0 then
  2798. return(max(_CrPos,_LfPos))
  2799. else
  2800. return(min(_CrPos,_LfPos))
  2801.  
  2802. GetElapsedTime:
  2803. signal on SYNTAX name ElapsedTimeBugWorkaround
  2804. getTime=time('E')
  2805. return(trunc(getTime,2))
  2806.  
  2807. ElapsedTimeBugWorkaround:
  2808. return('?')
  2809.  
  2810. InitializeSocketSupport:
  2811. call RxFuncAdd "SockLoadFuncs", "RxSock.DLL", "SockLoadFuncs"
  2812. signal on SYNTAX name RxSockDllMissing
  2813. if RexWhich='STANDARD_OS/2' then
  2814. call SockLoadFuncs "NoCopyrightDisplayEtc"
  2815. else
  2816. call SockLoadFuncs
  2817. return('')
  2818.  
  2819. RxSockDllMissing:
  2820. if RexWhich='STANDARD_OS/2' then
  2821. return("Can't locate RxSock.DLL")
  2822. else
  2823. return("Can't locate RxSock.DLL, Get from 'http://home.hiwaay.net/~abbott/regina/'")
  2824.  
  2825. InitializeFtpSupport:
  2826. call RxFuncAdd "FtpLoadFuncs", "RxFtp.DLL", "FtpLoadFuncs"
  2827. signal on SYNTAX name RxFtpDllMissing
  2828. call FtpLoadFuncs "NoCopyrightDisplayEtc"
  2829. return('')
  2830.  
  2831. RxFtpDllMissing:
  2832. return("Can't locate RxFtp.DLL")
  2833.  
  2834. ReplaceAnyFileNameSymbols:
  2835. parse value time('N') with Hours ':' Minutes ':' Seconds
  2836. CurrentTime=Hours||Minutes||Seconds
  2837. TmpDate=date('N')
  2838. parse var TmpDate TmpDD TmpMon TmpYYYY
  2839. CurrentDate=right(TmpYYYY,2)||TmpMon||TmpDD
  2840. CurrentDateNumb=date('S')
  2841. NewText=ReplaceString(arg(1), "{Time}",CurrentTime)
  2842. NewText=ReplaceString(NewText, "{DateNumbers}",CurrentDateNumb)
  2843. NewText=ReplaceString(NewText, "{Date}",CurrentDate)
  2844. return(NewText)
  2845.  
  2846. AddCommasToDecimalNumber:procedure
  2847. NoComma=strip(arg(1))
  2848. if pos(',',NoComma)<>0 then
  2849. return(NoComma)
  2850. DotPos=pos('.',NoComma)
  2851. if DotPos=0 then
  2852. AfterDecimal=''
  2853. else
  2854. do
  2855. if DotPos=1 then
  2856. return("0" ||NoComma)
  2857. AfterDecimal=substr(NoComma,DotPos+1)
  2858. NoComma=left(NoComma,DotPos-1)
  2859. end
  2860. NoComma=reverse(NoComma)
  2861. ResultWithCommas=""
  2862. do while length(NoComma)>3
  2863. ResultWithCommas=ResultWithCommas||left(NoComma,3)|| ','
  2864. NoComma=substr(NoComma,4)
  2865. end
  2866. ResultWithCommas=ResultWithCommas||NoComma
  2867. ResultWithCommas=reverse(ResultWithCommas)
  2868. if AfterDecimal<> '' then
  2869. ResultWithCommas=ResultWithCommas|| '.' ||AfterDecimal
  2870. return(ResultWithCommas)
  2871.  
  2872. ReplaceString:
  2873. TheString=arg(1)
  2874. ChangeFrom=arg(2)
  2875. ChangeTo=arg(3)
  2876. ChangeFromLength=length(ChangeFrom)
  2877. ChangeToLength=length(ChangeTo)
  2878. FoundPosn=pos(ChangeFrom,TheString)
  2879. do while FoundPosn<>0
  2880. TheString=left(TheString,FoundPosn-1)||ChangeTo||substr(TheString,FoundPosn+ChangeFromLength)
  2881. FoundPosn=pos(ChangeFrom,TheString,FoundPosn+ChangeToLength)
  2882. end
  2883. return(TheString)
  2884.  
  2885. CloseAndDeleteFile:
  2886. dfFile=arg(1)
  2887. CloseRc=stream(dfFile, 'c', 'close')
  2888. DosDelRc=_SysFileDelete(dfFile)
  2889. return(DosDelRc)
  2890.  
  2891. DebugAddressCmdBefore:
  2892. call DebugLine 'Executing: ' ||arg(1)
  2893. return
  2894.  
  2895. DebugAddressCmdOutput:
  2896. DbgLineNumber=arg(2)
  2897. if datatype(DbgLineNumber, 'W')=0 then
  2898. call DebugLine '  > ' ||arg(1)
  2899. else
  2900. do
  2901. if DbgLineNumber<999 then
  2902. DbgLineNumber=right(DbgLineNumber,3, '0')
  2903. call DebugLine '  > ' || DbgLineNumber || ': ' ||arg(1)
  2904. end
  2905. return
  2906.  
  2907. DebugAddressCmdAfter:
  2908. call DebugLine '  Rc = ' ||arg(1)
  2909. return
  2910.  
  2911. _Lineout:
  2912. loFileName=arg(1)
  2913. loTheLine=arg(2)
  2914. if 0<>lineout(loFileName,loTheLine)then
  2915. do
  2916. if Dying='N' then
  2917. do
  2918. FileState=stream(loFileName, 'Description')
  2919. CryAndDie('Failed writing line to "' || loFileName || '" - ' ||FileState)
  2920. end
  2921. end
  2922. return
  2923.  
  2924. CryAndDie:
  2925. signal off HALT
  2926. call on HALT name RexxCtrlCIgnore
  2927. ExitRc=SIGL
  2928. Dying='Y'
  2929. call SayAndDebugLine "ERROR: " ||arg(1)
  2930. if MemoryNeedsUpdating()='Y' then
  2931. do
  2932. call MemoryClose
  2933. end
  2934. call LoggedExit(ExitRc)
  2935.  
  2936. LoggedExit:
  2937. PgmRc=arg(1)
  2938. OrigPgmRc=PgmRc
  2939. if RexWhich='REGINA' then
  2940. do
  2941. if PgmRc='OK' then
  2942. PgmRc=0
  2943. else
  2944. PgmRc=1000+length(PgmRc)
  2945. end
  2946. call DebugLine ''
  2947. call DebugLine 'Return code'
  2948. call DebugLine '~~~~~~~~~~~'
  2949. if OrigPgmRc=PgmRc then
  2950. call DebugLine PgmRc
  2951. else
  2952. call DebugLine PgmRc|| ' , translated from => ' ||OrigPgmRc
  2953. call DebugLine ''
  2954. exit(PgmRc)
  2955.  
  2956. SetupMovedText:
  2957. NewMovedText=arg(1)
  2958. if NewMovedText='' then
  2959. do
  2960. call DebugLine ''
  2961. call DebugLine 'Initialised "MovedText"'
  2962. MovedTxt.0=0
  2963. end
  2964. else
  2965. do
  2966. Index=MovedTxt.0+1
  2967. MovedTxt.Index=NewMovedText
  2968. MovedTxtU.Index=translate(NewMovedText)
  2969. MovedTxt.0=Index
  2970. call DebugLine 'Added "MovedText" of "' || NewMovedText || '"'
  2971. end
  2972. return
  2973.  
  2974. ReplaceCommandLineCodes:
  2975. RightBit=arg(1)
  2976. LeftBit=''
  2977. StartPos=pos('{x',RightBit)
  2978. do while StartPos<>0
  2979. Codes2=substr(RightBit,StartPos+2,2)
  2980. if datatype(Codes2, 'X') <> 1 | substr(RightBit, StartPos+4, 1) <> '}' then
  2981. do
  2982. LeftBit=LeftBit||left(RightBit,StartPos+1)
  2983. RightBit=substr(RightBit,StartPos+2)
  2984. end
  2985. else
  2986. do
  2987. LeftBit=LeftBit||left(RightBit,StartPos-1)||x2c(Codes2)
  2988. RightBit=substr(RightBit,StartPos+5)
  2989. end
  2990. StartPos=pos('{x',RightBit)
  2991. end
  2992. return(LeftBit||RightBit)
  2993.  
  2994. GetServerErrorDescription:
  2995. f_ErrType=arg(1)
  2996. f_Rc=''
  2997. select
  2998. when f_ErrType='404' then
  2999. f_Rc='URL Not Found'
  3000. otherwise
  3001. end
  3002. return(f_Rc)
  3003.  
  3004. MyLineNumber:
  3005. return(SIGL)
  3006.  
  3007. DisplayCopyright:
  3008. if CopyrightDisplayed='N' then
  3009. do
  3010. say '[]-------------------------------------------------------------------------[]'
  3011. say '| CHECKURL.REX: Version ' || PgmVersion || ' (C)opyright Dennis Bareis 2000               |'
  3012. say '| http://www.labyrinth.net.au/~dbareis/index.htm (dbareis@labyrinth.net.au) |'
  3013. say '[]-------------------------------------------------------------------------[]'
  3014. CopyrightDisplayed='Y'
  3015. end
  3016. return
  3017.  
  3018. UserSyntaxError:
  3019. call DisplayCopyright
  3020. say "SYNTAX ERROR"
  3021. say "~~~~~~~~~~~~"
  3022. say '    ' ||arg(1)
  3023. say ''
  3024. say 'CORRECT SYNTAX'
  3025. say '~~~~~~~~~~~~~~'
  3026. say '    CHECKURL[.CMD] Command [Parm1 ...] [Option1 ...]'
  3027. say ''
  3028. say 'SOME OPTIONS'
  3029. say '~~~~~~~~~~~~'
  3030. say RexOptionChar|| 'ErrorFile[:[+]FileName] = Generate list of error URLs'
  3031. say RexOptionChar|| 'MemoryFile[:FileName]   = Long term memory of results'
  3032. say RexOptionChar|| 'CheckDays[:Period]      = Controls how long term memory used'
  3033. say RexOptionChar|| 'TestUrl[:Url]           = Define known URL which exists'
  3034. say RexOptionChar|| 'ReadTimeout:Seconds     = Define read timeout'
  3035. say RexOptionChar|| 'GetEnv:NameOfVariable   = Specify source of more options'
  3036. say ''
  3037. say 'Please see "CHECKURL.HTM" for more details (and more options).' ||Beep||Beep
  3038. LoggedExit(MyLineNumber())
  3039.  
  3040. RexxTrapAddInfo:
  3041. if symbol('ProcessingThisUrl') = 'VAR' then
  3042. do
  3043. if ProcessingThisUrl<> '' then
  3044. call SayAndDebugLine left('URL', 16) || ': ' ||ProcessingThisUrl
  3045. end
  3046. return
  3047.  
  3048. RexxTrapDying:
  3049. call charout,Beep||Beep
  3050. call LoggedExit arg(1)
  3051.  
  3052. RexxCtrlC:
  3053. IgnoredCount=0
  3054. LineCtrlC=SIGL
  3055. signal off HALT
  3056. call on HALT name RexxCtrlCIgnore
  3057. call SayAndDebugLine ''
  3058. call SayAndDebugLine copies('=+',39)
  3059. call SayAndDebugLine "Come on, you pressed Ctrl+C or Break didn't you!"
  3060. call SayAndDebugLine copies('=+',39)
  3061. if MemoryNeedsUpdating()='Y' then
  3062. do
  3063. say ''
  3064. say 'Please wait while INI is updated....'
  3065. call MemoryClose
  3066. say ''
  3067. say 'Phew... Lucky Phil, INI file update completed!'
  3068. end
  3069. exit(LineCtrlC)
  3070.  
  3071. RexxCtrlCIgnore:
  3072. IgnoredCount=IgnoredCount+1
  3073. call off HALT
  3074. call on HALT name RexxCtrlCIgnore
  3075. if IgnoredCount<>1 then
  3076. say "Some people just don't listen!"
  3077. say 'WARNING: Please wait while INI is updated....'
  3078. return
  3079.