Again, this is a subtle change. The avr_message2() function introduced a
while ago an effective verbosity level, where verbosity is reduced by the
number of -q options above one. This commit uses that level throughout
instead of verbose.
LIBAVRDUDE_EXIT was introduced to allow driver function to tell main.c
that all is done and avrdude should exit(0) indicating success. For
example, processing the -x help options in the driver should exit.
There have been increasingly more situations when the driver function
needed to return and suppress error messages from the caller; for these
LIBAVRDUDE_EXIT was used but now avrdude wrongly indicated success to the
shell when it should indicate an error.
This commit replaces LIBAVRDUDE_EXIT with LIBAVRDUDE_EXIT_FAIL or
LIBAVRDUDE_EXIT_OK as appropriate indicating error or success to the
shell, respectively.
Switch the command line argument parser from getopt(3) to
getopt_long(3) and add a few long options as aliases to existing
short options, e.g. "--help" and "--part" being aliases for "-?"
and "-p", respectively.
The getopt_long(3) function is available on GNU, BSD, and the existing
msvc/getopt.[ch] already implements getopt_long() on Windows. This
should cover all systems avrdude supports.
Adapt the avrdude usage message shown by "-?" or "--help" to show the
new long options.
TODO: Adapt man page and texi manual reflecting the long options.
Closes: #1922
Beyond initializing the cx pointer, it turns out more cleanup might be
required when re-initializing the context pointer. (Normal CLI only
initializes it once, so that's not an issue there.)
Thus, join all the required actions into an init_cx() function
provided by the library.