4 * Output an HTML message, modifying it slightly to make sure it plays nice
5 * with the rest of our web framework.
15 #include <sys/types.h>
17 #include <sys/socket.h>
19 #include <netinet/in.h>
29 #include "webserver.h"
34 void output_html(void) {
47 while (serv_gets(buf), strcmp(buf, "000")) {
48 line_length = strlen(buf);
49 total_length = total_length + line_length + 1;
50 msg = realloc(msg, total_length);
53 msgend = &msgend[line_length + 1];
58 msgend = &msg[total_length];
60 while (ptr < msgend) {
62 /* Advance to next tag */
63 ptr = strchr(ptr, '<');
66 /* Any of these tags cause everything up to and including
67 * the tag to be removed.
69 if ( (!strncasecmp(ptr, "HTML", 4))
70 ||(!strncasecmp(ptr, "HEAD", 4))
71 ||(!strncasecmp(ptr, "/HEAD", 5))
72 ||(!strncasecmp(ptr, "BODY", 4)) ) {
73 ptr = strchr(ptr, '>');
78 /* Any of these tags cause everything including and following
79 * the tag to be removed.
81 if ( (!strncasecmp(ptr, "/HTML", 5))
82 ||(!strncasecmp(ptr, "/BODY", 5)) ) {
92 write(WC->http_sock, msgstart, strlen(msgstart));
94 /* A little trailing vertical whitespace... */
95 wprintf("<BR><BR>\n");
97 /* Now give back the memory */