X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Fhtml2html.c;h=6a5932da28972a178edea2db3facb98b45b2bdef;hb=e1cfdc9ced08ba38ac79b4bb998c6e8c35cdc167;hp=9d6e357aaabfdf71d577063f3c5ffae85670ec14;hpb=719abc348ee76436439a16bcaccce317c12d3435;p=citadel.git diff --git a/webcit/html2html.c b/webcit/html2html.c index 9d6e357aa..6a5932da2 100644 --- a/webcit/html2html.c +++ b/webcit/html2html.c @@ -82,7 +82,7 @@ void extract_charset_from_meta(char *charset, char *meta_http_equiv, char *meta_ * * \param supplied_charset the input charset as declared in the MIME headers */ -void output_html(char *supplied_charset, int treat_as_wiki, int msgnum) { +void output_html(const char *supplied_charset, int treat_as_wiki, int msgnum, StrBuf *Source, StrBuf *Target) { char buf[SIZ]; char *msg; char *ptr; @@ -108,21 +108,23 @@ void output_html(char *supplied_charset, int treat_as_wiki, int msgnum) { size_t obuflen; /**< Length of output buffer */ char *osav; /**< Saved pointer to output buffer */ #endif + if (Target == NULL) + Target = WC->WBuf; safestrncpy(charset, supplied_charset, sizeof charset); msg = strdup(""); sprintf(new_window, ""); - wprintf(_("realloc() error! couldn't get %d bytes: %s"), + StrBufAppendPrintf(Target, ""); + StrBufAppendPrintf(Target, _("realloc() error! couldn't get %d bytes: %s"), buffer_length + 1, strerror(errno)); - wprintf("

\n"); + StrBufAppendPrintf(Target, "

\n"); while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) { /** flush */ } @@ -135,6 +137,11 @@ void output_html(char *supplied_charset, int treat_as_wiki, int msgnum) { strcpy(&msg[content_length], "\n"); content_length += 1; } + else { + content_length = StrLength(Source); + msg = (char*) ChrPtr(Source);/* TODO: remove cast */ + buffer_length = content_length; + } /** Do a first pass to isolate the message body */ ptr = msg + 1; @@ -234,7 +241,7 @@ void output_html(char *supplied_charset, int treat_as_wiki, int msgnum) { && (strcasecmp(charset, "")) ) { lprintf(9, "Converting %s to UTF-8\n", charset); - ic = ctdl_iconv_open("UTF-8", charset); + ctdl_iconv_open("UTF-8", charset, &ic); if (ic == (iconv_t)(-1) ) { lprintf(5, "%s:%d iconv_open() failed: %s\n", __FILE__, __LINE__, strerror(errno)); @@ -266,7 +273,7 @@ void output_html(char *supplied_charset, int treat_as_wiki, int msgnum) { /** Now go through the message, parsing tags as necessary. */ converted_msg = NewStrBufPlain(NULL, content_length + 8192); if (converted_msg == NULL) { - wprintf("Error %d: %s
%s:%d", errno, strerror(errno), __FILE__, __LINE__); + StrBufAppendPrintf(Target, "Error %d: %s
%s:%d", errno, strerror(errno), __FILE__, __LINE__); goto BAIL; } @@ -448,10 +455,10 @@ void output_html(char *supplied_charset, int treat_as_wiki, int msgnum) { /** output_length = content_length; */ /** Output our big pile of markup */ - StrBufAppendBuf(WC->WBuf, converted_msg, 0); + StrBufAppendBuf(Target, converted_msg, 0); BAIL: /** A little trailing vertical whitespace... */ - wprintf("

\n"); + StrBufAppendPrintf(Target, "

\n"); /** Now give back the memory */ FreeStrBuf(&converted_msg);