diff options
Diffstat (limited to 'tizen/src')
-rw-r--r-- | tizen/src/distrib/protobuf/protobuf-c-private.h | 72 | ||||
-rw-r--r-- | tizen/src/distrib/protobuf/protobuf-c.c | 5815 | ||||
-rw-r--r-- | tizen/src/distrib/protobuf/protobuf-c.h | 1444 | ||||
-rw-r--r-- | tizen/src/ecs/genmsg/ecs.pb-c.c | 547 | ||||
-rw-r--r-- | tizen/src/ecs/genmsg/ecs.pb-c.h | 18 | ||||
-rw-r--r-- | tizen/src/ecs/genmsg/ecs_ids.pb-c.c | 11 | ||||
-rw-r--r-- | tizen/src/ecs/genmsg/ecs_ids.pb-c.h | 19 | ||||
-rw-r--r-- | tizen/src/eventcast/genmsg/eventcast.pb-c.c | 479 | ||||
-rw-r--r-- | tizen/src/eventcast/genmsg/eventcast.pb-c.h | 32 |
9 files changed, 5028 insertions, 3409 deletions
diff --git a/tizen/src/distrib/protobuf/protobuf-c-private.h b/tizen/src/distrib/protobuf/protobuf-c-private.h deleted file mode 100644 index 01bbd35aa5..0000000000 --- a/tizen/src/distrib/protobuf/protobuf-c-private.h +++ /dev/null @@ -1,72 +0,0 @@ -/* --- protobuf-c-private.h: private structures and functions --- */ -/* - * Copyright 2008, Dave Benson. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with - * the License. You may obtain a copy of the License - * at http://www.apache.org/licenses/LICENSE-2.0 Unless - * required by applicable law or agreed to in writing, - * software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - - -/* === needs to be declared for the PROTOBUF_C_BUFFER_SIMPLE_INIT macro === */ - -void protobuf_c_buffer_simple_append (ProtobufCBuffer *buffer, - size_t len, - const unsigned char *data); - -/* === stuff which needs to be declared for use in the generated code === */ - -struct _ProtobufCEnumValueIndex -{ - const char *name; - unsigned index; /* into values[] array */ -}; - -/* IntRange: helper structure for optimizing - int => index lookups - in the case where the keys are mostly consecutive values, - as they presumably are for enums and fields. - - The data structures assumes that the values in the original - array are sorted */ -struct _ProtobufCIntRange -{ - int start_value; - unsigned orig_index; - /* NOTE: the number of values in the range can - be inferred by looking at the next element's orig_index. - a dummy element is added to make this simple */ -}; - - -/* === declared for exposition on ProtobufCIntRange === */ -/* note: ranges must have an extra sentinel IntRange at the end whose - orig_index is set to the number of actual values in the original array */ -/* returns -1 if no orig_index found */ -int protobuf_c_int_ranges_lookup (unsigned n_ranges, - ProtobufCIntRange *ranges); - -#define PROTOBUF_C_SERVICE_DESCRIPTOR_MAGIC 0x14159bc3 -#define PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC 0x28aaeef9 -#define PROTOBUF_C_ENUM_DESCRIPTOR_MAGIC 0x114315af - -/* === behind the scenes on the generated service's __init functions */ -typedef void (*ProtobufCServiceDestroy) (ProtobufCService *service); -void -protobuf_c_service_generated_init (ProtobufCService *service, - const ProtobufCServiceDescriptor *descriptor, - ProtobufCServiceDestroy destroy); - -void -protobuf_c_service_invoke_internal(ProtobufCService *service, - unsigned method_index, - const ProtobufCMessage *input, - ProtobufCClosure closure, - void *closure_data); diff --git a/tizen/src/distrib/protobuf/protobuf-c.c b/tizen/src/distrib/protobuf/protobuf-c.c index d8d41b9305..5debac8208 100644 --- a/tizen/src/distrib/protobuf/protobuf-c.c +++ b/tizen/src/distrib/protobuf/protobuf-c.c @@ -1,2619 +1,3642 @@ -/* --- protobuf-c.c: public protobuf c runtime implementation --- */ - /* - * Copyright 2008, Dave Benson. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with - * the License. You may obtain a copy of the License - * at http://www.apache.org/licenses/LICENSE-2.0 Unless - * required by applicable law or agreed to in writing, - * software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. + * Copyright (c) 2008-2015, Dave Benson and the protobuf-c authors. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* TODO items: - * 64-BIT OPTIMIZATION: certain implementations use 32-bit math even on 64-bit platforms - (uint64_size, uint64_pack, parse_uint64) +/*! \file + * Support library for `protoc-c` generated code. + * + * This file implements the public API used by the code generated + * by `protoc-c`. + * + * \authors Dave Benson and the protobuf-c authors + * + * \copyright 2008-2014. Licensed under the terms of the [BSD-2-Clause] license. + */ - * get_packed_size and pack seem to use type-prefixed names, - whereas parse uses type-suffixed names. pick one and stick with it. - Decision: go with type-suffixed, since the type (or its instance) - is typically the object of the verb. - NOTE: perhaps the "parse" methods should be reanemd to "unpack" - at the same time. (this only affects internal (static) functions) +/** + * \todo 64-BIT OPTIMIZATION: certain implementations use 32-bit math + * even on 64-bit platforms (uint64_size, uint64_pack, parse_uint64). + * + * \todo Use size_t consistently. + */ - * use TRUE and FALSE instead of 1 and 0 as appropriate +#include <stdlib.h> /* for malloc, free */ +#include <string.h> /* for strcmp, strlen, memcpy, memmove, memset */ - * use size_t consistently - */ +#include "protobuf-c.h" -//#if HAVE_PROTOBUF_C_CONFIG_H -//#include "protobuf-c-config.h" -//#endif -#include <stdio.h> /* for occasional printf()s */ -#include <stdlib.h> /* for abort(), malloc() etc */ -#include <string.h> /* for strlen(), memcpy(), memmove() */ -//#if HAVE_ALLOCA_H -//#include <alloca.h> -//#elif HAVE_MALLOC_H -//#include <malloc.h> -//#endif - -// to use "alloca()" in Windows. -#ifdef __WIN32 -#include <malloc.h> -#endif +#define TRUE 1 +#define FALSE 0 + +#define PROTOBUF_C__ASSERT_NOT_REACHED() assert(0) -#ifndef PRINT_UNPACK_ERRORS -#define PRINT_UNPACK_ERRORS 1 +/* Workaround for Microsoft compilers. */ +#ifdef _MSC_VER +# define inline __inline #endif -#include "protobuf-c.h" +/** + * \defgroup internal Internal functions and macros + * + * These are not exported by the library but are useful to developers working + * on `libprotobuf-c` itself. + */ -#define MAX_UINT64_ENCODED_SIZE 10 - -/* convenience macros */ -#define TMPALLOC(allocator, size) ((allocator)->tmp_alloc ((allocator)->allocator_data, (size))) -#define FREE(allocator, ptr) \ - do { if ((ptr) != NULL) ((allocator)->free ((allocator)->allocator_data, (ptr))); } while(0) -#define UNALIGNED_ALLOC(allocator, size) ALLOC (allocator, size) /* placeholder */ -#define STRUCT_MEMBER_P(struct_p, struct_offset) \ - ((void *) ((uint8_t*) (struct_p) + (struct_offset))) -#define STRUCT_MEMBER(member_type, struct_p, struct_offset) \ - (*(member_type*) STRUCT_MEMBER_P ((struct_p), (struct_offset))) -#define STRUCT_MEMBER_PTR(member_type, struct_p, struct_offset) \ - ((member_type*) STRUCT_MEMBER_P ((struct_p), (struct_offset))) -#define TRUE 1 -#define FALSE 0 +/** + * \defgroup macros Utility macros for manipulating structures + * + * Macros and constants used to manipulate the base "classes" generated by + * `protobuf-c`. They also define limits and check correctness. + * + * \ingroup internal + * @{ + */ -static void -alloc_failed_warning (unsigned size, const char *filename, unsigned line) -{ - fprintf (stderr, - "WARNING: out-of-memory allocating a block of size %u (%s:%u)\n", - size, filename, line); -} +/** The maximum length of a 64-bit integer in varint encoding. */ +#define MAX_UINT64_ENCODED_SIZE 10 -/* Try to allocate memory, running some special code if it fails. */ -#define DO_ALLOC(dst, allocator, size, fail_code) \ -{ size_t da__allocation_size = (size); \ - if (da__allocation_size == 0) \ - dst = NULL; \ - else if ((dst=((allocator)->alloc ((allocator)->allocator_data, \ - da__allocation_size))) == NULL) \ - { \ - alloc_failed_warning (da__allocation_size, __FILE__, __LINE__); \ - fail_code; \ - } \ -} -#define DO_UNALIGNED_ALLOC DO_ALLOC /* placeholder */ +#ifndef PROTOBUF_C_UNPACK_ERROR +# define PROTOBUF_C_UNPACK_ERROR(...) +#endif + +const char protobuf_c_empty_string[] = ""; +/** + * Internal `ProtobufCMessage` manipulation macro. + * + * Base macro for manipulating a `ProtobufCMessage`. Used by STRUCT_MEMBER() and + * STRUCT_MEMBER_PTR(). + */ +#define STRUCT_MEMBER_P(struct_p, struct_offset) \ + ((void *) ((uint8_t *) (struct_p) + (struct_offset))) + +/** + * Return field in a `ProtobufCMessage` based on offset. + * + * Take a pointer to a `ProtobufCMessage` and find the field at the offset. + * Cast it to the passed type. + */ +#define STRUCT_MEMBER(member_type, struct_p, struct_offset) \ + (*(member_type *) STRUCT_MEMBER_P((struct_p), (struct_offset))) + +/** + * Return field in a `ProtobufCMessage` based on offset. + * + * Take a pointer to a `ProtobufCMessage` and find the field at the offset. Cast + * it to a pointer to the passed type. + */ +#define STRUCT_MEMBER_PTR(member_type, struct_p, struct_offset) \ + ((member_type *) STRUCT_MEMBER_P((struct_p), (struct_offset))) +/* Assertions for magic numbers. */ #define ASSERT_IS_ENUM_DESCRIPTOR(desc) \ - assert((desc)->magic == PROTOBUF_C_ENUM_DESCRIPTOR_MAGIC) + assert((desc)->magic == PROTOBUF_C__ENUM_DESCRIPTOR_MAGIC) + #define ASSERT_IS_MESSAGE_DESCRIPTOR(desc) \ - assert((desc)->magic == PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC) + assert((desc)->magic == PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC) + #define ASSERT_IS_MESSAGE(message) \ - ASSERT_IS_MESSAGE_DESCRIPTOR((message)->descriptor) + ASSERT_IS_MESSAGE_DESCRIPTOR((message)->descriptor) + #define ASSERT_IS_SERVICE_DESCRIPTOR(desc) \ - assert((desc)->magic == PROTOBUF_C_SERVICE_DESCRIPTOR_MAGIC) + assert((desc)->magic == PROTOBUF_C__SERVICE_DESCRIPTOR_MAGIC) -/* --- allocator --- */ +/**@}*/ + +/* --- version --- */ -static void protobuf_c_out_of_memory_default (void) +const char * +protobuf_c_version(void) { - fprintf (stderr, "Out Of Memory!!!\n"); - abort (); + return PROTOBUF_C_VERSION; } -void (*protobuf_c_out_of_memory) (void) = protobuf_c_out_of_memory_default; -static void *system_alloc(void *allocator_data, size_t size) +uint32_t +protobuf_c_version_number(void) { - void *rv; - (void) allocator_data; - if (size == 0) - return NULL; - rv = malloc (size); - if (rv == NULL) - protobuf_c_out_of_memory (); - return rv; + return PROTOBUF_C_VERSION_NUMBER; } -static void system_free (void *allocator_data, void *data) +/* --- allocator --- */ + +static void * +system_alloc(void *allocator_data, size_t size) { - (void) allocator_data; - if (data) - free (data); + return malloc(size); } -/* Some users may configure the default allocator; - providing your own allocator to unpack() is prefered. - this allocator is still used for packing nested messages. */ -ProtobufCAllocator protobuf_c_default_allocator = +static void +system_free(void *allocator_data, void *data) { - system_alloc, - system_free, - NULL, - 8192, - NULL -}; + free(data); +} -/* Users should NOT modify this structure, - but it's difficult to prevent. +static inline void * +do_alloc(ProtobufCAllocator *allocator, size_t size) +{ + return allocator->alloc(allocator->allocator_data, size); +} - please modify protobuf_c_default_allocator instead. */ -ProtobufCAllocator protobuf_c_system_allocator = +static inline void +do_free(ProtobufCAllocator *allocator, void *data) { - system_alloc, - system_free, - NULL, - 8192, - NULL + if (data != NULL) + allocator->free(allocator->allocator_data, data); +} + +/* + * This allocator uses the system's malloc() and free(). It is the default + * allocator used if NULL is passed as the ProtobufCAllocator to an exported + * function. + */ +static ProtobufCAllocator protobuf_c__allocator = { + .alloc = &system_alloc, + .free = &system_free, + .allocator_data = NULL, }; /* === buffer-simple === */ + void -protobuf_c_buffer_simple_append (ProtobufCBuffer *buffer, - size_t len, - const uint8_t *data) -{ - ProtobufCBufferSimple *simp = (ProtobufCBufferSimple *) buffer; - size_t new_len = simp->len + len; - if (new_len > simp->alloced) - { - size_t new_alloced = simp->alloced * 2; - uint8_t *new_data; - while (new_alloced < new_len) - new_alloced += new_alloced; - DO_ALLOC (new_data, &protobuf_c_default_allocator, new_alloced, return); - memcpy (new_data, simp->data, simp->len); - if (simp->must_free_data) - FREE (&protobuf_c_default_allocator, simp->data); - else - simp->must_free_data = 1; - simp->data = new_data; - simp->alloced = new_alloced; - } - memcpy (simp->data + simp->len, data, len); - simp->len = new_len; -} - -/* === get_packed_size() === */ - -/* Return the number of bytes required to store the - tag for the field (which includes 3 bits for - the wire-type, and a single bit that denotes the end-of-tag. */ +protobuf_c_buffer_simple_append(ProtobufCBuffer *buffer, + size_t len, const uint8_t *data) +{ + ProtobufCBufferSimple *simp = (ProtobufCBufferSimple *) buffer; + size_t new_len = simp->len + len; + + if (new_len > simp->alloced) { + ProtobufCAllocator *allocator = simp->allocator; + size_t new_alloced = simp->alloced * 2; + uint8_t *new_data; + + if (allocator == NULL) + allocator = &protobuf_c__allocator; + while (new_alloced < new_len) + new_alloced += new_alloced; + new_data = do_alloc(allocator, new_alloced); + if (!new_data) + return; + memcpy(new_data, simp->data, simp->len); + if (simp->must_free_data) + do_free(allocator, simp->data); + else + simp->must_free_data = TRUE; + simp->data = new_data; + simp->alloced = new_alloced; + } + memcpy(simp->data + simp->len, data, len); + simp->len = new_len; +} + +/** + * \defgroup packedsz protobuf_c_message_get_packed_size() implementation + * + * Routines mainly used by protobuf_c_message_get_packed_size(). + * + * \ingroup internal + * @{ + */ + +/** + * Return the number of bytes required to store the tag for the field. Includes + * 3 bits for the wire-type, and a single bit that denotes the end-of-tag. + * + * \param number + * Field tag to encode. + * \return + * Number of bytes required. + */ static inline size_t -get_tag_size (unsigned number) -{ - if (number < (1<<4)) - return 1; - else if (number < (1<<11)) - return 2; - else if (number < (1<<18)) - return 3; - else if (number < (1<<25)) - return 4; - else - return 5; -} - -/* Return the number of bytes required to store - a variable-length unsigned integer that fits in 32-bit uint - in base-128 encoding. */ +get_tag_size(uint32_t number) +{ + if (number < (1UL << 4)) { + return 1; + } else if (number < (1UL << 11)) { + return 2; + } else if (number < (1UL << 18)) { + return 3; + } else if (number < (1UL << 25)) { + return 4; + } else { + return 5; + } +} + +/** + * Return the number of bytes required to store a variable-length unsigned + * 32-bit integer in base-128 varint encoding. + * + * \param v + * Value to encode. + * \return + * Number of bytes required. + */ static inline size_t -uint32_size (uint32_t v) -{ - if (v < (1<<7)) - return 1; - else if (v < (1<<14)) - return 2; - else if (v < (1<<21)) - return 3; - else if (v < (1<<28)) - return 4; - else - return 5; -} -/* Return the number of bytes required to store - a variable-length signed integer that fits in 32-bit int - in base-128 encoding. */ +uint32_size(uint32_t v) +{ + if (v < (1UL << 7)) { + return 1; + } else if (v < (1UL << 14)) { + return 2; + } else if (v < (1UL << 21)) { + return 3; + } else if (v < (1UL << 28)) { + return 4; + } else { + return 5; + } +} + +/** + * Return the number of bytes required to store a variable-length signed 32-bit + * integer in base-128 varint encoding. + * + * \param v + * Value to encode. + * \return + * Number of bytes required. + */ static inline size_t -int32_size (int32_t v) -{ - if (v < 0) - return 10; - else if (v < (1<<7)) - return 1; - else if (v < (1<<14)) - return 2; - else if (v < (1<<21)) - return 3; - else if (v < (1<<28)) - return 4; - else - return 5; -} -/* return the zigzag-encoded 32-bit unsigned int from a 32-bit signed int */ +int32_size(int32_t v) +{ + if (v < 0) { + return 10; + } else if (v < (1L << 7)) { + return 1; + } else if (v < (1L << 14)) { + return 2; + } else if (v < (1L << 21)) { + return 3; + } else if (v < (1L << 28)) { + return 4; + } else { + return 5; + } +} + +/** + * Return the ZigZag-encoded 32-bit unsigned integer form of a 32-bit signed + * integer. + * + * \param v + * Value to encode. + * \return + * ZigZag encoded integer. + */ static inline uint32_t -zigzag32 (int32_t v) -{ - if (v < 0) - return ((uint32_t)(-v)) * 2 - 1; - else - return v * 2; -} -/* Return the number of bytes required to store - a variable-length signed integer that fits in 32-bit int, - converted to unsigned via the zig-zag algorithm, - then packed using base-128 encoding. */ +zigzag32(int32_t v) +{ + if (v < 0) + return (-(uint32_t)v) * 2 - 1; + else + return (uint32_t)(v) * 2; +} + +/** + * Return the number of bytes required to store a signed 32-bit integer, + * converted to an unsigned 32-bit integer with ZigZag encoding, using base-128 + * varint encoding. + * + * \param v + * Value to encode. + * \return + * Number of bytes required. + */ static inline size_t -sint32_size (int32_t v) +sint32_size(int32_t v) { - return uint32_size(zigzag32(v)); + return uint32_size(zigzag32(v)); } -/* Return the number of bytes required to store - a variable-length unsigned integer that fits in 64-bit uint - in base-128 encoding. */ +/** + * Return the number of bytes required to store a 64-bit unsigned integer in + * base-128 varint encoding. + * + * \param v + * Value to encode. + * \return + * Number of bytes required. + */ static inline size_t -uint64_size (uint64_t v) -{ - uint32_t upper_v = (uint32_t )(v>>32); - if (upper_v == 0) - return uint32_size ((uint32_t)v); - else if (upper_v < (1<<3)) - return 5; - else if (upper_v < (1<<10)) - return 6; - else if (upper_v < (1<<17)) - return 7; - else if (upper_v < (1<<24)) - return 8; - else if (upper_v < (1U<<31)) - return 9; - else - return 10; -} - -/* return the zigzag-encoded 64-bit unsigned int from a 64-bit signed int */ +uint64_size(uint64_t v) +{ + uint32_t upper_v = (uint32_t) (v >> 32); + + if (upper_v == 0) { + return uint32_size((uint32_t) v); + } else if (upper_v < (1UL << 3)) { + return 5; + } else if (upper_v < (1UL << 10)) { + return 6; + } else if (upper_v < (1UL << 17)) { + return 7; + } else if (upper_v < (1UL << 24)) { + return 8; + } else if (upper_v < (1UL << 31)) { + return 9; + } else { + return 10; + } +} + +/** + * Return the ZigZag-encoded 64-bit unsigned integer form of a 64-bit signed + * integer. + * + * \param v + * Value to encode. + * \return + * ZigZag encoded integer. + */ static inline uint64_t -zigzag64 (int64_t v) -{ - if (v < 0) - return ((uint64_t)(-v)) * 2 - 1; - else - return v * 2; -} - -/* Return the number of bytes required to store - a variable-length signed integer that fits in 64-bit int, - converted to unsigned via the zig-zag algorithm, - then packed using base-128 encoding. */ +zigzag64(int64_t v) +{ + if (v < 0) + return (-(uint64_t)v) * 2 - 1; + else + return (uint64_t)(v) * 2; +} + +/** + * Return the number of bytes required to store a signed 64-bit integer, + * converted to an unsigned 64-bit integer with ZigZag encoding, using base-128 + * varint encoding. + * + * \param v + * Value to encode. + * \return + * Number of bytes required. + */ static inline size_t -sint64_size (int64_t v) +sint64_size(int64_t v) { - return uint64_size(zigzag64(v)); + return uint64_size(zigzag64(v)); } -/* Get serialized size of a single field in the message, - including the space needed by the identifying tag. */ +/** + * Calculate the serialized size of a single required message field, including + * the space needed by the preceding tag. + * + * \param field + * Field descriptor for member. + * \param member + * Field to encode. + * \return + * Number of bytes required. + */ static size_t -required_field_get_packed_size (const ProtobufCFieldDescriptor *field, - const void *member) -{ - size_t rv = get_tag_size (field->id); - switch (field->type) - { - case PROTOBUF_C_TYPE_SINT32: - return rv + sint32_size (*(const int32_t *) member); - case PROTOBUF_C_TYPE_INT32: - return rv + int32_size (*(const uint32_t *) member); - case PROTOBUF_C_TYPE_UINT32: - return rv + uint32_size (*(const uint32_t *) member); - case PROTOBUF_C_TYPE_SINT64: - return rv + sint64_size (*(const int64_t *) member); - case PROTOBUF_C_TYPE_INT64: - case PROTOBUF_C_TYPE_UINT64: - return rv + uint64_size (*(const uint64_t *) member); - case PROTOBUF_C_TYPE_SFIXED32: - case PROTOBUF_C_TYPE_FIXED32: - return rv + 4; - case PROTOBUF_C_TYPE_SFIXED64: - case PROTOBUF_C_TYPE_FIXED64: - return rv + 8; - case PROTOBUF_C_TYPE_BOOL: - return rv + 1; - case PROTOBUF_C_TYPE_FLOAT: - return rv + 4; - case PROTOBUF_C_TYPE_DOUBLE: - return rv + 8; - case PROTOBUF_C_TYPE_ENUM: - // TODO: is this correct for negative-valued enums? - return rv + uint32_size (*(const uint32_t *) member); - case PROTOBUF_C_TYPE_STRING: - { - const char *str = *(char * const *) member; - size_t len = str ? strlen (str) : 0; - return rv + uint32_size (len) + len; - } - case PROTOBUF_C_TYPE_BYTES: - { - size_t len = ((const ProtobufCBinaryData*) member)->len; - return rv + uint32_size (len) + len; - } - //case PROTOBUF_C_TYPE_GROUP: - case PROTOBUF_C_TYPE_MESSAGE: - { - const ProtobufCMessage *msg = * (ProtobufCMessage * const *) member; - size_t subrv = msg ? protobuf_c_message_get_packed_size (msg) : 0; - return rv + uint32_size (subrv) + subrv; - } - } - PROTOBUF_C_ASSERT_NOT_REACHED (); - return 0; -} - -/* Get serialized size of a single optional field in the message, - including the space needed by the identifying tag. - Returns 0 if the optional field isn't set. */ +required_field_get_packed_size(const ProtobufCFieldDescriptor *field, + const void *member) +{ + size_t rv = get_tag_size(field->id); + + switch (field->type) { + case PROTOBUF_C_TYPE_SINT32: + return rv + sint32_size(*(const int32_t *) member); + case PROTOBUF_C_TYPE_ENUM: + case PROTOBUF_C_TYPE_INT32: + return rv + int32_size(*(const int32_t *) member); + case PROTOBUF_C_TYPE_UINT32: + return rv + uint32_size(*(const uint32_t *) member); + case PROTOBUF_C_TYPE_SINT64: + return rv + sint64_size(*(const int64_t *) member); + case PROTOBUF_C_TYPE_INT64: + case PROTOBUF_C_TYPE_UINT64: + return rv + uint64_size(*(const uint64_t *) member); + case PROTOBUF_C_TYPE_SFIXED32: + case PROTOBUF_C_TYPE_FIXED32: + return rv + 4; + case PROTOBUF_C_TYPE_SFIXED64: + case PROTOBUF_C_TYPE_FIXED64: + return rv + 8; + case PROTOBUF_C_TYPE_BOOL: + return rv + 1; + case PROTOBUF_C_TYPE_FLOAT: + return rv + 4; + case PROTOBUF_C_TYPE_DOUBLE: + return rv + 8; + case PROTOBUF_C_TYPE_STRING: { + const char *str = *(char * const *) member; + size_t len = str ? strlen(str) : 0; + return rv + uint32_size(len) + len; + } + case PROTOBUF_C_TYPE_BYTES: { + size_t len = ((const ProtobufCBinaryData *) member)->len; + return rv + uint32_size(len) + len; + } + case PROTOBUF_C_TYPE_MESSAGE: { + const ProtobufCMessage *msg = *(ProtobufCMessage * const *) member; + size_t subrv = msg ? protobuf_c_message_get_packed_size(msg) : 0; + return rv + uint32_size(subrv) + subrv; + } + } + PROTOBUF_C__ASSERT_NOT_REACHED(); + return 0; +} + +/** + * Calculate the serialized size of a single oneof message field, including + * the space needed by the preceding tag. Returns 0 if the oneof field isn't + * selected or is not set. + * + * \param field + * Field descriptor for member. + * \param oneof_case + * Enum value that selects the field in the oneof. + * \param member + * Field to encode. + * \return + * Number of bytes required. + */ static size_t -optional_field_get_packed_size (const ProtobufCFieldDescriptor *field, - const protobuf_c_boolean *has, - const void *member) -{ - if (field->type == PROTOBUF_C_TYPE_MESSAGE - || field->type == PROTOBUF_C_TYPE_STRING) - { - const void *ptr = * (const void * const *) member; - if (ptr == NULL - || ptr == field->default_value) - return 0; - } - else - { - if (!*has) - return 0; - } - return required_field_get_packed_size (field, member); -} - -/* Get serialized size of a repeated field in the message, - which may consist of any number of values (including 0). - Includes the space needed by the identifying tags (as needed). */ +oneof_field_get_packed_size(const ProtobufCFieldDescriptor *field, + uint32_t oneof_case, + const void *member) +{ + if (oneof_case != field->id) { + return 0; + } + if (field->type == PROTOBUF_C_TYPE_MESSAGE || + field->type == PROTOBUF_C_TYPE_STRING) + { + const void *ptr = *(const void * const *) member; + if (ptr == NULL || ptr == field->default_value) + return 0; + } + return required_field_get_packed_size(field, member); +} + +/** + * Calculate the serialized size of a single optional message field, including + * the space needed by the preceding tag. Returns 0 if the optional field isn't + * set. + * + * \param field + * Field descriptor for member. + * \param has + * True if the field exists, false if not. + * \param member + * Field to encode. + * \return + * Number of bytes required. + */ static size_t -repeated_field_get_packed_size (const ProtobufCFieldDescriptor *field, - size_t count, - const void *member) -{ - size_t header_size; - size_t rv = 0; - unsigned i; - void *array = * (void * const *) member; - if (count == 0) - return 0; - header_size = get_tag_size (field->id); - if (!field->packed) - header_size *= count; - switch (field->type) - { - case PROTOBUF_C_TYPE_SINT32: - for (i = 0; i < count; i++) - rv += sint32_size (((int32_t*)array)[i]); - break; - case PROTOBUF_C_TYPE_INT32: - for (i = 0; i < count; i++) - rv += int32_size (((uint32_t*)array)[i]); - break; - case PROTOBUF_C_TYPE_UINT32: - case PROTOBUF_C_TYPE_ENUM: - for (i = 0; i < count; i++) - rv += uint32_size (((uint32_t*)array)[i]); - break; - case PROTOBUF_C_TYPE_SINT64: - for (i = 0; i < count; i++) - rv += sint64_size (((int64_t*)array)[i]); - break; - case PROTOBUF_C_TYPE_INT64: - case PROTOBUF_C_TYPE_UINT64: - for (i = 0; i < count; i++) - rv += uint64_size (((uint64_t*)array)[i]); - break; - case PROTOBUF_C_TYPE_SFIXED32: - case PROTOBUF_C_TYPE_FIXED32: - case PROTOBUF_C_TYPE_FLOAT: - rv += 4 * count; - break; - case PROTOBUF_C_TYPE_SFIXED64: - case PROTOBUF_C_TYPE_FIXED64: - case PROTOBUF_C_TYPE_DOUBLE: - rv += 8 * count; - break; - case PROTOBUF_C_TYPE_BOOL: - rv += count; - break; - case PROTOBUF_C_TYPE_STRING: - for (i = 0; i < count; i++) - { - size_t len = strlen (((char**) array)[i]); - rv += uint32_size (len) + len; - } - break; - - case PROTOBUF_C_TYPE_BYTES: - for (i = 0; i < count; i++) - { - size_t len = ((ProtobufCBinaryData*) array)[i].len; - rv += uint32_size (len) + len; - } - break; - case PROTOBUF_C_TYPE_MESSAGE: - for (i = 0; i < count; i++) - { - size_t len = protobuf_c_message_get_packed_size (((ProtobufCMessage **) array)[i]); - rv += uint32_size (len) + len; - } - break; - //case PROTOBUF_C_TYPE_GROUP: // NOT SUPPORTED - } - if (field->packed) - header_size += uint32_size (rv); - return header_size + rv; -} - -/* Get the packed size of a unknown field (meaning one that - is passed through mostly uninterpreted... this is done - for forward compatibilty with the addition of new fields). */ -static inline size_t -unknown_field_get_packed_size (const ProtobufCMessageUnknownField *field) -{ - return get_tag_size (field->tag) + field->len; +optional_field_get_packed_size(const ProtobufCFieldDescriptor *field, + const protobuf_c_boolean has, + const void *member) +{ + if (field->type == PROTOBUF_C_TYPE_MESSAGE || + field->type == PROTOBUF_C_TYPE_STRING) + { + const void *ptr = *(const void * const *) member; + if (ptr == NULL || ptr == field->default_value) + return 0; + } else { + if (!has) + return 0; + } + return required_field_get_packed_size(field, member); } -/* Get the number of bytes that the message will occupy once serialized. */ -size_t -protobuf_c_message_get_packed_size(const ProtobufCMessage *message) -{ - unsigned i; - size_t rv = 0; - ASSERT_IS_MESSAGE (message); - for (i = 0; i < message->descriptor->n_fields; i++) - { - const ProtobufCFieldDescriptor *field = message->descriptor->fields + i; - const void *member = ((const char *) message) + field->offset; - const void *qmember = ((const char *) message) + field->quantifier_offset; - - if (field->label == PROTOBUF_C_LABEL_REQUIRED) - rv += required_field_get_packed_size (field, member); - else if (field->label == PROTOBUF_C_LABEL_OPTIONAL) - rv += optional_field_get_packed_size (field, qmember, member); - else - rv += repeated_field_get_packed_size (field, * (const size_t *) qmember, member); - } - for (i = 0; i < message->n_unknown_fields; i++) - rv += unknown_field_get_packed_size (&message->unknown_fields[i]); - return rv; -} -/* === pack() === */ -/* Pack an unsigned 32-bit integer in base-128 encoding, and return the number of bytes needed: - this will be 5 or less. */ +static protobuf_c_boolean +field_is_zeroish(const ProtobufCFieldDescriptor *field, + const void *member) +{ + protobuf_c_boolean ret = FALSE; + + switch (field->type) { + case PROTOBUF_C_TYPE_BOOL: + ret = (0 == *(const protobuf_c_boolean *) member); + break; + case PROTOBUF_C_TYPE_ENUM: + case PROTOBUF_C_TYPE_SINT32: + case PROTOBUF_C_TYPE_INT32: + case PROTOBUF_C_TYPE_UINT32: + case PROTOBUF_C_TYPE_SFIXED32: + case PROTOBUF_C_TYPE_FIXED32: + ret = (0 == *(const uint32_t *) member); + break; + case PROTOBUF_C_TYPE_SINT64: + case PROTOBUF_C_TYPE_INT64: + case PROTOBUF_C_TYPE_UINT64: + case PROTOBUF_C_TYPE_SFIXED64: + case PROTOBUF_C_TYPE_FIXED64: + ret = (0 == *(const uint64_t *) member); + break; + case PROTOBUF_C_TYPE_FLOAT: + ret = (0 == *(const float *) member); + break; + case PROTOBUF_C_TYPE_DOUBLE: + ret = (0 == *(const double *) member); + break; + case PROTOBUF_C_TYPE_STRING: + ret = (NULL == *(const char * const *) member) || + ('\0' == **(const char * const *) member); + break; + case PROTOBUF_C_TYPE_BYTES: + case PROTOBUF_C_TYPE_MESSAGE: + ret = (NULL == *(const void * const *) member); + break; + default: + ret = TRUE; + break; + } + + return ret; +} + +/** + * Calculate the serialized size of a single unlabeled message field, including + * the space needed by the preceding tag. Returns 0 if the field isn't set or + * if it is set to a "zeroish" value (null pointer or 0 for numerical values). + * Unlabeled fields are supported only in proto3. + * + * \param field + * Field descriptor for member. + * \param member + * Field to encode. + * \return + * Number of bytes required. + */ +static size_t +unlabeled_field_get_packed_size(const ProtobufCFieldDescriptor *field, + const void *member) +{ + if (field_is_zeroish(field, member)) + return 0; + return required_field_get_packed_size(field, member); +} + +/** + * Calculate the serialized size of repeated message fields, which may consist + * of any number of values (including 0). Includes the space needed by the + * preceding tags (as needed). + * + * \param field + * Field descriptor for member. + * \param count + * Number of repeated field members. + * \param member + * Field to encode. + * \return + * Number of bytes required. + */ +static size_t +repeated_field_get_packed_size(const ProtobufCFieldDescriptor *field, + size_t count, const void *member) +{ + size_t header_size; + size_t rv = 0; + unsigned i; + void *array = *(void * const *) member; + + if (count == 0) + return 0; + header_size = get_tag_size(field->id); + if (0 == (field->flags & PROTOBUF_C_FIELD_FLAG_PACKED)) + header_size *= count; + + switch (field->type) { + case PROTOBUF_C_TYPE_SINT32: + for (i = 0; i < count; i++) + rv += sint32_size(((int32_t *) array)[i]); + break; + case PROTOBUF_C_TYPE_ENUM: + case PROTOBUF_C_TYPE_INT32: + for (i = 0; i < count; i++) + rv += int32_size(((int32_t *) array)[i]); + break; + case PROTOBUF_C_TYPE_UINT32: + for (i = 0; i < count; i++) + rv += uint32_size(((uint32_t *) array)[i]); + break; + case PROTOBUF_C_TYPE_SINT64: + for (i = 0; i < count; i++) + rv += sint64_size(((int64_t *) array)[i]); + break; + case PROTOBUF_C_TYPE_INT64: + case PROTOBUF_C_TYPE_UINT64: + for (i = 0; i < count; i++) + rv += uint64_size(((uint64_t *) array)[i]); + break; + case PROTOBUF_C_TYPE_SFIXED32: + case PROTOBUF_C_TYPE_FIXED32: + case PROTOBUF_C_TYPE_FLOAT: + rv += 4 * count; + break; + case PROTOBUF_C_TYPE_SFIXED64: + case PROTOBUF_C_TYPE_FIXED64: + case PROTOBUF_C_TYPE_DOUBLE: + rv += 8 * count; + break; + case PROTOBUF_C_TYPE_BOOL: + rv += count; + break; + case PROTOBUF_C_TYPE_STRING: + for (i = 0; i < count; i++) { + size_t len = strlen(((char **) array)[i]); + rv += uint32_size(len) + len; + } + break; + case PROTOBUF_C_TYPE_BYTES: + for (i = 0; i < count; i++) { + size_t len = ((ProtobufCBinaryData *) array)[i].len; + rv += uint32_size(len) + len; + } + break; + case PROTOBUF_C_TYPE_MESSAGE: + for (i = 0; i < count; i++) { + size_t len = protobuf_c_message_get_packed_size( + ((ProtobufCMessage **) array)[i]); + rv += uint32_size(len) + len; + } + break; + } + + if (0 != (field->flags & PROTOBUF_C_FIELD_FLAG_PACKED)) + header_size += uint32_size(rv); + return header_size + rv; +} + +/** + * Calculate the serialized size of an unknown field, i.e. one that is passed + * through mostly uninterpreted. This is required for forward compatibility if + * new fields are added to the message descriptor. + * + * \param field + * Unknown field type. + * \return + * Number of bytes required. + */ static inline size_t -uint32_pack (uint32_t value, uint8_t *out) -{ - unsigned rv = 0; - if (value >= 0x80) - { - out[rv++] = value | 0x80; - value >>= 7; - if (value >= 0x80) - { - out[rv++] = value | 0x80; - value >>= 7; - if (value >= 0x80) - { - out[rv++] = value | 0x80; - value >>= 7; - if (value >= 0x80) - { - out[rv++] = value | 0x80; - value >>= 7; - } - } - } - } - /* assert: value<128 */ - out[rv++] = value; - return rv; +unknown_field_get_packed_size(const ProtobufCMessageUnknownField *field) +{ + return get_tag_size(field->tag) + field->len; } -/* Pack a 32-bit signed integer, returning the number of bytes needed. - Negative numbers are packed as twos-complement 64-bit integers. */ +/**@}*/ + +/* + * Calculate the serialized size of the message. + */ +size_t protobuf_c_message_get_packed_size(const ProtobufCMessage *message) +{ + unsigned i; + size_t rv = 0; + + ASSERT_IS_MESSAGE(message); + for (i = 0; i < message->descriptor->n_fields; i++) { + const ProtobufCFieldDescriptor *field = + message->descriptor->fields + i; + const void *member = + ((const char *) message) + field->offset; + const void *qmember = + ((const char *) message) + field->quantifier_offset; + + if (field->label == PROTOBUF_C_LABEL_REQUIRED) { + rv += required_field_get_packed_size(field, member); + } else if ((field->label == PROTOBUF_C_LABEL_OPTIONAL || + field->label == PROTOBUF_C_LABEL_NONE) && + (0 != (field->flags & PROTOBUF_C_FIELD_FLAG_ONEOF))) { + rv += oneof_field_get_packed_size( + field, + *(const uint32_t *) qmember, + member + ); + } else if (field->label == PROTOBUF_C_LABEL_OPTIONAL) { + rv += optional_field_get_packed_size( + field, + *(protobuf_c_boolean *) qmember, + member + ); + } else if (field->label == PROTOBUF_C_LABEL_NONE) { + rv += unlabeled_field_get_packed_size( + field, + member + ); + } else { + rv += repeated_field_get_packed_size( + field, + *(const size_t *) qmember, + member + ); + } + } + for (i = 0; i < message->n_unknown_fields; i++) + rv += unknown_field_get_packed_size(&message->unknown_fields[i]); + return rv; +} + +/** + * \defgroup pack protobuf_c_message_pack() implementation + * + * Routines mainly used by protobuf_c_message_pack(). + * + * \ingroup internal + * @{ + */ + +/** + * Pack an unsigned 32-bit integer in base-128 varint encoding and return the + * number of bytes written, which must be 5 or less. + * + * \param value + * Value to encode. + * \param[out] out + * Packed value. + * \return + * Number of bytes written to `out`. + */ +static inline size_t +uint32_pack(uint32_t value, uint8_t *out) +{ + unsigned rv = 0; + + if (value >= 0x80) { + out[rv++] = value | 0x80; + value >>= 7; + if (value >= 0x80) { + out[rv++] = value | 0x80; + value >>= 7; + if (value >= 0x80) { + out[rv++] = value | 0x80; + value >>= 7; + if (value >= 0x80) { + out[rv++] = value | 0x80; + value >>= 7; + } + } + } + } + /* assert: value<128 */ + out[rv++] = value; + return rv; +} + +/** + * Pack a signed 32-bit integer and return the number of bytes written. + * Negative numbers are encoded as two's complement 64-bit integers. + * + * \param value + * Value to encode. + * \param[out] out + * Packed value. + * \return + * Number of bytes written to `out`. + */ static inline size_t -int32_pack (int32_t value, uint8_t *out) -{ - if (value < 0) - { - out[0] = value | 0x80; - out[1] = (value>>7) | 0x80; - out[2] = (value>>14) | 0x80; - out[3] = (value>>21) | 0x80; - out[4] = (value>>28) | 0x80; - out[5] = out[6] = out[7] = out[8] = 0xff; - out[9] = 0x01; - return 10; - } - else - return uint32_pack (value, out); -} - -/* Pack a 32-bit integer in zigwag encoding. */ +int32_pack(int32_t value, uint8_t *out) +{ + if (value < 0) { + out[0] = value | 0x80; + out[1] = (value >> 7) | 0x80; + out[2] = (value >> 14) | 0x80; + out[3] = (value >> 21) | 0x80; + out[4] = (value >> 28) | 0x80; + out[5] = out[6] = out[7] = out[8] = 0xff; + out[9] = 0x01; + return 10; + } else { + return uint32_pack(value, out); + } +} + +/** + * Pack a signed 32-bit integer using ZigZag encoding and return the number of + * bytes written. + * + * \param value + * Value to encode. + * \param[out] out + * Packed value. + * \return + * Number of bytes written to `out`. + */ static inline size_t -sint32_pack (int32_t value, uint8_t *out) +sint32_pack(int32_t value, uint8_t *out) { - return uint32_pack (zigzag32 (value), out); + return uint32_pack(zigzag32(value), out); } -/* Pack a 64-bit unsigned integer that fits in a 64-bit uint, - using base-128 encoding. */ +/** + * Pack a 64-bit unsigned integer using base-128 varint encoding and return the + * number of bytes written. + * + * \param value + * Value to encode. + * \param[out] out + * Packed value. + * \return + * Number of bytes written to `out`. + */ static size_t -uint64_pack (uint64_t value, uint8_t *out) -{ - uint32_t hi = (uint32_t )(value>>32); - uint32_t lo = (uint32_t )value; - unsigned rv; - if (hi == 0) - return uint32_pack ((uint32_t)lo, out); - out[0] = (lo) | 0x80; - out[1] = (lo>>7) | 0x80; - out[2] = (lo>>14) | 0x80; - out[3] = (lo>>21) | 0x80; - if (hi < 8) - { - out[4] = (hi<<4) | (lo>>28); - return 5; - } - else - { - out[4] = ((hi&7)<<4) | (lo>>28) | 0x80; - hi >>= 3; - } - rv = 5; - while (hi >= 128) - { - out[rv++] = hi | 0x80; - hi >>= 7; - } - out[rv++] = hi; - return rv; -} - -/* Pack a 64-bit signed integer in zigzan encoding, - return the size of the packed output. - (Max returned value is 10) */ +uint64_pack(uint64_t value, uint8_t *out) +{ + uint32_t hi = (uint32_t) (value >> 32); + uint32_t lo = (uint32_t) value; + unsigned rv; + + if (hi == 0) + return uint32_pack((uint32_t) lo, out); + out[0] = (lo) | 0x80; + out[1] = (lo >> 7) | 0x80; + out[2] = (lo >> 14) | 0x80; + out[3] = (lo >> 21) | 0x80; + if (hi < 8) { + out[4] = (hi << 4) | (lo >> 28); + return 5; + } else { + out[4] = ((hi & 7) << 4) | (lo >> 28) | 0x80; + hi >>= 3; + } + rv = 5; + while (hi >= 128) { + out[rv++] = hi | 0x80; + hi >>= 7; + } + out[rv++] = hi; + return rv; +} + +/** + * Pack a 64-bit signed integer in ZigZag encoding and return the number of + * bytes written. + * + * \param value + * Value to encode. + * \param[out] out + * Packed value. + * \return + * Number of bytes written to `out`. + */ static inline size_t -sint64_pack (int64_t value, uint8_t *out) +sint64_pack(int64_t value, uint8_t *out) { - return uint64_pack (zigzag64 (value), out); + return uint64_pack(zigzag64(value), out); } -/* Pack a 32-bit value, little-endian. - Used for fixed32, sfixed32, float) */ +/** + * Pack a 32-bit quantity in little-endian byte order. Used for protobuf wire + * types fixed32, sfixed32, float. Similar to "htole32". + * + * \param value + * Value to encode. + * \param[out] out + * Packed value. + * \return + * Number of bytes written to `out`. + */ static inline size_t -fixed32_pack (uint32_t value, void *out) +fixed32_pack(uint32_t value, void *out) { -#if 0 // IS_LITTLE_ENDIAN - memcpy (out, &value, 4); +#if !defined(WORDS_BIGENDIAN) + memcpy(out, &value, 4); #else - uint8_t *buf = out; - buf[0] = value; - buf[1] = value>>8; - buf[2] = value>>16; - buf[3] = value>>24; -#endif - return 4; -} + uint8_t *buf = out; -/* Pack a 64-bit fixed-length value. - (Used for fixed64, sfixed64, double) */ -/* XXX: the big-endian impl is really only good for 32-bit machines, - a 64-bit version would be appreciated, plus a way - to decide to use 64-bit math where convenient. */ + buf[0] = value; + buf[1] = value >> 8; + buf[2] = value >> 16; + buf[3] = value >> 24; +#endif + return 4; +} + +/** + * Pack a 64-bit quantity in little-endian byte order. Used for protobuf wire + * types fixed64, sfixed64, double. Similar to "htole64". + * + * \todo The big-endian impl is really only good for 32-bit machines, a 64-bit + * version would be appreciated, plus a way to decide to use 64-bit math where + * convenient. + * + * \param value + * Value to encode. + * \param[out] out + * Packed value. + * \return + * Number of bytes written to `out`. + */ static inline size_t -fixed64_pack (uint64_t value, void *out) +fixed64_pack(uint64_t value, void *out) { -#if 0 //IS_LITTLE_ENDIAN - memcpy (out, &value, 8); +#if !defined(WORDS_BIGENDIAN) + memcpy(out, &value, 8); #else - fixed32_pack (value, out); - fixed32_pack (value>>32, out+4); + fixed32_pack(value, out); + fixed32_pack(value >> 32, ((char *) out) + 4); #endif - return 8; -} - - -/* Pack a boolean as 0 or 1, even though the protobuf_c_boolean - can really assume any integer value. */ -/* XXX: perhaps on some platforms "*out = !!value" would be - a better impl, b/c that is idiotmatic c++ in some stl impls. */ + return 8; +} + +/** + * Pack a boolean value as an integer and return the number of bytes written. + * + * \todo Perhaps on some platforms *out = !!value would be a better impl, b/c + * that is idiomatic C++ in some STL implementations. + * + * \param value + * Value to encode. + * \param[out] out + * Packed value. + * \return + * Number of bytes written to `out`. + */ static inline size_t -boolean_pack (protobuf_c_boolean value, uint8_t *out) -{ - *out = value ? 1 : 0; - return 1; -} - -/* Pack a length-prefixed string. - The input string is NUL-terminated. - - The NULL pointer is treated as an empty string. - This isn't really necessary, but it allows people - to leave required strings blank. - (See Issue 13 in the bug tracker for a - little more explanation). +boolean_pack(protobuf_c_boolean value, uint8_t *out) +{ + *out = value ? TRUE : FALSE; + return 1; +} + +/** + * Pack a NUL-terminated C string and return the number of bytes written. The + * output includes a length delimiter. + * + * The NULL pointer is treated as an empty string. This isn't really necessary, + * but it allows people to leave required strings blank. (See Issue #13 in the + * bug tracker for a little more explanation). + * + * \param str + * String to encode. + * \param[out] out + * Packed value. + * \return + * Number of bytes written to `out`. */ static inline size_t -string_pack (const char * str, uint8_t *out) -{ - if (str == NULL) - { - out[0] = 0; - return 1; - } - else - { - size_t len = strlen (str); - size_t rv = uint32_pack (len, out); - memcpy (out + rv, str, len); - return rv + len; - } -} - +string_pack(const char *str, uint8_t *out) +{ + if (str == NULL) { + out[0] = 0; + return 1; + } else { + size_t len = strlen(str); + size_t rv = uint32_pack(len, out); + memcpy(out + rv, str, len); + return rv + len; + } +} + +/** + * Pack a ProtobufCBinaryData and return the number of bytes written. The output + * includes a length delimiter. + * + * \param bd + * ProtobufCBinaryData to encode. + * \param[out] out + * Packed value. + * \return + * Number of bytes written to `out`. + */ static inline size_t -binary_data_pack (const ProtobufCBinaryData *bd, uint8_t *out) -{ - size_t len = bd->len; - size_t rv = uint32_pack (len, out); - memcpy (out + rv, bd->data, len); - return rv + len; -} - +binary_data_pack(const ProtobufCBinaryData *bd, uint8_t *out) +{ + size_t len = bd->len; + size_t rv = uint32_pack(len, out); + memcpy(out + rv, bd->data, len); + return rv + len; +} + +/** + * Pack a ProtobufCMessage and return the number of bytes written. The output + * includes a length delimiter. + * + * \param message + * ProtobufCMessage object to pack. + * \param[out] out + * Packed message. + * \return + * Number of bytes written to `out`. + */ static inline size_t -prefixed_message_pack (const ProtobufCMessage *message, uint8_t *out) -{ - if (message == NULL) - { - out[0] = 0; - return 1; - } - else - { - size_t rv = protobuf_c_message_pack (message, out + 1); - uint32_t rv_packed_size = uint32_size (rv); - if (rv_packed_size != 1) - memmove (out + rv_packed_size, out + 1, rv); - return uint32_pack (rv, out) + rv; - } -} - -/* wire-type will be added in required_field_pack() */ -/* XXX: just call uint64_pack on 64-bit platforms. */ +prefixed_message_pack(const ProtobufCMessage *message, uint8_t *out) +{ + if (message == NULL) { + out[0] = 0; + return 1; + } else { + size_t rv = protobuf_c_message_pack(message, out + 1); + uint32_t rv_packed_size = uint32_size(rv); + if (rv_packed_size != 1) + memmove(out + rv_packed_size, out + 1, rv); + return uint32_pack(rv, out) + rv; + } +} + +/** + * Pack a field tag. + * + * Wire-type will be added in required_field_pack(). + * + * \todo Just call uint64_pack on 64-bit platforms. + * + * \param id + * Tag value to encode. + * \param[out] out + * Packed value. + * \return + * Number of bytes written to `out`. + */ static size_t -tag_pack (uint32_t id, uint8_t *out) -{ - if (id < (1<<(32-3))) - return uint32_pack (id<<3, out); - else - return uint64_pack (((uint64_t)id) << 3, out); -} - +tag_pack(uint32_t id, uint8_t *out) +{ + if (id < (1UL << (32 - 3))) + return uint32_pack(id << 3, out); + else + return uint64_pack(((uint64_t) id) << 3, out); +} + +/** + * Pack a required field and return the number of bytes written. + * + * \param field + * Field descriptor. + * \param member + * The field member. + * \param[out] out + * Packed value. + * \return + * Number of bytes written to `out`. + */ static size_t -required_field_pack (const ProtobufCFieldDescriptor *field, - const void *member, - uint8_t *out) -{ - size_t rv = tag_pack (field->id, out); - switch (field->type) - { - case PROTOBUF_C_TYPE_SINT32: - out[0] |= PROTOBUF_C_WIRE_TYPE_VARINT; - return rv + sint32_pack (*(const int32_t *) member, out + rv); - case PROTOBUF_C_TYPE_INT32: - out[0] |= PROTOBUF_C_WIRE_TYPE_VARINT; - return rv + int32_pack (*(const uint32_t *) member, out + rv); - case PROTOBUF_C_TYPE_UINT32: - case PROTOBUF_C_TYPE_ENUM: - out[0] |= PROTOBUF_C_WIRE_TYPE_VARINT; - return rv + uint32_pack (*(const uint32_t *) member, out + rv); - case PROTOBUF_C_TYPE_SINT64: - out[0] |= PROTOBUF_C_WIRE_TYPE_VARINT; - return rv + sint64_pack (*(const int64_t *) member, out + rv); - case PROTOBUF_C_TYPE_INT64: - case PROTOBUF_C_TYPE_UINT64: - out[0] |= PROTOBUF_C_WIRE_TYPE_VARINT; - return rv + uint64_pack (*(const uint64_t *) member, out + rv); - case PROTOBUF_C_TYPE_SFIXED32: - case PROTOBUF_C_TYPE_FIXED32: - case PROTOBUF_C_TYPE_FLOAT: - out[0] |= PROTOBUF_C_WIRE_TYPE_32BIT; - return rv + fixed32_pack (*(const uint32_t *) member, out + rv); - case PROTOBUF_C_TYPE_SFIXED64: - case PROTOBUF_C_TYPE_FIXED64: - case PROTOBUF_C_TYPE_DOUBLE: - out[0] |= PROTOBUF_C_WIRE_TYPE_64BIT; - return rv + fixed64_pack (*(const uint64_t *) member, out + rv); - case PROTOBUF_C_TYPE_BOOL: - out[0] |= PROTOBUF_C_WIRE_TYPE_VARINT; - return rv + boolean_pack (*(const protobuf_c_boolean *) member, out + rv); - case PROTOBUF_C_TYPE_STRING: - { - out[0] |= PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED; - return rv + string_pack (*(char * const *) member, out + rv); - } - - case PROTOBUF_C_TYPE_BYTES: - { - const ProtobufCBinaryData * bd = ((const ProtobufCBinaryData*) member); - out[0] |= PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED; - return rv + binary_data_pack (bd, out + rv); - } - //case PROTOBUF_C_TYPE_GROUP: // NOT SUPPORTED - case PROTOBUF_C_TYPE_MESSAGE: - { - out[0] |= PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED; - return rv + prefixed_message_pack (*(ProtobufCMessage * const *) member, - out + rv); - } - } - PROTOBUF_C_ASSERT_NOT_REACHED (); - return 0; -} +required_field_pack(const ProtobufCFieldDescriptor *field, + const void *member, uint8_t *out) +{ + size_t rv = tag_pack(field->id, out); + + switch (field->type) { + case PROTOBUF_C_TYPE_SINT32: + out[0] |= PROTOBUF_C_WIRE_TYPE_VARINT; + return rv + sint32_pack(*(const int32_t *) member, out + rv); + case PROTOBUF_C_TYPE_ENUM: + case PROTOBUF_C_TYPE_INT32: + out[0] |= PROTOBUF_C_WIRE_TYPE_VARINT; + return rv + int32_pack(*(const int32_t *) member, out + rv); + case PROTOBUF_C_TYPE_UINT32: + out[0] |= PROTOBUF_C_WIRE_TYPE_VARINT; + return rv + uint32_pack(*(const uint32_t *) member, out + rv); + case PROTOBUF_C_TYPE_SINT64: + out[0] |= PROTOBUF_C_WIRE_TYPE_VARINT; + return rv + sint64_pack(*(const int64_t *) member, out + rv); + case PROTOBUF_C_TYPE_INT64: + case PROTOBUF_C_TYPE_UINT64: + out[0] |= PROTOBUF_C_WIRE_TYPE_VARINT; + return rv + uint64_pack(*(const uint64_t *) member, out + rv); + case PROTOBUF_C_TYPE_SFIXED32: + case PROTOBUF_C_TYPE_FIXED32: + case PROTOBUF_C_TYPE_FLOAT: + out[0] |= PROTOBUF_C_WIRE_TYPE_32BIT; + return rv + fixed32_pack(*(const uint32_t *) member, out + rv); + case PROTOBUF_C_TYPE_SFIXED64: + case PROTOBUF_C_TYPE_FIXED64: + case PROTOBUF_C_TYPE_DOUBLE: + out[0] |= PROTOBUF_C_WIRE_TYPE_64BIT; + return rv + fixed64_pack(*(const uint64_t *) member, out + rv); + case PROTOBUF_C_TYPE_BOOL: + out[0] |= PROTOBUF_C_WIRE_TYPE_VARINT; + return rv + boolean_pack(*(const protobuf_c_boolean *) member, out + rv); + case PROTOBUF_C_TYPE_STRING: + out[0] |= PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED; + return rv + string_pack(*(char *const *) member, out + rv); + case PROTOBUF_C_TYPE_BYTES: + out[0] |= PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED; + return rv + binary_data_pack((const ProtobufCBinaryData *) member, out + rv); + case PROTOBUF_C_TYPE_MESSAGE: + out[0] |= PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED; + return rv + prefixed_message_pack(*(ProtobufCMessage * const *) member, out + rv); + } + PROTOBUF_C__ASSERT_NOT_REACHED(); + return 0; +} + +/** + * Pack a oneof field and return the number of bytes written. Only packs the + * field that is selected by the case enum. + * + * \param field + * Field descriptor. + * \param oneof_case + * Enum value that selects the field in the oneof. + * \param member + * The field member. + * \param[out] out + * Packed value. + * \return + * Number of bytes written to `out`. + */ static size_t -optional_field_pack (const ProtobufCFieldDescriptor *field, - const protobuf_c_boolean *has, - const void *member, - uint8_t *out) -{ - if (field->type == PROTOBUF_C_TYPE_MESSAGE - || field->type == PROTOBUF_C_TYPE_STRING) - { - const void *ptr = * (const void * const *) member; - if (ptr == NULL - || ptr == field->default_value) - return 0; - } - else - { - if (!*has) - return 0; - } - return required_field_pack (field, member, out); -} - -/* TODO: implement as a table lookup */ +oneof_field_pack(const ProtobufCFieldDescriptor *field, + uint32_t oneof_case, + const void *member, uint8_t *out) +{ + if (oneof_case != field->id) { + return 0; + } + if (field->type == PROTOBUF_C_TYPE_MESSAGE || + field->type == PROTOBUF_C_TYPE_STRING) + { + const void *ptr = *(const void * const *) member; + if (ptr == NULL || ptr == field->default_value) + return 0; + } + return required_field_pack(field, member, out); +} + +/** + * Pack an optional field and return the number of bytes written. + * + * \param field + * Field descriptor. + * \param has + * Whether the field is set. + * \param member + * The field member. + * \param[out] out + * Packed value. + * \return + * Number of bytes written to `out`. + */ +static size_t +optional_field_pack(const ProtobufCFieldDescriptor *field, + const protobuf_c_boolean has, + const void *member, uint8_t *out) +{ + if (field->type == PROTOBUF_C_TYPE_MESSAGE || + field->type == PROTOBUF_C_TYPE_STRING) + { + const void *ptr = *(const void * const *) member; + if (ptr == NULL || ptr == field->default_value) + return 0; + } else { + if (!has) + return 0; + } + return required_field_pack(field, member, out); +} + +/** + * Pack an unlabeled field and return the number of bytes written. + * + * \param field + * Field descriptor. + * \param member + * The field member. + * \param[out] out + * Packed value. + * \return + * Number of bytes written to `out`. + */ +static size_t +unlabeled_field_pack(const ProtobufCFieldDescriptor *field, + const void *member, uint8_t *out) +{ + if (field_is_zeroish(field, member)) + return 0; + return required_field_pack(field, member, out); +} + +/** + * Given a field type, return the in-memory size. + * + * \todo Implement as a table lookup. + * + * \param type + * Field type. + * \return + * Size of the field. + */ static inline size_t -sizeof_elt_in_repeated_array (ProtobufCType type) -{ - switch (type) - { - case PROTOBUF_C_TYPE_SINT32: - case PROTOBUF_C_TYPE_INT32: - case PROTOBUF_C_TYPE_UINT32: - case PROTOBUF_C_TYPE_SFIXED32: - case PROTOBUF_C_TYPE_FIXED32: - case PROTOBUF_C_TYPE_FLOAT: - case PROTOBUF_C_TYPE_ENUM: - return 4; - case PROTOBUF_C_TYPE_SINT64: - case PROTOBUF_C_TYPE_INT64: - case PROTOBUF_C_TYPE_UINT64: - case PROTOBUF_C_TYPE_SFIXED64: - case PROTOBUF_C_TYPE_FIXED64: - case PROTOBUF_C_TYPE_DOUBLE: - return 8; - case PROTOBUF_C_TYPE_BOOL: - return sizeof (protobuf_c_boolean); - case PROTOBUF_C_TYPE_STRING: - case PROTOBUF_C_TYPE_MESSAGE: - return sizeof (void *); - case PROTOBUF_C_TYPE_BYTES: - return sizeof (ProtobufCBinaryData); - } - PROTOBUF_C_ASSERT_NOT_REACHED (); - return 0; -} - +sizeof_elt_in_repeated_array(ProtobufCType type) +{ + switch (type) { + case PROTOBUF_C_TYPE_SINT32: + case PROTOBUF_C_TYPE_INT32: + case PROTOBUF_C_TYPE_UINT32: + case PROTOBUF_C_TYPE_SFIXED32: + case PROTOBUF_C_TYPE_FIXED32: + case PROTOBUF_C_TYPE_FLOAT: + case PROTOBUF_C_TYPE_ENUM: + return 4; + case PROTOBUF_C_TYPE_SINT64: + case PROTOBUF_C_TYPE_INT64: + case PROTOBUF_C_TYPE_UINT64: + case PROTOBUF_C_TYPE_SFIXED64: + case PROTOBUF_C_TYPE_FIXED64: + case PROTOBUF_C_TYPE_DOUBLE: + return 8; + case PROTOBUF_C_TYPE_BOOL: + return sizeof(protobuf_c_boolean); + case PROTOBUF_C_TYPE_STRING: + case PROTOBUF_C_TYPE_MESSAGE: + return sizeof(void *); + case PROTOBUF_C_TYPE_BYTES: + return sizeof(ProtobufCBinaryData); + } + PROTOBUF_C__ASSERT_NOT_REACHED(); + return 0; +} + +/** + * Pack an array of 32-bit quantities. + * + * \param[out] out + * Destination. + * \param[in] in + * Source. + * \param[in] n + * Number of elements in the source array. + */ static void -copy_to_little_endian_32 (void *out, const void *in, unsigned N) +copy_to_little_endian_32(void *out, const void *in, const unsigned n) { -#if 0 //IS_LITTLE_ENDIAN - memcpy (out, in, N * 4); +#if !defined(WORDS_BIGENDIAN) + memcpy(out, in, n * 4); #else - unsigned i; - const uint32_t *ini = in; - for (i = 0; i < N; i++) - fixed32_pack (ini[i], (uint32_t*)out + i); + unsigned i; + const uint32_t *ini = in; + for (i = 0; i < n; i++) + fixed32_pack(ini[i], (uint32_t *) out + i); #endif } + +/** + * Pack an array of 64-bit quantities. + * + * \param[out] out + * Destination. + * \param[in] in + * Source. + * \param[in] n + * Number of elements in the source array. + */ static void -copy_to_little_endian_64 (void *out, const void *in, unsigned N) +copy_to_little_endian_64(void *out, const void *in, const unsigned n) { -#if 0 //IS_LITTLE_ENDIAN - memcpy (out, in, N * 8); +#if !defined(WORDS_BIGENDIAN) + memcpy(out, in, n * 8); #else - unsigned i; - const uint64_t *ini = in; - for (i = 0; i < N; i++) - fixed64_pack (ini[i], (uint64_t*)out + i); + unsigned i; + const uint64_t *ini = in; + for (i = 0; i < n; i++) + fixed64_pack(ini[i], (uint64_t *) out + i); #endif } +/** + * Get the minimum number of bytes required to pack a field value of a + * particular type. + * + * \param type + * Field type. + * \return + * Number of bytes. + */ static unsigned -get_type_min_size (ProtobufCType type) -{ - if (type == PROTOBUF_C_TYPE_SFIXED32 - || type == PROTOBUF_C_TYPE_FIXED32 - || type == PROTOBUF_C_TYPE_FLOAT) - return 4; - if (type == PROTOBUF_C_TYPE_SFIXED64 - || type == PROTOBUF_C_TYPE_FIXED64 - || type == PROTOBUF_C_TYPE_DOUBLE) - return 8; - return 1; -} - +get_type_min_size(ProtobufCType type) +{ + if (type == PROTOBUF_C_TYPE_SFIXED32 || + type == PROTOBUF_C_TYPE_FIXED32 || + type == PROTOBUF_C_TYPE_FLOAT) + { + return 4; + } + if (type == PROTOBUF_C_TYPE_SFIXED64 || + type == PROTOBUF_C_TYPE_FIXED64 || + type == PROTOBUF_C_TYPE_DOUBLE) + { + return 8; + } + return 1; +} + +/** + * Packs the elements of a repeated field and returns the serialised field and + * its length. + * + * \param field + * Field descriptor. + * \param count + * Number of elements in the repeated field array. + * \param member + * Pointer to the elements for this repeated field. + * \param[out] out + * Serialised representation of the repeated field. + * \return + * Number of bytes serialised to `out`. + */ static size_t -repeated_field_pack (const ProtobufCFieldDescriptor *field, - size_t count, - const void *member, - uint8_t *out) -{ - char *array = * (char * const *) member; - unsigned i; - if (field->packed) - { - unsigned header_len; - unsigned len_start; - unsigned min_length; - unsigned payload_len; - unsigned length_size_min; - unsigned actual_length_size; - uint8_t *payload_at; - if (count == 0) - return 0; - header_len = tag_pack (field->id, out); - out[0] |= PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED; - len_start = header_len; - min_length = get_type_min_size (field->type) * count; - length_size_min = uint32_size (min_length); - header_len += length_size_min; - payload_at = out + header_len; - switch (field->type) - { - case PROTOBUF_C_TYPE_SFIXED32: - case PROTOBUF_C_TYPE_FIXED32: - case PROTOBUF_C_TYPE_FLOAT: - copy_to_little_endian_32 (payload_at, array, count); - payload_at += count * 4; - break; - - case PROTOBUF_C_TYPE_SFIXED64: - case PROTOBUF_C_TYPE_FIXED64: - case PROTOBUF_C_TYPE_DOUBLE: - copy_to_little_endian_64 (payload_at, array, count); - payload_at += count * 8; - break; - - case PROTOBUF_C_TYPE_INT32: - { - const int32_t *arr = (const int32_t *) array; - for (i = 0; i < count; i++) - payload_at += int32_pack (arr[i], payload_at); - } - break; - - case PROTOBUF_C_TYPE_SINT32: - { - const int32_t *arr = (const int32_t *) array; - for (i = 0; i < count; i++) - payload_at += sint32_pack (arr[i], payload_at); - } - break; - - case PROTOBUF_C_TYPE_SINT64: - { - const int64_t *arr = (const int64_t *) array; - for (i = 0; i < count; i++) - payload_at += sint64_pack (arr[i], payload_at); - } - break; - case PROTOBUF_C_TYPE_ENUM: - case PROTOBUF_C_TYPE_UINT32: - { - const uint32_t *arr = (const uint32_t *) array; - for (i = 0; i < count; i++) - payload_at += uint32_pack (arr[i], payload_at); - } - break; - case PROTOBUF_C_TYPE_INT64: - case PROTOBUF_C_TYPE_UINT64: - { - const uint64_t *arr = (const uint64_t *) array; - for (i = 0; i < count; i++) - payload_at += uint64_pack (arr[i], payload_at); - } - break; - case PROTOBUF_C_TYPE_BOOL: - { - const protobuf_c_boolean *arr = (const protobuf_c_boolean *) array; - for (i = 0; i < count; i++) - payload_at += boolean_pack (arr[i], payload_at); - } - break; - - default: - assert (0); - } - payload_len = payload_at - (out + header_len); - actual_length_size = uint32_size (payload_len); - if (length_size_min != actual_length_size) - { - assert (actual_length_size == length_size_min + 1); - memmove (out + header_len + 1, out + header_len, payload_len); - header_len++; - } - uint32_pack (payload_len, out + len_start); - return header_len + payload_len; - } - else - { - /* CONSIDER: optimize this case a bit (by putting the loop inside the switch) */ - size_t rv = 0; - unsigned siz = sizeof_elt_in_repeated_array (field->type); - for (i = 0; i < count; i++) - { - rv += required_field_pack (field, array, out + rv); - array += siz; - } - return rv; - } +repeated_field_pack(const ProtobufCFieldDescriptor *field, + size_t count, const void *member, uint8_t *out) +{ + void *array = *(void * const *) member; + unsigned i; + + if (0 != (field->flags & PROTOBUF_C_FIELD_FLAG_PACKED)) { + unsigned header_len; + unsigned len_start; + unsigned min_length; + unsigned payload_len; + unsigned length_size_min; + unsigned actual_length_size; + uint8_t *payload_at; + + if (count == 0) + return 0; + header_len = tag_pack(field->id, out); + out[0] |= PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED; + len_start = header_len; + min_length = get_type_min_size(field->type) * count; + length_size_min = uint32_size(min_length); + header_len += length_size_min; + payload_at = out + header_len; + + switch (field->type) { + case PROTOBUF_C_TYPE_SFIXED32: + case PROTOBUF_C_TYPE_FIXED32: + case PROTOBUF_C_TYPE_FLOAT: + copy_to_little_endian_32(payload_at, array, count); + payload_at += count * 4; + break; + case PROTOBUF_C_TYPE_SFIXED64: + case PROTOBUF_C_TYPE_FIXED64: + case PROTOBUF_C_TYPE_DOUBLE: + copy_to_little_endian_64(payload_at, array, count); + payload_at += count * 8; + break; + case PROTOBUF_C_TYPE_ENUM: + case PROTOBUF_C_TYPE_INT32: { + const int32_t *arr = (const int32_t *) array; + for (i = 0; i < count; i++) + payload_at += int32_pack(arr[i], payload_at); + break; + } + case PROTOBUF_C_TYPE_SINT32: { + const int32_t *arr = (const int32_t *) array; + for (i = 0; i < count; i++) + payload_at += sint32_pack(arr[i], payload_at); + break; + } + case PROTOBUF_C_TYPE_SINT64: { + const int64_t *arr = (const int64_t *) array; + for (i = 0; i < count; i++) + payload_at += sint64_pack(arr[i], payload_at); + break; + } + case PROTOBUF_C_TYPE_UINT32: { + const uint32_t *arr = (const uint32_t *) array; + for (i = 0; i < count; i++) + payload_at += uint32_pack(arr[i], payload_at); + break; + } + case PROTOBUF_C_TYPE_INT64: + case PROTOBUF_C_TYPE_UINT64: { + const uint64_t *arr = (const uint64_t *) array; + for (i = 0; i < count; i++) + payload_at += uint64_pack(arr[i], payload_at); + break; + } + case PROTOBUF_C_TYPE_BOOL: { + const protobuf_c_boolean *arr = (const protobuf_c_boolean *) array; + for (i = 0; i < count; i++) + payload_at += boolean_pack(arr[i], payload_at); + break; + } + default: + PROTOBUF_C__ASSERT_NOT_REACHED(); + } + + payload_len = payload_at - (out + header_len); + actual_length_size = uint32_size(payload_len); + if (length_size_min != actual_length_size) { + assert(actual_length_size == length_size_min + 1); + memmove(out + header_len + 1, out + header_len, + payload_len); + header_len++; + } + uint32_pack(payload_len, out + len_start); + return header_len + payload_len; + } else { + /* not "packed" cased */ + /* CONSIDER: optimize this case a bit (by putting the loop inside the switch) */ + size_t rv = 0; + unsigned siz = sizeof_elt_in_repeated_array(field->type); + + for (i = 0; i < count; i++) { + rv += required_field_pack(field, array, out + rv); + array = (char *)array + siz; + } + return rv; + } } + static size_t -unknown_field_pack (const ProtobufCMessageUnknownField *field, - uint8_t *out) +unknown_field_pack(const ProtobufCMessageUnknownField *field, uint8_t *out) { - size_t rv = tag_pack (field->tag, out); - out[0] |= field->wire_type; - memcpy (out + rv, field->data, field->len); - return rv + field->len; + size_t rv = tag_pack(field->tag, out); + out[0] |= field->wire_type; + memcpy(out + rv, field->data, field->len); + return rv + field->len; } +/**@}*/ + size_t -protobuf_c_message_pack (const ProtobufCMessage *message, - uint8_t *out) -{ - unsigned i; - size_t rv = 0; - ASSERT_IS_MESSAGE (message); - for (i = 0; i < message->descriptor->n_fields; i++) - { - const ProtobufCFieldDescriptor *field = message->descriptor->fields + i; - const void *member = ((const char *) message) + field->offset; - - /* it doesn't hurt to compute qmember (a pointer to the quantifier - field of the structure), but the pointer is only valid if - the field is one of: - - a repeated field - - an optional field that isn't a pointer type - (meaning: not a message or a string) */ - const void *qmember = ((const char *) message) + field->quantifier_offset; - - if (field->label == PROTOBUF_C_LABEL_REQUIRED) - rv += required_field_pack (field, member, out + rv); - else if (field->label == PROTOBUF_C_LABEL_OPTIONAL) - /* note that qmember is bogus for strings and messages, - but it isn't used */ - rv += optional_field_pack (field, qmember, member, out + rv); - else - rv += repeated_field_pack (field, * (const size_t *) qmember, member, out + rv); - } - for (i = 0; i < message->n_unknown_fields; i++) - rv += unknown_field_pack (&message->unknown_fields[i], out + rv); - return rv; -} - -/* === pack_to_buffer() === */ +protobuf_c_message_pack(const ProtobufCMessage *message, uint8_t *out) +{ + unsigned i; + size_t rv = 0; + + ASSERT_IS_MESSAGE(message); + for (i = 0; i < message->descriptor->n_fields; i++) { + const ProtobufCFieldDescriptor *field = + message->descriptor->fields + i; + const void *member = ((const char *) message) + field->offset; + + /* + * It doesn't hurt to compute qmember (a pointer to the + * quantifier field of the structure), but the pointer is only + * valid if the field is: + * - a repeated field, or + * - a field that is part of a oneof + * - an optional field that isn't a pointer type + * (Meaning: not a message or a string). + */ + const void *qmember = + ((const char *) message) + field->quantifier_offset; + + if (field->label == PROTOBUF_C_LABEL_REQUIRED) { + rv += required_field_pack(field, member, out + rv); + } else if ((field->label == PROTOBUF_C_LABEL_OPTIONAL || + field->label == PROTOBUF_C_LABEL_NONE) && + (0 != (field->flags & PROTOBUF_C_FIELD_FLAG_ONEOF))) { + rv += oneof_field_pack( + field, + *(const uint32_t *) qmember, + member, + out + rv + ); + } else if (field->label == PROTOBUF_C_LABEL_OPTIONAL) { + rv += optional_field_pack( + field, + *(const protobuf_c_boolean *) qmember, + member, + out + rv + ); + } else if (field->label == PROTOBUF_C_LABEL_NONE) { + rv += unlabeled_field_pack(field, member, out + rv); + } else { + rv += repeated_field_pack(field, *(const size_t *) qmember, + member, out + rv); + } + } + for (i = 0; i < message->n_unknown_fields; i++) + rv += unknown_field_pack(&message->unknown_fields[i], out + rv); + return rv; +} + +/** + * \defgroup packbuf protobuf_c_message_pack_to_buffer() implementation + * + * Routines mainly used by protobuf_c_message_pack_to_buffer(). + * + * \ingroup internal + * @{ + */ + +/** + * Pack a required field to a virtual buffer. + * + * \param field + * Field descriptor. + * \param member + * The element to be packed. + * \param[out] buffer + * Virtual buffer to append data to. + * \return + * Number of bytes packed. + */ static size_t -required_field_pack_to_buffer (const ProtobufCFieldDescriptor *field, - const void *member, - ProtobufCBuffer *buffer) -{ - size_t rv; - uint8_t scratch[MAX_UINT64_ENCODED_SIZE * 2]; - rv = tag_pack (field->id, scratch); - switch (field->type) - { - case PROTOBUF_C_TYPE_SINT32: - scratch[0] |= PROTOBUF_C_WIRE_TYPE_VARINT; - rv += sint32_pack (*(const int32_t *) member, scratch + rv); - buffer->append (buffer, rv, scratch); - break; - case PROTOBUF_C_TYPE_INT32: - scratch[0] |= PROTOBUF_C_WIRE_TYPE_VARINT; - rv += int32_pack (*(const uint32_t *) member, scratch + rv); - buffer->append (buffer, rv, scratch); - break; - case PROTOBUF_C_TYPE_UINT32: - case PROTOBUF_C_TYPE_ENUM: - scratch[0] |= PROTOBUF_C_WIRE_TYPE_VARINT; - rv += uint32_pack (*(const uint32_t *) member, scratch + rv); - buffer->append (buffer, rv, scratch); - break; - case PROTOBUF_C_TYPE_SINT64: - scratch[0] |= PROTOBUF_C_WIRE_TYPE_VARINT; - rv += sint64_pack (*(const int64_t *) member, scratch + rv); - buffer->append (buffer, rv, scratch); - break; - case PROTOBUF_C_TYPE_INT64: - case PROTOBUF_C_TYPE_UINT64: - scratch[0] |= PROTOBUF_C_WIRE_TYPE_VARINT; - rv += uint64_pack (*(const uint64_t *) member, scratch + rv); - buffer->append (buffer, rv, scratch); - break; - case PROTOBUF_C_TYPE_SFIXED32: - case PROTOBUF_C_TYPE_FIXED32: - case PROTOBUF_C_TYPE_FLOAT: - scratch[0] |= PROTOBUF_C_WIRE_TYPE_32BIT; - rv += fixed32_pack (*(const uint32_t *) member, scratch + rv); - buffer->append (buffer, rv, scratch); - break; - case PROTOBUF_C_TYPE_SFIXED64: - case PROTOBUF_C_TYPE_FIXED64: - case PROTOBUF_C_TYPE_DOUBLE: - scratch[0] |= PROTOBUF_C_WIRE_TYPE_64BIT; - rv += fixed64_pack (*(const uint64_t *) member, scratch + rv); - buffer->append (buffer, rv, scratch); - break; - case PROTOBUF_C_TYPE_BOOL: - scratch[0] |= PROTOBUF_C_WIRE_TYPE_VARINT; - rv += boolean_pack (*(const protobuf_c_boolean *) member, scratch + rv); - buffer->append (buffer, rv, scratch); - break; - case PROTOBUF_C_TYPE_STRING: - { - const char *str = *(char * const *) member; - size_t sublen = str ? strlen (str) : 0; - scratch[0] |= PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED; - rv += uint32_pack (sublen, scratch + rv); - buffer->append (buffer, rv, scratch); - buffer->append (buffer, sublen, (const uint8_t *) str); - rv += sublen; - break; - } - - case PROTOBUF_C_TYPE_BYTES: - { - const ProtobufCBinaryData * bd = ((const ProtobufCBinaryData*) member); - size_t sublen = bd->len; - scratch[0] |= PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED; - rv += uint32_pack (sublen, scratch + rv); - buffer->append (buffer, rv, scratch); - buffer->append (buffer, sublen, bd->data); - rv += sublen; - break; - } - //PROTOBUF_C_TYPE_GROUP, // NOT SUPPORTED - case PROTOBUF_C_TYPE_MESSAGE: - { - uint8_t simple_buffer_scratch[256]; - size_t sublen; - ProtobufCBufferSimple simple_buffer - = PROTOBUF_C_BUFFER_SIMPLE_INIT (simple_buffer_scratch); - const ProtobufCMessage *msg = *(ProtobufCMessage * const *) member; - scratch[0] |= PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED; - if (msg == NULL) - sublen = 0; - else - sublen = protobuf_c_message_pack_to_buffer (msg, &simple_buffer.base); - rv += uint32_pack (sublen, scratch + rv); - buffer->append (buffer, rv, scratch); - buffer->append (buffer, sublen, simple_buffer.data); - rv += sublen; - PROTOBUF_C_BUFFER_SIMPLE_CLEAR (&simple_buffer); - break; - } - default: - PROTOBUF_C_ASSERT_NOT_REACHED (); - } - return rv; -} +required_field_pack_to_buffer(const ProtobufCFieldDescriptor *field, + const void *member, ProtobufCBuffer *buffer) +{ + size_t rv; + uint8_t scratch[MAX_UINT64_ENCODED_SIZE * 2]; + + rv = tag_pack(field->id, scratch); + switch (field->type) { + case PROTOBUF_C_TYPE_SINT32: + scratch[0] |= PROTOBUF_C_WIRE_TYPE_VARINT; + rv += sint32_pack(*(const int32_t *) member, scratch + rv); + buffer->append(buffer, rv, scratch); + break; + case PROTOBUF_C_TYPE_ENUM: + case PROTOBUF_C_TYPE_INT32: + scratch[0] |= PROTOBUF_C_WIRE_TYPE_VARINT; + rv += int32_pack(*(const int32_t *) member, scratch + rv); + buffer->append(buffer, rv, scratch); + break; + case PROTOBUF_C_TYPE_UINT32: + scratch[0] |= PROTOBUF_C_WIRE_TYPE_VARINT; + rv += uint32_pack(*(const uint32_t *) member, scratch + rv); + buffer->append(buffer, rv, scratch); + break; + case PROTOBUF_C_TYPE_SINT64: + scratch[0] |= PROTOBUF_C_WIRE_TYPE_VARINT; + rv += sint64_pack(*(const int64_t *) member, scratch + rv); + buffer->append(buffer, rv, scratch); + break; + case PROTOBUF_C_TYPE_INT64: + case PROTOBUF_C_TYPE_UINT64: + scratch[0] |= PROTOBUF_C_WIRE_TYPE_VARINT; + rv += uint64_pack(*(const uint64_t *) member, scratch + rv); + buffer->append(buffer, rv, scratch); + break; + case PROTOBUF_C_TYPE_SFIXED32: + case PROTOBUF_C_TYPE_FIXED32: + case PROTOBUF_C_TYPE_FLOAT: + scratch[0] |= PROTOBUF_C_WIRE_TYPE_32BIT; + rv += fixed32_pack(*(const uint32_t *) member, scratch + rv); + buffer->append(buffer, rv, scratch); + break; + case PROTOBUF_C_TYPE_SFIXED64: + case PROTOBUF_C_TYPE_FIXED64: + case PROTOBUF_C_TYPE_DOUBLE: + scratch[0] |= PROTOBUF_C_WIRE_TYPE_64BIT; + rv += fixed64_pack(*(const uint64_t *) member, scratch + rv); + buffer->append(buffer, rv, scratch); + break; + case PROTOBUF_C_TYPE_BOOL: + scratch[0] |= PROTOBUF_C_WIRE_TYPE_VARINT; + rv += boolean_pack(*(const protobuf_c_boolean *) member, scratch + rv); + buffer->append(buffer, rv, scratch); + break; + case PROTOBUF_C_TYPE_STRING: { + const char *str = *(char *const *) member; + size_t sublen = str ? strlen(str) : 0; + + scratch[0] |= PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED; + rv += uint32_pack(sublen, scratch + rv); + buffer->append(buffer, rv, scratch); + buffer->append(buffer, sublen, (const uint8_t *) str); + rv += sublen; + break; + } + case PROTOBUF_C_TYPE_BYTES: { + const ProtobufCBinaryData *bd = ((const ProtobufCBinaryData *) member); + size_t sublen = bd->len; + + scratch[0] |= PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED; + rv += uint32_pack(sublen, scratch + rv); + buffer->append(buffer, rv, scratch); + buffer->append(buffer, sublen, bd->data); + rv += sublen; + break; + } + case PROTOBUF_C_TYPE_MESSAGE: { + uint8_t simple_buffer_scratch[256]; + size_t sublen; + const ProtobufCMessage *msg = *(ProtobufCMessage * const *) member; + ProtobufCBufferSimple simple_buffer = + PROTOBUF_C_BUFFER_SIMPLE_INIT(simple_buffer_scratch); + + scratch[0] |= PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED; + if (msg == NULL) + sublen = 0; + else + sublen = protobuf_c_message_pack_to_buffer(msg, &simple_buffer.base); + rv += uint32_pack(sublen, scratch + rv); + buffer->append(buffer, rv, scratch); + buffer->append(buffer, sublen, simple_buffer.data); + rv += sublen; + PROTOBUF_C_BUFFER_SIMPLE_CLEAR(&simple_buffer); + break; + } + default: + PROTOBUF_C__ASSERT_NOT_REACHED(); + } + return rv; +} + +/** + * Pack a oneof field to a buffer. Only packs the field that is selected by the case enum. + * + * \param field + * Field descriptor. + * \param oneof_case + * Enum value that selects the field in the oneof. + * \param member + * The element to be packed. + * \param[out] buffer + * Virtual buffer to append data to. + * \return + * Number of bytes serialised to `buffer`. + */ static size_t -optional_field_pack_to_buffer (const ProtobufCFieldDescriptor *field, - const protobuf_c_boolean *has, - const void *member, - ProtobufCBuffer *buffer) -{ - if (field->type == PROTOBUF_C_TYPE_MESSAGE - || field->type == PROTOBUF_C_TYPE_STRING) - { - const void *ptr = * (const void * const *) member; - if (ptr == NULL - || ptr == field->default_value) - return 0; - } - else - { - if (!*has) - return 0; - } - return required_field_pack_to_buffer (field, member, buffer); -} - +oneof_field_pack_to_buffer(const ProtobufCFieldDescriptor *field, + uint32_t oneof_case, + const void *member, ProtobufCBuffer *buffer) +{ + if (oneof_case != field->id) { + return 0; + } + if (field->type == PROTOBUF_C_TYPE_MESSAGE || + field->type == PROTOBUF_C_TYPE_STRING) + { + const void *ptr = *(const void *const *) member; + if (ptr == NULL || ptr == field->default_value) + return 0; + } + return required_field_pack_to_buffer(field, member, buffer); +} + +/** + * Pack an optional field to a buffer. + * + * \param field + * Field descriptor. + * \param has + * Whether the field is set. + * \param member + * The element to be packed. + * \param[out] buffer + * Virtual buffer to append data to. + * \return + * Number of bytes serialised to `buffer`. + */ static size_t -get_packed_payload_length (const ProtobufCFieldDescriptor *field, - unsigned count, - const void *array) -{ - unsigned rv = 0; - unsigned i; - switch (field->type) - { - case PROTOBUF_C_TYPE_SFIXED32: - case PROTOBUF_C_TYPE_FIXED32: - case PROTOBUF_C_TYPE_FLOAT: - return count * 4; - - case PROTOBUF_C_TYPE_SFIXED64: - case PROTOBUF_C_TYPE_FIXED64: - case PROTOBUF_C_TYPE_DOUBLE: - return count * 8; - - case PROTOBUF_C_TYPE_INT32: - { - const int32_t *arr = (const int32_t *) array; - for (i = 0; i < count; i++) - rv += int32_size (arr[i]); - } - break; - - case PROTOBUF_C_TYPE_SINT32: - { - const int32_t *arr = (const int32_t *) array; - for (i = 0; i < count; i++) - rv += sint32_size (arr[i]); - } - break; - case PROTOBUF_C_TYPE_ENUM: - case PROTOBUF_C_TYPE_UINT32: - { - const uint32_t *arr = (const uint32_t *) array; - for (i = 0; i < count; i++) - rv += uint32_size (arr[i]); - } - break; - - case PROTOBUF_C_TYPE_SINT64: - { - const int64_t *arr = (const int64_t *) array; - for (i = 0; i < count; i++) - rv += sint64_size (arr[i]); - } - break; - case PROTOBUF_C_TYPE_INT64: - case PROTOBUF_C_TYPE_UINT64: - { - const uint64_t *arr = (const uint64_t *) array; - for (i = 0; i < count; i++) - rv += uint64_size (arr[i]); - } - break; - case PROTOBUF_C_TYPE_BOOL: - return count; - default: - assert (0); - } - return rv; -} +optional_field_pack_to_buffer(const ProtobufCFieldDescriptor *field, + const protobuf_c_boolean has, + const void *member, ProtobufCBuffer *buffer) +{ + if (field->type == PROTOBUF_C_TYPE_MESSAGE || + field->type == PROTOBUF_C_TYPE_STRING) + { + const void *ptr = *(const void *const *) member; + if (ptr == NULL || ptr == field->default_value) + return 0; + } else { + if (!has) + return 0; + } + return required_field_pack_to_buffer(field, member, buffer); +} + +/** + * Pack an unlabeled field to a buffer. + * + * \param field + * Field descriptor. + * \param member + * The element to be packed. + * \param[out] buffer + * Virtual buffer to append data to. + * \return + * Number of bytes serialised to `buffer`. + */ +static size_t +unlabeled_field_pack_to_buffer(const ProtobufCFieldDescriptor *field, + const void *member, ProtobufCBuffer *buffer) +{ + if (field_is_zeroish(field, member)) + return 0; + return required_field_pack_to_buffer(field, member, buffer); +} + +/** + * Get the packed size of an array of same field type. + * + * \param field + * Field descriptor. + * \param count + * Number of elements of this type. + * \param array + * The elements to get the size of. + * \return + * Number of bytes required. + */ +static size_t +get_packed_payload_length(const ProtobufCFieldDescriptor *field, + unsigned count, const void *array) +{ + unsigned rv = 0; + unsigned i; + + switch (field->type) { + case PROTOBUF_C_TYPE_SFIXED32: + case PROTOBUF_C_TYPE_FIXED32: + case PROTOBUF_C_TYPE_FLOAT: + return count * 4; + case PROTOBUF_C_TYPE_SFIXED64: + case PROTOBUF_C_TYPE_FIXED64: + case PROTOBUF_C_TYPE_DOUBLE: + return count * 8; + case PROTOBUF_C_TYPE_ENUM: + case PROTOBUF_C_TYPE_INT32: { + const int32_t *arr = (const int32_t *) array; + for (i = 0; i < count; i++) + rv += int32_size(arr[i]); + break; + } + case PROTOBUF_C_TYPE_SINT32: { + const int32_t *arr = (const int32_t *) array; + for (i = 0; i < count; i++) + rv += sint32_size(arr[i]); + break; + } + case PROTOBUF_C_TYPE_UINT32: { + const uint32_t *arr = (const uint32_t *) array; + for (i = 0; i < count; i++) + rv += uint32_size(arr[i]); + break; + } + case PROTOBUF_C_TYPE_SINT64: { + const int64_t *arr = (const int64_t *) array; + for (i = 0; i < count; i++) + rv += sint64_size(arr[i]); + break; + } + case PROTOBUF_C_TYPE_INT64: + case PROTOBUF_C_TYPE_UINT64: { + const uint64_t *arr = (const uint64_t *) array; + for (i = 0; i < count; i++) + rv += uint64_size(arr[i]); + break; + } + case PROTOBUF_C_TYPE_BOOL: + return count; + default: + PROTOBUF_C__ASSERT_NOT_REACHED(); + } + return rv; +} + +/** + * Pack an array of same field type to a virtual buffer. + * + * \param field + * Field descriptor. + * \param count + * Number of elements of this type. + * \param array + * The elements to get the size of. + * \param[out] buffer + * Virtual buffer to append data to. + * \return + * Number of bytes packed. + */ static size_t -pack_buffer_packed_payload (const ProtobufCFieldDescriptor *field, - unsigned count, - const void *array, - ProtobufCBuffer *buffer) -{ - uint8_t scratch[16]; - size_t rv = 0; - unsigned i; - switch (field->type) - { - case PROTOBUF_C_TYPE_SFIXED32: - case PROTOBUF_C_TYPE_FIXED32: - case PROTOBUF_C_TYPE_FLOAT: -#if 0 //IS_LITTLE_ENDIAN - rv = count * 4; - goto no_packing_needed; +pack_buffer_packed_payload(const ProtobufCFieldDescriptor *field, + unsigned count, const void *array, + ProtobufCBuffer *buffer) +{ + uint8_t scratch[16]; + size_t rv = 0; + unsigned i; + + switch (field->type) { + case PROTOBUF_C_TYPE_SFIXED32: + case PROTOBUF_C_TYPE_FIXED32: + case PROTOBUF_C_TYPE_FLOAT: +#if !defined(WORDS_BIGENDIAN) + rv = count * 4; + goto no_packing_needed; #else - for (i = 0; i < count; i++) - { - unsigned len = fixed32_pack (((uint32_t*)array)[i], scratch); - buffer->append (buffer, len, scratch); - rv += len; - } + for (i = 0; i < count; i++) { + unsigned len = fixed32_pack(((uint32_t *) array)[i], scratch); + buffer->append(buffer, len, scratch); + rv += len; + } + break; #endif - break; - case PROTOBUF_C_TYPE_SFIXED64: - case PROTOBUF_C_TYPE_FIXED64: - case PROTOBUF_C_TYPE_DOUBLE: -#if 0 //IS_LITTLE_ENDIAN - rv = count * 8; - goto no_packing_needed; + case PROTOBUF_C_TYPE_SFIXED64: + case PROTOBUF_C_TYPE_FIXED64: + case PROTOBUF_C_TYPE_DOUBLE: +#if !defined(WORDS_BIGENDIAN) + rv = count * 8; + goto no_packing_needed; #else - for (i = 0; i < count; i++) - { - unsigned len = fixed64_pack (((uint64_t*)array)[i], scratch); - buffer->append (buffer, len, scratch); - rv += len; - } - break; + for (i = 0; i < count; i++) { + unsigned len = fixed64_pack(((uint64_t *) array)[i], scratch); + buffer->append(buffer, len, scratch); + rv += len; + } + break; +#endif + case PROTOBUF_C_TYPE_ENUM: + case PROTOBUF_C_TYPE_INT32: + for (i = 0; i < count; i++) { + unsigned len = int32_pack(((int32_t *) array)[i], scratch); + buffer->append(buffer, len, scratch); + rv += len; + } + break; + case PROTOBUF_C_TYPE_SINT32: + for (i = 0; i < count; i++) { + unsigned len = sint32_pack(((int32_t *) array)[i], scratch); + buffer->append(buffer, len, scratch); + rv += len; + } + break; + case PROTOBUF_C_TYPE_UINT32: + for (i = 0; i < count; i++) { + unsigned len = uint32_pack(((uint32_t *) array)[i], scratch); + buffer->append(buffer, len, scratch); + rv += len; + } + break; + case PROTOBUF_C_TYPE_SINT64: + for (i = 0; i < count; i++) { + unsigned len = sint64_pack(((int64_t *) array)[i], scratch); + buffer->append(buffer, len, scratch); + rv += len; + } + break; + case PROTOBUF_C_TYPE_INT64: + case PROTOBUF_C_TYPE_UINT64: + for (i = 0; i < count; i++) { + unsigned len = uint64_pack(((uint64_t *) array)[i], scratch); + buffer->append(buffer, len, scratch); + rv += len; + } + break; + case PROTOBUF_C_TYPE_BOOL: + for (i = 0; i < count; i++) { + unsigned len = boolean_pack(((protobuf_c_boolean *) array)[i], scratch); + buffer->append(buffer, len, scratch); + rv += len; + } + return count; + default: + PROTOBUF_C__ASSERT_NOT_REACHED(); + } + return rv; + +#if !defined(WORDS_BIGENDIAN) +no_packing_needed: + buffer->append(buffer, rv, array); + return rv; #endif - case PROTOBUF_C_TYPE_INT32: - for (i = 0; i < count; i++) - { - unsigned len = int32_pack (((int32_t*)array)[i], scratch); - buffer->append (buffer, len, scratch); - rv += len; - } - break; - - case PROTOBUF_C_TYPE_SINT32: - for (i = 0; i < count; i++) - { - unsigned len = sint32_pack (((int32_t*)array)[i], scratch); - buffer->append (buffer, len, scratch); - rv += len; - } - break; - case PROTOBUF_C_TYPE_ENUM: - case PROTOBUF_C_TYPE_UINT32: - for (i = 0; i < count; i++) - { - unsigned len = uint32_pack (((uint32_t*)array)[i], scratch); - buffer->append (buffer, len, scratch); - rv += len; - } - break; - - case PROTOBUF_C_TYPE_SINT64: - for (i = 0; i < count; i++) - { - unsigned len = sint64_pack (((int64_t*)array)[i], scratch); - buffer->append (buffer, len, scratch); - rv += len; - } - break; - case PROTOBUF_C_TYPE_INT64: - case PROTOBUF_C_TYPE_UINT64: - for (i = 0; i < count; i++) - { - unsigned len = uint64_pack (((uint64_t*)array)[i], scratch); - buffer->append (buffer, len, scratch); - rv += len; - } - break; - case PROTOBUF_C_TYPE_BOOL: - for (i = 0; i < count; i++) - { - unsigned len = boolean_pack (((protobuf_c_boolean*)array)[i], scratch); - buffer->append (buffer, len, scratch); - rv += len; - } - return count; - default: - assert(0); - } - return rv; - -//no_packing_needed: -// buffer->append (buffer, rv, array); -// return rv; } static size_t -repeated_field_pack_to_buffer (const ProtobufCFieldDescriptor *field, - unsigned count, - const void *member, - ProtobufCBuffer *buffer) -{ - char *array = * (char * const *) member; - if (count == 0) - return 0; - if (field->packed) - { - uint8_t scratch[MAX_UINT64_ENCODED_SIZE * 2]; - size_t rv = tag_pack (field->id, scratch); - size_t payload_len = get_packed_payload_length (field, count, array); - size_t tmp; - scratch[0] |= PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED; - rv += uint32_pack (payload_len, scratch + rv); - buffer->append (buffer, rv, scratch); - tmp = pack_buffer_packed_payload (field, count, array, buffer); - assert (tmp == payload_len); - return rv + payload_len; - } - else - { - size_t siz; - unsigned i; - /* CONSIDER: optimize this case a bit (by putting the loop inside the switch) */ - unsigned rv = 0; - siz = sizeof_elt_in_repeated_array (field->type); - for (i = 0; i < count; i++) - { - rv += required_field_pack_to_buffer (field, array, buffer); - array += siz; - } - return rv; - } +repeated_field_pack_to_buffer(const ProtobufCFieldDescriptor *field, + unsigned count, const void *member, + ProtobufCBuffer *buffer) +{ + char *array = *(char * const *) member; + + if (count == 0) + return 0; + if (0 != (field->flags & PROTOBUF_C_FIELD_FLAG_PACKED)) { + uint8_t scratch[MAX_UINT64_ENCODED_SIZE * 2]; + size_t rv = tag_pack(field->id, scratch); + size_t payload_len = get_packed_payload_length(field, count, array); + size_t tmp; + + scratch[0] |= PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED; + rv += uint32_pack(payload_len, scratch + rv); + buffer->append(buffer, rv, scratch); + tmp = pack_buffer_packed_payload(field, count, array, buffer); + assert(tmp == payload_len); + return rv + payload_len; + } else { + size_t siz; + unsigned i; + /* CONSIDER: optimize this case a bit (by putting the loop inside the switch) */ + unsigned rv = 0; + + siz = sizeof_elt_in_repeated_array(field->type); + for (i = 0; i < count; i++) { + rv += required_field_pack_to_buffer(field, array, buffer); + array += siz; + } + return rv; + } } static size_t -unknown_field_pack_to_buffer (const ProtobufCMessageUnknownField *field, - ProtobufCBuffer *buffer) +unknown_field_pack_to_buffer(const ProtobufCMessageUnknownField *field, + ProtobufCBuffer *buffer) { - uint8_t header[MAX_UINT64_ENCODED_SIZE]; - size_t rv = tag_pack (field->tag, header); - header[0] |= field->wire_type; - buffer->append (buffer, rv, header); - buffer->append (buffer, field->len, field->data); - return rv + field->len; + uint8_t header[MAX_UINT64_ENCODED_SIZE]; + size_t rv = tag_pack(field->tag, header); + + header[0] |= field->wire_type; + buffer->append(buffer, rv, header); + buffer->append(buffer, field->len, field->data); + return rv + field->len; } +/**@}*/ + size_t -protobuf_c_message_pack_to_buffer (const ProtobufCMessage *message, - ProtobufCBuffer *buffer) -{ - unsigned i; - size_t rv = 0; - ASSERT_IS_MESSAGE (message); - for (i = 0; i < message->descriptor->n_fields; i++) - { - const ProtobufCFieldDescriptor *field = message->descriptor->fields + i; - const void *member = ((const char *) message) + field->offset; - const void *qmember = ((const char *) message) + field->quantifier_offset; - - if (field->label == PROTOBUF_C_LABEL_REQUIRED) - rv += required_field_pack_to_buffer (field, member, buffer); - else if (field->label == PROTOBUF_C_LABEL_OPTIONAL) - rv += optional_field_pack_to_buffer (field, qmember, member, buffer); - else - rv += repeated_field_pack_to_buffer (field, * (const size_t *) qmember, member, buffer); - } - for (i = 0; i < message->n_unknown_fields; i++) - rv += unknown_field_pack_to_buffer (&message->unknown_fields[i], buffer); - - return rv; -} - -/* === unpacking === */ -#if PRINT_UNPACK_ERRORS -# define UNPACK_ERROR(args) do { printf args;printf("\n"); }while(0) -#else -# define UNPACK_ERROR(args) do { } while (0) -#endif +protobuf_c_message_pack_to_buffer(const ProtobufCMessage *message, + ProtobufCBuffer *buffer) +{ + unsigned i; + size_t rv = 0; + + ASSERT_IS_MESSAGE(message); + for (i = 0; i < message->descriptor->n_fields; i++) { + const ProtobufCFieldDescriptor *field = + message->descriptor->fields + i; + const void *member = + ((const char *) message) + field->offset; + const void *qmember = + ((const char *) message) + field->quantifier_offset; + + if (field->label == PROTOBUF_C_LABEL_REQUIRED) { + rv += required_field_pack_to_buffer(field, member, buffer); + } else if ((field->label == PROTOBUF_C_LABEL_OPTIONAL || + field->label == PROTOBUF_C_LABEL_NONE) && + (0 != (field->flags & PROTOBUF_C_FIELD_FLAG_ONEOF))) { + rv += oneof_field_pack_to_buffer( + field, + *(const uint32_t *) qmember, + member, + buffer + ); + } else if (field->label == PROTOBUF_C_LABEL_OPTIONAL) { + rv += optional_field_pack_to_buffer( + field, + *(const protobuf_c_boolean *) qmember, + member, + buffer + ); + } else if (field->label == PROTOBUF_C_LABEL_NONE) { + rv += unlabeled_field_pack_to_buffer( + field, + member, + buffer + ); + } else { + rv += repeated_field_pack_to_buffer( + field, + *(const size_t *) qmember, + member, + buffer + ); + } + } + for (i = 0; i < message->n_unknown_fields; i++) + rv += unknown_field_pack_to_buffer(&message->unknown_fields[i], buffer); + + return rv; +} + +/** + * \defgroup unpack unpacking implementation + * + * Routines mainly used by the unpacking functions. + * + * \ingroup internal + * @{ + */ static inline int -int_range_lookup (unsigned n_ranges, - const ProtobufCIntRange *ranges, - int value) -{ - unsigned start, n; - if (n_ranges == 0) - return -1; - start = 0; - n = n_ranges; - while (n > 1) - { - unsigned mid = start + n / 2; - if (value < ranges[mid].start_value) - { - n = mid - start; - } - else if (value >= ranges[mid].start_value + (int)(ranges[mid+1].orig_index-ranges[mid].orig_index)) - { - unsigned new_start = mid + 1; - n = start + n - new_start; - start = new_start; - } - else - return (value - ranges[mid].start_value) + ranges[mid].orig_index; - } - if (n > 0) - { - unsigned start_orig_index = ranges[start].orig_index; - unsigned range_size = ranges[start+1].orig_index - start_orig_index; - - if (ranges[start].start_value <= value - && value < (int)(ranges[start].start_value + range_size)) - return (value - ranges[start].start_value) + start_orig_index; - } - return -1; +int_range_lookup(unsigned n_ranges, const ProtobufCIntRange *ranges, int value) +{ + unsigned n; + unsigned start; + + if (n_ranges == 0) + return -1; + start = 0; + n = n_ranges; + while (n > 1) { + unsigned mid = start + n / 2; + + if (value < ranges[mid].start_value) { + n = mid - start; + } else if (value >= ranges[mid].start_value + + (int) (ranges[mid + 1].orig_index - + ranges[mid].orig_index)) + { + unsigned new_start = mid + 1; + n = start + n - new_start; + start = new_start; + } else + return (value - ranges[mid].start_value) + + ranges[mid].orig_index; + } + if (n > 0) { + unsigned start_orig_index = ranges[start].orig_index; + unsigned range_size = + ranges[start + 1].orig_index - start_orig_index; + + if (ranges[start].start_value <= value && + value < (int) (ranges[start].start_value + range_size)) + { + return (value - ranges[start].start_value) + + start_orig_index; + } + } + return -1; } static size_t -parse_tag_and_wiretype (size_t len, - const uint8_t *data, - uint32_t *tag_out, - ProtobufCWireType *wiretype_out) -{ - unsigned max_rv = len > 5 ? 5 : len; - uint32_t tag = (data[0]&0x7f) >> 3; - unsigned shift = 4; - unsigned rv; - *wiretype_out = data[0] & 7; - if ((data[0] & 0x80) == 0) - { - *tag_out = tag; - return 1; - } - for (rv = 1; rv < max_rv; rv++) - if (data[rv] & 0x80) - { - tag |= (data[rv] & 0x7f) << shift; - shift += 7; - } - else - { - tag |= data[rv] << shift; - *tag_out = tag; - return rv + 1; - } - return 0; /* error: bad header */ -} - -/* sizeof(ScannedMember) must be <= (1<<BOUND_SIZEOF_SCANNED_MEMBER_LOG2) */ -#define BOUND_SIZEOF_SCANNED_MEMBER_LOG2 5 +parse_tag_and_wiretype(size_t len, + const uint8_t *data, + uint32_t *tag_out, + ProtobufCWireType *wiretype_out) +{ + unsigned max_rv = len > 5 ? 5 : len; + uint32_t tag = (data[0] & 0x7f) >> 3; + unsigned shift = 4; + unsigned rv; + + *wiretype_out = data[0] & 7; + if ((data[0] & 0x80) == 0) { + *tag_out = tag; + return 1; + } + for (rv = 1; rv < max_rv; rv++) { + if (data[rv] & 0x80) { + tag |= (data[rv] & 0x7f) << shift; + shift += 7; + } else { + tag |= data[rv] << shift; + *tag_out = tag; + return rv + 1; + } + } + return 0; /* error: bad header */ +} + +/* sizeof(ScannedMember) must be <= (1UL<<BOUND_SIZEOF_SCANNED_MEMBER_LOG2) */ +#define BOUND_SIZEOF_SCANNED_MEMBER_LOG2 5 typedef struct _ScannedMember ScannedMember; -struct _ScannedMember -{ - uint32_t tag; - uint8_t wire_type; - uint8_t length_prefix_len; - const ProtobufCFieldDescriptor *field; - size_t len; - const uint8_t *data; +/** Field as it's being read. */ +struct _ScannedMember { + uint32_t tag; /**< Field tag. */ + uint8_t wire_type; /**< Field type. */ + uint8_t length_prefix_len; /**< Prefix length. */ + const ProtobufCFieldDescriptor *field; /**< Field descriptor. */ + size_t len; /**< Field length. */ + const uint8_t *data; /**< Pointer to field data. */ }; static inline uint32_t -scan_length_prefixed_data (size_t len, const uint8_t *data, size_t *prefix_len_out) -{ - unsigned hdr_max = len < 5 ? len : 5; - unsigned hdr_len; - uint32_t val = 0; - unsigned i; - unsigned shift = 0; - for (i = 0; i < hdr_max; i++) - { - val |= (data[i] & 0x7f) << shift; - shift += 7; - if ((data[i] & 0x80) == 0) - break; - } - if (i == hdr_max) - { - UNPACK_ERROR (("error parsing length for length-prefixed data")); - return 0; - } - hdr_len = i + 1; - *prefix_len_out = hdr_len; - if (hdr_len + val > len) - { - UNPACK_ERROR (("data too short after length-prefix of %u", - val)); - return 0; - } - return hdr_len + val; -} - -static size_t -max_b128_numbers (size_t len, const uint8_t *data) -{ - size_t rv = 0; - while (len--) - if ((*data++ & 0x80) == 0) - ++rv; - return rv; -} - - -/* Given a raw slab of packed-repeated values, - determine the number of elements. - This function detects certain kinds of errors - but not others; the remaining error checking is done by - parse_packed_repeated_member() */ +scan_length_prefixed_data(size_t len, const uint8_t *data, + size_t *prefix_len_out) +{ + unsigned hdr_max = len < 5 ? len : 5; + unsigned hdr_len; + uint32_t val = 0; + unsigned i; + unsigned shift = 0; + + for (i = 0; i < hdr_max; i++) { + val |= (data[i] & 0x7f) << shift; + shift += 7; + if ((data[i] & 0x80) == 0) + break; + } + if (i == hdr_max) { + PROTOBUF_C_UNPACK_ERROR("error parsing length for length-prefixed data"); + return 0; + } + hdr_len = i + 1; + *prefix_len_out = hdr_len; + if (hdr_len + val > len) { + PROTOBUF_C_UNPACK_ERROR("data too short after length-prefix of %u", val); + return 0; + } + return hdr_len + val; +} + +static size_t +max_b128_numbers(size_t len, const uint8_t *data) +{ + size_t rv = 0; + while (len--) + if ((*data++ & 0x80) == 0) + ++rv; + return rv; +} + +/**@}*/ + +/** + * Merge earlier message into a latter message. + * + * For numeric types and strings, if the same value appears multiple + * times, the parser accepts the last value it sees. For embedded + * message fields, the parser merges multiple instances of the same + * field. That is, all singular scalar fields in the latter instance + * replace those in the former, singular embedded messages are merged, + * and repeated fields are concatenated. + * + * The earlier message should be freed after calling this function, as + * some of its fields may have been reused and changed to their default + * values during the merge. + */ +static protobuf_c_boolean +merge_messages(ProtobufCMessage *earlier_msg, + ProtobufCMessage *latter_msg, + ProtobufCAllocator *allocator) +{ + unsigned i; + const ProtobufCFieldDescriptor *fields = + latter_msg->descriptor->fields; + for (i = 0; i < latter_msg->descriptor->n_fields; i++) { + if (fields[i].label == PROTOBUF_C_LABEL_REPEATED) { + size_t *n_earlier = + STRUCT_MEMBER_PTR(size_t, earlier_msg, + fields[i].quantifier_offset); + uint8_t **p_earlier = + STRUCT_MEMBER_PTR(uint8_t *, earlier_msg, + fields[i].offset); + size_t *n_latter = + STRUCT_MEMBER_PTR(size_t, latter_msg, + fields[i].quantifier_offset); + uint8_t **p_latter = + STRUCT_MEMBER_PTR(uint8_t *, latter_msg, + fields[i].offset); + + if (*n_earlier > 0) { + if (*n_latter > 0) { + /* Concatenate the repeated field */ + size_t el_size = + sizeof_elt_in_repeated_array(fields[i].type); + uint8_t *new_field; + + new_field = do_alloc(allocator, + (*n_earlier + *n_latter) * el_size); + if (!new_field) + return FALSE; + + memcpy(new_field, *p_earlier, + *n_earlier * el_size); + memcpy(new_field + + *n_earlier * el_size, + *p_latter, + *n_latter * el_size); + + do_free(allocator, *p_latter); + do_free(allocator, *p_earlier); + *p_latter = new_field; + *n_latter = *n_earlier + *n_latter; + } else { + /* Zero copy the repeated field from the earlier message */ + *n_latter = *n_earlier; + *p_latter = *p_earlier; + } + /* Make sure the field does not get double freed */ + *n_earlier = 0; + *p_earlier = 0; + } + } else if (fields[i].label == PROTOBUF_C_LABEL_OPTIONAL || + fields[i].label == PROTOBUF_C_LABEL_NONE) { + const ProtobufCFieldDescriptor *field; + uint32_t *earlier_case_p = STRUCT_MEMBER_PTR(uint32_t, + earlier_msg, + fields[i]. + quantifier_offset); + uint32_t *latter_case_p = STRUCT_MEMBER_PTR(uint32_t, + latter_msg, + fields[i]. + quantifier_offset); + protobuf_c_boolean need_to_merge = FALSE; + void *earlier_elem; + void *latter_elem; + const void *def_val; + + if (fields[i].flags & PROTOBUF_C_FIELD_FLAG_ONEOF) { + if (*latter_case_p == 0) { + /* lookup correct oneof field */ + int field_index = + int_range_lookup( + latter_msg->descriptor + ->n_field_ranges, + latter_msg->descriptor + ->field_ranges, + *earlier_case_p); + field = latter_msg->descriptor->fields + + field_index; + } else { + /* Oneof is present in the latter message, move on */ + continue; + } + } else { + field = &fields[i]; + } + + earlier_elem = STRUCT_MEMBER_P(earlier_msg, field->offset); + latter_elem = STRUCT_MEMBER_P(latter_msg, field->offset); + def_val = field->default_value; + + switch (field->type) { + case PROTOBUF_C_TYPE_MESSAGE: { + ProtobufCMessage *em = *(ProtobufCMessage **) earlier_elem; + ProtobufCMessage *lm = *(ProtobufCMessage **) latter_elem; + if (em != NULL) { + if (lm != NULL) { + if (!merge_messages(em, lm, allocator)) + return FALSE; + /* Already merged */ + need_to_merge = FALSE; + } else { + /* Zero copy the message */ + need_to_merge = TRUE; + } + } + break; + } + case PROTOBUF_C_TYPE_BYTES: { + uint8_t *e_data = + ((ProtobufCBinaryData *) earlier_elem)->data; + uint8_t *l_data = + ((ProtobufCBinaryData *) latter_elem)->data; + const ProtobufCBinaryData *d_bd = + (ProtobufCBinaryData *) def_val; + + need_to_merge = + (e_data != NULL && + (d_bd == NULL || + e_data != d_bd->data)) && + (l_data == NULL || + (d_bd != NULL && + l_data == d_bd->data)); + break; + } + case PROTOBUF_C_TYPE_STRING: { + char *e_str = *(char **) earlier_elem; + char *l_str = *(char **) latter_elem; + const char *d_str = def_val; + + need_to_merge = e_str != d_str && l_str == d_str; + break; + } + default: { + /* Could be has field or case enum, the logic is + * equivalent, since 0 (FALSE) means not set for + * oneof */ + need_to_merge = (*earlier_case_p != 0) && + (*latter_case_p == 0); + break; + } + } + + if (need_to_merge) { + size_t el_size = + sizeof_elt_in_repeated_array(field->type); + memcpy(latter_elem, earlier_elem, el_size); + /* + * Reset the element from the old message to 0 + * to make sure earlier message deallocation + * doesn't corrupt zero-copied data in the new + * message, earlier message will be freed after + * this function is called anyway + */ + memset(earlier_elem, 0, el_size); + + if (field->quantifier_offset != 0) { + /* Set the has field or the case enum, + * if applicable */ + *latter_case_p = *earlier_case_p; + *earlier_case_p = 0; + } + } + } + } + return TRUE; +} + +/** + * Count packed elements. + * + * Given a raw slab of packed-repeated values, determine the number of + * elements. This function detects certain kinds of errors but not + * others; the remaining error checking is done by + * parse_packed_repeated_member(). + */ static protobuf_c_boolean -count_packed_elements (ProtobufCType type, - size_t len, - const uint8_t *data, - size_t *count_out) -{ - switch (type) - { - case PROTOBUF_C_TYPE_SFIXED32: - case PROTOBUF_C_TYPE_FIXED32: - case PROTOBUF_C_TYPE_FLOAT: - if (len % 4 != 0) - { - UNPACK_ERROR (("length must be a multiple of 4 for fixed-length 32-bit types")); - return FALSE; - } - *count_out = len / 4; - return TRUE; - - case PROTOBUF_C_TYPE_SFIXED64: - case PROTOBUF_C_TYPE_FIXED64: - case PROTOBUF_C_TYPE_DOUBLE: - if (len % 8 != 0) - { - UNPACK_ERROR (("length must be a multiple of 8 for fixed-length 64-bit types")); - return FALSE; - } - *count_out = len / 8; - return TRUE; - - case PROTOBUF_C_TYPE_INT32: - case PROTOBUF_C_TYPE_SINT32: - case PROTOBUF_C_TYPE_ENUM: - case PROTOBUF_C_TYPE_UINT32: - case PROTOBUF_C_TYPE_INT64: - case PROTOBUF_C_TYPE_SINT64: - case PROTOBUF_C_TYPE_UINT64: - *count_out = max_b128_numbers (len, data); - return TRUE; - case PROTOBUF_C_TYPE_BOOL: - *count_out = len; - return TRUE; - - case PROTOBUF_C_TYPE_STRING: - case PROTOBUF_C_TYPE_BYTES: - case PROTOBUF_C_TYPE_MESSAGE: - default: - UNPACK_ERROR (("bad protobuf-c type %u for packed-repeated", type)); - return FALSE; - } +count_packed_elements(ProtobufCType type, + size_t len, const uint8_t *data, size_t *count_out) +{ + switch (type) { + case PROTOBUF_C_TYPE_SFIXED32: + case PROTOBUF_C_TYPE_FIXED32: + case PROTOBUF_C_TYPE_FLOAT: + if (len % 4 != 0) { + PROTOBUF_C_UNPACK_ERROR("length must be a multiple of 4 for fixed-length 32-bit types"); + return FALSE; + } + *count_out = len / 4; + return TRUE; + case PROTOBUF_C_TYPE_SFIXED64: + case PROTOBUF_C_TYPE_FIXED64: + case PROTOBUF_C_TYPE_DOUBLE: + if (len % 8 != 0) { + PROTOBUF_C_UNPACK_ERROR("length must be a multiple of 8 for fixed-length 64-bit types"); + return FALSE; + } + *count_out = len / 8; + return TRUE; + case PROTOBUF_C_TYPE_ENUM: + case PROTOBUF_C_TYPE_INT32: + case PROTOBUF_C_TYPE_SINT32: + case PROTOBUF_C_TYPE_UINT32: + case PROTOBUF_C_TYPE_INT64: + case PROTOBUF_C_TYPE_SINT64: + case PROTOBUF_C_TYPE_UINT64: + *count_out = max_b128_numbers(len, data); + return TRUE; + case PROTOBUF_C_TYPE_BOOL: + *count_out = len; + return TRUE; + case PROTOBUF_C_TYPE_STRING: + case PROTOBUF_C_TYPE_BYTES: + case PROTOBUF_C_TYPE_MESSAGE: + default: + PROTOBUF_C_UNPACK_ERROR("bad protobuf-c type %u for packed-repeated", type); + return FALSE; + } } static inline uint32_t -parse_uint32 (unsigned len, const uint8_t *data) -{ - unsigned rv = data[0] & 0x7f; - if (len > 1) - { - rv |= ((data[1] & 0x7f) << 7); - if (len > 2) - { - rv |= ((data[2] & 0x7f) << 14); - if (len > 3) - { - rv |= ((data[3] & 0x7f) << 21); - if (len > 4) - rv |= (data[4] << 28); - } - } - } - return rv; +parse_uint32(unsigned len, const uint8_t *data) +{ + uint32_t rv = data[0] & 0x7f; + if (len > 1) { + rv |= ((uint32_t) (data[1] & 0x7f) << 7); + if (len > 2) { + rv |= ((uint32_t) (data[2] & 0x7f) << 14); + if (len > 3) { + rv |= ((uint32_t) (data[3] & 0x7f) << 21); + if (len > 4) + rv |= ((uint32_t) (data[4]) << 28); + } + } + } + return rv; } + static inline uint32_t -parse_int32 (unsigned len, const uint8_t *data) +parse_int32(unsigned len, const uint8_t *data) { - return parse_uint32 (len, data); + return parse_uint32(len, data); } + static inline int32_t -unzigzag32 (uint32_t v) +unzigzag32(uint32_t v) { - if (v&1) - return -(v>>1) - 1; - else - return v>>1; + if (v & 1) + return -(v >> 1) - 1; + else + return v >> 1; } + static inline uint32_t -parse_fixed_uint32 (const uint8_t *data) +parse_fixed_uint32(const uint8_t *data) { -#if 0 //IS_LITTLE_ENDIAN - uint32_t t; - memcpy (&t, data, 4); - return t; +#if !defined(WORDS_BIGENDIAN) + uint32_t t; + memcpy(&t, data, 4); + return t; #else - return data[0] | (data[1] << 8) | (data[2] << 16) | (data[3] << 24); + return data[0] | + ((uint32_t) (data[1]) << 8) | + ((uint32_t) (data[2]) << 16) | + ((uint32_t) (data[3]) << 24); #endif } + static uint64_t -parse_uint64 (unsigned len, const uint8_t *data) -{ - unsigned shift, i; - uint64_t rv; - if (len < 5) - return parse_uint32 (len, data); - rv = ((data[0] & 0x7f)) - | ((data[1] & 0x7f)<<7) - | ((data[2] & 0x7f)<<14) - | ((data[3] & 0x7f)<<21); - shift = 28; - for (i = 4; i < len; i++) - { - rv |= (((uint64_t)(data[i]&0x7f)) << shift); - shift += 7; - } - return rv; +parse_uint64(unsigned len, const uint8_t *data) +{ + unsigned shift, i; + uint64_t rv; + + if (len < 5) + return parse_uint32(len, data); + rv = ((uint64_t) (data[0] & 0x7f)) | + ((uint64_t) (data[1] & 0x7f) << 7) | + ((uint64_t) (data[2] & 0x7f) << 14) | + ((uint64_t) (data[3] & 0x7f) << 21); + shift = 28; + for (i = 4; i < len; i++) { + rv |= (((uint64_t) (data[i] & 0x7f)) << shift); + shift += 7; + } + return rv; } + static inline int64_t -unzigzag64 (uint64_t v) +unzigzag64(uint64_t v) { - if (v&1) - return -(v>>1) - 1; - else - return v>>1; + if (v & 1) + return -(v >> 1) - 1; + else + return v >> 1; } + static inline uint64_t -parse_fixed_uint64 (const uint8_t *data) +parse_fixed_uint64(const uint8_t *data) { -#if 0 //IS_LITTLE_ENDIAN - uint64_t t; - memcpy (&t, data, 8); - return t; +#if !defined(WORDS_BIGENDIAN) + uint64_t t; + memcpy(&t, data, 8); + return t; #else - return (uint64_t)parse_fixed_uint32 (data) - | (((uint64_t)parse_fixed_uint32(data+4)) << 32); + return (uint64_t) parse_fixed_uint32(data) | + (((uint64_t) parse_fixed_uint32(data + 4)) << 32); #endif } + static protobuf_c_boolean -parse_boolean (unsigned len, const uint8_t *data) +parse_boolean(unsigned len, const uint8_t *data) { - unsigned i; - for (i = 0; i < len; i++) - if (data[i] & 0x7f) - return 1; - return 0; + unsigned i; + for (i = 0; i < len; i++) + if (data[i] & 0x7f) + return TRUE; + return FALSE; +} + +static protobuf_c_boolean +parse_required_member(ScannedMember *scanned_member, + void *member, + ProtobufCAllocator *allocator, + protobuf_c_boolean maybe_clear) +{ + unsigned len = scanned_member->len; + const uint8_t *data = scanned_member->data; + ProtobufCWireType wire_type = scanned_member->wire_type; + + switch (scanned_member->field->type) { + case PROTOBUF_C_TYPE_ENUM: + case PROTOBUF_C_TYPE_INT32: + if (wire_type != PROTOBUF_C_WIRE_TYPE_VARINT) + return FALSE; + *(int32_t *) member = parse_int32(len, data); + return TRUE; + case PROTOBUF_C_TYPE_UINT32: + if (wire_type != PROTOBUF_C_WIRE_TYPE_VARINT) + return FALSE; + *(uint32_t *) member = parse_uint32(len, data); + return TRUE; + case PROTOBUF_C_TYPE_SINT32: + if (wire_type != PROTOBUF_C_WIRE_TYPE_VARINT) + return FALSE; + *(int32_t *) member = unzigzag32(parse_uint32(len, data)); + return TRUE; + case PROTOBUF_C_TYPE_SFIXED32: + case PROTOBUF_C_TYPE_FIXED32: + case PROTOBUF_C_TYPE_FLOAT: + if (wire_type != PROTOBUF_C_WIRE_TYPE_32BIT) + return FALSE; + *(uint32_t *) member = parse_fixed_uint32(data); + return TRUE; + case PROTOBUF_C_TYPE_INT64: + case PROTOBUF_C_TYPE_UINT64: + if (wire_type != PROTOBUF_C_WIRE_TYPE_VARINT) + return FALSE; + *(uint64_t *) member = parse_uint64(len, data); + return TRUE; + case PROTOBUF_C_TYPE_SINT64: + if (wire_type != PROTOBUF_C_WIRE_TYPE_VARINT) + return FALSE; + *(int64_t *) member = unzigzag64(parse_uint64(len, data)); + return TRUE; + case PROTOBUF_C_TYPE_SFIXED64: + case PROTOBUF_C_TYPE_FIXED64: + case PROTOBUF_C_TYPE_DOUBLE: + if (wire_type != PROTOBUF_C_WIRE_TYPE_64BIT) + return FALSE; + *(uint64_t *) member = parse_fixed_uint64(data); + return TRUE; + case PROTOBUF_C_TYPE_BOOL: + *(protobuf_c_boolean *) member = parse_boolean(len, data); + return TRUE; + case PROTOBUF_C_TYPE_STRING: { + char **pstr = member; + unsigned pref_len = scanned_member->length_prefix_len; + + if (wire_type != PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED) + return FALSE; + + if (maybe_clear && *pstr != NULL) { + const char *def = scanned_member->field->default_value; + if (*pstr != NULL && *pstr != def) + do_free(allocator, *pstr); + } + *pstr = do_alloc(allocator, len - pref_len + 1); + if (*pstr == NULL) + return FALSE; + memcpy(*pstr, data + pref_len, len - pref_len); + (*pstr)[len - pref_len] = 0; + return TRUE; + } + case PROTOBUF_C_TYPE_BYTES: { + ProtobufCBinaryData *bd = member; + const ProtobufCBinaryData *def_bd; + unsigned pref_len = scanned_member->length_prefix_len; + + if (wire_type != PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED) + return FALSE; + + def_bd = scanned_member->field->default_value; + if (maybe_clear && + bd->data != NULL && + (def_bd == NULL || bd->data != def_bd->data)) + { + do_free(allocator, bd->data); + } + if (len - pref_len > 0) { + bd->data = do_alloc(allocator, len - pref_len); + if (bd->data == NULL) + return FALSE; + memcpy(bd->data, data + pref_len, len - pref_len); + } else { + bd->data = NULL; + } + bd->len = len - pref_len; + return TRUE; + } + case PROTOBUF_C_TYPE_MESSAGE: { + ProtobufCMessage **pmessage = member; + ProtobufCMessage *subm; + const ProtobufCMessage *def_mess; + protobuf_c_boolean merge_successful = TRUE; + unsigned pref_len = scanned_member->length_prefix_len; + + if (wire_type != PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED) + return FALSE; + + def_mess = scanned_member->field->default_value; + subm = protobuf_c_message_unpack(scanned_member->field->descriptor, + allocator, + len - pref_len, + data + pref_len); + + if (maybe_clear && + *pmessage != NULL && + *pmessage != def_mess) + { + if (subm != NULL) + merge_successful = merge_messages(*pmessage, subm, allocator); + /* Delete the previous message */ + protobuf_c_message_free_unpacked(*pmessage, allocator); + } + *pmessage = subm; + if (subm == NULL || !merge_successful) + return FALSE; + return TRUE; + } + } + return FALSE; } + static protobuf_c_boolean -parse_required_member (ScannedMember *scanned_member, - void *member, - ProtobufCAllocator *allocator, - protobuf_c_boolean maybe_clear) -{ - unsigned len = scanned_member->len; - const uint8_t *data = scanned_member->data; - ProtobufCWireType wire_type = scanned_member->wire_type; - switch (scanned_member->field->type) - { - case PROTOBUF_C_TYPE_INT32: - if (wire_type != PROTOBUF_C_WIRE_TYPE_VARINT) - return 0; - *(uint32_t*)member = parse_int32 (len, data); - return 1; - case PROTOBUF_C_TYPE_UINT32: - if (wire_type != PROTOBUF_C_WIRE_TYPE_VARINT) - return 0; - *(uint32_t*)member = parse_uint32 (len, data); - return 1; - case PROTOBUF_C_TYPE_SINT32: - if (wire_type != PROTOBUF_C_WIRE_TYPE_VARINT) - return 0; - *(int32_t*)member = unzigzag32 (parse_uint32 (len, data)); - return 1; - case PROTOBUF_C_TYPE_SFIXED32: - case PROTOBUF_C_TYPE_FIXED32: - case PROTOBUF_C_TYPE_FLOAT: - if (wire_type != PROTOBUF_C_WIRE_TYPE_32BIT) - return 0; - *(uint32_t*)member = parse_fixed_uint32 (data); - return 1; - - case PROTOBUF_C_TYPE_INT64: - case PROTOBUF_C_TYPE_UINT64: - if (wire_type != PROTOBUF_C_WIRE_TYPE_VARINT) - return 0; - *(uint64_t*)member = parse_uint64 (len, data); - return 1; - case PROTOBUF_C_TYPE_SINT64: - if (wire_type != PROTOBUF_C_WIRE_TYPE_VARINT) - return 0; - *(int64_t*)member = unzigzag64 (parse_uint64 (len, data)); - return 1; - case PROTOBUF_C_TYPE_SFIXED64: - case PROTOBUF_C_TYPE_FIXED64: - case PROTOBUF_C_TYPE_DOUBLE: - if (wire_type != PROTOBUF_C_WIRE_TYPE_64BIT) - return 0; - *(uint64_t*)member = parse_fixed_uint64 (data); - return 1; - - case PROTOBUF_C_TYPE_BOOL: - *(protobuf_c_boolean*)member = parse_boolean (len, data); - return 1; - - case PROTOBUF_C_TYPE_ENUM: - if (wire_type != PROTOBUF_C_WIRE_TYPE_VARINT) - return 0; - *(uint32_t*)member = parse_uint32 (len, data); - return 1; - - case PROTOBUF_C_TYPE_STRING: - if (wire_type != PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED) - return 0; - { - char **pstr = member; - unsigned pref_len = scanned_member->length_prefix_len; - if (maybe_clear && *pstr != NULL) - { - const char *def = scanned_member->field->default_value; - if (*pstr != NULL && *pstr != def) - FREE (allocator, *pstr); - } - DO_ALLOC (*pstr, allocator, len - pref_len + 1, return 0); - memcpy (*pstr, data + pref_len, len - pref_len); - (*pstr)[len-pref_len] = 0; - return 1; - } - case PROTOBUF_C_TYPE_BYTES: - if (wire_type != PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED) - return 0; - { - ProtobufCBinaryData *bd = member; - const ProtobufCBinaryData *def_bd; - unsigned pref_len = scanned_member->length_prefix_len; - def_bd = scanned_member->field->default_value; - if (maybe_clear - && bd->data != NULL - && (def_bd == NULL || bd->data != def_bd->data)) - FREE (allocator, bd->data); - DO_ALLOC (bd->data, allocator, len - pref_len, return 0); - memcpy (bd->data, data + pref_len, len - pref_len); - bd->len = len - pref_len; - return 1; - } - //case PROTOBUF_C_TYPE_GROUP, // NOT SUPPORTED - case PROTOBUF_C_TYPE_MESSAGE: - if (wire_type != PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED) - return 0; - { - ProtobufCMessage **pmessage = member; - ProtobufCMessage *subm; - const ProtobufCMessage *def_mess; - unsigned pref_len = scanned_member->length_prefix_len; - def_mess = scanned_member->field->default_value; - if (maybe_clear && *pmessage != NULL && *pmessage != def_mess) - protobuf_c_message_free_unpacked (*pmessage, allocator); - subm = protobuf_c_message_unpack (scanned_member->field->descriptor, - allocator, - len - pref_len, data + pref_len); - *pmessage = subm; /* since we freed the message we must clear the field, even if NULL */ - if (subm == NULL) - return 0; - return 1; - } - } - return 0; +parse_oneof_member (ScannedMember *scanned_member, + void *member, + ProtobufCMessage *message, + ProtobufCAllocator *allocator) +{ + uint32_t *oneof_case = STRUCT_MEMBER_PTR(uint32_t, message, + scanned_member->field->quantifier_offset); + + /* If we have already parsed a member of this oneof, free it. */ + if (*oneof_case != 0) { + /* lookup field */ + int field_index = + int_range_lookup(message->descriptor->n_field_ranges, + message->descriptor->field_ranges, + *oneof_case); + const ProtobufCFieldDescriptor *old_field = + message->descriptor->fields + field_index; + size_t el_size = sizeof_elt_in_repeated_array(old_field->type); + + switch (old_field->type) { + case PROTOBUF_C_TYPE_STRING: { + char **pstr = member; + const char *def = old_field->default_value; + if (*pstr != NULL && *pstr != def) + do_free(allocator, *pstr); + break; + } + case PROTOBUF_C_TYPE_BYTES: { + ProtobufCBinaryData *bd = member; + const ProtobufCBinaryData *def_bd = old_field->default_value; + if (bd->data != NULL && + (def_bd == NULL || bd->data != def_bd->data)) + { + do_free(allocator, bd->data); + } + break; + } + case PROTOBUF_C_TYPE_MESSAGE: { + ProtobufCMessage **pmessage = member; + const ProtobufCMessage *def_mess = old_field->default_value; + if (*pmessage != NULL && *pmessage != def_mess) + protobuf_c_message_free_unpacked(*pmessage, allocator); + break; + } + default: + break; + } + + memset (member, 0, el_size); + } + if (!parse_required_member (scanned_member, member, allocator, TRUE)) + return FALSE; + + *oneof_case = scanned_member->tag; + return TRUE; } + static protobuf_c_boolean -parse_optional_member (ScannedMember *scanned_member, - void *member, - ProtobufCMessage *message, - ProtobufCAllocator *allocator) +parse_optional_member(ScannedMember *scanned_member, + void *member, + ProtobufCMessage *message, + ProtobufCAllocator *allocator) { - if (!parse_required_member (scanned_member, member, allocator, TRUE)) - return 0; - if (scanned_member->field->quantifier_offset != 0) - STRUCT_MEMBER (protobuf_c_boolean, - message, - scanned_member->field->quantifier_offset) = 1; - return 1; + if (!parse_required_member(scanned_member, member, allocator, TRUE)) + return FALSE; + if (scanned_member->field->quantifier_offset != 0) + STRUCT_MEMBER(protobuf_c_boolean, + message, + scanned_member->field->quantifier_offset) = TRUE; + return TRUE; } static protobuf_c_boolean -parse_repeated_member (ScannedMember *scanned_member, - void *member, - ProtobufCMessage *message, - ProtobufCAllocator *allocator) -{ - const ProtobufCFieldDescriptor *field = scanned_member->field; - size_t *p_n = STRUCT_MEMBER_PTR(size_t, message, field->quantifier_offset); - size_t siz = sizeof_elt_in_repeated_array (field->type); - char *array = *(char**)member; - if (!parse_required_member (scanned_member, - array + siz * (*p_n), - allocator, - FALSE)) - return 0; - *p_n += 1; - return 1; -} - -static unsigned scan_varint (unsigned len, const uint8_t *data) -{ - unsigned i; - if (len > 10) - len = 10; - for (i = 0; i < len; i++) - if ((data[i] & 0x80) == 0) - break; - if (i == len) - return 0; - return i + 1; +parse_repeated_member(ScannedMember *scanned_member, + void *member, + ProtobufCMessage *message, + ProtobufCAllocator *allocator) +{ + const ProtobufCFieldDescriptor *field = scanned_member->field; + size_t *p_n = STRUCT_MEMBER_PTR(size_t, message, field->quantifier_offset); + size_t siz = sizeof_elt_in_repeated_array(field->type); + char *array = *(char **) member; + + if (!parse_required_member(scanned_member, array + siz * (*p_n), + allocator, FALSE)) + { + return FALSE; + } + *p_n += 1; + return TRUE; +} + +static unsigned +scan_varint(unsigned len, const uint8_t *data) +{ + unsigned i; + if (len > 10) + len = 10; + for (i = 0; i < len; i++) + if ((data[i] & 0x80) == 0) + break; + if (i == len) + return 0; + return i + 1; } static protobuf_c_boolean -parse_packed_repeated_member (ScannedMember *scanned_member, - void *member, - ProtobufCMessage *message) -{ - const ProtobufCFieldDescriptor *field = scanned_member->field; - size_t *p_n = STRUCT_MEMBER_PTR(size_t, message, field->quantifier_offset); - size_t siz = sizeof_elt_in_repeated_array (field->type); - char *array = *(char**)member + siz * (*p_n); - const uint8_t *at = scanned_member->data + scanned_member->length_prefix_len; - size_t rem = scanned_member->len - scanned_member->length_prefix_len; - size_t count = 0; - unsigned i; - switch (field->type) - { - case PROTOBUF_C_TYPE_SFIXED32: - case PROTOBUF_C_TYPE_FIXED32: - case PROTOBUF_C_TYPE_FLOAT: - count = (scanned_member->len - scanned_member->length_prefix_len) / 4; -#if 0 //IS_LITTLE_ENDIAN - goto no_unpacking_needed; +parse_packed_repeated_member(ScannedMember *scanned_member, + void *member, + ProtobufCMessage *message) +{ + const ProtobufCFieldDescriptor *field = scanned_member->field; + size_t *p_n = STRUCT_MEMBER_PTR(size_t, message, field->quantifier_offset); + size_t siz = sizeof_elt_in_repeated_array(field->type); + void *array = *(char **) member + siz * (*p_n); + const uint8_t *at = scanned_member->data + scanned_member->length_prefix_len; + size_t rem = scanned_member->len - scanned_member->length_prefix_len; + size_t count = 0; + unsigned i; + + switch (field->type) { + case PROTOBUF_C_TYPE_SFIXED32: + case PROTOBUF_C_TYPE_FIXED32: + case PROTOBUF_C_TYPE_FLOAT: + count = (scanned_member->len - scanned_member->length_prefix_len) / 4; +#if !defined(WORDS_BIGENDIAN) + goto no_unpacking_needed; #else - for (i = 0; i < count; i++) - { - ((uint32_t*)array)[i] = parse_fixed_uint32 (at); - at += 4; - } + for (i = 0; i < count; i++) { + ((uint32_t *) array)[i] = parse_fixed_uint32(at); + at += 4; + } + break; #endif - break; - case PROTOBUF_C_TYPE_SFIXED64: - case PROTOBUF_C_TYPE_FIXED64: - case PROTOBUF_C_TYPE_DOUBLE: - count = (scanned_member->len - scanned_member->length_prefix_len) / 8; -#if 0 //IS_LITTLE_ENDIAN - goto no_unpacking_needed; + case PROTOBUF_C_TYPE_SFIXED64: + case PROTOBUF_C_TYPE_FIXED64: + case PROTOBUF_C_TYPE_DOUBLE: + count = (scanned_member->len - scanned_member->length_prefix_len) / 8; +#if !defined(WORDS_BIGENDIAN) + goto no_unpacking_needed; #else - for (i = 0; i < count; i++) - { - ((uint64_t*)array)[i] = parse_fixed_uint64 (at); - at += 8; - } - break; + for (i = 0; i < count; i++) { + ((uint64_t *) array)[i] = parse_fixed_uint64(at); + at += 8; + } + break; #endif - case PROTOBUF_C_TYPE_INT32: - while (rem > 0) - { - unsigned s = scan_varint (rem, at); - if (s == 0) - { - UNPACK_ERROR (("bad packed-repeated int32 value")); - return FALSE; - } - ((int32_t*)array)[count++] = parse_int32 (s, at); - at += s; - rem -= s; - } - break; - - case PROTOBUF_C_TYPE_SINT32: - while (rem > 0) - { - unsigned s = scan_varint (rem, at); - if (s == 0) - { - UNPACK_ERROR (("bad packed-repeated sint32 value")); - return FALSE; - } - ((int32_t*)array)[count++] = unzigzag32 (parse_uint32 (s, at)); - at += s; - rem -= s; - } - break; - case PROTOBUF_C_TYPE_ENUM: - case PROTOBUF_C_TYPE_UINT32: - while (rem > 0) - { - unsigned s = scan_varint (rem, at); - if (s == 0) - { - UNPACK_ERROR (("bad packed-repeated enum or uint32 value")); - return FALSE; - } - ((uint32_t*)array)[count++] = parse_uint32 (s, at); - at += s; - rem -= s; - } - break; - - case PROTOBUF_C_TYPE_SINT64: - while (rem > 0) - { - unsigned s = scan_varint (rem, at); - if (s == 0) - { - UNPACK_ERROR (("bad packed-repeated sint64 value")); - return FALSE; - } - ((int64_t*)array)[count++] = unzigzag64 (parse_uint64 (s, at)); - at += s; - rem -= s; - } - break; - case PROTOBUF_C_TYPE_INT64: - case PROTOBUF_C_TYPE_UINT64: - while (rem > 0) - { - unsigned s = scan_varint (rem, at); - if (s == 0) - { - UNPACK_ERROR (("bad packed-repeated int64/uint64 value")); - return FALSE; - } - ((int64_t*)array)[count++] = parse_uint64 (s, at); - at += s; - rem -= s; - } - break; - case PROTOBUF_C_TYPE_BOOL: - count = rem; - for (i = 0; i < count; i++) - { - if (at[i] > 1) - { - UNPACK_ERROR (("bad packed-repeated boolean value")); - return FALSE; - } - ((protobuf_c_boolean*)array)[i] = at[i]; - } - break; - default: - assert(0); - } - *p_n += count; - return TRUE; - -//no_unpacking_needed: -// memcpy (array, at, count * siz); -// *p_n += count; -// return TRUE; + case PROTOBUF_C_TYPE_ENUM: + case PROTOBUF_C_TYPE_INT32: + while (rem > 0) { + unsigned s = scan_varint(rem, at); + if (s == 0) { + PROTOBUF_C_UNPACK_ERROR("bad packed-repeated int32 value"); + return FALSE; + } + ((int32_t *) array)[count++] = parse_int32(s, at); + at += s; + rem -= s; + } + break; + case PROTOBUF_C_TYPE_SINT32: + while (rem > 0) { + unsigned s = scan_varint(rem, at); + if (s == 0) { + PROTOBUF_C_UNPACK_ERROR("bad packed-repeated sint32 value"); + return FALSE; + } + ((int32_t *) array)[count++] = unzigzag32(parse_uint32(s, at)); + at += s; + rem -= s; + } + break; + case PROTOBUF_C_TYPE_UINT32: + while (rem > 0) { + unsigned s = scan_varint(rem, at); + if (s == 0) { + PROTOBUF_C_UNPACK_ERROR("bad packed-repeated enum or uint32 value"); + return FALSE; + } + ((uint32_t *) array)[count++] = parse_uint32(s, at); + at += s; + rem -= s; + } + break; + + case PROTOBUF_C_TYPE_SINT64: + while (rem > 0) { + unsigned s = scan_varint(rem, at); + if (s == 0) { + PROTOBUF_C_UNPACK_ERROR("bad packed-repeated sint64 value"); + return FALSE; + } + ((int64_t *) array)[count++] = unzigzag64(parse_uint64(s, at)); + at += s; + rem -= s; + } + break; + case PROTOBUF_C_TYPE_INT64: + case PROTOBUF_C_TYPE_UINT64: + while (rem > 0) { + unsigned s = scan_varint(rem, at); + if (s == 0) { + PROTOBUF_C_UNPACK_ERROR("bad packed-repeated int64/uint64 value"); + return FALSE; + } + ((int64_t *) array)[count++] = parse_uint64(s, at); + at += s; + rem -= s; + } + break; + case PROTOBUF_C_TYPE_BOOL: + count = rem; + for (i = 0; i < count; i++) { + if (at[i] > 1) { + PROTOBUF_C_UNPACK_ERROR("bad packed-repeated boolean value"); + return FALSE; + } + ((protobuf_c_boolean *) array)[i] = at[i]; + } + break; + default: + PROTOBUF_C__ASSERT_NOT_REACHED(); + } + *p_n += count; + return TRUE; + +#if !defined(WORDS_BIGENDIAN) +no_unpacking_needed: + memcpy(array, at, count * siz); + *p_n += count; + return TRUE; +#endif +} + +static protobuf_c_boolean +is_packable_type(ProtobufCType type) +{ + return + type != PROTOBUF_C_TYPE_STRING && + type != PROTOBUF_C_TYPE_BYTES && + type != PROTOBUF_C_TYPE_MESSAGE; } static protobuf_c_boolean -parse_member (ScannedMember *scanned_member, - ProtobufCMessage *message, - ProtobufCAllocator *allocator) -{ - const ProtobufCFieldDescriptor *field = scanned_member->field; - void *member; - if (field == NULL) - { - ProtobufCMessageUnknownField *ufield = message->unknown_fields + (message->n_unknown_fields++); - ufield->tag = scanned_member->tag; - ufield->wire_type = scanned_member->wire_type; - ufield->len = scanned_member->len; - DO_UNALIGNED_ALLOC (ufield->data, allocator, scanned_member->len, return 0); - memcpy (ufield->data, scanned_member->data, ufield->len); - return 1; - } - member = (char*)message + field->offset; - switch (field->label) - { - case PROTOBUF_C_LABEL_REQUIRED: - return parse_required_member (scanned_member, member, allocator, TRUE); - case PROTOBUF_C_LABEL_OPTIONAL: - return parse_optional_member (scanned_member, member, message, allocator); - case PROTOBUF_C_LABEL_REPEATED: - if (field->packed - && scanned_member->wire_type == PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED) - return parse_packed_repeated_member (scanned_member, member, message); - else - return parse_repeated_member (scanned_member, member, message, allocator); - } - PROTOBUF_C_ASSERT_NOT_REACHED (); - return 0; -} - - -/* TODO: expose/use this function if desc->message_init==NULL - (which occurs for old code, and may be useful for certain - programatic techniques for generating descriptors). */ +parse_member(ScannedMember *scanned_member, + ProtobufCMessage *message, + ProtobufCAllocator *allocator) +{ + const ProtobufCFieldDescriptor *field = scanned_member->field; + void *member; + + if (field == NULL) { + ProtobufCMessageUnknownField *ufield = + message->unknown_fields + + (message->n_unknown_fields++); + ufield->tag = scanned_member->tag; + ufield->wire_type = scanned_member->wire_type; + ufield->len = scanned_member->len; + ufield->data = do_alloc(allocator, scanned_member->len); + if (ufield->data == NULL) + return FALSE; + memcpy(ufield->data, scanned_member->data, ufield->len); + return TRUE; + } + member = (char *) message + field->offset; + switch (field->label) { + case PROTOBUF_C_LABEL_REQUIRED: + return parse_required_member(scanned_member, member, + allocator, TRUE); + case PROTOBUF_C_LABEL_OPTIONAL: + case PROTOBUF_C_LABEL_NONE: + if (0 != (field->flags & PROTOBUF_C_FIELD_FLAG_ONEOF)) { + return parse_oneof_member(scanned_member, member, + message, allocator); + } else { + return parse_optional_member(scanned_member, member, + message, allocator); + } + case PROTOBUF_C_LABEL_REPEATED: + if (scanned_member->wire_type == + PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED && + (0 != (field->flags & PROTOBUF_C_FIELD_FLAG_PACKED) || + is_packable_type(field->type))) + { + return parse_packed_repeated_member(scanned_member, + member, message); + } else { + return parse_repeated_member(scanned_member, + member, message, + allocator); + } + } + PROTOBUF_C__ASSERT_NOT_REACHED(); + return 0; +} + +/** + * Initialise messages generated by old code. + * + * This function is used if desc->message_init == NULL (which occurs + * for old code, and which would be useful to support allocating + * descriptors dynamically). + */ static void -protobuf_c_message_init_generic (const ProtobufCMessageDescriptor *desc, - ProtobufCMessage *message) -{ - unsigned i; - memset (message, 0, desc->sizeof_message); - message->descriptor = desc; - for (i = 0; i < desc->n_fields; i++) - if (desc->fields[i].default_value != NULL - && desc->fields[i].label != PROTOBUF_C_LABEL_REPEATED) - { - void *field = STRUCT_MEMBER_P (message, desc->fields[i].offset); - const void *dv = desc->fields[i].default_value; - switch (desc->fields[i].type) - { - case PROTOBUF_C_TYPE_INT32: - case PROTOBUF_C_TYPE_SINT32: - case PROTOBUF_C_TYPE_SFIXED32: - case PROTOBUF_C_TYPE_UINT32: - case PROTOBUF_C_TYPE_FIXED32: - case PROTOBUF_C_TYPE_FLOAT: - case PROTOBUF_C_TYPE_ENUM: - memcpy (field, dv, 4); - break; - - case PROTOBUF_C_TYPE_INT64: - case PROTOBUF_C_TYPE_SINT64: - case PROTOBUF_C_TYPE_SFIXED64: - case PROTOBUF_C_TYPE_UINT64: - case PROTOBUF_C_TYPE_FIXED64: - case PROTOBUF_C_TYPE_DOUBLE: - memcpy (field, dv, 8); - break; - - case PROTOBUF_C_TYPE_BOOL: - memcpy (field, dv, sizeof (protobuf_c_boolean)); - break; - - case PROTOBUF_C_TYPE_BYTES: - memcpy (field, dv, sizeof (ProtobufCBinaryData)); - break; - - case PROTOBUF_C_TYPE_STRING: - case PROTOBUF_C_TYPE_MESSAGE: - /* the next line essentially implements a cast from const, - which is totally unavoidable. */ - *(const void**)field = dv; - break; - } - } -} - -/* ScannedMember slabs (an unpacking implementation detail). - Before doing real unpacking, we first scan through the - elements to see how many there are (for repeated fields), - and which field to use (for non-repeated fields given twice). - - * In order to avoid allocations for small messages, - we keep a stack-allocated slab of ScannedMembers of - size FIRST_SCANNED_MEMBER_SLAB_SIZE (16). - After we fill that up, we allocate each slab twice - as large as the previous one. */ -#define FIRST_SCANNED_MEMBER_SLAB_SIZE_LOG2 4 - -/* The number of slabs, including the stack-allocated ones; - choose the number so that we would overflow if we needed - a slab larger than provided. */ -#define MAX_SCANNED_MEMBER_SLAB \ - (sizeof(void*)*8 - 1 \ - - BOUND_SIZEOF_SCANNED_MEMBER_LOG2 \ +message_init_generic(const ProtobufCMessageDescriptor *desc, + ProtobufCMessage *message) +{ + unsigned i; + + memset(message, 0, desc->sizeof_message); + message->descriptor = desc; + for (i = 0; i < desc->n_fields; i++) { + if (desc->fields[i].default_value != NULL && + desc->fields[i].label != PROTOBUF_C_LABEL_REPEATED) + { + void *field = + STRUCT_MEMBER_P(message, desc->fields[i].offset); + const void *dv = desc->fields[i].default_value; + + switch (desc->fields[i].type) { + case PROTOBUF_C_TYPE_INT32: + case PROTOBUF_C_TYPE_SINT32: + case PROTOBUF_C_TYPE_SFIXED32: + case PROTOBUF_C_TYPE_UINT32: + case PROTOBUF_C_TYPE_FIXED32: + case PROTOBUF_C_TYPE_FLOAT: + case PROTOBUF_C_TYPE_ENUM: + memcpy(field, dv, 4); + break; + case PROTOBUF_C_TYPE_INT64: + case PROTOBUF_C_TYPE_SINT64: + case PROTOBUF_C_TYPE_SFIXED64: + case PROTOBUF_C_TYPE_UINT64: + case PROTOBUF_C_TYPE_FIXED64: + case PROTOBUF_C_TYPE_DOUBLE: + memcpy(field, dv, 8); + break; + case PROTOBUF_C_TYPE_BOOL: + memcpy(field, dv, sizeof(protobuf_c_boolean)); + break; + case PROTOBUF_C_TYPE_BYTES: + memcpy(field, dv, sizeof(ProtobufCBinaryData)); + break; + + case PROTOBUF_C_TYPE_STRING: + case PROTOBUF_C_TYPE_MESSAGE: + /* + * The next line essentially implements a cast + * from const, which is totally unavoidable. + */ + *(const void **) field = dv; + break; + } + } + } +} + +/**@}*/ + +/* + * ScannedMember slabs (an unpacking implementation detail). Before doing real + * unpacking, we first scan through the elements to see how many there are (for + * repeated fields), and which field to use (for non-repeated fields given + * twice). + * + * In order to avoid allocations for small messages, we keep a stack-allocated + * slab of ScannedMembers of size FIRST_SCANNED_MEMBER_SLAB_SIZE (16). After we + * fill that up, we allocate each slab twice as large as the previous one. + */ +#define FIRST_SCANNED_MEMBER_SLAB_SIZE_LOG2 4 + +/* + * The number of slabs, including the stack-allocated ones; choose the number so + * that we would overflow if we needed a slab larger than provided. + */ +#define MAX_SCANNED_MEMBER_SLAB \ + (sizeof(unsigned int)*8 - 1 \ + - BOUND_SIZEOF_SCANNED_MEMBER_LOG2 \ - FIRST_SCANNED_MEMBER_SLAB_SIZE_LOG2) +#define REQUIRED_FIELD_BITMAP_SET(index) \ + (required_fields_bitmap[(index)/8] |= (1UL<<((index)%8))) + +#define REQUIRED_FIELD_BITMAP_IS_SET(index) \ + (required_fields_bitmap[(index)/8] & (1UL<<((index)%8))) + ProtobufCMessage * -protobuf_c_message_unpack (const ProtobufCMessageDescriptor *desc, - ProtobufCAllocator *allocator, - size_t len, - const uint8_t *data) -{ - ProtobufCMessage *rv; - size_t rem = len; - const uint8_t *at = data; - const ProtobufCFieldDescriptor *last_field = desc->fields + 0; - ScannedMember first_member_slab[1<<FIRST_SCANNED_MEMBER_SLAB_SIZE_LOG2]; - - /* scanned_member_slabs[i] is an array of arrays of ScannedMember. - The first slab (scanned_member_slabs[0] is just a pointer to - first_member_slab), above. All subsequent slabs will be allocated - using the allocator. */ - ScannedMember *scanned_member_slabs[MAX_SCANNED_MEMBER_SLAB+1]; - unsigned which_slab = 0; /* the slab we are currently populating */ - unsigned in_slab_index = 0; /* number of members in the slab */ - size_t n_unknown = 0; - unsigned f; - unsigned i_slab; - unsigned last_field_index = 0; - unsigned long *required_fields_bitmap; - unsigned required_fields_bitmap_len; - static const unsigned word_bits = sizeof(long) * 8; - - ASSERT_IS_MESSAGE_DESCRIPTOR (desc); - - if (allocator == NULL) - allocator = &protobuf_c_default_allocator; - - required_fields_bitmap_len = (desc->n_fields + word_bits - 1) / word_bits; - required_fields_bitmap = alloca(required_fields_bitmap_len * sizeof(long)); - memset(required_fields_bitmap, 0, required_fields_bitmap_len * sizeof(long)); - - DO_ALLOC (rv, allocator, desc->sizeof_message, return NULL); - scanned_member_slabs[0] = first_member_slab; - - /* Generated code always defines "message_init". - However, we provide a fallback for (1) users of old protobuf-c - generated-code that do not provide the function, - and (2) descriptors constructed from some other source - (most likely, direct construction from the .proto file) */ - if (desc->message_init != NULL) - protobuf_c_message_init (desc, rv); - else - protobuf_c_message_init_generic (desc, rv); - - while (rem > 0) - { - uint32_t tag; - ProtobufCWireType wire_type; - size_t used = parse_tag_and_wiretype (rem, at, &tag, &wire_type); - const ProtobufCFieldDescriptor *field; - ScannedMember tmp; - if (used == 0) - { - UNPACK_ERROR (("error parsing tag/wiretype at offset %u", - (unsigned)(at-data))); - goto error_cleanup_during_scan; - } - /* XXX: consider optimizing for field[1].id == tag, if field[1] exists! */ - if (last_field == NULL || last_field->id != tag) - { - /* lookup field */ - int field_index = int_range_lookup (desc->n_field_ranges, - desc->field_ranges, - tag); - if (field_index < 0) - { - field = NULL; - n_unknown++; - } - else - { - field = desc->fields + field_index; - last_field = field; - last_field_index = field_index; - } - } - else - field = last_field; - - if (field != NULL && field->label == PROTOBUF_C_LABEL_REQUIRED) - required_fields_bitmap[last_field_index / word_bits] |= (1UL << (last_field_index % word_bits)); - - at += used; - rem -= used; - tmp.tag = tag; - tmp.wire_type = wire_type; - tmp.field = field; - tmp.data = at; - switch (wire_type) - { - case PROTOBUF_C_WIRE_TYPE_VARINT: - { - unsigned max_len = rem < 10 ? rem : 10; - unsigned i; - for (i = 0; i < max_len; i++) - if ((at[i] & 0x80) == 0) - break; - if (i == max_len) - { - UNPACK_ERROR (("unterminated varint at offset %u", - (unsigned)(at-data))); - goto error_cleanup_during_scan; - } - tmp.len = i + 1; - } - break; - case PROTOBUF_C_WIRE_TYPE_64BIT: - if (rem < 8) - { - UNPACK_ERROR (("too short after 64bit wiretype at offset %u", - (unsigned)(at-data))); - goto error_cleanup_during_scan; - } - tmp.len = 8; - break; - case PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED: - { - size_t pref_len; - tmp.len = scan_length_prefixed_data (rem, at, &pref_len); - if (tmp.len == 0) - { - /* NOTE: scan_length_prefixed_data calls UNPACK_ERROR */ - goto error_cleanup_during_scan; - } - tmp.length_prefix_len = pref_len; - break; - } - case PROTOBUF_C_WIRE_TYPE_32BIT: - if (rem < 4) - { - UNPACK_ERROR (("too short after 32bit wiretype at offset %u", - (unsigned)(at-data))); - goto error_cleanup_during_scan; - } - tmp.len = 4; - break; - default: - UNPACK_ERROR (("unsupported tag %u at offset %u", - wire_type, (unsigned)(at-data))); - goto error_cleanup_during_scan; - } - if (in_slab_index == (1U<<(which_slab+FIRST_SCANNED_MEMBER_SLAB_SIZE_LOG2))) - { - size_t size; - in_slab_index = 0; - if (which_slab == MAX_SCANNED_MEMBER_SLAB) - { - UNPACK_ERROR (("too many fields")); - goto error_cleanup_during_scan; - } - which_slab++; - size = sizeof(ScannedMember) << (which_slab+FIRST_SCANNED_MEMBER_SLAB_SIZE_LOG2); - /* TODO: consider using alloca() ! */ - if (allocator->tmp_alloc != NULL) - scanned_member_slabs[which_slab] = TMPALLOC(allocator, size); - else - DO_ALLOC (scanned_member_slabs[which_slab], allocator, size, goto error_cleanup_during_scan); - } - scanned_member_slabs[which_slab][in_slab_index++] = tmp; - - if (field != NULL && field->label == PROTOBUF_C_LABEL_REPEATED) - { - size_t *n = STRUCT_MEMBER_PTR (size_t, rv, field->quantifier_offset); - if (field->packed - && wire_type == PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED) - { - size_t count; - if (!count_packed_elements (field->type, - tmp.len - tmp.length_prefix_len, - tmp.data + tmp.length_prefix_len, - &count)) - { - UNPACK_ERROR (("counting packed elements")); - goto error_cleanup_during_scan; +protobuf_c_message_unpack(const ProtobufCMessageDescriptor *desc, + ProtobufCAllocator *allocator, + size_t len, const uint8_t *data) +{ + ProtobufCMessage *rv; + size_t rem = len; + const uint8_t *at = data; + const ProtobufCFieldDescriptor *last_field = desc->fields + 0; + ScannedMember first_member_slab[1UL << + FIRST_SCANNED_MEMBER_SLAB_SIZE_LOG2]; + + /* + * scanned_member_slabs[i] is an array of arrays of ScannedMember. + * The first slab (scanned_member_slabs[0] is just a pointer to + * first_member_slab), above. All subsequent slabs will be allocated + * using the allocator. + */ + ScannedMember *scanned_member_slabs[MAX_SCANNED_MEMBER_SLAB + 1]; + unsigned which_slab = 0; /* the slab we are currently populating */ + unsigned in_slab_index = 0; /* number of members in the slab */ + size_t n_unknown = 0; + unsigned f; + unsigned j; + unsigned i_slab; + unsigned last_field_index = 0; + unsigned required_fields_bitmap_len; + unsigned char required_fields_bitmap_stack[16]; + unsigned char *required_fields_bitmap = required_fields_bitmap_stack; + protobuf_c_boolean required_fields_bitmap_alloced = FALSE; + + ASSERT_IS_MESSAGE_DESCRIPTOR(desc); + + if (allocator == NULL) + allocator = &protobuf_c__allocator; + + rv = do_alloc(allocator, desc->sizeof_message); + if (!rv) + return (NULL); + scanned_member_slabs[0] = first_member_slab; + + required_fields_bitmap_len = (desc->n_fields + 7) / 8; + if (required_fields_bitmap_len > sizeof(required_fields_bitmap_stack)) { + required_fields_bitmap = do_alloc(allocator, required_fields_bitmap_len); + if (!required_fields_bitmap) { + do_free(allocator, rv); + return (NULL); + } + required_fields_bitmap_alloced = TRUE; + } + memset(required_fields_bitmap, 0, required_fields_bitmap_len); + + /* + * Generated code always defines "message_init". However, we provide a + * fallback for (1) users of old protobuf-c generated-code that do not + * provide the function, and (2) descriptors constructed from some other + * source (most likely, direct construction from the .proto file). + */ + if (desc->message_init != NULL) + protobuf_c_message_init(desc, rv); + else + message_init_generic(desc, rv); + + while (rem > 0) { + uint32_t tag; + ProtobufCWireType wire_type; + size_t used = parse_tag_and_wiretype(rem, at, &tag, &wire_type); + const ProtobufCFieldDescriptor *field; + ScannedMember tmp; + + if (used == 0) { + PROTOBUF_C_UNPACK_ERROR("error parsing tag/wiretype at offset %u", + (unsigned) (at - data)); + goto error_cleanup_during_scan; + } + /* + * \todo Consider optimizing for field[1].id == tag, if field[1] + * exists! + */ + if (last_field == NULL || last_field->id != tag) { + /* lookup field */ + int field_index = + int_range_lookup(desc->n_field_ranges, + desc->field_ranges, + tag); + if (field_index < 0) { + field = NULL; + n_unknown++; + } else { + field = desc->fields + field_index; + last_field = field; + last_field_index = field_index; + } + } else { + field = last_field; + } + + if (field != NULL && field->label == PROTOBUF_C_LABEL_REQUIRED) + REQUIRED_FIELD_BITMAP_SET(last_field_index); + + at += used; + rem -= used; + tmp.tag = tag; + tmp.wire_type = wire_type; + tmp.field = field; + tmp.data = at; + tmp.length_prefix_len = 0; + + switch (wire_type) { + case PROTOBUF_C_WIRE_TYPE_VARINT: { + unsigned max_len = rem < 10 ? rem : 10; + unsigned i; + + for (i = 0; i < max_len; i++) + if ((at[i] & 0x80) == 0) + break; + if (i == max_len) { + PROTOBUF_C_UNPACK_ERROR("unterminated varint at offset %u", + (unsigned) (at - data)); + goto error_cleanup_during_scan; + } + tmp.len = i + 1; + break; + } + case PROTOBUF_C_WIRE_TYPE_64BIT: + if (rem < 8) { + PROTOBUF_C_UNPACK_ERROR("too short after 64bit wiretype at offset %u", + (unsigned) (at - data)); + goto error_cleanup_during_scan; + } + tmp.len = 8; + break; + case PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED: { + size_t pref_len; + + tmp.len = scan_length_prefixed_data(rem, at, &pref_len); + if (tmp.len == 0) { + /* NOTE: scan_length_prefixed_data calls UNPACK_ERROR */ + goto error_cleanup_during_scan; + } + tmp.length_prefix_len = pref_len; + break; + } + case PROTOBUF_C_WIRE_TYPE_32BIT: + if (rem < 4) { + PROTOBUF_C_UNPACK_ERROR("too short after 32bit wiretype at offset %u", + (unsigned) (at - data)); + goto error_cleanup_during_scan; + } + tmp.len = 4; + break; + default: + PROTOBUF_C_UNPACK_ERROR("unsupported tag %u at offset %u", + wire_type, (unsigned) (at - data)); + goto error_cleanup_during_scan; + } + + if (in_slab_index == (1UL << + (which_slab + FIRST_SCANNED_MEMBER_SLAB_SIZE_LOG2))) + { + size_t size; + + in_slab_index = 0; + if (which_slab == MAX_SCANNED_MEMBER_SLAB) { + PROTOBUF_C_UNPACK_ERROR("too many fields"); + goto error_cleanup_during_scan; + } + which_slab++; + size = sizeof(ScannedMember) + << (which_slab + FIRST_SCANNED_MEMBER_SLAB_SIZE_LOG2); + scanned_member_slabs[which_slab] = do_alloc(allocator, size); + if (scanned_member_slabs[which_slab] == NULL) + goto error_cleanup_during_scan; + } + scanned_member_slabs[which_slab][in_slab_index++] = tmp; + + if (field != NULL && field->label == PROTOBUF_C_LABEL_REPEATED) { + size_t *n = STRUCT_MEMBER_PTR(size_t, rv, + field->quantifier_offset); + if (wire_type == PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED && + (0 != (field->flags & PROTOBUF_C_FIELD_FLAG_PACKED) || + is_packable_type(field->type))) + { + size_t count; + if (!count_packed_elements(field->type, + tmp.len - + tmp.length_prefix_len, + tmp.data + + tmp.length_prefix_len, + &count)) + { + PROTOBUF_C_UNPACK_ERROR("counting packed elements"); + goto error_cleanup_during_scan; + } + *n += count; + } else { + *n += 1; + } + } + + at += tmp.len; + rem -= tmp.len; + } + + /* allocate space for repeated fields, also check that all required fields have been set */ + for (f = 0; f < desc->n_fields; f++) { + const ProtobufCFieldDescriptor *field = desc->fields + f; + if (field->label == PROTOBUF_C_LABEL_REPEATED) { + size_t siz = + sizeof_elt_in_repeated_array(field->type); + size_t *n_ptr = + STRUCT_MEMBER_PTR(size_t, rv, + field->quantifier_offset); + if (*n_ptr != 0) { + unsigned n = *n_ptr; + void *a; + *n_ptr = 0; + assert(rv->descriptor != NULL); +#define CLEAR_REMAINING_N_PTRS() \ + for(f++;f < desc->n_fields; f++) \ + { \ + field = desc->fields + f; \ + if (field->label == PROTOBUF_C_LABEL_REPEATED) \ + STRUCT_MEMBER (size_t, rv, field->quantifier_offset) = 0; \ } - *n += count; - } - else - *n += 1; - } - - at += tmp.len; - rem -= tmp.len; - } - - /* allocate space for repeated fields, also check that all required fields have been set */ - for (f = 0; f < desc->n_fields; f++) - { - const ProtobufCFieldDescriptor *field = desc->fields + f; - if (field->label == PROTOBUF_C_LABEL_REPEATED) - { - size_t siz = sizeof_elt_in_repeated_array (field->type); - size_t *n_ptr = STRUCT_MEMBER_PTR (size_t, rv, field->quantifier_offset); - if (*n_ptr != 0) - { - unsigned n = *n_ptr; - *n_ptr = 0; - assert(rv->descriptor != NULL); -#define CLEAR_REMAINING_N_PTRS() \ - for(f++;f < desc->n_fields; f++) \ - { \ - field = desc->fields + f; \ - if (field->label == PROTOBUF_C_LABEL_REPEATED) \ - STRUCT_MEMBER (size_t, rv, field->quantifier_offset) = 0; \ - } - DO_ALLOC (STRUCT_MEMBER (void *, rv, field->offset), - allocator, siz * n, - CLEAR_REMAINING_N_PTRS (); goto error_cleanup); + a = do_alloc(allocator, siz * n); + if (!a) { + CLEAR_REMAINING_N_PTRS(); + goto error_cleanup; + } + STRUCT_MEMBER(void *, rv, field->offset) = a; + } + } else if (field->label == PROTOBUF_C_LABEL_REQUIRED) { + if (field->default_value == NULL && + !REQUIRED_FIELD_BITMAP_IS_SET(f)) + { + CLEAR_REMAINING_N_PTRS(); + PROTOBUF_C_UNPACK_ERROR("message '%s': missing required field '%s'", + desc->name, field->name); + goto error_cleanup; + } + } + } #undef CLEAR_REMAINING_N_PTRS - } - } - else if (field->label == PROTOBUF_C_LABEL_REQUIRED) - { - if (field->default_value == NULL && 0 == (required_fields_bitmap[f / word_bits] & (1UL << (f % word_bits)))) - { - UNPACK_ERROR (("message '%s': missing required field '%s'", desc->name, field->name)); - goto error_cleanup; - } - } - } - - /* allocate space for unknown fields */ - if (n_unknown) - { - DO_ALLOC (rv->unknown_fields, - allocator, n_unknown * sizeof (ProtobufCMessageUnknownField), - goto error_cleanup); - } - - /* do real parsing */ - for (i_slab = 0; i_slab <= which_slab; i_slab++) - { - unsigned max = (i_slab == which_slab) ? in_slab_index : (1U<<(i_slab+4)); - ScannedMember *slab = scanned_member_slabs[i_slab]; - unsigned j; - for (j = 0; j < max; j++) - { - if (!parse_member (slab + j, rv, allocator)) - { - UNPACK_ERROR (("error parsing member %s of %s", - slab->field ? slab->field->name : "*unknown-field*", desc->name)); - goto error_cleanup; - } - } - } - - /* cleanup */ - if (allocator->tmp_alloc == NULL) - { - unsigned j; - for (j = 1; j <= which_slab; j++) - FREE (allocator, scanned_member_slabs[j]); - } - - return rv; + + /* allocate space for unknown fields */ + if (n_unknown) { + rv->unknown_fields = do_alloc(allocator, + n_unknown * sizeof(ProtobufCMessageUnknownField)); + if (rv->unknown_fields == NULL) + goto error_cleanup; + } + + /* do real parsing */ + for (i_slab = 0; i_slab <= which_slab; i_slab++) { + unsigned max = (i_slab == which_slab) ? + in_slab_index : (1UL << (i_slab + 4)); + ScannedMember *slab = scanned_member_slabs[i_slab]; + + for (j = 0; j < max; j++) { + if (!parse_member(slab + j, rv, allocator)) { + PROTOBUF_C_UNPACK_ERROR("error parsing member %s of %s", + slab->field ? slab->field->name : "*unknown-field*", + desc->name); + goto error_cleanup; + } + } + } + + /* cleanup */ + for (j = 1; j <= which_slab; j++) + do_free(allocator, scanned_member_slabs[j]); + if (required_fields_bitmap_alloced) + do_free(allocator, required_fields_bitmap); + return rv; error_cleanup: - protobuf_c_message_free_unpacked (rv, allocator); - if (allocator->tmp_alloc == NULL) - { - unsigned j; - for (j = 1; j <= which_slab; j++) - FREE (allocator, scanned_member_slabs[j]); - } - return NULL; + protobuf_c_message_free_unpacked(rv, allocator); + for (j = 1; j <= which_slab; j++) + do_free(allocator, scanned_member_slabs[j]); + if (required_fields_bitmap_alloced) + do_free(allocator, required_fields_bitmap); + return NULL; error_cleanup_during_scan: - FREE (allocator, rv); - if (allocator->tmp_alloc == NULL) - { - unsigned j; - for (j = 1; j <= which_slab; j++) - FREE (allocator, scanned_member_slabs[j]); - } - return NULL; -} - -/* === free_unpacked === */ -void -protobuf_c_message_free_unpacked (ProtobufCMessage *message, - ProtobufCAllocator *allocator) -{ - const ProtobufCMessageDescriptor *desc = message->descriptor; - unsigned f; - ASSERT_IS_MESSAGE (message); - if (allocator == NULL) - allocator = &protobuf_c_default_allocator; - message->descriptor = NULL; - for (f = 0; f < desc->n_fields; f++) - { - if (desc->fields[f].label == PROTOBUF_C_LABEL_REPEATED) - { - size_t n = STRUCT_MEMBER (size_t, message, desc->fields[f].quantifier_offset); - void * arr = STRUCT_MEMBER (void *, message, desc->fields[f].offset); - if (desc->fields[f].type == PROTOBUF_C_TYPE_STRING) - { - unsigned i; - for (i = 0; i < n; i++) - FREE (allocator, ((char**)arr)[i]); - } - else if (desc->fields[f].type == PROTOBUF_C_TYPE_BYTES) - { - unsigned i; - for (i = 0; i < n; i++) - FREE (allocator, ((ProtobufCBinaryData*)arr)[i].data); - } - else if (desc->fields[f].type == PROTOBUF_C_TYPE_MESSAGE) - { - unsigned i; - for (i = 0; i < n; i++) - protobuf_c_message_free_unpacked (((ProtobufCMessage**)arr)[i], allocator); - } - if (arr != NULL) - FREE (allocator, arr); - } - else if (desc->fields[f].type == PROTOBUF_C_TYPE_STRING) - { - char *str = STRUCT_MEMBER (char *, message, desc->fields[f].offset); - if (str && str != desc->fields[f].default_value) - FREE (allocator, str); - } - else if (desc->fields[f].type == PROTOBUF_C_TYPE_BYTES) - { - void *data = STRUCT_MEMBER (ProtobufCBinaryData, message, desc->fields[f].offset).data; - const ProtobufCBinaryData *default_bd; - default_bd = desc->fields[f].default_value; - if (data != NULL - && (default_bd == NULL || default_bd->data != data)) - FREE (allocator, data); - } - else if (desc->fields[f].type == PROTOBUF_C_TYPE_MESSAGE) - { - ProtobufCMessage *sm; - sm = STRUCT_MEMBER (ProtobufCMessage *, message,desc->fields[f].offset); - if (sm && sm != desc->fields[f].default_value) - protobuf_c_message_free_unpacked (sm, allocator); - } - } - - for (f = 0; f < message->n_unknown_fields; f++) - FREE (allocator, message->unknown_fields[f].data); - if (message->unknown_fields != NULL) - FREE (allocator, message->unknown_fields); - - FREE (allocator, message); + do_free(allocator, rv); + for (j = 1; j <= which_slab; j++) + do_free(allocator, scanned_member_slabs[j]); + if (required_fields_bitmap_alloced) + do_free(allocator, required_fields_bitmap); + return NULL; } void -protobuf_c_message_init (const ProtobufCMessageDescriptor *descriptor, - void *message) -{ - descriptor->message_init((ProtobufCMessage*) (message)); +protobuf_c_message_free_unpacked(ProtobufCMessage *message, + ProtobufCAllocator *allocator) +{ + const ProtobufCMessageDescriptor *desc; + unsigned f; + + if (message == NULL) + return; + + desc = message->descriptor; + + ASSERT_IS_MESSAGE(message); + + if (allocator == NULL) + allocator = &protobuf_c__allocator; + message->descriptor = NULL; + for (f = 0; f < desc->n_fields; f++) { + if (0 != (desc->fields[f].flags & PROTOBUF_C_FIELD_FLAG_ONEOF) && + desc->fields[f].id != + STRUCT_MEMBER(uint32_t, message, desc->fields[f].quantifier_offset)) + { + /* This is not the selected oneof, skip it */ + continue; + } + + if (desc->fields[f].label == PROTOBUF_C_LABEL_REPEATED) { + size_t n = STRUCT_MEMBER(size_t, + message, + desc->fields[f].quantifier_offset); + void *arr = STRUCT_MEMBER(void *, + message, + desc->fields[f].offset); + + if (arr != NULL) { + if (desc->fields[f].type == PROTOBUF_C_TYPE_STRING) { + unsigned i; + for (i = 0; i < n; i++) + do_free(allocator, ((char **) arr)[i]); + } else if (desc->fields[f].type == PROTOBUF_C_TYPE_BYTES) { + unsigned i; + for (i = 0; i < n; i++) + do_free(allocator, ((ProtobufCBinaryData *) arr)[i].data); + } else if (desc->fields[f].type == PROTOBUF_C_TYPE_MESSAGE) { + unsigned i; + for (i = 0; i < n; i++) + protobuf_c_message_free_unpacked( + ((ProtobufCMessage **) arr)[i], + allocator + ); + } + do_free(allocator, arr); + } + } else if (desc->fields[f].type == PROTOBUF_C_TYPE_STRING) { + char *str = STRUCT_MEMBER(char *, message, + desc->fields[f].offset); + + if (str && str != desc->fields[f].default_value) + do_free(allocator, str); + } else if (desc->fields[f].type == PROTOBUF_C_TYPE_BYTES) { + void *data = STRUCT_MEMBER(ProtobufCBinaryData, message, + desc->fields[f].offset).data; + const ProtobufCBinaryData *default_bd; + + default_bd = desc->fields[f].default_value; + if (data != NULL && + (default_bd == NULL || + default_bd->data != data)) + { + do_free(allocator, data); + } + } else if (desc->fields[f].type == PROTOBUF_C_TYPE_MESSAGE) { + ProtobufCMessage *sm; + + sm = STRUCT_MEMBER(ProtobufCMessage *, message, + desc->fields[f].offset); + if (sm && sm != desc->fields[f].default_value) + protobuf_c_message_free_unpacked(sm, allocator); + } + } + + for (f = 0; f < message->n_unknown_fields; f++) + do_free(allocator, message->unknown_fields[f].data); + if (message->unknown_fields != NULL) + do_free(allocator, message->unknown_fields); + + do_free(allocator, message); } -/* === services === */ -typedef void (*GenericHandler)(void *service, - const ProtobufCMessage *input, - ProtobufCClosure closure, - void *closure_data); -void -protobuf_c_service_invoke_internal(ProtobufCService *service, - unsigned method_index, - const ProtobufCMessage *input, - ProtobufCClosure closure, - void *closure_data) -{ - GenericHandler *handlers; - GenericHandler handler; - - /* Verify that method_index is within range. - If this fails, you are likely invoking a newly added - method on an old service. (Although other memory corruption - bugs can cause this assertion too) */ - PROTOBUF_C_ASSERT (method_index < service->descriptor->n_methods); +void +protobuf_c_message_init(const ProtobufCMessageDescriptor * descriptor, + void *message) +{ + descriptor->message_init((ProtobufCMessage *) (message)); +} + +protobuf_c_boolean +protobuf_c_message_check(const ProtobufCMessage *message) +{ + unsigned i; + + if (!message || + !message->descriptor || + message->descriptor->magic != PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC) + { + return FALSE; + } + + for (i = 0; i < message->descriptor->n_fields; i++) { + const ProtobufCFieldDescriptor *f = message->descriptor->fields + i; + ProtobufCType type = f->type; + ProtobufCLabel label = f->label; + void *field = STRUCT_MEMBER_P (message, f->offset); + + if (label == PROTOBUF_C_LABEL_REPEATED) { + size_t *quantity = STRUCT_MEMBER_P (message, f->quantifier_offset); + + if (*quantity > 0 && *(void **) field == NULL) { + return FALSE; + } + + if (type == PROTOBUF_C_TYPE_MESSAGE) { + ProtobufCMessage **submessage = *(ProtobufCMessage ***) field; + unsigned j; + for (j = 0; j < *quantity; j++) { + if (!protobuf_c_message_check(submessage[j])) + return FALSE; + } + } else if (type == PROTOBUF_C_TYPE_STRING) { + char **string = *(char ***) field; + unsigned j; + for (j = 0; j < *quantity; j++) { + if (!string[j]) + return FALSE; + } + } else if (type == PROTOBUF_C_TYPE_BYTES) { + ProtobufCBinaryData *bd = *(ProtobufCBinaryData **) field; + unsigned j; + for (j = 0; j < *quantity; j++) { + if (bd[j].len > 0 && bd[j].data == NULL) + return FALSE; + } + } + + } else { /* PROTOBUF_C_LABEL_REQUIRED or PROTOBUF_C_LABEL_OPTIONAL */ + + if (type == PROTOBUF_C_TYPE_MESSAGE) { + ProtobufCMessage *submessage = *(ProtobufCMessage **) field; + if (label == PROTOBUF_C_LABEL_REQUIRED || submessage != NULL) { + if (!protobuf_c_message_check(submessage)) + return FALSE; + } + } else if (type == PROTOBUF_C_TYPE_STRING) { + char *string = *(char **) field; + if (label == PROTOBUF_C_LABEL_REQUIRED && string == NULL) + return FALSE; + } else if (type == PROTOBUF_C_TYPE_BYTES) { + protobuf_c_boolean *has = STRUCT_MEMBER_P (message, f->quantifier_offset); + ProtobufCBinaryData *bd = field; + if (label == PROTOBUF_C_LABEL_REQUIRED || *has == TRUE) { + if (bd->len > 0 && bd->data == NULL) + return FALSE; + } + } + } + } + + return TRUE; +} - /* Get the array of virtual methods (which are enumerated by - the generated code) */ - handlers = (GenericHandler *) (service + 1); +/* === services === */ - /* get our method and invoke it */ - /* TODO: seems like handler==NULL is a situation that - needs handling */ - handler = handlers[method_index]; - (*handler) (service, input, closure, closure_data); +typedef void (*GenericHandler) (void *service, + const ProtobufCMessage *input, + ProtobufCClosure closure, + void *closure_data); +void +protobuf_c_service_invoke_internal(ProtobufCService *service, + unsigned method_index, + const ProtobufCMessage *input, + ProtobufCClosure closure, + void *closure_data) +{ + GenericHandler *handlers; + GenericHandler handler; + + /* + * Verify that method_index is within range. If this fails, you are + * likely invoking a newly added method on an old service. (Although + * other memory corruption bugs can cause this assertion too.) + */ + assert(method_index < service->descriptor->n_methods); + + /* + * Get the array of virtual methods (which are enumerated by the + * generated code). + */ + handlers = (GenericHandler *) (service + 1); + + /* + * Get our method and invoke it. + * \todo Seems like handler == NULL is a situation that needs handling. + */ + handler = handlers[method_index]; + (*handler)(service, input, closure, closure_data); } void -protobuf_c_service_generated_init (ProtobufCService *service, - const ProtobufCServiceDescriptor *descriptor, - ProtobufCServiceDestroy destroy) +protobuf_c_service_generated_init(ProtobufCService *service, + const ProtobufCServiceDescriptor *descriptor, + ProtobufCServiceDestroy destroy) { - ASSERT_IS_SERVICE_DESCRIPTOR(descriptor); - service->descriptor = descriptor; - service->destroy = destroy; - service->invoke = protobuf_c_service_invoke_internal; - memset (service + 1, 0, descriptor->n_methods * sizeof (GenericHandler)); + ASSERT_IS_SERVICE_DESCRIPTOR(descriptor); + service->descriptor = descriptor; + service->destroy = destroy; + service->invoke = protobuf_c_service_invoke_internal; + memset(service + 1, 0, descriptor->n_methods * sizeof(GenericHandler)); } -void protobuf_c_service_destroy (ProtobufCService *service) +void protobuf_c_service_destroy(ProtobufCService *service) { - service->destroy (service); + service->destroy(service); } /* --- querying the descriptors --- */ + const ProtobufCEnumValue * -protobuf_c_enum_descriptor_get_value_by_name - (const ProtobufCEnumDescriptor *desc, - const char *name) -{ - unsigned start = 0, count = desc->n_value_names; - while (count > 1) - { - unsigned mid = start + count / 2; - int rv = strcmp (desc->values_by_name[mid].name, name); - if (rv == 0) - return desc->values + desc->values_by_name[mid].index; - else if (rv < 0) - { - count = start + count - (mid + 1); - start = mid + 1; - } - else - count = mid - start; - } - if (count == 0) - return NULL; - if (strcmp (desc->values_by_name[start].name, name) == 0) - return desc->values + desc->values_by_name[start].index; - return NULL; +protobuf_c_enum_descriptor_get_value_by_name(const ProtobufCEnumDescriptor *desc, + const char *name) +{ + unsigned start = 0; + unsigned count; + + if (desc == NULL || desc->values_by_name == NULL) + return NULL; + + count = desc->n_value_names; + + while (count > 1) { + unsigned mid = start + count / 2; + int rv = strcmp(desc->values_by_name[mid].name, name); + if (rv == 0) + return desc->values + desc->values_by_name[mid].index; + else if (rv < 0) { + count = start + count - (mid + 1); + start = mid + 1; + } else + count = mid - start; + } + if (count == 0) + return NULL; + if (strcmp(desc->values_by_name[start].name, name) == 0) + return desc->values + desc->values_by_name[start].index; + return NULL; } + const ProtobufCEnumValue * -protobuf_c_enum_descriptor_get_value - (const ProtobufCEnumDescriptor *desc, - int value) +protobuf_c_enum_descriptor_get_value(const ProtobufCEnumDescriptor *desc, + int value) { - int rv = int_range_lookup (desc->n_value_ranges, desc->value_ranges, value); - if (rv < 0) - return NULL; - return desc->values + rv; + int rv = int_range_lookup(desc->n_value_ranges, desc->value_ranges, value); + if (rv < 0) + return NULL; + return desc->values + rv; } const ProtobufCFieldDescriptor * -protobuf_c_message_descriptor_get_field_by_name - (const ProtobufCMessageDescriptor *desc, - const char *name) -{ - unsigned start = 0, count = desc->n_fields; - const ProtobufCFieldDescriptor *field; - while (count > 1) - { - unsigned mid = start + count / 2; - int rv; - field = desc->fields + desc->fields_sorted_by_name[mid]; - rv = strcmp (field->name, name); - if (rv == 0) - return field; - else if (rv < 0) - { - count = start + count - (mid + 1); - start = mid + 1; - } - else - count = mid - start; - } - if (count == 0) - return NULL; - field = desc->fields + desc->fields_sorted_by_name[start]; - if (strcmp (field->name, name) == 0) - return field; - return NULL; +protobuf_c_message_descriptor_get_field_by_name(const ProtobufCMessageDescriptor *desc, + const char *name) +{ + unsigned start = 0; + unsigned count; + const ProtobufCFieldDescriptor *field; + + if (desc == NULL || desc->fields_sorted_by_name == NULL) + return NULL; + + count = desc->n_fields; + + while (count > 1) { + unsigned mid = start + count / 2; + int rv; + field = desc->fields + desc->fields_sorted_by_name[mid]; + rv = strcmp(field->name, name); + if (rv == 0) + return field; + else if (rv < 0) { + count = start + count - (mid + 1); + start = mid + 1; + } else + count = mid - start; + } + if (count == 0) + return NULL; + field = desc->fields + desc->fields_sorted_by_name[start]; + if (strcmp(field->name, name) == 0) + return field; + return NULL; } const ProtobufCFieldDescriptor * -protobuf_c_message_descriptor_get_field - (const ProtobufCMessageDescriptor *desc, - unsigned value) +protobuf_c_message_descriptor_get_field(const ProtobufCMessageDescriptor *desc, + unsigned value) { - int rv = int_range_lookup (desc->n_field_ranges, - desc->field_ranges, - value); - if (rv < 0) - return NULL; - return desc->fields + rv; + int rv = int_range_lookup(desc->n_field_ranges,desc->field_ranges, value); + if (rv < 0) + return NULL; + return desc->fields + rv; } const ProtobufCMethodDescriptor * -protobuf_c_service_descriptor_get_method_by_name - (const ProtobufCServiceDescriptor *desc, - const char *name) -{ - unsigned start = 0, count = desc->n_methods; - while (count > 1) - { - unsigned mid = start + count / 2; - unsigned mid_index = desc->method_indices_by_name[mid]; - const char *mid_name = desc->methods[mid_index].name; - int rv = strcmp (mid_name, name); - if (rv == 0) - return desc->methods + desc->method_indices_by_name[mid]; - if (rv < 0) - { - count = start + count - (mid + 1); - start = mid + 1; - } - else - { - count = mid - start; - } - } - if (count == 0) - return NULL; - if (strcmp (desc->methods[desc->method_indices_by_name[start]].name, name) == 0) - return desc->methods + desc->method_indices_by_name[start]; - return NULL; +protobuf_c_service_descriptor_get_method_by_name(const ProtobufCServiceDescriptor *desc, + const char *name) +{ + unsigned start = 0; + unsigned count; + + if (desc == NULL || desc->method_indices_by_name == NULL) + return NULL; + + count = desc->n_methods; + + while (count > 1) { + unsigned mid = start + count / 2; + unsigned mid_index = desc->method_indices_by_name[mid]; + const char *mid_name = desc->methods[mid_index].name; + int rv = strcmp(mid_name, name); + + if (rv == 0) + return desc->methods + desc->method_indices_by_name[mid]; + if (rv < 0) { + count = start + count - (mid + 1); + start = mid + 1; + } else { + count = mid - start; + } + } + if (count == 0) + return NULL; + if (strcmp(desc->methods[desc->method_indices_by_name[start]].name, name) == 0) + return desc->methods + desc->method_indices_by_name[start]; + return NULL; } diff --git a/tizen/src/distrib/protobuf/protobuf-c.h b/tizen/src/distrib/protobuf/protobuf-c.h index cde24bf23c..c8fa4fc2a7 100644 --- a/tizen/src/distrib/protobuf/protobuf-c.h +++ b/tizen/src/distrib/protobuf/protobuf-c.h @@ -1,486 +1,1106 @@ -/* --- protobuf-c.h: public protobuf c runtime api --- */ - /* - * Copyright 2008, Dave Benson. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with - * the License. You may obtain a copy of the License - * at http://www.apache.org/licenses/LICENSE-2.0 Unless - * required by applicable law or agreed to in writing, - * software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#ifndef __PROTOBUF_C_RUNTIME_H_ -#define __PROTOBUF_C_RUNTIME_H_ + * Copyright (c) 2008-2017, Dave Benson and the protobuf-c authors. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/*! \file + * \mainpage Introduction + * + * This is [protobuf-c], a C implementation of [Protocol Buffers]. + * + * This file defines the public API for the `libprotobuf-c` support library. + * This API includes interfaces that can be used directly by client code as well + * as the interfaces used by the code generated by the `protoc-c` compiler. + * + * The `libprotobuf-c` support library performs the actual serialization and + * deserialization of Protocol Buffers messages. It interacts with structures, + * definitions, and metadata generated by the `protoc-c` compiler from .proto + * files. + * + * \authors Dave Benson and the `protobuf-c` authors. + * + * \copyright 2008-2014. Licensed under the terms of the [BSD-2-Clause] license. + * + * [protobuf-c]: https://github.com/protobuf-c/protobuf-c + * [Protocol Buffers]: https://developers.google.com/protocol-buffers/ + * [BSD-2-Clause]: http://opensource.org/licenses/BSD-2-Clause + * + * \page gencode Generated Code + * + * For each enum, we generate a C enum. For each message, we generate a C + * structure which can be cast to a `ProtobufCMessage`. + * + * For each enum and message, we generate a descriptor object that allows us to + * implement a kind of reflection on the structures. + * + * First, some naming conventions: + * + * - The name of the type for enums and messages and services is camel case + * (meaning WordsAreCrammedTogether) except that double underscores are used + * to delimit scopes. For example, the following `.proto` file: + * +~~~{.proto} + package foo.bar; + message BazBah { + optional int32 val = 1; + } +~~~ + * + * would generate a C type `Foo__Bar__BazBah`. + * + * - Identifiers for functions and globals are all lowercase, with camel case + * words separated by single underscores. For example, one of the function + * prototypes generated by `protoc-c` for the above example: + * +~~~{.c} +Foo__Bar__BazBah * + foo__bar__baz_bah__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data); +~~~ + * + * - Identifiers for enum values contain an uppercase prefix which embeds the + * package name and the enum type name. + * + * - A double underscore is used to separate further components of identifier + * names. + * + * For example, in the name of the unpack function above, the package name + * `foo.bar` has become `foo__bar`, the message name BazBah has become + * `baz_bah`, and the method name is `unpack`. These are all joined with double + * underscores to form the C identifier `foo__bar__baz_bah__unpack`. + * + * We also generate descriptor objects for messages and enums. These are + * declared in the `.pb-c.h` files: + * +~~~{.c} +extern const ProtobufCMessageDescriptor foo__bar__baz_bah__descriptor; +~~~ + * + * The message structures all begin with `ProtobufCMessageDescriptor *` which is + * sufficient to allow them to be cast to `ProtobufCMessage`. + * + * For each message defined in a `.proto` file, we generate a number of + * functions and macros. Each function name contains a prefix based on the + * package name and message name in order to make it a unique C identifier. + * + * - `INIT`. Statically initializes a message object, initializing its + * descriptor and setting its fields to default values. Uninitialized + * messages cannot be processed by the protobuf-c library. + * +~~~{.c} +#define FOO__BAR__BAZ_BAH__INIT \ + { PROTOBUF_C_MESSAGE_INIT (&foo__bar__baz_bah__descriptor), 0 } +~~~ + * - `init()`. Initializes a message object, initializing its descriptor and + * setting its fields to default values. Uninitialized messages cannot be + * processed by the protobuf-c library. + * +~~~{.c} +void foo__bar__baz_bah__init + (Foo__Bar__BazBah *message); +~~~ + * - `unpack()`. Unpacks data for a particular message format. Note that the + * `allocator` parameter is usually `NULL` to indicate that the system's + * `malloc()` and `free()` functions should be used for dynamically allocating + * memory. + * +~~~{.c} +Foo__Bar__BazBah * + foo__bar__baz_bah__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data); +~~~ + * + * - `free_unpacked()`. Frees a message object obtained with the `unpack()` + * method. Freeing `NULL` is allowed (the same as with `free()`). + * +~~~{.c} +void foo__bar__baz_bah__free_unpacked + (Foo__Bar__BazBah *message, + ProtobufCAllocator *allocator); +~~~ + * + * - `get_packed_size()`. Calculates the length in bytes of the serialized + * representation of the message object. + * +~~~{.c} +size_t foo__bar__baz_bah__get_packed_size + (const Foo__Bar__BazBah *message); +~~~ + * + * - `pack()`. Pack a message object into a preallocated buffer. Assumes that + * the buffer is large enough. (Use `get_packed_size()` first.) + * +~~~{.c} +size_t foo__bar__baz_bah__pack + (const Foo__Bar__BazBah *message, + uint8_t *out); +~~~ + * + * - `pack_to_buffer()`. Packs a message into a "virtual buffer". This is an + * object which defines an "append bytes" callback to consume data as it is + * serialized. + * +~~~{.c} +size_t foo__bar__baz_bah__pack_to_buffer + (const Foo__Bar__BazBah *message, + ProtobufCBuffer *buffer); +~~~ + * + * \page pack Packing and unpacking messages + * + * To pack a message, first compute the packed size of the message with + * protobuf_c_message_get_packed_size(), then allocate a buffer of at least + * that size, then call protobuf_c_message_pack(). + * + * Alternatively, a message can be serialized without calculating the final size + * first. Use the protobuf_c_message_pack_to_buffer() function and provide a + * ProtobufCBuffer object which implements an "append" method that consumes + * data. + * + * To unpack a message, call the protobuf_c_message_unpack() function. The + * result can be cast to an object of the type that matches the descriptor for + * the message. + * + * The result of unpacking a message should be freed with + * protobuf_c_message_free_unpacked(). + */ + +#ifndef PROTOBUF_C_H +#define PROTOBUF_C_H -#include <stddef.h> #include <assert.h> +#include <limits.h> +#include <stddef.h> +#include <stdint.h> #ifdef __cplusplus -# define PROTOBUF_C_BEGIN_DECLS extern "C" { -# define PROTOBUF_C_END_DECLS } -#else -# define PROTOBUF_C_BEGIN_DECLS -# define PROTOBUF_C_END_DECLS -#endif - -#if !defined(PROTOBUF_C_NO_DEPRECATED) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) -#define PROTOBUF_C_DEPRECATED __attribute__((__deprecated__)) +# define PROTOBUF_C__BEGIN_DECLS extern "C" { +# define PROTOBUF_C__END_DECLS } #else -#define PROTOBUF_C_DEPRECATED +# define PROTOBUF_C__BEGIN_DECLS +# define PROTOBUF_C__END_DECLS #endif -/* Define int32_t, int64_t, uint32_t, uint64_t, uint8_t. - - Usually, just include <inttypes.h> to do the work. - XXX: should we use stdint.h? - */ -#ifndef PROTOBUF_C_SKIP_INTTYPES_H -# if defined(_MSC_VER) - /* On windows, in ms visual studio, define the types ourselves */ -# define int32_t signed __int32 -# define INT32_MIN _I32_MIN -# define INT32_MAX _I32_MAX -# define uint32_t unsigned __int32 -# define UINT32_MIN _UI32_MIN -# define UINT32_MAX _UI32_MAX -# define int64_t signed __int64 -# define INT64_MIN _I64_MIN -# define INT64_MAX _I64_MAX -# define uint64_t unsigned __int64 -# define UINT64_MIN _UI64_MIN -# define UINT64_MAX _UI64_MAX -# define uint8_t unsigned char -# else - /* Use the system inttypes.h */ -# include <inttypes.h> -# endif -#endif +PROTOBUF_C__BEGIN_DECLS #if defined(_WIN32) && defined(PROTOBUF_C_USE_SHARED_LIB) - # ifdef PROTOBUF_C_EXPORT -# define PROTOBUF_C_API __declspec(dllexport) +# define PROTOBUF_C__API __declspec(dllexport) # else -# define PROTOBUF_C_API __declspec(dllimport) +# define PROTOBUF_C__API __declspec(dllimport) +# endif +#else +# define PROTOBUF_C__API #endif +#if !defined(PROTOBUF_C__NO_DEPRECATED) && \ + ((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) +# define PROTOBUF_C__DEPRECATED __attribute__((__deprecated__)) #else -# define PROTOBUF_C_API +# define PROTOBUF_C__DEPRECATED #endif -PROTOBUF_C_BEGIN_DECLS +#ifndef PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE + #define PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(enum_name) \ + , _##enum_name##_IS_INT_SIZE = INT_MAX +#endif -typedef enum -{ - PROTOBUF_C_LABEL_REQUIRED, - PROTOBUF_C_LABEL_OPTIONAL, - PROTOBUF_C_LABEL_REPEATED +#define PROTOBUF_C__SERVICE_DESCRIPTOR_MAGIC 0x14159bc3 +#define PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC 0x28aaeef9 +#define PROTOBUF_C__ENUM_DESCRIPTOR_MAGIC 0x114315af + +/* Empty string used for initializers */ +extern const char protobuf_c_empty_string[]; + +/** + * \defgroup api Public API + * + * This is the public API for `libprotobuf-c`. These interfaces are stable and + * subject to Semantic Versioning guarantees. + * + * @{ + */ + +/** + * Values for the `flags` word in `ProtobufCFieldDescriptor`. + */ +typedef enum { + /** Set if the field is repeated and marked with the `packed` option. */ + PROTOBUF_C_FIELD_FLAG_PACKED = (1 << 0), + + /** Set if the field is marked with the `deprecated` option. */ + PROTOBUF_C_FIELD_FLAG_DEPRECATED = (1 << 1), + + /** Set if the field is a member of a oneof (union). */ + PROTOBUF_C_FIELD_FLAG_ONEOF = (1 << 2), +} ProtobufCFieldFlag; + +/** + * Message field rules. + * + * \see [Defining A Message Type] in the Protocol Buffers documentation. + * + * [Defining A Message Type]: + * https://developers.google.com/protocol-buffers/docs/proto#simple + */ +typedef enum { + /** A well-formed message must have exactly one of this field. */ + PROTOBUF_C_LABEL_REQUIRED, + + /** + * A well-formed message can have zero or one of this field (but not + * more than one). + */ + PROTOBUF_C_LABEL_OPTIONAL, + + /** + * This field can be repeated any number of times (including zero) in a + * well-formed message. The order of the repeated values will be + * preserved. + */ + PROTOBUF_C_LABEL_REPEATED, + + /** + * This field has no label. This is valid only in proto3 and is + * equivalent to OPTIONAL but no "has" quantifier will be consulted. + */ + PROTOBUF_C_LABEL_NONE, } ProtobufCLabel; -typedef enum -{ - PROTOBUF_C_TYPE_INT32, - PROTOBUF_C_TYPE_SINT32, - PROTOBUF_C_TYPE_SFIXED32, - PROTOBUF_C_TYPE_INT64, - PROTOBUF_C_TYPE_SINT64, - PROTOBUF_C_TYPE_SFIXED64, - PROTOBUF_C_TYPE_UINT32, - PROTOBUF_C_TYPE_FIXED32, - PROTOBUF_C_TYPE_UINT64, - PROTOBUF_C_TYPE_FIXED64, - PROTOBUF_C_TYPE_FLOAT, - PROTOBUF_C_TYPE_DOUBLE, - PROTOBUF_C_TYPE_BOOL, - PROTOBUF_C_TYPE_ENUM, - PROTOBUF_C_TYPE_STRING, - PROTOBUF_C_TYPE_BYTES, - //PROTOBUF_C_TYPE_GROUP, // NOT SUPPORTED - PROTOBUF_C_TYPE_MESSAGE, +/** + * Field value types. + * + * \see [Scalar Value Types] in the Protocol Buffers documentation. + * + * [Scalar Value Types]: + * https://developers.google.com/protocol-buffers/docs/proto#scalar + */ +typedef enum { + PROTOBUF_C_TYPE_INT32, /**< int32 */ + PROTOBUF_C_TYPE_SINT32, /**< signed int32 */ + PROTOBUF_C_TYPE_SFIXED32, /**< signed int32 (4 bytes) */ + PROTOBUF_C_TYPE_INT64, /**< int64 */ + PROTOBUF_C_TYPE_SINT64, /**< signed int64 */ + PROTOBUF_C_TYPE_SFIXED64, /**< signed int64 (8 bytes) */ + PROTOBUF_C_TYPE_UINT32, /**< unsigned int32 */ + PROTOBUF_C_TYPE_FIXED32, /**< unsigned int32 (4 bytes) */ + PROTOBUF_C_TYPE_UINT64, /**< unsigned int64 */ + PROTOBUF_C_TYPE_FIXED64, /**< unsigned int64 (8 bytes) */ + PROTOBUF_C_TYPE_FLOAT, /**< float */ + PROTOBUF_C_TYPE_DOUBLE, /**< double */ + PROTOBUF_C_TYPE_BOOL, /**< boolean */ + PROTOBUF_C_TYPE_ENUM, /**< enumerated type */ + PROTOBUF_C_TYPE_STRING, /**< UTF-8 or ASCII string */ + PROTOBUF_C_TYPE_BYTES, /**< arbitrary byte sequence */ + PROTOBUF_C_TYPE_MESSAGE, /**< nested message */ } ProtobufCType; +/** + * Field wire types. + * + * \see [Message Structure] in the Protocol Buffers documentation. + * + * [Message Structure]: + * https://developers.google.com/protocol-buffers/docs/encoding#structure + */ +typedef enum { + PROTOBUF_C_WIRE_TYPE_VARINT = 0, + PROTOBUF_C_WIRE_TYPE_64BIT = 1, + PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED = 2, + /* "Start group" and "end group" wire types are unsupported. */ + PROTOBUF_C_WIRE_TYPE_32BIT = 5, +} ProtobufCWireType; + +struct ProtobufCAllocator; +struct ProtobufCBinaryData; +struct ProtobufCBuffer; +struct ProtobufCBufferSimple; +struct ProtobufCEnumDescriptor; +struct ProtobufCEnumValue; +struct ProtobufCEnumValueIndex; +struct ProtobufCFieldDescriptor; +struct ProtobufCIntRange; +struct ProtobufCMessage; +struct ProtobufCMessageDescriptor; +struct ProtobufCMessageUnknownField; +struct ProtobufCMethodDescriptor; +struct ProtobufCService; +struct ProtobufCServiceDescriptor; +typedef struct ProtobufCAllocator ProtobufCAllocator; +typedef struct ProtobufCBinaryData ProtobufCBinaryData; +typedef struct ProtobufCBuffer ProtobufCBuffer; +typedef struct ProtobufCBufferSimple ProtobufCBufferSimple; +typedef struct ProtobufCEnumDescriptor ProtobufCEnumDescriptor; +typedef struct ProtobufCEnumValue ProtobufCEnumValue; +typedef struct ProtobufCEnumValueIndex ProtobufCEnumValueIndex; +typedef struct ProtobufCFieldDescriptor ProtobufCFieldDescriptor; +typedef struct ProtobufCIntRange ProtobufCIntRange; +typedef struct ProtobufCMessage ProtobufCMessage; +typedef struct ProtobufCMessageDescriptor ProtobufCMessageDescriptor; +typedef struct ProtobufCMessageUnknownField ProtobufCMessageUnknownField; +typedef struct ProtobufCMethodDescriptor ProtobufCMethodDescriptor; +typedef struct ProtobufCService ProtobufCService; +typedef struct ProtobufCServiceDescriptor ProtobufCServiceDescriptor; + +/** Boolean type. */ typedef int protobuf_c_boolean; -#define PROTOBUF_C_OFFSETOF(struct, member) offsetof(struct, member) -#define PROTOBUF_C_ASSERT(condition) assert(condition) -#define PROTOBUF_C_ASSERT_NOT_REACHED() assert(0) +typedef void (*ProtobufCClosure)(const ProtobufCMessage *, void *closure_data); +typedef void (*ProtobufCMessageInit)(ProtobufCMessage *); +typedef void (*ProtobufCServiceDestroy)(ProtobufCService *); -typedef struct _ProtobufCBinaryData ProtobufCBinaryData; -struct _ProtobufCBinaryData -{ - size_t len; - uint8_t *data; -}; +/** + * Structure for defining a custom memory allocator. + */ +struct ProtobufCAllocator { + /** Function to allocate memory. */ + void *(*alloc)(void *allocator_data, size_t size); -typedef struct _ProtobufCIntRange ProtobufCIntRange; /* private */ + /** Function to free memory. */ + void (*free)(void *allocator_data, void *pointer); -/* --- memory management --- */ -typedef struct _ProtobufCAllocator ProtobufCAllocator; -struct _ProtobufCAllocator -{ - void *(*alloc)(void *allocator_data, size_t size); - void (*free)(void *allocator_data, void *pointer); - void *(*tmp_alloc)(void *allocator_data, size_t size); - unsigned max_alloca; - void *allocator_data; + /** Opaque pointer passed to `alloc` and `free` functions. */ + void *allocator_data; }; -/* This is a configurable allocator. - * By default, it uses the system allocator (meaning malloc() and free()). - * This is typically changed to adapt to frameworks that provide - * some nonstandard allocation functions. +/** + * Structure for the protobuf `bytes` scalar type. * - * NOTE: you may modify this allocator. + * The data contained in a `ProtobufCBinaryData` is an arbitrary sequence of + * bytes. It may contain embedded `NUL` characters and is not required to be + * `NUL`-terminated. */ -extern PROTOBUF_C_API ProtobufCAllocator protobuf_c_default_allocator; /* settable */ +struct ProtobufCBinaryData { + size_t len; /**< Number of bytes in the `data` field. */ + uint8_t *data; /**< Data bytes. */ +}; -/* This is the system allocator, meaning it uses malloc() and free(). +/** + * Structure for defining a virtual append-only buffer. Used by + * protobuf_c_message_pack_to_buffer() to abstract the consumption of serialized + * bytes. * - * NOTE: please do NOT modify this allocator. - */ -extern PROTOBUF_C_API ProtobufCAllocator protobuf_c_system_allocator; /* use malloc, free etc */ - -/* This is the function that our default allocators call when they - run out-of-memory. The default behavior of this function is to - terminate your program. */ -extern PROTOBUF_C_API void (*protobuf_c_out_of_memory) (void); + * `ProtobufCBuffer` "subclasses" may be defined on the stack. For example, to + * write to a `FILE` object: + * +~~~{.c} +typedef struct { + ProtobufCBuffer base; + FILE *fp; +} BufferAppendToFile; -/* --- append-only data buffer --- */ -typedef struct _ProtobufCBuffer ProtobufCBuffer; -struct _ProtobufCBuffer -{ - void (*append)(ProtobufCBuffer *buffer, - size_t len, - const uint8_t *data); -}; -/* --- enums --- */ -typedef struct _ProtobufCEnumValue ProtobufCEnumValue; -typedef struct _ProtobufCEnumValueIndex ProtobufCEnumValueIndex; -typedef struct _ProtobufCEnumDescriptor ProtobufCEnumDescriptor; - -/* ProtobufCEnumValue: this represents a single value of - * an enumeration. - * 'name' is the string identifying this value, as given in the .proto file. - * 'c_name' is the full name of the C enumeration value. - * 'value' is the number assigned to this value, as given in the .proto file. - */ -struct _ProtobufCEnumValue +static void +my_buffer_file_append(ProtobufCBuffer *buffer, + size_t len, + const uint8_t *data) { - const char *name; - const char *c_name; - int value; + BufferAppendToFile *file_buf = (BufferAppendToFile *) buffer; + fwrite(data, len, 1, file_buf->fp); // XXX: No error handling! +} +~~~ + * + * To use this new type of ProtobufCBuffer, it could be called as follows: + * +~~~{.c} +... +BufferAppendToFile tmp = {0}; +tmp.base.append = my_buffer_file_append; +tmp.fp = fp; +protobuf_c_message_pack_to_buffer(&message, &tmp); +... +~~~ + */ +struct ProtobufCBuffer { + /** Append function. Consumes the `len` bytes stored at `data`. */ + void (*append)(ProtobufCBuffer *buffer, + size_t len, + const uint8_t *data); }; -/* ProtobufCEnumDescriptor: the represents the enum as a whole, - * with all its values. - * 'magic' is a code we check to ensure that the api is used correctly. - * 'name' is the qualified name (e.g. "namespace.Type"). - * 'short_name' is the unqualified name ("Type"), as given in the .proto file. - * 'package_name' is the '.'-separated namespace - * 'n_values' is the number of distinct values. - * 'values' is the array of distinct values. - * 'n_value_names' number of named values (including aliases). - * 'value_names' are the named values (including aliases). +/** + * Simple buffer "subclass" of `ProtobufCBuffer`. + * + * A `ProtobufCBufferSimple` object is declared on the stack and uses a + * scratch buffer provided by the user for the initial allocation. It performs + * exponential resizing, using dynamically allocated memory. A + * `ProtobufCBufferSimple` object can be created and used as follows: + * +~~~{.c} +uint8_t pad[128]; +ProtobufCBufferSimple simple = PROTOBUF_C_BUFFER_SIMPLE_INIT(pad); +ProtobufCBuffer *buffer = (ProtobufCBuffer *) &simple; +~~~ + * + * `buffer` can now be used with `protobuf_c_message_pack_to_buffer()`. Once a + * message has been serialized to a `ProtobufCBufferSimple` object, the + * serialized data bytes can be accessed from the `.data` field. + * + * To free the memory allocated by a `ProtobufCBufferSimple` object, if any, + * call PROTOBUF_C_BUFFER_SIMPLE_CLEAR() on the object, for example: * - * The rest of the values are private essentially. +~~~{.c} +PROTOBUF_C_BUFFER_SIMPLE_CLEAR(&simple); +~~~ * - * see also: Use protobuf_c_enum_descriptor_get_value_by_name() - * and protobuf_c_enum_descriptor_get_value() to efficiently - * lookup values in the descriptor. + * \see PROTOBUF_C_BUFFER_SIMPLE_INIT + * \see PROTOBUF_C_BUFFER_SIMPLE_CLEAR */ -struct _ProtobufCEnumDescriptor -{ - uint32_t magic; +struct ProtobufCBufferSimple { + /** "Base class". */ + ProtobufCBuffer base; + /** Number of bytes allocated in `data`. */ + size_t alloced; + /** Number of bytes currently stored in `data`. */ + size_t len; + /** Data bytes. */ + uint8_t *data; + /** Whether `data` must be freed. */ + protobuf_c_boolean must_free_data; + /** Allocator to use. May be NULL to indicate the system allocator. */ + ProtobufCAllocator *allocator; +}; + +/** + * Describes an enumeration as a whole, with all of its values. + */ +struct ProtobufCEnumDescriptor { + /** Magic value checked to ensure that the API is used correctly. */ + uint32_t magic; - const char *name; - const char *short_name; - const char *c_name; - const char *package_name; + /** The qualified name (e.g., "namespace.Type"). */ + const char *name; + /** The unqualified name as given in the .proto file (e.g., "Type"). */ + const char *short_name; + /** Identifier used in generated C code. */ + const char *c_name; + /** The dot-separated namespace. */ + const char *package_name; - /* sorted by value */ - unsigned n_values; - const ProtobufCEnumValue *values; + /** Number elements in `values`. */ + unsigned n_values; + /** Array of distinct values, sorted by numeric value. */ + const ProtobufCEnumValue *values; - /* sorted by name */ - unsigned n_value_names; - const ProtobufCEnumValueIndex *values_by_name; + /** Number of elements in `values_by_name`. */ + unsigned n_value_names; + /** Array of named values, including aliases, sorted by name. */ + const ProtobufCEnumValueIndex *values_by_name; - /* value-ranges, for faster lookups by number */ - unsigned n_value_ranges; - const ProtobufCIntRange *value_ranges; + /** Number of elements in `value_ranges`. */ + unsigned n_value_ranges; + /** Value ranges, for faster lookups by numeric value. */ + const ProtobufCIntRange *value_ranges; - void *reserved1; - void *reserved2; - void *reserved3; - void *reserved4; + /** Reserved for future use. */ + void *reserved1; + /** Reserved for future use. */ + void *reserved2; + /** Reserved for future use. */ + void *reserved3; + /** Reserved for future use. */ + void *reserved4; }; -/* --- messages --- */ -typedef struct _ProtobufCMessageDescriptor ProtobufCMessageDescriptor; -typedef struct _ProtobufCFieldDescriptor ProtobufCFieldDescriptor; -typedef struct _ProtobufCMessage ProtobufCMessage; -typedef void (*ProtobufCMessageInit)(ProtobufCMessage *); -/* ProtobufCFieldDescriptor: description of a single field - * in a message. - * 'name' is the name of the field, as given in the .proto file. - * 'id' is the code representing the field, as given in the .proto file. - * 'label' is one of PROTOBUF_C_LABEL_{REQUIRED,OPTIONAL,REPEATED} - * 'type' is the type of field. - * 'quantifier_offset' is the offset in bytes into the message's C structure - * for this member's "has_MEMBER" field (for optional members) or - * "n_MEMBER" field (for repeated members). - * 'offset' is the offset in bytes into the message's C structure - * for the member itself. - * 'descriptor' is a pointer to a ProtobufC{Enum,Message}Descriptor - * if type is PROTOBUF_C_TYPE_{ENUM,MESSAGE} respectively, - * otherwise NULL. - * 'default_value' is a pointer to a default value for this field, - * where allowed. - */ -struct _ProtobufCFieldDescriptor -{ - const char *name; - uint32_t id; - ProtobufCLabel label; - ProtobufCType type; - unsigned quantifier_offset; - unsigned offset; - const void *descriptor; /* for MESSAGE and ENUM types */ - const void *default_value; /* or NULL if no default-value */ - protobuf_c_boolean packed; - - unsigned reserved_flags; - void *reserved2; - void *reserved3; +/** + * Represents a single value of an enumeration. + */ +struct ProtobufCEnumValue { + /** The string identifying this value in the .proto file. */ + const char *name; + + /** The string identifying this value in generated C code. */ + const char *c_name; + + /** The numeric value assigned in the .proto file. */ + int value; +}; + +/** + * Used by `ProtobufCEnumDescriptor` to look up enum values. + */ +struct ProtobufCEnumValueIndex { + /** Name of the enum value. */ + const char *name; + /** Index into values[] array. */ + unsigned index; }; -/* ProtobufCMessageDescriptor: description of a message. - * - * 'magic' is a code we check to ensure that the api is used correctly. - * 'name' is the qualified name (e.g. "namespace.Type"). - * 'short_name' is the unqualified name ("Type"), as given in the .proto file. - * 'c_name' is the c-formatted name of the structure - * 'package_name' is the '.'-separated namespace - * 'sizeof_message' is the size in bytes of the C structure - * representing an instance of this type of message. - * 'n_fields' is the number of known fields in this message. - * 'fields' is the fields sorted by id number. - * 'fields_sorted_by_name', 'n_field_ranges' and 'field_ranges' - * are used for looking up fields by name and id. (private) - */ -struct _ProtobufCMessageDescriptor -{ - uint32_t magic; - const char *name; - const char *short_name; - const char *c_name; - const char *package_name; +/** + * Describes a single field in a message. + */ +struct ProtobufCFieldDescriptor { + /** Name of the field as given in the .proto file. */ + const char *name; + + /** Tag value of the field as given in the .proto file. */ + uint32_t id; + + /** Whether the field is `REQUIRED`, `OPTIONAL`, or `REPEATED`. */ + ProtobufCLabel label; + + /** The type of the field. */ + ProtobufCType type; - size_t sizeof_message; + /** + * The offset in bytes of the message's C structure's quantifier field + * (the `has_MEMBER` field for optional members or the `n_MEMBER` field + * for repeated members or the case enum for oneofs). + */ + unsigned quantifier_offset; - /* sorted by field-id */ - unsigned n_fields; - const ProtobufCFieldDescriptor *fields; - const unsigned *fields_sorted_by_name; + /** + * The offset in bytes into the message's C structure for the member + * itself. + */ + unsigned offset; - /* ranges, optimization for looking up fields */ - unsigned n_field_ranges; - const ProtobufCIntRange *field_ranges; + /** + * A type-specific descriptor. + * + * If `type` is `PROTOBUF_C_TYPE_ENUM`, then `descriptor` points to the + * corresponding `ProtobufCEnumDescriptor`. + * + * If `type` is `PROTOBUF_C_TYPE_MESSAGE`, then `descriptor` points to + * the corresponding `ProtobufCMessageDescriptor`. + * + * Otherwise this field is NULL. + */ + const void *descriptor; /* for MESSAGE and ENUM types */ - ProtobufCMessageInit message_init; - void *reserved1; - void *reserved2; - void *reserved3; + /** The default value for this field, if defined. May be NULL. */ + const void *default_value; + + /** + * A flag word. Zero or more of the bits defined in the + * `ProtobufCFieldFlag` enum may be set. + */ + uint32_t flags; + + /** Reserved for future use. */ + unsigned reserved_flags; + /** Reserved for future use. */ + void *reserved2; + /** Reserved for future use. */ + void *reserved3; }; +/** + * Helper structure for optimizing int => index lookups in the case + * where the keys are mostly consecutive values, as they presumably are for + * enums and fields. + * + * The data structures requires that the values in the original array are + * sorted. + */ +struct ProtobufCIntRange { + int start_value; + unsigned orig_index; + /* + * NOTE: the number of values in the range can be inferred by looking + * at the next element's orig_index. A dummy element is added to make + * this simple. + */ +}; -/* ProtobufCMessage: an instance of a message. +/** + * An instance of a message. * - * ProtobufCMessage is sort-of a lightweight - * base-class for all messages. - * - * In particular, ProtobufCMessage doesn't have - * any allocation policy associated with it. - * That's because it is common to create ProtobufCMessage's - * on the stack. In fact, we that's what we recommend - * for sending messages (because if you just allocate from the - * stack, then you can't really have a memory leak). + * `ProtobufCMessage` is a light-weight "base class" for all messages. * - * This means that functions like protobuf_c_message_unpack() - * which return a ProtobufCMessage must be paired - * with a free function, like protobuf_c_message_free_unpacked(). + * In particular, `ProtobufCMessage` doesn't have any allocation policy + * associated with it. That's because it's common to create `ProtobufCMessage` + * objects on the stack. In fact, that's what we recommend for sending messages. + * If the object is allocated from the stack, you can't really have a memory + * leak. * - * 'descriptor' gives the locations and types of the members of message - * 'n_unknown_fields' is the number of fields we didn't recognize. - * 'unknown_fields' are fields we didn't recognize. + * This means that calls to functions like protobuf_c_message_unpack() which + * return a `ProtobufCMessage` must be paired with a call to a free function, + * like protobuf_c_message_free_unpacked(). */ -typedef struct _ProtobufCMessageUnknownField ProtobufCMessageUnknownField; -struct _ProtobufCMessage -{ - const ProtobufCMessageDescriptor *descriptor; - unsigned n_unknown_fields; - ProtobufCMessageUnknownField *unknown_fields; +struct ProtobufCMessage { + /** The descriptor for this message type. */ + const ProtobufCMessageDescriptor *descriptor; + /** The number of elements in `unknown_fields`. */ + unsigned n_unknown_fields; + /** The fields that weren't recognized by the parser. */ + ProtobufCMessageUnknownField *unknown_fields; }; -#define PROTOBUF_C_MESSAGE_INIT(descriptor) { descriptor, 0, NULL } -/* To pack a message: you have two options: - (1) you can compute the size of the message - using protobuf_c_message_get_packed_size() - then pass protobuf_c_message_pack() a buffer of - that length. - (2) Provide a virtual buffer (a ProtobufCBuffer) to - accept data as we scan through it. - */ -PROTOBUF_C_API size_t protobuf_c_message_get_packed_size(const ProtobufCMessage *message); -PROTOBUF_C_API size_t protobuf_c_message_pack (const ProtobufCMessage *message, - uint8_t *out); -PROTOBUF_C_API size_t protobuf_c_message_pack_to_buffer (const ProtobufCMessage *message, - ProtobufCBuffer *buffer); - -PROTOBUF_C_API ProtobufCMessage * - protobuf_c_message_unpack (const ProtobufCMessageDescriptor *, - ProtobufCAllocator *allocator, - size_t len, - const uint8_t *data); -PROTOBUF_C_API void protobuf_c_message_free_unpacked (ProtobufCMessage *message, - ProtobufCAllocator *allocator); - -/* WARNING: 'message' must be a block of memory - of size descriptor->sizeof_message. */ -PROTOBUF_C_API void protobuf_c_message_init (const ProtobufCMessageDescriptor *, - void *message); - -/* --- services --- */ -typedef struct _ProtobufCMethodDescriptor ProtobufCMethodDescriptor; -typedef struct _ProtobufCServiceDescriptor ProtobufCServiceDescriptor; - -struct _ProtobufCMethodDescriptor -{ - const char *name; - const ProtobufCMessageDescriptor *input; - const ProtobufCMessageDescriptor *output; +/** + * Describes a message. + */ +struct ProtobufCMessageDescriptor { + /** Magic value checked to ensure that the API is used correctly. */ + uint32_t magic; + + /** The qualified name (e.g., "namespace.Type"). */ + const char *name; + /** The unqualified name as given in the .proto file (e.g., "Type"). */ + const char *short_name; + /** Identifier used in generated C code. */ + const char *c_name; + /** The dot-separated namespace. */ + const char *package_name; + + /** + * Size in bytes of the C structure representing an instance of this + * type of message. + */ + size_t sizeof_message; + + /** Number of elements in `fields`. */ + unsigned n_fields; + /** Field descriptors, sorted by tag number. */ + const ProtobufCFieldDescriptor *fields; + /** Used for looking up fields by name. */ + const unsigned *fields_sorted_by_name; + + /** Number of elements in `field_ranges`. */ + unsigned n_field_ranges; + /** Used for looking up fields by id. */ + const ProtobufCIntRange *field_ranges; + + /** Message initialisation function. */ + ProtobufCMessageInit message_init; + + /** Reserved for future use. */ + void *reserved1; + /** Reserved for future use. */ + void *reserved2; + /** Reserved for future use. */ + void *reserved3; }; -struct _ProtobufCServiceDescriptor -{ - uint32_t magic; - - const char *name; - const char *short_name; - const char *c_name; - const char *package; - unsigned n_methods; - const ProtobufCMethodDescriptor *methods; /* in order from .proto file */ - const unsigned *method_indices_by_name; + +/** + * An unknown message field. + */ +struct ProtobufCMessageUnknownField { + /** The tag number. */ + uint32_t tag; + /** The wire type of the field. */ + ProtobufCWireType wire_type; + /** Number of bytes in `data`. */ + size_t len; + /** Field data. */ + uint8_t *data; }; -typedef struct _ProtobufCService ProtobufCService; -typedef void (*ProtobufCClosure)(const ProtobufCMessage *message, - void *closure_data); -struct _ProtobufCService -{ - const ProtobufCServiceDescriptor *descriptor; - void (*invoke)(ProtobufCService *service, - unsigned method_index, - const ProtobufCMessage *input, - ProtobufCClosure closure, - void *closure_data); - void (*destroy) (ProtobufCService *service); +/** + * Method descriptor. + */ +struct ProtobufCMethodDescriptor { + /** Method name. */ + const char *name; + /** Input message descriptor. */ + const ProtobufCMessageDescriptor *input; + /** Output message descriptor. */ + const ProtobufCMessageDescriptor *output; }; +/** + * Service. + */ +struct ProtobufCService { + /** Service descriptor. */ + const ProtobufCServiceDescriptor *descriptor; + /** Function to invoke the service. */ + void (*invoke)(ProtobufCService *service, + unsigned method_index, + const ProtobufCMessage *input, + ProtobufCClosure closure, + void *closure_data); + /** Function to destroy the service. */ + void (*destroy)(ProtobufCService *service); +}; -void protobuf_c_service_destroy (ProtobufCService *); - - -/* --- querying the descriptors --- */ -PROTOBUF_C_API const ProtobufCEnumValue * -protobuf_c_enum_descriptor_get_value_by_name - (const ProtobufCEnumDescriptor *desc, - const char *name); -PROTOBUF_C_API const ProtobufCEnumValue * -protobuf_c_enum_descriptor_get_value - (const ProtobufCEnumDescriptor *desc, - int value); -PROTOBUF_C_API const ProtobufCFieldDescriptor * -protobuf_c_message_descriptor_get_field_by_name - (const ProtobufCMessageDescriptor *desc, - const char *name); -PROTOBUF_C_API const ProtobufCFieldDescriptor * -protobuf_c_message_descriptor_get_field - (const ProtobufCMessageDescriptor *desc, - unsigned value); -PROTOBUF_C_API const ProtobufCMethodDescriptor * -protobuf_c_service_descriptor_get_method_by_name - (const ProtobufCServiceDescriptor *desc, - const char *name); - -/* --- wire format enums --- */ -typedef enum -{ - PROTOBUF_C_WIRE_TYPE_VARINT, - PROTOBUF_C_WIRE_TYPE_64BIT, - PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED, - PROTOBUF_C_WIRE_TYPE_START_GROUP, /* unsupported */ - PROTOBUF_C_WIRE_TYPE_END_GROUP, /* unsupported */ - PROTOBUF_C_WIRE_TYPE_32BIT -} ProtobufCWireType; +/** + * Service descriptor. + */ +struct ProtobufCServiceDescriptor { + /** Magic value checked to ensure that the API is used correctly. */ + uint32_t magic; -/* --- unknown message fields --- */ -struct _ProtobufCMessageUnknownField -{ - uint32_t tag; - ProtobufCWireType wire_type; - size_t len; - uint8_t *data; + /** Service name. */ + const char *name; + /** Short version of service name. */ + const char *short_name; + /** C identifier for the service name. */ + const char *c_name; + /** Package name. */ + const char *package; + /** Number of elements in `methods`. */ + unsigned n_methods; + /** Method descriptors, in the order defined in the .proto file. */ + const ProtobufCMethodDescriptor *methods; + /** Sort index of methods. */ + const unsigned *method_indices_by_name; }; -/* --- extra (superfluous) api: trivial buffer --- */ -typedef struct _ProtobufCBufferSimple ProtobufCBufferSimple; -struct _ProtobufCBufferSimple -{ - ProtobufCBuffer base; - size_t alloced; - size_t len; - uint8_t *data; - protobuf_c_boolean must_free_data; -}; -#define PROTOBUF_C_BUFFER_SIMPLE_INIT(array_of_bytes) \ -{ { protobuf_c_buffer_simple_append }, \ - sizeof(array_of_bytes), 0, (array_of_bytes), 0 } -#define PROTOBUF_C_BUFFER_SIMPLE_CLEAR(simp_buf) \ - do { if ((simp_buf)->must_free_data) \ - protobuf_c_default_allocator.free (&protobuf_c_default_allocator.allocator_data, (simp_buf)->data); } while (0) +/** + * Get the version of the protobuf-c library. Note that this is the version of + * the library linked against, not the version of the headers compiled against. + * + * \return A string containing the version number of protobuf-c. + */ +PROTOBUF_C__API +const char * +protobuf_c_version(void); +/** + * Get the version of the protobuf-c library. Note that this is the version of + * the library linked against, not the version of the headers compiled against. + * + * \return A 32 bit unsigned integer containing the version number of + * protobuf-c, represented in base-10 as (MAJOR*1E6) + (MINOR*1E3) + PATCH. + */ +PROTOBUF_C__API +uint32_t +protobuf_c_version_number(void); -typedef enum -{ - PROTOBUF_C_CTYPE_INT32, - PROTOBUF_C_CTYPE_UINT32, - PROTOBUF_C_CTYPE_INT64, - PROTOBUF_C_CTYPE_UINT64, - PROTOBUF_C_CTYPE_FLOAT, - PROTOBUF_C_CTYPE_DOUBLE, - PROTOBUF_C_CTYPE_BOOL, - PROTOBUF_C_CTYPE_ENUM, - PROTOBUF_C_CTYPE_STRING, - PROTOBUF_C_CTYPE_BYTES, - PROTOBUF_C_CTYPE_MESSAGE, -} ProtobufCCType; - -extern ProtobufCCType protobuf_c_type_to_ctype (ProtobufCType type); -#define protobuf_c_type_to_ctype(type) \ - ((ProtobufCCType)(protobuf_c_type_to_ctype_array[(type)])) - -/* ====== private ====== */ -#include "protobuf-c-private.h" - - -PROTOBUF_C_END_DECLS - -#endif /* __PROTOBUF_C_RUNTIME_H_ */ +/** + * The version of the protobuf-c headers, represented as a string using the same + * format as protobuf_c_version(). + */ +#define PROTOBUF_C_VERSION "1.3.0" + +/** + * The version of the protobuf-c headers, represented as an integer using the + * same format as protobuf_c_version_number(). + */ +#define PROTOBUF_C_VERSION_NUMBER 1003000 + +/** + * The minimum protoc-c version which works with the current version of the + * protobuf-c headers. + */ +#define PROTOBUF_C_MIN_COMPILER_VERSION 1000000 + +/** + * Look up a `ProtobufCEnumValue` from a `ProtobufCEnumDescriptor` by name. + * + * \param desc + * The `ProtobufCEnumDescriptor` object. + * \param name + * The `name` field from the corresponding `ProtobufCEnumValue` object to + * match. + * \return + * A `ProtobufCEnumValue` object. + * \retval NULL + * If not found or if the optimize_for = CODE_SIZE option was set. + */ +PROTOBUF_C__API +const ProtobufCEnumValue * +protobuf_c_enum_descriptor_get_value_by_name( + const ProtobufCEnumDescriptor *desc, + const char *name); + +/** + * Look up a `ProtobufCEnumValue` from a `ProtobufCEnumDescriptor` by numeric + * value. + * + * \param desc + * The `ProtobufCEnumDescriptor` object. + * \param value + * The `value` field from the corresponding `ProtobufCEnumValue` object to + * match. + * + * \return + * A `ProtobufCEnumValue` object. + * \retval NULL + * If not found. + */ +PROTOBUF_C__API +const ProtobufCEnumValue * +protobuf_c_enum_descriptor_get_value( + const ProtobufCEnumDescriptor *desc, + int value); + +/** + * Look up a `ProtobufCFieldDescriptor` from a `ProtobufCMessageDescriptor` by + * the name of the field. + * + * \param desc + * The `ProtobufCMessageDescriptor` object. + * \param name + * The name of the field. + * \return + * A `ProtobufCFieldDescriptor` object. + * \retval NULL + * If not found or if the optimize_for = CODE_SIZE option was set. + */ +PROTOBUF_C__API +const ProtobufCFieldDescriptor * +protobuf_c_message_descriptor_get_field_by_name( + const ProtobufCMessageDescriptor *desc, + const char *name); + +/** + * Look up a `ProtobufCFieldDescriptor` from a `ProtobufCMessageDescriptor` by + * the tag value of the field. + * + * \param desc + * The `ProtobufCMessageDescriptor` object. + * \param value + * The tag value of the field. + * \return + * A `ProtobufCFieldDescriptor` object. + * \retval NULL + * If not found. + */ +PROTOBUF_C__API +const ProtobufCFieldDescriptor * +protobuf_c_message_descriptor_get_field( + const ProtobufCMessageDescriptor *desc, + unsigned value); + +/** + * Determine the number of bytes required to store the serialised message. + * + * \param message + * The message object to serialise. + * \return + * Number of bytes. + */ +PROTOBUF_C__API +size_t +protobuf_c_message_get_packed_size(const ProtobufCMessage *message); + +/** + * Serialise a message from its in-memory representation. + * + * This function stores the serialised bytes of the message in a pre-allocated + * buffer. + * + * \param message + * The message object to serialise. + * \param[out] out + * Buffer to store the bytes of the serialised message. This buffer must + * have enough space to store the packed message. Use + * protobuf_c_message_get_packed_size() to determine the number of bytes + * required. + * \return + * Number of bytes stored in `out`. + */ +PROTOBUF_C__API +size_t +protobuf_c_message_pack(const ProtobufCMessage *message, uint8_t *out); + +/** + * Serialise a message from its in-memory representation to a virtual buffer. + * + * This function calls the `append` method of a `ProtobufCBuffer` object to + * consume the bytes generated by the serialiser. + * + * \param message + * The message object to serialise. + * \param buffer + * The virtual buffer object. + * \return + * Number of bytes passed to the virtual buffer. + */ +PROTOBUF_C__API +size_t +protobuf_c_message_pack_to_buffer( + const ProtobufCMessage *message, + ProtobufCBuffer *buffer); + +/** + * Unpack a serialised message into an in-memory representation. + * + * \param descriptor + * The message descriptor. + * \param allocator + * `ProtobufCAllocator` to use for memory allocation. May be NULL to + * specify the default allocator. + * \param len + * Length in bytes of the serialised message. + * \param data + * Pointer to the serialised message. + * \return + * An unpacked message object. + * \retval NULL + * If an error occurred during unpacking. + */ +PROTOBUF_C__API +ProtobufCMessage * +protobuf_c_message_unpack( + const ProtobufCMessageDescriptor *descriptor, + ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data); + +/** + * Free an unpacked message object. + * + * This function should be used to deallocate the memory used by a call to + * protobuf_c_message_unpack(). + * + * \param message + * The message object to free. May be NULL. + * \param allocator + * `ProtobufCAllocator` to use for memory deallocation. May be NULL to + * specify the default allocator. + */ +PROTOBUF_C__API +void +protobuf_c_message_free_unpacked( + ProtobufCMessage *message, + ProtobufCAllocator *allocator); + +/** + * Check the validity of a message object. + * + * Makes sure all required fields (`PROTOBUF_C_LABEL_REQUIRED`) are present. + * Recursively checks nested messages. + * + * \retval TRUE + * Message is valid. + * \retval FALSE + * Message is invalid. + */ +PROTOBUF_C__API +protobuf_c_boolean +protobuf_c_message_check(const ProtobufCMessage *); + +/** Message initialiser. */ +#define PROTOBUF_C_MESSAGE_INIT(descriptor) { descriptor, 0, NULL } + +/** + * Initialise a message object from a message descriptor. + * + * \param descriptor + * Message descriptor. + * \param message + * Allocated block of memory of size `descriptor->sizeof_message`. + */ +PROTOBUF_C__API +void +protobuf_c_message_init( + const ProtobufCMessageDescriptor *descriptor, + void *message); + +/** + * Free a service. + * + * \param service + * The service object to free. + */ +PROTOBUF_C__API +void +protobuf_c_service_destroy(ProtobufCService *service); + +/** + * Look up a `ProtobufCMethodDescriptor` by name. + * + * \param desc + * Service descriptor. + * \param name + * Name of the method. + * + * \return + * A `ProtobufCMethodDescriptor` object. + * \retval NULL + * If not found or if the optimize_for = CODE_SIZE option was set. + */ +PROTOBUF_C__API +const ProtobufCMethodDescriptor * +protobuf_c_service_descriptor_get_method_by_name( + const ProtobufCServiceDescriptor *desc, + const char *name); + +/** + * Initialise a `ProtobufCBufferSimple` object. + */ +#define PROTOBUF_C_BUFFER_SIMPLE_INIT(array_of_bytes) \ +{ \ + { protobuf_c_buffer_simple_append }, \ + sizeof(array_of_bytes), \ + 0, \ + (array_of_bytes), \ + 0, \ + NULL \ +} + +/** + * Clear a `ProtobufCBufferSimple` object, freeing any allocated memory. + */ +#define PROTOBUF_C_BUFFER_SIMPLE_CLEAR(simp_buf) \ +do { \ + if ((simp_buf)->must_free_data) { \ + if ((simp_buf)->allocator != NULL) \ + (simp_buf)->allocator->free( \ + (simp_buf)->allocator, \ + (simp_buf)->data); \ + else \ + free((simp_buf)->data); \ + } \ +} while (0) + +/** + * The `append` method for `ProtobufCBufferSimple`. + * + * \param buffer + * The buffer object to append to. Must actually be a + * `ProtobufCBufferSimple` object. + * \param len + * Number of bytes in `data`. + * \param data + * Data to append. + */ +PROTOBUF_C__API +void +protobuf_c_buffer_simple_append( + ProtobufCBuffer *buffer, + size_t len, + const unsigned char *data); + +PROTOBUF_C__API +void +protobuf_c_service_generated_init( + ProtobufCService *service, + const ProtobufCServiceDescriptor *descriptor, + ProtobufCServiceDestroy destroy); + +PROTOBUF_C__API +void +protobuf_c_service_invoke_internal( + ProtobufCService *service, + unsigned method_index, + const ProtobufCMessage *input, + ProtobufCClosure closure, + void *closure_data); + +/**@}*/ + +PROTOBUF_C__END_DECLS + +#endif /* PROTOBUF_C_H */ diff --git a/tizen/src/ecs/genmsg/ecs.pb-c.c b/tizen/src/ecs/genmsg/ecs.pb-c.c index a91167e4c1..36bcc5c045 100644 --- a/tizen/src/ecs/genmsg/ecs.pb-c.c +++ b/tizen/src/ecs/genmsg/ecs.pb-c.c @@ -1,8 +1,9 @@ /* Generated by the protocol buffer compiler. DO NOT EDIT! */ +/* Generated from: ecs.proto */ /* Do not generate deprecated warnings for self */ -#ifndef PROTOBUF_C_NO_DEPRECATED -#define PROTOBUF_C_NO_DEPRECATED +#ifndef PROTOBUF_C__NO_DEPRECATED +#define PROTOBUF_C__NO_DEPRECATED #endif #include "ecs.pb-c.h" @@ -15,21 +16,21 @@ void ecs__check_version_req__init size_t ecs__check_version_req__get_packed_size (const ECS__CheckVersionReq *message) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__check_version_req__descriptor); + assert(message->base.descriptor == &ecs__check_version_req__descriptor); return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); } size_t ecs__check_version_req__pack (const ECS__CheckVersionReq *message, uint8_t *out) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__check_version_req__descriptor); + assert(message->base.descriptor == &ecs__check_version_req__descriptor); return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); } size_t ecs__check_version_req__pack_to_buffer (const ECS__CheckVersionReq *message, ProtobufCBuffer *buffer) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__check_version_req__descriptor); + assert(message->base.descriptor == &ecs__check_version_req__descriptor); return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); } ECS__CheckVersionReq * @@ -46,7 +47,7 @@ void ecs__check_version_req__free_unpacked (ECS__CheckVersionReq *message, ProtobufCAllocator *allocator) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__check_version_req__descriptor); + assert(message->base.descriptor == &ecs__check_version_req__descriptor); protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); } void ecs__check_version_ans__init @@ -58,21 +59,21 @@ void ecs__check_version_ans__init size_t ecs__check_version_ans__get_packed_size (const ECS__CheckVersionAns *message) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__check_version_ans__descriptor); + assert(message->base.descriptor == &ecs__check_version_ans__descriptor); return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); } size_t ecs__check_version_ans__pack (const ECS__CheckVersionAns *message, uint8_t *out) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__check_version_ans__descriptor); + assert(message->base.descriptor == &ecs__check_version_ans__descriptor); return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); } size_t ecs__check_version_ans__pack_to_buffer (const ECS__CheckVersionAns *message, ProtobufCBuffer *buffer) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__check_version_ans__descriptor); + assert(message->base.descriptor == &ecs__check_version_ans__descriptor); return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); } ECS__CheckVersionAns * @@ -89,7 +90,7 @@ void ecs__check_version_ans__free_unpacked (ECS__CheckVersionAns *message, ProtobufCAllocator *allocator) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__check_version_ans__descriptor); + assert(message->base.descriptor == &ecs__check_version_ans__descriptor); protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); } void ecs__keep_alive_req__init @@ -101,21 +102,21 @@ void ecs__keep_alive_req__init size_t ecs__keep_alive_req__get_packed_size (const ECS__KeepAliveReq *message) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__keep_alive_req__descriptor); + assert(message->base.descriptor == &ecs__keep_alive_req__descriptor); return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); } size_t ecs__keep_alive_req__pack (const ECS__KeepAliveReq *message, uint8_t *out) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__keep_alive_req__descriptor); + assert(message->base.descriptor == &ecs__keep_alive_req__descriptor); return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); } size_t ecs__keep_alive_req__pack_to_buffer (const ECS__KeepAliveReq *message, ProtobufCBuffer *buffer) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__keep_alive_req__descriptor); + assert(message->base.descriptor == &ecs__keep_alive_req__descriptor); return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); } ECS__KeepAliveReq * @@ -132,7 +133,7 @@ void ecs__keep_alive_req__free_unpacked (ECS__KeepAliveReq *message, ProtobufCAllocator *allocator) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__keep_alive_req__descriptor); + assert(message->base.descriptor == &ecs__keep_alive_req__descriptor); protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); } void ecs__keep_alive_ans__init @@ -144,21 +145,21 @@ void ecs__keep_alive_ans__init size_t ecs__keep_alive_ans__get_packed_size (const ECS__KeepAliveAns *message) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__keep_alive_ans__descriptor); + assert(message->base.descriptor == &ecs__keep_alive_ans__descriptor); return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); } size_t ecs__keep_alive_ans__pack (const ECS__KeepAliveAns *message, uint8_t *out) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__keep_alive_ans__descriptor); + assert(message->base.descriptor == &ecs__keep_alive_ans__descriptor); return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); } size_t ecs__keep_alive_ans__pack_to_buffer (const ECS__KeepAliveAns *message, ProtobufCBuffer *buffer) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__keep_alive_ans__descriptor); + assert(message->base.descriptor == &ecs__keep_alive_ans__descriptor); return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); } ECS__KeepAliveAns * @@ -175,7 +176,7 @@ void ecs__keep_alive_ans__free_unpacked (ECS__KeepAliveAns *message, ProtobufCAllocator *allocator) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__keep_alive_ans__descriptor); + assert(message->base.descriptor == &ecs__keep_alive_ans__descriptor); protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); } void ecs__injector_req__init @@ -187,21 +188,21 @@ void ecs__injector_req__init size_t ecs__injector_req__get_packed_size (const ECS__InjectorReq *message) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__injector_req__descriptor); + assert(message->base.descriptor == &ecs__injector_req__descriptor); return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); } size_t ecs__injector_req__pack (const ECS__InjectorReq *message, uint8_t *out) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__injector_req__descriptor); + assert(message->base.descriptor == &ecs__injector_req__descriptor); return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); } size_t ecs__injector_req__pack_to_buffer (const ECS__InjectorReq *message, ProtobufCBuffer *buffer) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__injector_req__descriptor); + assert(message->base.descriptor == &ecs__injector_req__descriptor); return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); } ECS__InjectorReq * @@ -218,7 +219,7 @@ void ecs__injector_req__free_unpacked (ECS__InjectorReq *message, ProtobufCAllocator *allocator) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__injector_req__descriptor); + assert(message->base.descriptor == &ecs__injector_req__descriptor); protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); } void ecs__injector_ans__init @@ -230,21 +231,21 @@ void ecs__injector_ans__init size_t ecs__injector_ans__get_packed_size (const ECS__InjectorAns *message) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__injector_ans__descriptor); + assert(message->base.descriptor == &ecs__injector_ans__descriptor); return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); } size_t ecs__injector_ans__pack (const ECS__InjectorAns *message, uint8_t *out) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__injector_ans__descriptor); + assert(message->base.descriptor == &ecs__injector_ans__descriptor); return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); } size_t ecs__injector_ans__pack_to_buffer (const ECS__InjectorAns *message, ProtobufCBuffer *buffer) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__injector_ans__descriptor); + assert(message->base.descriptor == &ecs__injector_ans__descriptor); return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); } ECS__InjectorAns * @@ -261,7 +262,7 @@ void ecs__injector_ans__free_unpacked (ECS__InjectorAns *message, ProtobufCAllocator *allocator) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__injector_ans__descriptor); + assert(message->base.descriptor == &ecs__injector_ans__descriptor); protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); } void ecs__injector_ntf__init @@ -273,21 +274,21 @@ void ecs__injector_ntf__init size_t ecs__injector_ntf__get_packed_size (const ECS__InjectorNtf *message) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__injector_ntf__descriptor); + assert(message->base.descriptor == &ecs__injector_ntf__descriptor); return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); } size_t ecs__injector_ntf__pack (const ECS__InjectorNtf *message, uint8_t *out) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__injector_ntf__descriptor); + assert(message->base.descriptor == &ecs__injector_ntf__descriptor); return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); } size_t ecs__injector_ntf__pack_to_buffer (const ECS__InjectorNtf *message, ProtobufCBuffer *buffer) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__injector_ntf__descriptor); + assert(message->base.descriptor == &ecs__injector_ntf__descriptor); return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); } ECS__InjectorNtf * @@ -304,7 +305,7 @@ void ecs__injector_ntf__free_unpacked (ECS__InjectorNtf *message, ProtobufCAllocator *allocator) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__injector_ntf__descriptor); + assert(message->base.descriptor == &ecs__injector_ntf__descriptor); protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); } void ecs__device_req__init @@ -316,21 +317,21 @@ void ecs__device_req__init size_t ecs__device_req__get_packed_size (const ECS__DeviceReq *message) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__device_req__descriptor); + assert(message->base.descriptor == &ecs__device_req__descriptor); return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); } size_t ecs__device_req__pack (const ECS__DeviceReq *message, uint8_t *out) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__device_req__descriptor); + assert(message->base.descriptor == &ecs__device_req__descriptor); return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); } size_t ecs__device_req__pack_to_buffer (const ECS__DeviceReq *message, ProtobufCBuffer *buffer) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__device_req__descriptor); + assert(message->base.descriptor == &ecs__device_req__descriptor); return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); } ECS__DeviceReq * @@ -347,7 +348,7 @@ void ecs__device_req__free_unpacked (ECS__DeviceReq *message, ProtobufCAllocator *allocator) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__device_req__descriptor); + assert(message->base.descriptor == &ecs__device_req__descriptor); protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); } void ecs__device_ans__init @@ -359,21 +360,21 @@ void ecs__device_ans__init size_t ecs__device_ans__get_packed_size (const ECS__DeviceAns *message) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__device_ans__descriptor); + assert(message->base.descriptor == &ecs__device_ans__descriptor); return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); } size_t ecs__device_ans__pack (const ECS__DeviceAns *message, uint8_t *out) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__device_ans__descriptor); + assert(message->base.descriptor == &ecs__device_ans__descriptor); return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); } size_t ecs__device_ans__pack_to_buffer (const ECS__DeviceAns *message, ProtobufCBuffer *buffer) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__device_ans__descriptor); + assert(message->base.descriptor == &ecs__device_ans__descriptor); return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); } ECS__DeviceAns * @@ -390,7 +391,7 @@ void ecs__device_ans__free_unpacked (ECS__DeviceAns *message, ProtobufCAllocator *allocator) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__device_ans__descriptor); + assert(message->base.descriptor == &ecs__device_ans__descriptor); protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); } void ecs__device_ntf__init @@ -402,21 +403,21 @@ void ecs__device_ntf__init size_t ecs__device_ntf__get_packed_size (const ECS__DeviceNtf *message) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__device_ntf__descriptor); + assert(message->base.descriptor == &ecs__device_ntf__descriptor); return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); } size_t ecs__device_ntf__pack (const ECS__DeviceNtf *message, uint8_t *out) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__device_ntf__descriptor); + assert(message->base.descriptor == &ecs__device_ntf__descriptor); return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); } size_t ecs__device_ntf__pack_to_buffer (const ECS__DeviceNtf *message, ProtobufCBuffer *buffer) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__device_ntf__descriptor); + assert(message->base.descriptor == &ecs__device_ntf__descriptor); return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); } ECS__DeviceNtf * @@ -433,7 +434,7 @@ void ecs__device_ntf__free_unpacked (ECS__DeviceNtf *message, ProtobufCAllocator *allocator) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__device_ntf__descriptor); + assert(message->base.descriptor == &ecs__device_ntf__descriptor); protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); } void ecs__monitor_req__init @@ -445,21 +446,21 @@ void ecs__monitor_req__init size_t ecs__monitor_req__get_packed_size (const ECS__MonitorReq *message) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__monitor_req__descriptor); + assert(message->base.descriptor == &ecs__monitor_req__descriptor); return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); } size_t ecs__monitor_req__pack (const ECS__MonitorReq *message, uint8_t *out) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__monitor_req__descriptor); + assert(message->base.descriptor == &ecs__monitor_req__descriptor); return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); } size_t ecs__monitor_req__pack_to_buffer (const ECS__MonitorReq *message, ProtobufCBuffer *buffer) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__monitor_req__descriptor); + assert(message->base.descriptor == &ecs__monitor_req__descriptor); return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); } ECS__MonitorReq * @@ -476,7 +477,7 @@ void ecs__monitor_req__free_unpacked (ECS__MonitorReq *message, ProtobufCAllocator *allocator) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__monitor_req__descriptor); + assert(message->base.descriptor == &ecs__monitor_req__descriptor); protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); } void ecs__monitor_ans__init @@ -488,21 +489,21 @@ void ecs__monitor_ans__init size_t ecs__monitor_ans__get_packed_size (const ECS__MonitorAns *message) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__monitor_ans__descriptor); + assert(message->base.descriptor == &ecs__monitor_ans__descriptor); return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); } size_t ecs__monitor_ans__pack (const ECS__MonitorAns *message, uint8_t *out) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__monitor_ans__descriptor); + assert(message->base.descriptor == &ecs__monitor_ans__descriptor); return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); } size_t ecs__monitor_ans__pack_to_buffer (const ECS__MonitorAns *message, ProtobufCBuffer *buffer) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__monitor_ans__descriptor); + assert(message->base.descriptor == &ecs__monitor_ans__descriptor); return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); } ECS__MonitorAns * @@ -519,7 +520,7 @@ void ecs__monitor_ans__free_unpacked (ECS__MonitorAns *message, ProtobufCAllocator *allocator) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__monitor_ans__descriptor); + assert(message->base.descriptor == &ecs__monitor_ans__descriptor); protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); } void ecs__monitor_ntf__init @@ -531,21 +532,21 @@ void ecs__monitor_ntf__init size_t ecs__monitor_ntf__get_packed_size (const ECS__MonitorNtf *message) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__monitor_ntf__descriptor); + assert(message->base.descriptor == &ecs__monitor_ntf__descriptor); return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); } size_t ecs__monitor_ntf__pack (const ECS__MonitorNtf *message, uint8_t *out) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__monitor_ntf__descriptor); + assert(message->base.descriptor == &ecs__monitor_ntf__descriptor); return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); } size_t ecs__monitor_ntf__pack_to_buffer (const ECS__MonitorNtf *message, ProtobufCBuffer *buffer) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__monitor_ntf__descriptor); + assert(message->base.descriptor == &ecs__monitor_ntf__descriptor); return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); } ECS__MonitorNtf * @@ -562,7 +563,7 @@ void ecs__monitor_ntf__free_unpacked (ECS__MonitorNtf *message, ProtobufCAllocator *allocator) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__monitor_ntf__descriptor); + assert(message->base.descriptor == &ecs__monitor_ntf__descriptor); protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); } void ecs__nfc_req__init @@ -574,21 +575,21 @@ void ecs__nfc_req__init size_t ecs__nfc_req__get_packed_size (const ECS__NfcReq *message) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__nfc_req__descriptor); + assert(message->base.descriptor == &ecs__nfc_req__descriptor); return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); } size_t ecs__nfc_req__pack (const ECS__NfcReq *message, uint8_t *out) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__nfc_req__descriptor); + assert(message->base.descriptor == &ecs__nfc_req__descriptor); return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); } size_t ecs__nfc_req__pack_to_buffer (const ECS__NfcReq *message, ProtobufCBuffer *buffer) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__nfc_req__descriptor); + assert(message->base.descriptor == &ecs__nfc_req__descriptor); return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); } ECS__NfcReq * @@ -605,7 +606,7 @@ void ecs__nfc_req__free_unpacked (ECS__NfcReq *message, ProtobufCAllocator *allocator) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__nfc_req__descriptor); + assert(message->base.descriptor == &ecs__nfc_req__descriptor); protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); } void ecs__nfc_ntf__init @@ -617,21 +618,21 @@ void ecs__nfc_ntf__init size_t ecs__nfc_ntf__get_packed_size (const ECS__NfcNtf *message) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__nfc_ntf__descriptor); + assert(message->base.descriptor == &ecs__nfc_ntf__descriptor); return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); } size_t ecs__nfc_ntf__pack (const ECS__NfcNtf *message, uint8_t *out) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__nfc_ntf__descriptor); + assert(message->base.descriptor == &ecs__nfc_ntf__descriptor); return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); } size_t ecs__nfc_ntf__pack_to_buffer (const ECS__NfcNtf *message, ProtobufCBuffer *buffer) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__nfc_ntf__descriptor); + assert(message->base.descriptor == &ecs__nfc_ntf__descriptor); return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); } ECS__NfcNtf * @@ -648,7 +649,7 @@ void ecs__nfc_ntf__free_unpacked (ECS__NfcNtf *message, ProtobufCAllocator *allocator) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__nfc_ntf__descriptor); + assert(message->base.descriptor == &ecs__nfc_ntf__descriptor); protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); } void ecs__event_cast_req__init @@ -660,21 +661,21 @@ void ecs__event_cast_req__init size_t ecs__event_cast_req__get_packed_size (const ECS__EventCastReq *message) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__event_cast_req__descriptor); + assert(message->base.descriptor == &ecs__event_cast_req__descriptor); return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); } size_t ecs__event_cast_req__pack (const ECS__EventCastReq *message, uint8_t *out) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__event_cast_req__descriptor); + assert(message->base.descriptor == &ecs__event_cast_req__descriptor); return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); } size_t ecs__event_cast_req__pack_to_buffer (const ECS__EventCastReq *message, ProtobufCBuffer *buffer) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__event_cast_req__descriptor); + assert(message->base.descriptor == &ecs__event_cast_req__descriptor); return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); } ECS__EventCastReq * @@ -691,7 +692,7 @@ void ecs__event_cast_req__free_unpacked (ECS__EventCastReq *message, ProtobufCAllocator *allocator) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__event_cast_req__descriptor); + assert(message->base.descriptor == &ecs__event_cast_req__descriptor); protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); } void ecs__event_cast_ans__init @@ -703,21 +704,21 @@ void ecs__event_cast_ans__init size_t ecs__event_cast_ans__get_packed_size (const ECS__EventCastAns *message) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__event_cast_ans__descriptor); + assert(message->base.descriptor == &ecs__event_cast_ans__descriptor); return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); } size_t ecs__event_cast_ans__pack (const ECS__EventCastAns *message, uint8_t *out) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__event_cast_ans__descriptor); + assert(message->base.descriptor == &ecs__event_cast_ans__descriptor); return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); } size_t ecs__event_cast_ans__pack_to_buffer (const ECS__EventCastAns *message, ProtobufCBuffer *buffer) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__event_cast_ans__descriptor); + assert(message->base.descriptor == &ecs__event_cast_ans__descriptor); return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); } ECS__EventCastAns * @@ -734,7 +735,7 @@ void ecs__event_cast_ans__free_unpacked (ECS__EventCastAns *message, ProtobufCAllocator *allocator) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__event_cast_ans__descriptor); + assert(message->base.descriptor == &ecs__event_cast_ans__descriptor); protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); } void ecs__event_cast_ntf__init @@ -746,21 +747,21 @@ void ecs__event_cast_ntf__init size_t ecs__event_cast_ntf__get_packed_size (const ECS__EventCastNtf *message) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__event_cast_ntf__descriptor); + assert(message->base.descriptor == &ecs__event_cast_ntf__descriptor); return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); } size_t ecs__event_cast_ntf__pack (const ECS__EventCastNtf *message, uint8_t *out) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__event_cast_ntf__descriptor); + assert(message->base.descriptor == &ecs__event_cast_ntf__descriptor); return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); } size_t ecs__event_cast_ntf__pack_to_buffer (const ECS__EventCastNtf *message, ProtobufCBuffer *buffer) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__event_cast_ntf__descriptor); + assert(message->base.descriptor == &ecs__event_cast_ntf__descriptor); return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); } ECS__EventCastNtf * @@ -777,7 +778,7 @@ void ecs__event_cast_ntf__free_unpacked (ECS__EventCastNtf *message, ProtobufCAllocator *allocator) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__event_cast_ntf__descriptor); + assert(message->base.descriptor == &ecs__event_cast_ntf__descriptor); protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); } void ecs__master__init @@ -789,21 +790,21 @@ void ecs__master__init size_t ecs__master__get_packed_size (const ECS__Master *message) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__master__descriptor); + assert(message->base.descriptor == &ecs__master__descriptor); return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); } size_t ecs__master__pack (const ECS__Master *message, uint8_t *out) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__master__descriptor); + assert(message->base.descriptor == &ecs__master__descriptor); return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); } size_t ecs__master__pack_to_buffer (const ECS__Master *message, ProtobufCBuffer *buffer) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__master__descriptor); + assert(message->base.descriptor == &ecs__master__descriptor); return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); } ECS__Master * @@ -820,7 +821,7 @@ void ecs__master__free_unpacked (ECS__Master *message, ProtobufCAllocator *allocator) { - PROTOBUF_C_ASSERT (message->base.descriptor == &ecs__master__descriptor); + assert(message->base.descriptor == &ecs__master__descriptor); protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); } static const ProtobufCFieldDescriptor ecs__check_version_req__field_descriptors[1] = @@ -831,10 +832,10 @@ static const ProtobufCFieldDescriptor ecs__check_version_req__field_descriptors[ PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_STRING, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__CheckVersionReq, version_str), + offsetof(ECS__CheckVersionReq, version_str), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, }; @@ -848,7 +849,7 @@ static const ProtobufCIntRange ecs__check_version_req__number_ranges[1 + 1] = }; const ProtobufCMessageDescriptor ecs__check_version_req__descriptor = { - PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC, + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, "ECS.CheckVersionReq", "CheckVersionReq", "ECS__CheckVersionReq", @@ -869,10 +870,10 @@ static const ProtobufCFieldDescriptor ecs__check_version_ans__field_descriptors[ PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_INT32, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__CheckVersionAns, errcode), + offsetof(ECS__CheckVersionAns, errcode), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -881,10 +882,10 @@ static const ProtobufCFieldDescriptor ecs__check_version_ans__field_descriptors[ PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_STRING, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__CheckVersionAns, version_str), + offsetof(ECS__CheckVersionAns, version_str), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, }; @@ -899,7 +900,7 @@ static const ProtobufCIntRange ecs__check_version_ans__number_ranges[1 + 1] = }; const ProtobufCMessageDescriptor ecs__check_version_ans__descriptor = { - PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC, + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, "ECS.CheckVersionAns", "CheckVersionAns", "ECS__CheckVersionAns", @@ -920,10 +921,10 @@ static const ProtobufCFieldDescriptor ecs__keep_alive_req__field_descriptors[1] PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_STRING, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__KeepAliveReq, time_str), + offsetof(ECS__KeepAliveReq, time_str), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, }; @@ -937,7 +938,7 @@ static const ProtobufCIntRange ecs__keep_alive_req__number_ranges[1 + 1] = }; const ProtobufCMessageDescriptor ecs__keep_alive_req__descriptor = { - PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC, + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, "ECS.KeepAliveReq", "KeepAliveReq", "ECS__KeepAliveReq", @@ -958,10 +959,10 @@ static const ProtobufCFieldDescriptor ecs__keep_alive_ans__field_descriptors[1] PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_STRING, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__KeepAliveAns, time_str), + offsetof(ECS__KeepAliveAns, time_str), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, }; @@ -975,7 +976,7 @@ static const ProtobufCIntRange ecs__keep_alive_ans__number_ranges[1 + 1] = }; const ProtobufCMessageDescriptor ecs__keep_alive_ans__descriptor = { - PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC, + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, "ECS.KeepAliveAns", "KeepAliveAns", "ECS__KeepAliveAns", @@ -996,10 +997,10 @@ static const ProtobufCFieldDescriptor ecs__injector_req__field_descriptors[5] = PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_STRING, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__InjectorReq, category), + offsetof(ECS__InjectorReq, category), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1008,10 +1009,10 @@ static const ProtobufCFieldDescriptor ecs__injector_req__field_descriptors[5] = PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_INT32, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__InjectorReq, length), + offsetof(ECS__InjectorReq, length), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1020,10 +1021,10 @@ static const ProtobufCFieldDescriptor ecs__injector_req__field_descriptors[5] = PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_INT32, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__InjectorReq, group), + offsetof(ECS__InjectorReq, group), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1032,10 +1033,10 @@ static const ProtobufCFieldDescriptor ecs__injector_req__field_descriptors[5] = PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_INT32, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__InjectorReq, action), + offsetof(ECS__InjectorReq, action), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1043,11 +1044,11 @@ static const ProtobufCFieldDescriptor ecs__injector_req__field_descriptors[5] = 5, PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_BYTES, - PROTOBUF_C_OFFSETOF(ECS__InjectorReq, has_data), - PROTOBUF_C_OFFSETOF(ECS__InjectorReq, data), + offsetof(ECS__InjectorReq, has_data), + offsetof(ECS__InjectorReq, data), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, }; @@ -1065,7 +1066,7 @@ static const ProtobufCIntRange ecs__injector_req__number_ranges[1 + 1] = }; const ProtobufCMessageDescriptor ecs__injector_req__descriptor = { - PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC, + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, "ECS.InjectorReq", "InjectorReq", "ECS__InjectorReq", @@ -1086,10 +1087,10 @@ static const ProtobufCFieldDescriptor ecs__injector_ans__field_descriptors[3] = PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_INT32, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__InjectorAns, errcode), + offsetof(ECS__InjectorAns, errcode), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1098,10 +1099,10 @@ static const ProtobufCFieldDescriptor ecs__injector_ans__field_descriptors[3] = PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_STRING, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__InjectorAns, errstr), + offsetof(ECS__InjectorAns, errstr), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1110,10 +1111,10 @@ static const ProtobufCFieldDescriptor ecs__injector_ans__field_descriptors[3] = PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_STRING, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__InjectorAns, category), + offsetof(ECS__InjectorAns, category), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, }; @@ -1129,7 +1130,7 @@ static const ProtobufCIntRange ecs__injector_ans__number_ranges[1 + 1] = }; const ProtobufCMessageDescriptor ecs__injector_ans__descriptor = { - PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC, + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, "ECS.InjectorAns", "InjectorAns", "ECS__InjectorAns", @@ -1150,10 +1151,10 @@ static const ProtobufCFieldDescriptor ecs__injector_ntf__field_descriptors[5] = PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_STRING, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__InjectorNtf, category), + offsetof(ECS__InjectorNtf, category), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1162,10 +1163,10 @@ static const ProtobufCFieldDescriptor ecs__injector_ntf__field_descriptors[5] = PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_INT32, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__InjectorNtf, length), + offsetof(ECS__InjectorNtf, length), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1174,10 +1175,10 @@ static const ProtobufCFieldDescriptor ecs__injector_ntf__field_descriptors[5] = PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_INT32, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__InjectorNtf, group), + offsetof(ECS__InjectorNtf, group), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1186,10 +1187,10 @@ static const ProtobufCFieldDescriptor ecs__injector_ntf__field_descriptors[5] = PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_INT32, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__InjectorNtf, action), + offsetof(ECS__InjectorNtf, action), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1197,11 +1198,11 @@ static const ProtobufCFieldDescriptor ecs__injector_ntf__field_descriptors[5] = 5, PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_BYTES, - PROTOBUF_C_OFFSETOF(ECS__InjectorNtf, has_data), - PROTOBUF_C_OFFSETOF(ECS__InjectorNtf, data), + offsetof(ECS__InjectorNtf, has_data), + offsetof(ECS__InjectorNtf, data), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, }; @@ -1219,7 +1220,7 @@ static const ProtobufCIntRange ecs__injector_ntf__number_ranges[1 + 1] = }; const ProtobufCMessageDescriptor ecs__injector_ntf__descriptor = { - PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC, + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, "ECS.InjectorNtf", "InjectorNtf", "ECS__InjectorNtf", @@ -1240,10 +1241,10 @@ static const ProtobufCFieldDescriptor ecs__device_req__field_descriptors[5] = PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_STRING, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__DeviceReq, category), + offsetof(ECS__DeviceReq, category), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1252,10 +1253,10 @@ static const ProtobufCFieldDescriptor ecs__device_req__field_descriptors[5] = PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_INT32, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__DeviceReq, length), + offsetof(ECS__DeviceReq, length), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1264,10 +1265,10 @@ static const ProtobufCFieldDescriptor ecs__device_req__field_descriptors[5] = PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_INT32, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__DeviceReq, group), + offsetof(ECS__DeviceReq, group), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1276,10 +1277,10 @@ static const ProtobufCFieldDescriptor ecs__device_req__field_descriptors[5] = PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_INT32, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__DeviceReq, action), + offsetof(ECS__DeviceReq, action), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1287,11 +1288,11 @@ static const ProtobufCFieldDescriptor ecs__device_req__field_descriptors[5] = 5, PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_BYTES, - PROTOBUF_C_OFFSETOF(ECS__DeviceReq, has_data), - PROTOBUF_C_OFFSETOF(ECS__DeviceReq, data), + offsetof(ECS__DeviceReq, has_data), + offsetof(ECS__DeviceReq, data), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, }; @@ -1309,7 +1310,7 @@ static const ProtobufCIntRange ecs__device_req__number_ranges[1 + 1] = }; const ProtobufCMessageDescriptor ecs__device_req__descriptor = { - PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC, + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, "ECS.DeviceReq", "DeviceReq", "ECS__DeviceReq", @@ -1330,10 +1331,10 @@ static const ProtobufCFieldDescriptor ecs__device_ans__field_descriptors[7] = PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_INT32, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__DeviceAns, errcode), + offsetof(ECS__DeviceAns, errcode), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1342,10 +1343,10 @@ static const ProtobufCFieldDescriptor ecs__device_ans__field_descriptors[7] = PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_STRING, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__DeviceAns, errstr), + offsetof(ECS__DeviceAns, errstr), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1354,10 +1355,10 @@ static const ProtobufCFieldDescriptor ecs__device_ans__field_descriptors[7] = PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_STRING, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__DeviceAns, category), + offsetof(ECS__DeviceAns, category), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1366,10 +1367,10 @@ static const ProtobufCFieldDescriptor ecs__device_ans__field_descriptors[7] = PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_INT32, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__DeviceAns, length), + offsetof(ECS__DeviceAns, length), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1378,10 +1379,10 @@ static const ProtobufCFieldDescriptor ecs__device_ans__field_descriptors[7] = PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_INT32, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__DeviceAns, group), + offsetof(ECS__DeviceAns, group), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1390,10 +1391,10 @@ static const ProtobufCFieldDescriptor ecs__device_ans__field_descriptors[7] = PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_INT32, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__DeviceAns, action), + offsetof(ECS__DeviceAns, action), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1401,11 +1402,11 @@ static const ProtobufCFieldDescriptor ecs__device_ans__field_descriptors[7] = 7, PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_BYTES, - PROTOBUF_C_OFFSETOF(ECS__DeviceAns, has_data), - PROTOBUF_C_OFFSETOF(ECS__DeviceAns, data), + offsetof(ECS__DeviceAns, has_data), + offsetof(ECS__DeviceAns, data), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, }; @@ -1425,7 +1426,7 @@ static const ProtobufCIntRange ecs__device_ans__number_ranges[1 + 1] = }; const ProtobufCMessageDescriptor ecs__device_ans__descriptor = { - PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC, + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, "ECS.DeviceAns", "DeviceAns", "ECS__DeviceAns", @@ -1446,10 +1447,10 @@ static const ProtobufCFieldDescriptor ecs__device_ntf__field_descriptors[5] = PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_STRING, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__DeviceNtf, category), + offsetof(ECS__DeviceNtf, category), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1458,10 +1459,10 @@ static const ProtobufCFieldDescriptor ecs__device_ntf__field_descriptors[5] = PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_INT32, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__DeviceNtf, length), + offsetof(ECS__DeviceNtf, length), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1470,10 +1471,10 @@ static const ProtobufCFieldDescriptor ecs__device_ntf__field_descriptors[5] = PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_INT32, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__DeviceNtf, group), + offsetof(ECS__DeviceNtf, group), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1482,10 +1483,10 @@ static const ProtobufCFieldDescriptor ecs__device_ntf__field_descriptors[5] = PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_INT32, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__DeviceNtf, action), + offsetof(ECS__DeviceNtf, action), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1493,11 +1494,11 @@ static const ProtobufCFieldDescriptor ecs__device_ntf__field_descriptors[5] = 5, PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_BYTES, - PROTOBUF_C_OFFSETOF(ECS__DeviceNtf, has_data), - PROTOBUF_C_OFFSETOF(ECS__DeviceNtf, data), + offsetof(ECS__DeviceNtf, has_data), + offsetof(ECS__DeviceNtf, data), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, }; @@ -1515,7 +1516,7 @@ static const ProtobufCIntRange ecs__device_ntf__number_ranges[1 + 1] = }; const ProtobufCMessageDescriptor ecs__device_ntf__descriptor = { - PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC, + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, "ECS.DeviceNtf", "DeviceNtf", "ECS__DeviceNtf", @@ -1536,10 +1537,10 @@ static const ProtobufCFieldDescriptor ecs__monitor_req__field_descriptors[1] = PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_STRING, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__MonitorReq, command), + offsetof(ECS__MonitorReq, command), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, }; @@ -1553,7 +1554,7 @@ static const ProtobufCIntRange ecs__monitor_req__number_ranges[1 + 1] = }; const ProtobufCMessageDescriptor ecs__monitor_req__descriptor = { - PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC, + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, "ECS.MonitorReq", "MonitorReq", "ECS__MonitorReq", @@ -1574,10 +1575,10 @@ static const ProtobufCFieldDescriptor ecs__monitor_ans__field_descriptors[4] = PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_INT32, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__MonitorAns, errcode), + offsetof(ECS__MonitorAns, errcode), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1586,10 +1587,10 @@ static const ProtobufCFieldDescriptor ecs__monitor_ans__field_descriptors[4] = PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_STRING, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__MonitorAns, errmsg), + offsetof(ECS__MonitorAns, errmsg), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1598,10 +1599,10 @@ static const ProtobufCFieldDescriptor ecs__monitor_ans__field_descriptors[4] = PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_STRING, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__MonitorAns, command), + offsetof(ECS__MonitorAns, command), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1609,11 +1610,11 @@ static const ProtobufCFieldDescriptor ecs__monitor_ans__field_descriptors[4] = 4, PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_BYTES, - PROTOBUF_C_OFFSETOF(ECS__MonitorAns, has_data), - PROTOBUF_C_OFFSETOF(ECS__MonitorAns, data), + offsetof(ECS__MonitorAns, has_data), + offsetof(ECS__MonitorAns, data), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, }; @@ -1630,7 +1631,7 @@ static const ProtobufCIntRange ecs__monitor_ans__number_ranges[1 + 1] = }; const ProtobufCMessageDescriptor ecs__monitor_ans__descriptor = { - PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC, + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, "ECS.MonitorAns", "MonitorAns", "ECS__MonitorAns", @@ -1651,10 +1652,10 @@ static const ProtobufCFieldDescriptor ecs__monitor_ntf__field_descriptors[2] = PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_STRING, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__MonitorNtf, command), + offsetof(ECS__MonitorNtf, command), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1662,11 +1663,11 @@ static const ProtobufCFieldDescriptor ecs__monitor_ntf__field_descriptors[2] = 2, PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_BYTES, - PROTOBUF_C_OFFSETOF(ECS__MonitorNtf, has_data), - PROTOBUF_C_OFFSETOF(ECS__MonitorNtf, data), + offsetof(ECS__MonitorNtf, has_data), + offsetof(ECS__MonitorNtf, data), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, }; @@ -1681,7 +1682,7 @@ static const ProtobufCIntRange ecs__monitor_ntf__number_ranges[1 + 1] = }; const ProtobufCMessageDescriptor ecs__monitor_ntf__descriptor = { - PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC, + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, "ECS.MonitorNtf", "MonitorNtf", "ECS__MonitorNtf", @@ -1702,10 +1703,10 @@ static const ProtobufCFieldDescriptor ecs__nfc_req__field_descriptors[2] = PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_STRING, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__NfcReq, category), + offsetof(ECS__NfcReq, category), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1713,11 +1714,11 @@ static const ProtobufCFieldDescriptor ecs__nfc_req__field_descriptors[2] = 2, PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_BYTES, - PROTOBUF_C_OFFSETOF(ECS__NfcReq, has_data), - PROTOBUF_C_OFFSETOF(ECS__NfcReq, data), + offsetof(ECS__NfcReq, has_data), + offsetof(ECS__NfcReq, data), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, }; @@ -1732,7 +1733,7 @@ static const ProtobufCIntRange ecs__nfc_req__number_ranges[1 + 1] = }; const ProtobufCMessageDescriptor ecs__nfc_req__descriptor = { - PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC, + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, "ECS.NfcReq", "NfcReq", "ECS__NfcReq", @@ -1753,10 +1754,10 @@ static const ProtobufCFieldDescriptor ecs__nfc_ntf__field_descriptors[2] = PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_STRING, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__NfcNtf, category), + offsetof(ECS__NfcNtf, category), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1764,11 +1765,11 @@ static const ProtobufCFieldDescriptor ecs__nfc_ntf__field_descriptors[2] = 2, PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_BYTES, - PROTOBUF_C_OFFSETOF(ECS__NfcNtf, has_data), - PROTOBUF_C_OFFSETOF(ECS__NfcNtf, data), + offsetof(ECS__NfcNtf, has_data), + offsetof(ECS__NfcNtf, data), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, }; @@ -1783,7 +1784,7 @@ static const ProtobufCIntRange ecs__nfc_ntf__number_ranges[1 + 1] = }; const ProtobufCMessageDescriptor ecs__nfc_ntf__descriptor = { - PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC, + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, "ECS.NfcNtf", "NfcNtf", "ECS__NfcNtf", @@ -1804,10 +1805,10 @@ static const ProtobufCFieldDescriptor ecs__event_cast_req__field_descriptors[5] PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_STRING, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__EventCastReq, category), + offsetof(ECS__EventCastReq, category), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1816,10 +1817,10 @@ static const ProtobufCFieldDescriptor ecs__event_cast_req__field_descriptors[5] PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_INT32, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__EventCastReq, length), + offsetof(ECS__EventCastReq, length), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1828,10 +1829,10 @@ static const ProtobufCFieldDescriptor ecs__event_cast_req__field_descriptors[5] PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_INT32, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__EventCastReq, group), + offsetof(ECS__EventCastReq, group), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1840,10 +1841,10 @@ static const ProtobufCFieldDescriptor ecs__event_cast_req__field_descriptors[5] PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_INT32, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__EventCastReq, action), + offsetof(ECS__EventCastReq, action), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1851,11 +1852,11 @@ static const ProtobufCFieldDescriptor ecs__event_cast_req__field_descriptors[5] 5, PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_BYTES, - PROTOBUF_C_OFFSETOF(ECS__EventCastReq, has_data), - PROTOBUF_C_OFFSETOF(ECS__EventCastReq, data), + offsetof(ECS__EventCastReq, has_data), + offsetof(ECS__EventCastReq, data), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, }; @@ -1873,7 +1874,7 @@ static const ProtobufCIntRange ecs__event_cast_req__number_ranges[1 + 1] = }; const ProtobufCMessageDescriptor ecs__event_cast_req__descriptor = { - PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC, + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, "ECS.EventCastReq", "EventCastReq", "ECS__EventCastReq", @@ -1894,10 +1895,10 @@ static const ProtobufCFieldDescriptor ecs__event_cast_ans__field_descriptors[7] PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_INT32, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__EventCastAns, errcode), + offsetof(ECS__EventCastAns, errcode), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1906,10 +1907,10 @@ static const ProtobufCFieldDescriptor ecs__event_cast_ans__field_descriptors[7] PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_STRING, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__EventCastAns, errstr), + offsetof(ECS__EventCastAns, errstr), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1918,10 +1919,10 @@ static const ProtobufCFieldDescriptor ecs__event_cast_ans__field_descriptors[7] PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_STRING, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__EventCastAns, category), + offsetof(ECS__EventCastAns, category), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1930,10 +1931,10 @@ static const ProtobufCFieldDescriptor ecs__event_cast_ans__field_descriptors[7] PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_INT32, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__EventCastAns, length), + offsetof(ECS__EventCastAns, length), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1942,10 +1943,10 @@ static const ProtobufCFieldDescriptor ecs__event_cast_ans__field_descriptors[7] PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_INT32, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__EventCastAns, group), + offsetof(ECS__EventCastAns, group), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1954,10 +1955,10 @@ static const ProtobufCFieldDescriptor ecs__event_cast_ans__field_descriptors[7] PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_INT32, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__EventCastAns, action), + offsetof(ECS__EventCastAns, action), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1965,11 +1966,11 @@ static const ProtobufCFieldDescriptor ecs__event_cast_ans__field_descriptors[7] 7, PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_BYTES, - PROTOBUF_C_OFFSETOF(ECS__EventCastAns, has_data), - PROTOBUF_C_OFFSETOF(ECS__EventCastAns, data), + offsetof(ECS__EventCastAns, has_data), + offsetof(ECS__EventCastAns, data), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, }; @@ -1989,7 +1990,7 @@ static const ProtobufCIntRange ecs__event_cast_ans__number_ranges[1 + 1] = }; const ProtobufCMessageDescriptor ecs__event_cast_ans__descriptor = { - PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC, + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, "ECS.EventCastAns", "EventCastAns", "ECS__EventCastAns", @@ -2010,10 +2011,10 @@ static const ProtobufCFieldDescriptor ecs__event_cast_ntf__field_descriptors[5] PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_STRING, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__EventCastNtf, category), + offsetof(ECS__EventCastNtf, category), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -2022,10 +2023,10 @@ static const ProtobufCFieldDescriptor ecs__event_cast_ntf__field_descriptors[5] PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_INT32, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__EventCastNtf, length), + offsetof(ECS__EventCastNtf, length), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -2034,10 +2035,10 @@ static const ProtobufCFieldDescriptor ecs__event_cast_ntf__field_descriptors[5] PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_INT32, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__EventCastNtf, group), + offsetof(ECS__EventCastNtf, group), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -2046,10 +2047,10 @@ static const ProtobufCFieldDescriptor ecs__event_cast_ntf__field_descriptors[5] PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_INT32, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__EventCastNtf, action), + offsetof(ECS__EventCastNtf, action), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -2057,11 +2058,11 @@ static const ProtobufCFieldDescriptor ecs__event_cast_ntf__field_descriptors[5] 5, PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_BYTES, - PROTOBUF_C_OFFSETOF(ECS__EventCastNtf, has_data), - PROTOBUF_C_OFFSETOF(ECS__EventCastNtf, data), + offsetof(ECS__EventCastNtf, has_data), + offsetof(ECS__EventCastNtf, data), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, }; @@ -2079,7 +2080,7 @@ static const ProtobufCIntRange ecs__event_cast_ntf__number_ranges[1 + 1] = }; const ProtobufCMessageDescriptor ecs__event_cast_ntf__descriptor = { - PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC, + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, "ECS.EventCastNtf", "EventCastNtf", "ECS__EventCastNtf", @@ -2100,10 +2101,10 @@ static const ProtobufCFieldDescriptor ecs__master__field_descriptors[19] = PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_ENUM, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__Master, type), + offsetof(ECS__Master, type), &ecs__master__type__descriptor, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -2112,10 +2113,10 @@ static const ProtobufCFieldDescriptor ecs__master__field_descriptors[19] = PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__Master, checkversion_req), + offsetof(ECS__Master, checkversion_req), &ecs__check_version_req__descriptor, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -2124,10 +2125,10 @@ static const ProtobufCFieldDescriptor ecs__master__field_descriptors[19] = PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__Master, checkversion_ans), + offsetof(ECS__Master, checkversion_ans), &ecs__check_version_ans__descriptor, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -2136,10 +2137,10 @@ static const ProtobufCFieldDescriptor ecs__master__field_descriptors[19] = PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__Master, keepalive_req), + offsetof(ECS__Master, keepalive_req), &ecs__keep_alive_req__descriptor, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -2148,10 +2149,10 @@ static const ProtobufCFieldDescriptor ecs__master__field_descriptors[19] = PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__Master, keepalive_ans), + offsetof(ECS__Master, keepalive_ans), &ecs__keep_alive_ans__descriptor, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -2160,10 +2161,10 @@ static const ProtobufCFieldDescriptor ecs__master__field_descriptors[19] = PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__Master, injector_req), + offsetof(ECS__Master, injector_req), &ecs__injector_req__descriptor, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -2172,10 +2173,10 @@ static const ProtobufCFieldDescriptor ecs__master__field_descriptors[19] = PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__Master, injector_ans), + offsetof(ECS__Master, injector_ans), &ecs__injector_ans__descriptor, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -2184,10 +2185,10 @@ static const ProtobufCFieldDescriptor ecs__master__field_descriptors[19] = PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__Master, injector_ntf), + offsetof(ECS__Master, injector_ntf), &ecs__injector_ntf__descriptor, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -2196,10 +2197,10 @@ static const ProtobufCFieldDescriptor ecs__master__field_descriptors[19] = PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__Master, device_req), + offsetof(ECS__Master, device_req), &ecs__device_req__descriptor, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -2208,10 +2209,10 @@ static const ProtobufCFieldDescriptor ecs__master__field_descriptors[19] = PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__Master, device_ans), + offsetof(ECS__Master, device_ans), &ecs__device_ans__descriptor, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -2220,10 +2221,10 @@ static const ProtobufCFieldDescriptor ecs__master__field_descriptors[19] = PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__Master, device_ntf), + offsetof(ECS__Master, device_ntf), &ecs__device_ntf__descriptor, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -2232,10 +2233,10 @@ static const ProtobufCFieldDescriptor ecs__master__field_descriptors[19] = PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__Master, monitor_req), + offsetof(ECS__Master, monitor_req), &ecs__monitor_req__descriptor, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -2244,10 +2245,10 @@ static const ProtobufCFieldDescriptor ecs__master__field_descriptors[19] = PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__Master, monitor_ans), + offsetof(ECS__Master, monitor_ans), &ecs__monitor_ans__descriptor, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -2256,10 +2257,10 @@ static const ProtobufCFieldDescriptor ecs__master__field_descriptors[19] = PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__Master, monitor_ntf), + offsetof(ECS__Master, monitor_ntf), &ecs__monitor_ntf__descriptor, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -2268,10 +2269,10 @@ static const ProtobufCFieldDescriptor ecs__master__field_descriptors[19] = PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__Master, nfc_req), + offsetof(ECS__Master, nfc_req), &ecs__nfc_req__descriptor, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -2280,10 +2281,10 @@ static const ProtobufCFieldDescriptor ecs__master__field_descriptors[19] = PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__Master, nfc_ntf), + offsetof(ECS__Master, nfc_ntf), &ecs__nfc_ntf__descriptor, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -2292,10 +2293,10 @@ static const ProtobufCFieldDescriptor ecs__master__field_descriptors[19] = PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__Master, eventcast_req), + offsetof(ECS__Master, eventcast_req), &ecs__event_cast_req__descriptor, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -2304,10 +2305,10 @@ static const ProtobufCFieldDescriptor ecs__master__field_descriptors[19] = PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__Master, eventcast_ans), + offsetof(ECS__Master, eventcast_ans), &ecs__event_cast_ans__descriptor, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -2316,10 +2317,10 @@ static const ProtobufCFieldDescriptor ecs__master__field_descriptors[19] = PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(ECS__Master, eventcast_ntf), + offsetof(ECS__Master, eventcast_ntf), &ecs__event_cast_ntf__descriptor, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, }; @@ -2352,7 +2353,7 @@ static const ProtobufCIntRange ecs__master__number_ranges[2 + 1] = }; const ProtobufCMessageDescriptor ecs__master__descriptor = { - PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC, + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, "ECS.Master", "Master", "ECS__Master", diff --git a/tizen/src/ecs/genmsg/ecs.pb-c.h b/tizen/src/ecs/genmsg/ecs.pb-c.h index 2dfba7485a..c242470cb7 100644 --- a/tizen/src/ecs/genmsg/ecs.pb-c.h +++ b/tizen/src/ecs/genmsg/ecs.pb-c.h @@ -1,11 +1,18 @@ /* Generated by the protocol buffer compiler. DO NOT EDIT! */ +/* Generated from: ecs.proto */ #ifndef PROTOBUF_C_ecs_2eproto__INCLUDED #define PROTOBUF_C_ecs_2eproto__INCLUDED -#include "../../distrib/protobuf/protobuf-c.h" +#include <protobuf-c/protobuf-c.h> -PROTOBUF_C_BEGIN_DECLS +PROTOBUF_C__BEGIN_DECLS + +#if PROTOBUF_C_VERSION_NUMBER < 1000000 +# error This file was generated by a newer version of protoc-c which is incompatible with your libprotobuf-c headers. Please update your headers. +#elif 1002001 < PROTOBUF_C_MIN_COMPILER_VERSION +# error This file was generated by an older version of protoc-c which is incompatible with your libprotobuf-c headers. Please regenerate this file with a newer version of protoc-c. +#endif #include "ecs_ids.pb-c.h" @@ -289,6 +296,9 @@ struct _ECS__Master ECS__MonitorReq *monitor_req; ECS__MonitorAns *monitor_ans; ECS__MonitorNtf *monitor_ntf; + /* + * Extensions 101 to 150; + */ ECS__NfcReq *nfc_req; ECS__NfcNtf *nfc_ntf; ECS__EventCastReq *eventcast_req; @@ -746,7 +756,7 @@ extern const ProtobufCMessageDescriptor ecs__event_cast_ans__descriptor; extern const ProtobufCMessageDescriptor ecs__event_cast_ntf__descriptor; extern const ProtobufCMessageDescriptor ecs__master__descriptor; -PROTOBUF_C_END_DECLS +PROTOBUF_C__END_DECLS -#endif /* PROTOBUF_ecs_2eproto__INCLUDED */ +#endif /* PROTOBUF_C_ecs_2eproto__INCLUDED */ diff --git a/tizen/src/ecs/genmsg/ecs_ids.pb-c.c b/tizen/src/ecs/genmsg/ecs_ids.pb-c.c index 97977afb23..61f1dd799c 100644 --- a/tizen/src/ecs/genmsg/ecs_ids.pb-c.c +++ b/tizen/src/ecs/genmsg/ecs_ids.pb-c.c @@ -1,12 +1,13 @@ /* Generated by the protocol buffer compiler. DO NOT EDIT! */ +/* Generated from: ecs_ids.proto */ /* Do not generate deprecated warnings for self */ -#ifndef PROTOBUF_C_NO_DEPRECATED -#define PROTOBUF_C_NO_DEPRECATED +#ifndef PROTOBUF_C__NO_DEPRECATED +#define PROTOBUF_C__NO_DEPRECATED #endif #include "ecs_ids.pb-c.h" -const ProtobufCEnumValue ecs__master__type__enum_values_by_number[18] = +static const ProtobufCEnumValue ecs__master__type__enum_values_by_number[18] = { { "CHECKVERSION_REQ", "ECS__MASTER__TYPE__CHECKVERSION_REQ", 2 }, { "CHECKVERSION_ANS", "ECS__MASTER__TYPE__CHECKVERSION_ANS", 3 }, @@ -30,7 +31,7 @@ const ProtobufCEnumValue ecs__master__type__enum_values_by_number[18] = static const ProtobufCIntRange ecs__master__type__value_ranges[] = { {2, 0},{101, 13},{0, 18} }; -const ProtobufCEnumValueIndex ecs__master__type__enum_values_by_name[18] = +static const ProtobufCEnumValueIndex ecs__master__type__enum_values_by_name[18] = { { "CHECKVERSION_ANS", 1 }, { "CHECKVERSION_REQ", 0 }, @@ -53,7 +54,7 @@ const ProtobufCEnumValueIndex ecs__master__type__enum_values_by_name[18] = }; const ProtobufCEnumDescriptor ecs__master__type__descriptor = { - PROTOBUF_C_ENUM_DESCRIPTOR_MAGIC, + PROTOBUF_C__ENUM_DESCRIPTOR_MAGIC, "ECS.Master_Type", "Master_Type", "ECS__MasterType", diff --git a/tizen/src/ecs/genmsg/ecs_ids.pb-c.h b/tizen/src/ecs/genmsg/ecs_ids.pb-c.h index d81fc0a67f..292791fbab 100644 --- a/tizen/src/ecs/genmsg/ecs_ids.pb-c.h +++ b/tizen/src/ecs/genmsg/ecs_ids.pb-c.h @@ -1,11 +1,18 @@ /* Generated by the protocol buffer compiler. DO NOT EDIT! */ +/* Generated from: ecs_ids.proto */ #ifndef PROTOBUF_C_ecs_5fids_2eproto__INCLUDED #define PROTOBUF_C_ecs_5fids_2eproto__INCLUDED -#include "../../distrib/protobuf/protobuf-c.h" +#include <protobuf-c/protobuf-c.h> -PROTOBUF_C_BEGIN_DECLS +PROTOBUF_C__BEGIN_DECLS + +#if PROTOBUF_C_VERSION_NUMBER < 1000000 +# error This file was generated by a newer version of protoc-c which is incompatible with your libprotobuf-c headers. Please update your headers. +#elif 1002001 < PROTOBUF_C_MIN_COMPILER_VERSION +# error This file was generated by an older version of protoc-c which is incompatible with your libprotobuf-c headers. Please regenerate this file with a newer version of protoc-c. +#endif @@ -26,11 +33,15 @@ typedef enum _ECS__MasterType { ECS__MASTER__TYPE__MONITOR_REQ = 12, ECS__MASTER__TYPE__MONITOR_ANS = 13, ECS__MASTER__TYPE__MONITOR_NTF = 14, + /* + * extension from 101 to 150 + */ ECS__MASTER__TYPE__NFC_REQ = 101, ECS__MASTER__TYPE__NFC_NTF = 102, ECS__MASTER__TYPE__EVENTCAST_REQ = 103, ECS__MASTER__TYPE__EVENTCAST_ANS = 104, ECS__MASTER__TYPE__EVENTCAST_NTF = 105 + PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(ECS__MASTER__TYPE) } ECS__MasterType; /* --- messages --- */ @@ -45,7 +56,7 @@ typedef enum _ECS__MasterType { extern const ProtobufCEnumDescriptor ecs__master__type__descriptor; -PROTOBUF_C_END_DECLS +PROTOBUF_C__END_DECLS -#endif /* PROTOBUF_ecs_5fids_2eproto__INCLUDED */ +#endif /* PROTOBUF_C_ecs_5fids_2eproto__INCLUDED */ diff --git a/tizen/src/eventcast/genmsg/eventcast.pb-c.c b/tizen/src/eventcast/genmsg/eventcast.pb-c.c index bfc55e8503..1a8d8cb6d8 100644 --- a/tizen/src/eventcast/genmsg/eventcast.pb-c.c +++ b/tizen/src/eventcast/genmsg/eventcast.pb-c.c @@ -1,8 +1,9 @@ /* Generated by the protocol buffer compiler. DO NOT EDIT! */ +/* Generated from: eventcast.proto */ /* Do not generate deprecated warnings for self */ -#ifndef PROTOBUF_C_NO_DEPRECATED -#define PROTOBUF_C_NO_DEPRECATED +#ifndef PROTOBUF_C__NO_DEPRECATED +#define PROTOBUF_C__NO_DEPRECATED #endif #include "eventcast.pb-c.h" @@ -15,21 +16,21 @@ void eventcast__hand_shake_req__init size_t eventcast__hand_shake_req__get_packed_size (const Eventcast__HandShakeReq *message) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__hand_shake_req__descriptor); + assert(message->base.descriptor == &eventcast__hand_shake_req__descriptor); return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); } size_t eventcast__hand_shake_req__pack (const Eventcast__HandShakeReq *message, uint8_t *out) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__hand_shake_req__descriptor); + assert(message->base.descriptor == &eventcast__hand_shake_req__descriptor); return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); } size_t eventcast__hand_shake_req__pack_to_buffer (const Eventcast__HandShakeReq *message, ProtobufCBuffer *buffer) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__hand_shake_req__descriptor); + assert(message->base.descriptor == &eventcast__hand_shake_req__descriptor); return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); } Eventcast__HandShakeReq * @@ -46,7 +47,7 @@ void eventcast__hand_shake_req__free_unpacked (Eventcast__HandShakeReq *message, ProtobufCAllocator *allocator) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__hand_shake_req__descriptor); + assert(message->base.descriptor == &eventcast__hand_shake_req__descriptor); protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); } void eventcast__hand_shake_ans__init @@ -58,21 +59,21 @@ void eventcast__hand_shake_ans__init size_t eventcast__hand_shake_ans__get_packed_size (const Eventcast__HandShakeAns *message) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__hand_shake_ans__descriptor); + assert(message->base.descriptor == &eventcast__hand_shake_ans__descriptor); return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); } size_t eventcast__hand_shake_ans__pack (const Eventcast__HandShakeAns *message, uint8_t *out) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__hand_shake_ans__descriptor); + assert(message->base.descriptor == &eventcast__hand_shake_ans__descriptor); return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); } size_t eventcast__hand_shake_ans__pack_to_buffer (const Eventcast__HandShakeAns *message, ProtobufCBuffer *buffer) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__hand_shake_ans__descriptor); + assert(message->base.descriptor == &eventcast__hand_shake_ans__descriptor); return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); } Eventcast__HandShakeAns * @@ -89,7 +90,7 @@ void eventcast__hand_shake_ans__free_unpacked (Eventcast__HandShakeAns *message, ProtobufCAllocator *allocator) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__hand_shake_ans__descriptor); + assert(message->base.descriptor == &eventcast__hand_shake_ans__descriptor); protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); } void eventcast__emulator_state__init @@ -101,21 +102,21 @@ void eventcast__emulator_state__init size_t eventcast__emulator_state__get_packed_size (const Eventcast__EmulatorState *message) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__emulator_state__descriptor); + assert(message->base.descriptor == &eventcast__emulator_state__descriptor); return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); } size_t eventcast__emulator_state__pack (const Eventcast__EmulatorState *message, uint8_t *out) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__emulator_state__descriptor); + assert(message->base.descriptor == &eventcast__emulator_state__descriptor); return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); } size_t eventcast__emulator_state__pack_to_buffer (const Eventcast__EmulatorState *message, ProtobufCBuffer *buffer) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__emulator_state__descriptor); + assert(message->base.descriptor == &eventcast__emulator_state__descriptor); return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); } Eventcast__EmulatorState * @@ -132,7 +133,7 @@ void eventcast__emulator_state__free_unpacked (Eventcast__EmulatorState *message, ProtobufCAllocator *allocator) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__emulator_state__descriptor); + assert(message->base.descriptor == &eventcast__emulator_state__descriptor); protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); } void eventcast__app_state__init @@ -144,21 +145,21 @@ void eventcast__app_state__init size_t eventcast__app_state__get_packed_size (const Eventcast__AppState *message) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__app_state__descriptor); + assert(message->base.descriptor == &eventcast__app_state__descriptor); return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); } size_t eventcast__app_state__pack (const Eventcast__AppState *message, uint8_t *out) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__app_state__descriptor); + assert(message->base.descriptor == &eventcast__app_state__descriptor); return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); } size_t eventcast__app_state__pack_to_buffer (const Eventcast__AppState *message, ProtobufCBuffer *buffer) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__app_state__descriptor); + assert(message->base.descriptor == &eventcast__app_state__descriptor); return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); } Eventcast__AppState * @@ -175,7 +176,7 @@ void eventcast__app_state__free_unpacked (Eventcast__AppState *message, ProtobufCAllocator *allocator) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__app_state__descriptor); + assert(message->base.descriptor == &eventcast__app_state__descriptor); protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); } void eventcast__start_req__init @@ -187,21 +188,21 @@ void eventcast__start_req__init size_t eventcast__start_req__get_packed_size (const Eventcast__StartReq *message) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__start_req__descriptor); + assert(message->base.descriptor == &eventcast__start_req__descriptor); return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); } size_t eventcast__start_req__pack (const Eventcast__StartReq *message, uint8_t *out) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__start_req__descriptor); + assert(message->base.descriptor == &eventcast__start_req__descriptor); return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); } size_t eventcast__start_req__pack_to_buffer (const Eventcast__StartReq *message, ProtobufCBuffer *buffer) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__start_req__descriptor); + assert(message->base.descriptor == &eventcast__start_req__descriptor); return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); } Eventcast__StartReq * @@ -218,7 +219,7 @@ void eventcast__start_req__free_unpacked (Eventcast__StartReq *message, ProtobufCAllocator *allocator) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__start_req__descriptor); + assert(message->base.descriptor == &eventcast__start_req__descriptor); protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); } void eventcast__start_ans__init @@ -230,21 +231,21 @@ void eventcast__start_ans__init size_t eventcast__start_ans__get_packed_size (const Eventcast__StartAns *message) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__start_ans__descriptor); + assert(message->base.descriptor == &eventcast__start_ans__descriptor); return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); } size_t eventcast__start_ans__pack (const Eventcast__StartAns *message, uint8_t *out) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__start_ans__descriptor); + assert(message->base.descriptor == &eventcast__start_ans__descriptor); return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); } size_t eventcast__start_ans__pack_to_buffer (const Eventcast__StartAns *message, ProtobufCBuffer *buffer) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__start_ans__descriptor); + assert(message->base.descriptor == &eventcast__start_ans__descriptor); return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); } Eventcast__StartAns * @@ -261,7 +262,7 @@ void eventcast__start_ans__free_unpacked (Eventcast__StartAns *message, ProtobufCAllocator *allocator) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__start_ans__descriptor); + assert(message->base.descriptor == &eventcast__start_ans__descriptor); protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); } void eventcast__set_event_status__init @@ -273,21 +274,21 @@ void eventcast__set_event_status__init size_t eventcast__set_event_status__get_packed_size (const Eventcast__SetEventStatus *message) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__set_event_status__descriptor); + assert(message->base.descriptor == &eventcast__set_event_status__descriptor); return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); } size_t eventcast__set_event_status__pack (const Eventcast__SetEventStatus *message, uint8_t *out) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__set_event_status__descriptor); + assert(message->base.descriptor == &eventcast__set_event_status__descriptor); return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); } size_t eventcast__set_event_status__pack_to_buffer (const Eventcast__SetEventStatus *message, ProtobufCBuffer *buffer) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__set_event_status__descriptor); + assert(message->base.descriptor == &eventcast__set_event_status__descriptor); return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); } Eventcast__SetEventStatus * @@ -304,7 +305,7 @@ void eventcast__set_event_status__free_unpacked (Eventcast__SetEventStatus *message, ProtobufCAllocator *allocator) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__set_event_status__descriptor); + assert(message->base.descriptor == &eventcast__set_event_status__descriptor); protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); } void eventcast__event_msg__init @@ -316,21 +317,21 @@ void eventcast__event_msg__init size_t eventcast__event_msg__get_packed_size (const Eventcast__EventMsg *message) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__event_msg__descriptor); + assert(message->base.descriptor == &eventcast__event_msg__descriptor); return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); } size_t eventcast__event_msg__pack (const Eventcast__EventMsg *message, uint8_t *out) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__event_msg__descriptor); + assert(message->base.descriptor == &eventcast__event_msg__descriptor); return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); } size_t eventcast__event_msg__pack_to_buffer (const Eventcast__EventMsg *message, ProtobufCBuffer *buffer) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__event_msg__descriptor); + assert(message->base.descriptor == &eventcast__event_msg__descriptor); return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); } Eventcast__EventMsg * @@ -347,7 +348,7 @@ void eventcast__event_msg__free_unpacked (Eventcast__EventMsg *message, ProtobufCAllocator *allocator) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__event_msg__descriptor); + assert(message->base.descriptor == &eventcast__event_msg__descriptor); protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); } void eventcast__event_terminate__init @@ -359,21 +360,21 @@ void eventcast__event_terminate__init size_t eventcast__event_terminate__get_packed_size (const Eventcast__EventTerminate *message) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__event_terminate__descriptor); + assert(message->base.descriptor == &eventcast__event_terminate__descriptor); return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); } size_t eventcast__event_terminate__pack (const Eventcast__EventTerminate *message, uint8_t *out) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__event_terminate__descriptor); + assert(message->base.descriptor == &eventcast__event_terminate__descriptor); return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); } size_t eventcast__event_terminate__pack_to_buffer (const Eventcast__EventTerminate *message, ProtobufCBuffer *buffer) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__event_terminate__descriptor); + assert(message->base.descriptor == &eventcast__event_terminate__descriptor); return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); } Eventcast__EventTerminate * @@ -390,7 +391,7 @@ void eventcast__event_terminate__free_unpacked (Eventcast__EventTerminate *message, ProtobufCAllocator *allocator) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__event_terminate__descriptor); + assert(message->base.descriptor == &eventcast__event_terminate__descriptor); protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); } void eventcast__set_sensor_status__init @@ -402,21 +403,21 @@ void eventcast__set_sensor_status__init size_t eventcast__set_sensor_status__get_packed_size (const Eventcast__SetSensorStatus *message) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__set_sensor_status__descriptor); + assert(message->base.descriptor == &eventcast__set_sensor_status__descriptor); return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); } size_t eventcast__set_sensor_status__pack (const Eventcast__SetSensorStatus *message, uint8_t *out) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__set_sensor_status__descriptor); + assert(message->base.descriptor == &eventcast__set_sensor_status__descriptor); return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); } size_t eventcast__set_sensor_status__pack_to_buffer (const Eventcast__SetSensorStatus *message, ProtobufCBuffer *buffer) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__set_sensor_status__descriptor); + assert(message->base.descriptor == &eventcast__set_sensor_status__descriptor); return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); } Eventcast__SetSensorStatus * @@ -433,7 +434,7 @@ void eventcast__set_sensor_status__free_unpacked (Eventcast__SetSensorStatus *message, ProtobufCAllocator *allocator) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__set_sensor_status__descriptor); + assert(message->base.descriptor == &eventcast__set_sensor_status__descriptor); protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); } void eventcast__sensor_data__init @@ -445,21 +446,21 @@ void eventcast__sensor_data__init size_t eventcast__sensor_data__get_packed_size (const Eventcast__SensorData *message) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__sensor_data__descriptor); + assert(message->base.descriptor == &eventcast__sensor_data__descriptor); return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); } size_t eventcast__sensor_data__pack (const Eventcast__SensorData *message, uint8_t *out) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__sensor_data__descriptor); + assert(message->base.descriptor == &eventcast__sensor_data__descriptor); return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); } size_t eventcast__sensor_data__pack_to_buffer (const Eventcast__SensorData *message, ProtobufCBuffer *buffer) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__sensor_data__descriptor); + assert(message->base.descriptor == &eventcast__sensor_data__descriptor); return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); } Eventcast__SensorData * @@ -476,7 +477,7 @@ void eventcast__sensor_data__free_unpacked (Eventcast__SensorData *message, ProtobufCAllocator *allocator) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__sensor_data__descriptor); + assert(message->base.descriptor == &eventcast__sensor_data__descriptor); protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); } void eventcast__sensor_msg__init @@ -488,21 +489,21 @@ void eventcast__sensor_msg__init size_t eventcast__sensor_msg__get_packed_size (const Eventcast__SensorMsg *message) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__sensor_msg__descriptor); + assert(message->base.descriptor == &eventcast__sensor_msg__descriptor); return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); } size_t eventcast__sensor_msg__pack (const Eventcast__SensorMsg *message, uint8_t *out) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__sensor_msg__descriptor); + assert(message->base.descriptor == &eventcast__sensor_msg__descriptor); return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); } size_t eventcast__sensor_msg__pack_to_buffer (const Eventcast__SensorMsg *message, ProtobufCBuffer *buffer) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__sensor_msg__descriptor); + assert(message->base.descriptor == &eventcast__sensor_msg__descriptor); return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); } Eventcast__SensorMsg * @@ -519,7 +520,7 @@ void eventcast__sensor_msg__free_unpacked (Eventcast__SensorMsg *message, ProtobufCAllocator *allocator) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__sensor_msg__descriptor); + assert(message->base.descriptor == &eventcast__sensor_msg__descriptor); protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); } void eventcast__resolution__init @@ -531,21 +532,21 @@ void eventcast__resolution__init size_t eventcast__resolution__get_packed_size (const Eventcast__Resolution *message) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__resolution__descriptor); + assert(message->base.descriptor == &eventcast__resolution__descriptor); return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); } size_t eventcast__resolution__pack (const Eventcast__Resolution *message, uint8_t *out) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__resolution__descriptor); + assert(message->base.descriptor == &eventcast__resolution__descriptor); return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); } size_t eventcast__resolution__pack_to_buffer (const Eventcast__Resolution *message, ProtobufCBuffer *buffer) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__resolution__descriptor); + assert(message->base.descriptor == &eventcast__resolution__descriptor); return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); } Eventcast__Resolution * @@ -562,7 +563,7 @@ void eventcast__resolution__free_unpacked (Eventcast__Resolution *message, ProtobufCAllocator *allocator) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__resolution__descriptor); + assert(message->base.descriptor == &eventcast__resolution__descriptor); protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); } void eventcast__display_msg__init @@ -574,21 +575,21 @@ void eventcast__display_msg__init size_t eventcast__display_msg__get_packed_size (const Eventcast__DisplayMsg *message) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__display_msg__descriptor); + assert(message->base.descriptor == &eventcast__display_msg__descriptor); return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); } size_t eventcast__display_msg__pack (const Eventcast__DisplayMsg *message, uint8_t *out) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__display_msg__descriptor); + assert(message->base.descriptor == &eventcast__display_msg__descriptor); return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); } size_t eventcast__display_msg__pack_to_buffer (const Eventcast__DisplayMsg *message, ProtobufCBuffer *buffer) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__display_msg__descriptor); + assert(message->base.descriptor == &eventcast__display_msg__descriptor); return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); } Eventcast__DisplayMsg * @@ -605,7 +606,7 @@ void eventcast__display_msg__free_unpacked (Eventcast__DisplayMsg *message, ProtobufCAllocator *allocator) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__display_msg__descriptor); + assert(message->base.descriptor == &eventcast__display_msg__descriptor); protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); } void eventcast__touch_max_count__init @@ -617,21 +618,21 @@ void eventcast__touch_max_count__init size_t eventcast__touch_max_count__get_packed_size (const Eventcast__TouchMaxCount *message) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__touch_max_count__descriptor); + assert(message->base.descriptor == &eventcast__touch_max_count__descriptor); return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); } size_t eventcast__touch_max_count__pack (const Eventcast__TouchMaxCount *message, uint8_t *out) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__touch_max_count__descriptor); + assert(message->base.descriptor == &eventcast__touch_max_count__descriptor); return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); } size_t eventcast__touch_max_count__pack_to_buffer (const Eventcast__TouchMaxCount *message, ProtobufCBuffer *buffer) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__touch_max_count__descriptor); + assert(message->base.descriptor == &eventcast__touch_max_count__descriptor); return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); } Eventcast__TouchMaxCount * @@ -648,7 +649,7 @@ void eventcast__touch_max_count__free_unpacked (Eventcast__TouchMaxCount *message, ProtobufCAllocator *allocator) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__touch_max_count__descriptor); + assert(message->base.descriptor == &eventcast__touch_max_count__descriptor); protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); } void eventcast__touch_data__init @@ -660,21 +661,21 @@ void eventcast__touch_data__init size_t eventcast__touch_data__get_packed_size (const Eventcast__TouchData *message) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__touch_data__descriptor); + assert(message->base.descriptor == &eventcast__touch_data__descriptor); return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); } size_t eventcast__touch_data__pack (const Eventcast__TouchData *message, uint8_t *out) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__touch_data__descriptor); + assert(message->base.descriptor == &eventcast__touch_data__descriptor); return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); } size_t eventcast__touch_data__pack_to_buffer (const Eventcast__TouchData *message, ProtobufCBuffer *buffer) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__touch_data__descriptor); + assert(message->base.descriptor == &eventcast__touch_data__descriptor); return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); } Eventcast__TouchData * @@ -691,7 +692,7 @@ void eventcast__touch_data__free_unpacked (Eventcast__TouchData *message, ProtobufCAllocator *allocator) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__touch_data__descriptor); + assert(message->base.descriptor == &eventcast__touch_data__descriptor); protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); } void eventcast__hwkey_msg__init @@ -703,21 +704,21 @@ void eventcast__hwkey_msg__init size_t eventcast__hwkey_msg__get_packed_size (const Eventcast__HWKeyMsg *message) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__hwkey_msg__descriptor); + assert(message->base.descriptor == &eventcast__hwkey_msg__descriptor); return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); } size_t eventcast__hwkey_msg__pack (const Eventcast__HWKeyMsg *message, uint8_t *out) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__hwkey_msg__descriptor); + assert(message->base.descriptor == &eventcast__hwkey_msg__descriptor); return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); } size_t eventcast__hwkey_msg__pack_to_buffer (const Eventcast__HWKeyMsg *message, ProtobufCBuffer *buffer) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__hwkey_msg__descriptor); + assert(message->base.descriptor == &eventcast__hwkey_msg__descriptor); return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); } Eventcast__HWKeyMsg * @@ -734,7 +735,7 @@ void eventcast__hwkey_msg__free_unpacked (Eventcast__HWKeyMsg *message, ProtobufCAllocator *allocator) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__hwkey_msg__descriptor); + assert(message->base.descriptor == &eventcast__hwkey_msg__descriptor); protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); } void eventcast__touch_msg__init @@ -746,21 +747,21 @@ void eventcast__touch_msg__init size_t eventcast__touch_msg__get_packed_size (const Eventcast__TouchMsg *message) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__touch_msg__descriptor); + assert(message->base.descriptor == &eventcast__touch_msg__descriptor); return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); } size_t eventcast__touch_msg__pack (const Eventcast__TouchMsg *message, uint8_t *out) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__touch_msg__descriptor); + assert(message->base.descriptor == &eventcast__touch_msg__descriptor); return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); } size_t eventcast__touch_msg__pack_to_buffer (const Eventcast__TouchMsg *message, ProtobufCBuffer *buffer) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__touch_msg__descriptor); + assert(message->base.descriptor == &eventcast__touch_msg__descriptor); return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); } Eventcast__TouchMsg * @@ -777,7 +778,7 @@ void eventcast__touch_msg__free_unpacked (Eventcast__TouchMsg *message, ProtobufCAllocator *allocator) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__touch_msg__descriptor); + assert(message->base.descriptor == &eventcast__touch_msg__descriptor); protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); } void eventcast__event_cast_msg__init @@ -789,21 +790,21 @@ void eventcast__event_cast_msg__init size_t eventcast__event_cast_msg__get_packed_size (const Eventcast__EventCastMsg *message) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__event_cast_msg__descriptor); + assert(message->base.descriptor == &eventcast__event_cast_msg__descriptor); return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); } size_t eventcast__event_cast_msg__pack (const Eventcast__EventCastMsg *message, uint8_t *out) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__event_cast_msg__descriptor); + assert(message->base.descriptor == &eventcast__event_cast_msg__descriptor); return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); } size_t eventcast__event_cast_msg__pack_to_buffer (const Eventcast__EventCastMsg *message, ProtobufCBuffer *buffer) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__event_cast_msg__descriptor); + assert(message->base.descriptor == &eventcast__event_cast_msg__descriptor); return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); } Eventcast__EventCastMsg * @@ -820,7 +821,7 @@ void eventcast__event_cast_msg__free_unpacked (Eventcast__EventCastMsg *message, ProtobufCAllocator *allocator) { - PROTOBUF_C_ASSERT (message->base.descriptor == &eventcast__event_cast_msg__descriptor); + assert(message->base.descriptor == &eventcast__event_cast_msg__descriptor); protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); } static const ProtobufCFieldDescriptor eventcast__hand_shake_req__field_descriptors[1] = @@ -831,10 +832,10 @@ static const ProtobufCFieldDescriptor eventcast__hand_shake_req__field_descripto PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_INT32, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(Eventcast__HandShakeReq, key), + offsetof(Eventcast__HandShakeReq, key), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, }; @@ -848,7 +849,7 @@ static const ProtobufCIntRange eventcast__hand_shake_req__number_ranges[1 + 1] = }; const ProtobufCMessageDescriptor eventcast__hand_shake_req__descriptor = { - PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC, + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, "eventcast.HandShakeReq", "HandShakeReq", "Eventcast__HandShakeReq", @@ -869,10 +870,10 @@ static const ProtobufCFieldDescriptor eventcast__hand_shake_ans__field_descripto PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_ENUM, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(Eventcast__HandShakeAns, result), + offsetof(Eventcast__HandShakeAns, result), &eventcast__message_result__descriptor, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, }; @@ -886,7 +887,7 @@ static const ProtobufCIntRange eventcast__hand_shake_ans__number_ranges[1 + 1] = }; const ProtobufCMessageDescriptor eventcast__hand_shake_ans__descriptor = { - PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC, + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, "eventcast.HandShakeAns", "HandShakeAns", "Eventcast__HandShakeAns", @@ -907,10 +908,10 @@ static const ProtobufCFieldDescriptor eventcast__emulator_state__field_descripto PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_ENUM, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(Eventcast__EmulatorState, state), + offsetof(Eventcast__EmulatorState, state), &eventcast__connection_state__descriptor, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, }; @@ -924,7 +925,7 @@ static const ProtobufCIntRange eventcast__emulator_state__number_ranges[1 + 1] = }; const ProtobufCMessageDescriptor eventcast__emulator_state__descriptor = { - PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC, + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, "eventcast.EmulatorState", "EmulatorState", "Eventcast__EmulatorState", @@ -945,10 +946,10 @@ static const ProtobufCFieldDescriptor eventcast__app_state__field_descriptors[1] PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_ENUM, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(Eventcast__AppState, state), + offsetof(Eventcast__AppState, state), &eventcast__connection_state__descriptor, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, }; @@ -962,7 +963,7 @@ static const ProtobufCIntRange eventcast__app_state__number_ranges[1 + 1] = }; const ProtobufCMessageDescriptor eventcast__app_state__descriptor = { - PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC, + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, "eventcast.AppState", "AppState", "Eventcast__AppState", @@ -980,7 +981,7 @@ const ProtobufCMessageDescriptor eventcast__app_state__descriptor = #define eventcast__start_req__number_ranges NULL const ProtobufCMessageDescriptor eventcast__start_req__descriptor = { - PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC, + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, "eventcast.StartReq", "StartReq", "Eventcast__StartReq", @@ -1001,10 +1002,10 @@ static const ProtobufCFieldDescriptor eventcast__start_ans__field_descriptors[1] PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_ENUM, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(Eventcast__StartAns, result), + offsetof(Eventcast__StartAns, result), &eventcast__message_result__descriptor, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, }; @@ -1018,7 +1019,7 @@ static const ProtobufCIntRange eventcast__start_ans__number_ranges[1 + 1] = }; const ProtobufCMessageDescriptor eventcast__start_ans__descriptor = { - PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC, + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, "eventcast.StartAns", "StartAns", "Eventcast__StartAns", @@ -1039,10 +1040,10 @@ static const ProtobufCFieldDescriptor eventcast__set_event_status__field_descrip PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_ENUM, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(Eventcast__SetEventStatus, type), + offsetof(Eventcast__SetEventStatus, type), &eventcast__event_type__descriptor, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1051,10 +1052,10 @@ static const ProtobufCFieldDescriptor eventcast__set_event_status__field_descrip PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_ENUM, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(Eventcast__SetEventStatus, state), + offsetof(Eventcast__SetEventStatus, state), &eventcast__state__descriptor, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, }; @@ -1069,7 +1070,7 @@ static const ProtobufCIntRange eventcast__set_event_status__number_ranges[1 + 1] }; const ProtobufCMessageDescriptor eventcast__set_event_status__descriptor = { - PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC, + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, "eventcast.SetEventStatus", "SetEventStatus", "Eventcast__SetEventStatus", @@ -1082,7 +1083,7 @@ const ProtobufCMessageDescriptor eventcast__set_event_status__descriptor = (ProtobufCMessageInit) eventcast__set_event_status__init, NULL,NULL,NULL /* reserved[123] */ }; -const ProtobufCEnumValue eventcast__event_msg__type__enum_values_by_number[4] = +static const ProtobufCEnumValue eventcast__event_msg__type__enum_values_by_number[4] = { { "START_REQ", "EVENTCAST__EVENT_MSG__TYPE__START_REQ", 2 }, { "START_ANS", "EVENTCAST__EVENT_MSG__TYPE__START_ANS", 3 }, @@ -1092,7 +1093,7 @@ const ProtobufCEnumValue eventcast__event_msg__type__enum_values_by_number[4] = static const ProtobufCIntRange eventcast__event_msg__type__value_ranges[] = { {2, 0},{0, 4} }; -const ProtobufCEnumValueIndex eventcast__event_msg__type__enum_values_by_name[4] = +static const ProtobufCEnumValueIndex eventcast__event_msg__type__enum_values_by_name[4] = { { "EVENT_STATUS", 3 }, { "START_ANS", 1 }, @@ -1101,7 +1102,7 @@ const ProtobufCEnumValueIndex eventcast__event_msg__type__enum_values_by_name[4] }; const ProtobufCEnumDescriptor eventcast__event_msg__type__descriptor = { - PROTOBUF_C_ENUM_DESCRIPTOR_MAGIC, + PROTOBUF_C__ENUM_DESCRIPTOR_MAGIC, "eventcast.EventMsg.TYPE", "TYPE", "Eventcast__EventMsg__TYPE", @@ -1122,10 +1123,10 @@ static const ProtobufCFieldDescriptor eventcast__event_msg__field_descriptors[5] PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_ENUM, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(Eventcast__EventMsg, type), + offsetof(Eventcast__EventMsg, type), &eventcast__event_msg__type__descriptor, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1134,10 +1135,10 @@ static const ProtobufCFieldDescriptor eventcast__event_msg__field_descriptors[5] PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(Eventcast__EventMsg, startreq), + offsetof(Eventcast__EventMsg, startreq), &eventcast__start_req__descriptor, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1146,10 +1147,10 @@ static const ProtobufCFieldDescriptor eventcast__event_msg__field_descriptors[5] PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(Eventcast__EventMsg, startans), + offsetof(Eventcast__EventMsg, startans), &eventcast__start_ans__descriptor, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1158,10 +1159,10 @@ static const ProtobufCFieldDescriptor eventcast__event_msg__field_descriptors[5] PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(Eventcast__EventMsg, terminate), + offsetof(Eventcast__EventMsg, terminate), &eventcast__event_terminate__descriptor, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1170,10 +1171,10 @@ static const ProtobufCFieldDescriptor eventcast__event_msg__field_descriptors[5] PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(Eventcast__EventMsg, setstatus), + offsetof(Eventcast__EventMsg, setstatus), &eventcast__set_event_status__descriptor, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, }; @@ -1191,7 +1192,7 @@ static const ProtobufCIntRange eventcast__event_msg__number_ranges[1 + 1] = }; const ProtobufCMessageDescriptor eventcast__event_msg__descriptor = { - PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC, + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, "eventcast.EventMsg", "EventMsg", "Eventcast__EventMsg", @@ -1209,7 +1210,7 @@ const ProtobufCMessageDescriptor eventcast__event_msg__descriptor = #define eventcast__event_terminate__number_ranges NULL const ProtobufCMessageDescriptor eventcast__event_terminate__descriptor = { - PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC, + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, "eventcast.EventTerminate", "EventTerminate", "Eventcast__EventTerminate", @@ -1230,10 +1231,10 @@ static const ProtobufCFieldDescriptor eventcast__set_sensor_status__field_descri PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_ENUM, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(Eventcast__SetSensorStatus, type), + offsetof(Eventcast__SetSensorStatus, type), &eventcast__sensor_type__descriptor, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1242,10 +1243,10 @@ static const ProtobufCFieldDescriptor eventcast__set_sensor_status__field_descri PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_ENUM, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(Eventcast__SetSensorStatus, state), + offsetof(Eventcast__SetSensorStatus, state), &eventcast__state__descriptor, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, }; @@ -1260,7 +1261,7 @@ static const ProtobufCIntRange eventcast__set_sensor_status__number_ranges[1 + 1 }; const ProtobufCMessageDescriptor eventcast__set_sensor_status__descriptor = { - PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC, + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, "eventcast.SetSensorStatus", "SetSensorStatus", "Eventcast__SetSensorStatus", @@ -1284,10 +1285,10 @@ static const ProtobufCFieldDescriptor eventcast__sensor_data__field_descriptors[ PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_ENUM, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(Eventcast__SensorData, sensor), + offsetof(Eventcast__SensorData, sensor), &eventcast__sensor_type__descriptor, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1296,10 +1297,10 @@ static const ProtobufCFieldDescriptor eventcast__sensor_data__field_descriptors[ PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_STRING, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(Eventcast__SensorData, x), + offsetof(Eventcast__SensorData, x), NULL, &eventcast__sensor_data__x__default_value, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1308,10 +1309,10 @@ static const ProtobufCFieldDescriptor eventcast__sensor_data__field_descriptors[ PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_STRING, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(Eventcast__SensorData, y), + offsetof(Eventcast__SensorData, y), NULL, &eventcast__sensor_data__y__default_value, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1320,10 +1321,10 @@ static const ProtobufCFieldDescriptor eventcast__sensor_data__field_descriptors[ PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_STRING, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(Eventcast__SensorData, z), + offsetof(Eventcast__SensorData, z), NULL, &eventcast__sensor_data__z__default_value, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, }; @@ -1340,7 +1341,7 @@ static const ProtobufCIntRange eventcast__sensor_data__number_ranges[1 + 1] = }; const ProtobufCMessageDescriptor eventcast__sensor_data__descriptor = { - PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC, + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, "eventcast.SensorData", "SensorData", "Eventcast__SensorData", @@ -1353,7 +1354,7 @@ const ProtobufCMessageDescriptor eventcast__sensor_data__descriptor = (ProtobufCMessageInit) eventcast__sensor_data__init, NULL,NULL,NULL /* reserved[123] */ }; -const ProtobufCEnumValue eventcast__sensor_msg__type__enum_values_by_number[5] = +static const ProtobufCEnumValue eventcast__sensor_msg__type__enum_values_by_number[5] = { { "START_REQ", "EVENTCAST__SENSOR_MSG__TYPE__START_REQ", 2 }, { "START_ANS", "EVENTCAST__SENSOR_MSG__TYPE__START_ANS", 3 }, @@ -1364,7 +1365,7 @@ const ProtobufCEnumValue eventcast__sensor_msg__type__enum_values_by_number[5] = static const ProtobufCIntRange eventcast__sensor_msg__type__value_ranges[] = { {2, 0},{0, 5} }; -const ProtobufCEnumValueIndex eventcast__sensor_msg__type__enum_values_by_name[5] = +static const ProtobufCEnumValueIndex eventcast__sensor_msg__type__enum_values_by_name[5] = { { "SENSOR_DATA", 4 }, { "SENSOR_STATUS", 3 }, @@ -1374,7 +1375,7 @@ const ProtobufCEnumValueIndex eventcast__sensor_msg__type__enum_values_by_name[5 }; const ProtobufCEnumDescriptor eventcast__sensor_msg__type__descriptor = { - PROTOBUF_C_ENUM_DESCRIPTOR_MAGIC, + PROTOBUF_C__ENUM_DESCRIPTOR_MAGIC, "eventcast.SensorMsg.Type", "Type", "Eventcast__SensorMsg__Type", @@ -1395,10 +1396,10 @@ static const ProtobufCFieldDescriptor eventcast__sensor_msg__field_descriptors[6 PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_ENUM, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(Eventcast__SensorMsg, type), + offsetof(Eventcast__SensorMsg, type), &eventcast__sensor_msg__type__descriptor, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1407,10 +1408,10 @@ static const ProtobufCFieldDescriptor eventcast__sensor_msg__field_descriptors[6 PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(Eventcast__SensorMsg, startreq), + offsetof(Eventcast__SensorMsg, startreq), &eventcast__start_req__descriptor, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1419,10 +1420,10 @@ static const ProtobufCFieldDescriptor eventcast__sensor_msg__field_descriptors[6 PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(Eventcast__SensorMsg, startans), + offsetof(Eventcast__SensorMsg, startans), &eventcast__start_ans__descriptor, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1431,10 +1432,10 @@ static const ProtobufCFieldDescriptor eventcast__sensor_msg__field_descriptors[6 PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(Eventcast__SensorMsg, terminate), + offsetof(Eventcast__SensorMsg, terminate), &eventcast__event_terminate__descriptor, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1443,10 +1444,10 @@ static const ProtobufCFieldDescriptor eventcast__sensor_msg__field_descriptors[6 PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(Eventcast__SensorMsg, setstatus), + offsetof(Eventcast__SensorMsg, setstatus), &eventcast__set_sensor_status__descriptor, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1455,10 +1456,10 @@ static const ProtobufCFieldDescriptor eventcast__sensor_msg__field_descriptors[6 PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(Eventcast__SensorMsg, data), + offsetof(Eventcast__SensorMsg, data), &eventcast__sensor_data__descriptor, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, }; @@ -1477,7 +1478,7 @@ static const ProtobufCIntRange eventcast__sensor_msg__number_ranges[1 + 1] = }; const ProtobufCMessageDescriptor eventcast__sensor_msg__descriptor = { - PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC, + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, "eventcast.SensorMsg", "SensorMsg", "Eventcast__SensorMsg", @@ -1498,10 +1499,10 @@ static const ProtobufCFieldDescriptor eventcast__resolution__field_descriptors[2 PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_INT32, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(Eventcast__Resolution, width), + offsetof(Eventcast__Resolution, width), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1510,10 +1511,10 @@ static const ProtobufCFieldDescriptor eventcast__resolution__field_descriptors[2 PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_INT32, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(Eventcast__Resolution, height), + offsetof(Eventcast__Resolution, height), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, }; @@ -1528,7 +1529,7 @@ static const ProtobufCIntRange eventcast__resolution__number_ranges[1 + 1] = }; const ProtobufCMessageDescriptor eventcast__resolution__descriptor = { - PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC, + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, "eventcast.Resolution", "Resolution", "Eventcast__Resolution", @@ -1548,11 +1549,11 @@ static const ProtobufCFieldDescriptor eventcast__display_msg__field_descriptors[ 1, PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_INT32, - PROTOBUF_C_OFFSETOF(Eventcast__DisplayMsg, has_framerate), - PROTOBUF_C_OFFSETOF(Eventcast__DisplayMsg, framerate), + offsetof(Eventcast__DisplayMsg, has_framerate), + offsetof(Eventcast__DisplayMsg, framerate), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1560,11 +1561,11 @@ static const ProtobufCFieldDescriptor eventcast__display_msg__field_descriptors[ 2, PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_BYTES, - PROTOBUF_C_OFFSETOF(Eventcast__DisplayMsg, has_imagedata), - PROTOBUF_C_OFFSETOF(Eventcast__DisplayMsg, imagedata), + offsetof(Eventcast__DisplayMsg, has_imagedata), + offsetof(Eventcast__DisplayMsg, imagedata), NULL, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, }; @@ -1579,7 +1580,7 @@ static const ProtobufCIntRange eventcast__display_msg__number_ranges[1 + 1] = }; const ProtobufCMessageDescriptor eventcast__display_msg__descriptor = { - PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC, + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, "eventcast.DisplayMsg", "DisplayMsg", "Eventcast__DisplayMsg", @@ -1600,11 +1601,11 @@ static const ProtobufCFieldDescriptor eventcast__touch_max_count__field_descript 1, PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_INT32, - PROTOBUF_C_OFFSETOF(Eventcast__TouchMaxCount, has_max), - PROTOBUF_C_OFFSETOF(Eventcast__TouchMaxCount, max), + offsetof(Eventcast__TouchMaxCount, has_max), + offsetof(Eventcast__TouchMaxCount, max), NULL, &eventcast__touch_max_count__max__default_value, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, }; @@ -1618,7 +1619,7 @@ static const ProtobufCIntRange eventcast__touch_max_count__number_ranges[1 + 1] }; const ProtobufCMessageDescriptor eventcast__touch_max_count__descriptor = { - PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC, + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, "eventcast.TouchMaxCount", "TouchMaxCount", "Eventcast__TouchMaxCount", @@ -1641,11 +1642,11 @@ static const ProtobufCFieldDescriptor eventcast__touch_data__field_descriptors[4 1, PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_INT32, - PROTOBUF_C_OFFSETOF(Eventcast__TouchData, has_index), - PROTOBUF_C_OFFSETOF(Eventcast__TouchData, index), + offsetof(Eventcast__TouchData, has_index), + offsetof(Eventcast__TouchData, index), NULL, &eventcast__touch_data__index__default_value, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1653,11 +1654,11 @@ static const ProtobufCFieldDescriptor eventcast__touch_data__field_descriptors[4 2, PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_FLOAT, - PROTOBUF_C_OFFSETOF(Eventcast__TouchData, has_xpoint), - PROTOBUF_C_OFFSETOF(Eventcast__TouchData, xpoint), + offsetof(Eventcast__TouchData, has_xpoint), + offsetof(Eventcast__TouchData, xpoint), NULL, &eventcast__touch_data__x_point__default_value, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1665,11 +1666,11 @@ static const ProtobufCFieldDescriptor eventcast__touch_data__field_descriptors[4 3, PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_FLOAT, - PROTOBUF_C_OFFSETOF(Eventcast__TouchData, has_ypoint), - PROTOBUF_C_OFFSETOF(Eventcast__TouchData, ypoint), + offsetof(Eventcast__TouchData, has_ypoint), + offsetof(Eventcast__TouchData, ypoint), NULL, &eventcast__touch_data__y_point__default_value, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1677,11 +1678,11 @@ static const ProtobufCFieldDescriptor eventcast__touch_data__field_descriptors[4 4, PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_ENUM, - PROTOBUF_C_OFFSETOF(Eventcast__TouchData, has_state), - PROTOBUF_C_OFFSETOF(Eventcast__TouchData, state), + offsetof(Eventcast__TouchData, has_state), + offsetof(Eventcast__TouchData, state), &eventcast__touch_state__descriptor, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, }; @@ -1698,7 +1699,7 @@ static const ProtobufCIntRange eventcast__touch_data__number_ranges[1 + 1] = }; const ProtobufCMessageDescriptor eventcast__touch_data__descriptor = { - PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC, + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, "eventcast.TouchData", "TouchData", "Eventcast__TouchData", @@ -1719,10 +1720,10 @@ static const ProtobufCFieldDescriptor eventcast__hwkey_msg__field_descriptors[1] PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_ENUM, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(Eventcast__HWKeyMsg, type), + offsetof(Eventcast__HWKeyMsg, type), &eventcast__hwkey_type__descriptor, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, }; @@ -1736,7 +1737,7 @@ static const ProtobufCIntRange eventcast__hwkey_msg__number_ranges[1 + 1] = }; const ProtobufCMessageDescriptor eventcast__hwkey_msg__descriptor = { - PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC, + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, "eventcast.HWKeyMsg", "HWKeyMsg", "Eventcast__HWKeyMsg", @@ -1749,7 +1750,7 @@ const ProtobufCMessageDescriptor eventcast__hwkey_msg__descriptor = (ProtobufCMessageInit) eventcast__hwkey_msg__init, NULL,NULL,NULL /* reserved[123] */ }; -const ProtobufCEnumValue eventcast__touch_msg__type__enum_values_by_number[8] = +static const ProtobufCEnumValue eventcast__touch_msg__type__enum_values_by_number[8] = { { "START_REQ", "EVENTCAST__TOUCH_MSG__TYPE__START_REQ", 2 }, { "START_ANS", "EVENTCAST__TOUCH_MSG__TYPE__START_ANS", 3 }, @@ -1763,7 +1764,7 @@ const ProtobufCEnumValue eventcast__touch_msg__type__enum_values_by_number[8] = static const ProtobufCIntRange eventcast__touch_msg__type__value_ranges[] = { {2, 0},{0, 8} }; -const ProtobufCEnumValueIndex eventcast__touch_msg__type__enum_values_by_name[8] = +static const ProtobufCEnumValueIndex eventcast__touch_msg__type__enum_values_by_name[8] = { { "DISPLAY_MSG", 6 }, { "HWKEY_MSG", 7 }, @@ -1776,7 +1777,7 @@ const ProtobufCEnumValueIndex eventcast__touch_msg__type__enum_values_by_name[8] }; const ProtobufCEnumDescriptor eventcast__touch_msg__type__descriptor = { - PROTOBUF_C_ENUM_DESCRIPTOR_MAGIC, + PROTOBUF_C__ENUM_DESCRIPTOR_MAGIC, "eventcast.TouchMsg.Type", "Type", "Eventcast__TouchMsg__Type", @@ -1797,10 +1798,10 @@ static const ProtobufCFieldDescriptor eventcast__touch_msg__field_descriptors[9] PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_ENUM, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(Eventcast__TouchMsg, type), + offsetof(Eventcast__TouchMsg, type), &eventcast__touch_msg__type__descriptor, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1809,10 +1810,10 @@ static const ProtobufCFieldDescriptor eventcast__touch_msg__field_descriptors[9] PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(Eventcast__TouchMsg, startreq), + offsetof(Eventcast__TouchMsg, startreq), &eventcast__start_req__descriptor, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1821,10 +1822,10 @@ static const ProtobufCFieldDescriptor eventcast__touch_msg__field_descriptors[9] PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(Eventcast__TouchMsg, startans), + offsetof(Eventcast__TouchMsg, startans), &eventcast__start_ans__descriptor, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1833,10 +1834,10 @@ static const ProtobufCFieldDescriptor eventcast__touch_msg__field_descriptors[9] PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(Eventcast__TouchMsg, terminate), + offsetof(Eventcast__TouchMsg, terminate), &eventcast__event_terminate__descriptor, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1845,10 +1846,10 @@ static const ProtobufCFieldDescriptor eventcast__touch_msg__field_descriptors[9] PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(Eventcast__TouchMsg, maxcount), + offsetof(Eventcast__TouchMsg, maxcount), &eventcast__touch_max_count__descriptor, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1857,10 +1858,10 @@ static const ProtobufCFieldDescriptor eventcast__touch_msg__field_descriptors[9] PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(Eventcast__TouchMsg, touchdata), + offsetof(Eventcast__TouchMsg, touchdata), &eventcast__touch_data__descriptor, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1869,10 +1870,10 @@ static const ProtobufCFieldDescriptor eventcast__touch_msg__field_descriptors[9] PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(Eventcast__TouchMsg, resolution), + offsetof(Eventcast__TouchMsg, resolution), &eventcast__resolution__descriptor, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1881,10 +1882,10 @@ static const ProtobufCFieldDescriptor eventcast__touch_msg__field_descriptors[9] PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(Eventcast__TouchMsg, display), + offsetof(Eventcast__TouchMsg, display), &eventcast__display_msg__descriptor, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1893,10 +1894,10 @@ static const ProtobufCFieldDescriptor eventcast__touch_msg__field_descriptors[9] PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(Eventcast__TouchMsg, hwkey), + offsetof(Eventcast__TouchMsg, hwkey), &eventcast__hwkey_msg__descriptor, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, }; @@ -1918,7 +1919,7 @@ static const ProtobufCIntRange eventcast__touch_msg__number_ranges[1 + 1] = }; const ProtobufCMessageDescriptor eventcast__touch_msg__descriptor = { - PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC, + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, "eventcast.TouchMsg", "TouchMsg", "Eventcast__TouchMsg", @@ -1931,7 +1932,7 @@ const ProtobufCMessageDescriptor eventcast__touch_msg__descriptor = (ProtobufCMessageInit) eventcast__touch_msg__init, NULL,NULL,NULL /* reserved[123] */ }; -const ProtobufCEnumValue eventcast__event_cast_msg__type__enum_values_by_number[7] = +static const ProtobufCEnumValue eventcast__event_cast_msg__type__enum_values_by_number[7] = { { "HANDSHAKE_REQ", "EVENTCAST__EVENT_CAST_MSG__TYPE__HANDSHAKE_REQ", 2 }, { "HANDSHAKE_ANS", "EVENTCAST__EVENT_CAST_MSG__TYPE__HANDSHAKE_ANS", 3 }, @@ -1944,7 +1945,7 @@ const ProtobufCEnumValue eventcast__event_cast_msg__type__enum_values_by_number[ static const ProtobufCIntRange eventcast__event_cast_msg__type__value_ranges[] = { {2, 0},{0, 7} }; -const ProtobufCEnumValueIndex eventcast__event_cast_msg__type__enum_values_by_name[7] = +static const ProtobufCEnumValueIndex eventcast__event_cast_msg__type__enum_values_by_name[7] = { { "APP_STATE", 3 }, { "EMUL_STATE", 2 }, @@ -1956,7 +1957,7 @@ const ProtobufCEnumValueIndex eventcast__event_cast_msg__type__enum_values_by_na }; const ProtobufCEnumDescriptor eventcast__event_cast_msg__type__descriptor = { - PROTOBUF_C_ENUM_DESCRIPTOR_MAGIC, + PROTOBUF_C__ENUM_DESCRIPTOR_MAGIC, "eventcast.EventCastMsg.Type", "Type", "Eventcast__EventCastMsg__Type", @@ -1977,10 +1978,10 @@ static const ProtobufCFieldDescriptor eventcast__event_cast_msg__field_descripto PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_ENUM, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(Eventcast__EventCastMsg, type), + offsetof(Eventcast__EventCastMsg, type), &eventcast__event_cast_msg__type__descriptor, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1989,10 +1990,10 @@ static const ProtobufCFieldDescriptor eventcast__event_cast_msg__field_descripto PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(Eventcast__EventCastMsg, handshakereq), + offsetof(Eventcast__EventCastMsg, handshakereq), &eventcast__hand_shake_req__descriptor, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -2001,10 +2002,10 @@ static const ProtobufCFieldDescriptor eventcast__event_cast_msg__field_descripto PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(Eventcast__EventCastMsg, handshakeans), + offsetof(Eventcast__EventCastMsg, handshakeans), &eventcast__hand_shake_ans__descriptor, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -2013,10 +2014,10 @@ static const ProtobufCFieldDescriptor eventcast__event_cast_msg__field_descripto PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(Eventcast__EventCastMsg, emulstate), + offsetof(Eventcast__EventCastMsg, emulstate), &eventcast__emulator_state__descriptor, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -2025,10 +2026,10 @@ static const ProtobufCFieldDescriptor eventcast__event_cast_msg__field_descripto PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(Eventcast__EventCastMsg, appstate), + offsetof(Eventcast__EventCastMsg, appstate), &eventcast__app_state__descriptor, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -2037,10 +2038,10 @@ static const ProtobufCFieldDescriptor eventcast__event_cast_msg__field_descripto PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(Eventcast__EventCastMsg, eventmsg), + offsetof(Eventcast__EventCastMsg, eventmsg), &eventcast__event_msg__descriptor, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -2049,10 +2050,10 @@ static const ProtobufCFieldDescriptor eventcast__event_cast_msg__field_descripto PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(Eventcast__EventCastMsg, sensormsg), + offsetof(Eventcast__EventCastMsg, sensormsg), &eventcast__sensor_msg__descriptor, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -2061,10 +2062,10 @@ static const ProtobufCFieldDescriptor eventcast__event_cast_msg__field_descripto PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, 0, /* quantifier_offset */ - PROTOBUF_C_OFFSETOF(Eventcast__EventCastMsg, touchmsg), + offsetof(Eventcast__EventCastMsg, touchmsg), &eventcast__touch_msg__descriptor, NULL, - 0, /* packed */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, }; @@ -2085,7 +2086,7 @@ static const ProtobufCIntRange eventcast__event_cast_msg__number_ranges[1 + 1] = }; const ProtobufCMessageDescriptor eventcast__event_cast_msg__descriptor = { - PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC, + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, "eventcast.EventCastMsg", "EventCastMsg", "Eventcast__EventCastMsg", @@ -2098,7 +2099,7 @@ const ProtobufCMessageDescriptor eventcast__event_cast_msg__descriptor = (ProtobufCMessageInit) eventcast__event_cast_msg__init, NULL,NULL,NULL /* reserved[123] */ }; -const ProtobufCEnumValue eventcast__message_result__enum_values_by_number[3] = +static const ProtobufCEnumValue eventcast__message_result__enum_values_by_number[3] = { { "SUCCESS", "EVENTCAST__MESSAGE_RESULT__SUCCESS", 1 }, { "FAILURE", "EVENTCAST__MESSAGE_RESULT__FAILURE", 2 }, @@ -2107,7 +2108,7 @@ const ProtobufCEnumValue eventcast__message_result__enum_values_by_number[3] = static const ProtobufCIntRange eventcast__message_result__value_ranges[] = { {1, 0},{0, 3} }; -const ProtobufCEnumValueIndex eventcast__message_result__enum_values_by_name[3] = +static const ProtobufCEnumValueIndex eventcast__message_result__enum_values_by_name[3] = { { "CANCEL", 2 }, { "FAILURE", 1 }, @@ -2115,7 +2116,7 @@ const ProtobufCEnumValueIndex eventcast__message_result__enum_values_by_name[3] }; const ProtobufCEnumDescriptor eventcast__message_result__descriptor = { - PROTOBUF_C_ENUM_DESCRIPTOR_MAGIC, + PROTOBUF_C__ENUM_DESCRIPTOR_MAGIC, "eventcast.MessageResult", "MessageResult", "Eventcast__MessageResult", @@ -2128,7 +2129,7 @@ const ProtobufCEnumDescriptor eventcast__message_result__descriptor = eventcast__message_result__value_ranges, NULL,NULL,NULL,NULL /* reserved[1234] */ }; -const ProtobufCEnumValue eventcast__connection_state__enum_values_by_number[3] = +static const ProtobufCEnumValue eventcast__connection_state__enum_values_by_number[3] = { { "CONNECTED", "EVENTCAST__CONNECTION_STATE__CONNECTED", 1 }, { "DISCONNECTED", "EVENTCAST__CONNECTION_STATE__DISCONNECTED", 2 }, @@ -2137,7 +2138,7 @@ const ProtobufCEnumValue eventcast__connection_state__enum_values_by_number[3] = static const ProtobufCIntRange eventcast__connection_state__value_ranges[] = { {1, 0},{0, 3} }; -const ProtobufCEnumValueIndex eventcast__connection_state__enum_values_by_name[3] = +static const ProtobufCEnumValueIndex eventcast__connection_state__enum_values_by_name[3] = { { "CONNECTED", 0 }, { "DISCONNECTED", 1 }, @@ -2145,7 +2146,7 @@ const ProtobufCEnumValueIndex eventcast__connection_state__enum_values_by_name[3 }; const ProtobufCEnumDescriptor eventcast__connection_state__descriptor = { - PROTOBUF_C_ENUM_DESCRIPTOR_MAGIC, + PROTOBUF_C__ENUM_DESCRIPTOR_MAGIC, "eventcast.ConnectionState", "ConnectionState", "Eventcast__ConnectionState", @@ -2158,7 +2159,7 @@ const ProtobufCEnumDescriptor eventcast__connection_state__descriptor = eventcast__connection_state__value_ranges, NULL,NULL,NULL,NULL /* reserved[1234] */ }; -const ProtobufCEnumValue eventcast__event_type__enum_values_by_number[2] = +static const ProtobufCEnumValue eventcast__event_type__enum_values_by_number[2] = { { "SENSOR", "EVENTCAST__EVENT_TYPE__SENSOR", 1 }, { "TOUCH", "EVENTCAST__EVENT_TYPE__TOUCH", 2 }, @@ -2166,14 +2167,14 @@ const ProtobufCEnumValue eventcast__event_type__enum_values_by_number[2] = static const ProtobufCIntRange eventcast__event_type__value_ranges[] = { {1, 0},{0, 2} }; -const ProtobufCEnumValueIndex eventcast__event_type__enum_values_by_name[2] = +static const ProtobufCEnumValueIndex eventcast__event_type__enum_values_by_name[2] = { { "SENSOR", 0 }, { "TOUCH", 1 }, }; const ProtobufCEnumDescriptor eventcast__event_type__descriptor = { - PROTOBUF_C_ENUM_DESCRIPTOR_MAGIC, + PROTOBUF_C__ENUM_DESCRIPTOR_MAGIC, "eventcast.EventType", "EventType", "Eventcast__EventType", @@ -2186,7 +2187,7 @@ const ProtobufCEnumDescriptor eventcast__event_type__descriptor = eventcast__event_type__value_ranges, NULL,NULL,NULL,NULL /* reserved[1234] */ }; -const ProtobufCEnumValue eventcast__state__enum_values_by_number[2] = +static const ProtobufCEnumValue eventcast__state__enum_values_by_number[2] = { { "ENABLED", "EVENTCAST__STATE__ENABLED", 1 }, { "DISABLED", "EVENTCAST__STATE__DISABLED", 2 }, @@ -2194,14 +2195,14 @@ const ProtobufCEnumValue eventcast__state__enum_values_by_number[2] = static const ProtobufCIntRange eventcast__state__value_ranges[] = { {1, 0},{0, 2} }; -const ProtobufCEnumValueIndex eventcast__state__enum_values_by_name[2] = +static const ProtobufCEnumValueIndex eventcast__state__enum_values_by_name[2] = { { "DISABLED", 1 }, { "ENABLED", 0 }, }; const ProtobufCEnumDescriptor eventcast__state__descriptor = { - PROTOBUF_C_ENUM_DESCRIPTOR_MAGIC, + PROTOBUF_C__ENUM_DESCRIPTOR_MAGIC, "eventcast.State", "State", "Eventcast__State", @@ -2214,7 +2215,7 @@ const ProtobufCEnumDescriptor eventcast__state__descriptor = eventcast__state__value_ranges, NULL,NULL,NULL,NULL /* reserved[1234] */ }; -const ProtobufCEnumValue eventcast__sensor_type__enum_values_by_number[5] = +static const ProtobufCEnumValue eventcast__sensor_type__enum_values_by_number[5] = { { "ACCEL", "EVENTCAST__SENSOR_TYPE__ACCEL", 1 }, { "MAGNETIC", "EVENTCAST__SENSOR_TYPE__MAGNETIC", 2 }, @@ -2225,7 +2226,7 @@ const ProtobufCEnumValue eventcast__sensor_type__enum_values_by_number[5] = static const ProtobufCIntRange eventcast__sensor_type__value_ranges[] = { {1, 0},{0, 5} }; -const ProtobufCEnumValueIndex eventcast__sensor_type__enum_values_by_name[5] = +static const ProtobufCEnumValueIndex eventcast__sensor_type__enum_values_by_name[5] = { { "ACCEL", 0 }, { "GYROSCOPE", 2 }, @@ -2235,7 +2236,7 @@ const ProtobufCEnumValueIndex eventcast__sensor_type__enum_values_by_name[5] = }; const ProtobufCEnumDescriptor eventcast__sensor_type__descriptor = { - PROTOBUF_C_ENUM_DESCRIPTOR_MAGIC, + PROTOBUF_C__ENUM_DESCRIPTOR_MAGIC, "eventcast.SensorType", "SensorType", "Eventcast__SensorType", @@ -2248,7 +2249,7 @@ const ProtobufCEnumDescriptor eventcast__sensor_type__descriptor = eventcast__sensor_type__value_ranges, NULL,NULL,NULL,NULL /* reserved[1234] */ }; -const ProtobufCEnumValue eventcast__touch_state__enum_values_by_number[2] = +static const ProtobufCEnumValue eventcast__touch_state__enum_values_by_number[2] = { { "PRESSED", "EVENTCAST__TOUCH_STATE__PRESSED", 1 }, { "RELEASED", "EVENTCAST__TOUCH_STATE__RELEASED", 2 }, @@ -2256,14 +2257,14 @@ const ProtobufCEnumValue eventcast__touch_state__enum_values_by_number[2] = static const ProtobufCIntRange eventcast__touch_state__value_ranges[] = { {1, 0},{0, 2} }; -const ProtobufCEnumValueIndex eventcast__touch_state__enum_values_by_name[2] = +static const ProtobufCEnumValueIndex eventcast__touch_state__enum_values_by_name[2] = { { "PRESSED", 0 }, { "RELEASED", 1 }, }; const ProtobufCEnumDescriptor eventcast__touch_state__descriptor = { - PROTOBUF_C_ENUM_DESCRIPTOR_MAGIC, + PROTOBUF_C__ENUM_DESCRIPTOR_MAGIC, "eventcast.TouchState", "TouchState", "Eventcast__TouchState", @@ -2276,7 +2277,7 @@ const ProtobufCEnumDescriptor eventcast__touch_state__descriptor = eventcast__touch_state__value_ranges, NULL,NULL,NULL,NULL /* reserved[1234] */ }; -const ProtobufCEnumValue eventcast__hwkey_type__enum_values_by_number[6] = +static const ProtobufCEnumValue eventcast__hwkey_type__enum_values_by_number[6] = { { "MENU", "EVENTCAST__HWKEY_TYPE__MENU", 1 }, { "HOME", "EVENTCAST__HWKEY_TYPE__HOME", 2 }, @@ -2288,7 +2289,7 @@ const ProtobufCEnumValue eventcast__hwkey_type__enum_values_by_number[6] = static const ProtobufCIntRange eventcast__hwkey_type__value_ranges[] = { {1, 0},{0, 6} }; -const ProtobufCEnumValueIndex eventcast__hwkey_type__enum_values_by_name[6] = +static const ProtobufCEnumValueIndex eventcast__hwkey_type__enum_values_by_name[6] = { { "BACK", 2 }, { "HOME", 1 }, @@ -2299,7 +2300,7 @@ const ProtobufCEnumValueIndex eventcast__hwkey_type__enum_values_by_name[6] = }; const ProtobufCEnumDescriptor eventcast__hwkey_type__descriptor = { - PROTOBUF_C_ENUM_DESCRIPTOR_MAGIC, + PROTOBUF_C__ENUM_DESCRIPTOR_MAGIC, "eventcast.HWKeyType", "HWKeyType", "Eventcast__HWKeyType", diff --git a/tizen/src/eventcast/genmsg/eventcast.pb-c.h b/tizen/src/eventcast/genmsg/eventcast.pb-c.h index e446a55167..ddf3429fb0 100644 --- a/tizen/src/eventcast/genmsg/eventcast.pb-c.h +++ b/tizen/src/eventcast/genmsg/eventcast.pb-c.h @@ -1,11 +1,18 @@ /* Generated by the protocol buffer compiler. DO NOT EDIT! */ +/* Generated from: eventcast.proto */ #ifndef PROTOBUF_C_eventcast_2eproto__INCLUDED #define PROTOBUF_C_eventcast_2eproto__INCLUDED -#include "../../distrib/protobuf/protobuf-c.h" +#include <protobuf-c/protobuf-c.h> -PROTOBUF_C_BEGIN_DECLS +PROTOBUF_C__BEGIN_DECLS + +#if PROTOBUF_C_VERSION_NUMBER < 1000000 +# error This file was generated by a newer version of protoc-c which is incompatible with your libprotobuf-c headers. Please update your headers. +#elif 1002001 < PROTOBUF_C_MIN_COMPILER_VERSION +# error This file was generated by an older version of protoc-c which is incompatible with your libprotobuf-c headers. Please regenerate this file with a newer version of protoc-c. +#endif typedef struct _Eventcast__HandShakeReq Eventcast__HandShakeReq; @@ -36,6 +43,7 @@ typedef enum _Eventcast__EventMsg__TYPE { EVENTCAST__EVENT_MSG__TYPE__START_ANS = 3, EVENTCAST__EVENT_MSG__TYPE__TERMINATE = 4, EVENTCAST__EVENT_MSG__TYPE__EVENT_STATUS = 5 + PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(EVENTCAST__EVENT_MSG__TYPE) } Eventcast__EventMsg__TYPE; typedef enum _Eventcast__SensorMsg__Type { EVENTCAST__SENSOR_MSG__TYPE__START_REQ = 2, @@ -43,6 +51,7 @@ typedef enum _Eventcast__SensorMsg__Type { EVENTCAST__SENSOR_MSG__TYPE__TERMINATE = 4, EVENTCAST__SENSOR_MSG__TYPE__SENSOR_STATUS = 5, EVENTCAST__SENSOR_MSG__TYPE__SENSOR_DATA = 6 + PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(EVENTCAST__SENSOR_MSG__TYPE) } Eventcast__SensorMsg__Type; typedef enum _Eventcast__TouchMsg__Type { EVENTCAST__TOUCH_MSG__TYPE__START_REQ = 2, @@ -53,6 +62,7 @@ typedef enum _Eventcast__TouchMsg__Type { EVENTCAST__TOUCH_MSG__TYPE__RESOLUTION = 7, EVENTCAST__TOUCH_MSG__TYPE__DISPLAY_MSG = 8, EVENTCAST__TOUCH_MSG__TYPE__HWKEY_MSG = 9 + PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(EVENTCAST__TOUCH_MSG__TYPE) } Eventcast__TouchMsg__Type; typedef enum _Eventcast__EventCastMsg__Type { EVENTCAST__EVENT_CAST_MSG__TYPE__HANDSHAKE_REQ = 2, @@ -62,24 +72,32 @@ typedef enum _Eventcast__EventCastMsg__Type { EVENTCAST__EVENT_CAST_MSG__TYPE__EVENT_MSG = 6, EVENTCAST__EVENT_CAST_MSG__TYPE__SENSOR_MSG = 7, EVENTCAST__EVENT_CAST_MSG__TYPE__TOUCH_MSG = 8 + PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(EVENTCAST__EVENT_CAST_MSG__TYPE) } Eventcast__EventCastMsg__Type; +/* + * define value + */ typedef enum _Eventcast__MessageResult { EVENTCAST__MESSAGE_RESULT__SUCCESS = 1, EVENTCAST__MESSAGE_RESULT__FAILURE = 2, EVENTCAST__MESSAGE_RESULT__CANCEL = 3 + PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(EVENTCAST__MESSAGE_RESULT) } Eventcast__MessageResult; typedef enum _Eventcast__ConnectionState { EVENTCAST__CONNECTION_STATE__CONNECTED = 1, EVENTCAST__CONNECTION_STATE__DISCONNECTED = 2, EVENTCAST__CONNECTION_STATE__TERMINATED = 3 + PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(EVENTCAST__CONNECTION_STATE) } Eventcast__ConnectionState; typedef enum _Eventcast__EventType { EVENTCAST__EVENT_TYPE__SENSOR = 1, EVENTCAST__EVENT_TYPE__TOUCH = 2 + PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(EVENTCAST__EVENT_TYPE) } Eventcast__EventType; typedef enum _Eventcast__State { EVENTCAST__STATE__ENABLED = 1, EVENTCAST__STATE__DISABLED = 2 + PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(EVENTCAST__STATE) } Eventcast__State; typedef enum _Eventcast__SensorType { EVENTCAST__SENSOR_TYPE__ACCEL = 1, @@ -87,10 +105,12 @@ typedef enum _Eventcast__SensorType { EVENTCAST__SENSOR_TYPE__GYROSCOPE = 3, EVENTCAST__SENSOR_TYPE__PROXIMITY = 4, EVENTCAST__SENSOR_TYPE__LIGHT = 5 + PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(EVENTCAST__SENSOR_TYPE) } Eventcast__SensorType; typedef enum _Eventcast__TouchState { EVENTCAST__TOUCH_STATE__PRESSED = 1, EVENTCAST__TOUCH_STATE__RELEASED = 2 + PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(EVENTCAST__TOUCH_STATE) } Eventcast__TouchState; typedef enum _Eventcast__HWKeyType { EVENTCAST__HWKEY_TYPE__MENU = 1, @@ -99,10 +119,14 @@ typedef enum _Eventcast__HWKeyType { EVENTCAST__HWKEY_TYPE__POWER = 4, EVENTCAST__HWKEY_TYPE__VOLUME_UP = 5, EVENTCAST__HWKEY_TYPE__VOLUME_DOWN = 6 + PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(EVENTCAST__HWKEY_TYPE) } Eventcast__HWKeyType; /* --- messages --- */ +/* + * define messages + */ struct _Eventcast__HandShakeReq { ProtobufCMessage base; @@ -792,7 +816,7 @@ extern const ProtobufCEnumDescriptor eventcast__touch_msg__type__descriptor; extern const ProtobufCMessageDescriptor eventcast__event_cast_msg__descriptor; extern const ProtobufCEnumDescriptor eventcast__event_cast_msg__type__descriptor; -PROTOBUF_C_END_DECLS +PROTOBUF_C__END_DECLS -#endif /* PROTOBUF_eventcast_2eproto__INCLUDED */ +#endif /* PROTOBUF_C_eventcast_2eproto__INCLUDED */ |