/* This script converting squish.cfg to msgarea.ctl */

/* There is your defaults */
UseAddress =     '2:461/13'
Origin =         'CompA$$ BBS /Entered online/'
Read_Security =  1
Write_Security = 1
SysOp_Security = 256

Parse Arg argstr
Say 'SQ2TOR 1.01 (C) 1997 Oleg Deribas, 2:461/13@fidonet'
If WORDS(argstr) < 2 Then Do
  Say 'Syntax: sq2tor squish.cfg msgarea.ctl'
  Exit
End
sqcfg = WORD(argstr,1)
earea = WORD(argstr,2)

rc = LINEOUT(earea,'; This message areas config file for Tornado',1)
rc = LINEOUT(earea,'; generated by squish.cfg->msgarea.ctl convertor')
rc = LINEOUT(earea,'; (c) Oleg Deribas 2:461/13@fidonet, 1997')

Do While lines(sqcfg)
  sqline = LINEIN(sqcfg)
  If TRANSLATE( WORD(sqline,1) ) = 'ECHOAREA' Then Do
    rc = LINEOUT(earea,'')
    rc = LINEOUT(earea,'[MsgArea]')

    BaseType =       'Fido'
    Do wc = 1 To WORDS(sqline)
      If WORD(sqline,wc) = '-$' Then
        BaseType = 'Squish'
      If WORD(sqline,wc) = '-0' Then
        BaseType = 'Passthrough'
    End /* do */

    If \ (BaseType = 'Passthrough') Then Do

      Say 'Echoarea ' WORD(sqline,2)

      rc = LINEOUT(earea,'Name          "'WORD(sqline,2)'"')
      rc = LINEOUT(earea,'UseAddress     'UseAddress)
      rc = LINEOUT(earea,'Origin        "'Origin'"')
      rc = LINEOUT(earea,'BaseType       'BaseType)
      rc = LINEOUT(earea,'BasePath       'WORD(sqline,3))
      rc = LINEOUT(earea,'Read_Security  'Read_Security)
      rc = LINEOUT(earea,'Write_Security 'Write_Security)
      rc = LINEOUT(earea,'SysOp_Security 'SysOp_Security)

    End

  end /* if */
end /* do */

rc = LINEOUT(sqcfg)
rc = LINEOUT(earea)
