Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 2 May 2011 07:06:32 -0700
From:      Artem Belevich <art@freebsd.org>
To:        Robert Schulze <rs@bytecamp.net>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: [LIBC] Modfied Version of sscanf
Message-ID:  <BANLkTim_WhRdWi8RbuubxQm4kD27V17h9g@mail.gmail.com>
In-Reply-To: <4DBEAAD5.7040906@bytecamp.net>
References:  <C9E46C77.389%moeller.akt@googlemail.com> <4DBEAAD5.7040906@bytecamp.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, May 2, 2011 at 6:00 AM, Robert Schulze <rs@bytecamp.net> wrote:
> Hi,
>
> Am 02.05.2011 14:13, schrieb Martin M=F6ller:
>>
>> Criteria:
>> =A0 =A0 o Receive the value of<resource>
>> =A0 =A0 o Check the Environment: Is<resource> =A0really sourrounded by '=
GET '
>> and
>> =A0 =A0 =A0 'HTTP/1.1' ?!
>
> these quite simple criteria might be matched by code like this one:
>
> char *ptr=3DNULL;
> char *res=3DNULL;
> if(strstr(str,"GET ")=3D=3Dstr) /* "GET " at beginning? */
> =A0 =A0 =A0 =A0{
> =A0 =A0 =A0 =A0ptr=3D(str+4);
> =A0 =A0 =A0 =A0if(ptr && (ptr=3Dstrstr(ptr," HTTP/1.1"))) /* find end of =
res */
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0{
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0*ptr=3D0; /* temp delimiter */
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0res=3Dstrdup(ptr);
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0*ptr=3D' '; /* restore original value of s=
tr */
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}
> =A0 =A0 =A0 =A0}

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=
=3D0.

--Artem

> with kind regards,
> Robert Schulze
> _______________________________________________
> freebsd-hackers@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org=
"
>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?BANLkTim_WhRdWi8RbuubxQm4kD27V17h9g>