[Courses] How to get line-information from buffer..

sneha sneha at vit.ac.in
Tue Oct 1 14:38:21 EST 2002


**Hello :)
A small example I tried....hope, it will work..try to use ur comparison from the red line..., buff_dest gives u one line at a time from the whole buffer (buff_source) which contained...

GET / HTTP/1.0
 Connection: Keep-Alive
 User-Agent: Mozilla/4.75 [en] (X11; U; Linux
 2.2.17-21mdk i686)
 Host: localhost:8000
 Accept: image/gif, image/x-xbitmap, image/jpeg,
 image/pjpeg, image/png, */*
 Accept-Encoding: gzip
 Accept-Language: en
 Accept-Charset: iso-8859-1,*,utf-8


code segment:
-------------------

while(buff_source[i]!='\0')
{
    buff_dest=(char *) calloc(sizeof(char *),250);
    while(buff_source[i]!='\n')
    {
        buff_dest[j]=buff_source[i];
        i++;j++;
    }
    i++; /* to start from the next line */
    j=0;
    printf("Line: %s\n",buff_dest);
    sscanf(buff_dest,"%s",h);
    if(!strcmp(h,"Host:"))
    {
        printf("Compare now:\n%s",buff_dest);
  
--------------------------------------------------------------------------------
    }         
}
            

good day
friendly
sneha :o)


----- Original Message ----- 
From: Abel Pires da Silva <lybel_2000 at yahoo.com>
To: Linuxchix <courses at linuxchix.org>
Sent: Tuesday, October 01, 2002 11:12 AM
Subject: Re: [Courses] How to get line-information from buffer..


> You need to do something like:
> 
> for each line in *buffer {
>   for each line in *file {
>     if ((strstr(buffer,file)) != NULL ) {
>       Do stuff for line match
>     }
>   }
> }
> 
> Thank you Conor for pointing the problem...
> But I think with some example of the above, will make
> it clear...
> 
> Regards,
> Abel
> 
> __________________________________________________
> Do you Yahoo!?
> New DSL Internet Access from SBC & Yahoo!
> http://sbc.yahoo.com
> _______________________________________________
> Courses mailing list
> Courses at linuxchix.org
> http://mailman.linuxchix.org/mailman/listinfo/courses
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://linuxchix.org/pipermail/courses/attachments/20021001/b0da7ce6/attachment.xhtml


More information about the Courses mailing list