home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / comm / fido / polly10.lha / polly / _poll.spot next >
Text File  |  1997-02-16  |  3KB  |  117 lines

  1. /*
  2. ** $VER: Polly 1.0 (16.2.97) Rolf Rotvel
  3. **
  4. ** Uses rexxreqtools.library and traplist.library (Optional)
  5. */
  6.  
  7. cfgpath = 'mail:max/spot.prefs'     /* Path to Spot cfg file */
  8. outpath = 'out:'                    /* Your outbound directory */
  9.  
  10. pollcmd = 'cc:brun trapdoor call'   /* Generic poll cmd. Must be able to call */
  11.                                     /* a nodenumber directly like TrapDoor */
  12.  
  13. traplist? = 1                       /* Set to 1 if you have traplist.library */
  14.                                     /* installed. 0 if not */     
  15.  
  16. /*
  17. ** End of cfg.
  18. */
  19. call addlib('rexxreqtools.library', 0, -30, 0)
  20. call addlib('rexxsupport.library', 0, -30, 0)
  21. if traplist? then call addlib('traplist.library', 0, -30, 0)
  22.  
  23. nl = '0a'x
  24. version = 'Polly '||word(sourceline(2), 4)
  25. pollnodes = ''
  26.  
  27. oldstamp = getclip('pollspot.stamp')
  28. parse value statef(cfgpath) with . . . . days mins ticks .
  29. newstamp = days||mins||ticks
  30.  
  31. if oldstamp ~= newstamp then do
  32.     if ~open('cfg', cfgpath, 'r') then exit 10
  33.     cfgtxt = readch('cfg', 65535)
  34.     call close('cfg')
  35.  
  36.     call setclip('pollspot.stamp', newstamp)
  37.     count = 1
  38.     reqbody = ''
  39.     reqgads = ''
  40.  
  41.     do forever      /* Terminates if no more POLL statements */
  42.         parse var cfgtxt . 'ADDRESS ' node '.' cfgtxt
  43.         pollmark = pos('POLL ', cfgtxt)
  44.         if pollmark = 0 then leave  
  45.  
  46.         nodemark = pos('ADDRESS', cfgtxt)
  47.         /* POLL comes before next ADDRESS or it's the last ADDRESS */
  48.         if pollmark < nodemark | nodemark = 0 then do 
  49.             reqbody = reqbody||nl||count||' : '||node
  50.             reqgads = reqgads||'_'||count||'|'
  51.             pollnodes = pollnodes||node||' '
  52.             count = count + 1                           
  53.         end
  54.     end
  55.     call setclip('pollspot.reqbody', reqbody)
  56.     call setclip('pollspot.reqgads', reqgads)
  57.     call setclip('pollspot.pollnodes', pollnodes)
  58. end
  59. else do
  60.     pollnodes = getclip('pollspot.pollnodes')
  61.     count = words(pollnodes) + 1
  62.  
  63.     reqbody = getclip('pollspot.reqbody')
  64.     reqgads = getclip('pollspot.reqgads')
  65. end
  66.  
  67. outfiles = upper(showdir(outpath, 'f'))
  68. if outfiles ~= '' then do 
  69.     outnodes = ''
  70.     cut = pos('.CUT', outfiles)
  71.     req = pos('.REQ', outfiles)
  72.     do forever
  73.         if cut = 0 & req = 0 then leave
  74.         if (req > cut & cut > 0) | req = 0 then do  
  75.             call getnode('.CUT')
  76.             cut = pos('.CUT', outfiles)
  77.         end
  78.         else do
  79.             call getnode('.REQ')
  80.             req = pos('.REQ', outfiles)
  81.         end
  82.     end
  83. end
  84.  
  85. parse var reqbody (nl) reqbody
  86. reqgads = reqgads||'_Node|_Quit'
  87.  
  88. ans = rtezrequest(reqbody, reqgads, version)
  89.  
  90. allnodes = pollnodes||outnodes
  91. select
  92.     when ans = 0 then exit
  93.     when ans = count then do    /* Count = nodes + 1 */
  94.         node = rtgetstring(,,'Type nodenumber', '_Ok|_Quit')
  95.         if rtresult = 0 | (traplist? & ~word(findnode(node), 1)) then exit
  96.     end
  97.     otherwise node = word(allnodes, ans)
  98. end
  99.  
  100. if pos(node, pollnodes) > 0 & show('p', 'SPOT') then address 'SPOT' 'poll node '||node||'.0'
  101. else address command pollcmd node
  102.  
  103. exit
  104.  
  105. GETNODE:
  106. arg suff
  107. parse var outfiles start (suff) outfiles
  108. parse value word(start, words(start)) with z '.' r '.' n '.' .
  109. node = z||':'||r||'/'||n
  110. if (traplist? & ~word(findnode(node), 1)) | pos(node, pollnodes) > 0 then return
  111.  
  112. outnodes = outnodes||node||' '
  113. reqbody = reqbody||nl||count||' : '||node||' ('||suff||')'
  114. reqgads = reqgads||'_'||count||'|'
  115. count = count + 1
  116. return
  117.