diff options
author | Jef Driesen <jefdriesen@telenet.be> | 2013-12-23 21:09:33 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-12-24 09:57:14 -0800 |
commit | ca1947f3cf0e36e8e476ed2dd272d642c5f524f4 (patch) | |
tree | bcf79f9d6e4e4ebc2c5c7f6ff8a226a1762f6249 /libdivecomputer.c | |
parent | 60d85de292e0d0b86a897f32334657346173c170 (diff) | |
download | subsurface-ca1947f3cf0e36e8e476ed2dd272d642c5f524f4.tar.gz |
Support downloading memory dumps.
Signed-off-by: Jef Driesen <jefdriesen@telenet.be>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'libdivecomputer.c')
-rw-r--r-- | libdivecomputer.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/libdivecomputer.c b/libdivecomputer.c index 37f6546f2..2b73a3be8 100644 --- a/libdivecomputer.c +++ b/libdivecomputer.c @@ -657,6 +657,7 @@ static const char *do_device_import(device_data_t *data) { dc_status_t rc; dc_device_t *device = data->device; + int dump = 0; /* TODO: Enable memory dump from the UI somehow. */ data->model = str_printf("%s %s", data->vendor, data->product); @@ -671,7 +672,24 @@ static const char *do_device_import(device_data_t *data) if (rc != DC_STATUS_SUCCESS) return translate("gettextFromC","Error registering the cancellation handler."); - rc = dc_device_foreach(device, dive_cb, data); + if (dump) { + dc_buffer_t *buffer = dc_buffer_new (0); + + rc = dc_device_dump (device, buffer); + if (rc == DC_STATUS_SUCCESS) { + /* TODO: Should the filename (and directory) be configurable? */ + FILE* fp = fopen ("subsurface.bin", "wb"); + if (fp != NULL) { + fwrite (dc_buffer_get_data (buffer), 1, dc_buffer_get_size (buffer), fp); + fclose (fp); + } + } + + dc_buffer_free (buffer); + } else { + rc = dc_device_foreach(device, dive_cb, data); + } + if (rc != DC_STATUS_SUCCESS) return translate("gettextFromC","Dive data import error"); |