| 24 | namespace NetUtils |
| 25 | { |
| 26 | int pbufFindChar(const pbuf* buf, char wtf, unsigned startPos) |
| 27 | { |
| 28 | unsigned ofs = 0; |
| 29 | |
| 30 | while(buf->len <= startPos) { |
| 31 | ofs += buf->len; |
| 32 | startPos -= buf->len; |
| 33 | buf = buf->next; |
| 34 | if(buf == nullptr) { |
| 35 | return -1; |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | do { |
| 40 | for(unsigned i = startPos; i < buf->len; i++) { |
| 41 | char* sbuf = (char*)buf->payload; |
| 42 | if(sbuf[i] == wtf) { |
| 43 | //debug_d("%d %d", ofs, i); |
| 44 | return ofs + i; |
| 45 | } |
| 46 | } |
| 47 | ofs += buf->len; |
| 48 | buf = buf->next; |
| 49 | startPos = 0; |
| 50 | } while(buf != nullptr); |
| 51 | |
| 52 | return -1; |
| 53 | } |
| 54 | |
| 55 | bool pbufIsStrEqual(const pbuf* buf, const char* compared, unsigned startPos) |
| 56 | { |
no outgoing calls
no test coverage detected