summaryrefslogtreecommitdiffstats
path: root/dive.h
diff options
context:
space:
mode:
authorGravatar Maximilian Güntner <maximilian.guentner@gmail.com>2013-11-02 02:12:42 +0100
committerGravatar Maximilian Güntner <maximilian.guentner@gmail.com>2013-11-02 02:55:03 +0100
commit6fe8cb652191728586f3731dcf6688b5a5b3efbb (patch)
treed579741fecbde7d5c9b66926fcdc40467dcfb480 /dive.h
parent2ef80930ff4ac15c7d68e7b3b8935c2121029fd3 (diff)
downloadsubsurface-6fe8cb652191728586f3731dcf6688b5a5b3efbb.tar.gz
Replaced the tag implementation
The new implementation supports custom tags which are provided by the user as well as default tags which are provided by subsurface. Default tags can be translated and will be written to XML in their non-localized form. Signed-off-by: Maximilian Güntner <maximilian.guentner@gmail.com>
Diffstat (limited to 'dive.h')
-rw-r--r--dive.h69
1 files changed, 40 insertions, 29 deletions
diff --git a/dive.h b/dive.h
index 3724cef29..89ea73df3 100644
--- a/dive.h
+++ b/dive.h
@@ -59,34 +59,6 @@ typedef int bool;
#define SEAWATER_SALINITY 10300
#define FRESHWATER_SALINITY 10000
-/* Dive tag definitions */
-#define DTAG_INVALID (1 << 0)
-#define DTAG_BOAT (1 << 1)
-#define DTAG_SHORE (1 << 2)
-#define DTAG_DRIFT (1 << 3)
-#define DTAG_DEEP (1 << 4)
-#define DTAG_CAVERN (1 << 5)
-#define DTAG_ICE (1 << 6)
-#define DTAG_WRECK (1 << 7)
-#define DTAG_CAVE (1 << 8)
-#define DTAG_ALTITUDE (1 << 9)
-#define DTAG_POOL (1 << 10)
-#define DTAG_LAKE (1 << 11)
-#define DTAG_RIVER (1 << 12)
-#define DTAG_NIGHT (1 << 13)
-#define DTAG_FRESH (1 << 14)
-#define DTAG_FRESH_NR 14
-#define DTAG_STUDENT (1 << 15)
-#define DTAG_INSTRUCTOR (1 << 16)
-#define DTAG_PHOTO (1 << 17)
-#define DTAG_VIDEO (1 << 18)
-#define DTAG_DECO (1 << 19)
-#define DTAG_NR 20
-/* defined in statistics.c */
-extern char *dtag_names[DTAG_NR];
-extern int dtag_shown[DTAG_NR];
-extern int dive_mask;
-
/*
* Some silly typedefs to make our units very explicit.
*
@@ -309,6 +281,45 @@ struct sample {
int po2;
};
+struct divetag {
+ /*
+ * The name of the divetag. If a translation is available, name contains
+ * the translated tag
+ */
+ char *name;
+ /*
+ * If a translation is available, we write the original tag to source.
+ * This enables us to write a non-localized tag to the xml file.
+ */
+ char *source;
+};
+
+struct tag_entry {
+ struct divetag *tag;
+ struct tag_entry *next;
+};
+
+/*
+ * divetags are only stored once, each dive only contains
+ * a list of tag_entries which then point to the divetags
+ * in the global g_tag_list
+ */
+
+extern struct tag_entry *g_tag_list;
+
+struct divetag *taglist_add_tag(struct tag_entry *tag_list, const char *tag);
+
+/*
+ * Writes all divetags in tag_list to buffer, limited by the buffer's (len)gth.
+ * Returns the characters written
+ */
+int taglist_get_tagstring(struct tag_entry *tag_list, char *buffer, int len);
+
+void taglist_init(struct tag_entry **tag_list);
+void taglist_clear(struct tag_entry *tag_list);
+void taglist_init_global();
+
+
/*
* Events are currently pretty meaningless. This is
* just based on the random data that libdivecomputer
@@ -399,7 +410,7 @@ struct dive {
pressure_t surface_pressure;
duration_t duration;
int salinity; // kg per 10000 l
- int dive_tags;
+ struct tag_entry *tag_list;
struct divecomputer dc;
};