| 82 | } |
| 83 | |
| 84 | size_t EqualityComparisonFilter::ChannelPut2(const std::string &channel, const byte *inString, size_t length, int messageEnd, bool blocking) |
| 85 | { |
| 86 | if (!blocking) |
| 87 | throw BlockingInputOnly("EqualityComparisonFilter"); |
| 88 | |
| 89 | unsigned int i = MapChannel(channel); |
| 90 | |
| 91 | if (i == 2) |
| 92 | return Output(3, inString, length, messageEnd, blocking, channel); |
| 93 | else if (m_mismatchDetected) |
| 94 | return 0; |
| 95 | else |
| 96 | { |
| 97 | MessageQueue &q1 = m_q[i], &q2 = m_q[1-i]; |
| 98 | |
| 99 | if (q2.AnyMessages() && q2.MaxRetrievable() < length) |
| 100 | goto mismatch; |
| 101 | |
| 102 | while (length > 0 && q2.AnyRetrievable()) |
| 103 | { |
| 104 | size_t len = length; |
| 105 | const byte *data = q2.Spy(len); |
| 106 | len = STDMIN(len, length); |
| 107 | if (memcmp(inString, data, len) != 0) |
| 108 | goto mismatch; |
| 109 | inString += len; |
| 110 | length -= len; |
| 111 | q2.Skip(len); |
| 112 | } |
| 113 | |
| 114 | q1.Put(inString, length); |
| 115 | |
| 116 | if (messageEnd) |
| 117 | { |
| 118 | if (q2.AnyRetrievable()) |
| 119 | goto mismatch; |
| 120 | else if (q2.AnyMessages()) |
| 121 | q2.GetNextMessage(); |
| 122 | else if (q2.NumberOfMessageSeries() > 0) |
| 123 | goto mismatch; |
| 124 | else |
| 125 | q1.MessageEnd(); |
| 126 | } |
| 127 | |
| 128 | return 0; |
| 129 | |
| 130 | mismatch: |
| 131 | return HandleMismatchDetected(blocking); |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | bool EqualityComparisonFilter::ChannelMessageSeriesEnd(const std::string &channel, int propagation, bool blocking) |
| 136 | { |
no test coverage detected