restructure main()

- factor out option parsing and curses initialization
- defer color initialisation until logcfg.dat is read
- factor out loading of databases
- minor fixes to failure handling
- factor out initialisation of hamlib, packet and lan connection
- factor out initialisation of keyer device
add correct deinitialisation of RTTY controller
restructure threading logic

- background thread gets started as before but main logging function
  'logit()' stays in the main thread
- add an cleanup function via atexit() to stop background thread