11 int_least8_t size_offset;
13 if (iter->index >= iter->descriptor->field_count) {
17 word0 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index]);
18 iter->type = (pb_type_t)((word0 >> 8) & 0xFF);
24 iter->tag = (pb_size_t)((word0 >> 2) & 0x3F);
25 size_offset = (int_least8_t)((word0 >> 24) & 0x0F);
26 data_offset = (word0 >> 16) & 0xFF;
27 iter->data_size = (pb_size_t)((word0 >> 28) & 0x0F);
33 uint32_t word1 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 1]);
35 iter->array_size = (pb_size_t)((word0 >> 16) & 0x0FFF);
36 iter->tag = (pb_size_t)(((word0 >> 2) & 0x3F) | ((word1 >> 28) << 6));
37 size_offset = (int_least8_t)((word0 >> 28) & 0x0F);
38 data_offset = word1 & 0xFFFF;
39 iter->data_size = (pb_size_t)((word1 >> 16) & 0x0FFF);
45 uint32_t word1 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 1]);
46 uint32_t word2 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 2]);
47 uint32_t word3 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 3]);
49 iter->array_size = (pb_size_t)(word0 >> 16);
50 iter->tag = (pb_size_t)(((word0 >> 2) & 0x3F) | ((word1 >> 8) << 6));
51 size_offset = (int_least8_t)(word1 & 0xFF);
53 iter->data_size = (pb_size_t)word3;
59 uint32_t word1 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 1]);
60 uint32_t word2 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 2]);
61 uint32_t word3 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 3]);
62 uint32_t word4 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 4]);
64 iter->array_size = (pb_size_t)word4;
65 iter->tag = (pb_size_t)(((word0 >> 2) & 0x3F) | ((word1 >> 8) << 6));
66 size_offset = (int_least8_t)(word1 & 0xFF);
68 iter->data_size = (pb_size_t)word3;
78 iter->pField = (
char *)iter->message + data_offset;
81 iter->pSize = (
char *)iter->pField - size_offset;
82 }
else if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED &&
83 (PB_ATYPE(iter->type) == PB_ATYPE_STATIC ||
84 PB_ATYPE(iter->type) == PB_ATYPE_POINTER)) {
86 iter->pSize = &iter->array_size;
91 if (PB_ATYPE(iter->type) == PB_ATYPE_POINTER && iter->pField != NULL) {
92 iter->pData = *(
void **)iter->pField;
94 iter->pData = iter->pField;
98 if (PB_LTYPE_IS_SUBMSG(iter->type)) {
99 iter->submsg_desc = iter->descriptor->submsg_info[iter->submessage_index];
101 iter->submsg_desc = NULL;
110 if (iter->index >= iter->descriptor->field_count) {
113 iter->field_info_index = 0;
114 iter->submessage_index = 0;
115 iter->required_field_index = 0;
123 uint32_t prev_descriptor = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index]);
124 pb_type_t prev_type = (prev_descriptor >> 8) & 0xFF;
125 pb_size_t descriptor_len = (pb_size_t)(1 << (prev_descriptor & 3));
131 iter->field_info_index = (pb_size_t)(iter->field_info_index + descriptor_len);
132 iter->required_field_index = (pb_size_t)(iter->required_field_index + (PB_HTYPE(prev_type) == PB_HTYPE_REQUIRED));
133 iter->submessage_index = (pb_size_t)(iter->submessage_index + PB_LTYPE_IS_SUBMSG(prev_type));
138 memset(iter, 0,
sizeof(*iter));
140 iter->descriptor = desc;
141 iter->message = message;
143 return load_descriptor_values(iter);
150 uint32_t word0 = PB_PROGMEM_READU32(msg->field_info[0]);
152 if (PB_ATYPE(word0 >> 8) == PB_ATYPE_POINTER) {
156 status = pb_field_iter_begin(iter, msg, &extension->dest);
158 status = pb_field_iter_begin(iter, msg, extension->dest);
161 iter->pSize = &extension->found;
166 advance_iterator(iter);
167 (void)load_descriptor_values(iter);
168 return iter->index != 0;
172 if (iter->tag == tag) {
174 }
else if (tag > iter->descriptor->largest_tag) {
177 pb_size_t
start = iter->index;
180 if (tag < iter->tag) {
184 iter->index = iter->descriptor->field_count;
189 advance_iterator(iter);
192 fieldinfo = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index]);
194 if (((fieldinfo >> 2) & 0x3F) == (tag & 0x3F)) {
196 (void)load_descriptor_values(iter);
198 if (iter->tag == tag &&
199 PB_LTYPE(iter->type) != PB_LTYPE_EXTENSION) {
204 }
while (iter->index !=
start);
207 (void)load_descriptor_values(iter);
213 if (PB_LTYPE(iter->type) == PB_LTYPE_EXTENSION) {
216 pb_size_t
start = iter->index;
221 advance_iterator(iter);
224 fieldinfo = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index]);
226 if (PB_LTYPE((fieldinfo >> 8) & 0xFF) == PB_LTYPE_EXTENSION) {
227 return load_descriptor_values(iter);
229 }
while (iter->index !=
start);
232 (void)load_descriptor_values(iter);
237static void *pb_const_cast(
const void *p) {
250 return pb_field_iter_begin(iter, desc, pb_const_cast(message));
254 return pb_field_iter_begin_extension(iter, (
pb_extension_t *)pb_const_cast(extension));
261 if (pCallback != NULL) {
262 if (istream != NULL && pCallback->funcs.decode != NULL) {
263 return pCallback->funcs.decode(istream, field, &pCallback->arg);
266 if (ostream != NULL && pCallback->funcs.encode != NULL) {
267 return pCallback->funcs.encode(ostream, field, &pCallback->arg);
275#ifdef PB_VALIDATE_UTF8
284bool pb_validate_utf8(
const char *str) {
285 const pb_byte_t *s = (
const pb_byte_t *)str;
291 }
else if ((s[0] & 0xe0) == 0xc0) {
293 if ((s[1] & 0xc0) != 0x80 ||
294 (s[0] & 0xfe) == 0xc0) {
299 }
else if ((s[0] & 0xf0) == 0xe0) {
301 if ((s[1] & 0xc0) != 0x80 ||
302 (s[2] & 0xc0) != 0x80 ||
303 (s[0] == 0xe0 && (s[1] & 0xe0) == 0x80) ||
304 (s[0] == 0xed && (s[1] & 0xe0) == 0xa0) ||
305 (s[0] == 0xef && s[1] == 0xbf &&
306 (s[2] & 0xfe) == 0xbe)) {
311 }
else if ((s[0] & 0xf8) == 0xf0) {
313 if ((s[1] & 0xc0) != 0x80 ||
314 (s[2] & 0xc0) != 0x80 ||
315 (s[3] & 0xc0) != 0x80 ||
316 (s[0] == 0xf0 && (s[1] & 0xf0) == 0x80) ||
317 (s[0] == 0xf4 && s[1] > 0x8f) || s[0] > 0xf4) {
int start(int MCULIBHANDLE, struct sc_firmware_api *api)
this is called when the board powers up