* remove duplicate function
[citadel.git] / webcit / serv_func.c
index aa43d350b84cab3a39fa8947b7e150d53e047e9d..fbaa088d8b583a98fbaeef989f85380eb9eee4da 100644 (file)
@@ -155,6 +155,74 @@ void _fmout(StrBuf *Target, char *align)
        wprintf("</div><br />\n");
 }
 
+void FmOut(StrBuf *Target, char *align, StrBuf *Source)
+{
+       const char *ptr, *pte;
+       const char *BufPtr = NULL;
+       StrBuf *Line = NewStrBuf();
+       StrBuf *Line1 = NewStrBuf();
+       StrBuf *Line2 = NewStrBuf();
+       int bn = 0;
+       int bq = 0;
+       int i, n, done = 0;
+       long len;
+       int intext = 0;
+
+       StrBufAppendPrintf(Target, "<div align=%s>\n", align);
+       while ((n = StrBufSipLine(Line, Source, &BufPtr), n >= 0) && !done)
+       {
+               done = n == 0;
+               bq = 0;
+               i = 0;
+               ptr = ChrPtr(Line);
+               len = StrLength(Line);
+               pte = ptr + len;
+
+               if ((intext == 1) && (isspace(*ptr))) {
+                       StrBufAppendBufPlain(Target, HKEY("<br />"), 0);
+               }
+               intext = 1;
+               if (isspace(*ptr)) while ((ptr < pte) &&
+                      ((*ptr == '>') ||
+                       isspace(*ptr)))
+               {
+                       if (*ptr == '>')
+                               bq++;
+                       ptr ++;
+                       i++;
+               }
+
+               /**
+                * Quoted text should be displayed in italics and in a
+                * different colour.  This code understands Citadel-style
+                * " >" quotes and will convert to <BLOCKQUOTE> tags.
+                */
+               if (i > 0) StrBufCutLeft(Line, i);
+               
+
+               for (i = bn; i < bq; i++)                               
+                       StrBufAppendBufPlain(Target, HKEY("<blockquote>"), 0);
+               for (i = bq; i < bn; i++)                               
+                       StrBufAppendBufPlain(Target, HKEY("</blockquote>"), 0);
+               bn = bq;
+
+               if (StrLength(Line) == 0)
+                       continue;
+               /** Activate embedded URL's */
+               UrlizeText(Line1, Line, Line2);
+
+               StrEscAppend(Target, Line1, NULL, 0, 0);
+
+               StrBufAppendBufPlain(Target, HKEY("\n"), 0);
+       }
+       for (i = 0; i < bn; i++)                                
+               StrBufAppendBufPlain(Target, HKEY("</blockquote>"), 0);
+       StrBufAppendBufPlain(Target, HKEY("</div><br />\n"), 0);
+       FreeStrBuf(&Line);
+       FreeStrBuf(&Line1);
+       FreeStrBuf(&Line2);
+}
+