/*
 *
 *   MegaCReq.rexx v 1.0 © 1995 by David Huckett 3:640/800 @ Fidonet.
 *
 *   Used to check as a user logs on if he has requested files waiting..
 *
 *   Requires MegaCD and MegaRXDL by David Huckett....
 *   Part of a complete CD-Rom access solution for Xenolink BBS..
 *
*/

/*
 * USAGE:   Rexx "Doors:MegaCD/MegaREQCH.rexx ~14"
 *
*/
/************* System Variables.. Change to suit yourself ******************/

BUFFERDIR     = 'Doors:MegaCD/BUFFER/' 
REQPATH       = 'Doors:MegaCD/Requests/'

/****************************************************************************/

options results


PR = 'PRINT'

arg Node
host = 'XenolinkRexxPort'Node
address value host
signal on error
signal on syntax
signal on IOERR

 if ~show('L','rexxsupport.library') then do
  if ~addlib('rexxsupport.library',0,-30,0) then do
    PR 'Support library not available.'
     call error
    signal Quit
   end
end

getuservar name ; nicename strip(result); name = result

fullname = SPACE(name,1,_)

GETUSERVAR MENUSET 
gfx=result         
if gfx >='1' then do
	WHI='[1;37m';RED='[31m';GRN='[32m';BGRN='[1;32m';YEL='[33m';BYEL='[1;33m';BLU='[34m';MAJ='[35m';CYA='[36m';BCYA='[1;36m';OFF='[0m'
END
	ELSE DO
	WHI='';RED='';GRN='';BGRN='';YEL='';BYEL='';BLU='';MAJ='';CYA='';OFF='';BCYA=''
END


if ~exists(REQPATH||Fullname'.fnd') then exit 0


pr
pr BGRN'MegaCD (c) David Huckett.'OFF
pr
pr CYA'You have requested files from CD-Roms waiting..'
pr
msg YEL'Do you wish to add them to your download list now? Y/N '
GETCHAR
ans = strip(upper(result))

if ans = 'N' then exit 0
if ans = 'Y' then call ADD

exit 0

ADD:

	if ~exists('T:MRXDL'node'.sfl') Then call open(tempdl,'T:MRXDL'node'.sfl','W')
	else Call open(Tempdl,'T:MRXDL'node'.sfl','A')
 
	Call open(rfile,REQPATH||FULLNAME'.fnd',R)
	Do i = 1 Until EOF(rfile)
        FILENAME.i = strip(Readln(rfile))
	if filename.i = '' then leave i
	Call WriteLn(Tempdl,BUFFERDIR  FILENAME.i)
	end

	Call close(Tempdl)
	Call close(rfile)

        address command 'DELETE 'REQPATH||FULLNAME'.fnd QUIET'

exit 0

/*************** ERROR Routine *******************/
error:
a = SIGL;message 'Error!!!  Line # 'a;call delay 200
SysopLog 'ERROR MegaReqCH line # 'a


EXIT 10

syntax:
a = SIGL;message 'Syntax Error!!!  Line # 'a;call delay 200
SysopLog 'SYNTAX ERROR MegaReqCH line # 'a
EXIT 10

ioerr:
message 'I/O Error!!!';call delay 200
SysopLog 'IO ERROR MegaReqCH.'

EXIT 10
