aboutsummaryrefslogtreecommitdiff
path: root/libsylph/utils.c
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2005-11-22 07:21:07 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2005-11-22 07:21:07 +0000
commitf83afc56908b487f1d0d87d563eabf68c01b411c (patch)
treea7614bea8301779382a5c52eb15ad988191c1356 /libsylph/utils.c
parent6e181791b71430f018d8a78fd943b825349f1128 (diff)
reduced memory usage on SMTP session.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@771 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'libsylph/utils.c')
-rw-r--r--libsylph/utils.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/libsylph/utils.c b/libsylph/utils.c
index 2d441163..8f531967 100644
--- a/libsylph/utils.c
+++ b/libsylph/utils.c
@@ -2757,6 +2757,66 @@ gchar *normalize_newlines(const gchar *str)
return out;
}
+FILE *get_outgoing_rfc2822_file(FILE *fp)
+{
+ gchar buf[BUFFSIZE];
+ FILE *outfp;
+
+ outfp = my_tmpfile();
+ if (!outfp) {
+ FILE_OP_ERROR("get_outgoing_rfc2822_file", "my_tmpfile");
+ return NULL;
+ }
+
+ /* output header part */
+ while (fgets(buf, sizeof(buf), fp) != NULL) {
+ strretchomp(buf);
+ if (!g_ascii_strncasecmp(buf, "Bcc:", 4)) {
+ gint next;
+
+ for (;;) {
+ next = fgetc(fp);
+ if (next == EOF)
+ break;
+ else if (next != ' ' && next != '\t') {
+ ungetc(next, fp);
+ break;
+ }
+ if (fgets(buf, sizeof(buf), fp) == NULL)
+ break;
+ }
+ } else {
+ if (fputs(buf, outfp) == EOF)
+ goto file_error;
+ if (fputs("\r\n", outfp) == EOF)
+ goto file_error;
+ if (buf[0] == '\0')
+ break;
+ }
+ }
+
+ /* output body part */
+ while (fgets(buf, sizeof(buf), fp) != NULL) {
+ strretchomp(buf);
+ if (buf[0] == '.') {
+ if (fputc('.', outfp) == EOF)
+ goto file_error;
+ }
+ if (fputs(buf, outfp) == EOF)
+ goto file_error;
+ if (fputs("\r\n", outfp) == EOF)
+ goto file_error;
+ }
+
+ rewind(outfp);
+ return outfp;
+
+file_error:
+ g_warning("get_outgoing_rfc2822_file(): writing to temporary file failed.\n");
+ fclose(outfp);
+ return NULL;
+}
+
gchar *get_outgoing_rfc2822_str(FILE *fp)
{
gchar buf[BUFFSIZE];