windows.c: Fix possible assert when passing NULL to *open()

On Win32 subsurface_fopen() can reach an assert in windows.c:
utf8_to_utf16(), if NULL is passed for 'path'.

Let's return NULL/-1 for some of the *open() functions in there.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
libdivecomputer.c: Try not to pass NULL to fopen()

C99 7.1.4, says nothing about passing NULL to fopen(),
which means that it isn't portable and there are no guaranties
that the return will be a NULL pointer or that that a library
implementation will not assert or SYSSEGV in the middle of the
fopen() branch.

libdivecomputer.c's 'dumpfile_name' and 'logfile_name' could
cause problems in that regard.

A possible fix for #411

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
DownloadFromDCWidget: prevent possible leaks for log/dump files

If the 'logfile_name' and 'dumpfile_name' were NULL we can simply
strdup() them with a new value, but if there was a previous value
we need to free() first.

C99 6.7.8 allows us to keep said variables without the
explicit NULL initialiazation.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Write the event data to the libdivecomputer log.

For some devices, the event data contains important data that is
required for parsing the dives, but which is not present in the full
memory dump.

Signed-off-by: Jef Driesen <jefdriesen@telenet.be>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Show import dialog only when needed for CSV config

We do not need any import dialog when importing normal XML based
divelogs. With this they are imported directly after file selection
dialog. However, when CSV files are detected in the import list, the
configuration dialog is displayed and applied for them. (CSV files are
detected by file extension.)

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>