| 5 | using namespace pubsub; |
| 6 | |
| 7 | ParseResult pubsub::parseMessage(Buffer* buf, |
| 8 | string* cmd, |
| 9 | string* topic, |
| 10 | string* content) |
| 11 | { |
| 12 | ParseResult result = kError; |
| 13 | const char* crlf = buf->findCRLF(); |
| 14 | if (crlf) |
| 15 | { |
| 16 | const char* space = std::find(buf->peek(), crlf, ' '); |
| 17 | if (space != crlf) |
| 18 | { |
| 19 | cmd->assign(buf->peek(), space); |
| 20 | topic->assign(space+1, crlf); |
| 21 | if (*cmd == "pub") |
| 22 | { |
| 23 | const char* start = crlf + 2; |
| 24 | crlf = buf->findCRLF(start); |
| 25 | if (crlf) |
| 26 | { |
| 27 | content->assign(start, crlf); |
| 28 | buf->retrieveUntil(crlf+2); |
| 29 | result = kSuccess; |
| 30 | } |
| 31 | else |
| 32 | { |
| 33 | result = kContinue; |
| 34 | } |
| 35 | } |
| 36 | else |
| 37 | { |
| 38 | buf->retrieveUntil(crlf+2); |
| 39 | result = kSuccess; |
| 40 | } |
| 41 | } |
| 42 | else |
| 43 | { |
| 44 | result = kError; |
| 45 | } |
| 46 | } |
| 47 | else |
| 48 | { |
| 49 | result = kContinue; |
| 50 | } |
| 51 | return result; |
| 52 | } |
| 53 |
nothing calls this directly
no test coverage detected