From 28093ae957548d5fc1e4d373ca0a345cc1be5069 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sun, 1 Jun 2014 20:56:29 -0700 Subject: Remove is_air() and convert its users to gasmix Also make gasname() and get_gas_string() global functions (which allows us to delete code elsewhere). Signed-off-by: Dirk Hohndel --- equipment.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'equipment.c') diff --git a/equipment.c b/equipment.c index a67df68a4..1dd3c3f9d 100644 --- a/equipment.c +++ b/equipment.c @@ -97,6 +97,24 @@ bool cylinder_is_used(struct dive *d, cylinder_t *cyl) return false; } +void get_gas_string(const struct gasmix *gasmix, char *text, int len) +{ + if (gasmix_is_air(gasmix)) + snprintf(text, len, "%s", translate("gettextFromC", "air")); + else if (get_he(gasmix) == 0) + snprintf(text, len, translate("gettextFromC", "EAN%d"), (get_o2(gasmix) + 5) / 10); + else + snprintf(text, len, "(%d/%d)", (get_o2(gasmix) + 5) / 10, (get_he(gasmix) + 5) / 10); +} + +/* Returns a static char buffer - only good for immediate use by printf etc */ +const char *gasname(const struct gasmix *gasmix) +{ + static char gas[64]; + get_gas_string(gasmix, gas, sizeof(gas)); + return gas; +} + bool weightsystem_none(void *_data) { weightsystem_t *ws = _data; -- cgit v1.2.3-70-g09d2