/*************************************************/
/*                                               */
/*   MegaCDOnline.rexx v1.01 © David Huckett..    */
/*    Xenolink 1.95 CD-Rom Door. loaded util     */
/*   By David Huckett  14-Jun-95 3:640/800 Fido  */
/*************************************************/

/*  WARNING  CD-ROMs that have no name and show up on Workbench as Unnamed
**           must only be used one at a time.. You can not have three volumes
**           loaded in drives all called Unnamed.. It will confuse the door.
*/

/*  INSTRUCTIONS
**
**   This is a small support util hacked from the main MegaCD.rexx
**   program..
**   What it is used for is to display to users as they log in, what
**   CD-Rom disks are loaded at the time...
**   It can be placed in you FakeMain.menu so that all users as they
**   Login, will get to see it..
**
**   Setup as a REXX "Doors:MegaCD/MegaCDOnline.rexx ~14" in you .src
**
**   Only a few options.. One will display ALL available CDs' with the
**   ones online at the time highlighted or it will just display the online
**   ones..
**   To display only loaded CDs' then leave ONLINEONLY = 'Y'
**   else to show all configured Cds' with the online ones highlighted
**   set ONLINEONLY = 'N'
**
*/

CDCFG      = 'Doors:MegaCD/CD.cfg'
BBSNAME    = 'MegaTech BBS'
ONLINEONLY = 'Y'
 
VERS = 'MegaCDOnline v1.01'
options results

PR = 'PRINT'

arg Node_Number
host = 'XenolinkRexxPort'Node_Number
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 privilege ; access = result
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

CALL PRAGMA('W','N')  /* Disk Requesters OFF */

START:
CLS
pr BLU'                 ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿'
pr '                 ³'BGRN||Centre(bbsname' CD-Rom Doorway',34)||OFF||BLU' ³'
pr '                 ³                                   ³'
pr '                 ³'BCYA'  Presently loaded CD-Rom Disks..'OFF||BLU'  ³'
pr '                 ³                                   ³'
pr '                 ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ'OFF
pr
	if ~exists(CDcfg) then do
	PR ' Sorry config file not found.. Advise Sysop.'
	call ERROR
end
	else do
	Call open(cfg,CDcfg,'R')
		numcd=readln(cfg)
		do i=1 to numcd
	lock.i=readln(cfg)
	title.i=readln(cfg)
	config.i=readln(cfg)
	desc.i=readln(cfg)
	noacclevel.i=readln(cfg)
	noviewlev.i=readln(cfg)

if index(noacclevel.i,access) ~=0 then existnoacc.i = 'No Access'
existnoview = index(noviewlev.i,access)  /* See if you have given access to their level */
if existnoview ~= 0 then do  /* Check to see if the user has view access */
title.i = 'No View'          /* eg GIF CD's, if not then flag this one out */ 
iterate i
end

if  ~Exists(lock.i) then do
	if onlineonly = 'Y' then iterate i
		pr YEL||left(i'.',4)CYA||left(title.i,15)RED||left('OFFLINE',8)OFF||left(desc.i,45)
		title.i='Not Online'        /* If the system can't get a lock on the volume */
		iterate i                   /* then flag it offline */
	end
	pr BCYA||left(i'.',4)BYEL||left(title.i,15)GRN||left('Online',8)CYA||left(desc.i,45)OFF
   	end
	call close(cfg)
END


pr
msg '[7m Any key to continue. [0m'
getchar
Exit 0


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


EXIT 10

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

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

EXIT 10
