--- a/servlib/bundling/BPQBlock.cc Fri May 27 18:33:25 2011 +0100
+++ b/servlib/bundling/BPQBlock.cc Mon May 30 19:36:18 2011 +0100
@@ -65,15 +65,43 @@
BPQBlock::~BPQBlock()
{
log_info_p(LOG, "BPQBlock: destructor");
-//TODO
-/*
if ( query_val_ != NULL ){
free(query_val_);
query_val_ = NULL;
}
-*/
+}
+/*
+int
+BPQBlock::format(char* buf, size_t sz) const
+{
+ if ( kind_ == KIND_QUERY ) {
+ return snprintf (buf, sz, "BPQ Query [%s] Matching Rule [%d]",
+ query_val_,
+ matching_rule_);
+ } else if ( kind_ == KIND_RESPONSE ) {
+ return snprintf (buf, sz, "BPQ Response [%s] Matching Rule [%d]",
+ query_val_,
+ matching_rule_);
+ } else
+ return snprintf (buf, sz, "INVALID BPQ KIND [%d]", kind_);
+ }
}
+void
+BPQBlock::format_verbose(oasys::StringBuffer* buf) const
+{
+ if ( kind_ == KIND_QUERY )
+ buf->appendf(" BPQ Query:\n");
+ else if ( kind_ == KIND_RESPONSE )
+ buf->appendf(" BPQ Response:\n");
+
+ buf->appendf("Matching Rule: %d\n", matching_rule_);
+ buf->appendf(" Query Length: %d\n", query_len_);
+ buf->appendf(" Query Value: %s\n", query_val_);
+ buf->appendf("\n");
+
+}
+*/
int
BPQBlock::write_to_buffer(u_char* buf, size_t len)
{
@@ -131,20 +159,31 @@
}
bool
-BPQBlock::match(BPQBlock* other) const
+BPQBlock::match(const BPQBlock* other) const
{
+/*
log_debug_p(LOG, "_BPQ_ Match: this(%s) other(%s)",
(char*)query_val_,
(char*)other->query_val());
-
+*/
return query_len_ == other->query_len() &&
strncmp( (char*)query_val_, (char*)other->query_val(),
query_len_ ) == 0;
}
int
-BPQBlock::initialise(BlockInfo* block)
+BPQBlock::initialise(BlockInfo* b)
{
+ ASSERT ( b != NULL);
+
+ BlockInfo* block = NULL;
+
+ if ( b->source() != NULL ) {
+ block = const_cast<BlockInfo*>(b->source());
+ } else {
+ block = b;
+ }
+
int decoding_len=0;
u_int i=0, j=0;
u_int len = block->data_length();