static void save_cylinder_info(FILE *f, struct dive *dive) { int i; for (i = 0; i < MAX_CYLINDERS; i++) { cylinder_t *cylinder = dive->cylinder+i; int volume = cylinder->type.size.mliter; const char *description = cylinder->type.description; int o2 = cylinder->gasmix.o2.permille; int he = cylinder->gasmix.he.permille; int start = cylinder->start.mbar; int end = cylinder->end.mbar; /* No cylinder information at all? */ if (!o2 && !volume && !start && !end) return; fprintf(f, " <cylinder"); if (volume) show_milli(f, " size='", volume, " l", "'"); show_pressure(f, cylinder->type.workingpressure, " workpressure='", "'"); if (description && *description) fprintf(f, " description='%s'", description); if (o2) { fprintf(f, " o2='%u.%u%%'", FRACTION(o2, 10)); if (he) fprintf(f, " he='%u.%u%%'", FRACTION(he, 10)); } show_pressure(f, cylinder->start, " start='", "'"); show_pressure(f, cylinder->end, " end='", "'"); fprintf(f, " />\n"); } }
static void save_cylinder_info(FILE *f, struct dive *dive) { int i, nr; nr = nr_cylinders(dive); for (i = 0; i < nr; i++) { cylinder_t *cylinder = dive->cylinder+i; int volume = cylinder->type.size.mliter; const char *description = cylinder->type.description; int o2 = cylinder->gasmix.o2.permille; int he = cylinder->gasmix.he.permille; fprintf(f, " <cylinder"); if (volume) show_milli(f, " size='", volume, " l", "'"); show_pressure(f, cylinder->type.workingpressure, " workpressure='", "'"); if (description && *description) fprintf(f, " description='%s'", description); if (o2) { fprintf(f, " o2='%u.%u%%'", FRACTION(o2, 10)); if (he) fprintf(f, " he='%u.%u%%'", FRACTION(he, 10)); } show_pressure(f, cylinder->start, " start='", "'"); show_pressure(f, cylinder->end, " end='", "'"); fprintf(f, " />\n"); } }
static void save_sample(FILE *f, struct sample *sample) { fprintf(f, " <sample time='%u:%02u min'", FRACTION(sample->time.seconds,60)); show_milli(f, " depth='", sample->depth.mm, " m", "'"); show_temperature(f, sample->temperature, " temp='", "'"); show_pressure(f, sample->cylinderpressure, " pressure='", "'"); if (sample->cylinderindex) fprintf(f, " cylinderindex='%d'", sample->cylinderindex); fprintf(f, " />\n"); }
static void save_weightsystem_info(FILE *f, struct dive *dive) { int i; for (i = 0; i < MAX_WEIGHTSYSTEMS; i++) { weightsystem_t *ws = dive->weightsystem+i; int grams = ws->weight.grams; const char *description = ws->description; /* No weight information at all? */ if (grams == 0) return; fprintf(f, " <weightsystem"); show_milli(f, " weight='", grams, " kg", "'"); if (description && *description) fprintf(f, " description='%s'", description); fprintf(f, " />\n"); } }
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); }
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_temperature(FILE *f, temperature_t temp, const char *pre, const char *post) { if (temp.mkelvin) show_milli(f, pre, temp.mkelvin - 273150, " C", post); }