Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Thursday, March 28, 2024

File: [Platon] / libplaton / platon / html / read.c (download)

Revision 1.5, Sat Oct 5 09:52:43 2002 UTC (21 years, 5 months ago) by nepto


Changes since 1.4: +3 -3 lines

CVS tag $Id was cahnged fro $Platon.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <platon/html/read.h>

enum html_reads html_read(FILE *f, char *p, int len)
{
    int i=0;
    if(f==NULL||p==NULL)return(HTML_ERROR);

    while(1){
        if(i==len-1)break;
        p[i]=getc(f);

        if(feof(f))break;
        if(p[i]=='\0')break;

        if(p[0]==HTML_TAG_BEGIN){
            if(p[i]==HTML_TAG_END){
                if(i<=4||strncmp(p,"<!--",4)||(!strncmp(p,"<!--",4)&&!strncmp(p+i-2,"-->",3))){
                    i++;
                    break;
                }
            }
        }
        else{
            if(p[i]==HTML_TAG_BEGIN){
                ungetc(p[i],f);
                break;
            }
        }
        i++;
    }

    if(!i){
        /* free(p); */
        return(HTML_EOF);
    }
    else{
        p[i]='\0';
        return(p[0]==HTML_TAG_BEGIN?HTML_TAG:HTML_TEXT);
    }
}


Platon Group <platon@platon.org> http://platon.org/
Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top