Fix the warnings like:
Comparison of array 'command' not equal to a null pointer is always true
command is an array, so can never be NULL, so don't bother checking
We add a simple wrapper #define to hide the difference between the
Mac and other platforms version of this function. The tests should
cover all our supported platforms, so remove the configure test.
In common with other recent changes, remove another place where
"Thread" is visible to the user.
We also now use the camera_id rather than the thread number. The
camera_id already defaults to the thread number, so this change
won't cause any difference for older config files that don't set
camera_id.
Remove option ipv6_enabled (IPv6 is always enabled)
Add option localhost_ipv4 (the user must choose to listen to IPv4 and IPv6 localhost, only relevant when the localhost option is set to on)
We currently rely on gethostname() to generate the links from the web
control homepage to the camera streams - unfortunately if DNS isn't
set up well the hostname won't be one the web browser can resolve
(often the case on raspberry pi's, where the hostname is set to
"raspberrypi" by default and users access them via IP address).
To cater for these situations we look at the "Host:" header in the
HTTP headers that came from the browser (which indicate which host the
browser has been asked to connect to) and use that to generate the
hostname to use in the links.
If there's no Host: header (unlikely these days) we default back to
the old behaviour.
Based on a commit originally by Chris Roberts <86montecarlo@gmail.com>
camera_name allows naming of threads, is displayed in the motion control
webpage, and a new specifier (%$) added enabling it to be used for
filenames and such.
The changes I have made since Chris's commit:
1. Change format specifier for threadname from %E to %$
This avoids clashing with any known strftime format specifiers.
(According to the Debian stable strftime man page - it seems we've
already used all spare letters to mean other things.)
2. Behaviour if camera_name is not set is now unchanged
(Previous it would display "thread 1 -- NULL" if the thread name was
unset, and I don't believe how printf deals with NULL values for %s
specifiers is guaranteed.)
3. Thread name is reflected into the system thread name
Uses pthread_setname_np. There's a autoconf test for it, which looks
for the version that takes the thread id and thread name. I believe
this should work on all recent linux, and maybe other platforms too.
(It won't work on macOS; autoconf will disable it - but I deliberately
always use the pthread_setname_np(pthread_self(), name) form so that
it could easily be adapted for macOS in the future.)
4. The parameter has been renamed from thread_name to camera_name, as
that seems to better reflect how the user will see it.
On a SIGHUP restart the main thread waits to restart until all worker
threads are finished executing, except webcontrol wasn't included.
If it was still running (such as reading a web request), it would
have a dangling context pointer after cnt_list was freed leading to a
crash. This counts that thread in the running threads, as a
termination webcontrol_finish variable to terminate it indepdent of
the device thread, and creates a webcontrol_running to identify when
it is running.