Collect spool-layout code to one file
[exim.git] / src / src / transport.c
index 9737acc5832e1dfb0c6e221e0a2ea6cc39350d22..af453b04a1af22cd79c966bae798212e65fdee6a 100644 (file)
@@ -1013,7 +1013,7 @@ dkim_transport_write_message(address_item *addr, int fd, int options,
 int dkim_fd;
 int save_errno = 0;
 BOOL rc;
-uschar dkim_spool_name[256];
+uschar * dkim_spool_name;
 char sbuf[2048];
 int sread = 0;
 int wwritten = 0;
@@ -1027,9 +1027,8 @@ if (!(dkim_private_key && dkim_domain && dkim_selector))
            check_string, escape_string, rewrite_rules,
            rewrite_existflags);
 
-(void)string_format(dkim_spool_name, sizeof(dkim_spool_name),
-       "%s/input/%s/%s/%s-%d-K",
-       spool_directory, queue_name, message_subdir, message_id, (int)getpid());
+dkim_spool_name = spool_fname(US"input", message_subdir, message_id,
+                   string_sprintf("-%d-K", (int)getpid()));
 
 if ((dkim_fd = Uopen(dkim_spool_name, O_RDWR|O_CREAT|O_TRUNC, SPOOL_MODE)) < 0)
   {
@@ -1656,8 +1655,6 @@ open_db *dbm_file;
 uschar buffer[256];
 
 int         i;
-uschar      spool_dir [PATH_MAX];
-uschar      spool_file [PATH_MAX];
 struct stat statbuf;
 
 *more = FALSE;
@@ -1715,8 +1712,6 @@ emptied, delete it and continue with any continuation records that may exist.
 but the 1 off will remain without it.  This code now allows me to SKIP over
 a message I do not want to send out on this run.  */
 
-sprintf(CS spool_dir, "%s/input/", spool_directory);
-
 host_length = host_record->count * MESSAGE_ID_LENGTH;
 
 while (1)
@@ -1755,14 +1750,13 @@ while (1)
 
   for (i = msgq_count - 1; i >= 0; --i) if (msgq[i].bKeep)
     {
-    if (split_spool_directory)
-       snprintf(CS spool_file, sizeof(spool_file), "%s/%s/%c/%s-D",
-             spool_dir, queue_name, msgq[i].message_id[5], msgq[i].message_id);
-    else
-       snprintf(CS spool_file, sizeof(spool_file), "%s/%s/%s-D",
-             spool_dir, queue_name, msgq[i].message_id);
+    uschar subdir[2];
+
+    subdir[0] = split_spool_directory ? msgq[i].message_id[5] : 0;
+    subdir[1] = 0;
 
-    if (Ustat(spool_file, &statbuf) != 0)
+    if (Ustat(spool_fname(US"input", subdir, msgq[i].message_id, US"-D"),
+             &statbuf) != 0)
       msgq[i].bKeep = FALSE;
     else if (!oicf_func || oicf_func(msgq[i].message_id, oicf_data))
       {