MCPcopy Create free account
hub / github.com/SmingHub/Sming / pbufFindChar

Function pbufFindChar

Sming/Components/Network/src/Network/NetUtils.cpp:26–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24namespace NetUtils
25{
26int 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
55bool pbufIsStrEqual(const pbuf* buf, const char* compared, unsigned startPos)
56{

Callers 2

pbufFindStrFunction · 0.85
onReceiveMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected