Use getopt_long instead of custom arg parsing

One side affect of this change is we no longer copy the filename args into
malloc'ed buffers, we just use const char pointers.

This also fixes how we recognize filename extensions, to ensure that the
filename really ends with the extension (i.e. .bin, not .binary).

BUG=chromium-os:21568
TEST=builds clean;
 Test following cases:
  cyapa_fw_update
  cyapa_fw_update -h
  cyapa_fw_update -v
  cyapa_fw_update -f
  cyapa_fw_update -f -b
  cyapa_fw_update -b -o bkup.bin
  cyapa_fw_update -b -o bkup
  cyapa_fw_update -f fw.iic
  cyapa_fw_update -f -b fw.binary

Change-Id: I48c2f686e2118e8b1ca91a54e87ee29c80f37b2e
1 file changed