From d6291ddc1fcf2537953b54c674f96ce651a16cd3 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Mon, 12 Jun 2000 22:32:54 +0000 Subject: Deprecated. 2000-06-12 Jeffrey Stedfast * camel-mime-filter-smtp.c: Deprecated. * providers/smtp/camel-smtp-transport.c (smtp_data): Updated to use camel-mime-filter-crlf with my 'dot' extension in place of camel-mime-filter-smtp * camel-mime-part.c (write_to_stream): Updated to reflect changes made to camel-mime-filter-crlf.c * camel-mime-filter-crlf.c (filter): Modified to be able to encode/decode dots ("\n.\n"<->"\n..\n"). Also fixed the decoder so that it should no longer get caught in an infinite loop. svn path=/trunk/; revision=3536 --- camel/camel-mime-filter-crlf.c | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) (limited to 'camel/camel-mime-filter-crlf.c') diff --git a/camel/camel-mime-filter-crlf.c b/camel/camel-mime-filter-crlf.c index d39d00887f..63ebfca62b 100644 --- a/camel/camel-mime-filter-crlf.c +++ b/camel/camel-mime-filter-crlf.c @@ -1,7 +1,9 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* * Copyright (C) 2000 Helix Code, Inc. * * Authors: Dan Winship + * Jeffrey Stedfast * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public License @@ -68,8 +70,11 @@ filter (CamelMimeFilter *f, char *in, size_t len, size_t prespace, char **out, size_t *outlen, size_t *outprespace) { CamelMimeFilterCRLF *crlf = (CamelMimeFilterCRLF *)f; + gboolean do_dots; char *p, *q; + do_dots = crlf->mode == CAMEL_MIME_FILTER_CRLF_MODE_CRLF_DOTS; + if (crlf->direction == CAMEL_MIME_FILTER_CRLF_ENCODE) { camel_mime_filter_set_size (f, 2 * len, FALSE); @@ -78,6 +83,9 @@ filter (CamelMimeFilter *f, char *in, size_t len, size_t prespace, while (p < in + len) { if (*p == '\n') *q++ = '\r'; + else + if (do_dots && *(p - 1) == '\n' && *p == '.' && *(p + 1) != '.') + *q++ = '.'; *q++ = *p++; } } else { @@ -86,9 +94,10 @@ filter (CamelMimeFilter *f, char *in, size_t len, size_t prespace, p = in; q = f->outbuf; while (p < in + len) { - if (*p == '\r') + if (*p == '\r') { crlf->saw_cr = TRUE; - else { + p++; + } else { if (crlf->saw_cr) { if (*p != '\n') *q++ = '\r'; @@ -96,6 +105,20 @@ filter (CamelMimeFilter *f, char *in, size_t len, size_t prespace, } *q++ = *p++; } + + if (do_dots) { + if (*p == '.' && *(p - 1) == '\n') { + crlf->saw_dot = TRUE; + p++; + } else { + if (crlf->saw_dot) { + if (*p == '.') + p++; + crlf->saw_dot = FALSE; + } + *q++ = *p++; + } + } } } @@ -121,11 +144,12 @@ reset (CamelMimeFilter *f) } CamelMimeFilter * -camel_mime_filter_crlf_new (CamelMimeFilterCRLFDirection direction) +camel_mime_filter_crlf_new (CamelMimeFilterCRLFDirection direction, CamelMimeFilterCRLFMode mode) { CamelMimeFilterCRLF *crlf = gtk_type_new (CAMEL_MIME_FILTER_CRLF_TYPE); crlf->direction = direction; + crlf->mode = mode; crlf->saw_cr = FALSE; return (CamelMimeFilter *)crlf; -- cgit v1.2.3