aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/gas.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gas.c')
-rw-r--r--src/gas.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/gas.c b/src/gas.c
new file mode 100644
index 0000000..c59db2c
--- /dev/null
+++ b/src/gas.c
@@ -0,0 +1,42 @@
+/* SPDX-License-Identifier: MIT-0 */
+
+#include <assert.h>
+
+#include "gas.h"
+
+double PO2_MAX = PO2_MAX_DEFAULT;
+
+gas_t gas_new(unsigned char o2, unsigned char he, double mod)
+{
+ assert(o2 + he <= 100);
+
+ if (mod == MOD_AUTO)
+ mod = PO2_MAX / (o2 / 100.0);
+
+ return (gas_t){.o2 = o2, .he = he, .n2 = 100 - o2 - he, .mod = mod};
+}
+
+int gas_equal(const gas_t *g1, const gas_t *g2)
+{
+ return g1->o2 == g2->o2 && g1->he == g2->he && g1->mod == g2->mod;
+}
+
+unsigned char gas_o2(const gas_t *gas)
+{
+ return gas->o2;
+}
+
+unsigned char gas_he(const gas_t *gas)
+{
+ return gas->he;
+}
+
+unsigned char gas_n2(const gas_t *gas)
+{
+ return gas->n2;
+}
+
+double gas_mod(const gas_t *gas)
+{
+ return gas->mod;
+}