Mirror of :pserver:cvs@cvs.fefe.de:/cvs libowfat https://www.fefe.de/libowfat/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

36 lines
875 B

#include "fmt.h"
#include "textcode.h"
#include "haveinline.h"
#include "case.h"
unsigned long scan_html(const char *src,char *dest,unsigned long *destlen) {
register const unsigned char* s=(const unsigned char*) src;
unsigned long written=0,i;
for (i=0; s[i]; ++i) {
if (s[i]=='&') {
if (case_starts((const char*)s+i+1,"amp;")) {
dest[written]='&';
i+=4;
} else if (case_starts((const char*)s+i+1,"lt;")) {
dest[written]='<';
i+=3;
} else if (case_starts((const char*)s+i+1,"gt;")) {
dest[written]='>';
i+=3;
}
} else if (s[i]=='<') {
if (case_starts((const char*)s+i+1,"br>")) {
dest[written]='\n';
i+=3;
} else if (case_starts((const char*)s+i+1,"p>")) {
dest[written]='\n'; ++written;
dest[written]='\n';
i+=3;
}
} else
dest[written]=s[i];
++written;
}
*destlen=written;
return i;
}