aboutsummaryrefslogtreecommitdiffstats
path: root/sink.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>1998-11-03 06:41:13 +0000
committerEric S. Raymond <esr@thyrsus.com>1998-11-03 06:41:13 +0000
commit689ff9f4de6fb7cb31d3b6421ad7423c1614d004 (patch)
treeb89c869723e987ccb4e8abb49d27a4d81ffa6775 /sink.c
parenta6627abcad47c801553b84b761afd01eac97c840 (diff)
downloadfetchmail-689ff9f4de6fb7cb31d3b6421ad7423c1614d004.tar.gz
fetchmail-689ff9f4de6fb7cb31d3b6421ad7423c1614d004.tar.bz2
fetchmail-689ff9f4de6fb7cb31d3b6421ad7423c1614d004.zip
Move some code.
svn path=/trunk/; revision=2170
Diffstat (limited to 'sink.c')
-rw-r--r--sink.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/sink.c b/sink.c
index 17e6406c..d802e493 100644
--- a/sink.c
+++ b/sink.c
@@ -24,6 +24,11 @@
#if defined(HAVE_UNISTD_H)
#include <unistd.h>
#endif
+#if defined(HAVE_STDARG_H)
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
#include "fetchmail.h"
#include "socket.h"
@@ -684,4 +689,61 @@ int close_sink(struct query *ctl, flag forward)
return(TRUE);
}
+int open_warning_by_mail(struct query *ctl)
+/* set up output sink for a mailed warning to calling user */
+{
+ int good, bad;
+
+ /*
+ * We give a null address list as arg 3 because we actually *want*
+ * this message to go to run.postmaster. The zero length arg 4 means
+ * we won't pass a SIZE option to ESMTP; the message length would
+ * be more trouble than it's worth to compute.
+ */
+ return(open_sink(ctl, "FETCHMAIL-DAEMON", NULL, 0, &good, &bad));
+}
+
+#if defined(HAVE_STDARG_H)
+void stuff_warning_line(struct query *ctl, const char *fmt, ... )
+#else
+void stuff_warning_line(struct query *ctl, fmt, va_alist)
+struct query *ctl;
+const char *fmt; /* printf-style format */
+va_dcl
+#endif
+/* format and ship a warning message line by mail */
+{
+ char buf[POPBUFSIZE];
+ va_list ap;
+
+ /*
+ * stuffline() requires its input to be writeable (for CR stripping),
+ * so we needed to copy the message to a writeable buffer anyway in
+ * case it was a string constant. We make a virtue of that necessity
+ * here by supporting stdargs/varargs.
+ */
+#if defined(HAVE_STDARG_H)
+ va_start(ap, fmt) ;
+#else
+ va_start(ap);
+#endif
+#ifdef HAVE_VSNPRINTF
+ vsnprintf(buf, sizeof(buf), fmt, ap);
+#else
+ vsprintf(buf, fmt, ap);
+#endif
+ va_end(ap);
+
+ strcat(buf, "\r\n");
+
+ stuffline(ctl, buf);
+}
+
+void close_warning_by_mail(struct query *ctl)
+/* sign and send mailed warnings */
+{
+ stuff_warning_line(ctl, "--\r\n\t\t\t\tThe Fetchmail Daemon\r\n");
+ close_sink(ctl, TRUE);
+}
+
/* sink.c ends here */