File tohal.awk of Package lomoco

#!/bin/awk -f
BEGIN {
    FS = ","
    print "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>"
    print "<deviceinfo version=\"0.2\">"
    print "  <device>"
    print "    <match key=\"info.bus\" string=\"usb_device\">"
    print "      <match key=\"usb_device.vendor_id\" int=\"0x046d\">"
}

$1 ~ /0xc[a-f0-9][a-f0-9][a-f0-9]/ {
    print "        <!-- " substr($3, index($3, "\"")) ", " $2 " -->"
    print "        <match key=\"usb_device.product_id\" int=\"0x" \
	  substr($1, index($1, "x")+1) "\">"
    print "          <merge key=\"resmgr.class\" type=\"string\">input</merge>"
    print "        </match>"
}

END {
    print "      </match>"
    print "    </match>"
    print "  </device>"
    print "</deviceinfo>"
}