|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// find returns true if the target string is found |
|
|
// find returns true if the target string is found |
|
|
bool Stream::find(char *target) |
|
|
|
|
|
|
|
|
bool Stream::find(const char *target) |
|
|
{ |
|
|
{ |
|
|
return findUntil(target, NULL); |
|
|
return findUntil(target, NULL); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// reads data from the stream until the target string of given length is found |
|
|
// reads data from the stream until the target string of given length is found |
|
|
// returns true if target string is found, false if timed out |
|
|
// returns true if target string is found, false if timed out |
|
|
bool Stream::find(char *target, size_t length) |
|
|
|
|
|
|
|
|
bool Stream::find(const char *target, size_t length) |
|
|
{ |
|
|
{ |
|
|
return findUntil(target, length, NULL, 0); |
|
|
return findUntil(target, length, NULL, 0); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// as find but search ends if the terminator string is found |
|
|
// as find but search ends if the terminator string is found |
|
|
bool Stream::findUntil(char *target, char *terminator) |
|
|
|
|
|
|
|
|
bool Stream::findUntil(const char *target, char *terminator) |
|
|
{ |
|
|
{ |
|
|
return findUntil(target, strlen(target), terminator, strlen(terminator)); |
|
|
return findUntil(target, strlen(target), terminator, strlen(terminator)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// reads data from the stream until the target string of the given length is found |
|
|
// reads data from the stream until the target string of the given length is found |
|
|
// search terminated if the terminator string is found |
|
|
// search terminated if the terminator string is found |
|
|
// returns true if target string is found, false if terminated or timed out |
|
|
// returns true if target string is found, false if terminated or timed out |
|
|
bool Stream::findUntil(char *target, size_t targetLen, char *terminator, size_t termLen) |
|
|
|
|
|
|
|
|
bool Stream::findUntil(const char *target, size_t targetLen, char *terminator, size_t termLen) |
|
|
{ |
|
|
{ |
|
|
size_t index = 0; // maximum target string length is 64k bytes! |
|
|
size_t index = 0; // maximum target string length is 64k bytes! |
|
|
size_t termIndex = 0; |
|
|
size_t termIndex = 0; |