+ if (temp.mkelvin)
+ show_milli(f, pre, temp.mkelvin - 273150, " C", post);
+}
+
+static void show_depth(FILE *f, depth_t depth, const char *pre, const char *post)
+{
+ if (depth.mm)
+ show_milli(f, pre, depth.mm, " m", post);
+}
+
+static void show_duration(FILE *f, duration_t duration, const char *pre, const char *post)
+{
+ if (duration.seconds)
+ fprintf(f, "%s%u:%02u min%s", pre, FRACTION(duration.seconds, 60), post);
+}
+
+static void show_pressure(FILE *f, pressure_t pressure, const char *pre, const char *post)
+{
+ if (pressure.mbar)
+ show_milli(f, pre, pressure.mbar, " bar", post);
+}
+
+/*
+ * We're outputting utf8 in xml.
+ * We need to quote the characters <, >, &.
+ *
+ * Technically I don't think we'd necessarily need to quote the control
+ * characters, but at least libxml2 doesn't like them. It doesn't even
+ * allow them quoted. So we just skip them and replace them with '?'.
+ *
+ * Nothing else (and if we ever do this using attributes, we'd need to
+ * quote the quotes we use too).
+ */
+static void quote(FILE *f, const char *text)
+{
+ const char *p = text;
+
+ for (;;) {
+ const char *escape;
+
+ switch (*p++) {
+ default:
+ continue;
+ case 0:
+ escape = NULL;
+ break;
+ case 1 ... 8:
+ case 11: case 12:
+ case 14 ... 31:
+ escape = "?";
+ break;
+ case '<':
+ escape = "<";
+ break;
+ case '>':
+ escape = ">";
+ break;
+ case '&':
+ escape = "&";
+ break;