core: load and save fingerprints to XML

We always use the global fingerprint table - maybe this should just not
be a parameter of the accessor functions?

The syntax is very simple - the raw data is encoded as a hex string, the
rest of the components are hex numbers.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2021-10-30 16:31:29 -07:00
parent 33527cb9e5
commit 2b1db9da82
4 changed files with 67 additions and 0 deletions

View file

@ -607,6 +607,16 @@ static void save_one_device(struct membuffer *b, const struct device *d)
put_format(b, "/>\n");
}
static void save_one_fingerprint(struct membuffer *b, int i)
{
put_format(b, "<fingerprint model='%08x' serial='%08x' deviceid='%08x' diveid='%08x' data='%s'/>\n",
fp_get_model(&fingerprint_table, i),
fp_get_serial(&fingerprint_table, i),
fp_get_deviceid(&fingerprint_table, i),
fp_get_diveid(&fingerprint_table, i),
fp_get_data(&fingerprint_table, i));
}
int save_dives(const char *filename)
{
return save_dives_logic(filename, false, false);
@ -676,6 +686,10 @@ static void save_dives_buffer(struct membuffer *b, bool select_only, bool anonym
if (!select_only || device_used_by_selected_dive(d))
save_one_device(b, d);
}
/* save the fingerprint data */
for (int i = 0; i < nr_fingerprints(&fingerprint_table); i++)
save_one_fingerprint(b, i);
if (autogroup)
put_format(b, " <autogroup state='1' />\n");
put_format(b, "</settings>\n");