#!/usr/bin/awk -f

# kcs (c) 1995 by Joerg Hessdoerfer (joe@amber.dinoco.de)
# Permission to use and re-distribute this software is 
# granted according to the GPL

BEGIN {
  getline online < sprintf("%s.nums",ENVIRON["CONFTMP"]);

  num = split(ARGV[1], a, ".");

  if(a[num] != "req")
    {
      getline;
      print;
    }
}

{
  if(a[num] != "req")
    {
      match($0, /\".*\"/);
      text = substr($0, RSTART, RLENGTH);
      sub(/\".*\"/, "DUMMY", $0);

      if( index(online, $1) != 0 )
	{ $3 = "on"; }
      else
	{ $3 = "off"; }

      sub(/DUMMY/, text, $0);

      print;
    }
  else
    {
      i = index(online, $3);
      
      value = substr(online , i + 4, 20);

      split(value, a, " ");
      value = a[1];
      
      $4 = value;
      print;

      getline;
      sub(/\(Old value was .*\)/, sprintf("(Old value was %s)", value), $0);
      print;
    }
}

