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 fprintf(stderr, "msg looks like this:\n%s\n", ptr);
62 while (ptr < msgend) {
64 /* Advance to next tag */
65 ptr = strchr(ptr, '<');
68 /* Any of these tags cause everything up to and including
69 * the tag to be removed.
71 if ( (!strncasecmp(ptr, "HTML", 4))
72 ||(!strncasecmp(ptr, "HEAD", 4))
73 ||(!strncasecmp(ptr, "/HEAD", 5))
74 ||(!strncasecmp(ptr, "BODY", 4)) ) {
75 ptr = strchr(ptr, '>');
80 /* Any of these tags cause everything including and following
81 * the tag to be removed.
83 if ( (!strncasecmp(ptr, "/HTML", 5))
84 ||(!strncasecmp(ptr, "/BODY", 5)) ) {
94 write(WC->http_sock, msgstart, strlen(msgstart));
96 /* Close a bunch of tags that might have been opened
97 wprintf("</I></B></FONT></TD></TR></TABLE></TT></PRE></A><BR>\n");
100 /* Now give back the memory */