6 static void doIndent(
int idt,
char **o,
const char *
tab) {
9 for (
i = 0;
i < idt;
i++) {
10 for (
x = (
char *)
tab; *
x;
x++) {
16 #define EMIT_ESC(s, code) \
19 const char *p = code; \
46 const char *words[
DSZ] = {
NULL };
47 int lengths[
DSZ] = { 0 };
48 int indexs[
DSZ] = { 0 };
56 int osz = (1 + strlen(
s)) * 20;
61 const char *str_a =
NULL;
66 ut64 cur = str_a - os;
71 words[indent - 1] = str_a;
72 lengths[indent - 1] =
s - str_a;
73 indexs[indent - 1] = 0;
83 if (*
s ==
'\n' || *
s ==
'\r' || *
s ==
'\t' || *
s ==
' ') {
93 indexs[indent - 1] = arrpos;
94 lengths[indent - 1] = (
s - os);
105 eprintf(
"JSON indentation is too deep\n");
122 for (
i = 0;
i <
DSZ &&
i < indent;
i++) {
123 if ((
int)(
size_t)words[
i] <
DSZ) {
124 ut64 cur = lengths[
i];
134 ut64 cur = words[
i] - os - 1;
143 char *q = strchr(
a,
'"');
157 const char *
tab =
" ";
158 const int indentSize = strlen(
tab);
164 int osz = (1 + strlen(
s)) * 20;
174 for (o =
O; *
s;
s++) {
175 if (o + (indent * indentSize) + 10 > OE) {
177 osz += 0x1000 + (indent * indentSize);
194 }
else if (
s[0] ==
'\\' &&
s[1] ==
'"') {
205 if (
s[0] !=
'{' &&
s[0] !=
'[') {
214 if (*
s ==
'\n' || *
s ==
'\r' || *
s ==
'\t' || *
s ==
' ') {
229 *o++ = (indent != -1) ?
'\n' :
' ';
232 eprintf(
"JSON indentation is too deep\n");
256 const int indentSize = strlen(
tab);
258 bool isValue =
false;
264 int osz = (1 + strlen(
s)) * 20;
274 for (o =
O; *
s;
s++) {
275 if (o + (indent * indentSize) + 10 > OE) {
277 osz += 0x1000 + (indent * indentSize);
294 }
else if (
s[0] ==
'\\' &&
s[1] ==
'"') {
312 if (
s[0] !=
'{' &&
s[0] !=
'[') {
313 if (*
s ==
'\n' || *
s ==
'\r' || *
s ==
'\t' || *
s ==
' ') {
331 if (!strncmp(
s,
"true", 4)) {
333 }
else if (!strncmp(
s,
"false", 5)) {
350 *o++ = (indent != -1) ?
'\n' :
' ';
352 eprintf(
"JSON indentation is too deep\n");
RZ_API void Ht_() free(HtName_(Ht) *ht)
static void doIndent(int idt, char **o, const char *tab)
RZ_API char * rz_print_json_indent(const char *s, bool color, const char *tab, const char **palette)
RZ_API char * rz_print_json_path(const char *s, int pos)
RZ_API char * rz_print_json_human(const char *s)
static const char * origColors[]
#define EMIT_ESC(s, code)
void * realloc(void *ptr, size_t size)
void * malloc(size_t size)
RZ_API char * rz_str_ndup(RZ_NULLABLE const char *ptr, int len)
Create new copy of string ptr limited to size len.
RZ_API const char * rz_str_trim_head_ro(const char *str)
ut64(WINAPI *w32_GetEnabledXStateFeatures)()