[LIBC] Modfied Version of sscanf
Artem Belevich
art at freebsd.org
Mon May 2 14:06:34 UTC 2011
On Mon, May 2, 2011 at 6:00 AM, Robert Schulze <rs at bytecamp.net> wrote:
> Hi,
>
> Am 02.05.2011 14:13, schrieb Martin Möller:
>>
>> Criteria:
>> o Receive the value of<resource>
>> o Check the Environment: Is<resource> really sourrounded by 'GET '
>> and
>> 'HTTP/1.1' ?!
>
> these quite simple criteria might be matched by code like this one:
>
> char *ptr=NULL;
> char *res=NULL;
> if(strstr(str,"GET ")==str) /* "GET " at beginning? */
> {
> ptr=(str+4);
> if(ptr && (ptr=strstr(ptr," HTTP/1.1"))) /* find end of res */
> {
> *ptr=0; /* temp delimiter */
> res=strdup(ptr);
> *ptr=' '; /* restore original value of str */
> }
> }
Bzzt!
Try it on "GET blah_HTTP/1.1.1.1.1.1_whatever HTTP/1.1"
>
> res is the value of <resource>, or NULL.
>
Second problem -- res on success will always be "" as you've just did *ptr=0.
--Artem
> with kind regards,
> Robert Schulze
> _______________________________________________
> freebsd-hackers at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> To unsubscribe, send any mail to "freebsd-hackers-unsubscribe at freebsd.org"
>
More information about the freebsd-hackers
mailing list