fix all warnings
Merge pull request #2 from else/master

fix warnings
Add parameters to force specific IP versions

In some cases IPv4 seems to yield better results than IPv6. So give the user
paramters to force a specific protocol version.

In order to restrict curl specific defines and functions to fetch_data_string
own flags have been introduced, which are later on mapped to CURL_IPRESOLVE_V4
and CURL_IPRESOLVE_V6.

CAVEAT: It is possible to force IPv6, but this will currently fail at runtime as
status.raumzeitlabor.de does not resolve to IPv6.
Use enum instead of bit flags

This is a cosmetic change. No functionality is changed by this commit.
Rework layout and add units behind values

* Align labels and values
* Add units behind values
* Reorder values for aesthetic reasons
* Split Upload and Download in two values
* Move door status into the header

At the moment I don't want to assume any specific charsets, so I tried to get
away without any non-ASCII characters. This restriction will be lifted when
character set conversion has been implemented.

Closes #3.
Code modularization

* Split the code in functional modules
* Use patterns in GNUmakefile rules
Fix pattern in GNUmakefile

...although it didn't break the makefile.
Use prefixes in public functions of modules

While here rename ui.[ch] to display[ch]
Accidently pushed a bsdism in GNUmakefile
Use macros to display value blocks

* This greatly simplifies toying around with the layout.
* While here adjust the layout once more.
* Use five columns spacing between between the display columns.
Fix warnings

Define _GNU_SOURCE before including header files to quell warnings.
Reduce code duplication in parse functions
Get rid of magic numbers in display function
Assertify
Avoid hitting the cosm rate limit

The current implementation of ncrzlstat pulled data from cosm every time a key
was pressed or the window was resized. It was not unusual to hit cosms rate
limit after three minutes.

This commit changes the implementation in a way, that only after a given refresh
timeout the data is pulled. The display will still be repainted after every
keypress or SIGWINCH received. This is far from perfect, but it is good enough
at the moment.

Currently, I am working on a non-blocking display, that only repaints itself if
new data was pulled or a SIGWINCH was received.
Rename display.[ch] to ui.[ch]
Remove "event loop"

In order to rework the inner workings of the "pull data - parse json - display
ui" workflow, remove the current "event loop" and start from scratch.

With this change a single snapshot of the state is displayed.
Rewrite "event loop" from scratch

* Wait for timeout before pulling data
* Redraw the screen only if new data has been pulled or the terminal has been
  resized

The code is a little hacky in the way it reparses already parsed data.

CAVEAT: The redrawing of the ui after terminal size changes is implemented but
not working yet. For some reason ncurses default SIGWINCH handler is not
triggered and KEY_RESIZE is not returned by getch().
Workaround issue in older ncurses implementations

A bug in GNU ncurses 5.7, and probably other versions, prevents ncurses default
SIGWINCH handler from being triggered. You can work around this issue by calling
doupdate() just before the call to getch(). At least with the latest version of
GNU ncurses 5.9 this issue seems to be fixed.

So, if the ui is not updated after resizing the terminal, try to build with
OLDCURSES defined.

This is the default, if you are using the BSDmakefile to build ncrzlstat.