+}
+
+static void
+deliver(char *maildir, char *newfn)
+{
+ char fn[TMPNAMLEN];
+ int fd;
+ char buf[BUFSIZ]; /* Allocated here only as an (early,
+ * evil) space optimization. */
+
+ if (chdir(maildir) != 0) {
+ err(EX_TEMPFAIL, "Failed chdir(%s)", maildir);
+ }
+
+ get_filename(fn);
+
+ fd = open(fn, O_WRONLY | O_EXCL | O_CREAT, 0600);
+ if (fd < 0) {
+ err(EX_TEMPFAIL, "Failed open(%s)", fn);
+ }
+
+ /* From this point, we have a tmp file, so if someting fails we
+ * must try to unlink it before bombing. */
+
+ strip_from(fd, buf, fn);
+ copy_message(fd, buf, fn);