]> code.citadel.org Git - citadel.git/blobdiff - citadel/html.c
* Removed all of the thread cancellation cruft that is no longer necessary
[citadel.git] / citadel / html.c
index 7127c89ac18408adc9786be16c63f8bef3d0f33d..a4d67929511cc14c55f23d2d13e44f8d686ec165 100644 (file)
@@ -14,9 +14,6 @@
 #include <string.h>
 #include <errno.h>
 #include <limits.h>
-#ifdef HAVE_PTHREAD_H
-#include <pthread.h>
-#endif
 #include <syslog.h>
 #include "citadel.h"
 #include "server.h"
 
 /*
  * Convert HTML to plain text.
+ *
+ * inputmsg      = pointer to raw HTML message
+ * screenwidth   = desired output screenwidth
+ * do_citaformat = set to 1 to indent newlines with spaces
  */
-char *html_to_ascii(char *inputmsg, int screenwidth) {
+char *html_to_ascii(char *inputmsg, int screenwidth, int do_citaformat) {
        char inbuf[256];
        char outbuf[256];
        char tag[1024];
@@ -99,6 +100,10 @@ char *html_to_ascii(char *inputmsg, int screenwidth) {
                                        strcat(outbuf, "\n\n");
                                }
 
+                               if (!strcasecmp(tag, "/DIV")) {
+                                       strcat(outbuf, "\n\n");
+                               }
+
                                else if (!strcasecmp(tag, "H1")) {
                                        strcat(outbuf, "\n\n");
                                }
@@ -220,9 +225,10 @@ char *html_to_ascii(char *inputmsg, int screenwidth) {
                        if (strlen(outbuf)>0)
                            for (i = 0; i<strlen(outbuf); ++i) {
                                if ( (i<(screenwidth-2)) && (outbuf[i]=='\n')) {
-
                                        strncat(outptr, outbuf, i+1);
-
+                                       strcat(outptr, "\n");
+                                       if (do_citaformat)
+                                               strcat(outptr, " ");
                                        strcpy(outbuf, &outbuf[i+1]);
                                        i = 0;
                                        did_out = 1;
@@ -237,16 +243,17 @@ char *html_to_ascii(char *inputmsg, int screenwidth) {
                                if (outbuf[i]==32) rb = i;
                        }
                        if (rb>=0) {
-
                                strncat(outptr, outbuf, rb);
                                strcat(outptr, "\n");
-
+                               if (do_citaformat)
+                                       strcat(outptr, " ");
                                strcpy(outbuf, &outbuf[rb+1]);
                        } else {
 
                                strncat(outptr, outbuf, screenwidth-2);
                                strcat(outptr, "\n");
-
+                               if (do_citaformat)
+                                       strcat(outptr, " ");
                                strcpy(outbuf, &outbuf[screenwidth-2]);
                        }
                }