+/*
+ * We keep our internal data in well-specified units, but
+ * the input and output may come in some random format. This
+ * keeps track of those units.
+ */
+struct units {
+ enum { METERS, FEET } length;
+ enum { LITER, CUFT } volume;
+ enum { BAR, PSI, PASCAL } pressure;
+ enum { CELSIUS, FAHRENHEIT, KELVIN } temperature;
+ enum { KG, LBS } weight;
+};
+
+extern const struct units SI_units, IMPERIAL_units;
+extern struct units input_units, output_units;
+
+extern int verbose;
+
+struct dive_table {
+ int nr, allocated;
+ struct dive **dives;
+};
+
+extern struct dive_table dive_table;
+
+extern int selected_dive;
+#define current_dive (get_dive(selected_dive))
+
+static inline struct dive *get_dive(unsigned int nr)
+{
+ if (nr >= dive_table.nr)
+ return NULL;
+ return dive_table.dives[nr];
+}
+
+extern void parse_xml_init(void);
+extern void parse_xml_file(const char *filename, GError **error);
+
+extern void show_dive_info(struct dive *);
+extern void flush_dive_info_changes(struct dive *);
+
+extern void show_dive_equipment(struct dive *);
+extern void flush_dive_equipment_changes(struct dive *);
+
+extern void update_dive(struct dive *new_dive);
+extern void save_dives(const char *filename);
+
+static inline unsigned int dive_size(int samples)
+{
+ return sizeof(struct dive) + samples*sizeof(struct sample);
+}
+
+extern time_t utc_mktime(struct tm *tm);
+
+extern struct dive *alloc_dive(void);
+extern void record_dive(struct dive *dive);
+
+extern struct sample *prepare_sample(struct dive **divep);
+extern void finish_sample(struct dive *dive, struct sample *sample);
+
+extern void report_dives(void);
+extern struct dive *fixup_dive(struct dive *dive);
+extern struct dive *try_to_merge(struct dive *a, struct dive *b);
+
+extern void update_air_info(char *buffer);
+
+#define DIVE_ERROR_PARSE 1
+