diff options
author | Andrew Moss <1043609+amoss@users.noreply.github.com> | 2019-12-16 15:12:00 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-16 15:12:00 +0100 |
commit | c8c72f18a6a8fd09d3b6284e49525396b24e8395 (patch) | |
tree | 5b9aeaea7d72e1d1029d45f67c0a5f130ecc2f80 /libnetdata/inlined.h | |
parent | c4bb3d2642ab34e6aca912b22e55aed52f84e974 (diff) |
Labels issues (#7515)
Initial work on host labels from the dedicated branch. Includes work for issues #7096, #7400, #7411, #7369, #7410, #7458, #7459, #7412 and #7408 by @vlvkobal, @thiagoftsm, @cakrit and @amoss.
Diffstat (limited to 'libnetdata/inlined.h')
-rw-r--r-- | libnetdata/inlined.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/libnetdata/inlined.h b/libnetdata/inlined.h index 6a5994c12a..330b65648e 100644 --- a/libnetdata/inlined.h +++ b/libnetdata/inlined.h @@ -246,6 +246,20 @@ static inline char *strncpyz(char *dst, const char *src, size_t n) { return p; } +static inline void escape_json_string(char *dst, char *src, size_t len) { + while (*src != '\0' && len > 1) { + if (*src == '\\' || *src == '\"' || *src < 0x1F) { + *dst++ = '\\'; + *dst++ = *src++; + len -= 2; + } else { + *dst++ = *src++; + len--; + } + } + *dst = '\0'; +} + static inline int read_file(const char *filename, char *buffer, size_t size) { if(unlikely(!size)) return 3; |