summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dive.h5
-rw-r--r--file.c11
-rw-r--r--gtk-gui.c6
-rw-r--r--main.c4
-rw-r--r--parse-xml.c6
5 files changed, 18 insertions, 14 deletions
diff --git a/dive.h b/dive.h
index 2c224a12d..42c09b581 100644
--- a/dive.h
+++ b/dive.h
@@ -344,11 +344,12 @@ static inline struct dive *get_dive(int nr)
for ((_i) = 0; ((_x) = get_dive(_i)) != NULL; (_i)++)
extern void parse_xml_init(void);
-extern void parse_xml_buffer(const char *url, const char *buf, int size, GError **error);
+extern void parse_xml_buffer(const char *url, const char *buf, int size, GError **error,
+ gboolean possible_default_filename);
extern void parse_xml_exit(void);
extern void set_filename(const char *filename, gboolean force);
-extern void parse_file(const char *filename, GError **error);
+extern void parse_file(const char *filename, GError **error, gboolean possible_default_filename);
#ifdef XSLT
extern xmlDoc *test_xslt_transforms(xmlDoc *doc);
diff --git a/file.c b/file.c
index df00ea213..1e58a4afd 100644
--- a/file.c
+++ b/file.c
@@ -71,7 +71,7 @@ static void suunto_read(struct zip_file *file, GError **error)
size = read * 3 / 2;
mem = realloc(mem, size);
}
- parse_xml_buffer("SDE file", mem, read, error);
+ parse_xml_buffer("SDE file", mem, read, error, FALSE);
free(mem);
}
#endif
@@ -239,16 +239,17 @@ static int open_by_filename(const char *filename, const char *fmt, struct memblo
return 0;
}
-static void parse_file_buffer(const char *filename, struct memblock *mem, GError **error)
+static void parse_file_buffer(const char *filename, struct memblock *mem, GError **error,
+ gboolean possible_default_filename)
{
char *fmt = strrchr(filename, '.');
if (fmt && open_by_filename(filename, fmt+1, mem, error))
return;
- parse_xml_buffer(filename, mem->buffer, mem->size, error);
+ parse_xml_buffer(filename, mem->buffer, mem->size, error, possible_default_filename);
}
-void parse_file(const char *filename, GError **error)
+void parse_file(const char *filename, GError **error, gboolean possible_default_filename)
{
struct memblock mem;
@@ -267,6 +268,6 @@ void parse_file(const char *filename, GError **error)
return;
}
- parse_file_buffer(filename, &mem, error);
+ parse_file_buffer(filename, &mem, error, possible_default_filename);
free(mem.buffer);
}
diff --git a/gtk-gui.c b/gtk-gui.c
index cf271be92..e5ac16f94 100644
--- a/gtk-gui.c
+++ b/gtk-gui.c
@@ -336,7 +336,7 @@ static void file_open(GtkWidget *w, gpointer data)
GError *error = NULL;
filename = fn_glist->data;
- parse_file(filename, &error);
+ parse_file(filename, &error, TRUE);
if (error != NULL)
{
report_error(error);
@@ -1371,7 +1371,7 @@ static GtkEntry *dive_computer_device(GtkWidget *vbox)
static void do_import_file(gpointer data, gpointer user_data)
{
GError *error = NULL;
- parse_file(data, &error);
+ parse_file(data, &error, FALSE);
if (error != NULL)
{
@@ -1440,7 +1440,7 @@ static GError *setup_uemis_import(device_data_t *data)
#ifdef DEBUGFILE
fprintf(debugfile, "xml buffer \"%s\"\n\n", buf);
#endif
- parse_xml_buffer("Uemis Download", buf, strlen(buf), &error);
+ parse_xml_buffer("Uemis Download", buf, strlen(buf), &error, FALSE);
set_uemis_last_dive(uemis_max_dive_data);
#if UEMIS_DEBUG
fprintf(debugfile, "uemis_max_dive_data: %s\n", uemis_max_dive_data);
diff --git a/main.c b/main.c
index bc7bf7af1..aa418e637 100644
--- a/main.c
+++ b/main.c
@@ -244,7 +244,7 @@ int main(int argc, char **argv)
}
no_filenames = FALSE;
GError *error = NULL;
- parse_file(a, &error);
+ parse_file(a, &error, TRUE);
if (error != NULL)
{
@@ -256,7 +256,7 @@ int main(int argc, char **argv)
if (no_filenames) {
GError *error = NULL;
const char *filename = subsurface_default_filename();
- parse_file(filename, &error);
+ parse_file(filename, &error, TRUE);
/* don't report errors - this file may not exist, but make
sure we remember this as the filename in use */
set_filename(filename, FALSE);
diff --git a/parse-xml.c b/parse-xml.c
index 44ef45746..698fe2a2f 100644
--- a/parse-xml.c
+++ b/parse-xml.c
@@ -1455,7 +1455,8 @@ static void reset_all(void)
import_source = UNKNOWN;
}
-void parse_xml_buffer(const char *url, const char *buffer, int size, GError **error)
+void parse_xml_buffer(const char *url, const char *buffer, int size, GError **error,
+ gboolean possible_default_filename)
{
xmlDoc *doc;
@@ -1472,7 +1473,8 @@ void parse_xml_buffer(const char *url, const char *buffer, int size, GError **er
return;
}
/* remember, if necessary, that this is the filename to store to */
- set_filename(url, FALSE);
+ if (possible_default_filename)
+ set_filename(url, FALSE);
reset_all();
dive_start();
#ifdef XSLT