diff options
author | Karel Zak | 2015-06-05 11:58:42 +0200 |
---|---|---|
committer | Karel Zak | 2015-06-05 11:58:42 +0200 |
commit | 6a768b55165f8b09bf95fc018b771261ddf64084 (patch) | |
tree | a4b8006ab8c0077ac67881f3865bd597aed01bec /include/carefulputc.h | |
parent | lslocks: add --json (diff) | |
download | kernel-qcow2-util-linux-6a768b55165f8b09bf95fc018b771261ddf64084.tar.gz kernel-qcow2-util-linux-6a768b55165f8b09bf95fc018b771261ddf64084.tar.xz kernel-qcow2-util-linux-6a768b55165f8b09bf95fc018b771261ddf64084.zip |
libsmartcols: keep JSON field names lower-case
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'include/carefulputc.h')
-rw-r--r-- | include/carefulputc.h | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/include/carefulputc.h b/include/carefulputc.h index 3a0ec5b66..681e66660 100644 --- a/include/carefulputc.h +++ b/include/carefulputc.h @@ -26,7 +26,7 @@ static inline int fputc_careful(int c, FILE *fp, const char fail) return (ret < 0) ? EOF : 0; } -static inline void fputs_quoted(const char *data, FILE *out) +static inline void fputs_quoted_case(const char *data, FILE *out, int dir) { const char *p; @@ -41,11 +41,17 @@ static inline void fputs_quoted(const char *data, FILE *out) fprintf(out, "\\x%02x", (unsigned char) *p); } else - fputc(*p, out); + fputc(dir == 1 ? toupper(*p) : + dir == -1 ? tolower(*p) : + *p, out); } fputc('"', out); } +#define fputs_quoted(_d, _o) fputs_quoted_case(_d, _o, 0) +#define fputs_quoted_upper(_d, _o) fputs_quoted_case(_d, _o, 1) +#define fputs_quoted_lower(_d, _o) fputs_quoted_case(_d, _o, -1) + static inline void fputs_nonblank(const char *data, FILE *out) { const char *p; |