38 NetBuffer::~NetBuffer() {
delete buf; }
43 if (s.length() >
size) {
69 if (
noRefill || full())
return false;
78 if (n <= 0)
return false;
93 s.append(
buf,len-len1);
106 if (p ==
wp && !
refill())
return false;
107 if (!isspace(*p))
break;
121 if (p ==
wp && !
refill())
return false;
122 if (!isspace(*p) || *p ==
'\n')
break;
140 char* p =
rp;
int len = 0;
142 if (p ==
wp && !
refill())
return false;
163 if (!isWordChar(*p))
return false;
166 if (p ==
wp && !
refill())
return false;
167 if (!isWordChar(*p)) {
168 if (len == 0)
return false;
182 if (!isalpha(*p))
return false;
189 if (len == 0)
return false;
208 if (!isalpha(*p))
return false;
211 if (p ==
wp && !
refill())
return false;
212 if (!isalpha(*p) && !isdigit(*p) && *p !=
'_') {
213 if (len == 0)
return false;
229 if (*p !=
'\"')
return false;
230 advance(p);
rp = p;
int len = 0;
232 if (p ==
wp && !
refill())
return false;
234 extract(len,s); advance(
rp);
return true;
247 if (*
rp ==
'0') { advance(
rp); b =
false;
return true; }
248 if (*
rp ==
'1') { advance(
rp); b =
true;
return true; }
261 if (!isdigit(*p) && *p !=
'-')
return false;
262 advance(p);
int len = 1;
264 if (p ==
wp && !
refill())
return false;
266 if (len == 0)
return false;
268 istringstream ss(s); ss >> i;
278 if (!isdigit(*p) && *p !=
'-')
return false;
279 advance(p);
int len = 1;
281 if (p ==
wp && !
refill())
return false;
283 if (len == 0)
return false;
285 istringstream ss(s); ss >> i;
301 if (!isdigit(*p))
return false;
302 int len = 0;
int dotCount = 0;
304 if (p ==
wp && !
refill())
return false;
305 if (*p ==
'.' && dotCount < 1) {
307 }
else if (!isdigit(*p) && *p !=
'.') {
308 if (len == 0)
return false;
319 return Packet::string2pktTyp(s,type);
325 return CtlPkt::string2cpType(s,cpTyp);
337 if (!isdigit(*p))
return false;
338 int len = 0;
int dotCount = 0;
340 if (p ==
wp && !
refill())
return false;
341 if (*p ==
'.' && dotCount < 3) {
343 }
else if (!isdigit(*p) && *p !=
'.') {
344 if (len == 0)
return false;
360 char* p =
rp;
int i = 0;
363 xbuf[i++] = *p; advance(p);
365 xbuf[i] =
'\0';
rp = p;
369 bool NetBuffer::readRspec(
RateSpec& rates) {
370 int bru, brd, pru, prd;
374 rates.
set(bru,brd,pru,prd);
return true;
386 if (*
rp != c)
return false;
387 advance(
rp);
return true;
396 if (p ==
wp && !
refill())
return false;
397 if (*p ==
'\n')
break;
400 rp = p; advance(
rp);
return true;
417 string& NetBuffer::toString(
string& s) {
419 ss <<
"rp=" << (
rp-
buf) <<
" wp=" << (
wp-
buf) << endl;