You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
808 B
C

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