Add some comments to 'readMatch'.

git-svn-id: svn+ssh://oldsvn/home/mlalondesvn/svn/cral@81 3ee9b42a-b53c-0410-a25e-f0b6218d5d5b
master
follower 17 years ago
parent 3d3d14263a
commit 2e4f5189df

@ -201,12 +201,27 @@ uint8_t readByte() {
int readMatch(char *stringToMatch) { int readMatch(char *stringToMatch) {
/*
Routine to read and match bytes received.
(Essentially strcmp replacement without requiring a large receive buffer.)
NOTE: Failed matches drop all bytes read so far. (i.e. you can't check for
a bunch of possible matches from the same starting position).
TODO: Fix this.
Note: This blocks if there isn't enough data in the rx buffer.
*/
while (getSn_RX_RSR(testSocket) < strlen(stringToMatch)) { while (getSn_RX_RSR(testSocket) < strlen(stringToMatch)) {
// block // block
// TODO: Return error or wait or "too short"? // TODO: Return error or wait or "too short"?
} }
// TODO: Do fancy string-matching techniques to avoid reading the whole string
// on non-matches. :-)
for (int currCharIdx = 0; currCharIdx < strlen(stringToMatch); currCharIdx++) { for (int currCharIdx = 0; currCharIdx < strlen(stringToMatch); currCharIdx++) {
if (readByte() != stringToMatch[currCharIdx]) { if (readByte() != stringToMatch[currCharIdx]) {
return 0; return 0;

Loading…
Cancel
Save