adapt: common: fix getting the code address

We've noticed an issue that the following command returns all
code part lines instead of the last one on some systems:

cut -d '
' -f $reslines

So replace it with "tail -n 1".
ugtrain: do cleanup, remove 'NONE' cfg handling

Some variable and function names are still a bit fuzzy. So rename
them to something more obvious. Change some comments, split some
lines and remove the 'NONE' cfg handling. We always have to test
and special treat the 'NONE' handling and we can't ask the user
everything. So it really makes sense to write a config, even if
there's only the process name inside.
system: introduce sleep_sec_unless_input()

Finally we've found the secret of the Linux command 'top' how to
only sleep unless there is input. The libc select() function is
used as the kernel notifies on the stdin file descriptor. Ugtrain
becomes much better responsive to user input with that and still
doesn't risk activation list corruption.

We also use the chance to move the other inline functions to the
system header and to improve some minor things.
examples: update some comments, add a check

Some comments aren't that precise. So change them accordingly.
There is also the possibility to check the static "Cheated" bool
better in Warzone2100. A C++ bool is always u8 with 0 or 1. So we
should check for less than 2.
discovery: do clean-up

In the meanwhile we know what we need and what not for successful
discovery. There is no need for looking at free() calls at all. We
should keep the option to record them but using them for matching
makes no sense. So remove that call back function and also remove
commented out debugging output. If we need to debug something, we
can work with a debug define.
discovery: optimize symbol lookup in stages 3 and 4

At the moment we run 'objdump -D' for each and every symbol. With
a small game binary like 'chromium-bsu' this is okay more or less
but with bigger binaries it is too slow.

So disassemble only once and write the output to the following file:
/tmp/memhack_disasm

The symbol lookups just read that file and search in it for the
symbol at the related jump-back code address. The disassembly file
is removed afterwards. For that also some system function changes
are required.
discovery: optimize parsing in stages 3 and 4

It is quite complex to read and understand what the current checks
while parsing are about to do. So rework and restructure that in
a way that it becomes clear what is done there. Should improve
performance as well.
system: improve use_shell handling and run_pgrp_bg()

If the command vector cmdv is set to NULL, then it is already known
that the shell has to be used. So we can remove that parameter.

In run_pgrp_bg() the use_shell param is used to determine the
method to get the game PID. But using the PID of the game call
instead of the game process is unsafe. So always determine and use
the game process PID.
ChangeLog, TODO: update for 0.2.0 release
options: improve pure long options handling

Let's do it like in the Linux command 'mdadm'. Start at 300 in the
enum and use CamelCase for the pure long options.
dump: add a missing include

For write(), close(), etc. we need to include unistd.h.
system: run_pgrp_bg(): redirect stdout/err to /dev/null

It is a bad idea to close stdout and stderr. So better redirect to
/dev/null. We've noticed during discovery that when running with
scanmem in parallel, a memory object couldn't be found reproducibly.
If running without scanmem, the memory object can be found. This
issue should be fixed with this.