mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
core: move has_dive helper function
This way it can be used by other code that needs this capability. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
9891bdc9ee
commit
95192bdf83
3 changed files with 20 additions and 19 deletions
|
@ -1492,3 +1492,22 @@ struct dive *find_next_visible_dive(timestamp_t when)
|
|||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool has_dive(unsigned int deviceid, unsigned int diveid)
|
||||
{
|
||||
int i;
|
||||
struct dive *dive;
|
||||
|
||||
for_each_dive (i, dive) {
|
||||
struct divecomputer *dc;
|
||||
|
||||
for_each_dc (dive, dc) {
|
||||
if (dc->deviceid != deviceid)
|
||||
continue;
|
||||
if (dc->diveid != diveid)
|
||||
continue;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -69,6 +69,7 @@ void clear_dive_table(struct dive_table *table);
|
|||
void move_dive_table(struct dive_table *src, struct dive_table *dst);
|
||||
struct dive *unregister_dive(int idx);
|
||||
extern void delete_single_dive(int idx);
|
||||
extern bool has_dive(unsigned int deviceid, unsigned int diveid);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -926,25 +926,6 @@ static void save_fingerprint(device_data_t *devdata)
|
|||
free(final);
|
||||
}
|
||||
|
||||
static int has_dive(unsigned int deviceid, unsigned int diveid)
|
||||
{
|
||||
int i;
|
||||
struct dive *dive;
|
||||
|
||||
for_each_dive (i, dive) {
|
||||
struct divecomputer *dc;
|
||||
|
||||
for_each_dc (dive, dc) {
|
||||
if (dc->deviceid != deviceid)
|
||||
continue;
|
||||
if (dc->diveid != diveid)
|
||||
continue;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* The fingerprint cache files contain the actual libdivecomputer
|
||||
* fingerprint, followed by 8 bytes of (deviceid,diveid) data.
|
||||
|
|
Loading…
Add table
Reference in a new issue