home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD1.iso / Fax / AVMN199D.LHA / avminstall / rexx / moveto.avm < prev    next >
Encoding:
Text File  |  1995-08-19  |  6.8 KB  |  258 lines

  1. /* TITLE: avm:rexx/moveto.avm */
  2. parse upper arg mailbox2 stuff
  3. numlogs = words(stuff) / 2
  4. do i = 1 to numlogs; mailbox = word(stuff, (i - 1) * 2 + 1); logname = word(stuff, (i - 1) * 2 + 2)
  5.     call loadLogEntry(mailbox, logname)
  6.         /* copy log itself */
  7.     address command 'copy >nil: <nil: quiet' logFile(mailbox, logname) || "#?" logFile(mailbox2, '')
  8.         /* copy filenames referenced if they aren't absolute filenames */
  9.     if (log.fileName ~= "" & (verify(log.fileName, '/:', 'M') = 0)) then 
  10.         address command 'copy >nil: <nil: quiet' voiceFile(mailbox, log.fileName) || "#?" voiceFile(mailbox2, '')
  11.  
  12.     if (log.altFileName ~= "" & (verify(log.altFileName, '/:', 'M') = 0)) then
  13.         address command 'copy >nil: <nil: quiet' voiceFile(mailbox, log.altFileName) || "#?" voiceFile(mailbox2, '')
  14.     address rexx 'broadcast' 'addtomailbox' mailbox2 logname
  15. end
  16. /* delete logs from original place */
  17. address rexx 'delete' stuff
  18. exit
  19.  
  20. error:
  21. exit
  22.  
  23. exit
  24.  
  25. mailboxDir: procedure
  26.     parse arg mailbox
  27.  
  28.     return 'avmmbox:' || mailbox || '/'
  29.  
  30. logFile: procedure
  31.     parse arg mailbox, magiccookie
  32.  
  33.     return 'avmmbox:' || mailbox || '/logs/' || magiccookie
  34.  
  35. voiceFile: procedure
  36.     parse arg mailbox, magiccookie
  37.  
  38.         if (verify(magiccookie, '/:', 'M') = 0) then
  39.           return 'avmmbox:' || mailbox || '/voices/' || magiccookie
  40.         else
  41.           return magiccookie
  42.  
  43. makeUniqueFile: procedure
  44.     if arg() ~= 0 then do
  45.         rc = "makeUniqueFile: bad args"
  46.         signal error
  47.     end
  48.     return address() || '.' || date('i') || '.' || time('s') || '.' || random(1, 999, time('s'))
  49.  
  50. convertToDate: procedure
  51.     if arg() ~= 1 then do
  52.         rc = "convertToDate: bad args"
  53.         signal error
  54.     end
  55.     parse arg timeInC
  56.  
  57.     actualTime = (timeInC - (2922)*86400) // (86400)
  58.     actualDate = (timeInC - actualTime - 2922*86400) % 86400
  59.  
  60.     return actualDate /* returning it in 'internal' format */
  61.  
  62. convertToTime: procedure
  63.     if arg() ~= 1 then do
  64.         rc = "convertToTime: bad args"
  65.         signal error
  66.     end
  67.     parse arg timeInC
  68.     
  69.     actualTime = (timeInC - (2922)*86400) // (86400)
  70.  
  71.     return actualTime
  72.  
  73. cTime: procedure
  74.     /* 2922 = 8*365 + 2 */
  75.     /* 86400 = 24*60*60 */
  76.     return (date('i')+2922)*86400 + time('s')
  77.  
  78. /* this returns a handle that you must use after initializing log. */
  79. initLogEntry: procedure expose log.
  80.     if arg() ~= 0 then do
  81.         rc = "initLogEntry: bad args"
  82.         signal error
  83.     end
  84.     
  85.     drop log.
  86.         log. = ''
  87.  
  88.         acidname = getclip(address() || 'CIDNAME')
  89.         acidnumber = getclip(address() || 'CIDNUMBER')
  90.  
  91.     /* 2922 = 8*365 + 2 */
  92.     /* 86400 = 24*60*60 */
  93.     log.time = (date('i')+2922)*86400 + time('s')
  94.     log.cidname = acidname
  95.     log.cidnumber = acidnumber
  96.  
  97.     return
  98.  
  99. loadLogEntry: procedure expose log.
  100.     if arg() ~= 2 then do
  101.         rc = "loadLogEntry: bad args"
  102.         signal error
  103.     end
  104.     parse arg mailbox, handle
  105.  
  106.         drop log.
  107.         log. = ''
  108.  
  109.     if ~exists(mailboxDir(mailbox)) then do
  110.         call showDebugger('Dir=' || mailboxDir(mailbox) 'does not exist')
  111.         return
  112.     end
  113.  
  114.     opened = open(handle, logFile(mailbox, handle), 'r')
  115.         if opened then do
  116.         call showDebugger('Loading entry' logFile(mailbox, handle))
  117.         do while ~eof(handle)
  118.             line = readln(handle)
  119.             parse upper var line variable '=' value
  120.             log.variable = value
  121.         end
  122.         call close(handle)
  123.     end; else call showDebugger('Could not load' logFile(mailbox, handle))
  124.     return
  125.  
  126. /* pass a handle here */
  127. saveLogEntry: procedure expose log.
  128.     if arg() ~= 2 then do
  129.         rc = "saveLogEntry: bad args"
  130.         signal error
  131.     end
  132.     parse arg mailbox, handle
  133.  
  134.     if ~exists(mailboxDir(mailbox)) then do
  135.         call showDebugger('Dir=' || mailboxDir(mailbox) 'does not exist')
  136.         return
  137.     end
  138.  
  139.     opened = open(handle, logFile(mailbox, handle), 'w')
  140.  
  141.     if opened then do
  142.         call showDebugger('Saving entry' logFile(mailbox, handle))
  143.         call writeln(handle, 'TYPE=' || log.type)
  144.         call writeln(handle, 'TIME=' || log.time)
  145.         call writeln(handle, 'LENGTH=' || log.length)
  146.  
  147.         call writeln(handle, 'ORIGMAILBOX=' || log.origmailbox)
  148.  
  149.         call writeln(handle, 'CIDNAME=' || log.cidname)
  150.         call writeln(handle, 'CIDNUMBER=' || log.cidnumber)
  151.  
  152.         call writeln(handle, 'COMMENT=' || log.comment)
  153.  
  154.         call writeln(handle, 'FILENAME=' || log.filename)
  155.         call writeln(handle, 'ALTFILENAME=' || log.altfilename)
  156.  
  157.         call writeln(handle, 'RETURNNUMBER=' || log.returnnumber)
  158.         call writeln(handle, 'RETURNSENDFUNC=' || log.returnsendfunc)
  159.         call writeln(handle, 'RETURNSTATUS=' || log.returnstatus)
  160.  
  161.         call writeln(handle, 'RETURNRETRY=' || log.returnretry)
  162.         call writeln(handle, 'RETURNINTERVAL=' || log.returninterval)
  163.  
  164.         call close(handle)
  165.         address rexx 'broadcast' 'addtomailbox' mailbox handle
  166.     end; else call showDebugger('Could not save' logFile(mailbox, handle))
  167.  
  168.     return
  169.  
  170. /* pass a handle here */
  171. updateLogEntry: procedure expose log.
  172.     if arg() ~= 2 then do
  173.         rc = "updateLogEntry: bad args"
  174.         signal error
  175.     end
  176.     parse arg mailbox, handle
  177.  
  178.     if ~exists(mailboxDir(mailbox)) then do
  179.         call showDebugger('Dir=' || mailboxDir(mailbox) 'does not exist')
  180.         return
  181.     end
  182.  
  183.     if ~exists(logFile(mailbox, handle)) then do
  184.         call showDebugger('Unable to update non-existent' logFile(mailbox, handle))
  185.         return
  186.     end
  187.     opened = open(handle, logFile(mailbox, handle), 'w')
  188.  
  189.     if opened then do
  190.         call showDebugger('Updating entry' logFile(mailbox, handle))
  191.         call writeln(handle, 'TYPE=' || log.type)
  192.         call writeln(handle, 'TIME=' || log.time)
  193.         call writeln(handle, 'LENGTH=' || log.length)
  194.  
  195.         call writeln(handle, 'ORIGMAILBOX=' || log.origmailbox)
  196.  
  197.         call writeln(handle, 'CIDNAME=' || log.cidname)
  198.         call writeln(handle, 'CIDNUMBER=' || log.cidnumber)
  199.  
  200.         call writeln(handle, 'COMMENT=' || log.comment)
  201.  
  202.         call writeln(handle, 'FILENAME=' || log.filename)
  203.         call writeln(handle, 'ALTFILENAME=' || log.altfilename)
  204.  
  205.         call writeln(handle, 'RETURNNUMBER=' || log.returnnumber)
  206.         call writeln(handle, 'RETURNSENDFUNC=' || log.returnsendfunc)
  207.         call writeln(handle, 'RETURNSTATUS=' || log.returnstatus)
  208.  
  209.         call writeln(handle, 'RETURNRETRY=' || log.returnretry)
  210.         call writeln(handle, 'RETURNINTERVAL=' || log.returninterval)
  211.  
  212.         call close(handle)
  213.         address rexx 'broadcast' 'refreshmailboxentry' mailbox handle
  214.     end; else call showDebugger('Could not update' logFile(mailbox, handle))
  215.  
  216.     return
  217.  
  218.  
  219.  
  220. showDebugger: procedure
  221.     if arg() ~= 1 then do
  222.         say "showDebugger: ERROR"
  223.         exit 20
  224.     end
  225.  
  226.     parse arg debuggerInfo
  227.     
  228.     firstLine = sourceline(1)
  229.     parse var firstLine '/*' 'TITLE:' title '*/'
  230.     if showlist('p', 'AVMLOGGER') then
  231.         address 'AVMLOGGER' 'add' title ':' debuggerInfo
  232.     else
  233.         say title ':' debuggerInfo
  234.  
  235.     return 
  236.  
  237. /*-----------------------------------------------------------------------*/
  238. /*                         signal processing                             */
  239.  
  240. arexxerror:
  241. error:
  242.     call showDebugger("Error" rc "at line" sigl)
  243.     exit 20
  244.  
  245. break_c:
  246. halt:
  247.     call showDebugger("Halt/Break_C at line" sigl)
  248.     exit 20
  249.  
  250. novalue:
  251.     call showDebugger("No value at line" sigl)
  252.     exit 20
  253.  
  254. syntax:
  255.     call showDebugger("Syntax error" rc "at line" sigl)
  256.     exit 20
  257.  
  258.