13#include "cyclic_callback.pb.h"
19 if (*p ==
'[' || *p ==
'{') depth++;
20 if (*p ==
']' || *p ==
'}') depth--;
22 }
while (depth > 0 || (*p !=
',' && *p !=
'}'));
28 while (*p ==
' ') p++;
35 TreeNode tree = TreeNode_init_zero;
36 char *p = (
char*)*arg;
64 char *p = (
char*)*arg;
68 KeyValuePair pair = KeyValuePair_init_zero;
74 textlen =
strchr(p,
'\'') - p;
76 pair.key[textlen] = 0;
79 while (*p ==
' ') p++;
85 pair.treeValue.arg = p;
90 pair.has_stringValue =
true;
92 textlen =
strchr(p,
'\'') - p;
93 strncpy(pair.stringValue, p, textlen);
94 pair.stringValue[textlen] = 0;
99 pair.has_dictValue =
true;
101 pair.dictValue.dictItem.arg = p;
106 pair.has_intValue =
true;
107 pair.intValue =
atoi(p);
127 Dictionary dict = Dictionary_init_zero;
131 fprintf(
stderr,
"Usage: %s \"{'foobar': 1234, ...}\"\n",
argv[0]);
136 dict.dictItem.arg =
argv[1];
138 if (!
pb_encode(&stream, Dictionary_fields, &dict))
static bool encode_tree(pb_ostream_t *stream, const pb_field_t *field, void *const *arg)
static bool encode_dictionary(pb_ostream_t *stream, const pb_field_t *field, void *const *arg)
static char * find_end_of_item(char *p)
MOSAPI char * strchr(const char *s, int c)
MOSAPI char * strncpy(char *__restrict dest, const char *__restrict src, size_t n)
size_t fwrite(const void *__restrict ptr, size_t size, size_t nmemb, FILE *__restrict stream)
MOSAPI s32 atoi(const char *nptr)
#define PB_GET_ERROR(stream)
pb_field_iter_t pb_field_t
#define PB_RETURN_ERROR(stream, msg)
bool pb_encode_tag_for_field(pb_ostream_t *stream, const pb_field_iter_t *field)
bool pb_encode_submessage(pb_ostream_t *stream, const pb_msgdesc_t *fields, const void *src_struct)
pb_ostream_t pb_ostream_from_buffer(pb_byte_t *buf, size_t bufsize)
bool pb_encode(pb_ostream_t *stream, const pb_msgdesc_t *fields, const void *src_struct)