diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2015-02-12 00:14:50 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-02-12 11:19:27 -0800 |
commit | 05948530e94096c47a517f709cee0e74794530ab (patch) | |
tree | e54673ce83c21746a88aad938cfec1b55dc6303b /save-git.c | |
parent | 4b15b9dfe910fd0df63bdc8024a919a566c380be (diff) | |
download | subsurface-05948530e94096c47a517f709cee0e74794530ab.tar.gz |
Save and load dive sites in git format
Update the version to 3.
Continue to read version 2 files and create dive sites on the fly.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'save-git.c')
-rw-r--r-- | save-git.c | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/save-git.c b/save-git.c index 6c2587bf8..764805d03 100644 --- a/save-git.c +++ b/save-git.c @@ -104,8 +104,6 @@ static void show_utf8(struct membuffer *b, const char *prefix, const char *value static void save_overview(struct membuffer *b, struct dive *dive) { - show_gps(b, dive->latitude, dive->longitude); - show_utf8(b, "location ", dive->location, "\n"); show_utf8(b, "divemaster ", dive->divemaster, "\n"); show_utf8(b, "buddy ", dive->buddy, "\n"); show_utf8(b, "suit ", dive->suit, "\n"); @@ -390,6 +388,7 @@ static void create_dive_buffer(struct dive *dive, struct membuffer *b) SAVE("visibility", visibility); cond_put_format(dive->tripflag == NO_TRIP, b, "notrip\n"); save_tags(b, dive->tag_list); + cond_put_format(dive->dive_site_uuid, b, "divesiteid %8x\n", dive->dive_site_uuid); save_overview(b, dive); save_cylinder_info(b, dive); @@ -804,7 +803,7 @@ static void save_one_device(void *_b, const char *model, uint32_t deviceid, put_string(b, "\n"); } -#define VERSION 2 +#define VERSION 3 static void save_settings(git_repository *repo, struct dir *tree) { @@ -818,6 +817,27 @@ static void save_settings(git_repository *repo, struct dir *tree) blob_insert(repo, tree, &b, "00-Subsurface"); } +static void save_divesites(git_repository *repo, struct dir *tree) +{ + struct dir *subdir; + struct membuffer dirname = { 0 }; + put_format(&dirname, "01-Divesites"); + subdir = new_directory(repo, tree, &dirname); + + for (int i = 0; i < dive_site_table.nr; i++) { + struct membuffer b = { 0 }; + struct dive_site *ds = get_dive_site(i); + int size = sizeof("Site-012345678"); + char name[size]; + snprintf(name, size, "Site-%8x", ds->uuid); + show_utf8(&b, "name ", ds->name, "\n"); + show_utf8(&b, "description ", ds->description, "\n"); + show_utf8(&b, "notes ", ds->notes, "\n"); + show_gps(&b, ds->latitude, ds->longitude); + blob_insert(repo, subdir, &b, name); + } +} + static int create_git_tree(git_repository *repo, struct dir *root, bool select_only) { int i; @@ -826,6 +846,8 @@ static int create_git_tree(git_repository *repo, struct dir *root, bool select_o save_settings(repo, root); + save_divesites(repo, root); + for (trip = dive_trip_list; trip != NULL; trip = trip->next) trip->index = 0; |