|
|
@@ -2411,6 +2411,33 @@ char *format_unit(char *buf, bool floatprec, const char *measurement, enum h2bs_
|
|
|
}
|
|
|
#define hashrate_to_bufstr(buf, hashrate, unitin, fmt) format_unit(buf, true, "h/s", fmt, hashrate, unitin)
|
|
|
|
|
|
+static
|
|
|
+char *_multi_format_unit(char *bufin, bool floatprec, const char *measurement, enum h2bs_fmt fmt, const char *delim, int count, const float *numbers)
|
|
|
+{
|
|
|
+ unsigned char unit = 0;
|
|
|
+ int i;
|
|
|
+ size_t delimsz = strlen(delim);
|
|
|
+ char *buf = bufin;
|
|
|
+
|
|
|
+ for (i = 0; i < count; ++i)
|
|
|
+ pick_unit(numbers[i], &unit);
|
|
|
+
|
|
|
+ --count;
|
|
|
+ for (i = 0; i < count; ++i)
|
|
|
+ {
|
|
|
+ format_unit(buf, floatprec, NULL, H2B_NOUNIT, numbers[i], unit);
|
|
|
+ buf += strlen(buf);
|
|
|
+ memcpy(buf, delim, delimsz);
|
|
|
+ buf += delimsz;
|
|
|
+ }
|
|
|
+
|
|
|
+ // Last entry has the unit
|
|
|
+ format_unit(buf, floatprec, measurement, fmt, numbers[count], unit);
|
|
|
+
|
|
|
+ return bufin;
|
|
|
+}
|
|
|
+#define multi_format_unit(buf, floatprec, measurement, fmt, delim, count, ...) _multi_format_unit(buf, floatprec, measurement, fmt, delim, count, (float[]){ __VA_ARGS__ })
|
|
|
+
|
|
|
static void
|
|
|
ti_hashrate_bufstr(char**out, float current, float average, float sharebased, enum h2bs_fmt longfmt)
|
|
|
{
|