home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / telecomm / fido / pltmap14.lha / PlutMap.lst < prev    next >
Encoding:
File List  |  1994-11-16  |  27.8 KB  |  1,060 lines

  1. '
  2. ' PlutMap - Powerful .FLO/.DLO/.CLO/.HLO File remapper
  3. '
  4. ' (c) by Peter Deane (3:622/401)
  5. '
  6. ' Whilst this program is freely distributable it is still copyright!
  7. ' Acknowledgement MUST be given in the program documentation
  8. ' for any utilisation of parts of this code in other works.
  9. '
  10. ' It must **NEVER** be sold, or had profits made from it,
  11. ' unless prior agreement (in writing) has been arranged with
  12. ' the author.
  13. '
  14. '
  15. versnum$="$VER: PlutMap 1.4 "
  16. versnum$="1.4"
  17. versname$="PlutMap"
  18. versdate$="16-Nov-1994"
  19. '
  20. DIM m68%(15)
  21. MODE 1
  22. '
  23. OPEN "O",#1,"*",1
  24. '
  25. configfile$=UPPER$(TRIM$(_dosCmd$))
  26. @find.config
  27. '
  28. PRINT #1,""
  29. PRINT #1,versname$+" V"+versnum$+" ("+versdate$+")"
  30. PRINT #1,"(c) by Peter Deane (3:622/401@FidoNet)"
  31. RELSEEK #1,0
  32. '
  33. IF INSTR(configfile$,"?")<4 AND INSTR(configfile$,"?")>0
  34.   PRINT #1,""
  35.   PRINT #1," Usage: PlutMap [Configfilename]"
  36.   PRINT #1," (Configfilename defaults to MAIL:PlutMap.cfg)"
  37.   RELSEEK #1,-1
  38.   GOTO cleanup
  39. ENDIF
  40. '
  41. IF config$="XXX"
  42.   PRINT #1,""
  43.   PRINT #1," Error: No config file found!"
  44.   PRINT #1," Usage: PlutMap [Configfilename]"
  45.   PRINT #1," (Configfilename defaults to MAIL:PlutMap.cfg)"
  46.   RELSEEK #1,-1
  47.   GOTO cleanup
  48. ENDIF
  49. '
  50. '
  51. filecount%=0
  52. '
  53. FOR k%=1 TO numpairs%
  54.   '
  55.   @humanise(re.map%(k%,1),re.map%(k%,2),re.map%(k%,3),re.map%(k%,4))
  56.   horig$=human$
  57.   @humanise(re.map%(k%,5),re.map%(k%,6),re.map%(k%,7),re.map%(k%,8))
  58.   hdest$=human$
  59.   @trapise(re.map%(k%,1),re.map%(k%,2),re.map%(k%,3),re.map%(k%,4))
  60.   torig$=trap$
  61.   @trapise(re.map%(k%,5),re.map%(k%,6),re.map%(k%,7),re.map%(k%,8))
  62.   tdest$=trap$
  63.   '
  64.   PRINT #1,""
  65.   PRINT #1,"Pass # "+STR$(k%)+" of "+STR$(numpairs%)+" for "+horig$
  66.   RELSEEK #1,0
  67.   '
  68.   donesummat!=FALSE
  69.   '
  70.   FOR outtype%=1 TO 4
  71.     '
  72.     IF outtype%=1
  73.       appnet$=".OUT"
  74.       append$=".FLO"
  75.     ELSE IF outtype%=2
  76.       appnet$=".CUT"
  77.       append$=".CLO"
  78.     ELSE IF outtype%=3
  79.       appnet$=".DUT"
  80.       append$=".DLO"
  81.     ELSE IF outtype%=4
  82.       appnet$=".HUT"
  83.       append$=".HLO"
  84.     ENDIF
  85.     '
  86.     IF append$=".FLO" AND (re.map%(k%,1)=re.map%(k%,5)) AND (re.map%(k%,2)=re.map%(k%,6)) AND (re.map%(k%,3)=re.map%(k%,7)) AND (re.map%(k%,4)=re.map%(k%,8))
  87.       GOTO sameflo
  88.     ENDIF
  89.     '
  90.     PRINT #1,"checking for *"+append$+" file to "+horig$;
  91.     RELSEEK #1,0
  92.     '
  93.     IF EXIST(outbound$+torig$+append$)
  94.       '
  95.       donesummat!=TRUE
  96.       PRINT #1," exists!"
  97.       RELSEEK #1,0
  98.       OPEN "I",#11,outbound$+torig$+append$,2048
  99.       '
  100.       ' Only do something if orig .FLO file has size :-)
  101.       '
  102.       xx%=LOF(#11)
  103.       @log(log$,"R",torig$+append$+" found ("+STR$(xx%)+" bytes)")
  104.       '
  105.       IF xx%<=3
  106.         @log(log$,"R","Short *"+append$+" file - ignored")
  107.       ELSE
  108.         INC filecount%
  109.         '
  110.         IF EXIST(outbound$+tdest$+".FLO")
  111.           @log(log$,"R","Appending to file: "+outbound$+tdest$+".FLO")
  112.           PRINT #1,"  Appending to file "+outbound$+tdest$+".FLO"
  113.           RELSEEK #1,0
  114.           comflag!=FALSE
  115.           OPEN "A",#12,outbound$+tdest$+".FLO"
  116.         ELSE
  117.           @log(log$,"R","Creating new file: "+outbound$+tdest$+".FLO")
  118.           PRINT #1,"  Creating new file "+outbound$+tdest$+".FLO"
  119.           RELSEEK #1,0
  120.           comflag!=TRUE
  121.           OPEN "O",#12,outbound$+tdest$+".FLO"
  122.         ENDIF
  123.         '
  124.         @gimmetheday
  125.         arcfilename$=HEX$(TIMER,8)+".P"+daynum$
  126.         IF re.map$(k%,2)=""
  127.           arcfilename$=outbound$+arcfilename$
  128.         ELSE
  129.           arcfilename$=re.map$(k%,2)+arcfilename$
  130.         ENDIF
  131.         arcfloadd!=FALSE
  132.         '
  133.         DO
  134.           exsuc!=FALSE
  135.           LINE INPUT #11,xx$
  136.           '
  137.           IF LEN(xx$)>1
  138.             raw$=xx$
  139.             raw$=TRIM$(raw$)
  140.             xx.circ$=RIGHT$(xx$,LEN(xx$)-1)
  141.             @giveroot(xx.circ$)
  142.           ELSE
  143.             raw$=""
  144.           ENDIF
  145.           '
  146.           IF LEFT$(raw$,1)="#"
  147.             '
  148.             IF (hashmove!=TRUE) AND (re.map$(k%,2)<>"") AND (EXIST(xx.circ$)) AND (LEN(raw$)>2)
  149.               '
  150.               ex$="Copy >RAM:PlutMap.tmp "+xx.circ$+" to "+re.map$(k%,2)+justname$+" CLONE"
  151.               EXEC ex$,-1,-1
  152.               '
  153.               IF NOT EXIST("Ram:PlutMap.tmp")
  154.                 exsuc!=TRUE
  155.               ELSE
  156.                 exsuc!=TRUE
  157.                 OPEN "A",#63,"Ram:PlutMap.tmp"
  158.                 aa%=LOF(#63)
  159.                 SEEK #63,aa%
  160.                 PRINT #63,""
  161.                 CLOSE #63
  162.                 '
  163.                 OPEN "I",#62,"Ram:PlutMap.tmp"
  164.                 DO
  165.                   LINE INPUT #62,xx$
  166.                   xx$=UPPER$(xx$)
  167.                   RELSEEK #1,-1
  168.                   IF (INSTR(xx$,"FAIL")) OR (INSTR(xx$,"CAN'T OPEN")) OR (INSTR(xx$,"ARGUMENT MISSING")) OR (INSTR(xx$,"NOT MOUNTED")) OR (INSTR(xx$,"DESTINATION")) OR (INSTR(xx$,"INFINITE")) OR (INSTR(xx$,"ERROR"))
  169.                     exsuc!=FALSE
  170.                   ENDIF
  171.                 LOOP UNTIL EOF(#62)
  172.                 CLOSE #62
  173.                 '
  174.               ENDIF
  175.               '
  176.               IF EXIST("Ram:PlutMap.tmp")
  177.                 KILL "Ram:PlutMap.tmp"
  178.               ENDIF
  179.               '
  180.               IF exsuc!
  181.                 @log(log$,"R","Moved: "+justname$+" To dir: "+re.map$(k%,2))
  182.                 PRINT #1,"  Moved: "+justname$+" To dir: "+re.map$(k%,2)
  183.                 RELSEEK #1,-1
  184.                 '
  185.                 IF EXIST(xx.circ$)
  186.                   KILL xx.circ$
  187.                   ' for #-files, replace with a null file, rather than delete
  188.                   OPEN "O",#78,xx.circ$,16
  189.                   CLOSE #78
  190.                 ENDIF
  191.                 '
  192.                 PRINT #12,"#"+re.map$(k%,2)+justname$
  193.               ELSE
  194.                 @log(log$,"R","Error - Couldn't move: "+justname$+" To dir: "+re.map$(k%,2))
  195.                 PRINT #1,"  Error - Couldn't move: "+justname$+" To dir: "+re.map$(k%,2)
  196.                 RELSEEK #1,-1
  197.                 PRINT #12,raw$
  198.               ENDIF
  199.               '
  200.               '
  201.             ELSE
  202.               @log(log$,"R","Passed on: "+justname$+" For: "+horig$)
  203.               PRINT #1,"  Passed on: "+justname$+" For: "+horig$
  204.               RELSEEK #1,-1
  205.               PRINT #12,raw$
  206.             ENDIF
  207.             '
  208.             '
  209.           ELSE IF LEFT$(raw$,1)="-"
  210.             '
  211.             IF (minusmove!=TRUE) AND (re.map$(k%,2)<>"") AND (EXIST(xx.circ$)) AND (LEN(raw$)>2)
  212.               '
  213.               ex$="Copy >RAM:PlutMap.tmp "+xx.circ$+" to "+re.map$(k%,2)+justname$+" CLONE"
  214.               EXEC ex$,-1,-1
  215.               '
  216.               IF NOT EXIST("Ram:PlutMap.tmp")
  217.                 exsuc!=TRUE
  218.               ELSE
  219.                 exsuc!=TRUE
  220.                 OPEN "A",#63,"Ram:PlutMap.tmp"
  221.                 aa%=LOF(#63)
  222.                 SEEK #63,aa%
  223.                 PRINT #63,""
  224.                 CLOSE #63
  225.                 '
  226.                 OPEN "I",#62,"Ram:PlutMap.tmp"
  227.                 DO
  228.                   LINE INPUT #62,xx$
  229.                   xx$=UPPER$(xx$)
  230.                   IF (INSTR(xx$,"FAIL")) OR (INSTR(xx$,"CAN'T OPEN")) OR (INSTR(xx$,"ARGUMENT MISSING")) OR (INSTR(xx$,"NOT MOUNTED")) OR (INSTR(xx$,"DESTINATION")) OR (INSTR(xx$,"INFINITE")) OR (INSTR(xx$,"ERROR"))
  231.                     exsuc!=FALSE
  232.                   ENDIF
  233.                 LOOP UNTIL EOF(#62)
  234.                 CLOSE #62
  235.                 '
  236.                 '
  237.               ENDIF
  238.               '
  239.               IF EXIST("Ram:PlutMap.tmp")
  240.                 KILL "Ram:PlutMap.tmp"
  241.               ENDIF
  242.               '
  243.               IF exsuc!
  244.                 @log(log$,"R","Moved: "+justname$+" To dir: "+re.map$(k%,2))
  245.                 PRINT #1,"  Moved:  "+justname$+" To dir: "+re.map$(k%,2)
  246.                 RELSEEK #1,-1
  247.                 IF EXIST(xx.circ$)
  248.                   KILL xx.circ$
  249.                 ENDIF
  250.                 PRINT #12,"-"+re.map$(k%,2)+justname$
  251.               ELSE
  252.                 @log(log$,"R","Error - Couldn't move: "+justname$+" To dir: "+re.map$(k%,2))
  253.                 PRINT #1,"  Error - Couldn't move: "+justname$+" To dir: "+re.map$(k%,2)
  254.                 RELSEEK #1,-1
  255.                 PRINT #12,raw$
  256.               ENDIF
  257.               '
  258.               '
  259.             ELSE
  260.               @log(log$,"R","Passed on: "+justname$+" For: "+horig$)
  261.               PRINT #1,"  Passed on: "+justname$+" For: "+horig$
  262.               RELSEEK #1,-1
  263.               PRINT #12,raw$
  264.             ENDIF
  265.             '
  266.             '
  267.           ELSE IF LEFT$(raw$,1)="^"
  268.             '
  269.             IF (caretmove!=TRUE) AND (re.map$(k%,2)<>"") AND (EXIST(xx.circ$)) AND (LEN(raw$)>2)
  270.               '
  271.               ex$="Copy >RAM:PlutMap.tmp "+xx.circ$+" to "+re.map$(k%,2)+justname$+" CLONE"
  272.               EXEC ex$,-1,-1
  273.               '
  274.               IF NOT EXIST("Ram:PlutMap.tmp")
  275.                 exsuc!=TRUE
  276.               ELSE
  277.                 exsuc!=TRUE
  278.                 OPEN "A",#63,"Ram:PlutMap.tmp"
  279.                 aa%=LOF(#63)
  280.                 SEEK #63,aa%
  281.                 PRINT #63,""
  282.                 CLOSE #63
  283.                 '
  284.                 OPEN "I",#62,"Ram:PlutMap.tmp"
  285.                 DO
  286.                   LINE INPUT #62,xx$
  287.                   xx$=UPPER$(xx$)
  288.                   IF (INSTR(xx$,"FAIL")) OR (INSTR(xx$,"CAN'T OPEN")) OR (INSTR(xx$,"ARGUMENT MISSING")) OR (INSTR(xx$,"NOT MOUNTED")) OR (INSTR(xx$,"DESTINATION")) OR (INSTR(xx$,"INFINITE")) OR (INSTR(xx$,"ERROR"))
  289.                     exsuc!=FALSE
  290.                   ENDIF
  291.                 LOOP UNTIL EOF(#62)
  292.                 CLOSE #62
  293.                 '
  294.               ENDIF
  295.               '
  296.               IF EXIST("Ram:PlutMap.tmp")
  297.                 KILL "Ram:PlutMap.tmp"
  298.               ENDIF
  299.               '
  300.               IF exsuc!
  301.                 @log(log$,"R","Moved:  "+justname$+" To dir: "+re.map$(k%,2))
  302.                 PRINT #1,"  Moved: "+justname$+" To dir: "+re.map$(k%,2)
  303.                 RELSEEK #1,-1
  304.                 IF EXIST(xx.circ$)
  305.                   KILL xx.circ$
  306.                 ENDIF
  307.                 PRINT #12,"^"+re.map$(k%,2)+justname$
  308.               ELSE
  309.                 @log(log$,"R","Error - Couldn't move: "+justname$+" To dir: "+re.map$(k%,2))
  310.                 PRINT #1,"  Error - Couldn't move: "+justname$+" To dir: "+re.map$(k%,2)
  311.                 RELSEEK #1,-1
  312.                 PRINT #12,raw$
  313.               ENDIF
  314.               '
  315.               '
  316.             ELSE
  317.               @log(log$,"R","Passed on: "+justname$+" For: "+horig$)
  318.               PRINT #1,"  Passed on: "+justname$+" For: "+horig$
  319.               RELSEEK #1,-1
  320.               PRINT #12,raw$
  321.             ENDIF
  322.             '
  323.           ELSE IF LEFT$(raw$,1)="~"
  324.             '
  325.             IF (tildemove!=TRUE) AND (re.map$(k%,2)<>"") AND (EXIST(xx.circ$)) AND (LEN(raw$)>2)
  326.               '
  327.               ex$="Copy >RAM:PlutMap.tmp "+xx.circ$+" to "+re.map$(k%,2)+justname$+" CLONE"
  328.               EXEC ex$,-1,-1
  329.               '
  330.               IF NOT EXIST("Ram:PlutMap.tmp")
  331.                 exsuc!=TRUE
  332.               ELSE
  333.                 exsuc!=TRUE
  334.                 OPEN "A",#63,"Ram:PlutMap.tmp"
  335.                 aa%=LOF(#63)
  336.                 SEEK #63,aa%
  337.                 PRINT #63,""
  338.                 CLOSE #63
  339.                 '
  340.                 OPEN "I",#62,"Ram:PlutMap.tmp"
  341.                 DO
  342.                   LINE INPUT #62,xx$
  343.                   xx$=UPPER$(xx$)
  344.                   IF (INSTR(xx$,"FAIL")) OR (INSTR(xx$,"CAN'T OPEN")) OR (INSTR(xx$,"ARGUMENT MISSING")) OR (INSTR(xx$,"NOT MOUNTED")) OR (INSTR(xx$,"DESTINATION")) OR (INSTR(xx$,"INFINITE")) OR (INSTR(xx$,"ERROR"))
  345.                     exsuc!=FALSE
  346.                   ENDIF
  347.                 LOOP UNTIL EOF(#62)
  348.                 CLOSE #62
  349.                 '
  350.               ENDIF
  351.               '
  352.               IF EXIST("Ram:PlutMap.tmp")
  353.                 KILL "Ram:PlutMap.tmp"
  354.               ENDIF
  355.               '
  356.               IF exsuc!
  357.                 @log(log$,"R","Moved: "+justname$+" To dir: "+re.map$(k%,2))
  358.                 PRINT #1,"  Moved: "+justname$+" To dir: "+re.map$(k%,2)
  359.                 RELSEEK #1,-1
  360.                 IF EXIST(xx.circ$)
  361.                   KILL xx.circ$
  362.                 ENDIF
  363.                 PRINT #12,"~"+re.map$(k%,2)+justname$
  364.               ELSE
  365.                 @log(log$,"R","Error - Couldn't move: "+justname$+" To dir: "+re.map$(k%,2))
  366.                 PRINT #1,"  Error - Couldn't move: "+justname$+" To dir: "+re.map$(k%,2)
  367.                 RELSEEK #1,-1
  368.                 PRINT #12,raw$
  369.               ENDIF
  370.               '
  371.             ELSE
  372.               @log(log$,"R","Passed on: "+justname$+" For: "+horig$)
  373.               PRINT #1,"  Passed on: "+justname$+" For: "+horig$
  374.               RELSEEK #1,-1
  375.               PRINT #12,raw$
  376.             ENDIF
  377.             '
  378.           ELSE IF (re.map$(k%,1)="P") AND (EXIST(raw$)) AND (LEN(raw$)>2)
  379.             '
  380.             ex$=packcmd$+" "+arcfilename$+" "+raw$
  381.             @log(log$,"R","Executing: "+ex$)
  382.             PRINT #1,"Archiving "+justname$+" for "+horig$
  383.             RELSEEK #1,-1
  384.             '
  385.             EXEC ex$,-1,-1
  386.             '
  387.             IF NOT EXIST("Ram:PlutMap.tmp")
  388.               exsuc!=TRUE
  389.             ELSE
  390.               exsuc!=TRUE
  391.               OPEN "A",#63,"Ram:PlutMap.tmp"
  392.               aa%=LOF(#63)
  393.               SEEK #63,aa%
  394.               PRINT #63,""
  395.               CLOSE #63
  396.               '
  397.               OPEN "I",#62,"Ram:PlutMap.tmp"
  398.               DO
  399.                 LINE INPUT #62,xx$
  400.                 xx$=UPPER$(xx$)
  401.                 IF (INSTR(xx$,"FAIL")) OR (INSTR(xx$,"CAN'T OPEN")) OR (INSTR(xx$,"ARGUMENT MISSING")) OR (INSTR(xx$,"NOT MOUNTED")) OR (INSTR(xx$,"INFINITE")) OR (INSTR(xx$,"ERROR"))
  402.                   exsuc!=FALSE
  403.                 ENDIF
  404.               LOOP UNTIL EOF(#62)
  405.               CLOSE #62
  406.             ENDIF
  407.             '
  408.             IF exsuc!=FALSE
  409.               @log(log$,"R","Archiving to "+arcfilename$+" Failed!")
  410.               PRINT #1,"Archiving to "+arcfilename$+" Failed!"
  411.               RELSEEK #1,-1
  412.               @log(log$,"R","Passed on: "+raw$+" For: "+horig$)
  413.               PRINT #1,"  Passed on: "+raw$+" For: "+horig$
  414.               RELSEEK #1,-1
  415.               PRINT #12,raw$
  416.             ELSE
  417.               PRINT #1,"Archiving to "+arcfilename$+" all okay"
  418.               RELSEEK #1,-1
  419.               IF arcfloadd!=FALSE
  420.                 PRINT #12,"-"+arcfilename$
  421.                 arcfloadd!=TRUE
  422.               ENDIF
  423.               @log(log$,"R","Added: "+justname$+" to "+arcfile$+" For: "+horig$)
  424.               '
  425.               koff!=TRUE
  426.               FOR zq%=1 TO numnodelete%
  427.                 IF INSTR(UPPER$(raw$),no.kill$(zq%))>0
  428.                   koff!=FALSE
  429.                 ENDIF
  430.               NEXT zq%
  431.               '
  432.               IF koff!
  433.                 IF EXIST(raw$)
  434.                   KILL raw$
  435.                 ENDIF
  436.                 @log(log$,"R","Deleted "+raw$)
  437.                 PRINT #1,"Deleted "+raw$
  438.                 RELSEEK #1,-1
  439.               ELSE
  440.                 @log(log$,"R",raw$+" not deleted (overridden from cfg)")
  441.                 PRINT #1,raw$+" not deleted (overridden from cfg)"
  442.                 RELSEEK #1,-1
  443.               ENDIF
  444.               '
  445.             ENDIF
  446.             '
  447.             IF EXIST("Ram:PlutMap.tmp")
  448.               KILL "Ram:PlutMap.tmp"
  449.             ENDIF
  450.             '
  451.           ELSE
  452.             '
  453.             IF (LEN(re.map$(k%,2))>2) AND EXIST(raw$) AND (LEN(raw$)>2)
  454.               '
  455.               ex$="Copy >RAM:PlutMap.tmp "+raw$+" to "+re.map$(k%,2)+justname$+" CLONE"
  456.               EXEC ex$,-1,-1
  457.               '
  458.               IF NOT EXIST("Ram:PlutMap.tmp")
  459.                 exsuc!=TRUE
  460.               ELSE
  461.                 exsuc!=TRUE
  462.                 OPEN "A",#63,"Ram:PlutMap.tmp"
  463.                 aa%=LOF(#63)
  464.                 SEEK #63,aa%
  465.                 PRINT #63,""
  466.                 CLOSE #63
  467.                 '
  468.                 OPEN "I",#62,"Ram:PlutMap.tmp"
  469.                 DO
  470.                   LINE INPUT #62,xx$
  471.                   xx$=UPPER$(xx$)
  472.                   IF (INSTR(xx$,"FAIL")) OR (INSTR(xx$,"CAN'T OPEN")) OR (INSTR(xx$,"ARGUMENT MISSING")) OR (INSTR(xx$,"NOT MOUNTED")) OR (INSTR(xx$,"DESTINATION")) OR (INSTR(xx$,"INFINITE")) OR (INSTR(xx$,"ERROR"))
  473.                     exsuc!=FALSE
  474.                   ENDIF
  475.                 LOOP UNTIL EOF(#62)
  476.                 CLOSE #62
  477.                 '
  478.               ENDIF
  479.               '
  480.               IF EXIST("Ram:PlutMap.tmp")
  481.                 KILL "Ram:PlutMap.tmp"
  482.               ENDIF
  483.               '
  484.               IF exsuc!
  485.                 @log(log$,"R","Moved: "+justname$+" To dir: "+re.map$(k%,2))
  486.                 PRINT #1,"  Moved: "+justname$+" To dir: "+re.map$(k%,2)
  487.                 RELSEEK #1,-1
  488.                 IF EXIST(raw$)
  489.                   KILL raw$
  490.                 ENDIF
  491.                 PRINT #12,re.map$(k%,1)+re.map$(k%,2)+justname$
  492.               ELSE
  493.                 @log(log$,"R","Error - Couldn't move: "+justname$+" To dir: "+re.map$(k%,2))
  494.                 PRINT #1,"  Error - Couldn't move: "+justname$+" To dir: "+re.map$(k%,2)
  495.                 RELSEEK #1,-1
  496.                 PRINT #12,raw$
  497.               ENDIF
  498.               '
  499.             ELSE
  500.               @log(log$,"R","Passed on: "+justname$+" For: "+horig$)
  501.               PRINT #1,"  Passed on: "+justname$+" For: "+horig$
  502.               RELSEEK #1,-1
  503.               PRINT #12,raw$
  504.             ENDIF
  505.             '
  506.             '
  507.             '
  508.           ENDIF
  509.         LOOP UNTIL EOF(#11)
  510.         CLOSE #12
  511.         '
  512.         ' Does the .FLO file we made need a comment?
  513.         '
  514.         IF comflag!
  515.           xx$=outbound$+tdest$+".FLO"+CHR$(0)
  516.           xc$="To "+hdest$+"; "+CHR$(0)
  517.           '
  518.           ~SetComment(V:xx$,V:xc$)
  519.           '
  520.         ENDIF
  521.         '
  522.       ENDIF
  523.       CLOSE #11
  524.       KILL outbound$+torig$+append$
  525.       '
  526.       '
  527.     ELSE
  528.       PRINT #1," not today!"+CHR$(10)+CHR$(27)+"[A"+CHR$(27)+"[K";
  529.       RELSEEK #1,0
  530.     ENDIF
  531.     '
  532.     sameflo:
  533.     '
  534.     '  Add in check for mail .PKTS here later on
  535.     '
  536.     '
  537.   NEXT outtype%
  538.   IF donesummat!=FALSE
  539.     PRINT #1,CHR$(10)+CHR$(27)+"[2A"+CHR$(27)+"[K"+CHR$(27)+"[A";
  540.     RELSEEK #1,0
  541.   ENDIF
  542. NEXT k%
  543. '
  544. @log(log$,"R",STR$(filecount%)+" input file(s) dealt with")
  545. IF filecount%=0
  546.   PRINT #1,"NO input files remapped."
  547. ELSE IF filecount%=1
  548.   PRINT #1,STR$(filecount%)+" input file remapped."
  549. ELSE
  550.   PRINT #1,STR$(filecount%)+" input files remapped."
  551. ENDIF
  552. @log(log$,"R",versname$+" V"+versnum$+" closed")
  553. '
  554. cleanup:
  555. '
  556. PRINT #1,versname$+" terminated at "+TIME$
  557. CLOSE #1
  558. END
  559. '
  560. PROCEDURE giveroot(bigname$)
  561.   '
  562.   '  Give filename only given a full filespec.
  563.   '
  564.   LOCAL xy%,xz%
  565.   '
  566.   xf$=TRIM$(bigname$)
  567.   '
  568.   xy%=RINSTR(xf$,":")
  569.   xz%=RINSTR(xf$,"/")
  570.   '
  571.   IF xy%+xz%=0
  572.     ' xf$ is fine as is.
  573.   ENDIF
  574.   '
  575.   IF (xy%>0) AND (xz%=0)
  576.     xf$=MID$(xf$,xy%+1,255)
  577.   ENDIF
  578.   '
  579.   IF (xz%>0) AND (xy%=0)
  580.     xf$=MID$(xf$,xz%+1,255)
  581.   ENDIF
  582.   '
  583.   IF (xz%>0) AND (xy%>0)
  584.     xf$=MID$(xf$,xz%+1,255)
  585.   ENDIF
  586.   '
  587.   justname$=xf$
  588.   '
  589. RETURN
  590. '
  591. PROCEDURE log(log$,lprefix$,entry$)
  592.   '
  593.   ' creates a Trapdoor-style log entry
  594.   ' Inputs:
  595.   '        log$  (filename of the log)
  596.   '      prefix$ (one character at the start)
  597.   '      entry$  (text to add)
  598.   '
  599.   IF EXIST(log$)
  600.     OPEN "A",#54,log$,4096
  601.   ELSE
  602.     OPEN "O",#54,log$,4096
  603.   ENDIF
  604.   '
  605.   PRINT #54,lprefix$;" ";
  606.   @dateconv(DATE$)
  607.   PRINT #54,pd.date$;" ";
  608.   PRINT #54,TIME$;"  ";
  609.   IF LEN(entry$)<=58
  610.     PRINT #54,entry$
  611.   ELSE
  612.     aa%=RINSTR(entry$," ",58)
  613.     IF aa%=0
  614.       PRINT #54,LEFT$(entry$,58)
  615.       PRINT #54,SPACE$(24);RIGHT$(entry$,LEN(entry$)-58)
  616.     ELSE
  617.       PRINT #54,LEFT$(entry$,aa%)
  618.       PRINT #54,SPACE$(24);RIGHT$(entry$,LEN(entry$)-aa%)
  619.     ENDIF
  620.   ENDIF
  621.   CLOSE #54
  622. RETURN
  623. '
  624. '
  625. PROCEDURE dateconv(pddt$)
  626.   '
  627.   ' converts date to Fido style DD Mmm YY
  628.   ' string to use in program is pd.date$
  629.   ' pd.date$ is always of the form DD Mmm YY (ie 9 chars long)
  630.   '
  631.   LOCAL pd.temp$,pd.date1$,pd.date2$,pd.date3$,pd.month%,pd.month$
  632.   '
  633.   pd.date1$=LEFT$(pddt$,2)
  634.   pd.date2$=MID$(pddt$,4,2)
  635.   pd.date3$=RIGHT$(pddt$,2)
  636.   pd.month%=VAL(pddt$)
  637.   '
  638.   SELECT pd.month%
  639.     '
  640.   CASE 1
  641.     pd.month$="Jan"
  642.   CASE 2
  643.     pd.month$="Feb"
  644.   CASE 3
  645.     pd.month$="Mar"
  646.   CASE 4
  647.     pd.month$="Apr"
  648.   CASE 5
  649.     pd.month$="May"
  650.   CASE 6
  651.     pd.month$="Jun"
  652.   CASE 7
  653.     pd.month$="Jul"
  654.   CASE 8
  655.     pd.month$="Aug"
  656.   CASE 9
  657.     pd.month$="Sep"
  658.   CASE 10
  659.     pd.month$="Oct"
  660.   CASE 11
  661.     pd.month$="Nov"
  662.   CASE 12
  663.     pd.month$="Dec"
  664.   DEFAULT
  665.     pd.month$="???"
  666.   ENDSELECT
  667.   pd.date$=pd.date2$+" "+pd.month$+" "+pd.date3$
  668.   '
  669. RETURN
  670. '
  671. '
  672. PROCEDURE convfqfa(enterednode$)
  673.   '
  674.   convnode$=enterednode$+CHR$(0)
  675.   convprob!=FALSE
  676.   addr%=0
  677.   defaddr%=0
  678.   '
  679.   nodelistlib$="traplist.library"+CHR$(0)
  680.   nodelistbase%=OpenLibrary(V:nodelistlib$,0)
  681.   '
  682.   IF nodelistbase%=0
  683.     convprob!=TRUE
  684.     PRINT #1,""
  685.     PRINT #1,"ERROR: traplist.library couldn't be opened."
  686.     PRINT #1,"Using 0:0/0.0 as node number."
  687.     PRINT #1,""
  688.     RELSEEK #1,0
  689.     zone&=0
  690.     net&=0
  691.     node&=0
  692.     point&=0
  693.   ELSE
  694.     '
  695.     addr%=AllocMem(8,65536)
  696.     defaddr%=AllocMem(8,65536)
  697.     '
  698.     DPOKE defaddr%+0,0
  699.     DPOKE defaddr%+2,0
  700.     DPOKE defaddr%+4,0
  701.     DPOKE defaddr%+6,0
  702.     '
  703.     ' parse the input into addr% via the library.
  704.     '
  705.     nlparseaddr(addr%,V:convnode$,defaddr%)
  706.     '
  707.     IF m68%(0)=0
  708.       zone&=DPEEK(addr%+0)
  709.       net&=DPEEK(addr%+2)
  710.       node&=DPEEK(addr%+4)
  711.       point&=DPEEK(addr%+6)
  712.     ELSE
  713.       PRINT #1,""
  714.       PRINT #1,"ERROR: Invalid node # in config."
  715.       PRINT #1,"Using 0:0/0.0 as node number."
  716.       PRINT #1,""
  717.       RELSEEK #1,0
  718.       convprob!=TRUE
  719.       zone&=0
  720.       net&=0
  721.       node&=0
  722.       point&=0
  723.     ENDIF
  724.   ENDIF
  725.   '
  726.   IF addr%
  727.     ~FreeMem(addr%,8)
  728.   ENDIF
  729.   '
  730.   IF defaddr%
  731.     ~FreeMem(defaddr%,8)
  732.   ENDIF
  733.   '
  734.   IF nodelistbase%
  735.     ~CloseLibrary(nodelistbase%)
  736.   ENDIF
  737.   '
  738. RETURN
  739. '
  740. '
  741. PROCEDURE nlparseaddr(addr%,str%,default%)
  742.   m68%(8)=addr%
  743.   m68%(9)=str%
  744.   m68%(10)=default%
  745.   m68%(14)=nodelistbase%
  746.   RCALL nodelistbase%-156,m68%()
  747. RETURN
  748. '
  749. '
  750. PROCEDURE humanise(zo%,ne%,no%,po%)
  751.   human$=STR$(zo%)+":"+STR$(ne%)+"/"+STR$(no%)+"."+STR$(po%)
  752. RETURN
  753. '
  754. PROCEDURE trapise(zo%,ne%,no%,po%)
  755.   trap$=STR$(zo%)+"."+STR$(ne%)+"."+STR$(no%)+"."+STR$(po%)
  756. RETURN
  757. '
  758. PROCEDURE gimmetheday
  759.   '
  760.   dt$=DATE$
  761.   '
  762.   date.1$=LEFT$(dt$,2)
  763.   date.2$=MID$(dt$,4,2)
  764.   date.3$=RIGHT$(dt$,4)
  765.   '
  766.   day%=VAL(date.1$)
  767.   month%=VAL(date.2$)
  768.   year%=VAL(date.3$)
  769.   '
  770.   xx%=year% MOD 4
  771.   '
  772.   IF xx%=0
  773.     leapadd!=TRUE
  774.   ELSE
  775.     leapadd!=FALSE
  776.   ENDIF
  777.   '
  778.   SELECT month%
  779.     '
  780.   CASE 1
  781.     daynum%=day%+0
  782.     leapadd!=FALSE
  783.   CASE 2
  784.     daynum%=day%+31
  785.     leapadd!=FALSE
  786.   CASE 3
  787.     daynum%=day%+59
  788.   CASE 4
  789.     daynum%=day%+90
  790.   CASE 5
  791.     daynum%=day%+120
  792.   CASE 6
  793.     daynum%=day%+151
  794.   CASE 7
  795.     daynum%=day%+181
  796.   CASE 8
  797.     daynum%=day%+212
  798.   CASE 9
  799.     daynum%=day%+243
  800.   CASE 10
  801.     daynum%=day%+273
  802.   CASE 11
  803.     daynum%=day%+304
  804.   CASE 12
  805.     daynum%=day%+334
  806.   DEFAULT
  807.     daynum%=day%+0
  808.   ENDSELECT
  809.   '
  810.   IF leapadd!
  811.     INC daynum%
  812.   ENDIF
  813.   '
  814.   xd$=STR$(daynum%)
  815.   IF LEN(xd$)=1
  816.     daynum$="0"+xd$
  817.   ELSE IF LEN(xd$)=2
  818.     daynum$=xd$
  819.   ELSE
  820.     daynum$=RIGHT$(xd$,2)
  821.   ENDIF
  822.   '
  823. RETURN
  824. '
  825. '
  826. PROCEDURE find.config
  827.   '
  828.   IF (configfile$="") AND (EXIST("MAIL:PlutMap.cfg"))
  829.     config$="MAIL:PlutMap.cfg"
  830.   ELSE IF (configfile$<>"") AND (EXIST(configfile$))
  831.     config$=configfile$
  832.   ELSE IF EXIST("PlutMap.cfg")
  833.     config$="PlutMap.cfg"
  834.   ELSE
  835.     config$="XXX"
  836.   ENDIF
  837.   '
  838.   ' Defaults
  839.   '
  840.   log$="Mail:PlutMap.log"
  841.   inbound$="Mail:Inbound/"
  842.   outbound$="Mail:Outbound/"
  843.   numpairs%=0
  844.   numnodelete%=0
  845.   hashmove!=FALSE
  846.   caretmove!=TRUE
  847.   minusmove!=TRUE
  848.   tildemove!=FALSE
  849.   destdir$="Mail:"
  850.   '
  851.   '
  852.   IF config$<>"XXX"
  853.     '
  854.     OPEN "I",#2,config$,128
  855.     configerr!=FALSE
  856.     DO
  857.       '
  858.       LINE INPUT #2,xx$
  859.       '
  860.       xx$=TRIM$(xx$)
  861.       xxu$=UPPER$(xx$)
  862.       '
  863.       IF xxu$="" OR LEFT$(xxu$,1)=";"
  864.         ' Do nothing
  865.       ELSE IF LEFT$(xxu$,5)="REMAP"
  866.         INC numpairs%
  867.       ELSE IF LEFT$(xxu$,6)="NOKILL"
  868.         INC numnodelete%
  869.       ELSE IF LEFT$(xxu$,7)="INBOUND"
  870.         xx$=RIGHT$(xx$,LEN(xx$)-7)
  871.         xx$=TRIM$(xx$)
  872.         inbound$=xx$
  873.         IF RIGHT$(inbound$,1)<>"/" AND RIGHT$(inbound$,1)<>":"
  874.           inbound$=inbound$+"/"
  875.         ENDIF
  876.       ELSE IF LEFT$(xxu$,8)="OUTBOUND"
  877.         xx$=RIGHT$(xx$,LEN(xx$)-8)
  878.         xx$=TRIM$(xx$)
  879.         outbound$=xx$
  880.         IF RIGHT$(outbound$,1)<>"/" AND RIGHT$(outbound$,1)<>":"
  881.           outbound$=outbound$+"/"
  882.         ENDIF
  883.       ELSE IF LEFT$(xxu$,11)="PACKCOMMAND"
  884.         xx$=RIGHT$(xx$,LEN(xx$)-11)
  885.         xx$=TRIM$(xx$)
  886.         packcmd$=xx$
  887.       ELSE IF LEFT$(xxu$,7)="LOGFILE"
  888.         xx$=RIGHT$(xx$,LEN(xx$)-7)
  889.         xx$=TRIM$(xx$)
  890.         log$=xx$
  891.       ELSE IF LEFT$(xxu$,8)="HASHMOVE"
  892.         hashmove!=TRUE
  893.       ELSE IF LEFT$(xxu$,9)="CARETMOVE"
  894.         caretmove!=TRUE
  895.       ELSE IF LEFT$(xxu$,9)="MINUSMOVE"
  896.         minusmove!=TRUE
  897.       ELSE IF LEFT$(xxu$,9)="TILDEMOVE"
  898.         tildemove!=TRUE
  899.         '
  900.       ELSE IF LEFT$(xxu$,10)="NOHASHMOVE"
  901.         hashmove!=FALSE
  902.       ELSE IF LEFT$(xxu$,11)="NOCARETMOVE"
  903.         caretmove!=FALSE
  904.       ELSE IF LEFT$(xxu$,11)="NOMINUSMOVE"
  905.         minusmove!=FALSE
  906.       ELSE IF LEFT$(xxu$,11)="NOTILDEMOVE"
  907.         tildemove!=FALSE
  908.         '
  909.       ENDIF
  910.       '
  911.     LOOP UNTIL EOF(#2)
  912.     CLOSE #2
  913.     '
  914.     DIM re.map$(numpairs%+1,2)
  915.     DIM re.map%(numpairs%+1,8)
  916.     DIM no.kill$(numnodelete%+1)
  917.     '
  918.     jj%=0
  919.     kk%=0
  920.     '
  921.     '
  922.     @log(log$,CHR$(10)+"R",versname$+" V"+versnum$+" opened")
  923.     '
  924.     OPEN "I",#2,config$,128
  925.     configerr!=FALSE
  926.     DO
  927.       '
  928.       LINE INPUT #2,xx$
  929.       '
  930.       xx$=TRIM$(xx$)
  931.       xxu$=UPPER$(xx$)
  932.       '
  933.       IF LEFT$(xxu$,6)="NOKILL"
  934.         xx$=RIGHT$(xxu$,LEN(xxu$)-6)
  935.         xx$=TRIM$(xx$)
  936.         '
  937.         IF LEN(xx$)>2
  938.           INC kk%
  939.         ENDIF
  940.         '
  941.         no.kill$(kk%)=xx$
  942.         '
  943.       ELSE IF LEFT$(xxu$,5)="REMAP"
  944.         xx$=RIGHT$(xx$,LEN(xx$)-5)
  945.         xx$=TRIM$(xx$)
  946.         '
  947.         aa%=0
  948.         bb%=0
  949.         '
  950.         aa%=INSTR(xx$," ",0)
  951.         IF aa%=0
  952.           GOTO confgetskip
  953.         ENDIF
  954.         '
  955.         firstnode$=LEFT$(xx$,aa%)
  956.         firstnode$=TRIM$(firstnode$)
  957.         whatsleft$=RIGHT$(xx$,LEN(xx$)-aa%)
  958.         whatsleft$=TRIM$(whatsleft$)
  959.         '
  960.         bb%=INSTR(whatsleft$," ")
  961.         IF bb%=0
  962.           secondnode$=TRIM$(whatsleft$)
  963.           prefix$=""
  964.           destdir$=""
  965.           GOTO getnomore
  966.         ELSE
  967.           secondnode$=LEFT$(whatsleft$,bb%)
  968.           secondnode$=TRIM$(secondnode$)
  969.         ENDIF
  970.         whatsleft$=RIGHT$(whatsleft$,LEN(whatsleft$)-bb%)
  971.         whatsleft$=TRIM$(whatsleft$)
  972.         '
  973.         cc%=INSTR(whatsleft$," ")
  974.         IF cc%=0
  975.           arg3$=TRIM$(whatsleft$)
  976.           arg4$=""
  977.         ELSE
  978.           arg3$=LEFT$(whatsleft$,cc%)
  979.           arg3$=TRIM$(arg3$)
  980.           arg4$=RIGHT$(whatsleft$,LEN(whatsleft$)-cc%)
  981.           arg4$=TRIM$(arg4$)
  982.         ENDIF
  983.         '
  984.         ' Now, there are four possibilities:
  985.         '
  986.         IF (arg4$="") AND (LEN(arg3$)=1)
  987.           prefix$=arg3$
  988.           destdir$=""
  989.         ELSE IF (arg4$="") AND (LEN(arg3$)>1)
  990.           prefix$=""
  991.           destdir$=arg3$
  992.         ELSE IF LEN(arg3$)=1
  993.           prefix$=arg3$
  994.           destdir$=arg4$
  995.         ELSE IF LEN(arg4$)=1
  996.           prefix$=arg4$
  997.           destdir$=arg3$
  998.           '
  999.           ' Allow an escape route, just in case!
  1000.           '
  1001.         ELSE
  1002.           prefix$=arg3$
  1003.           destdir$=arg4$
  1004.         ENDIF
  1005.         '
  1006.         '
  1007.         IF LEN(destdir$)>1
  1008.           IF RIGHT$(destdir$,1)<>"/" AND RIGHT$(destdir$,1)<>":"
  1009.             destdir$=destdir$+"/"
  1010.           ENDIF
  1011.         ENDIF
  1012.         '
  1013.         IF LEN(prefix$)>1
  1014.           prefix$=LEFT$(prefix$,1)
  1015.         ENDIF
  1016.         '
  1017.         getnomore:
  1018.         INC jj%
  1019.         '
  1020.         re.map$(jj%,1)=prefix$
  1021.         re.map$(jj%,2)=destdir$
  1022.         '
  1023.         @convfqfa(firstnode$)
  1024.         re.map%(jj%,1)=zone&
  1025.         re.map%(jj%,2)=net&
  1026.         re.map%(jj%,3)=node&
  1027.         re.map%(jj%,4)=point&
  1028.         checkone%=zone&+net&+node&+point&
  1029.         '
  1030.         @convfqfa(secondnode$)
  1031.         re.map%(jj%,5)=zone&
  1032.         re.map%(jj%,6)=net&
  1033.         re.map%(jj%,7)=node&
  1034.         re.map%(jj%,8)=point&
  1035.         checktwo%=zone&+net&+node&+point&
  1036.         '
  1037.         ' If sending/receiving to 0:0/0.0, disregard line
  1038.         '
  1039.         IF checkone%=0 OR checktwo%=0
  1040.           DEC jj%
  1041.         ENDIF
  1042.         '
  1043.         '
  1044.       ENDIF
  1045.       '
  1046.       confgetskip:
  1047.     LOOP UNTIL EOF(#2)
  1048.     CLOSE #2
  1049.     '
  1050.     ' Remove any dodgy lines from numpairs% var
  1051.     '
  1052.     numpairs%=jj%
  1053.     numnodelete%=kk%
  1054.     '
  1055.   ENDIF
  1056.   '
  1057. RETURN
  1058. '
  1059. '
  1060.