home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / amiga / comms / misc / jwsc0830.lha / jbundle.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  1992-08-06  |  9.8 KB  |  337 lines

  1.  
  2. /*
  3.  *    Origional Name: FidoInOut.Rexx by Russell McOrmond
  4.  *
  5.  *    Modifications To Create Bundler For .OUT files.
  6.  *                                     by James McOrmond
  7.  *
  8.  *
  9.  *    Revision History as JBundle.rexx
  10.  *
  11.  *    Feb 11/92  Bundler options
  12.  *    Feb 13/92  Configurable compressors
  13.  *    Feb 13/92  Hold, Crash, Norm, Direct priorities
  14.  *    Feb 14/92  Fixed bundle naming scheme
  15.  *    Feb 16/92  Added use of TestLock utility by Russell
  16.  *    Feb 16/92  Multiple Outbound Directories
  17.  *    Feb 17/92  Deletes bundles under 5 bytes in size before arc'ng to it
  18.  *    Feb 17/92  Restructure sub-directories - "NONE" compression handled
  19.  *    Feb 17/92  Improves processing time when there is nothing to do
  20.  *    Feb 18/92  Fixed Bug in "NONE" compression directories.
  21.  *    Mar 25/92  Now creates uppercase names
  22.  *    Mar 26/92  Uses standard Us-Them filenames for transit.
  23.  *    Mar 26/92  Generates more random .pkt filenames.
  24.  *    Mar 27/92  Added Us-Them for pointnet addresses.
  25.  *    Apr 7/92   Fixed Support for Archivers that don't like 4d filenames.
  26.  *    Apr 7/92   Complete re-did the archiving procedure.
  27.  *    Apr 13/92  Fixed Bug in Bundle Naming Scheme.
  28.  *    Apr 22/92  fixes sent in by Rick Morrow updated.
  29.  *    May 1?/92  Cleaned up naming scheme, minor changes
  30.  *    Jul 31/92  pkt naming scheme used as suggested by Walt Sullivan.
  31.  *    Aug 8/92   Minor cleaning up.  Removal of DLGMail specific.
  32.  *             
  33.  *             
  34.  *
  35.  *    Configure your address in lines 83 - 90.
  36.  *    Set your Directorys in lines 59 - 62
  37.  *    If you want this as fast as possible, uncomment lines 161-166
  38.  */
  39.  
  40.  
  41. options results
  42.  
  43. DTF_IFSENT = 128
  44. DTF_DELETE = 64
  45. DTF_TRUNCATE = 32
  46. DTF_REQUEUE = 16
  47.  
  48. DT_TRUNCATE     = DTF_IFSENT+DTF_TRUNCATE+DTF_REQUEUE
  49. DT_FILEATTACH   = DTF_IFSENT+DTF_REQUEUE
  50. DT_DELETE       = DTF_IFSENT+DTF_DELETE+DTF_REQUEUE
  51. DT_SHOW_DELETE  = DT_DELETE
  52. DT_NOTHING      = DT_FILEATTACH
  53. DT_EXTRA_DELETE = DT_DELETE
  54. DT_REQUEST      = DTF_REQUEUE+DTF_DELETE
  55. DT_MAILBUNDLE   = DT_TRUNCATE
  56.  
  57. DTPRI_CRASH = 50
  58. DTPRI_HOLD  = -50
  59. DTPRI_DIRECT= 30
  60.  
  61. nl='0a'X
  62. cr='0d'X
  63. TRUE = 1
  64. FALSE = 0
  65.  
  66. PACKETS = "OUTBOUND:"          /* where #?.#?.#?.#?.out's are found */
  67. BUNDLES = "OUTBOUND:"          /* bundles in here, temp sub-dirs    */
  68. QUEUE   = "outbound:flows/"    /* Welmats .FLOW files               */
  69. CONFIGS = "mail:"              /* jbundle.cfg                       */
  70.  
  71. Numeric digits 8
  72.  
  73. outbound = GetOutbound()       /* Makes sure your Outbound is set   */
  74. if (outbound="")then call SetOutbound(QUEUE)
  75. outbound = upper(GetOutbound())
  76.  
  77. say
  78. say "JBundle.rexx 4d.out -> Flow.Library Bundler 1.02"
  79. say "Updated Aug 6, 1992 by James McOrmond"
  80. say
  81. say "Working..."
  82.  
  83. myaddress.domain = "Fidonet"     /* Put YOUR address here */
  84. myaddress.zone = 1
  85. myaddress.net = 224
  86. myaddress.node = 140
  87. myaddress.point = 0
  88. call SetDefaultAddress(myaddress)
  89.  
  90. myaddress.pointnet = 30125
  91.  
  92. x=Open('cfgfile',CONFIGS||"jbundle.cfg",'R')
  93. if x=0 then DO
  94.   say "Error opening jbundle.cfg"
  95.   Exit 1
  96. END
  97.  
  98. i=0
  99.  
  100. DO forever
  101.   Line=Upper(strip(space(ReadLn('cfgfile'),1),'B'))
  102.  
  103.   if EOF('cfgfile') then Leave
  104.   if Left(Line,1)=";" then Iterate
  105.   if line="" then Iterate
  106.  
  107.   i=i+1
  108.   tonode.i.domain = "Fidonet"
  109.  
  110.   parse var Line fromnode.i.zone":"fromnode.i.net"/"fromnode.i.node"."fromnode.i.point" "tonode.i.zone":"tonode.i.net"/"tonode.i.node"."tonode.i.point" "tmp.1" "tmp.2
  111.  
  112.   TONODE.I.PRI = "0"
  113.   ARCHIVER.I = "lha -2 -u -P-5 m "
  114.   j = 0
  115.  
  116.   DO j = j + 1 UNTIL j = 2
  117.     if left(tmp.j, 2) = "AR" then ARCHIVER.I = "arc mw "
  118.     if left(tmp.j, 2) = "ZO" then ARCHIVER.I = "zoo aq:M "
  119.     if left(tmp.j, 2) = "ZI" then ARCHIVER.I = "zip -m -q -k -j -s "
  120.     if left(tmp.j, 2) = "LZ" then ARCHIVER.I = "lharc -u m "
  121.     if left(tmp.j, 3) = "NON" then ARCHIVER.I = "none"
  122.  
  123.     if left(tmp.j, 2) = "CR" then TONODE.I.PRI = DTPRI_CRASH
  124.     if left(tmp.j, 2) = "HO" then TONODE.I.PRI = DTPRI_HOLD
  125.     if left(tmp.j, 2) = "DI" then TONODE.I.PRI = DTPRI_DIRECT
  126.     if datatype(tmp.j) = "NUM" then TONODE.I.PRI = TMP.J
  127.  
  128.   END
  129.  
  130. END
  131. x=Close('cfgfile')
  132.  
  133. if EXISTS(BUNDLES||"temps") < 1 then Address Command 'makedir' BUNDLES||"temps"
  134. if EXISTS(BUNDLES||"none") < 1 then Address Command "makedir" BUNDLES||"none"
  135.  
  136. tonode.numnodes = i
  137.  
  138. DO anode = 1 until anode = tonode.numnodes
  139.  
  140.   pat = PACKETS||fromnode.anode.zone||"."||fromnode.anode.net||"."||fromnode.anode.node||"."||fromnode.anode.point||".out"
  141.   say
  142.   say "Pattern is" pat
  143.  
  144.   if archiver.anode = "none" then toname = "none"
  145.   else toname = tonode.anode.zone||"."||tonode.anode.net||"."||tonode.anode.node||"."||tonode.anode.point
  146.  
  147.   dirname = BUNDLES||"temps/"||toname
  148.   if EXISTS(dirname) < 1 then Address Command 'makedir 'dirname
  149.  
  150.   say "Routing to :" toname
  151.  
  152.   Options Failat 21
  153.   Address Command 'rename >nil:' pat dirname||"/ QUIET"
  154.   Options failat 10
  155.  
  156.   if archiver.anode = "none" then Iterate
  157.  
  158. /* By commenting the following section, the script slows down, but it has
  159.  * a side effect of cleaning up a bit.  If you would rather have the speed,
  160.  * just uncomment this next section.
  161.  */
  162.  
  163. /*  Options Failat 21
  164.  * Address Command 'delete' dirname
  165.  * if (RC=0) then Iterate
  166.  * Options Failat 10
  167.  */
  168.  
  169.   say "Priority   :" tonode.anode.pri
  170.  
  171.   i = 0
  172.   xbun = 0
  173.  
  174.   Address command 'list >t:jbun.tmp' BUNDLES||toname||".(MO?|TU?|WE?|TH?|FR?|SA?|SU?) quick nohead"
  175.   address command 'type t:jbun.tmp'
  176.  
  177.   x=Open('xbun','t:jbun.tmp', 'R')
  178.   if x=0 then DO
  179.     say "Error opening t:jbun.tmp"
  180.     exit 1
  181.     END
  182.   Line=upper(ReadLn('xbun'))
  183.  
  184.   If EOF('xbun') | Left(Line,1)=":" then DO
  185.     dayt = Date(w)
  186.     END
  187.   else do                           /* fixed minor bug :-( */
  188.     dayt=Right(Line,3)
  189.     i = right(line,1)
  190.     end
  191.  
  192.   x=Close('xbun')
  193.  
  194.   DO forever
  195.     bunname = upper(BUNDLES||TONAME||"."||LEFT(Left(dayt,2)||i,3))
  196.     address command 'testlock' bunname
  197.     if (RC ~= 1) then Leave
  198.     Say "Bumping I" i
  199.     i = i + 1
  200.     END
  201.  
  202.   say 'bunname' bunname
  203.  
  204.   if (EXISTS(bunname) & (word(StateF(bunname),2) < 5)) then Address Command 'delete' bunname
  205.  
  206.   work_detail = FindDetail(tonode.anode)
  207.  
  208.   call ScanDetail(work_detail, huge_list)
  209.  
  210.   if huge_list.numnodes > 0 then DO
  211.      DO i = 1 until i = huge_list.numnodes
  212.         if ((upper(huge_list.i.filename) ~= bunname) & (EXISTS(huge_list.i.filename))) then DO
  213.            detailnode=AddWorkName(work_detail,huge_list.i.filename,huge_list.i.asname,huge_list.i.flags)
  214.  
  215.            ChangeDetailPri(work_detail,detailnode,huge_list.i.pri)
  216.            END
  217.         END
  218.      END
  219.  
  220.    Options Failat 21
  221.    Address Command 'list >t:jbun.tmp' dirname||'/#?.(?UT|PKT) quick nohead'
  222.    Options Failat 10
  223.  
  224.    if ~Open('tmpfile','t:jbun.tmp', 'R') then Exit 1
  225.  
  226.    arcit = 0
  227.  
  228.    DO forever
  229.      Line=ReadLn('tmpfile')
  230.  
  231.      if EOF('tmpfile') then Leave
  232.  
  233.      clock = time('Normal')
  234.      magicnum = substr(date('Normal'),1,2) || substr(clock,1,2) || substr(clock,4,2) || substr(clock,7,2)
  235.  
  236.      Address Command 'rename' dirname||"/"||Line dirname||"/"magicnum||".pkt"
  237.      arcit = 1
  238.  
  239.      END
  240.    x=Close('tmpfile')
  241.  
  242.    if arcit then DO
  243.       Options Failat 21
  244.       Address Command "rename >nil: " bunname bundles||"tmparc."||left(archiver.anode,3)
  245.       lformat= '"'archiver.anode bundles||"tmparc."||left(archiver.anode,3) dirname||"/%s"'"'
  246.       Address Command "list >t:jbundle.tmp" dirname||"/#?.pkt quick lformat=" lformat
  247.       Address Command "type t:jbundle.tmp"
  248.       Address Command "execute t:jbundle.tmp"
  249.       Address Command "rename" bundles||"tmparc."||left(archiver.anode,3) bunname
  250.    END
  251.  
  252.    Options Failat 21
  253.    Address Command 'delete >nil:' dirname
  254.    Options Failat 10
  255.  
  256.    if EXISTS(bunname) then DO
  257.       say 'adding' bunname
  258.  
  259.       tonode.node = tonode.anode.node
  260.       tonode.net = tonode.anode.net
  261.  
  262.       if ((tonode.anode.node = myaddress.node) & (tonode.anode.net = myaddress.net)) then do
  263.          tonode.net = myaddress.pointnet
  264.          tonode.node = tonode.anode.point
  265.          end
  266.  
  267.       say "Packet Address" tonode.net||"/"||tonode.node
  268.  
  269.       asfile = UPPER(d2x(65536+myaddress.net-tonode.net,4) ,
  270.                ||d2x(65536+myaddress.node-tonode.node,4) ,
  271.                ||right(bunname,4))
  272.  
  273.       detailnode=AddWorkName(work_detail,bunname,asfile,DT_DELETE)
  274.       ChangeDetailPri(work_detail,detailnode,tonode.anode.pri)
  275.       END
  276.  
  277.    call DumpOutbound(outbound)
  278.    END
  279.  
  280. say
  281. Options Failat 21
  282. Address Command 'rename' PACKETS||"#?.(D|C|H)UT" BUNDLES||"temps/none/"
  283. Options Failat 10
  284. Address Command 'list >t:jbun.tmp' BUNDLES||"temps/none/#?.(?UT|PKT) QUICK NOHEAD"
  285.  
  286. if EXISTS(PACKETS||"pkts") < 1 then Address Command 'makedir' PACKETS||"pkts"
  287.  
  288. x=Open('none',"t:jbun.tmp",'R')
  289. if x=0 then Exit 1
  290.  
  291. do forever
  292.   Line = Upper(strip(space(ReadLn('none'),1),'B'))
  293.   if EOF('none') then Leave
  294.   if left(line,1) = ":" then Leave
  295.   Say "Processing" Line
  296.   node.pri = 1
  297.   node.domain = "FidoNet"
  298.   Parse var Line node.zone"."node.net"."node.node"."node.point"."junk
  299.   if Left(junk,1)= "C" then node.pri = DTPRI_CRASH+1
  300.   if Left(junk,1)= "H" then node.pri = DTPRI_HOLD+1
  301.   if Left(junk,1)= "D" then node.pri = DTPRI_DIRECT+1
  302.  
  303.   work_detail = FindDetail(node)
  304.   call ScanDetail(work_detail, huge_list)
  305.   if huge_list.numnodes > 0 then DO
  306.      Do i = 1 until i = huge_list.numnodes
  307.         if Exists(huge_list.i.filename) then DO
  308.            detailnode = AddworkName(work_detail,huge_list.i.filename,huge_list.i.asname,huge_list.i.flags)
  309.            changedetailpri(work_detail,detailnode,huge_list.i.pri)
  310.            END
  311.         END
  312.      END
  313.  
  314.   clock = time('Normal')
  315.   magicnum = substr(date('Normal'),1,2) || substr(clock,1,2) || substr(clock,4,2) || substr(clock,7,2)
  316.  
  317.   asfile = magicnum||".pkt"
  318.   Address Command 'rename' BUNDLES||"temps/none/"||Line PACKETS||"pkts/"||asfile
  319.   Address Command 'filenote' PACKETS||"pkts/"||asfile Line
  320.  
  321.   detailnode = AddWorkName(work_detail,PACKETS||"pkts/"||asfile,asfile, DT_DELETE)
  322.   changedetailpri(work_detail,detailnode,node.pri)
  323.   call DumpOutBound(outbound)
  324.   END
  325. x=Close('none')
  326.  
  327. /* Address Command 'delete >nil: t:jbun.tmp' */
  328.  
  329. say
  330. say 'JBundle Finished!'
  331. say
  332.  
  333. /* We're outa here! */
  334.  
  335. exit
  336.  
  337.