#/* #undef CFG_BIG_ENDIAN */
#
#/* Configuration file directory */
##define CFG_CONFIGFILE_DIR "/usr/share/ntop"
#
BEGIN {
    WHOAMIFROM=ARGV[1]
    ARGV[1]=""

    print "  /*                                                       B E G I N"
    print "   *"
    print "   * Autogenerated from " WHOAMIFROM " and inserted into webInterface.c "
    print "   *      " strftime()
    print "   *"
    print "   */"
    print ""

    while (getline < "stoplist" > 0) {
        stopentry[$1]="y"
    }
    firstz="y"
}

{
    if ($1 in stopentry) { next } 

    if (substr($1, 1, 1) == "z") { 
      $1 = substr($1, 2)
      if(firstz == "y") {
        firstz="n"
        print "  /* Move the following lines */"
      }
    }

    if ($2 == "*") {
        print "  printFeatureConfigInfo(textPrintFlag, \"" $1 "\","
        print "#ifdef " $1
        print "                         \"yes\""
        print "#else"
        print "                         \"no\""
        print "#endif"
        print "                         );"
    } else if (substr($2, 1, 1) == "\"") {
        print "#ifdef " $1
        print "  printFeatureConfigInfo(textPrintFlag, \"" $1 "\", " $2 ");"
        print "#else"
        print "  printFeatureConfigInfo(textPrintFlag, \"" $1 "\", \"undefined\");"
        print "#endif"
    } else if (substr($2, 1, 1) == "#") {
        print "#ifdef " $1
        print "  printFeatureConfigNum(textPrintFlag, \"" $1 "\", " substr($2, 2) ");"
        print "#else"
        print "  printFeatureConfigInfo(textPrintFlag, \"" $1 "\", \"undefined\");"
        print "#endif"
    } else if ($2 == "NULL") {
        print "  printFeatureConfigInfo(textPrintFlag, \"" $1 "\", \"(null)\");"
    } else {
        print "#ifdef " $1
        print "  printFeatureConfigInfo(textPrintFlag, \"" $1 "\", " $2 ");"
        print "#else"
        print "  printFeatureConfigInfo(textPrintFlag, \"" $1 "\", \"undefined\");"
        print "#endif"
    }
    print ""
}

END {
    print "  /*                                                       E N D"
    print "   *"
    print "   * Autogenerated from " WHOAMIFROM " and inserted into webInterface.c "
    print "   *"
    print "   */"
    print ""
}
