Allow both -bf and -bF in the same test run.
[exim.git] / src / src / expand.c
index 2575247b3c4e2b1c813e810f5a7977263f4ad7a4..1bdcd3760c0d061055d258985232d1ef53a4337c 100644 (file)
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/expand.c,v 1.3 2004/11/05 16:53:28 ph10 Exp $ */
+/* $Cambridge: exim/src/src/expand.c,v 1.7 2004/11/18 11:17:33 ph10 Exp $ */
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
@@ -283,7 +283,9 @@ enum {
   vtype_reply,          /* value not used; get reply from headers */
   vtype_pid,            /* value not used; result is pid */
   vtype_host_lookup,    /* value not used; get host name */
-  vtype_load_avg        /* value not used; result is int from os_getloadavg */
+  vtype_load_avg,       /* value not used; result is int from os_getloadavg */
+  vtype_pspace,         /* partition space; value is T/F for spool/log */
+  vtype_pinodes         /* partition inodes; value is T/F for spool/log */  
   };
 
 /* This table must be kept in alphabetical order. */
@@ -352,6 +354,8 @@ static var_entry var_table[] = {
   { "local_user_gid",      vtype_gid,         &local_user_gid },
   { "local_user_uid",      vtype_uid,         &local_user_uid },
   { "localhost_number",    vtype_int,         &host_number },
+  { "log_inodes",          vtype_pinodes,     (void *)FALSE },
+  { "log_space",           vtype_pspace,      (void *)FALSE },  
   { "mailstore_basename",  vtype_stringptr,   &mailstore_basename },
   { "message_age",         vtype_int,         &message_age },
   { "message_body",        vtype_msgbody,     &message_body },
@@ -421,6 +425,8 @@ static var_entry var_table[] = {
   { "sn8",                 vtype_filter_int,  &filter_sn[8] },
   { "sn9",                 vtype_filter_int,  &filter_sn[9] },
   { "spool_directory",     vtype_stringptr,   &spool_directory },
+  { "spool_inodes",        vtype_pinodes,     (void *)TRUE },
+  { "spool_space",         vtype_pspace,      (void *)TRUE },  
   { "thisaddress",         vtype_stringptr,   &filter_thisaddress },
   { "tls_certificate_verified", vtype_int,    &tls_certificate_verified },
   { "tls_cipher",          vtype_stringptr,   &tls_cipher },
@@ -1310,6 +1316,22 @@ while (last > first)
       s[ptr] = 0;     /* string_cat() leaves room */
       }
     return s;
+    
+    case vtype_pspace:
+      {
+      int inodes;
+      sprintf(CS var_buffer, "%d", 
+        receive_statvfs((BOOL)(var_table[middle].value), &inodes));  
+      }
+    return var_buffer;
+    
+    case vtype_pinodes:
+      {
+      int inodes;
+      (void) receive_statvfs((BOOL)(var_table[middle].value), &inodes);  
+      sprintf(CS var_buffer, "%d", inodes);
+      }
+    return var_buffer;
     }
   }
 
@@ -2153,17 +2175,24 @@ uschar *s = *sptr;    /* Local value */
 uschar *sub1, *sub2;
 
 /* If there are no following strings, we substitute the contents of $value for
-lookups and for extractions in the success case. In the fail case, nothing is
-substituted. In the case of "if", lack of following strings is an error. */
+lookups and for extractions in the success case. For the ${if item, the string
+"true" is substituted. In the fail case, nothing is substituted for all three 
+items. */
 
 while (isspace(*s)) s++;
 if (*s == '}')
   {
-  if (type[0] == 'i') goto FAILED_CURLY;
-  if (yes && lookup_value != NULL)
-    *yieldptr = string_cat(*yieldptr, sizeptr, ptrptr, lookup_value,
-      Ustrlen(lookup_value));
-  lookup_value = save_lookup;
+  if (type[0] == 'i')
+    {
+    if (yes) *yieldptr = string_cat(*yieldptr, sizeptr, ptrptr, US"true", 4); 
+    }
+  else
+    {      
+    if (yes && lookup_value != NULL)
+      *yieldptr = string_cat(*yieldptr, sizeptr, ptrptr, lookup_value,
+        Ustrlen(lookup_value));
+    lookup_value = save_lookup;
+    }
   s++;
   goto RETURN;
   }
@@ -3929,7 +3958,7 @@ while (*s != 0)
         /* Convert to masked textual format and add to output. */
 
         yield = string_cat(yield, &size, &ptr, buffer,
-          host_nmtoa(count, binary, mask, buffer));
+          host_nmtoa(count, binary, mask, buffer, '.'));
         continue;
         }
 
@@ -4061,7 +4090,7 @@ while (*s != 0)
 
       case EOP_RFC2047:
         {
-        uschar buffer[1024];
+        uschar buffer[2048];
         uschar *string = parse_quote_2047(sub, Ustrlen(sub), headers_charset,
           buffer, sizeof(buffer));
         yield = string_cat(yield, &size, &ptr, string, Ustrlen(string));