home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / yrndl153.zip / YARNDIAL.CMD < prev    next >
OS/2 REXX Batch file  |  1997-03-13  |  92KB  |  2,744 lines

  1. /* YARNDIAL.CMD v 1.53 by Jerry Levy  13 Mar 97
  2. Comments appreciated: send to jlevy@ibm.net
  3. (Jerry Levy, Marblehead, MA USA) */
  4.  
  5. version = '1.53'
  6.  
  7. local_error_trapping = 1
  8.  
  9. choose = ''
  10. arg choose
  11.  
  12. /*
  13. ===========History============
  14. See YD.DOC for details.
  15.  
  16. YARNDIAL v. 1.53     13 Mar 97
  17.   Some fixes
  18.  
  19. YARNDIAL v. 1.52     04 Mar 97 (GA Release)
  20.   Numerous small changes/customization/corrections so runs
  21.   equally well under Object ReXX as well as Classic ReXX
  22.  
  23. YARNDIAL v. 1.50     25 Jan 97
  24.    Final beta.
  25.    Added: support for multiple ISP's
  26.  
  27. YARNDIAL v. 1.42 (several betas)     to 25 Jan 97
  28.    Bug-catching in YARNDIAL.CMD.
  29.    Support for use of VSOUP (VSOUP1.2.5) as alternative to SOUPER.
  30.    Eliminated TIMER.CMD (see README.1ST, YD.DOC).
  31.    Changes in YDINSTL, mostly related to VSoup support.
  32.    Souper and VSoup _xtra_options changed
  33.  
  34. ==========COPYRIGHT NOTICE AND DISCLAIMER=============
  35. YDINSTL.CMD is Copyright 1996-7 by Jerry Levy (all rights reserved)
  36. YARNDIAL.CMD is Copyright 1995-7 by Jerry Levy (all rights reserved)
  37.  
  38. These are provided as-is and without charge, with no warranty expressed
  39. or implied as to merchantability or fitness for any particular purpose.  All
  40. responsibility for any and all incidental and consequential damages is
  41. disclaimed.  These programs and associated text files are freeware.  They
  42. may be distributed without restriction providing: (1) this notice and
  43. disclaimer remain intact, (2) all programs and files are included and
  44. unchanged, and (3) they are distributed either in the original .zip archive
  45. or the archive after being unzipped into a folder or onto a disk or other
  46. medium.  Use of either or both of these programs constitutes acceptance
  47. of these terms by all users.
  48.  
  49. ================INSTALLATION======================
  50. You could read YD.DOC.
  51. Or you could read README.1ST (shorter, recommended).
  52.  
  53. If YARN and SOUPER are installed and run OK...
  54.  
  55. ...and if you are using the IAK Dialer to connect to IBM/IGN/Advantis,
  56. or the Dial-Other-Internet_Providers utility (SLIPPM.EXE)...
  57.  
  58. then just run YDINSTL.CMD.
  59. ==================================================
  60.  
  61. */
  62.  
  63. cr = d2c(13)        /* enter key, as well as carriage return */
  64. crlf = d2c(13) || d2c(10)   /* carriage return + linefeed */
  65. escape = d2c(27)   /* escape character */
  66. ctrl_Q = d2c(17)
  67. ctrl_R = d2c(18)
  68. bs = d2c(8)   /* Backspace */
  69. tab = d2c(9)   /* tab */
  70. X1 = d2c(0)   /* Extended key */
  71. X2 = d2c(224)   /* Extended key */
  72.  
  73. /* We back up the soup.zip created from incoming mail, but not the
  74. one created for incoming news.  You can change that by editing these
  75. two assignments.  1 we back up, 0 we don't. */
  76. make_mail_soupzip_backup = 1
  77. make_news_soupzip_backup = 0
  78.  
  79. do_not_kill = 0
  80. rebuilt = 0
  81. remote = 0
  82.  
  83. call Welcome      /* Say Hello */
  84.  
  85. if local_error_trapping then signal on failure
  86. if local_error_trapping then signal on halt
  87. if local_error_trapping then signal on syntax
  88. if local_error_trapping then signal on error
  89. if local_error_trapping then signal on notready
  90. if local_error_trapping then signal on novalue
  91.  
  92. trace 'N'
  93.  
  94. timeout = 0      /* Flag is reset to 1 if dialer times out */
  95.  
  96. Abandon = 0     /* Initialize */
  97. replies_zip = 1        /* if we try to export mail and there is none, this is reset to 0 */
  98. do_catchup_on_news = 0        /* initialize the flag to do no news catchup */
  99.  
  100. queue_ydext = rxqueue('GET') /* current active queue */
  101.  
  102. /* create named dataqueue */
  103. queue_ydint = 'Q_YD_INT'        /* for use inside YARNDIAL */
  104. call rxqueue 'DELETE', queue_ydint        /* If a queue_ydint queue existed, kill it */
  105. call rxqueue 'CREATE', queue_ydint        /* Create our internal queue */ 
  106. call rxqueue 'SET', queue_ydint        /* Set our internal queue active */ 
  107. call rxqueue 'SET', queue_ydext        /* Set external queue active */ 
  108.  
  109. /* MAIN PROGRAM */
  110.  
  111. /* Load Rexx Util functions if not already loaded */
  112. if RxFuncQuery('SysLoadFuncs') \= 0 then
  113.    do
  114.       call RxFuncAdd 'SysLoadFuncs', 'REXXUTIL', 'SysLoadFuncs'
  115.       call SysLoadFuncs
  116.    end
  117.  
  118. /* Initialize these filenames */
  119. go_exe = 'GO.EXE'
  120. ydinstl_cmd = 'YDINSTL.CMD'
  121. ydparms_dat = 'YD_PARMS.DAT'
  122. killjoy_exe = 'KILLJOY.EXE'
  123. alt_dialer_exe = 'SLIPPM.EXE'
  124. logfile = 'C:\DESKTOP\LOG.TXT'
  125.  
  126. '@echo off'        /* No echoing of any os/2 commands */
  127.  
  128. /* Read parameters in from the ydparms.dat datafile */
  129. call parms_from_ydparms_dat
  130.  
  131. /* CHOOSE is the command-line argument, if any */
  132. call analyze_choose
  133.  
  134. /* We look for some obvious inconsistencies or omissions in YDPARMS_DAT */
  135. call fatal_error_check
  136.  
  137. call directory_maintenance
  138.  
  139. /* are we connected? to whom? is it the right connection? */
  140. call get_current_connection
  141.  
  142. /*
  143. ================
  144. Call up the main_menu.  What do we want to do? We can get mail, news, send, etc.
  145. Returns a variable CHOICE = 1, 2, 3, 4, 5, 6, or 7.  Or Escape or CTRL-Q to quit.
  146. 1 = get mail only
  147. 2 = get news only
  148. 3 = get both mail and news
  149. 4 = export replies, posts, etc. (only export, no retrieval)
  150. 5 = get mail and news, export replies, posts, etc.
  151. 6 = Fix an interrupted import
  152. 7 = set catchup on news, read-only for mail, limit size of news articles
  153.      and then we are re-prompted whether to get, send, etc.
  154. ================
  155. */
  156. if \remote then call main_menu
  157.  
  158. if \remote then call analyze_choice        /* From main_menu() response */
  159.  
  160. /*
  161. ====================
  162. A home\replies folder (empty) may be left behind as trash
  163. after execution of mail/news retrieval from some Yarn/Souper
  164. installations. We get rid of it if your setup of Yarn/Souper
  165. leaves one behind.
  166. ====================
  167. */
  168. replies_dir = home || '\replies'
  169. call SysRmDir replies_dir
  170.  
  171. /* Do whatever we selected we wanted to do from the main_menu() */
  172.  
  173. /*
  174. ============
  175. Process MAIN_MENU selection = 6.
  176. 6 = Fix the interrupted import
  177. ============
  178. */
  179. if choice = pos(choice, 'xxxxx6x') then
  180.    do
  181.       call fix_import_message
  182.       k = 1
  183.       call fix_import
  184.       if number_of_ISPs > 1 then
  185.         do k = 2 to number_of_ISPs
  186.            if isp_active.k = 0 then iterate
  187.            if popsrvr.k = '' then iterate
  188.            call fix_import
  189.         end
  190.       signal goodbye        /* Exit the program when done */
  191.    end
  192.  
  193. /*
  194. ============
  195. Process MAIN_MENU selection = 7.
  196. 7 = set some souper switches so we can
  197.   do read-only for mail, limit news-article size, do catchup on news
  198.  
  199. First: tell us what we're going to do.
  200. ============
  201. */
  202. if choice = pos(choice, 'xxxxxx7') then
  203.    do
  204.       call SysCls
  205.       say ''
  206.       say 'You selected to modify souper options.'
  207.       say ''
  208.       say 'We will first dial in.'
  209.       say ''
  210.       say 'After a connection is successfully established you will'
  211.       say 'be asked to select your one-time-only Souper/VSoup options.'
  212.       say ''
  213.       say 'When you are finished with that, another menu will pop'
  214.       say 'up asking if you want to do news catchup, to get news or mail,'
  215.       say 'or to send posts.'
  216.       say ''
  217.       say 'To quit now, press Escape'
  218.       say 'Any other key starts the dialup connection or uses one already up'
  219.       if SysGetKey('NOECHO') = Escape then signal goodbye
  220.       else NOP
  221.     end
  222.  
  223. /*
  224. ============
  225. These are for all selections.  Dial up if not already connected.
  226. ============
  227. */
  228. call dialup_server
  229. call time 'R'        /* start clock recording time on line */
  230. t = 0
  231.  
  232. /*
  233. ============
  234. Now, for MAIN_MENU selection = 7 again
  235. ============
  236. */
  237.  
  238.       if choice = pos(choice, 'xxxxxx7') then
  239.         do
  240.            call souper_options
  241.            if \remote then choice = menu2()        /* calls menu2() */
  242.         end
  243. /*
  244. =================
  245. For remaining MAIN_MENU selections of 1, 2, 3, 4, 5.
  246. 1 = get mail only
  247. 2 = get news only
  248. 3 = get both mail and news
  249. 4 = export replies, posts, etc. (only export, no retrieval)
  250. 5 = get mail and news, export replies, posts, etc.
  251. =================
  252. */
  253.       k = 1
  254.       if choice = pos(choice, '1x3x5xx') then call import_mail
  255.       if number_of_ISPs > 1 then
  256.         do k = 2 to number_of_ISPs
  257.            if isp_active.k = 0 then iterate
  258.            if popsrvr.k = '' then iterate
  259.            if choice = pos(choice, '1x3x5xx') then call import_mail
  260.         end
  261.  
  262.       k = 1
  263.       if choice = pos(choice, 'x23x5xx') then call import_news
  264.       if number_of_ISPs > 1 then 
  265.         do k = 2 to number_of_ISPs
  266.            if isp_active.k = 0 then iterate
  267.            if default_news.k = '' then iterate
  268.            if choice = pos(choice, 'x23x5xx') then call import_news
  269.         end
  270.  
  271.       if choice = pos(choice, 'xxx45xx') then call exporter /* only export once */
  272.  
  273. call kill_dialers_slip_ppp_slattach        /* Kill these and slattach, too */
  274.  
  275. if \remote then call restore_zip        /* If sending went south on you, you can restore to send again */
  276. if \remote then call toss_old_news
  277.  
  278. signal Depart        /* Exit and report times */
  279. /*
  280. =======================
  281. goodbye()
  282. quit()
  283. depart()
  284.  
  285. Exit routines.  Most exits are jumps to
  286. goodbye()
  287. =======================
  288. */
  289.  
  290. goodbye:
  291. call kill_dialers_slip_ppp_slattach        /* Now fall into DEPART() */
  292.  
  293. Depart:
  294. if timeout then signal Quit
  295. say ''
  296. if \rebuilt then call connect_stats        /* tell us elapsed time, unless we were fixing import */
  297. x = EndLocal()
  298.  
  299. /* Now fall into QUIT() */
  300.  
  301. Quit:
  302. say ''
  303. if \remote then say 'Done. Press any key to exit...'        
  304. if \remote then answer = SysGetKey('NOECHO')
  305. if remote then say 'Remote operation over at' time() date()
  306. EXIT
  307.  
  308. RETURN
  309.  
  310. /*
  311. ======================================================
  312. End of main program
  313. ======================================================
  314. */
  315.  
  316. /*
  317. =====================
  318. welcome()
  319.  
  320. Say Hello.
  321. =====================
  322. */
  323. welcome:
  324. say ''
  325. say 'YRNDIAL.CMD v' || version
  326. say '(c) 1995-7 by Jerry Levy (all rights reserved)'
  327. say 'jlevy@ibm.net        Marblehead, MA USA'
  328. say ''
  329. say 'Dials in, gets or posts news, mail and replies.'
  330. say 'Normally this program closes the connection upon exiting.' crlf
  331. time1 = time()
  332. date1 = date('S')
  333. /* format date as yyyy/mm/dd */
  334. date1 = left(date1,4) || '/' || substr(date1,5,2) || '/' || right(date1,2)
  335. RETURN
  336.  
  337. /*
  338. =======================================
  339. fatal_error_check()
  340.  
  341. We check for some obvious flaws in the data
  342. returned from YDPARMS_DAT
  343. =======================================
  344. */
  345.  
  346. fatal_error_check:
  347. service = translate(service)        /* Upper case */
  348.  
  349. if pos(connection_type, '134567') = 0 & connection_type < 8 then
  350.         /* 2 is reserved for future use */
  351.    do
  352.       call beep 1000, 200
  353.       say ''
  354.       say 'Fatal error in' ydparms_dat '; the connection_type'
  355.       say 'can only be 1, or 3-7'
  356.       say ''
  357.       Abandon = 1
  358.    end
  359.  
  360. if connection_type = pos(connection_type, '13457') & dialup_string = '' then
  361.    do
  362.       call beep 1000, 200
  363.       say ''
  364.       say 'Fatal error in' ydparms_dat
  365.       say 'Dialup_string is blank.  Cannot be blank if connection_type is 1, 3-5, or 7.'
  366.       say ''
  367.       Abandon = 1
  368.    end
  369.  
  370. if service = '' then
  371.    do
  372.       call beep 1000, 200
  373.       say ''
  374.       say 'Possible error in' ydparms_dat 'SERVICE field is blank.'
  375.       say 'Usually would contain something like: PPP, SLIP, SL, etc.'
  376.    end
  377.  
  378. if override_dnk_during_remote \= 0 & override_dnk_during_remote \= 1 then
  379.    do
  380.       call beep 1000, 200
  381.       say ''
  382.       say 'Fatal error in' ydparms_dat
  383.       say 'OVERRIDE_DNK_DURING_REMOTE can only be 0 or 1'
  384.       if pos(interface_removal, 'Oo') \=0 then
  385.         say 'You have the letter' pos(interface_removal, 'Oo') 'there now.'
  386.       say ''
  387.       say 'A setting of 1 is advised if you are running from a timer program'
  388.       say 'and if you could rack up huge phone and connection bills if your'
  389.       say 'connection stayed up.'
  390.       override_dnk_during_remote = 1
  391.       do_not_kill_connection = 0
  392.       do_not_kill = 0
  393.        
  394.       Abandon = 1
  395.    end
  396.  
  397. if vsoup \= 0 & vsoup \= 1 then
  398.    do
  399.       call beep 1000, 200
  400.       say ''
  401.       say 'Fatal error in' ydparms_dat
  402.       say 'VSOUP in' ydparms_dat 'is neither 0 nor 1.'
  403.       say 'VSOUP can only be 0 or 1'
  404.       if pos(interface_removal, 'Oo') \=0 then
  405.         say 'You have the letter' pos(interface_removal, 'Oo') 'there now.'
  406.       say ''
  407.       say 'A setting of 1 means you are running VSOUP.EXE.'
  408.       say 'A setting of 0 means you are running SOUPER.EXE.'
  409.       say 'You must edit VSOUP in the' ydparms_dat
  410.       say 'file to  to equal 0 or 1, depending on which of these'
  411.       say 'programs you are using.'
  412.       Abandon = 1
  413.    end
  414.  
  415. if pos(getmail_autho.1, '123') = 0 & getmail_autho.1 < 4 & vsoup = 1,
  416.    & pos(getnews_autho.1, '123') = 0 & getnews_autho.1 < 4,
  417.    & pos(send_autho.1, '123') = 0 & send_autho.1 < 4 then
  418.    do
  419.       call beep 1000, 200
  420.       say ''
  421.       say 'Fatal error in' ydparms_dat
  422.       say 'getmail_autho.1, getnews_autho.1, and send_autho.1 can only be 1, 2, or 3'
  423.       if pos(getmail_autho.1, 'Oo') \=0,
  424.         | pos(getnews_autho.1, 'Oo') \=0,
  425.         | pos(send_autho.1, 'Oo') \=0 then
  426.         say 'You may have a wrong value or the letter O or o there now.'
  427.       say ''
  428.       Abandon = 1
  429.    end
  430.  
  431. /* Check if domain nameserver addresses are both blank.  If only
  432. on is, copy the other over to it.  Error only if both are missing. */
  433. if DNS = '' then DNS = DNS2
  434. if DNS2 = '' then DNS2 = DNS
  435. if DNS = '' & DNS2 = '' then
  436.    do
  437.       call beep 1000, 200
  438.       say ''
  439.       say 'Possible error: nothing in DNS or DNS2 fields in' ydparms_dat ||','
  440.       say 'DNS and DNS2 are the domain nameserver addresses (main and'
  441.       say 'alternate) in Decimal Dot notation.  At least one of these fields'
  442.       say 'must be populated.  It would look like: 150.203.23.247'
  443.       say ''
  444.    end
  445.  
  446. if VSOUP = 0 & stream(souper_exe, 'c', 'query exists') = '' then
  447.    do
  448.       Abandon = 1
  449.       say ''
  450.       say 'You are trying to run YARNDIAL with SOUPER and we cannot'
  451.       say 'find' souper_exe || '. You must either copy SOUPER to the'
  452.       say 'directory indicated or edit the name and/or path of the'
  453.       say 'SOUPER_EXE entry in' ydparms_dat 'to correctly'
  454.       say 'indicate where the SOUPER program is located.'
  455.    end
  456.  
  457. if VSOUP = 1 & stream(vsoup_exe, 'c', 'query exists') = '' then
  458.    do
  459.       Abandon = 1
  460.       say ''
  461.       say 'You are trying to run YARNDIAL with VSOUP and we cannot'
  462.       say 'find' vsoup_exe || '. You must either copy VSOUP to the'
  463.       say 'directory indicated or edit the name and/or path of the'
  464.       say 'VSOUP_EXE entry in' ydparms_dat 'to correctly'
  465.       say 'indicate where the VSOUP program is located.'
  466.    end
  467.  
  468. if Abandon = 1 then
  469.    do
  470.       say 'Aborting...'
  471.       signal goodbye
  472.    end
  473. RETURN
  474.  
  475. /*
  476. =================
  477. get_current_connection()
  478.  
  479. (1)  Check whether slippm.exe, slip.exe, ppp.exe, in-joy.exe,
  480. IAK Dialer, ilink2.exe are running.  Are what is running the right
  481. processes for our connection_type and service (SLIP or PPP)?
  482. Of these processes:
  483.         SLIP.EXE
  484.         PPP.EXE
  485.         SLIPPM.EXE
  486.         IN-JOY.EXE
  487.         ILINK2.EXE
  488.         the IAK Dialer
  489.         whatever alt_dialer_exe is
  490.  
  491. Close down any that are not consistent with
  492. our connection_type.
  493.  
  494. Then determine: which ones are (left) running?
  495.  
  496.  
  497. (2)  Check for sl and ppp and other router interfaces
  498. ====================
  499. */
  500. get_current_connection:
  501. say 'Check for an existing connection, and whether it is correct for us:'
  502. say '   Active dialers? Active SLIP?  Active PPP?'
  503.  
  504. if connection_type = 1 then        /* IBM/IGN/Advantis IAK Dialer only */
  505.    do
  506.       service = 'SLIP'        /* must be SLIP for the IAK Dialer */
  507.       call close_down 'ppp'        /* ...because none of these should be running */
  508.       call close_down 'slippm'
  509.       call close_down 'in-joy'
  510.       call close_down 'ilink2'
  511.       if alt_dialer \= 'DIALER' then
  512.         call close_down alt_dialer
  513.    end
  514.  
  515. /* for connection_type 6 (pot luck) we check (almost) nothing */
  516. if connection_type = 6 then
  517.    do
  518.       if service = 'PPP' then call close_down 'slip'
  519.       if service = 'SLIP' then call close_down 'ppp'
  520.    end
  521.  
  522. if pos(connection_type, '45') \= 0,
  523.    & alt_dialer = 'SLIPPM' then
  524.    do
  525.       call close_down 'in-joy'
  526.       call close_down 'dialer'
  527.       call close_down 'ilink2'
  528.    end
  529.  
  530. if pos(connection_type, '45') \= 0,
  531.    & alt_dialer = 'IN-JOY' then
  532.    do
  533.       call close_down 'slip'        /* IN-JOY doesn't use this...*/
  534.       call close_down 'ppp'        /* ...or these...*/
  535.       call close_down 'slippm'
  536.       call close_down 'ilink2'
  537.       call close_down 'dialer'        /*...IAK Dialer */
  538.    end
  539.  
  540. if pos(connection_type, '45') \= 0,
  541.    & alt_dialer = 'ILINK2' then
  542.    do
  543.       call close_down 'in-joy'
  544.       call close_down 'dialer'
  545.       call close_down 'slippm'
  546.    end
  547.  
  548. if pos(connection_type, '45') \= 0,
  549.    & alt_dialer \= 'SLIPPM',
  550.    & alt_dialer \= 'ILINK2',
  551.    & alt_dialer \= 'DIALER',
  552.    & alt_dialer \= 'IN-JOY' then
  553.    do
  554.       call close_down 'slippm'
  555.       call close_down 'ilink2'
  556.       call close_down 'dialer'
  557.       call close_down 'in-joy'
  558.    end
  559.  
  560. if connection_type = 3 then        /* PPP.EXE or SLIP.EXE dialup string only */
  561.    do
  562.       if service = 'SLIP' then
  563.         call close_down 'ppp'
  564.       if service = 'PPP' then
  565.         call close_down 'slip'
  566.       call close_down 'slippm'
  567.       call close_down 'in-joy'
  568.       call close_down 'ilink2'
  569.       if alt_dialer \= 'PPP' & alt_dialer \= 'SLIP' then
  570.         call close_down alt_dialer
  571.    end
  572.  
  573.  
  574. /*
  575. ===============
  576. See what stuff related to dialers or dialup strings may
  577. be running
  578.  
  579. and
  580.  
  581. Poll the routers: e.g., is an sl or a ppp interface up?
  582. Note, however, that what is returned may not be
  583. currently active, and what is returned could represent
  584. the last occurrence not a present connection.
  585. Calls wait_for_interface(), which uses
  586. NETSTAT.EXE -r to poll.
  587. ===============
  588. */
  589.  
  590. /*
  591. ==================
  592. Below are flags.  They are set to 1 if a process is running
  593. or if an interface is up.  Initialize all to zero
  594. ==================
  595. */
  596.  
  597. slip_is_running = 0
  598. ppp_is_running = 0
  599. IAKdialer_is_running = 0
  600. slippm_is_running = 0
  601. ilink2_is_running = 0
  602. alt_dialer_is_running = 0
  603. slipexe_or_pppexe_running = 0
  604.  
  605. some_interf_up = 0
  606. ifprefix_interf_up = 0
  607.  
  608. /* are any of these running? */
  609. call is_slip_running        /* If so returns slip_is_running=1 */
  610. call is_ppp_running        /* If so returns ppp_is_running=1 */
  611. call is_slippm_running        /* If so returns slippm_is_running=1 */
  612. call is_ilink2_running        /* If so returns slippm_is_running=1 */
  613. call is_IAKdialer_running        /* If so returns IAKdialer_is_running=1 */
  614. call is_alt_dialer_running /* etcetera */
  615. if slip_is_running | ppp_is_running then slipexe_or_pppexe_running = 1
  616.  
  617. say '   Checking router interfaces...'
  618. /* Check for pppx or slx or lanx router interfaces
  619. we may not use this information, but this step is
  620. done here in anticipation of future uses */
  621.  
  622. call are_there_interfaces_up
  623.  
  624.  
  625. /*
  626. ==================
  627. Get path to TCPOS2.INI file.
  628.  
  629. We get information about the current_connection from
  630. TCPOS2.INI, unless our dialer is IN-JOY which doesn't
  631. talk to TCPOS2.INI.
  632. ==================
  633. */
  634. tcpip_etc_path = value('etc', , 'OS2ENVIRONMENT')
  635. tcpos2_ini = tcpip_etc_path || '\' || 'tcpos2.ini'
  636.  
  637. /*
  638. ==========
  639. TCPOS2.INI inquiries
  640. ==========
  641. */
  642. current_connection_key = SysIni(tcpos2_ini, 'CONNECTION', 'CURRENT_CONNECTION')
  643.  
  644. /* strip final null char */
  645. current_connection_key = strip(current_connection_key, 'T', X1)
  646. userID_connected = SysIni(tcpos2_ini, 'CONNECTION', current_connection_key)
  647. userID_connected = strip(userID_connected, 'T', X1)
  648. parse var userID_connected user_ID ',' system_app
  649.  
  650. /*
  651. ====================
  652. Next we will decide if we need to dial or whether we
  653. can use what may already be established as a connection.
  654.  
  655. When dial = 1 we need to dial.  We will determine
  656. below whether, if we are already on line, we are online
  657. to the provider for this user installation or not.  If
  658. we cannot ID the provider as ours we simply close down
  659. SLIP, PPP, SLIPPM, and the IAK DIALER and redial.  First
  660. we set the dial flag (set dial = 1), then we determine
  661. if we should really dial.  If we are connected to our
  662. provider we zero the dial flag.
  663. ====================
  664. */
  665.  
  666. dial = 1        /* initialize it */
  667.  
  668. /*
  669. ====================
  670. We get parameters from the CONNECTION app of TCPOS2.INI
  671. We can make a pretty good (not perfect) assessment in
  672. this simple way whether we are connected to the right provider.
  673. ====================
  674. */
  675. if alt_dialer_is_running & some_interf_up & connection_type \= 7 then
  676.       select
  677.         when connection_type = 1,
  678.         & IAKdialer_is_running,
  679.         & translate(user_id) = translate(login_ID.1),
  680.         & translate(system_app) = 'ADVANTIS' then
  681.            do
  682.               say 'Two beeps means' user_id 'is already connected to IBM/IGN/Advantis.  Proceed.'
  683.               call connected_signal
  684.            end
  685.  
  686.         when connection_type = 4,
  687.         & (slippm_is_running | ilink2_is_running),
  688.         & translate(user_ID) = translate(login_ID.1) then
  689.            do
  690.               say 'Two beeps means we are already logged in as'
  691.               say user_id '(Pop_ID:' pop_ID.1 || ').  Proceed.'
  692.               call connected_signal
  693.            end
  694.    
  695.         when pos(connection_type, '45') \= 0 & alt_dialer = 'IN-JOY',
  696.         & pos(translate(interf_prefix), make_if_list()) \= 0 then
  697.            do
  698.               say 'Two beeps means we are connected via' alt_dialer
  699.               say 'to' domain_name || '.  Proceed...'
  700.               call connected_signal
  701.            end
  702.    
  703.         when connection_type = 3,   /* slip.exe or ppp.exe dialer string */
  704.         & translate(user_ID) = translate(login_ID.1) then
  705.            do
  706.               say 'Two beeps means we are already logged in as'
  707.               say user_id '(Pop_ID:' pop_ID.1 || ').  Proceed.'
  708.               call connected_signal
  709.            end
  710.    
  711.         when connection_type = 6 then
  712.         dial = 0        /* Pot Luck */
  713.  
  714.         otherwise
  715.            say 'Connected, but to a provider or for a connection different than'
  716.            say 'the one for which this YARN user installation was configured.'
  717.            say 'We are closing down whatever was up (if one was up).'
  718.            say 'We will redial after you select an action from the next menu.'
  719.            say ''
  720.            dial = 1        /* we will dial when we hit dialup_server() */
  721.            connection_type = 7    /* we act like we are connection_type 7 */
  722.  
  723.            x = do_not_kill /* save it */
  724.            do_not_kill = 0  /* temporarily to 0*/
  725.            call kill_all        /* ...so we can kill everything */
  726.            do_not_kill = x  /* and reset it to what it was */
  727.      end   /* of select */
  728.  
  729. if connection_type = 7 | \some_interf_up then
  730.    dial = 1
  731.  
  732. RETURN
  733.  
  734.  
  735. /*
  736. ===============
  737. connected_signal()
  738. Double-beep if connected (no double-beep if in remote mode)
  739. ===============
  740. */
  741. connected_signal:
  742. say ''
  743. if \remote then call beep 1000, 200
  744. if \remote then call beep 32767, 25  /* Too high pitched, inaudible, an improvised pause. */
  745. if \remote then call beep 1000, 200
  746. dial = 0        /* unset the flag: we do not need to dial up server */
  747. RETURN
  748.  
  749.  
  750. /*
  751. =====================
  752. directory_maintenance()
  753.  
  754. Some grunt work to get drives, directories we need.
  755. =====================
  756. */
  757.  
  758. directory_maintenance:
  759. home_drive = filespec('drive', home)
  760. /* Make dirs for temp storage of incoming mail and news.  We make them
  761. compatible with the directory structure recommended by R. Griech
  762. for his VSoup, whether we use VSoup or not */
  763.  
  764. call SysMkDir home || '\yarn'        /* of course this already exists */
  765. call SysMkDir home || '\yarn\in'
  766. call SysMkDir home || '\yarn\in\mail'
  767. call SysMkDir home || '\yarn\in\news'
  768. mail_incoming_dir.1 = home || '\yarn\in\mail'
  769. news_incoming_dir.1 = home || '\yarn\in\news'
  770. if number_of_ISPs > 1 then
  771.    do i = 2 to number_of_ISPs
  772.       call SysMkDir home || '\yarn\in\mail' || i
  773.       call SysMkDir home || '\yarn\in\news' || i
  774.       mail_incoming_dir.i = home || '\yarn\in\mail' || i
  775.       news_incoming_dir.i = home || '\yarn\in\news' || i
  776.    end
  777.  
  778. /* Create an outgoing dir compatible with the directory structure recommended
  779. for VSoup, whether we use it or not */
  780. call SysMkDir home || '\yarn\out'
  781.  
  782. /* Extract drive and dir for the reply packet .zip file */
  783. parse var reply_packet rpname '.' ext
  784. yarn_outgoing_drive = filespec('drive', reply_packet)
  785. yarn_outgoing_dir = yarn_outgoing_drive || strip(filespec('path', reply_packet), 'T', '\')
  786.  
  787. RETURN
  788.  
  789. /*
  790. ================
  791.  routines use GO.EXE to let us determine whether
  792.         SLIP.EXE
  793.         PPP.EXE
  794.         SLIPPM.EXE
  795.         IN-JOY.EXE
  796.         ILINK2.EXE
  797.         DIALER.EXE
  798.         alt_dialer_exe (whatever it is)
  799. are running processes
  800. ================
  801. */
  802.  
  803. is_slip_running:
  804. signal off error
  805. slip_is_running = 0
  806. go_exe '-cp SLIP>NUL'        /* returns 1 if slip is running, 0 if not */
  807. If RC=1 then
  808.    do
  809.       slip_is_running = 1
  810.    end
  811. if local_error_trapping then signal on error
  812. RETURN
  813.  
  814. is_ppp_running:
  815. signal off error
  816. ppp_is_running = 0
  817. go_exe '-cp PPP>NUL'        /* returns 1 if ppp is running, 0 if not */
  818. If RC=1 then
  819.    do
  820.       ppp_is_running = 1
  821.    end
  822. if local_error_trapping then signal on error
  823. RETURN
  824.  
  825. is_slippm_running:
  826. signal off error
  827. slippm_is_running = 0
  828. go_exe '-cp SLIPPM>NUL'        /* returns 1 if slippm is running, 0 if not */
  829. If RC=1 then
  830.    do
  831.       slippm_is_running = 1
  832.    end
  833. if local_error_trapping then signal on error
  834. RETURN
  835.  
  836. is_ilink2_running:
  837. signal off error
  838. ilink2_is_running = 0
  839. go_exe '-cp ILINK2>NUL'        /* returns 1 if ilink2 is running, 0 if not */
  840. If RC=1 then
  841.    do
  842.       ilink2_is_running = 1
  843.    end
  844. if local_error_trapping then signal on error
  845. RETURN
  846.  
  847. is_IAKdialer_running:
  848. signal off error
  849. IAKdialer_is_running = 0
  850. go_exe '-cp DIALER>NUL'        /* returns 1 if IAK Dialer is running, 0 if not */
  851. If RC=1 then
  852.    do
  853.       IAKdialer_is_running = 1
  854.    end
  855. if local_error_trapping then signal on error
  856. RETURN
  857.  
  858. is_alt_dialer_running:
  859. signal off error
  860. alt_dialer_is_running = 0
  861. go_exe '-cp' alt_dialer '>NUL'        /* returns 1 if running, 0 if not */
  862. If RC=1 then
  863.    do
  864.       alt_dialer_is_running = 1
  865.    end
  866. if local_error_trapping then signal on error
  867. RETURN
  868.  
  869. /*
  870. =============================================
  871. main_menu()
  872.  
  873. This is the main YARNDIAL selection menu.  If we select 7 (souper options)
  874. we first dial in to the system and only after we're connected do we get to
  875. select the options.  Then we get another menu asking if we want to get or send stuff.
  876. =============================================
  877. */
  878. main_menu:
  879.    say ''
  880.    say 'MAIN SELECTION MENU'
  881.    say '1  Only import Mail'
  882.    say '2  Only import News Articles'
  883.    say '3  Only import, but both Mail AND News'
  884.    say '4  Only export (send Mail, Posts, Replies, and Follow-ups)'
  885.    say '5  Everything: Get Mail and News AND send Posts, Replies, Follow-ups'
  886.    say '6  Complete an interrupted importation of mail/news or rebuild a'
  887.    say '        corrupted YARN history file (always shuts down dialer)'
  888.    say '7  Souper options:  one-time-only changes in how Souper/VSoup run:'
  889.    say '      Catchup on News'
  890.    say '      Maximum News Packet Size'
  891.    say '      Do not retrieve newsgroup articles longer than set number of lines'
  892.    say '      Read-only for Mail: Don''t empty POP3 mailbox'
  893.    say 'Press:'
  894.    say '    1 2 3 4 5 6 7   Executes functions as shown; goes off-line when done.'
  895.    if do_not_kill_connection then        /* ...then we have a choice */
  896.       do
  897.         say ' or' dnk.1 dnk.2 dnk.3 dnk.4 dnk.5 dnk.6 dnk.7,
  898.         '  Same functions; connection remains up.'   
  899.       end
  900.  
  901.    say 'To exit now and close connection: Escape key'
  902.    if do_not_kill_connection then
  903.       say 'To exit, but leave any existing connection up: CTRL-Q'
  904.    say 'Enter Selection:'
  905. RETURN
  906.  
  907. /*
  908. ===================
  909. analyze_choice()
  910. If we are not logging to a file and choice is 1-7, we pass it on;
  911. if !@#$%^& we intercept, set do_not_kill=1, and translate to 1-7;
  912. if it is an exit command (Escape, ctrl_Q) we quit; and anything else,
  913. it is an incorrect response and we re-prompt.
  914. ===================
  915. */
  916. analyze_choice: 
  917. do until pos(choice, '1234567' || Escape) \= 0 
  918.    choice = SysGetKey('NOECHO')
  919.  
  920. /*
  921. ==================
  922. We can select dnk.1 thru 7 whereby we elect to do the same things
  923. as for choices 1 thru 7 except we do not close down dialer
  924. and other connection stuff at the end.  If any of the dnk. characters
  925. are the 1,2,3,4,5,6, or 7, the dialer is shut down.
  926.  
  927. dnk.1 thru 7 default to the shift-key characters
  928. [on a US keyboard !@#$%^&] for keypresses 12345677]
  929.  
  930. For menu choice 6, the dialer is always shut down so
  931. dnk.6, whatever is entered, is blanked out.
  932. ==================
  933. */
  934.  
  935.    select
  936.       when choice = Escape then
  937.         do
  938.         say 'Quitting Yarndial...'
  939.         signal goodbye
  940.         end
  941.       when choice = ctrl_Q & \do_not_kill_connection then
  942.         do
  943.         choice = ''        /* Blank.  Something that is not a correct one */
  944.         say 'Selection must be 1-7 or Escape key.  Try again...'
  945.         end
  946.        when choice = ctrl_Q & do_not_kill_connection then
  947.         do
  948.         say 'Quitting Yarndial...'
  949.         do_not_kill = 1 
  950.         signal goodbye
  951.         end
  952.       when pos(choice, '1234567') = 0 & \do_not_kill_connection then
  953.         do
  954.         say ''
  955.         say 'Selection must be 1-7 or Escape key.  Try again...'
  956.         say ''
  957.         end
  958.       when pos(choice, '1234567') = 0,
  959.         & do_not_kill_connection,
  960.         & pos(choice, dnk_string) = 0 then
  961.         do
  962.         say ''
  963.         say 'Not an allowable selection, try again...'
  964.         say ''
  965.         end
  966.       when pos(choice, '1234567') = 0,
  967.         & pos(choice, dnk_string) \=0  then
  968.         do
  969.            do_not_kill = 1 
  970.            if choice = dnk.1 then choice = 1
  971.            if choice = dnk.2 then choice = 2
  972.            if choice = dnk.3 then choice = 3
  973.            if choice = dnk.4 then choice = 4
  974.            if choice = dnk.5 then choice = 5
  975.            if choice = dnk.6 then choice = 6
  976.            if choice = dnk.7 then choice = 7
  977.         end
  978.       otherwise NOP
  979.    end        /* of Select */
  980.    dnk_alert = ''
  981.    if do_not_kill = 1 then dnk_alert = '  (connection will stay up when finished)'
  982.    say ''
  983.    say ' Menu Selection: ' choice dnk_alert
  984.    say ''
  985. end        /* of Do Until Pos(choice, '1234567' || Escape) */
  986. RETURN
  987.  
  988. /*
  989. ===================
  990. analyze_choose()
  991. CHOOSE is the command-line argument (or arguments).
  992. CHOOSE can be the value of choice we would make
  993. after being prompted from main_menu()
  994. ===================
  995. */
  996. analyze_choose:
  997. remote = 0
  998.    select
  999.       when strip(choose, 'B') = '' then NOP        /* blank? Then just normal operation */
  1000.       when pos(choose, '12345') = 0 & \do_not_kill_connection then
  1001.         do
  1002.            selection = '"Menu" selection(' choose '=' c2x(choose) || 'hex) invalid.  Terminating YarnDial.'
  1003.            say selection
  1004.         end
  1005.       when pos(choose,  '12345' || dnk.1 || dnk.2 || dnk.3 || dnk.4 || dnk.5) = 0,
  1006.         & do_not_kill_connection then
  1007.         do
  1008.            selection = '"Menu" selection(' choose '=' c2x(choose) || 'hex) invalid.  Terminating YarnDial.'
  1009.            say selection
  1010.         end
  1011.       when pos(choose, '12345') \= 0,
  1012.         & length(choose) = 1 & \do_not_kill_connection then
  1013.         do
  1014.            choice = choose 
  1015.            remote = 1
  1016.         end
  1017.       when pos(choose, '12345') \= 0,
  1018.         & length(choose) = 1 & do_not_kill_connection then
  1019.         do
  1020.            choice = choose 
  1021.            remote = 1
  1022.         end
  1023.       when pos(choose, dnk.1 || dnk.2 || dnk.3 || dnk.4 || dnk.5) \= 0,
  1024.         & length(choose) = 1 & do_not_kill_connection then
  1025.         do
  1026.            do_not_kill = 1
  1027.            choice = choose 
  1028.            if choice = dnk.1 then choice = 1
  1029.            if choice = dnk.2 then choice = 2
  1030.            if choice = dnk.3 then choice = 3
  1031.            if choice = dnk.4 then choice = 4
  1032.            if choice = dnk.5 then choice = 5
  1033.            remote = 1
  1034.         end
  1035.       otherwise NOP
  1036.    end        /* of Select */
  1037.  
  1038.    dnk_alert = ''
  1039.    if override_dnk_during_remote & remote then do_not_kill = 0        /*override to kill conn. */
  1040.    if do_not_kill = 1 then dnk_alert = '  (connection will stay up when finished)'
  1041. RETURN
  1042.  
  1043. /*
  1044. ====================
  1045. This is the menu that comes up after we have made
  1046. one-time-only changes (i.e., for this session only) to the
  1047. souper command-line options after selecting 7 from  main_menu().
  1048.  
  1049. The selections: 1-5, are the same exact functional operation as
  1050. from selecting 1-5 on main_menu().
  1051. ====================
  1052. */
  1053. menu2:
  1054.    say ''
  1055.    say '   Any changed option settings are in force for this session only.'
  1056.    say ''
  1057.    say 'Press:'
  1058.    say '1  Only import Mail'
  1059.    say '2  Only import News Articles'
  1060.    say '3  Only import, but both Mail AND News'
  1061.    say '4  Only export (send Mail, Posts, Replies, and Follow-ups)'
  1062.    say '5  Everything: Get mail and news AND send Posts, Replies, and Follow-ups'
  1063.    say 'Pressing Esc key exits now.  Enter Selection:'
  1064.  
  1065. do until pos(choice, '12345') \= 0 
  1066.    choice = SysGetKey('NOECHO')
  1067.    select
  1068.       when choice = Escape then signal goodbye
  1069.       when pos(choice, '12345') = 0 then
  1070.         do
  1071.            say ''
  1072.            say 'Selection' choice || '.  Must be 1-5 or Escape key.  Try again...'
  1073.            say ''
  1074.         end
  1075.       otherwise NOP
  1076.    end
  1077.    say ''
  1078.    say 'Selection: ' choice
  1079.    say ''
  1080. end
  1081. RETURN choice
  1082.  
  1083. /*
  1084. =========================================================
  1085. dialup_server()
  1086.  
  1087. Starts dialers.  As dialer is starting up and logging in,
  1088. wait_for_interface() starts a timed wait.  When we connect,
  1089. the wait_for_interface() senses a new ppp, slip, etc.
  1090. interface by interpreting the output of netstat.exe run with the -r
  1091. option, and this subroutine ends. If we time out, the
  1092. wait_for_interface() senses that and we exit YARNDIAL.
  1093.  
  1094. We start by reassigning some variables depending upon the
  1095. connection_type, then we start the actual dialup.
  1096.  
  1097. The dial variable was assigned 0 or 1 in the get_current_connection()
  1098. subroutine.  If dial=1 we must dial, if dial=0, we were connected to
  1099. the right provider already and do not dial.
  1100.  
  1101. =========================================================
  1102. */
  1103. dialup_server:
  1104. /*
  1105. =============
  1106. connection_type 1 is for IAK Dialer only
  1107. =============
  1108. */
  1109. if connection_type = 1 then        /* IAK Dialer only */
  1110.    do
  1111.       say 'Connecting to IBM/IGN/Advantis via the IAK Dialer...'
  1112.       if dial then
  1113.         do
  1114.         dialing_msg = login_ID.1 'dialing' account '<password> via use of IAK Dialer'
  1115.         say dialing_msg 
  1116.         end
  1117.    end        /* if connection_type = 1 */
  1118.  
  1119. if pos(connection_type, '34') \= 0 then
  1120.    do
  1121.       if dial then
  1122.         do
  1123.         if connection_type = 3 then dialing_msg = 'Dialing with a PPP.EXE or SLIP.EXE dialup string'
  1124.         if connection_type = 4 then dialing_msg = 'Dialing' host_app 'with' alt_dialer_exe
  1125.         say dialing_msg
  1126.         end
  1127.    end    /* if connection_type 3 or 4 */
  1128.  
  1129. /*
  1130. =============
  1131. For connection_type 6 (especially), but also for
  1132. 5 and 7, we are a bit more flexible about where
  1133. some parms we need may be found in YD_PARMS.DAT
  1134. =============
  1135. */
  1136. if pos(connection_type, '567') \= 0 then
  1137.    do
  1138.       if connection_type = 5 then
  1139.         do
  1140.            dialing_msg = 'YD_PARMS.DAT was manually configured: Dialing with',
  1141.         || crlf || 'dialup_string in YD_PARMS.DAT...'
  1142.            say dialing_msg
  1143.         end
  1144.  
  1145.       if connection_type = 6 then
  1146.         do
  1147.            say 'Will not attempt to validate vs. parameters in YD_PARMS.DAT'
  1148.            dialing_msg = 'Trying to use any currently established connection...'
  1149.            say dialing_msg
  1150.         end
  1151.  
  1152.       if connection_type = 7 then
  1153.         do
  1154.            say 'Will not attempt to validate vs. parameters in YD_PARMS.DAT'
  1155.            say 'Dialing with dialup_string in YD_PARMS.DAT...'
  1156.         end
  1157.    end        /* if connection_type 5, 6 or 7 */
  1158.  
  1159. /*
  1160. ===================
  1161. Dial up.
  1162. Unless we are connection_type 6, we wait for
  1163. sl0 or ppp0 interface before going on to get/send
  1164. mail or news.  Or if we time out after 'wait'
  1165. seconds, we exit
  1166. ===================
  1167. */
  1168. if connection_type = 1 & dial then
  1169.    do
  1170.      call make_if_list
  1171.      interpret dialup_string
  1172.  
  1173.  /* 'wait' = seconds to wait for a connect */
  1174.       call wait_for_interface wait, 0
  1175.       if \found_interface then
  1176.         do
  1177.            timeout = 1
  1178.            say ''
  1179.            say 'Dialer timed out.  Exiting...'
  1180.            call time 'R'  /* No connection.  We zero the elapsed-time clock */
  1181.            t = 0
  1182.            if local_error_trapping then signal on error
  1183.            signal goodbye
  1184.         end
  1185.     end
  1186.  
  1187. if pos(connection_type, '3457') \=0 & dial then
  1188.    do
  1189.       call make_if_list
  1190.       interpret dialup_string
  1191.       call wait_for_interface wait, 0
  1192.       if \found_interface then
  1193.         do
  1194.            timeout = 1
  1195.            say ''
  1196.            say 'Dialer timed out.  Exiting...'
  1197.            call time 'R'
  1198.            t = 0
  1199.            if local_error_trapping then signal on error
  1200.            signal goodbye
  1201.         end
  1202.    end
  1203. RETURN
  1204.  
  1205. /*
  1206. ============================
  1207. import_mail()
  1208. import_news()
  1209. exporter()
  1210. catchup_on_news()
  1211.  
  1212. These four routines are the ones which call SOUPER.EXE
  1213. or VSOUP.EXE
  1214.  
  1215. Vs_auth_string_login.k = [login_ID.k[:pwd.k]@]
  1216. Vs_auth_string_pop.k = [pop_ID.k[:pop_pwd.k]@]
  1217. (the square brackets embrace optional parameters) are
  1218. the VSoup authorization strings for use of either the
  1219. Login_ID and PWD, or the POP_ID and POP_PWD.
  1220. ============================
  1221. */
  1222.  
  1223. import_mail:
  1224. x = directory(mail_incoming_dir.k)        /* Change to this directory */
  1225. /* Set or reset the NNTPSERVER environment variable to default_news */
  1226.       x = value('NNTPSERVER', default_news.k, 'OS2ENVIRONMENT')
  1227.  
  1228. say 'Importing mail from' popsrvr.k
  1229.  
  1230. areas_file = mail_incoming_dir.k || '\areas'
  1231. msgs_file = mail_incoming_dir.k || '\*.msg'
  1232.  
  1233. signal off error
  1234. signal off failure
  1235.  
  1236. /* Go and retrieve the mail.  Souper and VSoup generate
  1237. an areas file and a series of *.msg files */
  1238. if \vsoup then
  1239.    do
  1240.       if getmail_autho.k = 1 then
  1241.         souper_exe souper_getmail_std_options souper_getmail_xtra_options popsrvr.k pop_id.k pop_pwd.k
  1242.       if getmail_autho.k = 2 then
  1243.         souper_exe souper_getmail_std_options souper_getmail_xtra_options popsrvr.k login_ID.k pwd.k
  1244.       if getmail_autho.k = 3 then
  1245.         souper_exe souper_getmail_std_options souper_getmail_xtra_options popsrvr.k
  1246.    end
  1247. else
  1248.    do
  1249.       if remote then call add_hyphenM_to_vsoup_options  /* Serves as a kind of log */
  1250.  
  1251.       if getmail_autho.k = 1 then
  1252.         vsoup_exe vsoup_getmail_std_options vsoup_getmail_xtra_options ,
  1253.         'pop3://' || Vs_auth_string_pop.k || popsrvr.k
  1254.  
  1255.       if getmail_autho.k = 2 then
  1256.         vsoup_exe vsoup_getmail_std_options vsoup_getmail_xtra_options ,
  1257.         'pop3://' || Vs_auth_string_login.k || popsrvr.k
  1258.  
  1259.       if getmail_autho.k = 3 then
  1260.         vsoup_exe vsoup_getmail_std_options vsoup_getmail_xtra_options ,
  1261.         'pop3://' || popsrvr.k
  1262.    end
  1263. if file_is_there(areas_file) & file_is_there(msgs_file) then
  1264.    zip_exe 'soup.zip areas *.msg 2>&1>nul'        /* zip only if file(s) there to be zipped */
  1265.  
  1266. /* Now back up that soup.zip, up to two levels of backup (if such backup is selected) */
  1267. if make_mail_soupzip_backup & stream('soup.zip', 'c', 'query exists') \= '' then
  1268.    do
  1269.       if stream('soup.zik', 'c', 'query exists') \= '' then
  1270.         'copy soup.zik soup.zkk 2>&1>nul'
  1271.       if stream('soup.zip', 'c', 'query exists') \= '' then
  1272.         'copy soup.zip soup.zik 2>&1>nul'
  1273.    end
  1274.  
  1275. /* Import the soup.zip into YARN */
  1276. if stream('soup.zip', 'c', 'query exists') \= '' then import_exe 'soup.zip'
  1277.  
  1278. if local_error_trapping then signal on error
  1279. if local_error_trapping then signal on failure
  1280. say ''
  1281. RETURN
  1282.  
  1283.  
  1284. import_news:
  1285. x = directory(news_incoming_dir.k)
  1286. x = value('NNTPSERVER', default_news.k, 'OS2ENVIRONMENT')
  1287. say 'Importing news from' default_news.k
  1288.  
  1289. areas_file = news_incoming_dir.k || '\areas'
  1290. msgs_file = news_incoming_dir.k || '\*.msg'
  1291.  
  1292. signal off error
  1293. signal off failure
  1294. if \vsoup then
  1295.     do
  1296.       if getnews_autho.k = 1 then
  1297.         souper_exe souper_getnews_std_options souper_getnews_xtra_options default_news.k pop_id.k pop_pwd.k
  1298.       if getnews_autho.k = 2 then
  1299.         souper_exe souper_getnews_std_options souper_getnews_xtra_options default_news.k login_ID.k pwd.k
  1300.       if getnews_autho.k = 3 then
  1301.         souper_exe souper_getnews_std_options souper_getnews_xtra_options default_news.k
  1302.    end
  1303. else
  1304.    do
  1305.       if remote then add_hyphenM_to_vsoup_options  /* Serves as a kind of log */
  1306.       if getnews_autho.k = 1 then
  1307.         vsoup_exe vsoup_getnews_std_options vsoup_getnews_xtra_options ,
  1308.         'nntp://' || Vs_auth_string_pop.k || default_news.k
  1309.  
  1310.       if getnews_autho.k = 2 then
  1311.         vsoup_exe vsoup_getnews_std_options vsoup_getnews_xtra_options ,
  1312.         'nntp://' || Vs_auth_string_login.k || default_news.k
  1313.  
  1314.       if getnews_autho.k = 3 then
  1315.         vsoup_exe vsoup_getnews_std_options vsoup_getnews_xtra_options ,
  1316.         'nntp://' || default_news.k
  1317.    end
  1318.  
  1319. if file_is_there(areas_file) & file_is_there(msgs_file) then
  1320.    zip_exe 'soup.zip areas *.msg  2>&1>nul'
  1321.  
  1322. /* Now back up that soup.zip, up to two levels of backup (if such backup is selected) */
  1323. if make_news_soupzip_backup & stream('soup.zip', 'c', 'query exists') \= '' then
  1324.    do
  1325.       if stream('soup.zik', 'c', 'query exists') \= '' then
  1326.         'copy soup.zik soup.zkk 2>&1>nul'
  1327.      if stream('soup.zip', 'c', 'query exists') \= '' then
  1328.         'copy soup.zip soup.zik 2>&1>nul'
  1329.    end
  1330.  
  1331.  
  1332. if stream('soup.zip', 'c', 'query exists') \= '' then import_exe 'soup.zip'
  1333.  
  1334. if local_error_trapping then signal on error
  1335. if local_error_trapping then signal on failure
  1336. say ''
  1337. RETURN
  1338.  
  1339. exporter:
  1340. say 'Exporting posts, replies, follow-ups to' mail_gw.1
  1341. /* if a reply-packet exists, send mail */
  1342. if stream(reply_packet, 'c', 'query exists') \= '' then
  1343.    do
  1344.       /* Change to outgoing drive and directory */
  1345.       x = directory(yarn_outgoing_dir)
  1346.       x = value('NNTPSERVER', default_news.1, 'OS2ENVIRONMENT')
  1347.       'copy' reply_packet rpname || '.BAK>nul'
  1348.       unzip_exe reply_packet
  1349.       signal off error
  1350.       signal off failure
  1351.       if \vsoup then
  1352.         do
  1353.         if send_autho.1 = 1 then
  1354.         souper_exe souper_send_std_options souper_send_xtra_options mail_gw.1 pop_id.1 pop_pwd.1
  1355.         if send_autho.1 = 2 then
  1356.         souper_exe souper_send_std_options souper_send_xtra_options mail_gw.1 login_ID.1 pwd.1
  1357.         if send_autho.1 = 3 then
  1358.         souper_exe souper_send_std_options souper_send_xtra_options mail_gw.1
  1359.         end
  1360.       else
  1361.         do
  1362.            if remote then add_hyphenM_to_vsoup_options
  1363.              /* Serves as a kind of log */
  1364.            if send_autho.1 = 1 then
  1365.            vsoup_exe vsoup_send_std_options vsoup_send_xtra_options ,
  1366.         'smtp://' || Vs_auth_string_pop.1 || mail_gw.1
  1367.  
  1368.            if send_autho.1 = 2 then
  1369.            vsoup_exe vsoup_send_std_options vsoup_send_xtra_options ,
  1370.         'smtp://' || Vs_auth_string_login.1 || mail_gw.1
  1371.  
  1372.            if send_autho.1 = 3 then
  1373.            vsoup_exe vsoup_send_std_options vsoup_send_xtra_options ,
  1374.         'smtp://' || mail_gw.1
  1375.  
  1376.         end
  1377.       'erase' reply_packet
  1378.    end
  1379. else        /* tell us nothing waiting to be sent */
  1380.    do
  1381.       replies_zip = 0
  1382.       say ''
  1383.       say reply_packet 'not found (no replies are waiting to be sent).'
  1384.    end
  1385.  
  1386. if local_error_trapping then signal on error
  1387. if local_error_trapping then signal on failure
  1388. RETURN
  1389.  
  1390. /*
  1391. ================
  1392. catchup_on_news()
  1393.  
  1394. Communicates with news server to determine how many articles are unread,
  1395. and updates the NEWSRC file in the HOME directory to leave as "unread"
  1396. the number "How_Many" of yet-to-be downloaded  articles
  1397. ================
  1398. */
  1399. catchup_on_news:
  1400. x = directory(news_incoming_dir.k)        
  1401. say ''
  1402. say 'Communicating with news server' default_news.k
  1403. say 'to update our NEWSRC...'
  1404. if \vsoup then
  1405.    do
  1406.       if getnews_autho.k = 1 then
  1407.         souper_exe '-c' || How_Many default_news.k pop_id.k pop_pwd.k
  1408.       if getnews_autho.k = 2 then
  1409.         souper_exe '-c' || How_Many default_news.k login_ID.k pwd.k
  1410.       if getnews_autho.k = 3 then
  1411.         souper_exe '-c' || How_Many default_news.k
  1412.    end
  1413. else
  1414.    do
  1415.       if remote then add_hyphenM_to_vsoup_options  /* Serves as a kind of log */
  1416.       if getnews_autho.k = 1 then
  1417.         vsoup_exe '-c' || How_Many 'nntp://' || Vs_auth_string_pop.k || default_news.k
  1418.  
  1419.       if getnews_autho.k = 2 then
  1420.         vsoup_exe '-c' || How_Many 'nntp://' || Vs_auth_string_login.k || default_news.k
  1421.  
  1422.       if getnews_autho.k = 3 then
  1423.         vsoup_exe '-c' || How_Many 'nntp://' || default_news.k
  1424.    end
  1425. say 'Each group in NEWSRC file caught up for all but last' How_Many 'articles'
  1426. say 'for Internet Service Provider #' || k
  1427. say 'Articles not marked as read can be retrieved in the next or a later operation.'
  1428. RETURN
  1429.  
  1430. /*
  1431. =====================
  1432. catch()
  1433.  
  1434. For catching up on news.  Sets the How_Many variable.
  1435. How_Many is number of unread news articles (max) we
  1436. retrieve from each newsgroup (all the older ones
  1437. in each newsgroup are marked as read)
  1438. =====================
  1439. */
  1440. Catch:
  1441. How_Many = ''
  1442. call SysCls
  1443. say 'News catchup was selected'
  1444. say ''
  1445. say ''
  1446. say 'Mark every article not yet downloaded in'
  1447. say 'each newsgroup as read except for the last n articles.'
  1448. do until DataType(How_Many,'W')
  1449.    say 'Enter n (Max number to be transferred to you).'
  1450.    prompt = 'It must be a whole number  (Esc exits now):'
  1451.    say prompt
  1452.    parse value SysCurPos() with row col
  1453.    row  = row - 1
  1454.    col = length(prompt) + 2
  1455.    call SysCurPos row, col
  1456.    pull How_Many .
  1457.    if How_Many = Escape then
  1458.       do
  1459.         say 'Esc pressed, Quitting...'
  1460.         signal goodbye
  1461.       end
  1462.    if DataType(How_Many) = 0 then
  1463.       say 'Whole number only. Try Again.' 
  1464. end
  1465. RETURN
  1466.  
  1467. /*
  1468. ===================
  1469. fix_import_message()
  1470. fix_import()
  1471.  
  1472. if for some reason the imported mail or news files
  1473. were not zipped and/or they were not imported into
  1474. YARN repositories correctly (for example, if your
  1475. machine crashed or if you had yarn running while
  1476. SOUPER was fetching them), this option may be able
  1477. to zip into soup.zip any that were unzipped at the
  1478. time, and will process the soup.zip and import the
  1479. messages.  In case YARN's news history or spool files
  1480. might have become corrupted in the process or has
  1481. independently become corrupted, it will also (try to)
  1482. rebuild it.
  1483.  
  1484. If you backed-up soup.zip files, rename the back up or
  1485. recopy it to the mail or news retrieval directory, and
  1486. this routine will re-process it.
  1487.  
  1488. Before we do anything, though, we kill slip, ppp,
  1489. IAKdialer, etc., so we are doing whatever we do (which
  1490. takes a long time) while off-line. 
  1491. =================
  1492. */
  1493. fix_import_message:
  1494. say 'If on-line, we will get off line.  This may take several seconds...'
  1495. call kill_dialers_slip_ppp_slattach        /* Kill these and slattach, too */
  1496.         /* and in-joy if we are connection_type 4 */
  1497.  
  1498. say crlf || 'IMPORTING WAS INTERRUPTED? NEED TO REBUILD YARN History File?'
  1499. say ''
  1500. say 'If either you did not complete the importing of news or mail and/or'
  1501. say 'if YARN''s History File has become corrupted, we can now try to complete'
  1502. say 'the importing of mail and news and also do news file rebuilds.'
  1503. say 'The rebuild of news spool and history files may take some time...'
  1504. say ''
  1505. say 'Don''t bother with this unless'
  1506. say ' o  You think you have a problem.'
  1507. say ''
  1508. say ' o  Fetching and importing of mail and/or news was interrupted.'
  1509. say '' 
  1510. say ' o  You want to restore a backed-up soup.zip file (for mail, or'
  1511. say '    for news, or for both) by copying soup.zip backups into their'
  1512. say '    respective mail or news retrieval directories, for re-import into'
  1513. say '    Yarn.  BUT BEFORE you restore the SOUP.ZIP''s, run this rebuild'
  1514. say '    once to clean up any unzipped retrieval debris.' 
  1515. say ''
  1516. say 'CTRL-Q quits now without doing anything.  Any other key continues'
  1517. say 'the rebuild: '
  1518.  
  1519. if SysGetKey('NOECHO') = ctrl_Q then signal Goodbye
  1520. RETURN 
  1521.  
  1522. /*
  1523. =================
  1524. Now fix the import
  1525. =================
  1526. */
  1527. fix_import:
  1528. rebuilt = 1        /* set flag, so don't have to re-kill already-killed dialers */
  1529.  
  1530. signal off notready
  1531. signal off error
  1532. signal off failure
  1533. say 'Ignore any messages about not finding areas or *.msg files'
  1534. say 'to zip or about zip errors.'
  1535. say ''
  1536. /* First try reimport for mail */
  1537. x = directory(mail_incoming_dir.k)
  1538. say 'Trying to re-zip, re-import mail (dir:' mail_incoming_dir.k || ')'        
  1539.  
  1540. areas_file = mail_incoming_dir.k || '\areas'
  1541. msgs_file = mail_incoming_dir.k || '\*.msg'
  1542.  
  1543. if file_is_there(areas_file) & file_is_there(msgs_file) then
  1544.    zip_exe 'soup.zip areas *.msg  2>&1>nul'
  1545. if stream('soup.zip', 'c', 'query exists') \= '' then        /* scrub import if no zipfile */
  1546.    import_exe 'soup.zip'
  1547.  
  1548. /* Then attempt rebuild for news */
  1549. x = directory(news_incoming_dir.k)        
  1550. say 'Trying to re-zip, re-import/rebuild for news (dir:' news_incoming_dir.k        ||')'
  1551.  
  1552. areas_file = news_incoming_dir.k || '\areas'
  1553. msgs_file = news_incoming_dir.k || '\*.msg'
  1554.  
  1555. if file_is_there(areas_file) & file_is_there(msgs_file) then
  1556.    zip_exe 'soup.zip areas *.msg  2>&1>nul'
  1557. if stream('soup.zip', 'c', 'query exists') \= '' then        /* scrub import if no zipfile */
  1558.    import_exe 'soup.zip'
  1559. rebuild_exe '-s'        /*fixes spool file, rebuilds history file */
  1560. rebuild_exe '-o'        /* rebuilds history and overview files */
  1561.  
  1562. if local_error_trapping then signal on failure
  1563. if local_error_trapping then signal on notready
  1564. if local_error_trapping then signal on error
  1565. say ''
  1566. RETURN
  1567.  
  1568.  
  1569. /*
  1570. ======================
  1571. add_hyphenM_to_vsoup_options()
  1572.  
  1573. -M creates status message which is stored as an incoming
  1574. e-mail.  It can serve as a logging when YARNDIAL is run
  1575. remotely, i.e, called up by a timer program.  This routine
  1576. appends -M to the vsoup options.  There is no harm done
  1577. if a -M as an option was previously configured.
  1578.  
  1579. This program is called only if VSoup is the program used to
  1580. communicate (send/get/post mail/news, and only if remote=1
  1581. which it will be if there is a command-line argument setting
  1582. the variable CHOOSE (corresponds to the main-menu choice
  1583. to get mail, news, etc.)  If a CHOOSE argument is detected,
  1584. the wariable remote is set to 1.
  1585. ======================
  1586. */
  1587. add_hyphenM_to_vsoup_options:
  1588.    vsoup_getmail_xtra_options = vsoup_getmail_xtra_options '-M'
  1589.    vsoup_getnews_xtra_options = vsoup_getnews_xtra_options '-M'
  1590.    vsoup_send_xtra_options = vsoup_send_xtra_options '-M'
  1591. RETURN
  1592.  
  1593. /*
  1594. ======================
  1595. kill_dialers_slip_ppp_slattach()
  1596.  
  1597. kill these, and tell us about it
  1598. ======================
  1599. */
  1600.  
  1601. kill_dialers_slip_ppp_slattach:        
  1602. say ''
  1603. if rebuilt then signal depart
  1604. if \do_not_kill then
  1605.    do
  1606.       say 'Killing dialer(s), slip.exe, ppp.exe, etc., if up...'
  1607.       call kill_all        /* next routine does the contract */
  1608.       say 'We are off-line now.'
  1609.    end
  1610. if do_not_kill then
  1611.   do
  1612.      say 'Beeping to remind you that YOU MAY STILL BE CONNECTED!'
  1613.      say 'When ready to disconnect, run LOGOFF.CMD or close down dialer.'
  1614.      call beep 1000, 200
  1615.      call beep 32767, 25  /* Too high pitched, inaudible, an improvised pause. */ 
  1616.      call beep 1000, 200
  1617.    end
  1618. say ''
  1619. t = time('E')        /* elapsed time, souper/vsoup processes only */
  1620. RETURN
  1621.  
  1622. kill_all:        /* calls to this routine kill everything quietly */
  1623. call close_down 'DIALER'
  1624. call close_down 'SLIP'
  1625. call close_down 'PPP'
  1626. call close_down 'SLATTACH'
  1627. call close_down 'SLIPPM'
  1628. call close_down 'ILINK2'
  1629. if alt_dialer \= 'DIALER',
  1630.    & alt_dialer \= 'SLIP',
  1631.    & alt_dialer \= 'PPP',
  1632.    & alt_dialer \= 'SLIPPM',
  1633.    & alt_dialer \= 'ILINK2',
  1634.    & alt_dialer \= 'IN-JOY' then
  1635.       call close_down alt_dialer
  1636. if stream(killjoy_exe, 'c', 'query exists') \= '' then
  1637.    do
  1638.       killjoy_exe
  1639.       call SysSleep 2        /* settle time */
  1640.    end
  1641. call close_down 'IN-JOY' 
  1642. call SysSleep 2        /* just in case, wait a bit and re-kill */
  1643. call close_down 'DIALER'
  1644. call close_down 'SLIP'
  1645. call close_down 'PPP'
  1646. call close_down 'SLATTACH'
  1647. call close_down 'SLIPPM'
  1648. call close_down 'ILINK2'
  1649. if alt_dialer \= 'DIALER',
  1650.    & alt_dialer \= 'SLIP',
  1651.    & alt_dialer \= 'PPP',
  1652.    & alt_dialer \= 'SLIPPM',
  1653.    & alt_dialer \= 'ILINK2',
  1654.    & alt_dialer \= 'IN-JOY' then
  1655.       call close_down alt_dialer
  1656. if stream(killjoy_exe, 'c', 'query exists') \= '' then
  1657.    do
  1658.       killjoy_exe
  1659.       call SysSleep 2        /* settle time */
  1660.    end
  1661. call close_down 'IN-JOY' 
  1662. if interface_removal \= 0 then
  1663.    call routings_to_hosts(interf_prefix)        /* and clear out interfaces */
  1664. RETURN
  1665.  
  1666.  
  1667. /*
  1668. =========================================
  1669. close_down(process)
  1670.  
  1671. Close down a process (such as slip or ppp or slippm) with
  1672. GO.EXE using the -ka option kills all instances of 'process'.
  1673. No harm done if 'process' not running  and we try to close it down.
  1674. =========================================
  1675. */
  1676. close_down:
  1677. parse upper arg process
  1678. signal off error
  1679. go_exe '-cp' process '>NUL'        /* returns RC=1 if process is running and 0 if not */
  1680. if RC=1 & process = 'DIALER' then
  1681.    do
  1682.       call is_IAKdialer_running
  1683.       if IAKdialer_is_running then 
  1684.         do
  1685. /* Only try to close this way if IAK duller is confirmed to be running */
  1686.            process '-c' /* hope IAK dialer is at least v 1.33 where -c option supported */
  1687.            call SysSleep 2 /* settle time, IAK Dialer is funny */
  1688.            say '   If this window was minimized for a few seconds: perfectly normal.'
  1689.         end
  1690.    end
  1691. /* try to shut down in-joy with IN-JOY's own killjoy.exe */
  1692. if RC=1 & process = 'IN-JOY' then
  1693.    do
  1694.       if stream(killjoy_exe, 'c', 'query exists') \= '' then killjoy_exe
  1695.       call SysSleep 2        /* settle time */
  1696.    end
  1697. go_exe '-ka' process '>NUL'  /* do a kill whether running or not */
  1698. if local_error_trapping then signal on error
  1699.  
  1700. RETURN
  1701.  
  1702. /*
  1703. =================
  1704. routings_to_hosts(interf_prefix)
  1705.  
  1706. Only called if interface_removal is non-zero.
  1707.  
  1708. Examines routing table host routes reported out by running
  1709.         netstat -r
  1710. and then
  1711. if interface_removal = 1
  1712.         and if IN-JOY is the dialer and if the interf_prefix is IN-JOY's,
  1713.         deletes that routing entry.
  1714. if interface_removal = 2
  1715.         whatever the dialer and interf_prefix deletes all routing entries.
  1716.  
  1717.  
  1718. Why do this?  IN-JOY sometimes leaves a phantom routing in the tables
  1719. and it persists, once there, when other dialers are started after
  1720. that happens.
  1721. =================
  1722. */
  1723. routings_to_hosts:
  1724. parse arg if_prefix
  1725. if_prefix = translate(if_prefix)
  1726. ifp_length = length(if_prefix)
  1727.  
  1728. call rxqueue 'CREATE', queue_ydint        /* (re)create internal queue */
  1729. call rxqueue 'SET', queue_ydint        /* set internal queue */
  1730. /* do queued(); parse pull; end */        /* If there is anything in it, clear it out */
  1731.  
  1732. 'netstat -r | rxqueue' queue_ydint        /* send output to the queue */
  1733. do queued()
  1734.    dest = ''
  1735.    rtr = ''
  1736.    interf = ''
  1737.    parse pull netstat_line
  1738.    parse var netstat_line dest rtr .
  1739.    dest = strip(dest, 'B')
  1740.    rtr = strip(rtr, 'B')
  1741.    if words(netstat_line) > 0  then
  1742.       do
  1743.          interf = word(netstat_line, words(netstat_line))
  1744.          interf = strip(interf, 'B')
  1745.       end
  1746.    else iterate
  1747.    select
  1748. /* A headings line (first word is 'destination' or 'metric')? Discard the line */
  1749.       when translate(dest) = 'DESTINATION' then iterate
  1750.       when translate(dest) = 'METRIC' then iterate
  1751.  
  1752. /* Blank dest or rtr? Discard the line, 'route delete' won't work */
  1753.       when dest = '' | rtr = '' then iterate
  1754.  
  1755. /* If interface_removal=1, IN-JOY, but not our interface,
  1756. also discard the line */
  1757.       when interface_removal = 1 & alt_dialer = 'IN-JOY',
  1758.         & translate(left(interf, ifp_length)) \= if_prefix then
  1759.         iterate
  1760.  
  1761. /* If interface_removal=1 and not IN-JOY,
  1762. discard the line */
  1763.       when interface_removal = 1 & alt_dialer \= 'IN-JOY' then iterate
  1764.  
  1765. /* Anything else, delete the routing */
  1766.       otherwise
  1767.         'route -h delete' dest rtr
  1768.    end        /* of Select */
  1769. end        /* of Do queued() */
  1770.  
  1771. do queued(); parse pull; end        /* If there is anything in queue, clear it out */
  1772. call rxqueue 'SET', queue_ydext        /* reset to whatever queue may have been in use before */ 
  1773. RETURN
  1774.  
  1775.  
  1776.  
  1777. /*
  1778. =====================
  1779. restore_zip()
  1780.  
  1781. Chance to restore zipfile if sending didn't
  1782. seem to go right
  1783. =====================
  1784. */
  1785.  
  1786. restore_zip:
  1787. rpname_bak = rpname || '.BAK'
  1788. /* if we were exporting posts and replies and if there was a reply_packet */
  1789. if pos(choice, 'xxx45xx') \= 0 & timeout = 0 & replies_zip then
  1790.    do
  1791.       say '     If you got an error sending posts and replies, press'
  1792.       say '     CONTROL-R now to restore' reply_packet
  1793.       say '     for re-transmission in a later session, but do this'
  1794.       say '     only if you got an error.'
  1795.       say '     Otherwise press any other key to continue exiting.'
  1796.       if SysGetKey('NOECHO') = ctrl_R then
  1797.         if stream(rpname_bak, 'c', 'query exists') \= '' then  
  1798.         do
  1799.         say 'Restoring' reply_packet
  1800.         'copy' rpname_bak reply_packet '2>&1>null'
  1801.         end
  1802.       else say 'No' rpname_bak 'to restore'
  1803.    end
  1804. RETURN
  1805.  
  1806. /*
  1807. ================
  1808. toss_old_news()
  1809.  
  1810. Chance to remove old news using the expire program
  1811. ===============
  1812. */
  1813. toss_old_news:
  1814.    Prompt = 'Remove old (expired) yarn messages (Y/N)?'
  1815.    say prompt
  1816.    parse value SysCurPos() with row col
  1817.    row  = row - 1
  1818.    col = length(prompt) + 2
  1819.    call SysCurPos row, col
  1820.    if translate(SysGetKey('NOECHO')) = 'Y' then
  1821.       do
  1822.         say ''
  1823.         say 'Removing expired news' || crlf
  1824.         expire_exe '-o'        /* Remove old messages */
  1825.       end
  1826. RETURN
  1827.  
  1828. /*
  1829. ===================
  1830. connect_stats()
  1831.  
  1832. How long were we on line retrieving or sending stuff?
  1833. ==================
  1834. */
  1835. connect_stats:
  1836. con_time = '   Retrieval and sending of news and/or mail took' trunc((t/60), 2) 'mins'
  1837. if t \= 0 then say con_time
  1838. RETURN
  1839.  
  1840.  
  1841.  
  1842. /*
  1843. ===================
  1844. parms_from_ydparms_dat()
  1845.  
  1846. Assign parameters based on what is in YDPARMS_DAT
  1847. ==================
  1848. */
  1849. parms_from_ydparms_dat:
  1850.  
  1851. /* Can we find ydparms_dat file? */
  1852.  
  1853. home = directory()        /* Where we are executing this pgm from */
  1854. home = translate(home)
  1855.  
  1856. ydparms_dat = home || '\' || filespec('name', ydparms_dat)
  1857. /* All the parameters we need are in ydparms_dat.
  1858. Abort if can't locate the ydparms_dat file. Means we
  1859. never ran the installer */
  1860.  
  1861. if stream(ydparms_dat, 'c', 'query exists') = '' then
  1862.    do
  1863.       go_exe = home || '\' || go_exe        /* assume that's where it is */
  1864.       call beep 1000, 200
  1865.       say 'Cannot find YD_PARMS.DAT, the file containing parameters'
  1866.       say 'YARNDIAL needs in order to run.  This is normal if you have'
  1867.       say 'not yet run the installer,' ydinstl_cmd || '.'
  1868.       say ''
  1869.       say 'Aborting.  Press any key to exit.  Then run' ydinstl_cmd
  1870.       call SysGetKey 'NOECHO'
  1871.       exit
  1872.    end
  1873. /* OK, we found it.  Initialize some vars, then get parameters from YD_PARMS.DAT */
  1874. /*
  1875. do i = 1 to number_of_ISP
  1876.    isp_active.i = 0
  1877.    login_ID.i = ''
  1878.    pwd.i = ''
  1879.    pop_ID.i = ''
  1880.    pop_pwd.i = ''
  1881.    popsrvr.i = ''
  1882.    default_news.i = ''
  1883.    mail_gw.i = ''
  1884.    getmail_autho.i = 1
  1885.    getnews_autho.i = 1
  1886.    send_autho.i = 1
  1887. end
  1888. */
  1889. say 'Please wait while parameters load and we perform our setup...'
  1890. n = find_equate_lines_in_datafile(ydparms_dat)
  1891. i = 1
  1892. number_of_ISPs = 1
  1893. /*
  1894. ====================
  1895. Strip out all leading and trailing blanks and tabs
  1896. from parsed left and right sides of the equal sign.
  1897. Leave any internal ones alone
  1898. ====================
  1899. */
  1900.  
  1901. do until i = n
  1902.    parse var line.i parm.i '=' val.i
  1903.    parm.i = translate(parm.i)
  1904.    do until parm.i = stripped_parm.i & val.i = stripped_val.i
  1905.       stripped_parm.i = strip(parm.i, 'B')
  1906.       parm.i = strip(stripped_parm.i, 'B', tab)
  1907.       stripped_val.i = strip(val.i, 'B')
  1908.       val.i = strip(stripped_val.i, 'B', tab)
  1909.    end
  1910.    isp_parm = ''        /* clear these 2 things */
  1911.    isp_num = '0'
  1912.    parse var parm.i isp_parm '.' isp_num
  1913.    if abbrev(line.i, '#') then NOP
  1914.    else
  1915.         /* set up our variables */
  1916.       select
  1917.         when parm.i = 'HOME' then HOME = val.i 
  1918.         when parm.i = 'YARN' then YARN = val.i
  1919.         when parm.i = 'CONNECTION_TYPE' then connection_type = val.i
  1920.         when parm.i = 'INTERFACE_REMOVAL' then interface_removal = val.i
  1921.         when parm.i = 'HOST_APP' then host_app = val.i
  1922.         when parm.i = 'INTERF_PREFIX' then interf_prefix = val.i
  1923.         when parm.i = 'DIALUP_STRING' then dialup_string = val.i
  1924.         when parm.i = 'DO_NOT_KILL_CONNECTION' then do_not_kill_connection = val.i
  1925.         when parm.i = 'DNK_STRING' then dnk_string = val.i
  1926.         when parm.i = 'OVERRIDE_DNK_DURING_REMOTE' then
  1927.            override_dnk_during_remote = val.i
  1928.         when parm.i = 'USER' then user = val.i
  1929.         when parm.i = 'HOST' then host = val.i
  1930.         when parm.i = 'ACCOUNT' then account = val.i
  1931.         when parm.i = 'VSOUP' then vsoup = val.i
  1932.         when parm.i = 'ZIP_EXE' then zip_exe = val.i
  1933.         when parm.i = 'UNZIP_EXE' then unzip_exe = val.i
  1934.         when parm.i = 'REPLY_PACKET' then reply_packet = val.i
  1935.         when parm.i = 'SOUPER_EXE' then souper_exe = val.i 
  1936.         when parm.i = 'VSOUP_EXE' then vsoup_exe = val.i 
  1937.         when parm.i = 'IMPORT_EXE' then import_exe = val.i 
  1938.         when parm.i = 'EXPORT_EXE' then export_exe = val.i 
  1939.         when parm.i = 'EXPIRE_EXE' then expire_exe = val.i 
  1940.         when parm.i = 'REBUILD_EXE' then rebuild_exe = val.i
  1941.         when parm.i = 'KILLJOY_EXE' then killjoy_exe = val.i
  1942.         when parm.i = 'ALT_DIALER_EXE' then
  1943.            do
  1944.               alt_dialer_exe = val.i
  1945.               call parse_altdialerexe
  1946.            end
  1947.         when parm.i = 'GO_EXE' then go_exe = val.i
  1948.         when parm.i = 'SOUPER_GETMAIL_STD_OPTIONS'
  1949.         then souper_getmail_std_options = val.i 
  1950.         when parm.i = 'SOUPER_GETMAIL_XTRA_OPTIONS'
  1951.         then souper_getmail_xtra_options = val.i 
  1952.         when parm.i = 'SOUPER_GETNEWS_STD_OPTIONS' then
  1953.            souper_getnews_std_options = val.i 
  1954.         when parm.i = 'SOUPER_GETNEWS_XTRA_OPTIONS' then
  1955.            souper_getnews_xtra_options = val.i 
  1956.         when parm.i = 'SOUPER_SEND_STD_OPTIONS' then
  1957.            souper_send_std_options = val.i 
  1958.         when parm.i = 'SOUPER_SEND_XTRA_OPTIONS' then
  1959.            souper_send_xtra_options = val.i
  1960.         when parm.i = 'VSOUP_GETMAIL_STD_OPTIONS' then
  1961.            vsoup_getmail_std_options = val.i 
  1962.         when parm.i = 'VSOUP_GETMAIL_XTRA_OPTIONS' then
  1963.            vsoup_getmail_xtra_options = val.i 
  1964.         when parm.i = 'VSOUP_GETNEWS_STD_OPTIONS' then
  1965.            vsoup_getnews_std_options = val.i 
  1966.         when parm.i = 'VSOUP_GETNEWS_XTRA_OPTIONS' then
  1967.            vsoup_getnews_xtra_options = val.i 
  1968.         when parm.i = 'VSOUP_SEND_STD_OPTIONS' then
  1969.            vsoup_send_std_options = val.i 
  1970.         when parm.i = 'VSOUP_SEND_XTRA_OPTIONS' then
  1971.            vsoup_send_xtra_options = val.i
  1972.         when parm.i = 'WAIT' then wait = val.i
  1973.         when parm.i = 'ASK' then ASK = val.i
  1974.         when parm.i = 'IS1' then IS1 = val.i
  1975.         when parm.i = 'IS2' then IS2 = val.i
  1976.         when parm.i = 'RS1' then RS1 = val.i
  1977.         when parm.i = 'RS2' then RS2 = val.i
  1978.         when parm.i = 'FS1' then FS1 = val.i
  1979.         when parm.i = 'FS2' then FS2 = val.i
  1980.         when parm.i = 'PIN' then PIN = val.i
  1981.         when parm.i = 'PROVIDER' then PROVIDER = val.i
  1982.         when parm.i = 'SAVE_PWD' then SAVE_PWD = val.i
  1983.         when parm.i = 'PHONE_NUMBER' then PHONE_NUMBER = val.i
  1984.         when parm.i = 'HANGUP' then HANGUP = val.i
  1985.         when parm.i = 'SCRIPT' then SCRIPT = val.i
  1986.         when parm.i = 'SERVICE' then SERVICE = val.i
  1987.         when parm.i = 'YOURIP' then YOURIP = val.i
  1988.         when parm.i = 'DESTIP' then DESTIP = val.i
  1989.         when parm.i = 'NETMASK' then NETMASK = val.i
  1990.         when parm.i = 'MTU_SIZE' then MTU_SIZE = val.i
  1991.         when parm.i = 'VJ_COMP' then VJ_COMP = val.i
  1992.         when parm.i = 'PRIMARY_INF' then PRIMARY_INF = val.i
  1993.         when parm.i = 'HOSTNAME' then HOSTNAME = val.i
  1994.         when parm.i = 'DOMAIN_NAME' then DOMAIN_NAME = val.i
  1995.         when parm.i = 'DNS' then DNS = val.i
  1996.         when parm.i = 'DNS2' then DNS2 = val.i
  1997.         when parm.i = 'DEFAULT_WWW' then DEFAULT_WWW = val.i
  1998.         when parm.i = 'DEFAULT_GOPHER' then DEFAULT_GOPHER = val.i
  1999.         when parm.i = 'REPLY_DOMAIN' then REPLY_DOMAIN = val.i
  2000.         when parm.i = 'REPLY_ID' then REPLY_ID = val.i
  2001.         when parm.i = 'MODEM_TYPE' then MODEM_TYPE = val.i
  2002.         when parm.i = 'COMPORT' then COMPORT = val.i
  2003.         when parm.i = 'BAUD' then BAUD = val.i
  2004.         when parm.i = 'DATABITS' then DATABITS = val.i
  2005.         when parm.i = 'PARITY' then PARITY = val.i
  2006.         when parm.i = 'DIAL_MODE' then DIAL_MODE = val.i
  2007.         when parm.i = 'PREFIX' then PREFIX = val.i
  2008.         when parm.i = 'PREFIX_ANS' then PREFIX_ANS = val.i
  2009.         when parm.i = 'INIT' then INIT = val.i
  2010.         when parm.i = 'INIT2' then INIT2 = val.i
  2011.         when parm.i = 'DISABLE' then DISABLE = val.i
  2012.         when parm.i = 'DISABLE_SEQ' then DISABLE_SEQ = val.i
  2013.         when parm.i = 'DIAL_PREFIX' then DIAL_PREFIX = val.i
  2014.         when parm.i = 'AUTOSTART' then AUTOSTART = val.i
  2015.         when parm.i = 'TOTAL_CONNECT' then TOTAL_CONNECT = val.i
  2016.         when isp_parm = 'ISP_ACTIVE' then
  2017.            do        /* check for a syntax error */
  2018.               ISP_ACTIVE.isp_num = val.i
  2019.               if  \DataType(isp_num,'W') then
  2020.                  do
  2021.                     call beep 1000, 200
  2022.                     say ''
  2023.                     say 'Fatal Error in' ydparms_dat
  2024.                     say parm.i 'found.'
  2025.                     say 'The index X in ISP_ACTIVE.X must be an integer.'
  2026.                     say 'Aborting.  Edit' ydparms_dat 'to correct.'
  2027.                     signal goodbye
  2028.                  end
  2029.               if val.i \= 1 & val.i \= 0 then
  2030.                  do
  2031.                     call beep 1000, 200
  2032.                     say ''
  2033.                     say 'Fatal Error in' ydparms_dat
  2034.                     say parm.i 'must be set equal either to 0 or 1'
  2035.                     if val.i = '' then say parm.i 'is now blank.'
  2036.                     if pos(val.i, 'oO') \= 0 then
  2037.                     say '      (the letter ''O'')'
  2038.                     say 'Aborting.  Edit' ydparms_dat 'to correct.'
  2039.                     signal goodbye
  2040.                  end
  2041.               if isp_num > number_of_ISPs then
  2042.                  number_of_ISPs = isp_num        /* counts up the ISP's */
  2043.            end
  2044.         when isp_parm = 'LOGIN_ID' then login_ID.isp_num = val.i
  2045.         when isp_parm = 'PWD' then pwd.isp_num = val.i
  2046.         when isp_parm = 'ENCR_PWD' then encr_pwd.isp_num = val.i
  2047.         when isp_parm = 'POP_ID' then pop_ID.isp_num = val.i
  2048.         when isp_parm = 'POP_PWD' then pop_pwd.isp_num = val.i
  2049.         when isp_parm = 'ENCR_POP_PWD' then encr_pop_pwd.isp_num = val.i
  2050.         when isp_parm = 'POPSRVR' then popsrvr.isp_num = val.i
  2051.         when isp_parm = 'DEFAULT_NEWS' then default_news.isp_num = val.i
  2052.         when isp_parm = 'MAIL_GW' then mail_gw.isp_num = val.i
  2053.         when isp_parm = 'GETMAIL_AUTHO' then getmail_autho.isp_num = val.i
  2054.         when isp_parm = 'GETNEWS_AUTHO' then getnews_autho.isp_num = val.i
  2055.         when isp_parm = 'SEND_AUTHO' then send_autho.isp_num = val.i
  2056.         otherwise NOP
  2057.       end    /* select */
  2058.    i = i + 1
  2059. end   /* do until...*/
  2060.  
  2061. /* So now we've gotten everything.  Process some of it */
  2062.  
  2063. do i = 1 to number_of_ISPs        /* if no servers, assume the isp is inactive */
  2064.    if popsrvr.i = '' & default_news.i = '' then isp_active.i = 0
  2065.    if pos(getnews_autho.i, '123') \= 0 then getnews_autho.i = 1
  2066.    if pos(getmail_autho.i, '123') \= 0 then getmail_autho.i = 1
  2067. end
  2068.  
  2069. /* Translation Table to decode the passwords */
  2070.  
  2071. o21 = '&\<=>|()! *+"''-/,#$%.0123456789:;?'
  2072. o22 = '@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^'
  2073. o23 = '_`abcdefghijklmnopqrstuvwxyz{}~'
  2074. e21 = '&\<=>|()u *+"''-/,MI$kUHgW[_A5%w~Fh'
  2075. e22 = 't?K^l0jJP{98xBadb1nZimRyY]4}`o'
  2076. e23 = 'E;67V@vS:C.sNGzcefQpqTr!2#XDLO3'
  2077.  
  2078. do i = 1 to number_of_ISPs
  2079. /* These next 2 lines have the effect of ignoring whatever was found as
  2080. an encrypted password if an un-encrypted one was found.  In other
  2081. words, if both were in the YD_PARMS.DAT file, the UN-ENCRYPTED
  2082. password is given precedence (easier to enter, change, etc.). */
  2083.    if pop_pwd.i = '' then
  2084.       pop_pwd.i = translate(encr_pop_pwd.i, e21||e22||e23, o21||o22||o23)
  2085.  
  2086.    if pwd.i = '' then
  2087.       pwd.i = translate(encr_pwd.i, e21||e22||e23, o21||o22||o23)
  2088. end
  2089.  
  2090. /* These do more parameter massaging */
  2091. call parse_DNKstring
  2092. call build_vsoup_auth_strings
  2093.  
  2094. RETURN
  2095.  
  2096. /*
  2097. ============
  2098. parse_DNKstring()
  2099.  
  2100. DO NOT KILL OPTION
  2101. If the DO_NOT_KILL_CONNECTION parameter in YD_PARMS.DAT =1
  2102. we can have the option come up in the main menu to kill or not
  2103. to kill the connection when YARNDIAL finishes.  If it is zero,
  2104. we always kill the connection at the end.
  2105.  
  2106. dnk.1 thru .7 are the "do-not-kill" alternatives to
  2107. 1-7 and on the main menu.  If do_not_kill is enabled (=1)
  2108. you can execute the same functions as 1-7 but dialers, slip,
  2109. etc. are not shut down when done.
  2110.  
  2111. We parse the dnk_string to the 7 individual dnk.i alternate chars.
  2112. ============
  2113. */
  2114. parse_DNKstring:
  2115. /* Was there an erroneous value for do_not_kill_connection?  If so, set to 0 */
  2116. if pos(do_not_kill_connection, '01') = 0 then do_not_kill_connection = 0
  2117.  
  2118. /* Parse the string into individual characters, unless there was no string */
  2119. if length(dnk_string) > 7 then dnk(string) = left(dnk_string, 7)
  2120. if dnk_string \= '' then
  2121.    do i = 1 to length(dnk_string)
  2122.       if substr(dnk_string, i, 1) \= '' & substr(dnk_string, i, 1) \= ' ' then
  2123.         dnk.i = substr(dnk_string, i, 1)
  2124.       else dnk.i = i
  2125.  
  2126.       if i = 6 then dnk.i = '6'
  2127.    end
  2128. /* now reconstruct the dnk_string */
  2129. dnk_string = dnk.1 || dnk.2 || dnk.3 || dnk.4 || dnk.5 || dnk.6 || dnk.7
  2130.  
  2131.  
  2132. RETURN
  2133.  
  2134. /*
  2135. ==================
  2136. parse_altdialerexe()
  2137.  
  2138. Get alt_dialer_exe filename.  Strip path, "." and extension,
  2139. and also strip any options that may have been entered.
  2140. alt_dialer_exe stores the name of the dialer executable. 
  2141. ==================
  2142. */
  2143. parse_altdialerexe:
  2144. parse var alt_dialer_exe alt_dialer_name alt_dialer_options        /* strip options */
  2145. alt_dialer_name = translate(alt_dialer_name)        /* upper case */
  2146. alt_dialer_name = filespec('name', alt_dialer_name)        /* eliminate drive and path */
  2147. parse var alt_dialer_name alt_dialer '.' ext        /*...and extension */
  2148.  
  2149.  
  2150. /*  (Re)set HOME and YARN environmental
  2151. variables, and set EMXOPT to 40 file handles */
  2152. x = SetLocal()
  2153. x = value('home', home, 'OS2ENVIRONMENT')
  2154. x = value('yarn', yarn, 'OS2ENVIRONMENT')
  2155.  
  2156. emx_env = '-h40 -c -n'
  2157. x = value('emxopt', EMX_ENV, 'OS2ENVIRONMENT')
  2158. RETURN
  2159.  
  2160. /*
  2161. ===========
  2162. build_vsoup_auth_strings()
  2163.  
  2164. Construct the VSoup authorization strings for use of either the
  2165. Login_ID and PWD and the POP_ID and POP_PWD.
  2166.  
  2167. Vs_auth_string_login.k = [login_ID.k[:pwd.k]@]
  2168. Vs_auth_string_pop.k = [pop_ID.k[:pop_pwd.k]@]
  2169. where the square brackets embrace optional parameters.
  2170.  
  2171. These are used in a format such as
  2172.    pop3://[pop_ID.k[:pop_pwd.k]@]pop3-host.k
  2173. or    pop3:// || Vs_auth_string_pop.k|| pop3-host.k
  2174. ==========
  2175. */
  2176. build_vsoup_auth_strings:
  2177. do k = 1 to number_of_ISPs
  2178.    if login_ID.k = '' & pwd.k = '' then
  2179.       Vs_auth_string_login.k = ''
  2180.    if login_ID.k \= '' & pwd.k = '' then
  2181.       Vs_auth_string_login.k = login_ID.k || '@'
  2182.    if login_ID.k = '' & pwd.k \= '' then
  2183.       Vs_auth_string_login.k = ':' || pwd.k || '@'
  2184.    if login_ID.k \= '' & pwd.k \= '' then
  2185.       Vs_auth_string_login.k =  login_ID.k || ':' || pwd.k || '@'
  2186.  
  2187.    if pop_ID.k = '' & pop_pwd.k = '' then
  2188.       Vs_auth_string_pop.k = ''
  2189.    if pop_ID.k \= '' & pop_pwd.k = '' then
  2190.       Vs_auth_string_pop.k = pop_ID.k || '@'
  2191.    if pop_ID.k = '' & pwd.k \= '' then
  2192.       Vs_auth_string_pop.k = ':' || pop_pwd.k || '@'
  2193.    if pop_ID.k \= '' & pwd.k \= '' then
  2194.       Vs_auth_string_pop.k =  pop_ID.k || ':' || pop_pwd.k || '@'
  2195. end
  2196. RETURN
  2197.  
  2198. /*
  2199. ======================
  2200. find_equate_lines_in_datafile()
  2201.  
  2202. Called by parms_from_ydparms_dat()
  2203. The dat file is set up to use a # as the first char on a dataline
  2204. to indicate that the line is a comment line, and to use a
  2205. backslash ('\') as the final character on a dataline to
  2206. mean the line is continued on the line following.  First
  2207. we reconstitute those lines that have continuations,
  2208. then we search through those lines for an '=' sign as
  2209. other than the first character.  We eliminate from
  2210. consideration any line with a '#' as the first character
  2211. as that signifies the line is a comment line.
  2212. ======================
  2213. */
  2214. find_equate_lines_in_datafile:
  2215. arg filename
  2216. n = 1
  2217. do while lines(filename) > 0
  2218.    data_line.n = linein(filename)
  2219.    select
  2220.       when right(data_line.n, 1) = '\' then        /* concatenating continuations */
  2221.         do until right(data_line.n, 1) \= '\'
  2222.         data_line_n_with_right_slash_stripped =,
  2223.         strip(right(data_line.n,1), 'T', '\')
  2224.         next_data_line = linein(filename)
  2225.         data_line.n = data_line_n_with_right_slash_stripped || next_data_line
  2226.         end
  2227.  
  2228. /* only lines without a leading # and with an = qualify */
  2229.       when pos('=', data_line.n) > 0 & \abbrev(data_line.n, '#') then
  2230.         do
  2231.         line.n = data_line.n
  2232.         n = n + 1
  2233.         end
  2234.       otherwise NOP
  2235.    end
  2236. end
  2237. RETURN n
  2238.  
  2239. /*
  2240. ====================
  2241. souper_options()
  2242.  
  2243. Chance to modify the souper options on a
  2244. one-time-only basis
  2245. ====================
  2246. */
  2247. souper_options:
  2248. call SysCls
  2249. souper_getnews_xtra_options = '' /* the defaults */
  2250. souper_getmail_xtra_options = ''
  2251. souper_send_xtra_options = ''
  2252. vsoup_getnews_xtra_options = ''
  2253. vsoup_getmail_xtra_options = ''
  2254. vsoup_send_xtra_options = ''
  2255. option1 = ''
  2256. option2 = ''
  2257. option3 = ''
  2258. option4 = ''
  2259.  
  2260. say ''
  2261. say 'SOUPER OPTIONS SCREEN'
  2262. say 'You can select these as one-time-only options when souper runs.'
  2263. do until opts = 6
  2264.    say ''
  2265.    say 'Press:'
  2266.    say '  1 Set maximum news packetsize (default is 2048KB [2.048MB])'
  2267.    say '  2 Do not retrieve newsgroup articles containing more than set'
  2268.    say '    number of lines in the body (default is: no limit)'
  2269.    say '    You get to set the number of lines.'
  2270.    say '  3 Do catchup on news.  Mark all as read except last m unread'
  2271.    say '    news articles in each group.  You set m.'
  2272.    say '  4 For mail: read-only.  Do not empty POP3 mailbox or update NEWSRC file'
  2273.    say '  5 Default all four of the above.'
  2274.    say '  6 DONE.  (MUST press 6 to exit this screen)'
  2275.    do until pos(opts,'123456') \= 0
  2276.       say ''
  2277.       prompt = 'Select 1-6:'
  2278.       say prompt
  2279.         parse value SysCurPos() with row col
  2280.         row  = row - 1
  2281.         col = length(prompt) + 2
  2282.         call SysCurPos row, col
  2283.       opts = SysGetKey('NOECHO')
  2284.       say ''
  2285.    end
  2286.    select
  2287.       when opts = 1 then call max_news_packet
  2288.       when opts = 2 then call max_news_lines
  2289.       when opts = 3 then 
  2290.         do
  2291.         say ''
  2292.         say ''
  2293.         say ''
  2294.         call catch
  2295.         do_catchup_on_news = 1
  2296.         say 'All but' How_Many 'articles (each group) max. will be marked read.'
  2297.         end
  2298.       when opts = 4 then call read_only_getmail_mode
  2299.       when opts = 5 then
  2300.         do
  2301.         option1 = ''
  2302.         option2 = ''
  2303.         option3 = ''
  2304.         option4 = ''
  2305.         choice = 7        /* go back with same value for choice as we came with */
  2306.         say ''
  2307.         say 'Accepting defaults for all three options'
  2308.         say ''
  2309.         say ''
  2310.         say 'Press any key to continue'
  2311.         call SysGetKey 'NOECHO'
  2312.         end
  2313.       otherwise NOP
  2314.    end
  2315. end
  2316.  
  2317. souper_getnews_xtra_options = strip(souper_getnews_xtra_options, 'B')
  2318. souper_getnews_xtra_options = souper_getnews_xtra_options option1
  2319. souper_getnews_xtra_options = strip(souper_getnews_xtra_options, 'B')
  2320. souper_getnews_xtra_options = souper_getnews_xtra_options option2
  2321. souper_getnews_xtra_options = strip(souper_getnews_xtra_options, 'B')
  2322. souper_getnews_xtra_options = souper_getnews_xtra_options option3
  2323. souper_getnews_xtra_options = strip(souper_getnews_xtra_options, 'B')
  2324.  
  2325. souper_getmail_xtra_options = strip(souper_getmail_xtra_options, 'B')
  2326. souper_getmail_xtra_options = souper_getmail_xtra_options option4
  2327. souper_getmail_xtra_options = strip(souper_getmail_xtra_options, 'B')
  2328.  
  2329. vsoup_getnews_xtra_options = strip(vsoup_getnews_xtra_options, 'B')
  2330. vsoup_getnews_xtra_options = vsoup_getnews_xtra_options option1
  2331. vsoup_getnews_xtra_options = strip(vsoup_getnews_xtra_options, 'B')
  2332. vsoup_getnews_xtra_options = vsoup_getnews_xtra_options option2
  2333. vsoup_getnews_xtra_options = strip(vsoup_getnews_xtra_options, 'B')
  2334. vsoup_getnews_xtra_options = vsoup_getnews_xtra_options option3
  2335. vsoup_getnews_xtra_options = strip(vsoup_getnews_xtra_options, 'B')
  2336.  
  2337. vsoup_getmail_xtra_options = strip(vsoup_getmail_xtra_options, 'B')
  2338. vsoup_getmail_xtra_options = vsoup_getmail_xtra_options option4
  2339. vsoup_getmail_xtra_options = strip(vsoup_getmail_xtra_options, 'B')
  2340.  
  2341. say ''
  2342. say 'Final Souper command-line option settings now are:'
  2343. say 'GETNEWS souper.exe options:' souper_getnews_std_options souper_getnews_xtra_options
  2344. say 'GETMAIL souper.exe options:' souper_getmail_std_options souper_getmail_xtra_options
  2345. say 'SENDING souper.exe options:' souper_send_std_options souper_send_xtra_options
  2346. say ''
  2347. say '...or for vsoup:'
  2348. say 'GETNEWS vsoup.exe options:' vsoup_getnews_std_options vsoup_getnews_xtra_options
  2349. say 'GETMAIL vsoup.exe options:' vsoup_getmail_std_options vsoup_getmail_xtra_options
  2350. say 'SENDING vsoup.exe options:' vsoup_send_std_options vsoup_send_xtra_options
  2351. say ''
  2352. say 'Press any key to continue'
  2353. call SysGetKey 'NOECHO'
  2354.  
  2355. if do_catchup_on_news then
  2356. do
  2357.    k = 1
  2358.    call catchup_on_news   /* do the catchup right now! */
  2359.    
  2360.    if number_of_ISPs > 1 then
  2361.       do k = 2 to number_of_ISPs
  2362.          if isp_active.k = 0 then iterate
  2363.          if default_news.k = 0 then iterate
  2364.          call beep 1000, 200
  2365.          say ''
  2366.          say 'Do catchup on other newsservers (Y/N)?'
  2367.          if \remote then
  2368.             do
  2369.                continue = SysGetKey('NOECHO')
  2370.                if pos(continue, 'yY') \= 0 then leave
  2371.             end
  2372.          x = value('NNTPSERVER', default_news.k, 'OS2ENVIRONMENT')
  2373.          call catchup_on_news
  2374.       end
  2375.    end
  2376. RETURN
  2377.  
  2378.  
  2379. max_news_packet:
  2380.      do until datatype(option1, 'W')
  2381.         call SysCls
  2382.         say ''
  2383.         say 'Enter a number in kilobytes for maximum news packet size.'
  2384.         say '2048 is typical. 0 sets packet size to unlimited.'
  2385.         say ''
  2386.         prompt = 'Enter number of kilobytes now:'
  2387.         say prompt
  2388.         parse value SysCurPos() with row col
  2389.         row  = row - 1
  2390.         col = length(prompt) + 2
  2391.         call SysCurPos row, col
  2392.         pull option1
  2393.         if \DataType(option1, 'W') then say 'Must be whole number or zero.'
  2394.      end
  2395.      say ''
  2396.      say 'Maximum packet size for news is set to' option1 'kilobytes'
  2397.      option1 = '-k' option1
  2398.      say ''
  2399.      say ''
  2400.      say 'Press any key to continue'
  2401.      call SysGetKey 'NOECHO'
  2402. RETURN
  2403.  
  2404. max_news_lines:
  2405.       call SysCls
  2406.       do until datatype(option2, 'W')
  2407.         say ''
  2408.         say 'Do not retrieve articles with more than this many lines'
  2409.         say 'in the body of the article.  Enter 0 for unlimited (the'
  2410.         say 'usual default for souper).'
  2411.         say ''
  2412.         prompt = 'Enter maximum lines:'
  2413.         say prompt
  2414.         parse value SysCurPos() with row col
  2415.         row  = row - 1
  2416.         col = length(prompt) + 2
  2417.         call SysCurPos row, col
  2418.         pull option2
  2419.         if \DataType(option2, 'W') then say 'Must be whole number or zero.'
  2420.      end
  2421.      say ''
  2422.      say 'Reject newsgroup articles with more than' option2 'lines in body.'
  2423.      if option2 = 0 then option2 = ''
  2424.         else option2 = '-l' option2
  2425.      say ''
  2426.      say ''
  2427.      say 'Press any key to continue'
  2428.      call SysGetKey 'NOECHO'
  2429. RETURN
  2430.  
  2431. read_only_getmail_mode:
  2432.       call SysCls
  2433.       do until pos(option4, 'YN') \=0
  2434.         say ''
  2435.         say 'For mail: You can set to read-only.  Retrieves mail but'
  2436.         say 'does not empty POP3 mailbox.'
  2437.         say ''
  2438.         say 'Set to Read-Only Mode?'
  2439.         prompt = 'Y sets Read-Only mode, N (normal default) doesn''t:'
  2440.         say prompt
  2441.         parse value SysCurPos() with row col
  2442.         row  = row - 1
  2443.         col = length(prompt) + 2
  2444.         call SysCurPos row, col
  2445.         pull option4
  2446.      end
  2447.      if option4 ='Y' then
  2448.         do
  2449.         say 'Read-Only mode set'
  2450.         option4 = '-r'
  2451.         end
  2452.      else
  2453.         do
  2454.         say 'Regular (not Read-Only) mode set'
  2455.         option4 = ''
  2456.         end 
  2457.      say ''
  2458.      say ''
  2459.      say 'Press any key to continue'
  2460.      call SysGetKey 'NOECHO'
  2461. RETURN
  2462.  
  2463.  
  2464. /*
  2465. ==============================================
  2466. are_there_interfaces_up()
  2467.  
  2468. Checks for active router interfaces.  We look specifically
  2469. for an interface with the same characters in interf_prefix
  2470. (or at least, for its forst n characters where n=length of
  2471. interf_prefix).  Returns ifprefix_interf_up=1 if found.
  2472.  
  2473. Then, whatever the prefix, checks whether any interface(s)
  2474. are up whether its prefix is interf_prefix, sl, ppp, slip,
  2475. lan, l, or whatever.  Returns some_interf_up=1 if found.
  2476.  
  2477. We obliterate upper/lower case distinctions in the prefix.
  2478. i.e., ppp is the same as PPP.
  2479. ==============================================
  2480. */
  2481.  
  2482. are_there_interfaces_up:
  2483. if_prefix = translate(interf_prefix)
  2484.  
  2485. some_interf_up = 0 
  2486. ifprefix_interf_up = 0
  2487. some_interf_up = 0
  2488. dest = ''
  2489. interface = ''
  2490.  
  2491. call rxqueue 'CREATE', queue_ydint        /* (re)create internal queue */
  2492. call rxqueue 'SET', queue_ydint        /* set internal queue */
  2493. /* do queued(); parse pull; end */        /* If there is anything in it, clear it out */
  2494.  
  2495. netstat_line = ''
  2496. 'netstat -r | rxqueue /LIFO' queue_ydint        /* send output to the queue */
  2497. do queued()
  2498.    pull netstat_line /* interface may be last word */
  2499.    dest = word(netstat_line, 1)
  2500.    dest = strip(dest, 'B')
  2501.    if dest = 'DESTINATION' then iterate /* line is a heading line, discard */
  2502.    if dest = 'METRIC' then iterate /* line is a heading line, discard */
  2503.    if words(netstat_line) > 0 then
  2504.       do
  2505.          interface = word(netstat_line, words(netstat_line))
  2506.          if left(interface, length(interf_prefix)) = if_prefix then
  2507.             ifprefix_interf_up = 1
  2508.          if interface \= '' then some_interf_up = 1      /* anything */
  2509.       end
  2510.    else iterate
  2511. end
  2512.  
  2513. do queued(); parse pull; end        /* If there is anything in queue, clear it out */
  2514. call rxqueue 'SET', queue_ydext        /* reset to whatever queue may have been in use before */ 
  2515. RETURN
  2516.  
  2517. /*
  2518. =====================
  2519. make_if_list()
  2520.  
  2521. Creates a string of all router interfaces detected,
  2522. with spaces as separators.  The interfaces are
  2523. translated to upper case before being recorded in the string.
  2524.  
  2525.  
  2526. possible examples of what an if _list will look like:
  2527. if_list = 'PPP3 PPP1 SL0'
  2528. if_list = ''        (none detected)
  2529. if_list = 'SL0'
  2530.  
  2531. if_list  includes all interface types; they can be mixed
  2532.  
  2533. make_if_list() returns the list (as a string, if_list)
  2534. We obliterate upper/lower case distinctions:  i.e., ppp 
  2535. becomes PPP.
  2536. =====================
  2537. */ 
  2538. make_if_list:
  2539.  
  2540. if_list = ''
  2541. dest = ''
  2542. interface = ''
  2543.  
  2544. call rxqueue 'CREATE', queue_ydint        /* (re)create internal queue */
  2545. call rxqueue 'SET', queue_ydint        /* set internal queue */
  2546. /* do queued(); parse pull; end */        /* If there is anything in it, clear it out */
  2547.  
  2548. 'netstat -r | rxqueue /LIFO' queue_ydint        /* send output to the queue */
  2549. do queued()
  2550.    pull netstat_line /* interface may be last word */
  2551.       if words(netstat_line) > 0 then
  2552.          do
  2553.             interface = word(netstat_line, words(netstat_line))
  2554.             dest = word(netstat_line, 1)
  2555.             dest = strip(dest, 'B')
  2556.             if dest = 'DESTINATION' then iterate /* line is the heading line, discard */
  2557.             if dest = 'METRIC' then iterate /* line is the heading line, discard */
  2558. /* if interface is not in the list, add it */
  2559.             if pos(interface, if_list) = 0 then if_list = if_list interface
  2560.          end
  2561.       else iterate
  2562. end
  2563.  
  2564. do queued(); parse pull; end        /* If there is anything in queue, clear it out */
  2565. call rxqueue 'SET', queue_ydext        /* reset to whatever queue may have been in use before */ 
  2566. RETURN if_list
  2567.  
  2568. /*
  2569. ==============================================
  2570. wait_for_interface()
  2571.  
  2572. Waits for a new interface to become active, which is
  2573. deduced from comparison of interface(s) returned by NETSTAT.EXE -r
  2574. to the string prepared before starting the dialer of all
  2575. (any) pre-existing interfaces (if_list).
  2576.  
  2577. Takes two arguments which are
  2578.    total_delay        the wait until timeout, seconds
  2579.    quiet        quiet mode if 1, verbose mode if 0
  2580.  
  2581. Returns the variable found_interface which =1 if 
  2582. a new interface is detected or =0 if we time out
  2583. before finding a new one.  Upper/lower case differences do not matter.
  2584. ==============================================
  2585. */
  2586.  
  2587. wait_for_interface:
  2588. parse arg total_delay, quiet
  2589.  
  2590. recheck_delay = 1        /* recheck interval in seconds */
  2591. if_prefix = translate(interf_prefix)
  2592. ifp_length = length(interf_prefix)
  2593.  
  2594. say 'Waiting for' service '(' || interf_prefix || ') - maximum wait =' total_delay 'second(s)'
  2595.  
  2596. found_interface = 0        /* clear to not found */
  2597.  
  2598. call rxqueue 'CREATE', queue_ydint        /* (re)create internal queue */
  2599. call rxqueue 'SET', queue_ydint        /* set internal queue */
  2600. /* do queued(); parse pull; end */        /* If there is anything in it, clear it out */
  2601.  
  2602. do index = 1 to total_delay by recheck_delay        /* Periodically check avail. routes */
  2603.    call SysSleep recheck_delay        /* Minor delay, then check for routes */
  2604.    'netstat -r | rxqueue /LIFO' queue_ydint        /* send output to the queue */
  2605.  
  2606.    do queued()
  2607.       pull netstat_line        /* May have interface as last word in line */
  2608.       dest = word(netstat_line, 1)
  2609.       dest = strip(dest, 'B')
  2610.       if dest = 'DESTINATION' then iterate /* line is the heading line, discard */
  2611.       if dest = 'METRIC' then iterate /* line is the heading line, discard */
  2612.          if words(netstat_line) > 0 then
  2613.             do
  2614.                interface = word(netstat_line, words(netstat_line))
  2615.                if left(interface, ifp_length) = if_prefix then        /* Check for interface */
  2616.                   do
  2617.                      if pos(interface, if_list) = 0 then
  2618.                         do
  2619.                            found_interface = 1 /* (new) , we did not time out */ 
  2620.                            if \quiet then say 'interface' interface 'detected'
  2621.                               leave index
  2622.                         end
  2623.                    end        /* of If Left(interface, ifp_length) = if_prefix */
  2624.             end   /* if words(...) */
  2625.    end        /* of Do Queued() */
  2626. end        /* of Do Index */ 
  2627.  
  2628. do queued(); parse pull; end        /* If there is anything in queue, clear it out */
  2629. call rxqueue 'SET', queue_ydext        /* reset to whatever queue may have been in use before */ 
  2630. RETURN found_interface
  2631.  
  2632. /*
  2633. =================
  2634. file_is_there()
  2635.  
  2636. Finds files using wild cards
  2637. =================
  2638. */
  2639. file_is_there: procedure
  2640. file.1 = ''
  2641. arg file
  2642. call SysFileTree file, 'file', 'FO'
  2643. if file.1 = '' then there = 0
  2644. if file.1 \= '' then there = 1
  2645. file.1 = ''
  2646. RETURN there
  2647.  
  2648.  
  2649. /*
  2650. ==============================================
  2651. HANDLING OF ERROR TRAPS
  2652.  
  2653. ReXX Errors (failure, halt, syntax, novalue, error,
  2654. novalue) that occur with SIGNAL ON XXXXX (XXXXX = failure,
  2655. halt, etc.) are diverted (we jump) to one of these
  2656. where the error and the offending line are identified.
  2657. ==============================================
  2658. */
  2659.  
  2660.    FAILURE:
  2661.    say 'Rexx FAILURE condition' rc 'in line' sigl ':' errortext(rc)
  2662.    say sourceline(sigl)
  2663.  
  2664.    call beep 300, 500
  2665.    do_not_kill = 0
  2666.    call rxqueue 'CREATE', queue_ydint        /* (re)create internal queue */
  2667.    call rxqueue 'DELETE', queue_ydint
  2668.    call rxqueue 'SET', queue_ydext        
  2669.    signal goodbye
  2670.    RETURN
  2671.  
  2672.  
  2673.    HALT:
  2674.    say 'Rexx HALT condition' rc 'in line' sigl ':' errortext(rc)
  2675.    say sourceline(sigl)
  2676.  
  2677.    call beep 300, 500
  2678.    do_not_kill = 0
  2679.    call rxqueue 'CREATE', queue_ydint
  2680.    call rxqueue 'DELETE', queue_ydint
  2681.    call rxqueue 'SET', queue_ydext        
  2682.    signal goodbye
  2683.    RETURN
  2684.  
  2685.  
  2686.    SYNTAX:
  2687.    say 'Rexx SYNTAX error' rc 'in line' sigl ':' errortext(rc)
  2688.    say sourceline(sigl)
  2689.  
  2690.    call beep 300, 500
  2691.    do_not_kill = 0
  2692.    call rxqueue 'CREATE', queue_ydint
  2693.    call rxqueue 'DELETE', queue_ydint
  2694.    call rxqueue 'SET', queue_ydext        
  2695.    signal goodbye
  2696.    RETURN
  2697.  
  2698.  
  2699.    NOTREADY:
  2700.    say 'Rexx NOTREADY condition' rc 'in line' sigl ':' errortext(rc)
  2701.    say sourceline(sigl)
  2702.  
  2703.    call beep 300, 500
  2704.    do_not_kill = 0
  2705.    call rxqueue 'CREATE', queue_ydint
  2706.    call rxqueue 'DELETE', queue_ydint
  2707.    call rxqueue 'SET', queue_ydext        
  2708.    signal goodbye
  2709.    RETURN
  2710.  
  2711.  
  2712.    ERROR:
  2713.    say 'Rexx ERROR condition' rc 'in line' sigl ':' errortext(rc)
  2714.    say sourceline(sigl)
  2715.  
  2716.    call beep 300, 500
  2717.    do_not_kill = 0
  2718.    call rxqueue 'CREATE', queue_ydint
  2719.    call rxqueue 'DELETE', queue_ydint
  2720.    call rxqueue 'SET', queue_ydext        
  2721.    signal goodbye
  2722.    RETURN
  2723.  
  2724.  
  2725.    NOVALUE:
  2726.    say 'Rexx NOVALUE condition' rc 'in line' sigl ':' errortext(rc)
  2727.    say sourceline(sigl)
  2728.  
  2729.    call beep 300, 500
  2730.    do_not_kill = 0
  2731.    call rxqueue 'CREATE', queue_ydint
  2732.    call rxqueue 'set', queue_ydint
  2733.    call rxqueue 'DELETE', queue_ydint
  2734.    call rxqueue 'SET', queue_ydext        
  2735.    signal goodbye
  2736.    RETURN
  2737. 
  2738.  
  2739.  
  2740.  
  2741.  
  2742.  
  2743.  
  2744.