/***********************************
 *                                 * 
 *     FreqAssist Version 1.02     *
 *    by Steve Robbins [M3014]     *
 *           RFS Software          *
 *      Last updated 10 Jan 95     *
 *                                 *
 ***********************************/

options results
parse arg LineNumber
if ~show('L','rexxsupport.library') then do                  
   if addlib('rexxsupport.library',0,-30,0) then NOP
   else do
      say 'Rexxsupport.library is not available'
      exit 10
   end
end
signal on syntax
signal on ioerr
signal on BREAK_C

x = 0
i = 0
j = 0
k = 0
say " "
say " FreqAssist     Version 1.02     by: Steve Robbins [M3014]     RFS Software"
say " "
call open(config,"MEBBSNet:ConfigFiles/FreqAssist.cfg",'R')
do until EOF(config)
   junk = readln(config)
   if left(junk, 5) == "MAGIC" then do
      i = i + 1
      ConfigMagic.i = junk
   end
   if left(junk, 8) == "PASSWORD" then do
      j = j + 1
      ConfigPass.j = junk
   end
   if left(junk, 7) == "PASSDIR" then do
      k = k + 1
      ConfigPassDir.k = junk
   end
end
call close(config)
call pragma('directory',"MEBBSNet:ConfigFiles")
address command "rename freq.cfg freq.bak"
call open(freq,"MEBBSNet:ConfigFiles/freq.bak",'R')
call open(freq1,"MEBBSNet:ConfigFiles/freq.cfg",'W')
do until EOF(freq)
   junk = readln(freq)
   freqname = word(junk,1)
   path = Word(junk,2)
   password = word(junk,3)
   do l = 1 to j     
      if Upper(path) == Upper(word(ConfigPass.l,2)) then do
         if length(word(configpass.l,3)) > 8 then do
            x = 1
            say "Failed adding a password to "freqname", password exceeds 8 characters."
         end
         if x ~= 1 then password = word(ConfigPass.l,3)
         if x ~= 1 then say "Adding password to "freqname
      end
      x = 0
   end
   do m = 1 to i
      if Upper(path) == Upper(word(ConfigMagic.m,3)) then do
         freqname1 = word(ConfigMagic.m,2)
         say "Adding Magic Name - "freqname1
         junk = Upper(freqname1)" "path" "password
         call writeln(freq1, junk)
      end
   end
   do n = 1 to k
      if Upper(left(path,lastpos("/", path))) == Upper(word(ConfigPassDir.n,2)) | Upper(left(path,lastpos(":", path))) == Upper(word(ConfigPassDir.n,3)) then do
         if length(word(configpassdir.l,3)) > 8 then do
            x = 1
            say "Failed adding a password to "freqname", password exceeds 8 characters."
         end
         if x ~= 1 then password = word(ConfigPassDir.n,3)
         if x ~= 1 then say "Adding password to "freqname
      end
      x = 0
   end
   junk = Upper(freqname)" "path" "password
   call writeln(freq1, junk)
end
call close(freq)
call close(freq1)
address command "delete MEBBSNet:ConfigFiles/freq.bak QUIET"
say " "
exit
      

BREAK_C:
exit

syntax:
   say "**syntax** in FreqAssist in line: " SIGL " Severity: " RC
   exit

ioerr:
   say "**IO ERROR** in FreqAssist in line: " SIGL " Severity: " RC
   exit




