A small memory footprint AMQP implimentation
Dependents: iothub_client_sample_amqp remote_monitoring simplesample_amqp
message.c@0:6ae2f7bca550, 2016-04-08 (annotated)
- Committer:
- Azure.IoT Build
- Date:
- Fri Apr 08 12:01:10 2016 -0700
- Revision:
- 0:6ae2f7bca550
- Child:
- 12:b30dacf113f2
1.0.4
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Azure.IoT Build | 0:6ae2f7bca550 | 1 | // Copyright (c) Microsoft. All rights reserved. |
Azure.IoT Build | 0:6ae2f7bca550 | 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. |
Azure.IoT Build | 0:6ae2f7bca550 | 3 | |
Azure.IoT Build | 0:6ae2f7bca550 | 4 | #include <stdlib.h> |
Azure.IoT Build | 0:6ae2f7bca550 | 5 | #ifdef _CRTDBG_MAP_ALLOC |
Azure.IoT Build | 0:6ae2f7bca550 | 6 | #include <crtdbg.h> |
Azure.IoT Build | 0:6ae2f7bca550 | 7 | #endif |
Azure.IoT Build | 0:6ae2f7bca550 | 8 | #include <string.h> |
Azure.IoT Build | 0:6ae2f7bca550 | 9 | #include "azure_uamqp_c/message.h" |
Azure.IoT Build | 0:6ae2f7bca550 | 10 | #include "azure_uamqp_c/amqpvalue.h" |
Azure.IoT Build | 0:6ae2f7bca550 | 11 | #include "azure_uamqp_c/amqpalloc.h" |
Azure.IoT Build | 0:6ae2f7bca550 | 12 | |
Azure.IoT Build | 0:6ae2f7bca550 | 13 | typedef struct BODY_AMQP_DATA_TAG |
Azure.IoT Build | 0:6ae2f7bca550 | 14 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 15 | unsigned char* body_data_section_bytes; |
Azure.IoT Build | 0:6ae2f7bca550 | 16 | size_t body_data_section_length; |
Azure.IoT Build | 0:6ae2f7bca550 | 17 | } BODY_AMQP_DATA; |
Azure.IoT Build | 0:6ae2f7bca550 | 18 | |
Azure.IoT Build | 0:6ae2f7bca550 | 19 | typedef struct MESSAGE_INSTANCE_TAG |
Azure.IoT Build | 0:6ae2f7bca550 | 20 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 21 | BODY_AMQP_DATA* body_amqp_data_items; |
Azure.IoT Build | 0:6ae2f7bca550 | 22 | size_t body_amqp_data_count; |
Azure.IoT Build | 0:6ae2f7bca550 | 23 | AMQP_VALUE* body_amqp_sequence_items; |
Azure.IoT Build | 0:6ae2f7bca550 | 24 | size_t body_amqp_sequence_count; |
Azure.IoT Build | 0:6ae2f7bca550 | 25 | AMQP_VALUE body_amqp_value; |
Azure.IoT Build | 0:6ae2f7bca550 | 26 | HEADER_HANDLE header; |
Azure.IoT Build | 0:6ae2f7bca550 | 27 | annotations delivery_annotations; |
Azure.IoT Build | 0:6ae2f7bca550 | 28 | annotations message_annotations; |
Azure.IoT Build | 0:6ae2f7bca550 | 29 | PROPERTIES_HANDLE properties; |
Azure.IoT Build | 0:6ae2f7bca550 | 30 | application_properties application_properties; |
Azure.IoT Build | 0:6ae2f7bca550 | 31 | annotations footer; |
Azure.IoT Build | 0:6ae2f7bca550 | 32 | uint32_t message_format; |
Azure.IoT Build | 0:6ae2f7bca550 | 33 | } MESSAGE_INSTANCE; |
Azure.IoT Build | 0:6ae2f7bca550 | 34 | |
Azure.IoT Build | 0:6ae2f7bca550 | 35 | static void free_all_body_data_items(MESSAGE_INSTANCE* message_instance) |
Azure.IoT Build | 0:6ae2f7bca550 | 36 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 37 | size_t i; |
Azure.IoT Build | 0:6ae2f7bca550 | 38 | |
Azure.IoT Build | 0:6ae2f7bca550 | 39 | for (i = 0; i < message_instance->body_amqp_data_count; i++) |
Azure.IoT Build | 0:6ae2f7bca550 | 40 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 41 | if (message_instance->body_amqp_data_items[i].body_data_section_bytes != NULL) |
Azure.IoT Build | 0:6ae2f7bca550 | 42 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 43 | amqpalloc_free(message_instance->body_amqp_data_items[i].body_data_section_bytes); |
Azure.IoT Build | 0:6ae2f7bca550 | 44 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 45 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 46 | |
Azure.IoT Build | 0:6ae2f7bca550 | 47 | amqpalloc_free(message_instance->body_amqp_data_items); |
Azure.IoT Build | 0:6ae2f7bca550 | 48 | message_instance->body_amqp_data_count = 0; |
Azure.IoT Build | 0:6ae2f7bca550 | 49 | message_instance->body_amqp_data_items = NULL; |
Azure.IoT Build | 0:6ae2f7bca550 | 50 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 51 | |
Azure.IoT Build | 0:6ae2f7bca550 | 52 | static void free_all_body_sequence_items(MESSAGE_INSTANCE* message_instance) |
Azure.IoT Build | 0:6ae2f7bca550 | 53 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 54 | size_t i; |
Azure.IoT Build | 0:6ae2f7bca550 | 55 | |
Azure.IoT Build | 0:6ae2f7bca550 | 56 | for (i = 0; i < message_instance->body_amqp_sequence_count; i++) |
Azure.IoT Build | 0:6ae2f7bca550 | 57 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 58 | if (message_instance->body_amqp_sequence_items[i] != NULL) |
Azure.IoT Build | 0:6ae2f7bca550 | 59 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 60 | amqpvalue_destroy(message_instance->body_amqp_sequence_items[i]); |
Azure.IoT Build | 0:6ae2f7bca550 | 61 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 62 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 63 | |
Azure.IoT Build | 0:6ae2f7bca550 | 64 | amqpalloc_free(message_instance->body_amqp_sequence_items); |
Azure.IoT Build | 0:6ae2f7bca550 | 65 | message_instance->body_amqp_sequence_count = 0; |
Azure.IoT Build | 0:6ae2f7bca550 | 66 | message_instance->body_amqp_sequence_items = NULL; |
Azure.IoT Build | 0:6ae2f7bca550 | 67 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 68 | |
Azure.IoT Build | 0:6ae2f7bca550 | 69 | MESSAGE_HANDLE message_create(void) |
Azure.IoT Build | 0:6ae2f7bca550 | 70 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 71 | MESSAGE_INSTANCE* result = (MESSAGE_INSTANCE*)amqpalloc_malloc(sizeof(MESSAGE_INSTANCE)); |
Azure.IoT Build | 0:6ae2f7bca550 | 72 | /* Codes_SRS_MESSAGE_01_002: [If allocating memory for the message fails, message_create shall fail and return NULL.] */ |
Azure.IoT Build | 0:6ae2f7bca550 | 73 | if (result != NULL) |
Azure.IoT Build | 0:6ae2f7bca550 | 74 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 75 | result->header = NULL; |
Azure.IoT Build | 0:6ae2f7bca550 | 76 | result->delivery_annotations = NULL; |
Azure.IoT Build | 0:6ae2f7bca550 | 77 | result->message_annotations = NULL; |
Azure.IoT Build | 0:6ae2f7bca550 | 78 | result->properties = NULL; |
Azure.IoT Build | 0:6ae2f7bca550 | 79 | result->application_properties = NULL; |
Azure.IoT Build | 0:6ae2f7bca550 | 80 | result->footer = NULL; |
Azure.IoT Build | 0:6ae2f7bca550 | 81 | result->body_amqp_data_items = NULL; |
Azure.IoT Build | 0:6ae2f7bca550 | 82 | result->body_amqp_data_count = 0; |
Azure.IoT Build | 0:6ae2f7bca550 | 83 | result->body_amqp_value = NULL; |
Azure.IoT Build | 0:6ae2f7bca550 | 84 | result->body_amqp_sequence_items = NULL; |
Azure.IoT Build | 0:6ae2f7bca550 | 85 | result->body_amqp_sequence_count = 0; |
Azure.IoT Build | 0:6ae2f7bca550 | 86 | result->message_format = 0; |
Azure.IoT Build | 0:6ae2f7bca550 | 87 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 88 | |
Azure.IoT Build | 0:6ae2f7bca550 | 89 | /* Codes_SRS_MESSAGE_01_001: [message_create shall create a new AMQP message instance and on success it shall return a non-NULL handle for the newly created message instance.] */ |
Azure.IoT Build | 0:6ae2f7bca550 | 90 | return result; |
Azure.IoT Build | 0:6ae2f7bca550 | 91 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 92 | |
Azure.IoT Build | 0:6ae2f7bca550 | 93 | MESSAGE_HANDLE message_clone(MESSAGE_HANDLE source_message) |
Azure.IoT Build | 0:6ae2f7bca550 | 94 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 95 | MESSAGE_INSTANCE* result; |
Azure.IoT Build | 0:6ae2f7bca550 | 96 | |
Azure.IoT Build | 0:6ae2f7bca550 | 97 | /* Codes_SRS_MESSAGE_01_062: [If source_message is NULL, message_clone shall fail and return NULL.] */ |
Azure.IoT Build | 0:6ae2f7bca550 | 98 | if (source_message == NULL) |
Azure.IoT Build | 0:6ae2f7bca550 | 99 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 100 | result = NULL; |
Azure.IoT Build | 0:6ae2f7bca550 | 101 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 102 | else |
Azure.IoT Build | 0:6ae2f7bca550 | 103 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 104 | MESSAGE_INSTANCE* source_message_instance = (MESSAGE_INSTANCE*)source_message; |
Azure.IoT Build | 0:6ae2f7bca550 | 105 | result = (MESSAGE_INSTANCE*)message_create(); |
Azure.IoT Build | 0:6ae2f7bca550 | 106 | |
Azure.IoT Build | 0:6ae2f7bca550 | 107 | /* Codes_SRS_MESSAGE_01_003: [message_clone shall clone a message entirely and on success return a non-NULL handle to the cloned message.] */ |
Azure.IoT Build | 0:6ae2f7bca550 | 108 | /* Codes_SRS_MESSAGE_01_004: [If allocating memory for the new cloned message fails, message_clone shall fail and return NULL.] */ |
Azure.IoT Build | 0:6ae2f7bca550 | 109 | if (result != NULL) |
Azure.IoT Build | 0:6ae2f7bca550 | 110 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 111 | result->message_format = source_message_instance->message_format; |
Azure.IoT Build | 0:6ae2f7bca550 | 112 | |
Azure.IoT Build | 0:6ae2f7bca550 | 113 | if (source_message_instance->header != NULL) |
Azure.IoT Build | 0:6ae2f7bca550 | 114 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 115 | /* Codes_SRS_MESSAGE_01_005: [If a header exists on the source message it shall be cloned by using header_clone.] */ |
Azure.IoT Build | 0:6ae2f7bca550 | 116 | result->header = header_clone(source_message_instance->header); |
Azure.IoT Build | 0:6ae2f7bca550 | 117 | if (result->header == NULL) |
Azure.IoT Build | 0:6ae2f7bca550 | 118 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 119 | message_destroy(result); |
Azure.IoT Build | 0:6ae2f7bca550 | 120 | result = NULL; |
Azure.IoT Build | 0:6ae2f7bca550 | 121 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 122 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 123 | |
Azure.IoT Build | 0:6ae2f7bca550 | 124 | if ((result != NULL) && (source_message_instance->delivery_annotations != NULL)) |
Azure.IoT Build | 0:6ae2f7bca550 | 125 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 126 | /* Codes_SRS_MESSAGE_01_006: [If delivery annotations exist on the source message they shall be cloned by using annotations_clone.] */ |
Azure.IoT Build | 0:6ae2f7bca550 | 127 | result->delivery_annotations = annotations_clone(source_message_instance->delivery_annotations); |
Azure.IoT Build | 0:6ae2f7bca550 | 128 | if (result->delivery_annotations == NULL) |
Azure.IoT Build | 0:6ae2f7bca550 | 129 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 130 | message_destroy(result); |
Azure.IoT Build | 0:6ae2f7bca550 | 131 | result = NULL; |
Azure.IoT Build | 0:6ae2f7bca550 | 132 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 133 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 134 | |
Azure.IoT Build | 0:6ae2f7bca550 | 135 | if ((result != NULL) && (source_message_instance->message_annotations != NULL)) |
Azure.IoT Build | 0:6ae2f7bca550 | 136 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 137 | /* Codes_SRS_MESSAGE_01_007: [If message annotations exist on the source message they shall be cloned by using annotations_clone.] */ |
Azure.IoT Build | 0:6ae2f7bca550 | 138 | result->message_annotations = annotations_clone(source_message_instance->message_annotations); |
Azure.IoT Build | 0:6ae2f7bca550 | 139 | if (result->message_annotations == NULL) |
Azure.IoT Build | 0:6ae2f7bca550 | 140 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 141 | message_destroy(result); |
Azure.IoT Build | 0:6ae2f7bca550 | 142 | result = NULL; |
Azure.IoT Build | 0:6ae2f7bca550 | 143 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 144 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 145 | |
Azure.IoT Build | 0:6ae2f7bca550 | 146 | if ((result != NULL) && (source_message_instance->properties != NULL)) |
Azure.IoT Build | 0:6ae2f7bca550 | 147 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 148 | /* Codes_SRS_MESSAGE_01_008: [If message properties exist on the source message they shall be cloned by using properties_clone.] */ |
Azure.IoT Build | 0:6ae2f7bca550 | 149 | result->properties = properties_clone(source_message_instance->properties); |
Azure.IoT Build | 0:6ae2f7bca550 | 150 | if (result->properties == NULL) |
Azure.IoT Build | 0:6ae2f7bca550 | 151 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 152 | message_destroy(result); |
Azure.IoT Build | 0:6ae2f7bca550 | 153 | result = NULL; |
Azure.IoT Build | 0:6ae2f7bca550 | 154 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 155 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 156 | |
Azure.IoT Build | 0:6ae2f7bca550 | 157 | if ((result != NULL) && (source_message_instance->application_properties != NULL)) |
Azure.IoT Build | 0:6ae2f7bca550 | 158 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 159 | /* Codes_SRS_MESSAGE_01_009: [If application properties exist on the source message they shall be cloned by using amqpvalue_clone.] */ |
Azure.IoT Build | 0:6ae2f7bca550 | 160 | result->application_properties = amqpvalue_clone(source_message_instance->application_properties); |
Azure.IoT Build | 0:6ae2f7bca550 | 161 | if (result->application_properties == NULL) |
Azure.IoT Build | 0:6ae2f7bca550 | 162 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 163 | message_destroy(result); |
Azure.IoT Build | 0:6ae2f7bca550 | 164 | result = NULL; |
Azure.IoT Build | 0:6ae2f7bca550 | 165 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 166 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 167 | |
Azure.IoT Build | 0:6ae2f7bca550 | 168 | if ((result != NULL) && (source_message_instance->footer != NULL)) |
Azure.IoT Build | 0:6ae2f7bca550 | 169 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 170 | /* Codes_SRS_MESSAGE_01_010: [If a footer exists on the source message it shall be cloned by using annotations_clone.] */ |
Azure.IoT Build | 0:6ae2f7bca550 | 171 | result->footer = amqpvalue_clone(source_message_instance->footer); |
Azure.IoT Build | 0:6ae2f7bca550 | 172 | if (result->footer == NULL) |
Azure.IoT Build | 0:6ae2f7bca550 | 173 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 174 | message_destroy(result); |
Azure.IoT Build | 0:6ae2f7bca550 | 175 | result = NULL; |
Azure.IoT Build | 0:6ae2f7bca550 | 176 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 177 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 178 | |
Azure.IoT Build | 0:6ae2f7bca550 | 179 | if ((result != NULL) && (source_message_instance->body_amqp_data_count > 0)) |
Azure.IoT Build | 0:6ae2f7bca550 | 180 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 181 | size_t i; |
Azure.IoT Build | 0:6ae2f7bca550 | 182 | |
Azure.IoT Build | 0:6ae2f7bca550 | 183 | result->body_amqp_data_items = (BODY_AMQP_DATA*)amqpalloc_malloc(source_message_instance->body_amqp_data_count * sizeof(BODY_AMQP_DATA)); |
Azure.IoT Build | 0:6ae2f7bca550 | 184 | if (result->body_amqp_data_items == NULL) |
Azure.IoT Build | 0:6ae2f7bca550 | 185 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 186 | message_destroy(result); |
Azure.IoT Build | 0:6ae2f7bca550 | 187 | result = NULL; |
Azure.IoT Build | 0:6ae2f7bca550 | 188 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 189 | else |
Azure.IoT Build | 0:6ae2f7bca550 | 190 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 191 | for (i = 0; i < source_message_instance->body_amqp_data_count; i++) |
Azure.IoT Build | 0:6ae2f7bca550 | 192 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 193 | result->body_amqp_data_items[i].body_data_section_length = source_message_instance->body_amqp_data_items[i].body_data_section_length; |
Azure.IoT Build | 0:6ae2f7bca550 | 194 | |
Azure.IoT Build | 0:6ae2f7bca550 | 195 | /* Codes_SRS_MESSAGE_01_011: [If an AMQP data has been set as message body on the source message it shall be cloned by allocating memory for the binary payload.] */ |
Azure.IoT Build | 0:6ae2f7bca550 | 196 | result->body_amqp_data_items[i].body_data_section_bytes = amqpalloc_malloc(source_message_instance->body_amqp_data_items[i].body_data_section_length); |
Azure.IoT Build | 0:6ae2f7bca550 | 197 | if (result->body_amqp_data_items[i].body_data_section_bytes == NULL) |
Azure.IoT Build | 0:6ae2f7bca550 | 198 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 199 | break; |
Azure.IoT Build | 0:6ae2f7bca550 | 200 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 201 | else |
Azure.IoT Build | 0:6ae2f7bca550 | 202 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 203 | (void)memcpy(result->body_amqp_data_items[i].body_data_section_bytes, source_message_instance->body_amqp_data_items[i].body_data_section_bytes, result->body_amqp_data_items[i].body_data_section_length); |
Azure.IoT Build | 0:6ae2f7bca550 | 204 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 205 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 206 | |
Azure.IoT Build | 0:6ae2f7bca550 | 207 | result->body_amqp_data_count = i; |
Azure.IoT Build | 0:6ae2f7bca550 | 208 | if (i < source_message_instance->body_amqp_data_count) |
Azure.IoT Build | 0:6ae2f7bca550 | 209 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 210 | message_destroy(result); |
Azure.IoT Build | 0:6ae2f7bca550 | 211 | result = NULL; |
Azure.IoT Build | 0:6ae2f7bca550 | 212 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 213 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 214 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 215 | |
Azure.IoT Build | 0:6ae2f7bca550 | 216 | if ((result != NULL) && (source_message_instance->body_amqp_sequence_count > 0)) |
Azure.IoT Build | 0:6ae2f7bca550 | 217 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 218 | size_t i; |
Azure.IoT Build | 0:6ae2f7bca550 | 219 | |
Azure.IoT Build | 0:6ae2f7bca550 | 220 | result->body_amqp_sequence_items = (AMQP_VALUE*)amqpalloc_malloc(source_message_instance->body_amqp_sequence_count * sizeof(AMQP_VALUE)); |
Azure.IoT Build | 0:6ae2f7bca550 | 221 | if (result->body_amqp_sequence_items == NULL) |
Azure.IoT Build | 0:6ae2f7bca550 | 222 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 223 | message_destroy(result); |
Azure.IoT Build | 0:6ae2f7bca550 | 224 | result = NULL; |
Azure.IoT Build | 0:6ae2f7bca550 | 225 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 226 | else |
Azure.IoT Build | 0:6ae2f7bca550 | 227 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 228 | for (i = 0; i < source_message_instance->body_amqp_sequence_count; i++) |
Azure.IoT Build | 0:6ae2f7bca550 | 229 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 230 | /* Codes_SRS_MESSAGE_01_011: [If an AMQP data has been set as message body on the source message it shall be cloned by allocating memory for the binary payload.] */ |
Azure.IoT Build | 0:6ae2f7bca550 | 231 | result->body_amqp_sequence_items[i] = amqpvalue_clone(source_message_instance->body_amqp_sequence_items[i]); |
Azure.IoT Build | 0:6ae2f7bca550 | 232 | if (result->body_amqp_sequence_items[i] == NULL) |
Azure.IoT Build | 0:6ae2f7bca550 | 233 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 234 | break; |
Azure.IoT Build | 0:6ae2f7bca550 | 235 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 236 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 237 | |
Azure.IoT Build | 0:6ae2f7bca550 | 238 | result->body_amqp_sequence_count = i; |
Azure.IoT Build | 0:6ae2f7bca550 | 239 | if (i < source_message_instance->body_amqp_sequence_count) |
Azure.IoT Build | 0:6ae2f7bca550 | 240 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 241 | message_destroy(result); |
Azure.IoT Build | 0:6ae2f7bca550 | 242 | result = NULL; |
Azure.IoT Build | 0:6ae2f7bca550 | 243 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 244 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 245 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 246 | |
Azure.IoT Build | 0:6ae2f7bca550 | 247 | if ((result != NULL) && (source_message_instance->body_amqp_value != NULL)) |
Azure.IoT Build | 0:6ae2f7bca550 | 248 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 249 | result->body_amqp_value = amqpvalue_clone(source_message_instance->body_amqp_value); |
Azure.IoT Build | 0:6ae2f7bca550 | 250 | if (result->body_amqp_value == NULL) |
Azure.IoT Build | 0:6ae2f7bca550 | 251 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 252 | message_destroy(result); |
Azure.IoT Build | 0:6ae2f7bca550 | 253 | result = NULL; |
Azure.IoT Build | 0:6ae2f7bca550 | 254 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 255 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 256 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 257 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 258 | |
Azure.IoT Build | 0:6ae2f7bca550 | 259 | return result; |
Azure.IoT Build | 0:6ae2f7bca550 | 260 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 261 | |
Azure.IoT Build | 0:6ae2f7bca550 | 262 | void message_destroy(MESSAGE_HANDLE message) |
Azure.IoT Build | 0:6ae2f7bca550 | 263 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 264 | if (message != NULL) |
Azure.IoT Build | 0:6ae2f7bca550 | 265 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 266 | MESSAGE_INSTANCE* message_instance = (MESSAGE_INSTANCE*)message; |
Azure.IoT Build | 0:6ae2f7bca550 | 267 | |
Azure.IoT Build | 0:6ae2f7bca550 | 268 | if (message_instance->header != NULL) |
Azure.IoT Build | 0:6ae2f7bca550 | 269 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 270 | header_destroy(message_instance->header); |
Azure.IoT Build | 0:6ae2f7bca550 | 271 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 272 | if (message_instance->properties != NULL) |
Azure.IoT Build | 0:6ae2f7bca550 | 273 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 274 | properties_destroy(message_instance->properties); |
Azure.IoT Build | 0:6ae2f7bca550 | 275 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 276 | if (message_instance->application_properties != NULL) |
Azure.IoT Build | 0:6ae2f7bca550 | 277 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 278 | application_properties_destroy(message_instance->application_properties); |
Azure.IoT Build | 0:6ae2f7bca550 | 279 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 280 | if (message_instance->footer != NULL) |
Azure.IoT Build | 0:6ae2f7bca550 | 281 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 282 | annotations_destroy(message_instance->footer); |
Azure.IoT Build | 0:6ae2f7bca550 | 283 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 284 | if (message_instance->body_amqp_value != NULL) |
Azure.IoT Build | 0:6ae2f7bca550 | 285 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 286 | amqpvalue_destroy(message_instance->body_amqp_value); |
Azure.IoT Build | 0:6ae2f7bca550 | 287 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 288 | if (message_instance->message_annotations != NULL) |
Azure.IoT Build | 0:6ae2f7bca550 | 289 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 290 | application_properties_destroy(message_instance->message_annotations); |
Azure.IoT Build | 0:6ae2f7bca550 | 291 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 292 | |
Azure.IoT Build | 0:6ae2f7bca550 | 293 | free_all_body_data_items(message_instance); |
Azure.IoT Build | 0:6ae2f7bca550 | 294 | free_all_body_sequence_items(message_instance); |
Azure.IoT Build | 0:6ae2f7bca550 | 295 | amqpalloc_free(message_instance); |
Azure.IoT Build | 0:6ae2f7bca550 | 296 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 297 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 298 | |
Azure.IoT Build | 0:6ae2f7bca550 | 299 | int message_set_header(MESSAGE_HANDLE message, HEADER_HANDLE header) |
Azure.IoT Build | 0:6ae2f7bca550 | 300 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 301 | int result; |
Azure.IoT Build | 0:6ae2f7bca550 | 302 | |
Azure.IoT Build | 0:6ae2f7bca550 | 303 | if ((message == NULL) || |
Azure.IoT Build | 0:6ae2f7bca550 | 304 | (header == NULL)) |
Azure.IoT Build | 0:6ae2f7bca550 | 305 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 306 | result = __LINE__; |
Azure.IoT Build | 0:6ae2f7bca550 | 307 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 308 | else |
Azure.IoT Build | 0:6ae2f7bca550 | 309 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 310 | MESSAGE_INSTANCE* message_instance = (MESSAGE_INSTANCE*)message; |
Azure.IoT Build | 0:6ae2f7bca550 | 311 | HEADER_HANDLE new_header; |
Azure.IoT Build | 0:6ae2f7bca550 | 312 | |
Azure.IoT Build | 0:6ae2f7bca550 | 313 | new_header = header_clone(header); |
Azure.IoT Build | 0:6ae2f7bca550 | 314 | if (new_header == NULL) |
Azure.IoT Build | 0:6ae2f7bca550 | 315 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 316 | result = __LINE__; |
Azure.IoT Build | 0:6ae2f7bca550 | 317 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 318 | else |
Azure.IoT Build | 0:6ae2f7bca550 | 319 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 320 | if (message_instance->header != NULL) |
Azure.IoT Build | 0:6ae2f7bca550 | 321 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 322 | header_destroy(message_instance->header); |
Azure.IoT Build | 0:6ae2f7bca550 | 323 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 324 | |
Azure.IoT Build | 0:6ae2f7bca550 | 325 | message_instance->header = new_header; |
Azure.IoT Build | 0:6ae2f7bca550 | 326 | result = 0; |
Azure.IoT Build | 0:6ae2f7bca550 | 327 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 328 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 329 | |
Azure.IoT Build | 0:6ae2f7bca550 | 330 | return result; |
Azure.IoT Build | 0:6ae2f7bca550 | 331 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 332 | |
Azure.IoT Build | 0:6ae2f7bca550 | 333 | int message_get_header(MESSAGE_HANDLE message, HEADER_HANDLE* header) |
Azure.IoT Build | 0:6ae2f7bca550 | 334 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 335 | int result; |
Azure.IoT Build | 0:6ae2f7bca550 | 336 | |
Azure.IoT Build | 0:6ae2f7bca550 | 337 | if ((message == NULL) || |
Azure.IoT Build | 0:6ae2f7bca550 | 338 | (header == NULL)) |
Azure.IoT Build | 0:6ae2f7bca550 | 339 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 340 | result = __LINE__; |
Azure.IoT Build | 0:6ae2f7bca550 | 341 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 342 | else |
Azure.IoT Build | 0:6ae2f7bca550 | 343 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 344 | MESSAGE_INSTANCE* message_instance = (MESSAGE_INSTANCE*)message; |
Azure.IoT Build | 0:6ae2f7bca550 | 345 | |
Azure.IoT Build | 0:6ae2f7bca550 | 346 | if (message_instance->header == NULL) |
Azure.IoT Build | 0:6ae2f7bca550 | 347 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 348 | *header = NULL; |
Azure.IoT Build | 0:6ae2f7bca550 | 349 | result = 0; |
Azure.IoT Build | 0:6ae2f7bca550 | 350 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 351 | else |
Azure.IoT Build | 0:6ae2f7bca550 | 352 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 353 | *header = header_clone(message_instance->header); |
Azure.IoT Build | 0:6ae2f7bca550 | 354 | if (*header == NULL) |
Azure.IoT Build | 0:6ae2f7bca550 | 355 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 356 | result = __LINE__; |
Azure.IoT Build | 0:6ae2f7bca550 | 357 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 358 | else |
Azure.IoT Build | 0:6ae2f7bca550 | 359 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 360 | result = 0; |
Azure.IoT Build | 0:6ae2f7bca550 | 361 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 362 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 363 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 364 | |
Azure.IoT Build | 0:6ae2f7bca550 | 365 | return result; |
Azure.IoT Build | 0:6ae2f7bca550 | 366 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 367 | |
Azure.IoT Build | 0:6ae2f7bca550 | 368 | int message_set_delivery_annotations(MESSAGE_HANDLE message, annotations delivery_annotations) |
Azure.IoT Build | 0:6ae2f7bca550 | 369 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 370 | int result; |
Azure.IoT Build | 0:6ae2f7bca550 | 371 | |
Azure.IoT Build | 0:6ae2f7bca550 | 372 | if ((message == NULL) || |
Azure.IoT Build | 0:6ae2f7bca550 | 373 | (delivery_annotations == NULL)) |
Azure.IoT Build | 0:6ae2f7bca550 | 374 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 375 | result = __LINE__; |
Azure.IoT Build | 0:6ae2f7bca550 | 376 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 377 | else |
Azure.IoT Build | 0:6ae2f7bca550 | 378 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 379 | MESSAGE_INSTANCE* message_instance = (MESSAGE_INSTANCE*)message; |
Azure.IoT Build | 0:6ae2f7bca550 | 380 | annotations new_delivery_annotations; |
Azure.IoT Build | 0:6ae2f7bca550 | 381 | |
Azure.IoT Build | 0:6ae2f7bca550 | 382 | new_delivery_annotations = annotations_clone(delivery_annotations); |
Azure.IoT Build | 0:6ae2f7bca550 | 383 | if (new_delivery_annotations == NULL) |
Azure.IoT Build | 0:6ae2f7bca550 | 384 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 385 | result = __LINE__; |
Azure.IoT Build | 0:6ae2f7bca550 | 386 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 387 | else |
Azure.IoT Build | 0:6ae2f7bca550 | 388 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 389 | if (message_instance->delivery_annotations != NULL) |
Azure.IoT Build | 0:6ae2f7bca550 | 390 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 391 | annotations_destroy(message_instance->delivery_annotations); |
Azure.IoT Build | 0:6ae2f7bca550 | 392 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 393 | message_instance->delivery_annotations = new_delivery_annotations; |
Azure.IoT Build | 0:6ae2f7bca550 | 394 | result = 0; |
Azure.IoT Build | 0:6ae2f7bca550 | 395 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 396 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 397 | |
Azure.IoT Build | 0:6ae2f7bca550 | 398 | return result; |
Azure.IoT Build | 0:6ae2f7bca550 | 399 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 400 | |
Azure.IoT Build | 0:6ae2f7bca550 | 401 | int message_get_delivery_annotations(MESSAGE_HANDLE message, annotations* delivery_annotations) |
Azure.IoT Build | 0:6ae2f7bca550 | 402 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 403 | int result; |
Azure.IoT Build | 0:6ae2f7bca550 | 404 | |
Azure.IoT Build | 0:6ae2f7bca550 | 405 | if ((message == NULL) || |
Azure.IoT Build | 0:6ae2f7bca550 | 406 | (delivery_annotations == NULL)) |
Azure.IoT Build | 0:6ae2f7bca550 | 407 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 408 | result = __LINE__; |
Azure.IoT Build | 0:6ae2f7bca550 | 409 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 410 | else |
Azure.IoT Build | 0:6ae2f7bca550 | 411 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 412 | MESSAGE_INSTANCE* message_instance = (MESSAGE_INSTANCE*)message; |
Azure.IoT Build | 0:6ae2f7bca550 | 413 | |
Azure.IoT Build | 0:6ae2f7bca550 | 414 | if (message_instance->delivery_annotations == NULL) |
Azure.IoT Build | 0:6ae2f7bca550 | 415 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 416 | *delivery_annotations = NULL; |
Azure.IoT Build | 0:6ae2f7bca550 | 417 | result = 0; |
Azure.IoT Build | 0:6ae2f7bca550 | 418 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 419 | else |
Azure.IoT Build | 0:6ae2f7bca550 | 420 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 421 | *delivery_annotations = annotations_clone(message_instance->delivery_annotations); |
Azure.IoT Build | 0:6ae2f7bca550 | 422 | if (*delivery_annotations == NULL) |
Azure.IoT Build | 0:6ae2f7bca550 | 423 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 424 | result = __LINE__; |
Azure.IoT Build | 0:6ae2f7bca550 | 425 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 426 | else |
Azure.IoT Build | 0:6ae2f7bca550 | 427 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 428 | result = 0; |
Azure.IoT Build | 0:6ae2f7bca550 | 429 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 430 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 431 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 432 | |
Azure.IoT Build | 0:6ae2f7bca550 | 433 | return result; |
Azure.IoT Build | 0:6ae2f7bca550 | 434 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 435 | |
Azure.IoT Build | 0:6ae2f7bca550 | 436 | int message_set_message_annotations(MESSAGE_HANDLE message, annotations message_annotations) |
Azure.IoT Build | 0:6ae2f7bca550 | 437 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 438 | int result; |
Azure.IoT Build | 0:6ae2f7bca550 | 439 | |
Azure.IoT Build | 0:6ae2f7bca550 | 440 | if ((message == NULL) || |
Azure.IoT Build | 0:6ae2f7bca550 | 441 | (message_annotations == NULL)) |
Azure.IoT Build | 0:6ae2f7bca550 | 442 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 443 | result = __LINE__; |
Azure.IoT Build | 0:6ae2f7bca550 | 444 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 445 | else |
Azure.IoT Build | 0:6ae2f7bca550 | 446 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 447 | MESSAGE_INSTANCE* message_instance = (MESSAGE_INSTANCE*)message; |
Azure.IoT Build | 0:6ae2f7bca550 | 448 | annotations new_message_annotations; |
Azure.IoT Build | 0:6ae2f7bca550 | 449 | |
Azure.IoT Build | 0:6ae2f7bca550 | 450 | new_message_annotations = annotations_clone(message_annotations); |
Azure.IoT Build | 0:6ae2f7bca550 | 451 | if (new_message_annotations == NULL) |
Azure.IoT Build | 0:6ae2f7bca550 | 452 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 453 | result = __LINE__; |
Azure.IoT Build | 0:6ae2f7bca550 | 454 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 455 | else |
Azure.IoT Build | 0:6ae2f7bca550 | 456 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 457 | if (message_instance->message_annotations != NULL) |
Azure.IoT Build | 0:6ae2f7bca550 | 458 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 459 | annotations_destroy(message_instance->message_annotations); |
Azure.IoT Build | 0:6ae2f7bca550 | 460 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 461 | |
Azure.IoT Build | 0:6ae2f7bca550 | 462 | message_instance->message_annotations = new_message_annotations; |
Azure.IoT Build | 0:6ae2f7bca550 | 463 | result = 0; |
Azure.IoT Build | 0:6ae2f7bca550 | 464 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 465 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 466 | |
Azure.IoT Build | 0:6ae2f7bca550 | 467 | return result; |
Azure.IoT Build | 0:6ae2f7bca550 | 468 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 469 | |
Azure.IoT Build | 0:6ae2f7bca550 | 470 | int message_get_message_annotations(MESSAGE_HANDLE message, annotations* message_annotations) |
Azure.IoT Build | 0:6ae2f7bca550 | 471 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 472 | int result; |
Azure.IoT Build | 0:6ae2f7bca550 | 473 | |
Azure.IoT Build | 0:6ae2f7bca550 | 474 | if ((message == NULL) || |
Azure.IoT Build | 0:6ae2f7bca550 | 475 | (message_annotations == NULL)) |
Azure.IoT Build | 0:6ae2f7bca550 | 476 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 477 | result = __LINE__; |
Azure.IoT Build | 0:6ae2f7bca550 | 478 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 479 | else |
Azure.IoT Build | 0:6ae2f7bca550 | 480 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 481 | MESSAGE_INSTANCE* message_instance = (MESSAGE_INSTANCE*)message; |
Azure.IoT Build | 0:6ae2f7bca550 | 482 | |
Azure.IoT Build | 0:6ae2f7bca550 | 483 | if (message_instance->message_annotations == NULL) |
Azure.IoT Build | 0:6ae2f7bca550 | 484 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 485 | *message_annotations = NULL; |
Azure.IoT Build | 0:6ae2f7bca550 | 486 | result = 0; |
Azure.IoT Build | 0:6ae2f7bca550 | 487 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 488 | else |
Azure.IoT Build | 0:6ae2f7bca550 | 489 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 490 | *message_annotations = annotations_clone(message_instance->message_annotations); |
Azure.IoT Build | 0:6ae2f7bca550 | 491 | if (*message_annotations == NULL) |
Azure.IoT Build | 0:6ae2f7bca550 | 492 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 493 | result = __LINE__; |
Azure.IoT Build | 0:6ae2f7bca550 | 494 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 495 | else |
Azure.IoT Build | 0:6ae2f7bca550 | 496 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 497 | result = 0; |
Azure.IoT Build | 0:6ae2f7bca550 | 498 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 499 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 500 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 501 | |
Azure.IoT Build | 0:6ae2f7bca550 | 502 | return result; |
Azure.IoT Build | 0:6ae2f7bca550 | 503 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 504 | |
Azure.IoT Build | 0:6ae2f7bca550 | 505 | int message_set_properties(MESSAGE_HANDLE message, PROPERTIES_HANDLE properties) |
Azure.IoT Build | 0:6ae2f7bca550 | 506 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 507 | int result; |
Azure.IoT Build | 0:6ae2f7bca550 | 508 | |
Azure.IoT Build | 0:6ae2f7bca550 | 509 | if ((message == NULL) || |
Azure.IoT Build | 0:6ae2f7bca550 | 510 | (properties == NULL)) |
Azure.IoT Build | 0:6ae2f7bca550 | 511 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 512 | result = __LINE__; |
Azure.IoT Build | 0:6ae2f7bca550 | 513 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 514 | else |
Azure.IoT Build | 0:6ae2f7bca550 | 515 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 516 | MESSAGE_INSTANCE* message_instance = (MESSAGE_INSTANCE*)message; |
Azure.IoT Build | 0:6ae2f7bca550 | 517 | PROPERTIES_HANDLE new_properties; |
Azure.IoT Build | 0:6ae2f7bca550 | 518 | |
Azure.IoT Build | 0:6ae2f7bca550 | 519 | new_properties = properties_clone(properties); |
Azure.IoT Build | 0:6ae2f7bca550 | 520 | if (new_properties == NULL) |
Azure.IoT Build | 0:6ae2f7bca550 | 521 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 522 | result = __LINE__; |
Azure.IoT Build | 0:6ae2f7bca550 | 523 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 524 | else |
Azure.IoT Build | 0:6ae2f7bca550 | 525 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 526 | if (message_instance->properties != NULL) |
Azure.IoT Build | 0:6ae2f7bca550 | 527 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 528 | properties_destroy(message_instance->properties); |
Azure.IoT Build | 0:6ae2f7bca550 | 529 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 530 | |
Azure.IoT Build | 0:6ae2f7bca550 | 531 | message_instance->properties = new_properties; |
Azure.IoT Build | 0:6ae2f7bca550 | 532 | result = 0; |
Azure.IoT Build | 0:6ae2f7bca550 | 533 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 534 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 535 | |
Azure.IoT Build | 0:6ae2f7bca550 | 536 | return result; |
Azure.IoT Build | 0:6ae2f7bca550 | 537 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 538 | |
Azure.IoT Build | 0:6ae2f7bca550 | 539 | int message_get_properties(MESSAGE_HANDLE message, PROPERTIES_HANDLE* properties) |
Azure.IoT Build | 0:6ae2f7bca550 | 540 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 541 | int result; |
Azure.IoT Build | 0:6ae2f7bca550 | 542 | |
Azure.IoT Build | 0:6ae2f7bca550 | 543 | if ((message == NULL) || |
Azure.IoT Build | 0:6ae2f7bca550 | 544 | (properties == NULL)) |
Azure.IoT Build | 0:6ae2f7bca550 | 545 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 546 | result = __LINE__; |
Azure.IoT Build | 0:6ae2f7bca550 | 547 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 548 | else |
Azure.IoT Build | 0:6ae2f7bca550 | 549 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 550 | MESSAGE_INSTANCE* message_instance = (MESSAGE_INSTANCE*)message; |
Azure.IoT Build | 0:6ae2f7bca550 | 551 | |
Azure.IoT Build | 0:6ae2f7bca550 | 552 | if (message_instance->properties == NULL) |
Azure.IoT Build | 0:6ae2f7bca550 | 553 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 554 | *properties = NULL; |
Azure.IoT Build | 0:6ae2f7bca550 | 555 | result = 0; |
Azure.IoT Build | 0:6ae2f7bca550 | 556 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 557 | else |
Azure.IoT Build | 0:6ae2f7bca550 | 558 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 559 | *properties = properties_clone(message_instance->properties); |
Azure.IoT Build | 0:6ae2f7bca550 | 560 | if (*properties == NULL) |
Azure.IoT Build | 0:6ae2f7bca550 | 561 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 562 | result = __LINE__; |
Azure.IoT Build | 0:6ae2f7bca550 | 563 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 564 | else |
Azure.IoT Build | 0:6ae2f7bca550 | 565 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 566 | result = 0; |
Azure.IoT Build | 0:6ae2f7bca550 | 567 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 568 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 569 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 570 | |
Azure.IoT Build | 0:6ae2f7bca550 | 571 | return result; |
Azure.IoT Build | 0:6ae2f7bca550 | 572 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 573 | |
Azure.IoT Build | 0:6ae2f7bca550 | 574 | int message_set_application_properties(MESSAGE_HANDLE message, AMQP_VALUE application_properties) |
Azure.IoT Build | 0:6ae2f7bca550 | 575 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 576 | int result; |
Azure.IoT Build | 0:6ae2f7bca550 | 577 | |
Azure.IoT Build | 0:6ae2f7bca550 | 578 | if ((message == NULL) || |
Azure.IoT Build | 0:6ae2f7bca550 | 579 | (application_properties == NULL)) |
Azure.IoT Build | 0:6ae2f7bca550 | 580 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 581 | result = __LINE__; |
Azure.IoT Build | 0:6ae2f7bca550 | 582 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 583 | else |
Azure.IoT Build | 0:6ae2f7bca550 | 584 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 585 | MESSAGE_INSTANCE* message_instance = (MESSAGE_INSTANCE*)message; |
Azure.IoT Build | 0:6ae2f7bca550 | 586 | AMQP_VALUE new_application_properties; |
Azure.IoT Build | 0:6ae2f7bca550 | 587 | |
Azure.IoT Build | 0:6ae2f7bca550 | 588 | new_application_properties = application_properties_clone(application_properties); |
Azure.IoT Build | 0:6ae2f7bca550 | 589 | if (new_application_properties == NULL) |
Azure.IoT Build | 0:6ae2f7bca550 | 590 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 591 | result = __LINE__; |
Azure.IoT Build | 0:6ae2f7bca550 | 592 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 593 | else |
Azure.IoT Build | 0:6ae2f7bca550 | 594 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 595 | if (message_instance->application_properties != NULL) |
Azure.IoT Build | 0:6ae2f7bca550 | 596 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 597 | amqpvalue_destroy(message_instance->application_properties); |
Azure.IoT Build | 0:6ae2f7bca550 | 598 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 599 | |
Azure.IoT Build | 0:6ae2f7bca550 | 600 | message_instance->application_properties = new_application_properties; |
Azure.IoT Build | 0:6ae2f7bca550 | 601 | result = 0; |
Azure.IoT Build | 0:6ae2f7bca550 | 602 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 603 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 604 | |
Azure.IoT Build | 0:6ae2f7bca550 | 605 | return result; |
Azure.IoT Build | 0:6ae2f7bca550 | 606 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 607 | |
Azure.IoT Build | 0:6ae2f7bca550 | 608 | int message_get_application_properties(MESSAGE_HANDLE message, AMQP_VALUE* application_properties) |
Azure.IoT Build | 0:6ae2f7bca550 | 609 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 610 | int result; |
Azure.IoT Build | 0:6ae2f7bca550 | 611 | |
Azure.IoT Build | 0:6ae2f7bca550 | 612 | if ((message == NULL) || |
Azure.IoT Build | 0:6ae2f7bca550 | 613 | (application_properties == NULL)) |
Azure.IoT Build | 0:6ae2f7bca550 | 614 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 615 | result = __LINE__; |
Azure.IoT Build | 0:6ae2f7bca550 | 616 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 617 | else |
Azure.IoT Build | 0:6ae2f7bca550 | 618 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 619 | MESSAGE_INSTANCE* message_instance = (MESSAGE_INSTANCE*)message; |
Azure.IoT Build | 0:6ae2f7bca550 | 620 | |
Azure.IoT Build | 0:6ae2f7bca550 | 621 | if (message_instance->application_properties == NULL) |
Azure.IoT Build | 0:6ae2f7bca550 | 622 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 623 | *application_properties = NULL; |
Azure.IoT Build | 0:6ae2f7bca550 | 624 | result = 0; |
Azure.IoT Build | 0:6ae2f7bca550 | 625 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 626 | else |
Azure.IoT Build | 0:6ae2f7bca550 | 627 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 628 | *application_properties = application_properties_clone(message_instance->application_properties); |
Azure.IoT Build | 0:6ae2f7bca550 | 629 | if (*application_properties == NULL) |
Azure.IoT Build | 0:6ae2f7bca550 | 630 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 631 | result = __LINE__; |
Azure.IoT Build | 0:6ae2f7bca550 | 632 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 633 | else |
Azure.IoT Build | 0:6ae2f7bca550 | 634 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 635 | result = 0; |
Azure.IoT Build | 0:6ae2f7bca550 | 636 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 637 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 638 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 639 | |
Azure.IoT Build | 0:6ae2f7bca550 | 640 | return result; |
Azure.IoT Build | 0:6ae2f7bca550 | 641 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 642 | |
Azure.IoT Build | 0:6ae2f7bca550 | 643 | int message_set_footer(MESSAGE_HANDLE message, annotations footer) |
Azure.IoT Build | 0:6ae2f7bca550 | 644 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 645 | int result; |
Azure.IoT Build | 0:6ae2f7bca550 | 646 | |
Azure.IoT Build | 0:6ae2f7bca550 | 647 | if ((message == NULL) || |
Azure.IoT Build | 0:6ae2f7bca550 | 648 | (footer == NULL)) |
Azure.IoT Build | 0:6ae2f7bca550 | 649 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 650 | result = __LINE__; |
Azure.IoT Build | 0:6ae2f7bca550 | 651 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 652 | else |
Azure.IoT Build | 0:6ae2f7bca550 | 653 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 654 | MESSAGE_INSTANCE* message_instance = (MESSAGE_INSTANCE*)message; |
Azure.IoT Build | 0:6ae2f7bca550 | 655 | AMQP_VALUE new_footer; |
Azure.IoT Build | 0:6ae2f7bca550 | 656 | |
Azure.IoT Build | 0:6ae2f7bca550 | 657 | new_footer = annotations_clone(footer); |
Azure.IoT Build | 0:6ae2f7bca550 | 658 | if (new_footer == NULL) |
Azure.IoT Build | 0:6ae2f7bca550 | 659 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 660 | result = __LINE__; |
Azure.IoT Build | 0:6ae2f7bca550 | 661 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 662 | else |
Azure.IoT Build | 0:6ae2f7bca550 | 663 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 664 | if (message_instance->footer != NULL) |
Azure.IoT Build | 0:6ae2f7bca550 | 665 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 666 | annotations_destroy(message_instance->footer); |
Azure.IoT Build | 0:6ae2f7bca550 | 667 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 668 | |
Azure.IoT Build | 0:6ae2f7bca550 | 669 | message_instance->footer = new_footer; |
Azure.IoT Build | 0:6ae2f7bca550 | 670 | result = 0; |
Azure.IoT Build | 0:6ae2f7bca550 | 671 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 672 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 673 | |
Azure.IoT Build | 0:6ae2f7bca550 | 674 | return result; |
Azure.IoT Build | 0:6ae2f7bca550 | 675 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 676 | |
Azure.IoT Build | 0:6ae2f7bca550 | 677 | int message_get_footer(MESSAGE_HANDLE message, annotations* footer) |
Azure.IoT Build | 0:6ae2f7bca550 | 678 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 679 | int result; |
Azure.IoT Build | 0:6ae2f7bca550 | 680 | |
Azure.IoT Build | 0:6ae2f7bca550 | 681 | if ((message == NULL) || |
Azure.IoT Build | 0:6ae2f7bca550 | 682 | (footer == NULL)) |
Azure.IoT Build | 0:6ae2f7bca550 | 683 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 684 | result = __LINE__; |
Azure.IoT Build | 0:6ae2f7bca550 | 685 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 686 | else |
Azure.IoT Build | 0:6ae2f7bca550 | 687 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 688 | MESSAGE_INSTANCE* message_instance = (MESSAGE_INSTANCE*)message; |
Azure.IoT Build | 0:6ae2f7bca550 | 689 | |
Azure.IoT Build | 0:6ae2f7bca550 | 690 | if (message_instance->footer == NULL) |
Azure.IoT Build | 0:6ae2f7bca550 | 691 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 692 | *footer = NULL; |
Azure.IoT Build | 0:6ae2f7bca550 | 693 | result = 0; |
Azure.IoT Build | 0:6ae2f7bca550 | 694 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 695 | else |
Azure.IoT Build | 0:6ae2f7bca550 | 696 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 697 | *footer = annotations_clone(message_instance->footer); |
Azure.IoT Build | 0:6ae2f7bca550 | 698 | if (*footer == NULL) |
Azure.IoT Build | 0:6ae2f7bca550 | 699 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 700 | result = __LINE__; |
Azure.IoT Build | 0:6ae2f7bca550 | 701 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 702 | else |
Azure.IoT Build | 0:6ae2f7bca550 | 703 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 704 | result = 0; |
Azure.IoT Build | 0:6ae2f7bca550 | 705 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 706 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 707 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 708 | |
Azure.IoT Build | 0:6ae2f7bca550 | 709 | return result; |
Azure.IoT Build | 0:6ae2f7bca550 | 710 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 711 | |
Azure.IoT Build | 0:6ae2f7bca550 | 712 | int message_add_body_amqp_data(MESSAGE_HANDLE message, BINARY_DATA binary_data) |
Azure.IoT Build | 0:6ae2f7bca550 | 713 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 714 | int result; |
Azure.IoT Build | 0:6ae2f7bca550 | 715 | |
Azure.IoT Build | 0:6ae2f7bca550 | 716 | MESSAGE_INSTANCE* message_instance = (MESSAGE_INSTANCE*)message; |
Azure.IoT Build | 0:6ae2f7bca550 | 717 | if ((message == NULL) || |
Azure.IoT Build | 0:6ae2f7bca550 | 718 | (binary_data.bytes == NULL) || |
Azure.IoT Build | 0:6ae2f7bca550 | 719 | (binary_data.length == 0)) |
Azure.IoT Build | 0:6ae2f7bca550 | 720 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 721 | result = __LINE__; |
Azure.IoT Build | 0:6ae2f7bca550 | 722 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 723 | else |
Azure.IoT Build | 0:6ae2f7bca550 | 724 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 725 | BODY_AMQP_DATA* new_body_amqp_data_items = (BODY_AMQP_DATA*)amqpalloc_realloc(message_instance->body_amqp_data_items, sizeof(BODY_AMQP_DATA) * (message_instance->body_amqp_data_count + 1)); |
Azure.IoT Build | 0:6ae2f7bca550 | 726 | if (new_body_amqp_data_items == NULL) |
Azure.IoT Build | 0:6ae2f7bca550 | 727 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 728 | result = __LINE__; |
Azure.IoT Build | 0:6ae2f7bca550 | 729 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 730 | else |
Azure.IoT Build | 0:6ae2f7bca550 | 731 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 732 | message_instance->body_amqp_data_items = new_body_amqp_data_items; |
Azure.IoT Build | 0:6ae2f7bca550 | 733 | |
Azure.IoT Build | 0:6ae2f7bca550 | 734 | message_instance->body_amqp_data_items[message_instance->body_amqp_data_count].body_data_section_bytes = (unsigned char*)amqpalloc_malloc(binary_data.length); |
Azure.IoT Build | 0:6ae2f7bca550 | 735 | if (message_instance->body_amqp_data_items[message_instance->body_amqp_data_count].body_data_section_bytes == NULL) |
Azure.IoT Build | 0:6ae2f7bca550 | 736 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 737 | result = __LINE__; |
Azure.IoT Build | 0:6ae2f7bca550 | 738 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 739 | else |
Azure.IoT Build | 0:6ae2f7bca550 | 740 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 741 | message_instance->body_amqp_data_items[message_instance->body_amqp_data_count].body_data_section_length = binary_data.length; |
Azure.IoT Build | 0:6ae2f7bca550 | 742 | (void)memcpy(message_instance->body_amqp_data_items[message_instance->body_amqp_data_count].body_data_section_bytes, binary_data.bytes, binary_data.length); |
Azure.IoT Build | 0:6ae2f7bca550 | 743 | |
Azure.IoT Build | 0:6ae2f7bca550 | 744 | if (message_instance->body_amqp_value != NULL) |
Azure.IoT Build | 0:6ae2f7bca550 | 745 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 746 | amqpvalue_destroy(message_instance->body_amqp_value); |
Azure.IoT Build | 0:6ae2f7bca550 | 747 | message_instance->body_amqp_value = NULL; |
Azure.IoT Build | 0:6ae2f7bca550 | 748 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 749 | free_all_body_sequence_items(message_instance); |
Azure.IoT Build | 0:6ae2f7bca550 | 750 | |
Azure.IoT Build | 0:6ae2f7bca550 | 751 | message_instance->body_amqp_data_count++; |
Azure.IoT Build | 0:6ae2f7bca550 | 752 | result = 0; |
Azure.IoT Build | 0:6ae2f7bca550 | 753 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 754 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 755 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 756 | |
Azure.IoT Build | 0:6ae2f7bca550 | 757 | return result; |
Azure.IoT Build | 0:6ae2f7bca550 | 758 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 759 | |
Azure.IoT Build | 0:6ae2f7bca550 | 760 | int message_get_body_amqp_data(MESSAGE_HANDLE message, size_t index, BINARY_DATA* binary_data) |
Azure.IoT Build | 0:6ae2f7bca550 | 761 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 762 | int result; |
Azure.IoT Build | 0:6ae2f7bca550 | 763 | |
Azure.IoT Build | 0:6ae2f7bca550 | 764 | if ((message == NULL) || |
Azure.IoT Build | 0:6ae2f7bca550 | 765 | (binary_data == NULL)) |
Azure.IoT Build | 0:6ae2f7bca550 | 766 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 767 | result = __LINE__; |
Azure.IoT Build | 0:6ae2f7bca550 | 768 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 769 | else |
Azure.IoT Build | 0:6ae2f7bca550 | 770 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 771 | MESSAGE_INSTANCE* message_instance = (MESSAGE_INSTANCE*)message; |
Azure.IoT Build | 0:6ae2f7bca550 | 772 | |
Azure.IoT Build | 0:6ae2f7bca550 | 773 | if (index >= message_instance->body_amqp_data_count) |
Azure.IoT Build | 0:6ae2f7bca550 | 774 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 775 | result = __LINE__; |
Azure.IoT Build | 0:6ae2f7bca550 | 776 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 777 | else |
Azure.IoT Build | 0:6ae2f7bca550 | 778 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 779 | binary_data->bytes = message_instance->body_amqp_data_items[index].body_data_section_bytes; |
Azure.IoT Build | 0:6ae2f7bca550 | 780 | binary_data->length = message_instance->body_amqp_data_items[index].body_data_section_length; |
Azure.IoT Build | 0:6ae2f7bca550 | 781 | |
Azure.IoT Build | 0:6ae2f7bca550 | 782 | result = 0; |
Azure.IoT Build | 0:6ae2f7bca550 | 783 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 784 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 785 | |
Azure.IoT Build | 0:6ae2f7bca550 | 786 | return result; |
Azure.IoT Build | 0:6ae2f7bca550 | 787 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 788 | |
Azure.IoT Build | 0:6ae2f7bca550 | 789 | int message_get_body_amqp_data_count(MESSAGE_HANDLE message, size_t* count) |
Azure.IoT Build | 0:6ae2f7bca550 | 790 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 791 | int result; |
Azure.IoT Build | 0:6ae2f7bca550 | 792 | |
Azure.IoT Build | 0:6ae2f7bca550 | 793 | MESSAGE_INSTANCE* message_instance = (MESSAGE_INSTANCE*)message; |
Azure.IoT Build | 0:6ae2f7bca550 | 794 | if ((message == NULL) || |
Azure.IoT Build | 0:6ae2f7bca550 | 795 | (count == NULL)) |
Azure.IoT Build | 0:6ae2f7bca550 | 796 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 797 | result = __LINE__; |
Azure.IoT Build | 0:6ae2f7bca550 | 798 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 799 | else |
Azure.IoT Build | 0:6ae2f7bca550 | 800 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 801 | *count = message_instance->body_amqp_data_count; |
Azure.IoT Build | 0:6ae2f7bca550 | 802 | result = 0; |
Azure.IoT Build | 0:6ae2f7bca550 | 803 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 804 | |
Azure.IoT Build | 0:6ae2f7bca550 | 805 | return result; |
Azure.IoT Build | 0:6ae2f7bca550 | 806 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 807 | |
Azure.IoT Build | 0:6ae2f7bca550 | 808 | int message_add_body_amqp_sequence(MESSAGE_HANDLE message, AMQP_VALUE sequence_list) |
Azure.IoT Build | 0:6ae2f7bca550 | 809 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 810 | int result; |
Azure.IoT Build | 0:6ae2f7bca550 | 811 | size_t item_count; |
Azure.IoT Build | 0:6ae2f7bca550 | 812 | |
Azure.IoT Build | 0:6ae2f7bca550 | 813 | MESSAGE_INSTANCE* message_instance = (MESSAGE_INSTANCE*)message; |
Azure.IoT Build | 0:6ae2f7bca550 | 814 | if ((message == NULL) || |
Azure.IoT Build | 0:6ae2f7bca550 | 815 | (sequence_list == NULL) || |
Azure.IoT Build | 0:6ae2f7bca550 | 816 | (amqpvalue_get_list_item_count(sequence_list, (uint32_t*)&item_count) != 0)) |
Azure.IoT Build | 0:6ae2f7bca550 | 817 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 818 | result = __LINE__; |
Azure.IoT Build | 0:6ae2f7bca550 | 819 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 820 | else |
Azure.IoT Build | 0:6ae2f7bca550 | 821 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 822 | AMQP_VALUE* new_body_amqp_sequence_items = (AMQP_VALUE*)amqpalloc_realloc(message_instance->body_amqp_sequence_items, sizeof(AMQP_VALUE) * (message_instance->body_amqp_sequence_count + 1)); |
Azure.IoT Build | 0:6ae2f7bca550 | 823 | if (new_body_amqp_sequence_items == NULL) |
Azure.IoT Build | 0:6ae2f7bca550 | 824 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 825 | result = __LINE__; |
Azure.IoT Build | 0:6ae2f7bca550 | 826 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 827 | else |
Azure.IoT Build | 0:6ae2f7bca550 | 828 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 829 | message_instance->body_amqp_sequence_items = new_body_amqp_sequence_items; |
Azure.IoT Build | 0:6ae2f7bca550 | 830 | |
Azure.IoT Build | 0:6ae2f7bca550 | 831 | message_instance->body_amqp_sequence_items[message_instance->body_amqp_sequence_count] = amqpvalue_clone(sequence_list); |
Azure.IoT Build | 0:6ae2f7bca550 | 832 | if (message_instance->body_amqp_sequence_items[message_instance->body_amqp_sequence_count] == NULL) |
Azure.IoT Build | 0:6ae2f7bca550 | 833 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 834 | result = __LINE__; |
Azure.IoT Build | 0:6ae2f7bca550 | 835 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 836 | else |
Azure.IoT Build | 0:6ae2f7bca550 | 837 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 838 | if (message_instance->body_amqp_value != NULL) |
Azure.IoT Build | 0:6ae2f7bca550 | 839 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 840 | amqpvalue_destroy(message_instance->body_amqp_value); |
Azure.IoT Build | 0:6ae2f7bca550 | 841 | message_instance->body_amqp_value = NULL; |
Azure.IoT Build | 0:6ae2f7bca550 | 842 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 843 | free_all_body_data_items(message_instance); |
Azure.IoT Build | 0:6ae2f7bca550 | 844 | |
Azure.IoT Build | 0:6ae2f7bca550 | 845 | message_instance->body_amqp_sequence_count++; |
Azure.IoT Build | 0:6ae2f7bca550 | 846 | result = 0; |
Azure.IoT Build | 0:6ae2f7bca550 | 847 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 848 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 849 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 850 | |
Azure.IoT Build | 0:6ae2f7bca550 | 851 | return result; |
Azure.IoT Build | 0:6ae2f7bca550 | 852 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 853 | |
Azure.IoT Build | 0:6ae2f7bca550 | 854 | int message_get_body_amqp_sequence(MESSAGE_HANDLE message, size_t index, AMQP_VALUE* sequence_list) |
Azure.IoT Build | 0:6ae2f7bca550 | 855 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 856 | int result; |
Azure.IoT Build | 0:6ae2f7bca550 | 857 | |
Azure.IoT Build | 0:6ae2f7bca550 | 858 | if ((message == NULL) || |
Azure.IoT Build | 0:6ae2f7bca550 | 859 | (sequence_list == NULL)) |
Azure.IoT Build | 0:6ae2f7bca550 | 860 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 861 | result = __LINE__; |
Azure.IoT Build | 0:6ae2f7bca550 | 862 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 863 | else |
Azure.IoT Build | 0:6ae2f7bca550 | 864 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 865 | MESSAGE_INSTANCE* message_instance = (MESSAGE_INSTANCE*)message; |
Azure.IoT Build | 0:6ae2f7bca550 | 866 | |
Azure.IoT Build | 0:6ae2f7bca550 | 867 | if (index >= message_instance->body_amqp_sequence_count) |
Azure.IoT Build | 0:6ae2f7bca550 | 868 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 869 | result = __LINE__; |
Azure.IoT Build | 0:6ae2f7bca550 | 870 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 871 | else |
Azure.IoT Build | 0:6ae2f7bca550 | 872 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 873 | *sequence_list = amqpvalue_clone(message_instance->body_amqp_sequence_items[index]); |
Azure.IoT Build | 0:6ae2f7bca550 | 874 | if (*sequence_list == NULL) |
Azure.IoT Build | 0:6ae2f7bca550 | 875 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 876 | result = __LINE__; |
Azure.IoT Build | 0:6ae2f7bca550 | 877 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 878 | else |
Azure.IoT Build | 0:6ae2f7bca550 | 879 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 880 | result = 0; |
Azure.IoT Build | 0:6ae2f7bca550 | 881 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 882 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 883 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 884 | |
Azure.IoT Build | 0:6ae2f7bca550 | 885 | return result; |
Azure.IoT Build | 0:6ae2f7bca550 | 886 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 887 | |
Azure.IoT Build | 0:6ae2f7bca550 | 888 | int message_get_body_amqp_sequence_count(MESSAGE_HANDLE message, size_t* count) |
Azure.IoT Build | 0:6ae2f7bca550 | 889 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 890 | int result; |
Azure.IoT Build | 0:6ae2f7bca550 | 891 | |
Azure.IoT Build | 0:6ae2f7bca550 | 892 | MESSAGE_INSTANCE* message_instance = (MESSAGE_INSTANCE*)message; |
Azure.IoT Build | 0:6ae2f7bca550 | 893 | if ((message == NULL) || |
Azure.IoT Build | 0:6ae2f7bca550 | 894 | (count == NULL)) |
Azure.IoT Build | 0:6ae2f7bca550 | 895 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 896 | result = __LINE__; |
Azure.IoT Build | 0:6ae2f7bca550 | 897 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 898 | else |
Azure.IoT Build | 0:6ae2f7bca550 | 899 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 900 | *count = message_instance->body_amqp_sequence_count; |
Azure.IoT Build | 0:6ae2f7bca550 | 901 | result = 0; |
Azure.IoT Build | 0:6ae2f7bca550 | 902 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 903 | |
Azure.IoT Build | 0:6ae2f7bca550 | 904 | return result; |
Azure.IoT Build | 0:6ae2f7bca550 | 905 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 906 | |
Azure.IoT Build | 0:6ae2f7bca550 | 907 | int message_set_body_amqp_value(MESSAGE_HANDLE message, AMQP_VALUE body_amqp_value) |
Azure.IoT Build | 0:6ae2f7bca550 | 908 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 909 | int result; |
Azure.IoT Build | 0:6ae2f7bca550 | 910 | |
Azure.IoT Build | 0:6ae2f7bca550 | 911 | MESSAGE_INSTANCE* message_instance = (MESSAGE_INSTANCE*)message; |
Azure.IoT Build | 0:6ae2f7bca550 | 912 | if ((message == NULL) || |
Azure.IoT Build | 0:6ae2f7bca550 | 913 | (body_amqp_value == NULL)) |
Azure.IoT Build | 0:6ae2f7bca550 | 914 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 915 | result = __LINE__; |
Azure.IoT Build | 0:6ae2f7bca550 | 916 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 917 | else |
Azure.IoT Build | 0:6ae2f7bca550 | 918 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 919 | message_instance->body_amqp_value = amqpvalue_clone(body_amqp_value); |
Azure.IoT Build | 0:6ae2f7bca550 | 920 | |
Azure.IoT Build | 0:6ae2f7bca550 | 921 | free_all_body_data_items(message_instance); |
Azure.IoT Build | 0:6ae2f7bca550 | 922 | free_all_body_sequence_items(message_instance); |
Azure.IoT Build | 0:6ae2f7bca550 | 923 | result = 0; |
Azure.IoT Build | 0:6ae2f7bca550 | 924 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 925 | |
Azure.IoT Build | 0:6ae2f7bca550 | 926 | return result; |
Azure.IoT Build | 0:6ae2f7bca550 | 927 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 928 | |
Azure.IoT Build | 0:6ae2f7bca550 | 929 | int message_get_inplace_body_amqp_value(MESSAGE_HANDLE message, AMQP_VALUE* body_amqp_value) |
Azure.IoT Build | 0:6ae2f7bca550 | 930 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 931 | int result; |
Azure.IoT Build | 0:6ae2f7bca550 | 932 | |
Azure.IoT Build | 0:6ae2f7bca550 | 933 | if ((message == NULL) || |
Azure.IoT Build | 0:6ae2f7bca550 | 934 | (body_amqp_value == NULL)) |
Azure.IoT Build | 0:6ae2f7bca550 | 935 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 936 | result = __LINE__; |
Azure.IoT Build | 0:6ae2f7bca550 | 937 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 938 | else |
Azure.IoT Build | 0:6ae2f7bca550 | 939 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 940 | MESSAGE_INSTANCE* message_instance = (MESSAGE_INSTANCE*)message; |
Azure.IoT Build | 0:6ae2f7bca550 | 941 | |
Azure.IoT Build | 0:6ae2f7bca550 | 942 | *body_amqp_value = message_instance->body_amqp_value; |
Azure.IoT Build | 0:6ae2f7bca550 | 943 | |
Azure.IoT Build | 0:6ae2f7bca550 | 944 | result = 0; |
Azure.IoT Build | 0:6ae2f7bca550 | 945 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 946 | |
Azure.IoT Build | 0:6ae2f7bca550 | 947 | return result; |
Azure.IoT Build | 0:6ae2f7bca550 | 948 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 949 | |
Azure.IoT Build | 0:6ae2f7bca550 | 950 | int message_get_body_type(MESSAGE_HANDLE message, MESSAGE_BODY_TYPE* body_type) |
Azure.IoT Build | 0:6ae2f7bca550 | 951 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 952 | int result; |
Azure.IoT Build | 0:6ae2f7bca550 | 953 | |
Azure.IoT Build | 0:6ae2f7bca550 | 954 | if ((message == NULL) || |
Azure.IoT Build | 0:6ae2f7bca550 | 955 | (body_type == NULL)) |
Azure.IoT Build | 0:6ae2f7bca550 | 956 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 957 | result = __LINE__; |
Azure.IoT Build | 0:6ae2f7bca550 | 958 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 959 | else |
Azure.IoT Build | 0:6ae2f7bca550 | 960 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 961 | MESSAGE_INSTANCE* message_instance = (MESSAGE_INSTANCE*)message; |
Azure.IoT Build | 0:6ae2f7bca550 | 962 | |
Azure.IoT Build | 0:6ae2f7bca550 | 963 | if (message_instance->body_amqp_value != NULL) |
Azure.IoT Build | 0:6ae2f7bca550 | 964 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 965 | *body_type = MESSAGE_BODY_TYPE_VALUE; |
Azure.IoT Build | 0:6ae2f7bca550 | 966 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 967 | else if (message_instance->body_amqp_data_count > 0) |
Azure.IoT Build | 0:6ae2f7bca550 | 968 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 969 | *body_type = MESSAGE_BODY_TYPE_DATA; |
Azure.IoT Build | 0:6ae2f7bca550 | 970 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 971 | else if (message_instance->body_amqp_sequence_count > 0) |
Azure.IoT Build | 0:6ae2f7bca550 | 972 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 973 | *body_type = MESSAGE_BODY_TYPE_SEQUENCE; |
Azure.IoT Build | 0:6ae2f7bca550 | 974 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 975 | else |
Azure.IoT Build | 0:6ae2f7bca550 | 976 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 977 | *body_type = MESSAGE_BODY_TYPE_NONE; |
Azure.IoT Build | 0:6ae2f7bca550 | 978 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 979 | |
Azure.IoT Build | 0:6ae2f7bca550 | 980 | result = 0; |
Azure.IoT Build | 0:6ae2f7bca550 | 981 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 982 | |
Azure.IoT Build | 0:6ae2f7bca550 | 983 | return result; |
Azure.IoT Build | 0:6ae2f7bca550 | 984 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 985 | |
Azure.IoT Build | 0:6ae2f7bca550 | 986 | int message_set_message_format(MESSAGE_HANDLE message, uint32_t message_format) |
Azure.IoT Build | 0:6ae2f7bca550 | 987 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 988 | int result; |
Azure.IoT Build | 0:6ae2f7bca550 | 989 | |
Azure.IoT Build | 0:6ae2f7bca550 | 990 | if (message == NULL) |
Azure.IoT Build | 0:6ae2f7bca550 | 991 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 992 | result = __LINE__; |
Azure.IoT Build | 0:6ae2f7bca550 | 993 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 994 | else |
Azure.IoT Build | 0:6ae2f7bca550 | 995 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 996 | MESSAGE_INSTANCE* message_instance = (MESSAGE_INSTANCE*)message; |
Azure.IoT Build | 0:6ae2f7bca550 | 997 | message_instance->message_format = message_format; |
Azure.IoT Build | 0:6ae2f7bca550 | 998 | result = 0; |
Azure.IoT Build | 0:6ae2f7bca550 | 999 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 1000 | |
Azure.IoT Build | 0:6ae2f7bca550 | 1001 | return result; |
Azure.IoT Build | 0:6ae2f7bca550 | 1002 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 1003 | |
Azure.IoT Build | 0:6ae2f7bca550 | 1004 | int message_get_message_format(MESSAGE_HANDLE message, uint32_t *message_format) |
Azure.IoT Build | 0:6ae2f7bca550 | 1005 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 1006 | int result; |
Azure.IoT Build | 0:6ae2f7bca550 | 1007 | |
Azure.IoT Build | 0:6ae2f7bca550 | 1008 | if ((message == NULL) || |
Azure.IoT Build | 0:6ae2f7bca550 | 1009 | (message_format == NULL)) |
Azure.IoT Build | 0:6ae2f7bca550 | 1010 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 1011 | result = __LINE__; |
Azure.IoT Build | 0:6ae2f7bca550 | 1012 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 1013 | else |
Azure.IoT Build | 0:6ae2f7bca550 | 1014 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 1015 | MESSAGE_INSTANCE* message_instance = (MESSAGE_INSTANCE*)message; |
Azure.IoT Build | 0:6ae2f7bca550 | 1016 | *message_format = message_instance->message_format; |
Azure.IoT Build | 0:6ae2f7bca550 | 1017 | result = 0; |
Azure.IoT Build | 0:6ae2f7bca550 | 1018 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 1019 | |
Azure.IoT Build | 0:6ae2f7bca550 | 1020 | return result; |
Azure.IoT Build | 0:6ae2f7bca550 | 1021 | } |