* Updated message reading to use the new MSG4 command, so we can do output
[citadel.git] / webcit / html2html.c
index 8fdc8cb38de2840d06bec0d429c4f370cf4e2d07..705d7e76e709c88ee551423e9653c1f677b6967d 100644 (file)
 #include <signal.h>
 #include "webcit.h"
 #include "vcard.h"
+#include "webserver.h"
 
 
 /*
- * Here we go.  Please note that the buffer may be changed by this function!
  */
-void output_text_html(char *partbuf, int total_length) {
-
+void output_html(void) {
+       char buf[SIZ];
+       char *msg;
        char *ptr;
        char *msgstart;
        char *msgend;
+       int total_length = 1;
+       int line_length = 0;
+
+       msg = strdup("");
+       msgstart = msg;
+       msgend = msg;
+
+       while (serv_gets(buf), strcmp(buf, "000")) {
+               line_length = strlen(buf);
+               total_length = total_length + line_length + 1;
+               msg = realloc(msg, total_length);
+               strcpy(msgend, buf);
+               strcat(msgend, "\n");
+               msgend = &msgend[line_length + 1];
+       }
+
+       ptr = msg;
+       msgstart = msg;
+       msgend = &msg[total_length];
 
-       ptr = partbuf;
-       msgstart = partbuf;
-       msgend = &partbuf[total_length];
+       fprintf(stderr, "msg looks like this:\n%s\n", ptr);
 
        while (ptr < msgend) {
 
@@ -75,7 +93,11 @@ void output_text_html(char *partbuf, int total_length) {
 
        write(WC->http_sock, msgstart, strlen(msgstart));
 
-       /* Close a bunch of tags that might have been opened */
+       /* Close a bunch of tags that might have been opened 
        wprintf("</I></B></FONT></TD></TR></TABLE></TT></PRE></A><BR>\n");
+        */
+
+       /* Now give back the memory */
+       free(msg);
 }