diff options
-rw-r--r-- | divesite.c | 16 | ||||
-rw-r--r-- | divesite.h | 2 |
2 files changed, 17 insertions, 1 deletions
diff --git a/divesite.c b/divesite.c index 998fe23bf..800ccc9bd 100644 --- a/divesite.c +++ b/divesite.c @@ -200,3 +200,19 @@ void clear_dive_site(struct dive_site *ds) ds->taxonomy.nr = 0; free_taxonomy(&ds->taxonomy); } + +uint32_t find_or_create_dive_site_with_name(const char *name) +{ + int i; + struct dive_site *ds; + bool found = false; + for_each_dive_site(i,ds) { + if (same_string(name, ds->name)) { + found = true; + break; + } + } + if (ds) + return ds->uuid; + return create_dive_site(name); +} diff --git a/divesite.h b/divesite.h index 306272e96..8801ddce9 100644 --- a/divesite.h +++ b/divesite.h @@ -59,7 +59,7 @@ uint32_t get_dive_site_uuid_by_gps_proximity(degrees_t latitude, degrees_t longi bool dive_site_is_empty(struct dive_site *ds); void copy_dive_site(struct dive_site *orig, struct dive_site *copy); void clear_dive_site(struct dive_site *ds); - +uint32_t find_or_create_dive_site_with_name(const char *name); #ifdef __cplusplus } #endif |