summaryrefslogtreecommitdiffstats
path: root/lib/qfstring.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/qfstring.h')
-rw-r--r--lib/qfstring.h30
1 files changed, 28 insertions, 2 deletions
diff --git a/lib/qfstring.h b/lib/qfstring.h
index be858899..98593685 100644
--- a/lib/qfstring.h
+++ b/lib/qfstring.h
@@ -25,6 +25,11 @@
#include "misc.h"
#include "vargs.h"
+#include <stddef.h>
+#include <stdint.h>
+
+#include "qtime.h"
+
/*==============================================================================
* These "qfstring" address the issues of dealing with *fixed* length
* strings, particularly where the string handling must be async-signal-safe.
@@ -76,7 +81,11 @@ enum pf_flags
pf_zeros = BIT( 3), /* "0" seen */
pf_alt = BIT( 4), /* "#" seen */
- pf_precision = BIT( 7), /* '.' seen */
+ pf_precision = 1 << 5, /* '.' seen */
+
+ /* For scaled formatting of decimals and byte counts */
+ pf_scale = 1 << 6,
+ pf_trailing = 1 << 7, /* add blank scale if required */
/* The following signal how to render the value */
pf_oct = BIT( 8), /* octal */
@@ -113,7 +122,6 @@ Inline uint qfs_left(qf_str qfs) ;
extern void qfs_append(qf_str qfs, const char* src) ;
extern void qfs_append_n(qf_str qfs, const char* src, uint n) ;
-
extern void qfs_append_ch_x_n(qf_str qfs, char ch, uint n) ;
extern void qfs_append_justified(qf_str qfs, const char* src, int width) ;
extern void qfs_append_justified_n(qf_str qfs, const char* src,
@@ -132,6 +140,24 @@ extern uint qfs_vprintf(qf_str qfs, const char *format, va_list args) ;
Inline uint qfs_strlen(const char* str) ;
+/* Construction of numbers from long
+ *
+ * Need enough space for groups of 3 decimal digits plus ',' or '\0', and an
+ * extra group for sign and some slack. For 64 bits comes out at 32 bytes !
+ */
+enum { qfs_number_len = (((64 + 9) / 10) + 1) * (3 + 1) } ;
+
+CONFIRM((sizeof(long) * 8) <= 64) ;
+
+typedef struct qfs_num_str_t
+{
+ char str[qfs_number_len] ;
+} qfs_num_str_t;
+
+extern qfs_num_str_t qfs_dec_value(long val, enum pf_flags flags) ;
+extern qfs_num_str_t qfs_bin_value(long val, enum pf_flags flags) ;
+extern qfs_num_str_t qfs_time_period(qtime_t val, enum pf_flags flags) ;
+
/*==============================================================================
* The Inline functions.
*/