$Id$
+Mon Jan 30 00:14:06 EST 2006 ajc
+* HTML messages are now encoded as "Quoted-Printable" before being
+ transmitted to the server. New utility function text_to_server_qp()
+ handles this.
+
Sun Jan 29 23:20:48 EST 2006 ajc
* Removed the "convert_to_html" option from text_to_server() because we no
longer have any callers which require it.
}
serv_puts("Content-type: text/html; charset=utf-8");
+ serv_puts("Content-Transfer-Encoding: quoted-printable");
serv_puts("");
- serv_puts("<html><body>\n"); /** Future templates go here */
- text_to_server(bstr("msgtext"));
- serv_puts("</body></html>\n");
+ serv_puts("<html><body>\r\n");
+ text_to_server_qp(bstr("msgtext")); /** Transmit message in quoted-printable encoding */
+ serv_puts("</body></html>\r\n");
-
if (is_multipart) {
/** Add in the attachments */
}
+/**
+ * \brief Transmit message text (in memory) to the server,
+ * converting to Quoted-Printable encoding as we go.
+ *
+ * \param ptr Pointer to the message being transmitted
+ */
+void text_to_server_qp(char *ptr)
+{
+ char buf[256];
+ int ch, pos;
+ int output_len = 0;
+
+ pos = 0;
+ buf[0] = 0;
+ output_len = 0;
+
+ while (ptr[pos] != 0) {
+ ch = ptr[pos++];
+
+ if (ch == 13) {
+ /* ignore carriage returns */
+ }
+ else if (ch == 10) {
+ /* hard line break */
+ if (output_len > 0) {
+ if (isspace(buf[output_len-1])) {
+ sprintf(&buf[output_len-1], "=%02X", buf[output_len-1]);
+ output_len += 2;
+ }
+ }
+ buf[output_len++] = 0;
+ serv_puts(buf);
+ output_len = 0;
+ }
+ else if (ch == 9) {
+ buf[output_len++] = ch;
+ }
+ else if ( (ch >= 32) && (ch <= 60) ) {
+ buf[output_len++] = ch;
+ }
+ else if ( (ch >= 62) && (ch <= 126) ) {
+ buf[output_len++] = ch;
+ }
+ else {
+ sprintf(&buf[output_len], "=%02X", ch);
+ output_len += 3;
+ }
+
+ if (output_len > 72) {
+ /* soft line break */
+ if (isspace(buf[output_len-1])) {
+ sprintf(&buf[output_len-1], "=%02X", buf[output_len-1]);
+ output_len += 2;
+ }
+ buf[output_len++] = '=';
+ buf[output_len++] = 0;
+ serv_puts(buf);
+ output_len = 0;
+ }
+ }
+
+ /* end of data - transmit anything that's left */
+ if (output_len > 0) {
+ if (isspace(buf[output_len-1])) {
+ sprintf(&buf[output_len-1], "=%02X", buf[output_len-1]);
+ output_len += 2;
+ }
+ buf[output_len++] = 0;
+ serv_puts(buf);
+ output_len = 0;
+ }
+}
+
+
+
/**
* \brief translate server message output to text
void print_message(char *msgnum_as_string);
void display_headers(char *msgnum_as_string);
void text_to_server(char *ptr);
+void text_to_server_qp(char *ptr);
void display_enter(void);
void post_message(void);
void confirm_delete_msg(void);