home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / vsoup128.zip / yarnio.cmd < prev    next >
OS/2 REXX Batch file  |  1997-04-05  |  20KB  |  740 lines

  1. /*
  2.  *  make IO for Yarn -  rg060297
  3.  *
  4.  *  Please read the following sections carefully.  For further information
  5.  *  refer to VSoup.Inf/VSoup.Txt.
  6.  *
  7.  *  rg130696:
  8.  *  - now using VSoup for news reception
  9.  *  - big update:
  10.  *    simultaneous mail/news reception/transmission
  11.  *  rg180796:
  12.  *  - 'import' retries in an endlos loop until soup.zip has been accepted
  13.  *  - if SEND fails, the messages are zipped again, which means they can be edited
  14.  *    again in Yarn
  15.  *  rg080996:
  16.  *  - auto connect/disconnect, if required
  17.  *  - user configuration section better indicated
  18.  *  - YarnBinDir no longer required (see config section)
  19.  *  - the secondary newsserver can be defined via YARNIONEWS2 environment variable
  20.  *  - if YARNIONEWS2 is empty, the secondary news server is disabled by default
  21.  *  - yarnio-operation a little bit more secure (chance of packet loss minimized...)
  22.  *  - new command line options for disabling specific services
  23.  *  rg130996:
  24.  *  - semaphor for each service
  25.  *  - legal to start multiple instances of YarnIo
  26.  *  - simple signal handling for logoutISP (signal handling is real b*llsh*t in REXX,
  27.  *    because one has to use the environment vars)
  28.  *  - YarnIo is checking %YARN%\history.pag before starting import...
  29.  *  rg170996:
  30.  *  - configuration file yarnio.set (resides in the same directory as yarnio.cmd)
  31.  *    now user configuration and YarnIo are independent
  32.  *  rg200996:
  33.  *  - zipProg/unzipProg now in YarnIo.Set
  34.  *  rg220996:
  35.  *  - signal handling removed!  To check and abort the connection an extra CMD
  36.  *    will be opened
  37.  *  rg161096:
  38.  *  - zipping now only for SEND operation (to allow reedit)
  39.  *  - areas / *.msg is not imported with 'import -u' (YarnIo.Set must be changed!!)
  40.  *  rg041196:
  41.  *  - now capable of handling up to 9 news/mail server for reception
  42.  *    RCVMAIL2..RCVMAIL9, RCVNEWS2..RCVNEWS9 are all optional and enabled in YARNIO.SET
  43.  *    through definition of the variables 'soupRcvMail2'..'soupRcvMail9' and
  44.  *    'soupRcvNews2'..'soupRcvNews9'
  45.  *  rg171196:
  46.  *  - connect loop changed.  Now 'ping' cmds with delay can also be used (e.g. slipwait)
  47.  *  rg060297:
  48.  *  - bug in 'ping' loop (Connect)
  49.  *
  50.  *  environment vars:
  51.  *  - home
  52.  *  - tmp
  53.  *  - yarn
  54.  *
  55.  *  directory structure (must be set up manually!):
  56.  *  - %home%\yarn\in       - files for reception
  57.  *  - %home%\yarn\in\mail  - files for received mail from primary POP3 server
  58.  *  - %home%\yarn\in\mail2 - files for received mail from POP3 server 2 (optionally)
  59.  *             :
  60.  *  - %home%\yarn\in\mail9 - files for received mail from POP3 server 9 (optionally)
  61.  *  - %home%\yarn\in\news  - files for received news from primaray NNTP server
  62.  *  - %home%\yarn\in\news2 - files for received news from NNTP server 2 (optionally)
  63.  *             :
  64.  *  - %home%\yarn\in\news9 - files for received news from NNTP server 9 (optionally)
  65.  *  - %home%\yarn\out      - souper packets for transmission
  66.  *  - %yarn%               - yarn subdir (history.pag required)
  67.  *
  68.  *  external utilities (configured in yarnio.set):
  69.  *  - vsoup.exe        - soup packet receiver transmitter
  70.  *  - import.exe       - import messages to Yarn database
  71.  *  - zip              - zip files
  72.  *  - unzip            - unzip files
  73.  *  - ping             - ping a host (exit status 0 indicates there is a connection)
  74.  *  - loginisp.cmd     - connect to your ISP
  75.  *  - logoutisp.cmd    - disconnect from your ISP
  76.  *                       if you have an auto-dialer, loginisp/logoutisp can be empty cmd files
  77.  *
  78.  *  options:
  79.  *  -SEND      - no mail/news transmission
  80.  *  -RCVMAIL   - no mail reception primary POP3 server
  81.  *  -RCVMAIL2  - no mail reception 2nd POP3 server
  82.  *       :
  83.  *  -RCVMAIL9  - no mail reception 9th POP3 server
  84.  *  -RCVNEWS   - no news reception from primary newsserver
  85.  *  -RCVNEWS2  - no news reception from newsserver #2
  86.  *       :
  87.  *  -RCVNEWS9  - no news reception from newsserver #9
  88.  *
  89.  *  internal options:
  90.  *   SEND      - start the send process
  91.  *   RCVMAIL   - start the receive mail process
  92.  *   RCVMAIL2 .. RCVMAIL9
  93.  *   RCVNEWS   - start the receive news process
  94.  *   RCVNEWS2 -- RCVNEWS9
  95.  *   CHECKISP  - if YarnIo failes, connection will be killed
  96.  *  with no option given, YarnIo starts all the above processes
  97.  *
  98.  *  todo:
  99.  *  - restructure script, so that there are several procedures (& stems)
  100.  *  - output to several servers (smtp & nntp) - requires an external utility
  101.  */
  102.  
  103. call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  104. call SysLoadFuncs
  105.  
  106.  
  107. rc = SysCls()
  108. SAY 'YarnIo -- Copyright (c) 1996 by Hardy Griech'
  109. SAY ''
  110. SAY ''
  111.  
  112.  
  113. DEBUG = 0
  114.  
  115. /*
  116.  *  get some global vars
  117.  */
  118. env = 'os2environment'
  119. homeDir = value('home',,env)
  120. tmpDir  = value('tmp',,env)
  121. yarnDir = value('yarn',,env)
  122. parse source . . compCmdName
  123. cmdName = filespec('name',compCmdName)
  124. CompSetName = delstr(CompCmdName,lastpos('.',CompCmdName)) || '.set'
  125.  
  126. IF (homeDir = '')  |  (tmpDir = '')  |  (yarnDir = '') THEN DO
  127.     call Help 'Either HOME, TMP or YARN not defined in environment'
  128. END
  129.  
  130. /*********************************************************************************
  131.  *********************************************************************************
  132.  *
  133.  *  begin of user configuration section
  134.  *
  135.  *  define some global vars (commands / directories)
  136.  *  change, if you like to
  137.  *
  138.  *  NEVERTHELESS IT IS NOT RECOMMENDED TO CHANGE ANYTHING IN THIS SECTION
  139.  *       TRY TO KEEP YOUR CONFIGURATION IN THE YARNIO.SET FILE
  140.  */
  141.  
  142. rc            = setlocal()
  143. xmtDir        = homeDir || '\yarn\out'
  144. soupXmtZip    = 'reply.zip'                 /* same as in yarn-config! */
  145. rcvDir        = homeDir || '\yarn\in'
  146. rcvNewsDir    = rcvDir  || '\news'
  147. rcvMailDir    = rcvDir  || '\mail'
  148. DO ii = 2 TO 9
  149.     dummy = VALUE( 'rcvNews' || ii || 'Dir', rcvNewsDir || ii )
  150.     dummy = VALUE( 'rcvMail' || ii || 'Dir', rcvMailDir || ii )
  151. END
  152.  
  153. /*
  154.  *  set up some configuration defaults
  155.  */
  156. soupSend      = ''
  157. soupRcvNews   = ''
  158. soupRcvMail   = ''
  159. echoProlog    = 'echo' CompSetName || ': no'
  160. preImportProg = ''
  161. importProg    = echoProlog 'importProg defined:'
  162. pingHost      = echoProlog 'pingHost defined'
  163. connectISP    = echoProlog 'connectISP defined'
  164. hangupISP     = echoProlog 'hangupISP defined'
  165. unzipProg     = echoProlog 'unzipProg defined'
  166.  
  167. /*
  168.  *  the following could be changed, but this is not required (at least if you have zip/unzip)
  169.  */
  170. yarnHistory   = yarnDir || '\history.pag'
  171. soupRcvAreas  = 'areas'
  172. SoupRcvMsgs   = '*.msg'
  173. SoupXmtReply  = 'replies'
  174. SoupXmtMsgs   = '*.msg'
  175.  
  176. /*
  177.  *  interprete the user configuration
  178.  */
  179. if \FileExists(CompSetName) then do
  180.    say CompSetName 'required for configuration'
  181.    exit 3
  182. END
  183.  
  184. CALL GetIniFile
  185.  
  186. unzipProg     = unzipProg soupXmtZip
  187. zipProgSend   = zipProg soupXmtZip soupXmtReply soupXmtMsgs
  188.  
  189. /*
  190.  *  end of configuration section
  191.  *
  192.  *********************************************************************************
  193.  *********************************************************************************/
  194.  
  195. '@set EMXOPT=-h40 -c -n'   /*  set the maximum number of handles to 40  */
  196.  
  197. /*
  198.  *  files for internal use
  199.  */
  200. semActive   = tmpdir  || '\yarnio.act'
  201. semLocal    = '.\yarnio.act'
  202. semImport   = tmpdir  || '\yarnio.imp'
  203. flgRcvNews  = tmpdir  || '\yarnio.fn'
  204. flgRcvMail  = tmpDir  || '\yarnio.fm'
  205. flgXmt      = tmpDir  || '\yarnio.fx'
  206. DO ii = 2 TO 9
  207.     dummy = VALUE( 'flgRcvNews' || ii, flgRcvNews || ii )
  208.     dummy = VALUE( 'flgRcvMail' || ii, flgRcvMail || ii )
  209. END
  210.  
  211.  
  212. if \DEBUG then do
  213.     startProc = 'start /c /b /min'
  214. end
  215. else do
  216.     startProc = 'start /c /b'
  217. end
  218.  
  219. if DEBUG then 
  220.     trace('?i')
  221.  
  222. /*
  223.  *  get command line options
  224.  */
  225. Option = ''
  226. AddOption = ''
  227. parse upper arg ropt
  228. do while ropt \= ''
  229.     parse var ropt opt ropt
  230.     add = 1
  231.     select
  232.     when LEFT(opt,8) = '-RCVMAIL'  &  SYMBOL('soup' || SUBSTR(opt,2)) = 'VAR' THEN
  233.         dummy = VALUE( 'soup' || SUBSTR(opt,2), '' );
  234.     when LEFT(opt,8) = '-RCVNEWS'  &  SYMBOL('soup' || SUBSTR(opt,2)) = 'VAR' THEN
  235.         dummy = VALUE( 'soup' || SUBSTR(opt,2), '' );
  236.     when opt = '-SEND' then
  237.         soupSend = ''
  238.     otherwise do
  239.         Option = opt
  240.         add = 0
  241.     end
  242.     end
  243.     if add then
  244.     AddOption = AddOption opt
  245. end
  246.  
  247. /*
  248.  *  do the thing
  249.  */
  250. if Option = '' then do
  251.     wasConnected = 1;
  252.     haveSema = 0;
  253.     if stream(semActive,'c','open write') = 'READY:' then do
  254.     haveSema = 1;
  255.     wasConnected = Connect()
  256.     end
  257.     /*
  258.      *  initiate all other processes and wait for completion
  259.      */
  260.     rc = time('R')
  261.     say 'starting the transmitting/receiving processes...'
  262.     rc = DeleteFile( flgRcvNews )    /* fails, if already started... */
  263.     '@' startProc '"RCVNEWS:' soupRcvNews || '"'  CompCmdName 'RCVNEWS'  AddOption
  264.     rc = DeleteFile( flgRcvMail )
  265.     '@' startProc '"RCVMAIL:' soupRcvMail || '"'  CompCmdName 'RCVMAIL'  AddOption
  266.     rc = DeleteFile( flgXmt )
  267.     '@' startProc '"SEND:' soupSend || '"'     CompCmdName 'SEND'     AddOption
  268.     DO ii = 2 TO 9
  269.     rc = DeleteFile( VALUE('flgRcvNews' || ii) )
  270.     IF SYMBOL('soupRcvNews' || ii) = 'VAR' THEN
  271.         '@' startProc '"RCVNEWS' || ii || ':' VALUE('soupRcvNews'||ii) || '"' CompCmdName 'RCVNEWS' || ii AddOption
  272.     rc = DeleteFile( VALUE('flgRcvMail' || ii) )
  273.     IF SYMBOL('soupRcvMail' || ii) = 'VAR' THEN
  274.         '@' startProc '"RCVMAIL' || ii || ':' VALUE('soupRcvMail'||ii) || '"' CompCmdName 'RCVMAIL' || ii AddOption
  275.     END
  276.     
  277.     State = 'aborted'
  278.     if haveSema then do
  279.     say 'waiting...'
  280.     say ''
  281.     rc = SysSleep( 10 )     /*  time to start subprocesses  */
  282.     loopCnt = 0
  283.     /*
  284.      *  This loop waits until no flgXmt/flgRcv remains
  285.      *  After that operations is aborted
  286.      */
  287.     do forever
  288.         rc = SysSleep( 1 )
  289.         loopCnt = loopCnt + 2
  290.         if loopCnt > 3600 then do
  291.         say 'timeout:  cleaning up and exit...'
  292.         leave
  293.         END
  294.         te = TIME('E')  /* **** */
  295.         SAY te || 's'
  296.         rc = DispStatus( 'online:' format(te,,1) || 's' )
  297.         rc = CheckFlag( flgXmt,     'SEND:    ' );
  298.         rc = CheckFlag( flgRcvMail, 'RCVMAIL: ' );
  299.         rc = CheckFlag( flgRcvNews, 'RCVNEWS: ' );
  300.         DO ii = 2 TO 9
  301.         rc = CheckFlag( VALUE('flgRcvNews' || ii), 'RCVNEWS' || ii || ':' );
  302.         rc = CheckFlag( VALUE('flgRcvMail' || ii), 'RCVMAIL' || ii || ':' );
  303.         END
  304.         rc = SysSleep( 1 )
  305.         ex = \FileExists(flgRcvNews) & \FileExists(flgRcvMail) & \FileExists(flgXmt);
  306.         DO ii = 2 TO 9
  307.         ex = ex & \FileExists(VALUE('flgRcvNews' || ii)) & \FileExists(VALUE('flgRcvMail' || ii));
  308.         END
  309.         IF ex THEN DO
  310.         SAY ''
  311.         say 'finished...'
  312.         leave
  313.         end
  314.     end
  315.     State = 'ok'
  316.     end
  317.     else
  318.     State = 'already active'
  319.     rc = CleanUp( State )
  320. end
  321. else if Option = 'CHECKISP' then do
  322.     say 'checking the connection...'
  323.     do forever
  324.     rc = SysSleep( 5 )
  325.     if stream(semActive,'c','open write') = 'READY:' then do
  326.         rc = DeleteFile( semActive )
  327.         rc = SysSleep( 5 )
  328.         rc = hangup( 1 )
  329.         rc = SysSleep( 5 )
  330.         exit 0
  331.     end
  332.     end
  333. end
  334. else if Option = 'SEND' then do
  335.     /*
  336.      *  transmit messages (news & mail)
  337.      */
  338.     text = CheckCmd(soupSend)
  339.     if text = '' then do
  340.     text = SetWorkingDir(xmtDir)
  341.     if text = '' then DO
  342.         text = SetFlag(flgXmt,semLocal)
  343.         if text = '' then do
  344.         rc = DoImport()
  345.         text = '-- nothing done'
  346.         if FileExists(soupXmtZip) then do
  347.             '@' unzipProg
  348.         END
  349.         IF FileExists(soupXmtReply) THEN DO
  350.             SAY 'sending messages...'
  351.             SAY soupSend
  352.             '@' soupSend
  353.             text = 'msg(s) transmitted'
  354.             if rc \= 0 then
  355.             text = soupSend 'returned with an error'
  356.             rc = DoImport()                  /* deletes all *.msg belonging to area */
  357.             rc = SysFileDelete( soupXmtZip )
  358.             if FileExists(soupXmtReply) then do
  359.             say 'moving' soupXmtMsgs 'again into' soupXmtZip
  360.             '@' zipProgSend
  361.             end
  362.         END
  363.         rc = SendFlag( flgXmt,text )
  364.         rc = DeleteFile( semLocal )
  365.         end
  366.     end
  367.     end
  368. end
  369. else if LEFT(Option,7) = 'RCVMAIL'  &  SYMBOL('soup' || Option) = 'VAR'  &  SYMBOL(Option || 'Dir') = 'VAR' then
  370.     text = DoReception( VALUE('soup' || Option), VALUE(Option || 'Dir'), VALUE('flg' || Option) )
  371. else if LEFT(Option,7) = 'RCVNEWS'  &  SYMBOL('soup' || Option) = 'VAR'  &  SYMBOL(Option || 'Dir') = 'VAR' then
  372.     text = DoReception( VALUE('soup' || Option), VALUE(Option || 'Dir'), VALUE('flg' || Option) )
  373. ELSE DO
  374.     call Help 'ill option:' Option
  375. END
  376.  
  377. say Option || ':' text
  378. if substr(text,1,1) \= "-" then do
  379.     rc = SysSleep( 30 )   /* do not close window immediately */
  380.     say 'goodbye'         /* last chance for ^S...           */
  381. end
  382. exit 0
  383.  
  384.  
  385.  
  386. CleanUp:  procedure expose hangupISP semActive wasConnected cmdName
  387. State = arg(1)
  388.  
  389. if State = 'ok'  |  State = 'aborted' then do
  390.     say CmdName 'took' format(TIME('E'),,1) || 's'
  391.     
  392.     if \wasConnected then
  393.     rc = Hangup(1)
  394.     say State
  395.     rc = DeleteFile(semActive)
  396.     rc = SysSleep( 30 )
  397.     SAY 'goodbye'
  398.     if State = 'aborted' then
  399.     exit 3
  400.     exit 0
  401. end
  402. else do
  403.     say CmdName 'already active'
  404.     say '(if actually not, delete' semActive 'manually)'
  405.     exit 3 
  406. end
  407.  
  408. AbsExit:
  409. exit 99
  410.  
  411.  
  412.  
  413. /********************************************************************************
  414.  *
  415.  *  Do a single reception procedure
  416.  */
  417. DoReception: procedure expose semImport semLocal preImportProg importProg,
  418.                               soupRcvAreas soupRcvMsgs yarnHistory
  419. cmd     = arg(1)
  420. dir     = arg(2)
  421. flgfile = arg(3)
  422.  
  423. text = CheckCmd(cmd)
  424. if text = '' then do
  425.     text = SetWorkingDir(dir)
  426.     if text = '' then do
  427.     text = SetFlag(flgfile,semLocal)
  428.     if text = '' then do
  429.         rc = DoImport()
  430.         say cmd
  431.         '@' cmd
  432.         text = 'ok'
  433.         if rc \= 0 then
  434.         text = cmd 'returned with an error'
  435.         rc = SendFlag( flgfile,text )     /* hier kann es ein Problem geben, wenn eine zweite Instanz gestartet wurde */
  436.         rc = DoImport()
  437.     end
  438.     rc = DeleteFile( semLocal )
  439.     end
  440. end
  441. return text
  442.  
  443.  
  444.  
  445. /********************************************************************************
  446.  *
  447.  *  Import the received data to the Yarn database
  448.  *  - on entry the current subdir contains the areas, *.msg or zip-files
  449.  *  - sets semaphor to avoid simultaneous imports
  450.  *
  451.  */
  452. DoImport: procedure expose semImport preImportProg importProg ,
  453.     soupRcvAreas soupRcvMsgs yarnHistory
  454.  
  455. /*
  456.  *  wait until semaphor is free
  457.  */
  458. First = 1
  459. do forever
  460.     if \FileExists(soupRcvAreas)  &  \FileExists(soupRcvMsgs) then DO    /*******????****/
  461.     if \First then
  462.         say soupRcvAreas 'vanished (was another instance active?)'
  463.     return 0
  464.     end
  465.     if stream(semImport,'c','open write') = 'READY:' then
  466.     leave
  467.     if First then do
  468.     say 'import locked, waiting for access'
  469.     First = 0
  470.     end
  471.     rc = SysSleep( 5 )
  472. end
  473.  
  474. IF preImportProg \= '' THEN
  475.     '@' preImportProg
  476.  
  477. /*
  478.  *  repeat import until soupRcvAreas has been successfully read...
  479.  */
  480. do forever
  481.     if stream(yarnHistory,'c','open write') = 'READY:' then do
  482.     rc = stream(yarnHistory,'c','close')   /**** hier kann was schiefgehen... ****/
  483.     '@' importProg
  484.     if \FileExists(soupRcvAreas) then
  485.         leave
  486.     end
  487.     if First then do
  488.     say 'import locked, waiting for access'
  489.     First = 0
  490.     end
  491.     rc = SysSleep( 5 )
  492. end
  493. rc = DeleteFile( semImport )
  494. return 1
  495.  
  496.  
  497.  
  498. /********************************************************************************
  499.  *
  500.  *  set the working directory
  501.  *  if operation fails, return value is an error message, 
  502.  *  otherwise empty string is returned
  503.  */
  504. SetWorkingDir: procedure
  505. dir = arg(1)
  506.  
  507. if translate(directory(dir)) = translate(dir) then do
  508.     say 'working directory is' dir
  509.     return ''
  510. end
  511. return 'cannot change to' dir
  512.  
  513.  
  514.  
  515. /********************************************************************************
  516.  *
  517.  *  Check flag file
  518.  */
  519. CheckFlag: procedure
  520. file = arg(1)
  521. msg  = arg(2)
  522.  
  523. if FileExists(file) then DO
  524.     IF stream(file,'c','open read') = 'READY:' THEN DO
  525.     txt = linein( file )
  526.     rc = DeleteFile( file )
  527.     say msg "'" || txt || "'"
  528.     if rc \= 0 then
  529.         say 'cannot delete' file || ', rc=' || rc
  530.     return 1
  531.     end
  532. end
  533. return 0
  534.  
  535.  
  536.  
  537. SetFlag: PROCEDURE
  538. flgfile = ARG(1)
  539. semfile = ARG(2)
  540.  
  541. /*
  542.  *  there is a very small case, when this could fail:
  543.  *  another instance starts & finishs during the '|'
  544.  */
  545. IF stream(semfile,'c','open write') \= 'READY:' THEN
  546.     RETURN '-- blocked'
  547. IF stream(flgfile,'c','open write') \= 'READY:' THEN DO
  548.     rc = DeleteFile(semFile)
  549.     RETURN '-- blocked'
  550. END
  551. RETURN ''
  552.  
  553.  
  554.  
  555. SendFlag: procedure
  556. file = arg(1)
  557. msg  = arg(2)
  558.  
  559. rc = lineout( file,msg )
  560. rc = lineout( file )
  561. return 1
  562.  
  563.  
  564.  
  565. CheckCmd: procedure
  566. cmd = arg(1)
  567.  
  568. if cmd = '' then
  569.     return '-- disabled'
  570. return ''
  571.  
  572.  
  573.  
  574. DeleteFile: procedure
  575. f = arg(1)
  576.  
  577. rc = stream( f,'c','close' )
  578. rc = SysFileDelete( f )
  579. return rc
  580.  
  581.  
  582.  
  583. /********************************************************************************
  584.  *
  585.  *  Connect to ISP, usually calls 'loginisp.cmd'
  586.  *  If you have an auto dialer, then the pinging should be enough to start
  587.  *  connecting.  'loginisp.cmd' can thus be an empty script...
  588.  *
  589.  *  Requires the time('R')/('S') commands to stop the time.  This is due
  590.  *  to delay of the ping command (e.g. 'slipwait 2' takes two seconds, 'ping host 1'
  591.  *  almost no time).
  592.  *
  593.  *  Thanx to scgf@netcomuk.co.uk (Phillip Deackes) for the idea
  594.  */
  595. Connect: procedure expose hangupISP connectISP pingHost CompCmdName startProc DEBUG
  596.  
  597. IF DEBUG THEN
  598.     RETURN 1
  599.  
  600. rc = charout(, 'checking connection --> ' )
  601.  
  602. rc = TIME('R')
  603. do FOREVER
  604.     IF TIME('E') > 2 THEN
  605.     LEAVE
  606.     '@' pingHost
  607.     IF rc = 0 THEN DO
  608.     SAY 'ok'
  609.     RETURN 1
  610.     END
  611. END
  612.  
  613. say 'connecting to ISP'
  614. '@' startProc '"YarnIo CHECKISP"' CompCmdName 'CHECKISP'
  615.  
  616. do i = 1 to 10
  617.     IF i \= 1 THEN
  618.     SAY 'retrying...'
  619.     '@' connectISP
  620.     rt = 80
  621.     DO WHILE rt >= 0
  622.         rc = DispStatus( format(rt,,1) || 's left' )
  623.     rc = TIME('R')
  624.     '@' pingHost
  625.     dt = TIME('E')
  626.     rt = rt - dt
  627.     IF dt < 0.5 THEN DO 
  628.         call SysSleep 1
  629.         rt = rt - 1
  630.     END
  631.     IF rc = 0 THEN DO
  632.         rc = DispStatus( '' )
  633.         RETURN 0
  634.     END
  635.     END
  636.     rc = DispStatus( '' )
  637.     rc = Hangup( 0 )
  638.     rc = SysSleep( 5 )
  639. END i
  640. SAY ''
  641. say '*****************************'
  642. say '*** impossible to connect ***'
  643. say '*** check your equipment  ***'
  644. say '*****************************'
  645. say 'aborted...'
  646. DO FOREVER
  647.     rc = SysSleep( 6000 )
  648. END
  649. return 0
  650.  
  651.  
  652.  
  653. /********************************************************************************
  654.  *
  655.  *  Hangup connection to your ISP, usually calls 'logoutisp.cmd'
  656.  *  The called script/progam could do whatever you want, e.g. if you have
  657.  *  established other connections the 'logoutisp.cmd' could reject the hangup etc...
  658.  */
  659. Hangup: procedure expose hangupISP
  660. sayMsg = arg(1)
  661.  
  662. if sayMsg then
  663.     say 'hanging up connection'
  664. '@' hangupISP
  665. return 1
  666.  
  667.  
  668.  
  669. DispStatus: PROCEDURE
  670. msg = LEFT( ARG(1),25,' ' )
  671.  
  672. IF msg \= '' THEN
  673.     msg = 'Sts:' msg
  674.  
  675. PARSE VALUE SysCurPos( 0,48 ) WITH l c
  676. SAY msg
  677. rc = SysCurPos( l,c );
  678. RETURN 1
  679.  
  680.  
  681.  
  682. FileExists: procedure
  683. filemask = arg(1)
  684. rc = SysFileTree( filemask,res,F,, )
  685. return res.0 \= 0
  686.  
  687.  
  688.  
  689. Help: PROCEDURE EXPOSE CompSetName 
  690. helpMsg = ARG(1)
  691.  
  692. CALL GetIniFile
  693.  
  694. say 'failed:' helpMsg
  695. say ''
  696. say CmdName '0.93 rg060297'
  697. say CmdName 'receives and transmits news/mail to Yarn via VSoup'
  698. say ''
  699. say 'options (for disabling corresponding service):'
  700. msg = ''
  701. IF soupSend \= '' THEN
  702.     msg = '-SEND '
  703. IF soupRcvMail \= '' THEN
  704.     msg = msg || '-RCVMAIL '
  705. IF soupRcvNews \= '' THEN
  706.     msg = msg || '-RCVNEWS '
  707. SAY msg
  708.  
  709. msg = ''
  710. DO ii = 2 TO 9
  711.     IF SYMBOL('soupRcvMail' || ii) = 'VAR' THEN
  712.     msg = msg || '-RCVMAIL' || ii || ' '
  713.     IF SYMBOL('soupRcvNews' || ii) = 'VAR' THEN
  714.     msg = msg || '-RCVNEWS' || ii || ' '
  715. END
  716. SAY msg
  717. SAY
  718. say 'no options given:  perform all services'
  719. exit( 3 )
  720.  
  721.  
  722.  
  723. GetIniFile:
  724.  
  725. IF stream(CompSetName,'c','open read') \= 'READY:' THEN DO
  726.     SAY 'cannot open' CompSetName
  727.     rc = SysSleep( 30 )
  728.     SAY 'goodbye'
  729.     EXIT( 3 )
  730. END
  731.  
  732. do WHILE LINES(CompSetName) \= 0
  733.     line = linein(CompSetName)
  734.     if substr(strip(line),1,1) \= '#' THEN DO
  735.     interpret line
  736.     END
  737. END
  738. rc = stream( CompSetName,'c','close' )
  739. RETURN
  740.