summaryrefslogtreecommitdiffstats
path: root/libnetdata/buffer/buffer.h
diff options
context:
space:
mode:
Diffstat (limited to 'libnetdata/buffer/buffer.h')
-rw-r--r--libnetdata/buffer/buffer.h58
1 files changed, 42 insertions, 16 deletions
diff --git a/libnetdata/buffer/buffer.h b/libnetdata/buffer/buffer.h
index 0f1540287..26efe0070 100644
--- a/libnetdata/buffer/buffer.h
+++ b/libnetdata/buffer/buffer.h
@@ -97,7 +97,6 @@ typedef struct web_buffer {
#define buffer_no_cacheable(wb) do { (wb)->options |= WB_CONTENT_NO_CACHEABLE; if((wb)->options & WB_CONTENT_CACHEABLE) (wb)->options &= ~WB_CONTENT_CACHEABLE; (wb)->expires = 0; } while(0)
#define buffer_strlen(wb) ((wb)->len)
-const char *buffer_tostring(BUFFER *wb);
#define BUFFER_OVERFLOW_EOF "EOF"
@@ -158,6 +157,16 @@ void buffer_json_initialize(BUFFER *wb, const char *key_quote, const char *value
void buffer_json_finalize(BUFFER *wb);
+static const char *buffer_tostring(BUFFER *wb)
+{
+ buffer_need_bytes(wb, 1);
+ wb->buffer[wb->len] = '\0';
+
+ buffer_overflow_check(wb);
+
+ return(wb->buffer);
+}
+
static inline void _buffer_json_depth_push(BUFFER *wb, BUFFER_JSON_NODE_TYPE type) {
#ifdef NETDATA_INTERNAL_CHECKS
assert(wb->json.depth <= BUFFER_JSON_MAX_DEPTH && "BUFFER JSON: max nesting reached");
@@ -249,20 +258,25 @@ static inline void buffer_strcat(BUFFER *wb, const char *txt) {
buffer_overflow_check(wb);
}
+static inline void buffer_contents_replace(BUFFER *wb, const char *txt, size_t len) {
+ wb->len = 0;
+ buffer_need_bytes(wb, len + 1);
+
+ memcpy(wb->buffer, txt, len);
+ wb->len = len;
+ wb->buffer[wb->len] = '\0';
+
+ buffer_overflow_check(wb);
+}
+
static inline void buffer_strncat(BUFFER *wb, const char *txt, size_t len) {
if(unlikely(!txt || !*txt)) return;
- const char *t = txt;
buffer_need_bytes(wb, len + 1);
- char *s = &wb->buffer[wb->len];
- char *d = s;
- const char *e = &wb->buffer[wb->len + len];
- while(*t && d < e)
- *d++ = *t++;
-
- wb->len += d - s;
+ memcpy(&wb->buffer[wb->len], txt, len);
+ wb->len += len;
wb->buffer[wb->len] = '\0';
buffer_overflow_check(wb);
@@ -944,10 +958,12 @@ typedef enum __attribute__((packed)) {
RRDF_FIELD_OPTS_VISIBLE = (1 << 1), // the field should be visible by default
RRDF_FIELD_OPTS_STICKY = (1 << 2), // the field should be sticky
RRDF_FIELD_OPTS_FULL_WIDTH = (1 << 3), // the field should get full width
- RRDF_FIELD_OPTS_WRAP = (1 << 4), // the field should get full width
+ RRDF_FIELD_OPTS_WRAP = (1 << 4), // the field should wrap
+ RRDR_FIELD_OPTS_DUMMY = (1 << 5), // not a presentable field
} RRDF_FIELD_OPTIONS;
typedef enum __attribute__((packed)) {
+ RRDF_FIELD_TYPE_NONE,
RRDF_FIELD_TYPE_INTEGER,
RRDF_FIELD_TYPE_STRING,
RRDF_FIELD_TYPE_DETAIL_STRING,
@@ -960,6 +976,9 @@ typedef enum __attribute__((packed)) {
static inline const char *rrdf_field_type_to_string(RRDF_FIELD_TYPE type) {
switch(type) {
default:
+ case RRDF_FIELD_TYPE_NONE:
+ return "none";
+
case RRDF_FIELD_TYPE_INTEGER:
return "integer";
@@ -984,10 +1003,11 @@ static inline const char *rrdf_field_type_to_string(RRDF_FIELD_TYPE type) {
}
typedef enum __attribute__((packed)) {
- RRDF_FIELD_VISUAL_VALUE, // show the value, possibly applying a transformation
- RRDF_FIELD_VISUAL_BAR, // show the value and a bar, respecting the max field to fill the bar at 100%
- RRDF_FIELD_VISUAL_PILL, //
- RRDF_FIELD_VISUAL_MARKDOC, //
+ RRDF_FIELD_VISUAL_VALUE, // show the value, possibly applying a transformation
+ RRDF_FIELD_VISUAL_BAR, // show the value and a bar, respecting the max field to fill the bar at 100%
+ RRDF_FIELD_VISUAL_PILL, //
+ RRDF_FIELD_VISUAL_RICH, //
+ RRDR_FIELD_VISUAL_ROW_OPTIONS, // this is a dummy column that is used for row options
} RRDF_FIELD_VISUAL;
static inline const char *rrdf_field_visual_to_string(RRDF_FIELD_VISUAL visual) {
@@ -1002,8 +1022,11 @@ static inline const char *rrdf_field_visual_to_string(RRDF_FIELD_VISUAL visual)
case RRDF_FIELD_VISUAL_PILL:
return "pill";
- case RRDF_FIELD_VISUAL_MARKDOC:
- return "markdoc";
+ case RRDF_FIELD_VISUAL_RICH:
+ return "richValue";
+
+ case RRDR_FIELD_VISUAL_ROW_OPTIONS:
+ return "rowOptions";
}
}
@@ -1150,6 +1173,9 @@ buffer_rrdf_table_add_field(BUFFER *wb, size_t field_id, const char *key, const
buffer_json_member_add_boolean(wb, "full_width", options & RRDF_FIELD_OPTS_FULL_WIDTH);
buffer_json_member_add_boolean(wb, "wrap", options & RRDF_FIELD_OPTS_WRAP);
+
+ if(options & RRDR_FIELD_OPTS_DUMMY)
+ buffer_json_member_add_boolean(wb, "dummy", true);
}
buffer_json_object_close(wb);
}