mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Support downloading memory dumps.
Signed-off-by: Jef Driesen <jefdriesen@telenet.be> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
60d85de292
commit
ca1947f3cf
1 changed files with 19 additions and 1 deletions
|
@ -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");
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue