summaryrefslogtreecommitdiffstats
path: root/core/save-html.c
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-04-11 17:41:56 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-05-06 13:58:09 -0700
commit989d6a3f96b818e5eacc5a2ccb1cc82e6dd8354c (patch)
tree006daeb578ac4d3e68044ecfc36e7e12b1604ee8 /core/save-html.c
parent282041e228d4a60ff7108fbfd1fc23caffd59ba4 (diff)
downloadsubsurface-989d6a3f96b818e5eacc5a2ccb1cc82e6dd8354c.tar.gz
media: use table instead of linked list for media
For consistency with equipment, use our table macros for pictures. Generally tables (arrays) are preferred over linked lists, because they allow random access. This is mostly copy & paste of the equipment code. Sadly, our table macros are quite messy and need some revamping. Therefore, the resulting code is likewise somewhat messy. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core/save-html.c')
-rw-r--r--core/save-html.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/core/save-html.c b/core/save-html.c
index 5a01a6d2e..dd4bde130 100644
--- a/core/save-html.c
+++ b/core/save-html.c
@@ -28,23 +28,20 @@ void write_attribute(struct membuffer *b, const char *att_name, const char *valu
void save_photos(struct membuffer *b, const char *photos_dir, struct dive *dive)
{
- struct picture *pic = dive->picture_list;
-
- if (!pic)
+ if (dive->pictures.nr <= 0)
return;
char *separator = "\"photos\":[";
- do {
+ FOR_EACH_PICTURE(dive) {
put_string(b, separator);
separator = ", ";
- char *fname = get_file_name(local_file_path(pic));
+ char *fname = get_file_name(local_file_path(picture));
put_string(b, "{\"filename\":\"");
put_quoted(b, fname, 1, 0);
put_string(b, "\"}");
- copy_image_and_overwrite(local_file_path(pic), photos_dir, fname);
+ copy_image_and_overwrite(local_file_path(picture), photos_dir, fname);
free(fname);
- pic = pic->next;
- } while (pic);
+ }
put_string(b, "],");
}