D
Da Wang
Hi, all
I am trying to use sscanf to parse the header for a web server,
according to the requirement, it need to neglect all the blanks in the
header
for example, all the following should be equvalient and the value should
be read correctly( get "Host" and "localhost" )
" Host: localhost "
" Host : localhost "
" Host :localhost "
"Host:localhost"
etc.
I have tried various ways and wrote the following code:
--------
st=sscanf(header, " %[a-zA-Z0-9_-] : %[^ ]" ,name, value);
---------
and so far it seems works..however, it only support a limit set of chars
and if I want more, I need to add all of them into the bracket, which
looks awkward. I am wondering if anyone has a better solution to my
problem and hope you could kindly help me out.
Many thanks.
--
Life is an opportunity to do something.
.-._
o_oo'_)
`._ `._
`, \
//_(_)_/
~~
I am trying to use sscanf to parse the header for a web server,
according to the requirement, it need to neglect all the blanks in the
header
for example, all the following should be equvalient and the value should
be read correctly( get "Host" and "localhost" )
" Host: localhost "
" Host : localhost "
" Host :localhost "
"Host:localhost"
etc.
I have tried various ways and wrote the following code:
--------
st=sscanf(header, " %[a-zA-Z0-9_-] : %[^ ]" ,name, value);
---------
and so far it seems works..however, it only support a limit set of chars
and if I want more, I need to add all of them into the bracket, which
looks awkward. I am wondering if anyone has a better solution to my
problem and hope you could kindly help me out.
Many thanks.
--
Life is an opportunity to do something.
.-._
o_oo'_)
`._ `._
`, \
//_(_)_/
~~