diff options
author | Alan Conway <aconway@apache.org> | 2006-10-11 15:50:15 +0000 |
---|---|---|
committer | Alan Conway <aconway@apache.org> | 2006-10-11 15:50:15 +0000 |
commit | 2bcadbb42a6fb2f096c1fc0a4b957d64a5024ef6 (patch) | |
tree | 886eb0659c6f28c2f1d26de7d5fd29fff0072dc5 /cpp/common/framing | |
parent | 9fc2b6c5f0848d65f1bf20e62279c055d12a1d40 (diff) | |
download | qpid-python-2bcadbb42a6fb2f096c1fc0a4b957d64a5024ef6.tar.gz |
Turned up gcc warnings, fixed warnings in code, enabled -Werror.
Note: #include "qpid_test_plugin.h" instead of <cppunit/TestPlugin.h>
Works around warning from a cppunit macro.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@462834 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/common/framing')
28 files changed, 168 insertions, 138 deletions
diff --git a/cpp/common/framing/generated/stylesheets/amqp_client_handler_impl.xsl b/cpp/common/framing/generated/stylesheets/amqp_client_handler_impl.xsl index aa095eaf79..0cc34e0ecf 100644 --- a/cpp/common/framing/generated/stylesheets/amqp_client_handler_impl.xsl +++ b/cpp/common/framing/generated/stylesheets/amqp_client_handler_impl.xsl @@ -7,7 +7,7 @@ =============================== Template: client_handler_impl_h =============================== - Template to generate the AMQP_ServerHandlerImpl class header file. + Template to generate the AMQP_ClientHandlerImpl class header file. --> <xsl:template match="amqp" mode="client_handler_impl_h"> <xsl:param name="domain-cpp-table"/> @@ -122,7 +122,7 @@ class AMQP_ClientHandlerImpl : virtual public AMQP_ClientOperations ================================= Template: client_handler_impl_cpp ================================= - Template to generate the AMQP_ServerHandlerImpl class stubs. + Template to generate the AMQP_ClientHandlerImpl class stubs. --> <xsl:template match="amqp" mode="client_handler_impl_cpp"> <xsl:param name="domain-cpp-table"/> @@ -163,12 +163,12 @@ AMQP_ClientHandlerImpl::~AMQP_ClientHandlerImpl() <xsl:for-each select="method"> <xsl:if test="chassis[@name='client']"> <xsl:text>void AMQP_ClientHandlerImpl::</xsl:text><xsl:value-of select="$class"/><xsl:text>HandlerImpl::</xsl:text> - <xsl:value-of select="amqp:cpp-name(@name)"/><xsl:text>( u_int16_t channel</xsl:text> + <xsl:value-of select="amqp:cpp-name(@name)"/><xsl:text>( u_int16_t /*channel*/</xsl:text> <xsl:if test="field"> <xsl:text>,
 </xsl:text> <xsl:for-each select="field"> <xsl:variable name="domain-cpp-type" select="amqp:cpp-lookup(@domain, $domain-cpp-table)"/> - <xsl:value-of select="concat($domain-cpp-type, amqp:cpp-arg-ref($domain-cpp-type), ' ', amqp:cpp-name(@name))"/> + <xsl:value-of select="concat($domain-cpp-type, amqp:cpp-arg-ref($domain-cpp-type), ' /*', amqp:cpp-name(@name), '*/')"/> <xsl:if test="position()!=last()"> <xsl:text>,
 </xsl:text> </xsl:if> diff --git a/cpp/common/framing/generated/stylesheets/amqp_server_handler_impl.xsl b/cpp/common/framing/generated/stylesheets/amqp_server_handler_impl.xsl index de879a5670..6450d3fd0c 100644 --- a/cpp/common/framing/generated/stylesheets/amqp_server_handler_impl.xsl +++ b/cpp/common/framing/generated/stylesheets/amqp_server_handler_impl.xsl @@ -163,12 +163,12 @@ AMQP_ServerHandlerImpl::~AMQP_ServerHandlerImpl() <xsl:for-each select="method"> <xsl:if test="chassis[@name='server']"> <xsl:text>void AMQP_ServerHandlerImpl::</xsl:text><xsl:value-of select="$class"/><xsl:text>HandlerImpl::</xsl:text> - <xsl:value-of select="amqp:cpp-name(@name)"/><xsl:text>( u_int16_t channel</xsl:text> + <xsl:value-of select="amqp:cpp-name(@name)"/><xsl:text>( u_int16_t /*channel*/</xsl:text> <xsl:if test="field"> <xsl:text>,
 </xsl:text> <xsl:for-each select="field"> <xsl:variable name="domain-cpp-type" select="amqp:cpp-lookup(@domain, $domain-cpp-table)"/> - <xsl:value-of select="concat($domain-cpp-type, amqp:cpp-arg-ref($domain-cpp-type), ' ', amqp:cpp-name(@name))"/> + <xsl:value-of select="concat($domain-cpp-type, amqp:cpp-arg-ref($domain-cpp-type), ' /*', amqp:cpp-name(@name), '*/')"/> <xsl:if test="position()!=last()"> <xsl:text>,
 </xsl:text> </xsl:if> diff --git a/cpp/common/framing/generated/stylesheets/amqp_server_operations.xsl b/cpp/common/framing/generated/stylesheets/amqp_server_operations.xsl index b42242e8fe..4b97700f04 100644 --- a/cpp/common/framing/generated/stylesheets/amqp_server_operations.xsl +++ b/cpp/common/framing/generated/stylesheets/amqp_server_operations.xsl @@ -66,7 +66,7 @@ class AMQP_ServerOperations <xsl:value-of select="amqp:process-docs(doc)"/> <xsl:text>*/
</xsl:text> </xsl:if> - <xsl:for-each select="rule">/** + <xsl:for-each select="rule"> <xsl:text>
/**
</xsl:text> <xsl:text>Rule "</xsl:text><xsl:value-of select="@name"/><xsl:text>":
</xsl:text> <xsl:value-of select="amqp:process-docs(doc)"/> diff --git a/cpp/common/framing/generated/stylesheets/cpp.xsl b/cpp/common/framing/generated/stylesheets/cpp.xsl index ae66f65745..f9e5ba4141 100644 --- a/cpp/common/framing/generated/stylesheets/cpp.xsl +++ b/cpp/common/framing/generated/stylesheets/cpp.xsl @@ -122,7 +122,7 @@ public: } </xsl:if> - inline void encodeContent(Buffer& buffer) const + inline void encodeContent(Buffer& <xsl:if test="$f/field">buffer</xsl:if>) const { <xsl:if test="$f/field[@type='bit']"> u_int8_t flags = 0; @@ -140,11 +140,8 @@ public: </xsl:for-each> } - inline void decodeContent(Buffer& buffer) + inline void decodeContent(Buffer& <xsl:if test="$f/field">buffer</xsl:if>) { - <xsl:if test="$f/field[@type='bit']"> - u_int8_t maxbit = <xsl:value-of select="$f/@bit-field-count"/>; - </xsl:if> <xsl:for-each select="$f/field"> <xsl:choose> <xsl:when test="@type = 'bit' and @boolean-index = 1"> diff --git a/cpp/common/framing/inc/AMQHeaderBody.h b/cpp/common/framing/inc/AMQHeaderBody.h index e39fffa8ce..4f9cdb571a 100644 --- a/cpp/common/framing/inc/AMQHeaderBody.h +++ b/cpp/common/framing/inc/AMQHeaderBody.h @@ -42,7 +42,7 @@ public: HeaderProperties* getProperties(){ return properties; } const HeaderProperties* getProperties() const { return properties; } inline u_int64_t getContentSize() const { return contentSize; } - inline void setContentSize(u_int64_t size) { contentSize = size; } + inline void setContentSize(u_int64_t _size) { contentSize = _size; } virtual ~AMQHeaderBody(); virtual u_int32_t size() const; virtual void encode(Buffer& buffer) const; diff --git a/cpp/common/framing/inc/AMQHeartbeatBody.h b/cpp/common/framing/inc/AMQHeartbeatBody.h index cfe057bdcd..da612a2a44 100644 --- a/cpp/common/framing/inc/AMQHeartbeatBody.h +++ b/cpp/common/framing/inc/AMQHeartbeatBody.h @@ -33,8 +33,8 @@ public: virtual ~AMQHeartbeatBody(); inline u_int32_t size() const { return 0; } inline u_int8_t type() const { return HEARTBEAT_BODY; } - inline void encode(Buffer& buffer) const {} - inline void decode(Buffer& buffer, u_int32_t size) {} + inline void encode(Buffer& ) const {} + inline void decode(Buffer& , u_int32_t /*size*/) {} virtual void print(std::ostream& out) const; }; diff --git a/cpp/common/framing/inc/BasicHeaderProperties.h b/cpp/common/framing/inc/BasicHeaderProperties.h index 8688a37bf9..c32612221b 100644 --- a/cpp/common/framing/inc/BasicHeaderProperties.h +++ b/cpp/common/framing/inc/BasicHeaderProperties.h @@ -70,20 +70,20 @@ namespace framing { inline string& getAppId(){ return appId; } inline string& getClusterId(){ return clusterId; } - void inline setContentType(string& type){ contentType = type; } + void inline setContentType(string& _type){ contentType = _type; } void inline setContentEncoding(string& encoding){ contentEncoding = encoding; } - void inline setHeaders(FieldTable& headers){ this->headers = headers; } + void inline setHeaders(FieldTable& _headers){ headers = _headers; } void inline setDeliveryMode(u_int8_t mode){ deliveryMode = mode; } - void inline setPriority(u_int8_t priority){ this->priority = priority; } - void inline setCorrelationId(string& correlationId){ this->correlationId = correlationId; } - void inline setReplyTo(string& replyTo){ this->replyTo = replyTo;} - void inline setExpiration(string& expiration){ this->expiration = expiration; } - void inline setMessageId(string& messageId){ this->messageId = messageId; } - void inline setTimestamp(u_int64_t timestamp){ this->timestamp = timestamp; } - void inline setType(string& type){ this->type = type; } - void inline setUserId(string& userId){ this->userId = userId; } - void inline setAppId(string& appId){this->appId = appId; } - void inline setClusterId(string& clusterId){ this->clusterId = clusterId; } + void inline setPriority(u_int8_t _priority){ priority = _priority; } + void inline setCorrelationId(string& _correlationId){ correlationId = _correlationId; } + void inline setReplyTo(string& _replyTo){ replyTo = _replyTo;} + void inline setExpiration(string& _expiration){ expiration = _expiration; } + void inline setMessageId(string& _messageId){ messageId = _messageId; } + void inline setTimestamp(u_int64_t _timestamp){ timestamp = _timestamp; } + void inline setType(string& _type){ type = _type; } + void inline setUserId(string& _userId){ userId = _userId; } + void inline setAppId(string& _appId){appId = _appId; } + void inline setClusterId(string& _clusterId){ clusterId = _clusterId; } }; } diff --git a/cpp/common/framing/inc/BodyHandler.h b/cpp/common/framing/inc/BodyHandler.h index f92ae66804..a4aee2709e 100644 --- a/cpp/common/framing/inc/BodyHandler.h +++ b/cpp/common/framing/inc/BodyHandler.h @@ -30,6 +30,7 @@ namespace framing { class BodyHandler{ public: + virtual ~BodyHandler(); virtual void handleMethod(AMQMethodBody::shared_ptr body) = 0; virtual void handleHeader(AMQHeaderBody::shared_ptr body) = 0; virtual void handleContent(AMQContentBody::shared_ptr body) = 0; diff --git a/cpp/common/framing/inc/Buffer.h b/cpp/common/framing/inc/Buffer.h index e0532cc9d6..4d3d503b00 100644 --- a/cpp/common/framing/inc/Buffer.h +++ b/cpp/common/framing/inc/Buffer.h @@ -27,16 +27,16 @@ class FieldTable; class Buffer { - const int size; + const u_int32_t size; char* data; - int position; - int limit; - int r_position; - int r_limit; + u_int32_t position; + u_int32_t limit; + u_int32_t r_position; + u_int32_t r_limit; public: - Buffer(int size); + Buffer(u_int32_t size); ~Buffer(); void flip(); @@ -44,9 +44,9 @@ public: void compact(); void record(); void restore(); - int available(); + u_int32_t available(); char* start(); - void move(int bytes); + void move(u_int32_t bytes); void putOctet(u_int8_t i); void putShort(u_int16_t i); diff --git a/cpp/common/framing/inc/InitiationHandler.h b/cpp/common/framing/inc/InitiationHandler.h index 2e8d1e652b..7b1fb36e2d 100644 --- a/cpp/common/framing/inc/InitiationHandler.h +++ b/cpp/common/framing/inc/InitiationHandler.h @@ -27,6 +27,7 @@ namespace framing { class InitiationHandler{ public: + virtual ~InitiationHandler(); virtual void initiated(ProtocolInitiation* header) = 0; }; diff --git a/cpp/common/framing/inc/InputHandler.h b/cpp/common/framing/inc/InputHandler.h index 2722cae0ed..927bd97ab4 100644 --- a/cpp/common/framing/inc/InputHandler.h +++ b/cpp/common/framing/inc/InputHandler.h @@ -27,6 +27,7 @@ namespace framing { class InputHandler{ public: + virtual ~InputHandler(); virtual void received(AMQFrame* frame) = 0; }; diff --git a/cpp/common/framing/inc/OutputHandler.h b/cpp/common/framing/inc/OutputHandler.h index 7fe63660c3..afc8d7f257 100644 --- a/cpp/common/framing/inc/OutputHandler.h +++ b/cpp/common/framing/inc/OutputHandler.h @@ -27,6 +27,7 @@ namespace framing { class OutputHandler{ public: + virtual ~OutputHandler(); virtual void send(AMQFrame* frame) = 0; }; diff --git a/cpp/common/framing/inc/Value.h b/cpp/common/framing/inc/Value.h index 3d525a0bef..fe939e8758 100644 --- a/cpp/common/framing/inc/Value.h +++ b/cpp/common/framing/inc/Value.h @@ -147,8 +147,8 @@ class EmptyValue : public Value { ~EmptyValue(); virtual u_int32_t size() const { return 0; } virtual char getType() const { return 0; } - virtual void encode(Buffer& buffer) {} - virtual void decode(Buffer& buffer) {} + virtual void encode(Buffer& ) {} + virtual void decode(Buffer& ) {} virtual bool operator==(const Value& v) const { return dynamic_cast<const EmptyValue*>(&v); } diff --git a/cpp/common/framing/src/AMQContentBody.cpp b/cpp/common/framing/src/AMQContentBody.cpp index 6bc588c3ab..1be8867d53 100644 --- a/cpp/common/framing/src/AMQContentBody.cpp +++ b/cpp/common/framing/src/AMQContentBody.cpp @@ -30,8 +30,8 @@ u_int32_t qpid::framing::AMQContentBody::size() const{ void qpid::framing::AMQContentBody::encode(Buffer& buffer) const{ buffer.putRawData(data); } -void qpid::framing::AMQContentBody::decode(Buffer& buffer, u_int32_t size){ - buffer.getRawData(data, size); +void qpid::framing::AMQContentBody::decode(Buffer& buffer, u_int32_t _size){ + buffer.getRawData(data, _size); } void qpid::framing::AMQContentBody::print(std::ostream& out) const diff --git a/cpp/common/framing/src/AMQFrame.cpp b/cpp/common/framing/src/AMQFrame.cpp index 5686c9ac81..487ab1a443 100644 --- a/cpp/common/framing/src/AMQFrame.cpp +++ b/cpp/common/framing/src/AMQFrame.cpp @@ -63,33 +63,13 @@ bool AMQFrame::decode(Buffer& buffer) { if(buffer.available() < 7) return false; buffer.record(); - u_int8_t type = buffer.getOctet(); - channel = buffer.getShort(); - u_int32_t size = buffer.getLong(); - if(buffer.available() < size + 1){ + u_int32_t bufSize = decodeHead(buffer); + + if(buffer.available() < bufSize + 1){ buffer.restore(); return false; } - switch(type) - { - case METHOD_BODY: - body = createMethodBody(buffer); - break; - case HEADER_BODY: - body = AMQBody::shared_ptr(new AMQHeaderBody()); - break; - case CONTENT_BODY: - body = AMQBody::shared_ptr(new AMQContentBody()); - break; - case HEARTBEAT_BODY: - body = AMQBody::shared_ptr(new AMQHeartbeatBody()); - break; - default: - string msg("Unknown body type: "); - msg += type; - THROW_QPID_ERROR(FRAMING_ERROR, msg); - } - body->decode(buffer, size); + decodeBody(buffer, bufSize); u_int8_t end = buffer.getOctet(); if(end != 0xCE) THROW_QPID_ERROR(FRAMING_ERROR, "Frame end not found"); return true; @@ -101,7 +81,7 @@ u_int32_t AMQFrame::decodeHead(Buffer& buffer){ return buffer.getLong(); } -void AMQFrame::decodeBody(Buffer& buffer, uint32_t size) +void AMQFrame::decodeBody(Buffer& buffer, uint32_t bufSize) { switch(type) { @@ -122,7 +102,7 @@ void AMQFrame::decodeBody(Buffer& buffer, uint32_t size) msg += type; THROW_QPID_ERROR(FRAMING_ERROR, msg); } - body->decode(buffer, size); + body->decode(buffer, bufSize); } std::ostream& qpid::framing::operator<<(std::ostream& out, const AMQFrame& t){ diff --git a/cpp/common/framing/src/AMQHeaderBody.cpp b/cpp/common/framing/src/AMQHeaderBody.cpp index 1fd387c5d5..dce5f1fd54 100644 --- a/cpp/common/framing/src/AMQHeaderBody.cpp +++ b/cpp/common/framing/src/AMQHeaderBody.cpp @@ -41,12 +41,12 @@ void qpid::framing::AMQHeaderBody::encode(Buffer& buffer) const { properties->encode(buffer); } -void qpid::framing::AMQHeaderBody::decode(Buffer& buffer, u_int32_t size){ +void qpid::framing::AMQHeaderBody::decode(Buffer& buffer, u_int32_t bufSize){ u_int16_t classId = buffer.getShort(); weight = buffer.getShort(); contentSize = buffer.getLongLong(); createProperties(classId); - properties->decode(buffer, size - 12); + properties->decode(buffer, bufSize - 12); } void qpid::framing::AMQHeaderBody::createProperties(int classId){ diff --git a/cpp/common/framing/src/AMQMethodBody.cpp b/cpp/common/framing/src/AMQMethodBody.cpp index 73862bb2bf..7455050377 100644 --- a/cpp/common/framing/src/AMQMethodBody.cpp +++ b/cpp/common/framing/src/AMQMethodBody.cpp @@ -24,7 +24,7 @@ void qpid::framing::AMQMethodBody::encode(Buffer& buffer) const{ encodeContent(buffer); } -void qpid::framing::AMQMethodBody::decode(Buffer& buffer, u_int32_t size){ +void qpid::framing::AMQMethodBody::decode(Buffer& buffer, u_int32_t /*size*/){ decodeContent(buffer); } @@ -32,7 +32,7 @@ bool qpid::framing::AMQMethodBody::match(AMQMethodBody* other) const{ return other != 0 && other->amqpClassId() == amqpClassId() && other->amqpMethodId() == amqpMethodId(); } -void qpid::framing::AMQMethodBody::invoke(AMQP_ServerOperations& target, u_int16_t channel){ +void qpid::framing::AMQMethodBody::invoke(AMQP_ServerOperations& /*target*/, u_int16_t /*channel*/){ THROW_QPID_ERROR(PROTOCOL_ERROR, "Method not supported by AMQP Server."); } diff --git a/cpp/common/framing/src/BasicHeaderProperties.cpp b/cpp/common/framing/src/BasicHeaderProperties.cpp index 4219d33a8f..c9153665d5 100644 --- a/cpp/common/framing/src/BasicHeaderProperties.cpp +++ b/cpp/common/framing/src/BasicHeaderProperties.cpp @@ -23,23 +23,23 @@ qpid::framing::BasicHeaderProperties::BasicHeaderProperties() : deliveryMode(0), qpid::framing::BasicHeaderProperties::~BasicHeaderProperties(){} u_int32_t qpid::framing::BasicHeaderProperties::size() const{ - u_int32_t size = 2;//flags - if(contentType.length() > 0) size += contentType.length() + 1; - if(contentEncoding.length() > 0) size += contentEncoding.length() + 1; - if(headers.count() > 0) size += headers.size(); - if(deliveryMode != 0) size += 1; - if(priority != 0) size += 1; - if(correlationId.length() > 0) size += correlationId.length() + 1; - if(replyTo.length() > 0) size += replyTo.length() + 1; - if(expiration.length() > 0) size += expiration.length() + 1; - if(messageId.length() > 0) size += messageId.length() + 1; - if(timestamp != 0) size += 8; - if(type.length() > 0) size += type.length() + 1; - if(userId.length() > 0) size += userId.length() + 1; - if(appId.length() > 0) size += appId.length() + 1; - if(clusterId.length() > 0) size += clusterId.length() + 1; + u_int32_t bytes = 2;//flags + if(contentType.length() > 0) bytes += contentType.length() + 1; + if(contentEncoding.length() > 0) bytes += contentEncoding.length() + 1; + if(headers.count() > 0) bytes += headers.size(); + if(deliveryMode != 0) bytes += 1; + if(priority != 0) bytes += 1; + if(correlationId.length() > 0) bytes += correlationId.length() + 1; + if(replyTo.length() > 0) bytes += replyTo.length() + 1; + if(expiration.length() > 0) bytes += expiration.length() + 1; + if(messageId.length() > 0) bytes += messageId.length() + 1; + if(timestamp != 0) bytes += 8; + if(type.length() > 0) bytes += type.length() + 1; + if(userId.length() > 0) bytes += userId.length() + 1; + if(appId.length() > 0) bytes += appId.length() + 1; + if(clusterId.length() > 0) bytes += clusterId.length() + 1; - return size; + return bytes; } void qpid::framing::BasicHeaderProperties::encode(qpid::framing::Buffer& buffer) const{ @@ -62,9 +62,8 @@ void qpid::framing::BasicHeaderProperties::encode(qpid::framing::Buffer& buffer) if(clusterId.length() > 0) buffer.putShortString(clusterId); } -void qpid::framing::BasicHeaderProperties::decode(qpid::framing::Buffer& buffer, u_int32_t size){ +void qpid::framing::BasicHeaderProperties::decode(qpid::framing::Buffer& buffer, u_int32_t /*size*/){ u_int16_t flags = buffer.getShort(); - int shift = 15; if(flags & (1 << 15)) buffer.getShortString(contentType); if(flags & (1 << 14)) buffer.getShortString(contentEncoding); if(flags & (1 << 13)) buffer.getFieldTable(headers); @@ -83,7 +82,6 @@ void qpid::framing::BasicHeaderProperties::decode(qpid::framing::Buffer& buffer, u_int16_t qpid::framing::BasicHeaderProperties::getFlags() const{ u_int16_t flags(0); - int shift = 15; if(contentType.length() > 0) flags |= (1 << 15); if(contentEncoding.length() > 0) flags |= (1 << 14); if(headers.count() > 0) flags |= (1 << 13); diff --git a/cpp/common/framing/src/BodyHandler.cpp b/cpp/common/framing/src/BodyHandler.cpp index 4e4e2e02f7..b428c62637 100644 --- a/cpp/common/framing/src/BodyHandler.cpp +++ b/cpp/common/framing/src/BodyHandler.cpp @@ -21,6 +21,8 @@ using namespace qpid::framing; using namespace std::tr1; +BodyHandler::~BodyHandler() {} + void BodyHandler::handleBody(AMQBody::shared_ptr& body){ switch(body->type()) diff --git a/cpp/common/framing/src/Buffer.cpp b/cpp/common/framing/src/Buffer.cpp index 15a4485abd..87aa1df7e9 100644 --- a/cpp/common/framing/src/Buffer.cpp +++ b/cpp/common/framing/src/Buffer.cpp @@ -18,7 +18,7 @@ #include "Buffer.h" #include "FieldTable.h" -qpid::framing::Buffer::Buffer(int _size) : size(_size), position(0), limit(_size){ +qpid::framing::Buffer::Buffer(u_int32_t _size) : size(_size), position(0), limit(_size){ data = new char[size]; } @@ -37,7 +37,7 @@ void qpid::framing::Buffer::clear(){ } void qpid::framing::Buffer::compact(){ - int p = limit - position; + u_int32_t p = limit - position; //copy p chars from position to 0 memmove(data, data + position, p); limit = size; @@ -54,7 +54,7 @@ void qpid::framing::Buffer::restore(){ limit = r_limit; } -int qpid::framing::Buffer::available(){ +u_int32_t qpid::framing::Buffer::available(){ return limit - position; } @@ -62,7 +62,7 @@ char* qpid::framing::Buffer::start(){ return data + position; } -void qpid::framing::Buffer::move(int bytes){ +void qpid::framing::Buffer::move(u_int32_t bytes){ position += bytes; } @@ -123,29 +123,29 @@ u_int64_t qpid::framing::Buffer::getLongLong(){ void qpid::framing::Buffer::putShortString(const string& s){ - u_int8_t size = s.length(); - putOctet(size); - s.copy(data + position, size); - position += size; + u_int8_t len = s.length(); + putOctet(len); + s.copy(data + position, len); + position += len; } void qpid::framing::Buffer::putLongString(const string& s){ - u_int32_t size = s.length(); - putLong(size); - s.copy(data + position, size); - position += size; + u_int32_t len = s.length(); + putLong(len); + s.copy(data + position, len); + position += len; } void qpid::framing::Buffer::getShortString(string& s){ - u_int8_t size = getOctet(); - s.assign(data + position, size); - position += size; + u_int8_t len = getOctet(); + s.assign(data + position, len); + position += len; } void qpid::framing::Buffer::getLongString(string& s){ - u_int32_t size = getLong(); - s.assign(data + position, size); - position += size; + u_int32_t len = getLong(); + s.assign(data + position, len); + position += len; } void qpid::framing::Buffer::putFieldTable(const FieldTable& t){ @@ -157,12 +157,12 @@ void qpid::framing::Buffer::getFieldTable(FieldTable& t){ } void qpid::framing::Buffer::putRawData(const string& s){ - u_int32_t size = s.length(); - s.copy(data + position, size); - position += size; + u_int32_t len = s.length(); + s.copy(data + position, len); + position += len; } -void qpid::framing::Buffer::getRawData(string& s, u_int32_t size){ - s.assign(data + position, size); - position += size; +void qpid::framing::Buffer::getRawData(string& s, u_int32_t len){ + s.assign(data + position, len); + position += len; } diff --git a/cpp/common/framing/src/FieldTable.cpp b/cpp/common/framing/src/FieldTable.cpp index b12b2783df..088c8fb500 100644 --- a/cpp/common/framing/src/FieldTable.cpp +++ b/cpp/common/framing/src/FieldTable.cpp @@ -27,12 +27,12 @@ namespace framing { FieldTable::~FieldTable() {} u_int32_t FieldTable::size() const { - u_int32_t size(4); + u_int32_t len(4); for(ValueMap::const_iterator i = values.begin(); i != values.end(); ++i) { // 2 = shortstr_len_byyte + type_char_byte - size += 2 + (i->first).size() + (i->second)->size(); + len += 2 + (i->first).size() + (i->second)->size(); } - return size; + return len; } int FieldTable::count() const { @@ -74,9 +74,6 @@ void FieldTable::setTable(const std::string& name, const FieldTable& value){ } namespace { -// TODO aconway 2006-09-26: This is messy. Revisit the field table -// and Value classes with a traits-based approach. -// template <class T> T default_value() { return T(); } template <> int default_value<int>() { return 0; } template <> u_int64_t default_value<u_int64_t>() { return 0; } @@ -117,9 +114,11 @@ void FieldTable::encode(Buffer& buffer) const{ } void FieldTable::decode(Buffer& buffer){ - u_int32_t size = buffer.getLong(); - int leftover = buffer.available() - size; - + u_int32_t len = buffer.getLong(); + u_int32_t available = buffer.available(); + if (available < len) + THROW_QPID_ERROR(FRAMING_ERROR, "Not enough data for field table."); + u_int32_t leftover = available - len; while(buffer.available() > leftover){ std::string name; buffer.getShortString(name); diff --git a/cpp/common/framing/src/InitiationHandler.cpp b/cpp/common/framing/src/InitiationHandler.cpp new file mode 100644 index 0000000000..9c18facf44 --- /dev/null +++ b/cpp/common/framing/src/InitiationHandler.cpp @@ -0,0 +1,21 @@ +/* + * + * Copyright (c) 2006 The Apache Software Foundation + * + * 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. + * + */ + +#include "InitiationHandler.h" + +qpid::framing::InitiationHandler::~InitiationHandler() {} diff --git a/cpp/common/framing/src/InputHandler.cpp b/cpp/common/framing/src/InputHandler.cpp new file mode 100644 index 0000000000..7116caa24a --- /dev/null +++ b/cpp/common/framing/src/InputHandler.cpp @@ -0,0 +1,21 @@ +/* + * + * Copyright (c) 2006 The Apache Software Foundation + * + * 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. + * + */ + +#include "InputHandler.h" + +qpid::framing::InputHandler::~InputHandler() {} diff --git a/cpp/common/framing/src/OutputHandler.cpp b/cpp/common/framing/src/OutputHandler.cpp new file mode 100644 index 0000000000..8d99b4ef92 --- /dev/null +++ b/cpp/common/framing/src/OutputHandler.cpp @@ -0,0 +1,21 @@ +/* + * + * Copyright (c) 2006 The Apache Software Foundation + * + * 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. + * + */ + +#include "OutputHandler.h" + +qpid::framing::OutputHandler::~OutputHandler() {} diff --git a/cpp/common/framing/test/BodyHandlerTest.cpp b/cpp/common/framing/test/BodyHandlerTest.cpp index 94038d9a6c..1cad6afe02 100644 --- a/cpp/common/framing/test/BodyHandlerTest.cpp +++ b/cpp/common/framing/test/BodyHandlerTest.cpp @@ -17,11 +17,7 @@ */ #include <iostream> #include "amqp_framing.h" -#include <cppunit/TestCase.h> -#include <cppunit/TextTestRunner.h> -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/plugin/TestPlugIn.h> - +#include "qpid_test_plugin.h" using namespace qpid::framing; class BodyHandlerTest : public CppUnit::TestCase diff --git a/cpp/common/framing/test/field_table_test.cpp b/cpp/common/framing/test/field_table_test.cpp index 48332e05bc..535f7f4a08 100644 --- a/cpp/common/framing/test/field_table_test.cpp +++ b/cpp/common/framing/test/field_table_test.cpp @@ -17,10 +17,7 @@ */ #include <iostream> #include "amqp_framing.h" -#include <cppunit/TestCase.h> -#include <cppunit/TextTestRunner.h> -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/plugin/TestPlugIn.h> +#include <qpid_test_plugin.h> using namespace qpid::framing; diff --git a/cpp/common/framing/test/framing_test.cpp b/cpp/common/framing/test/framing_test.cpp index 1978c2cbed..8c69f8718a 100644 --- a/cpp/common/framing/test/framing_test.cpp +++ b/cpp/common/framing/test/framing_test.cpp @@ -19,10 +19,7 @@ #include "ConnectionRedirectBody.h" #include <iostream> #include <sstream> -#include <cppunit/TestCase.h> -#include <cppunit/TextTestRunner.h> -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/plugin/TestPlugIn.h> +#include <qpid_test_plugin.h> #include <typeinfo> using namespace qpid::framing; diff --git a/cpp/common/framing/test/header_test.cpp b/cpp/common/framing/test/header_test.cpp index 0ff6d47d57..f98dd5d108 100644 --- a/cpp/common/framing/test/header_test.cpp +++ b/cpp/common/framing/test/header_test.cpp @@ -17,10 +17,7 @@ */ #include <iostream> #include "amqp_framing.h" -#include <cppunit/TestCase.h> -#include <cppunit/TextTestRunner.h> -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/plugin/TestPlugIn.h> +#include <qpid_test_plugin.h> using namespace qpid::framing; |