Debug: use difftime()
[exim.git] / src / src / transports / smtp.c
index 73659235216fea2c8b21678bb2b4e9e89fb5bffe..ddd6ad7e13e0d0aef2e516bee623e0f4767bc7a2 100644 (file)
@@ -533,7 +533,7 @@ switch(*errno_value)
 
   case ERRNO_SMTPFORMAT:       /* Handle malformed SMTP response */
     s = string_printing(buffer);
-    while (isspace(*s)) s++;
+    Uskip_whitespace(&s);
     *message = *s == 0
       ? string_sprintf("Malformed SMTP reply (an empty line) "
          "in response to %s%s", pl, smtp_command)
@@ -815,8 +815,7 @@ uschar * match;
 if (regex_match(regex_LIMITS, sx->buffer, -1, &match))
   for (const uschar * s = sx->buffer + Ustrlen(match); *s; )
     {
-    while (isspace(*s)) s++;
-    if (*s == '\n') break;
+    if (Uskip_whitespace(&s) == '\n') break;
 
     if (strncmpic(s, US"MAILMAX=", 8) == 0)
       {
@@ -946,7 +945,8 @@ if (  sx->early_pipe_active
     if (!(er = dbfn_read_enforce_length(dbm_file, ehlo_resp_key, sizeof(dbdata_ehlo_resp))))
       debug_printf("no ehlo-resp record!\n");
     else
-      debug_printf("ehlo-resp record is %d seconds old\n", time(NULL) - er->time_stamp);
+      debug_printf("ehlo-resp record is %.0f seconds old\n",
+                   difftime(time(NULL), er->time_stamp));
     }
 
   dbfn_delete(dbm_file, ehlo_resp_key);
@@ -1307,7 +1307,7 @@ while (count-- > 0)
 
     if (testflag(addr, af_dr_retry_exists))
       {
-      uschar *altkey = string_sprintf("%s:<%s>", addr->address_retry_key,
+      uschar * altkey = string_sprintf("%s:<%s>", addr->address_retry_key,
         sender_address);
       retry_add_item(addr, altkey, rf_delete);
       retry_add_item(addr, addr->address_retry_key, rf_delete);
@@ -1323,7 +1323,7 @@ while (count-- > 0)
 
   else if (errno == ETIMEDOUT)
     {
-    uschar *message = string_sprintf("SMTP timeout after RCPT TO:<%s>",
+    uschar * message = string_sprintf("SMTP timeout after RCPT TO:<%s>",
                transport_rcpt_address(addr, sx->conn_args.tblock->rcpt_include_affixes));
     set_errno_nohost(sx->first_addr, ETIMEDOUT, message, DEFER, FALSE, &sx->delivery_start);
     retry_add_item(addr, addr->address_retry_key, 0);
@@ -1694,8 +1694,8 @@ if (  sx->esmtp
        {
        DEBUG(D_transport) debug_printf("skipping %s authenticator: %s\n",
          au->name,
-         (au->client)? "client_condition is false" :
-                       "not configured as a client");
+         au->client ? "client_condition is false"
+                   : "not configured as a client");
        continue;
        }
 
@@ -1703,15 +1703,14 @@ if (  sx->esmtp
 
       while (*p)
        {
-       int len = Ustrlen(au->public_name);
-       int rc;
+       int len = Ustrlen(au->public_name), rc;
 
-       while (isspace(*p)) p++;
+       Uskip_whitespace(&p);
 
        if (strncmpic(au->public_name, p, len) != 0 ||
-           (p[len] != 0 && !isspace(p[len])))
+           (p[len] && !isspace(p[len])))
          {
-         while (*p != 0 && !isspace(*p)) p++;
+         while (*p && !isspace(*p)) p++;
          continue;
          }
 
@@ -5378,7 +5377,7 @@ retry_non_continued:
     BOOL host_is_expired = FALSE, message_defer = FALSE, some_deferred = FALSE;
     address_item * first_addr = NULL;
     uschar * interface = NULL;
-    uschar * retry_host_key = NULL, * retry_message_key = NULL;
+    const uschar * retry_host_key = NULL, * retry_message_key = NULL;
     uschar * serialize_key = NULL;
 
     /* Deal slightly better with a possible Linux kernel bug that results
@@ -5875,9 +5874,7 @@ retry_non_continued:
                  ob->expand_retry_include_ip_address, &incl_ip) != OK)
          incl_ip = TRUE;       /* error; use most-specific retry record */
 
-        retry_host_key = incl_ip
-         ? string_sprintf("T:%S:%s%s", host->name, host->address, pistring)
-         : string_sprintf("T:%S%s", host->name, pistring);
+        retry_host_key = retry_host_key_build(host, incl_ip, pistring);
         }
 
       /* If a delivery of another message over an existing SMTP connection
@@ -5923,10 +5920,8 @@ retry_non_continued:
                  ob->expand_retry_include_ip_address, &incl_ip) != OK)
          incl_ip = TRUE;       /* error; use most-specific retry record */
 
-        retry_message_key = incl_ip
-         ? string_sprintf("T:%S:%s%s:%s", host->name, host->address, pistring,
-             message_id)
-         : string_sprintf("T:%S%s:%s", host->name, pistring, message_id);
+        retry_message_key = string_sprintf("%s:%s",
+         retry_host_key_build(host, incl_ip, pistring), message_id);
         }
       retry_add_item(addrlist, retry_message_key,
         rf_message | rf_host | delete_flag);