diff -r -c RAToolSet-4.6.3/src/irr/birdwhoisc.cc RAToolSet-4.6.3-patched/src/irr/birdwhoisc.cc *** RAToolSet-4.6.3/src/irr/birdwhoisc.cc Thu Oct 14 20:13:22 1999 --- RAToolSet-4.6.3-patched/src/irr/birdwhoisc.cc Mon Feb 19 15:12:59 2001 *************** *** 9,14 **** --- 9,15 ---- #include "rpsl/object_log.hh" #include #include + #include #ifndef BUFFER_SIZE #define BUFFER_SIZE 2047 *************** *** 90,95 **** --- 91,116 ---- return true; } + // remove RIPE-style comments + static void stripRipeComments(Buffer &buf) + { + // remove leading '\n' characters, if any + while ((buf.getSize() > 0) && ((buf.getContents())[0] == '\n')) { + buf.flush(1); + } + + // remove comments at beginning of buffer + while ((buf.getSize() >= 2) && ((buf.getContents())[0] == '%')) { + char *contents = buf.getContents(); + char *eol = (char *)memchr(contents, '\n', buf.getSize()); + if (eol == NULL) { + // no EOL, no comment to strip (yet) + return; + } + buf.flush(eol-contents+1); + } + } + bool BirdWhoisClient::getResponse(char *&text, int &len) { int bytesRead; bool found = false; *************** *** 111,116 **** --- 132,144 ---- && response->contents[endOfQuery+2] == '\n') found = true; + if ((response->size == 2) && + (response->contents[0] == '\n') && + (response->contents[1] == '\n')) + { + found = true; + } + if (found) break; *************** *** 125,130 **** --- 153,159 ---- response=NULL; return false; } + stripRipeComments(*response); } while (!found); Buffer *result = response;