diff options
-rw-r--r-- | examples/amqp_sendstring.c | 21 | ||||
-rw-r--r-- | librabbitmq/codegen.py | 23 |
2 files changed, 27 insertions, 17 deletions
diff --git a/examples/amqp_sendstring.c b/examples/amqp_sendstring.c index 6fe540d..77d8fd3 100644 --- a/examples/amqp_sendstring.c +++ b/examples/amqp_sendstring.c @@ -86,14 +86,19 @@ int main(int argc, char const * const *argv) { die_on_amqp_error(amqp_login(conn, "/", 131072, AMQP_SASL_METHOD_PLAIN, "guest", "guest"), "Logging in"); - die_on_error(amqp_basic_publish(conn, - amqp_cstring_bytes(exchange), - amqp_cstring_bytes(routingkey), - 0, - 0, - NULL, - amqp_cstring_bytes(messagebody)), - "Publishing"); + { + amqp_basic_properties_t props; + props._flags = AMQP_BASIC_CONTENT_TYPE_FLAG; + props.content_type = amqp_cstring_bytes("text/plain"); + die_on_error(amqp_basic_publish(conn, + amqp_cstring_bytes(exchange), + amqp_cstring_bytes(routingkey), + 0, + 0, + &props, + amqp_cstring_bytes(messagebody)), + "Publishing"); + } printf("Waiting for frames...\n"); while (1) { diff --git a/librabbitmq/codegen.py b/librabbitmq/codegen.py index 9f6cde0..0967119 100644 --- a/librabbitmq/codegen.py +++ b/librabbitmq/codegen.py @@ -329,15 +329,20 @@ int amqp_encode_properties(uint16_t class_id, similarity of structure between classes */ amqp_flags_t flags = * (amqp_flags_t *) decoded; /* cheating! */ - do { - amqp_flags_t remainder = flags >> 16; - uint16_t partial_flags = flags & 0xFFFE; - if (remainder != 0) { partial_flags |= 1; } - E_16(encoded, offset, partial_flags); - offset += 2; - flags = remainder; - } while (flags != 0); - + { + /* We take a copy of flags to avoid destroying it, as it is used + in the autogenerated code below. */ + amqp_flags_t remaining_flags = flags; + do { + amqp_flags_t remainder = remaining_flags >> 16; + uint16_t partial_flags = remaining_flags & 0xFFFE; + if (remainder != 0) { partial_flags |= 1; } + E_16(encoded, offset, partial_flags); + offset += 2; + remaining_flags = remainder; + } while (remaining_flags != 0); + } + switch (class_id) {""" for c in spec.allClasses(): genEncodeProperties(c) print """ default: return -ENOENT; |