home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 8
/
FreshFishVol8-CD2.bin
/
bbs
/
comm
/
avmnfax-1.33.lha
/
avmNfax
/
rexx
/
handlefax.avm
< prev
next >
Wrap
Text File
|
1994-06-24
|
15KB
|
574 lines
/* TITLE: avm:rexx/handlefax.avm */
/* we want results! Otherwise, we wouldn't get anything from RESULT */
options results
/* Need to make sure that stdtail.avm is also included */
signal on halt
signal on novalue
signal on syntax
signal on break_c
/* needed for some of the functions we use */
call addlib("rexxsupport.library", 0, -30, 0)
/* a higher than normal priority since calls are important to us :) */
call pragma('priority', 1)
/* ensure that commands are directed to the correct server */
parse arg servername .
address value servername
parse arg servername mailbox .
if symbol('mailbox') ~= 'VAR' | mailbox = '' then mailbox = 'manual'
options failat 50
'turnoffvoicemode'
'assumemode' 'Unknown'
'setserial' '19200' '8' 'N' '1' '7Wire'
action = rc
select
when action = 0 then nop
when action = 14 then nop
when action = 16 then nop
otherwise signal arexxerror
end
isTrapFax:
faxprogram = upper(getclip('AVMFaxProgram'))
if faxprogram = 'TRAPFAX' then do
call showDebugger('Starting TrapFax reception.')
call time('r')
/*----------------------------------------*/
address rexx 'setuptfax.avm'
/*----------------------------------------*/
'writeline' 'ATA'
address command "trapfax:tfaxdoor getty"
call showDebugger('TrapFax reception ' || time('e'))
isGPFax:
end; else if faxprogram = 'GPFAX' then do
call showDebugger('Starting GPFax reception.')
call time('r')
address rexx_gpfax 'listen'
address rexx_gpfax 'recfax'
faxresult = rc
address rexx_gpfax 'unlisten'
call showDebugger('GPFax result is' faxresult)
call showDebugger('GPFax done ' || time('e'))
isEFax:
end; else if faxprogram = 'EFAX' then do
/* create a unique filename */
efaxFileName = makeUniqueFile()
call time('r')
address command 'avm:gnu/efax -p' servername '-r' voiceFile(mailbox, efaxFileName)
efaxLength = time('e')
end
doneRecFax:
'delay' 2
action = rc
select
when action = 0 then nop
when action = 12 then signal stdabort
when action = 14 then signal stderror
when action = 16 then signal stderror
otherwise signal arexxerror
end
'writeline' 'AT+FCLASS=0'
'readline' '2'
action = rc
if action = 0 then value = result
select
when action = 0 then nop
when action = 10 then nop
when action = 12 then signal stdabort
when action = 14 then signal stderror
when action = 16 then signal stderror
otherwise signal arexxerror
end
'readline' '2'
action = rc
if action = 0 then value = result
select
when action = 0 then nop
when action = 10 then nop
when action = 12 then signal stdabort
when action = 14 then signal stderror
when action = 16 then signal stderror
otherwise signal arexxerror
end
createLog:
handle = makeUniqueFile()
call initLogEntry()
log.comment = 'Fax attempted.'
log.type = 'Try_FAX'
if faxprogram = 'GPFAX' then do
if faxresult <= 5 then signal gotfaxgpfax
end; else if faxprogram = 'TRAPFAX' then do
call open('cfaxlstfl', 'trapfax:trapfax.log', 'r')
call open('cfaxnrfl', 'trapfax:incoming/trapfax.sequence', 'r')
cfaxnr = readln('cfaxnrfl')
cnewfaxnr = right(cfaxnr, 4, '0')
do forever
cfax = readln('cfaxlstfl')
cfaxlsnr = right(left(cfax, 6), 4)
if cfaxlsnr = cfaxnr | eof('cfaxlstfl') then break
end
call close('cfaxlstfl'); call close('cfaxnrfl')
if left(cfax, 1) ~= 'E' then signal gotfaxtrapfax
end; else if faxprogram = 'EFAX' then do
if exists(voiceFile(mailbox, efaxFileName) || '.001') then signal gotfaxefax
end
signal finished
gotfaxgpfax:
address rexx_gpfax 'reportlog' 1
faxfilename = result
log.filename = result
address rexx_gpfax 'reportlog' 6
log.length = result
address rexx_gpfax 'reportlog' 2
log.comment = result 'page(s) received.'
address rexx_gpfax 'reportlog' 4
log.returnnumber = result
log.type = 'fax'
signal finished
gotfaxtrapfax:
faxfilename = 'trapfax:incoming/In-' || cfaxnr || '.FAX'
log.filename = faxfilename
myvar = right(left(cfax, 54), 5)
myvar = (left(myvar, 2)*60) + (right(myvar, 2))
log.length = myvar
myvar = right(left(cfax, 47), 2); myvar = strip(myvar, 'L')
log.comment = myvar 'page(s)'
myvar = right(left(cfax, 45), 22)
myvar = strip(myvar, 'T')
log.returnnumber = myvar; log.type = 'fax'
signal finished
gotfaxefax:
log.filename = efaxFileName
faxfilename = efaxFileName
log.type = 'fax'
log.length = efaxLength
base = voiceFile(mailbox, efaxFileName) || '.'
do i = 1 to 999
if ~exists(base || right(i, 3, '0')) then break
end
log.comment = i - 1 'page(s).'
log.returnNumber = getclip(upper(servername || '.faxid'))
signal finished
finished:
call saveLogEntry(mailbox, handle)
call loadMailbox(mailbox)
if upper(log.type) = 'FAX' & mailbox.autofaxforwardb = 1 & mailbox.autofaxforwardscript ~= "" then do
handle = makeUniqueFile()
call initLogEntry(); log.origmailbox = mailbox
log.filename = voiceFile(mailbox, faxfilename); log.type = 'fax'
log.returnsendfunc = mailbox.autofaxforwardscript; log.returninterval = 5
log.returnretry = 3; log.returnnumber = mailbox.autofaxforward
call saveLogEntry('Outgoing', handle)
end
exit
/* TITLE: avm:rexx/simplestdtail.avm */
/* This is the standard tail */
exit
exit
mailboxDir: procedure
parse arg mailbox
return 'avm:' || mailbox || '/'
logFile: procedure
parse arg mailbox, magiccookie
return 'avm:' || mailbox || '/logs/' || magiccookie
voiceFile: procedure
parse arg mailbox, magiccookie
if (verify(magiccookie, '/:', 'M') = 0) then
return 'avm:' || mailbox || '/voices/' || magiccookie
else
return magiccookie
makeUniqueFile: procedure
if arg() ~= 0 then do
rc = "makeUniqueFile: bad args"
signal error
end
return address() || '.' || date('i') || '.' || time('s') || '.' || random(1, 999, time('s'))
convertToDate: procedure
if arg() ~= 1 then do
rc = "convertToDate: bad args"
signal error
end
parse arg timeInC
actualTime = (timeInC - (2922)*86400) // (86400)
actualDate = (timeInC - actualTime - 2922*86400) % 86400
return actualDate /* returning it in 'internal' format */
convertToTime: procedure
if arg() ~= 1 then do
rc = "convertToTime: bad args"
signal error
end
parse arg timeInC
actualTime = (timeInC - (2922)*86400) // (86400)
return actualTime
cTime: procedure
/* 2922 = 8*365 + 2 */
/* 86400 = 24*60*60 */
return (date('i')+2922)*86400 + time('s')
/* this returns a handle that you must use after initializing log. */
initLogEntry: procedure expose log.
if arg() ~= 0 then do
rc = "initLogEntry: bad args"
signal error
end
drop log.
log. = ''
acidname = getclip(address() || 'CIDNAME')
acidnumber = getclip(address() || 'CIDNUMBER')
/* 2922 = 8*365 + 2 */
/* 86400 = 24*60*60 */
log.time = (date('i')+2922)*86400 + time('s')
log.cidname = acidname
log.cidnumber = acidnumber
return
loadLogEntry: procedure expose log.
if arg() ~= 2 then do
rc = "loadLogEntry: bad args"
signal error
end
parse arg mailbox, handle
drop log.
log. = ''
if ~exists(mailboxDir(mailbox)) then do
call showDebugger('Dir=' || mailboxDir(mailbox) 'does not exist')
return
end
opened = open(handle, logFile(mailbox, handle), 'r')
if opened then do
call showDebugger('Loading entry' logFile(mailbox, handle))
do while ~eof(handle)
line = readln(handle)
parse upper var line variable '=' value
log.variable = value
end
call close(handle)
end; else call showDebugger('Could not load' logFile(mailbox, handle))
return
/* pass a handle here */
saveLogEntry: procedure expose log.
if arg() ~= 2 then do
rc = "saveLogEntry: bad args"
signal error
end
parse arg mailbox, handle
if ~exists(mailboxDir(mailbox)) then do
call showDebugger('Dir=' || mailboxDir(mailbox) 'does not exist')
return
end
opened = open(handle, logFile(mailbox, handle), 'w')
if opened then do
call showDebugger('Saving entry' logFile(mailbox, handle))
call writeln(handle, 'TYPE=' || log.type)
call writeln(handle, 'TIME=' || log.time)
call writeln(handle, 'LENGTH=' || log.length)
call writeln(handle, 'ORIGMAILBOX=' || log.origmailbox)
call writeln(handle, 'CIDNAME=' || log.cidname)
call writeln(handle, 'CIDNUMBER=' || log.cidnumber)
call writeln(handle, 'COMMENT=' || log.comment)