mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
core: use divelog struct in git parser state
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
40275ea56b
commit
7d5c6be188
1 changed files with 12 additions and 20 deletions
|
@ -47,11 +47,7 @@ struct git_parser_state {
|
||||||
struct picture active_pic;
|
struct picture active_pic;
|
||||||
struct dive_site *active_site;
|
struct dive_site *active_site;
|
||||||
struct filter_preset *active_filter;
|
struct filter_preset *active_filter;
|
||||||
struct dive_table *table;
|
struct divelog *log;
|
||||||
struct trip_table *trips;
|
|
||||||
struct dive_site_table *sites;
|
|
||||||
struct device_table *devices;
|
|
||||||
struct filter_preset_table *filter_presets;
|
|
||||||
int o2pressure_sensor;
|
int o2pressure_sensor;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -176,9 +172,9 @@ static void parse_dive_gps(char *line, struct membuffer *str, struct git_parser_
|
||||||
|
|
||||||
parse_location(line, &location);
|
parse_location(line, &location);
|
||||||
if (!ds) {
|
if (!ds) {
|
||||||
ds = get_dive_site_by_gps(&location, state->sites);
|
ds = get_dive_site_by_gps(&location, state->log->sites);
|
||||||
if (!ds)
|
if (!ds)
|
||||||
ds = create_dive_site_with_gps("", &location, state->sites);
|
ds = create_dive_site_with_gps("", &location, state->log->sites);
|
||||||
add_dive_to_dive_site(state->active_dive, ds);
|
add_dive_to_dive_site(state->active_dive, ds);
|
||||||
} else {
|
} else {
|
||||||
if (dive_site_has_gps_location(ds) && !same_location(&ds->location, &location)) {
|
if (dive_site_has_gps_location(ds) && !same_location(&ds->location, &location)) {
|
||||||
|
@ -198,9 +194,9 @@ static void parse_dive_location(char *line, struct membuffer *str, struct git_pa
|
||||||
char *name = detach_cstring(str);
|
char *name = detach_cstring(str);
|
||||||
struct dive_site *ds = get_dive_site_for_dive(state->active_dive);
|
struct dive_site *ds = get_dive_site_for_dive(state->active_dive);
|
||||||
if (!ds) {
|
if (!ds) {
|
||||||
ds = get_dive_site_by_name(name, state->sites);
|
ds = get_dive_site_by_name(name, state->log->sites);
|
||||||
if (!ds)
|
if (!ds)
|
||||||
ds = create_dive_site(name, state->sites);
|
ds = create_dive_site(name, state->log->sites);
|
||||||
add_dive_to_dive_site(state->active_dive, ds);
|
add_dive_to_dive_site(state->active_dive, ds);
|
||||||
} else {
|
} else {
|
||||||
// we already had a dive site linked to the dive
|
// we already had a dive site linked to the dive
|
||||||
|
@ -228,7 +224,7 @@ static void parse_dive_notes(char *line, struct membuffer *str, struct git_parse
|
||||||
{ UNUSED(line); state->active_dive->notes = detach_cstring(str); }
|
{ UNUSED(line); state->active_dive->notes = detach_cstring(str); }
|
||||||
|
|
||||||
static void parse_dive_divesiteid(char *line, struct membuffer *str, struct git_parser_state *state)
|
static void parse_dive_divesiteid(char *line, struct membuffer *str, struct git_parser_state *state)
|
||||||
{ UNUSED(str); add_dive_to_dive_site(state->active_dive, get_dive_site_by_uuid(get_hex(line), state->sites)); }
|
{ UNUSED(str); add_dive_to_dive_site(state->active_dive, get_dive_site_by_uuid(get_hex(line), state->log->sites)); }
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We can have multiple tags in the membuffer. They are separated by
|
* We can have multiple tags in the membuffer. They are separated by
|
||||||
|
@ -1014,7 +1010,7 @@ static void parse_settings_divecomputerid(char *line, struct membuffer *str, str
|
||||||
break;
|
break;
|
||||||
line = parse_keyvalue_entry(parse_divecomputerid_keyvalue, &id, line, str);
|
line = parse_keyvalue_entry(parse_divecomputerid_keyvalue, &id, line, str);
|
||||||
}
|
}
|
||||||
create_device_node(state->devices, id.model, id.serial, id.nickname);
|
create_device_node(state->log->devices, id.model, id.serial, id.nickname);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct fingerprint_helper {
|
struct fingerprint_helper {
|
||||||
|
@ -1429,7 +1425,7 @@ static void finish_active_trip(struct git_parser_state *state)
|
||||||
|
|
||||||
if (trip) {
|
if (trip) {
|
||||||
state->active_trip = NULL;
|
state->active_trip = NULL;
|
||||||
insert_trip(trip, state->trips);
|
insert_trip(trip, state->log->trips);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1439,7 +1435,7 @@ static void finish_active_dive(struct git_parser_state *state)
|
||||||
|
|
||||||
if (dive) {
|
if (dive) {
|
||||||
state->active_dive = NULL;
|
state->active_dive = NULL;
|
||||||
record_dive_to_table(dive, state->table);
|
record_dive_to_table(dive, state->log->dives);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1757,7 +1753,7 @@ static int parse_site_entry(struct git_parser_state *state, const git_tree_entry
|
||||||
if (*suffix == '\0')
|
if (*suffix == '\0')
|
||||||
return report_error("Dive site without uuid");
|
return report_error("Dive site without uuid");
|
||||||
uint32_t uuid = strtoul(suffix, NULL, 16);
|
uint32_t uuid = strtoul(suffix, NULL, 16);
|
||||||
state->active_site = alloc_or_get_dive_site(uuid, state->sites);
|
state->active_site = alloc_or_get_dive_site(uuid, state->log->sites);
|
||||||
git_blob *blob = git_tree_entry_blob(state->repo, entry);
|
git_blob *blob = git_tree_entry_blob(state->repo, entry);
|
||||||
if (!blob)
|
if (!blob)
|
||||||
return report_error("Unable to read dive site file");
|
return report_error("Unable to read dive site file");
|
||||||
|
@ -1833,7 +1829,7 @@ static int parse_filter_preset(struct git_parser_state *state, const git_tree_en
|
||||||
|
|
||||||
git_blob_free(blob);
|
git_blob_free(blob);
|
||||||
|
|
||||||
add_filter_preset_to_table(state->active_filter, state->filter_presets);
|
add_filter_preset_to_table(state->active_filter, state->log->filter_presets);
|
||||||
free_filter_preset(state->active_filter);
|
free_filter_preset(state->active_filter);
|
||||||
state->active_filter = NULL;
|
state->active_filter = NULL;
|
||||||
|
|
||||||
|
@ -1967,11 +1963,7 @@ int git_load_dives(struct git_info *info, struct divelog *log)
|
||||||
int ret;
|
int ret;
|
||||||
struct git_parser_state state = { 0 };
|
struct git_parser_state state = { 0 };
|
||||||
state.repo = info->repo;
|
state.repo = info->repo;
|
||||||
state.table = log->dives;
|
state.log = log;
|
||||||
state.trips = log->trips;
|
|
||||||
state.sites = log->sites;
|
|
||||||
state.devices = log->devices;
|
|
||||||
state.filter_presets = log->filter_presets;
|
|
||||||
|
|
||||||
if (!info->repo)
|
if (!info->repo)
|
||||||
return report_error("Unable to open git repository '%s[%s]'", info->url, info->branch);
|
return report_error("Unable to open git repository '%s[%s]'", info->url, info->branch);
|
||||||
|
|
Loading…
Reference in a new issue