*error = NULL;
-while ((s = (*func)()) != NULL)
+while ((s = (*func)()))
{
int v, c;
BOOL negated = FALSE;
/* Conditions (but not verbs) are allowed to be negated by an initial
exclamation mark. */
- while (isspace(*s)) s++;
- if (*s == '!')
+ if (Uskip_whitespace(&s) == '!')
{
negated = TRUE;
s++;
}
cond->u.varname = string_copyn(s, 18);
s = endptr;
- while (isspace(*s)) s++;
+ Uskip_whitespace(&s);
}
else
#endif
cond->u.varname = string_copyn(s + 4, endptr - s - 4);
s = endptr;
- while (isspace(*s)) s++;
+ Uskip_whitespace(&s);
}
/* For "set", we are now positioned for the data. For the others, only
conditions[c].is_modifier ? US"modifier" : US"condition");
return NULL;
}
- while (isspace(*s)) s++;
+ Uskip_whitespace(&s);
cond->arg = string_copy(s);
}
}
for(;;)
{
- while (isspace(*acl_text)) acl_text++; /* Leading spaces/empty lines */
- if (*acl_text == 0) return NULL; /* No more data */
- yield = acl_text; /* Potential data line */
+ Uskip_whitespace(&acl_text); /* Leading spaces/empty lines */
+ if (!*acl_text) return NULL; /* No more data */
+ yield = acl_text; /* Potential data line */
while (*acl_text && *acl_text != '\n') acl_text++;
/* If we hit the end before a newline, we have the whole logical line. If
it's a comment, there's no more data to be given. Otherwise, yield it. */
- if (*acl_text == 0) return (*yield == '#')? NULL : yield;
+ if (!*acl_text) return *yield == '#' ? NULL : yield;
/* After reaching a newline, end this loop if the physical line does not
start with '#'. If it does, it's a comment, and the loop continues. */
uschar *real_sender_address;
uschar *originator_home = US"/";
size_t sz;
-rmark reset_point;
struct passwd *pw;
struct stat statbuf;
unprivileged = (real_uid != root_uid && original_euid != root_uid);
+/* For most of the args-parsing we need to use permanent pool memory */
+ {
+ int old_pool = store_pool;
+ store_pool = POOL_PERM;
+
/* Scan the program's arguments. Some can be dealt with right away; others are
simply recorded for checking and handling afterwards. Do a high-level switch
on the second character (the one after '-'), to save some effort. */
-for (i = 1; i < argc; i++)
+ for (i = 1; i < argc; i++)
{
BOOL badarg = FALSE;
uschar * arg = argv[i];
else
{
/* Well, the trust list at least is up to scratch... */
- rmark reset_point = store_mark();
+ rmark reset_point;
uschar *trusted_configs[32];
int nr_configs = 0;
int i = 0;
+ int old_pool = store_pool;
+ store_pool = POOL_MAIN;
+ reset_point = store_mark();
while (Ufgets(big_buffer, big_buffer_size, trust_list))
{
uschar *start = big_buffer, *nl;
else /* No valid prefixes found in trust_list file. */
f.trusted_config = FALSE;
store_reset(reset_point);
+ store_pool = old_pool;
}
}
else /* Could not open trust_list file. */
if (*argrest)
{
- uschar *hn;
+ uschar * hn = Ustrchr(argrest, ':');
if (received_protocol)
exim_fail("received_protocol is set already\n");
- hn = Ustrchr(argrest, ':');
if (!hn)
received_protocol = string_copy_taint(argrest, TRUE);
else
{
- int old_pool = store_pool;
- store_pool = POOL_PERM;
received_protocol = string_copyn_taint(argrest, hn - argrest, TRUE);
- store_pool = old_pool;
sender_host_name = string_copy_taint(hn + 1, TRUE);
}
}
/* If -R or -S have been specified without -q, assume a single queue run. */
-if ( (deliver_selectstring || deliver_selectstring_sender)
- && queue_interval < 0)
- queue_interval = 0;
+ if ( (deliver_selectstring || deliver_selectstring_sender)
+ && queue_interval < 0)
+ queue_interval = 0;
END_ARG:
+ store_pool = old_pool;
+ }
+
/* If usage_wanted is set we call the usage function - which never returns */
if (usage_wanted) exim_usage(called_as);
if (smtp_start_session())
{
+ rmark reset_point;
for (; (reset_point = store_mark()); store_reset(reset_point))
{
if (smtp_setup_msg() <= 0) break;
while (more)
{
- reset_point = store_mark();
+ rmark reset_point = store_mark();
message_id[0] = 0;
/* Handle the SMTP case; call smtp_setup_mst() to deal with the initial SMTP
expand_getkeyed(uschar * key, const uschar * s)
{
int length = Ustrlen(key);
-while (isspace(*s)) s++;
+Uskip_whitespace(&s);
/* Loop to search for the key */
while (*s && *s != '=' && !isspace(*s)) s++;
dkeylength = s - dkey;
- while (isspace(*s)) s++;
- if (*s == '=') while (isspace((*(++s))));
+ if (Uskip_whitespace(&s) == '=') while (isspace((*(++s))));
data = string_dequote(&s);
if (length == dkeylength && strncmpic(key, dkey, length) == 0)
return data;
- while (isspace(*s)) s++;
+ Uskip_whitespace(&s);
}
return NULL;
s = find_header(US"reply-to:", newsize,
exists_only ? FH_EXISTS_ONLY|FH_WANT_RAW : FH_WANT_RAW,
headers_charset);
- if (s) while (isspace(*s)) s++;
+ if (s) Uskip_whitespace(&s);
if (!s || !*s)
{
*newsize = 0; /* For the *s==0 case */
if (s)
{
uschar *t;
- while (isspace(*s)) s++;
- for (t = s; *t != 0; t++) if (*t == '\n') *t = ' ';
+ Uskip_whitespace(&s);
+ for (t = s; *t; t++) if (*t == '\n') *t = ' ';
while (t > s && isspace(t[-1])) t--;
*t = 0;
}
{
const uschar *s = *sptr;
-while (isspace(*s)) s++;
+Uskip_whitespace(&s);
for (int i = 0; i < n; i++)
{
if (*s != '{')
if (!(sub[i] = expand_string_internal(s+1, TRUE, &s, skipping, TRUE, resetok)))
return 3;
if (*s++ != '}') return 1;
- while (isspace(*s)) s++;
+ Uskip_whitespace(&s);
}
if (check_end && *s++ != '}')
{
unsigned depth = 0;
BOOL quotesmode = wrap[0] == wrap[1];
-while (isspace(*p)) p++;
-
-if (*p == *wrap)
+if (Uskip_whitespace(&p) == *wrap)
{
s = ++p;
wrap++;
int_eximarith_t n;
uschar *s = *sptr;
-while (isspace(*s)) s++;
-if (isdigit((c = *s)))
+if (isdigit((c = Uskip_whitespace(&s))))
{
int count;
(void)sscanf(CS s, (decimal? SC_EXIM_DEC "%n" : SC_EXIM_ARITH "%n"), &n, &count);
case 'm': n *= 1024*1024; s++; break;
case 'g': n *= 1024*1024*1024; s++; break;
}
- while (isspace (*s)) s++;
+ Uskip_whitespace(&s);
}
else if (c == '(')
{
{
uschar *s = *sptr;
int_eximarith_t x;
-while (isspace(*s)) s++;
+Uskip_whitespace(&s);
if (*s == '+' || *s == '-' || *s == '~')
{
int op = *s++;
kinds. Allow everything except space or { to appear; the actual content
is checked by search_findtype_partial. */ /*}*/
- while (*s != 0 && *s != '{' && !isspace(*s)) /*}*/
+ while (*s && *s != '{' && !isspace(*s)) /*}*/
{
if (nameptr < sizeof(name) - 1) name[nameptr++] = *s;
s++;
}
- name[nameptr] = 0;
+ name[nameptr] = '\0';
while (isspace(*s)) s++;
/* Now check for the individual search type and any partial or default
for (h = header_list; h; h = h->next)
{
- uschar *s;
if (h->type == htype_old) continue;
if (strncmpic(h->text, US"List-", 5) == 0)
{
- s = h->text + 5;
+ uschar * s = h->text + 5;
if (strncmpic(s, US"Id:", 3) == 0 ||
strncmpic(s, US"Help:", 5) == 0 ||
strncmpic(s, US"Subscribe:", 10) == 0 ||
else if (strncmpic(h->text, US"Auto-submitted:", 15) == 0)
{
- s = h->text + 15;
- while (isspace(*s)) s++;
+ uschar * s = h->text + 15;
+ Uskip_whitespace(&s);
if (strncmpic(s, US"no", 2) != 0) return FALSE;
s += 2;
- while (isspace(*s)) s++;
- if (*s != 0) return FALSE;
+ Uskip_whitespace(&s);
+ if (*s) return FALSE;
}
}
global_rewrite_rules);
-if (self_from == NULL) self_from = self;
-if (self_to == NULL) self_to = self;
+if (!self_from) self_from = self;
+if (self_to) self_to = self;
/* If there's a prefix or suffix set, we must include the prefixed/
suffixed version of the local part in the tests. */
-if (deliver_localpart_prefix != NULL || deliver_localpart_suffix != NULL)
+if (deliver_localpart_prefix || deliver_localpart_suffix)
{
psself = string_sprintf("%s%s%s@%s",
(deliver_localpart_prefix == NULL)? US"" : deliver_localpart_prefix,
#ifndef _FUNCTIONS_H_
#define _FUNCTIONS_H_
+#include <ctype.h>
#include <sys/time.h>
/*XXX will likely need unchecked copy also */
+/* Advance the string pointer given over any whitespace.
+Return the next char as there's enought places using it to be useful. */
+
+#define Uskip_whitespace(sp) skip_whitespace(CUSS sp)
+
+static inline uschar skip_whitespace(const uschar ** sp)
+{ while (isspace(**sp)) (*sp)++; return **sp; }
+
+
/******************************************************************************/
#if !defined(MACRO_PREDEF) && !defined(COMPILE_UTILITY)
extern BOOL allow_domain_literals; /* As it says */
extern BOOL allow_mx_to_ip; /* Allow MX records to -> ip address */
#ifdef EXPERIMENTAL_ARC
-struct arc_set *arc_received; /* highest ARC instance evaluation struct */
+extern struct arc_set *arc_received; /* highest ARC instance evaluation struct */
extern int arc_received_instance; /* highest ARC instance number in headers */
extern int arc_oldest_pass; /* lowest passing instance number in headers */
extern const uschar *arc_state; /* verification state */
if (c == 0)
{
- uschar *s = text + mid->len;
- while (isspace(*s)) s++;
- if (*s == ':')
+ uschar * s = text + mid->len;
+ if (Uskip_whitespace(&s) == ':')
return (!is_resent || mid->allow_resent)? mid->htype : htype_other;
c = 1;
}
uschar *string, bit_table *options, int count, uschar *which, int flags)
{
uschar *errmsg;
-if (string == NULL) return;
+if (!string) return;
if (*string == '=')
{
char *end; /* Not uschar */
memset(selector, 0, sizeof(*selector)*selsize);
*selector = strtoul(CS string+1, &end, 0);
- if (*end == 0) return;
+ if (!*end) return;
errmsg = string_sprintf("malformed numeric %s_selector setting: %s", which,
string);
goto ERROR_RETURN;
int len;
bit_table *start, *end;
- while (isspace(*string)) string++;
- if (*string == 0) return;
+ Uskip_whitespace(&string);
+ if (!*string) return;
if (*string != '+' && *string != '-')
{
bit_table *middle = start + (end - start)/2;
int c = Ustrncmp(s, middle->name, len);
if (c == 0)
- {
if (middle->name[len] != 0) c = -1; else
{
unsigned int bit = middle->bit;
break; /* Out of loop to match selector name */
}
- }
if (c < 0) end = middle; else start = middle + 1;
} /* Loop to match selector name */
int ret;
gstring * res = NULL;
-ret = sqlite3_exec(handle, CS query, sqlite_callback, &res, (char **)errmsg);
+ret = sqlite3_exec(handle, CS query, sqlite_callback, &res, CSS errmsg);
if (ret != SQLITE_OK)
{
debug_printf_indent("sqlite3_exec failed: %s\n", *errmsg);
/* Set the parameters for the three different kinds of lookup. */
keyquery = semicolon + 1;
-while (isspace(*keyquery)) keyquery++;
+Uskip_whitespace(&keyquery);
if (mac_islookup(search_type, lookup_absfilequery))
{
filename = keyquery;
- while (*keyquery != 0 && !isspace(*keyquery)) keyquery++;
+ while (*keyquery && !isspace(*keyquery)) keyquery++;
filename = string_copyn(filename, keyquery - filename);
- while (isspace(*keyquery)) keyquery++;
+ Uskip_whitespace(&keyquery);
}
else if (!mac_islookup(search_type, lookup_querystyle))
result = search_find(handle, filename, keyquery, partial, affix, affixlen,
starflags, &expand_setup, opts);
-if (!result) return f.search_find_defer? DEFER : FAIL;
+if (!result) return f.search_find_defer ? DEFER : FAIL;
if (valueptr) *valueptr = result;
expand_nmax = expand_setup;
if (h->type == htype_id)
{
message_id = Ustrchr(h->text, ':') + 1;
- while (isspace(*message_id)) message_id++;
+ Uskip_whitespace(&message_id);
}
for (h = header_list; h; h = h->next)
while (*s)
{
int c, level;
- while (isspace(*s)) s++;
- if (*s != '(') break;
+
+ if (Uskip_whitespace(&s) != '(') break;
level = 1;
- while((c = *(++s)) != 0)
+ while((c = *(++s)))
{
if (c == '(') level++;
else if (c == ')') { if (--level <= 0) { s++; break; } }
}
s = ss + (terminator? 1:0);
- while (isspace(*s)) s++;
+ Uskip_whitespace(&s);
}
}
static BOOL
match_tag(const uschar *s, const uschar *tag)
{
-for (; *tag != 0; s++, tag++)
+for (; *tag; s++, tag++)
if (*tag == ' ')
{
while (*s == ' ' || *s == '\t') s++;
int
rda_is_filter(const uschar *s)
{
-while (isspace(*s)) s++; /* Skips initial blank lines */
-if (match_tag(s, CUS"# exim filter")) return FILTER_EXIM;
- else if (match_tag(s, CUS"# sieve filter")) return FILTER_SIEVE;
- else return FILTER_FORWARD;
+Uskip_whitespace(&s); /* Skips initial blank lines */
+if (match_tag(s, CUS"# exim filter")) return FILTER_EXIM;
+else if (match_tag(s, CUS"# sieve filter")) return FILTER_SIEVE;
+else return FILTER_FORWARD;
}
}
name[namelen] = 0;
-while (isspace(*s)) s++;
+Uskip_whitespace(&s);
if (*s++ != '=')
{
log_write(0, LOG_PANIC|LOG_CONFIG_IN, "malformed macro definition");
redef = TRUE;
s++;
}
-while (isspace(*s)) s++;
+Uskip_whitespace(&s);
/* If an existing macro of the same name was defined on the command line, we
just skip this definition. It's an error to attempt to redefine a macro without
/* Find the true start of the physical line - leading spaces are always
ignored. */
-while (isspace(*ss)) ss++;
+Uskip_whitespace(&ss);
/* Process the physical line for macros. If this is the start of the logical
line, skip over initial text at the start of the line if it starts with an
if (len == 0 && isupper(*s))
{
while (isalnum(*s) || *s == '_') s++;
- while (isspace(*s)) s++;
- if (*s != '=') s = ss; /* Not a macro definition */
+ if (Uskip_whitespace(&s) != '=') s = ss; /* Not a macro definition */
}
/* Skip leading chars which cannot start a macro name, to avoid multiple
/* An empty macro replacement at the start of a line could mean that ss no
longer points to the first non-blank character. */
-while (isspace(*ss)) ss++;
+Uskip_whitespace(&ss);
return ss;
}
struct stat statbuf;
ss += 9 + include_if_exists;
- while (isspace(*ss)) ss++;
+ Uskip_whitespace(&ss);
t = ss + Ustrlen(ss);
while (t > ss && isspace(t[-1])) t--;
if (*ss == '\"' && t[-1] == '\"')
if (strncmpic(s, US"begin ", 6) == 0)
{
s += 6;
- while (isspace(*s)) s++;
+ Uskip_whitespace(&s);
if (big_buffer + len - s > sizeof(next_section) - 2)
s[sizeof(next_section) - 2] = 0;
Ustrcpy(next_section, s);
readconf_readname(uschar *name, int len, uschar *s)
{
int p = 0;
-while (isspace(*s)) s++;
-if (isalpha(*s))
- {
+
+if (isalpha(Uskip_whitespace(&s)))
while (isalnum(*s) || *s == '_')
{
if (p < len-1) name[p++] = *s;
s++;
}
- }
+
name[p] = 0;
-while (isspace(*s)) s++;
+Uskip_whitespace(&s);
return s;
}
next->next = NULL;
next->key = string_dequote(&p);
-while (isspace(*p)) p++;
-if (*p == 0)
+Uskip_whitespace(&p);
+if (!*p)
log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN,
"missing rewrite replacement string");
next->flags = 0;
next->replacement = string_dequote(&p);
-while (*p != 0) switch (*p++)
+while (*p) switch (*p++)
{
case ' ': case '\t': break;
log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, "too many named %ss (max is %d)\n",
tname, max);
-while (isspace(*s)) s++;
+Uskip_whitespace(&s);
ss = s;
while (isalnum(*s) || *s == '_') s++;
t = store_get(sizeof(tree_node) + s-ss, is_tainted(ss));
Ustrncpy(t->name, ss, s-ss);
t->name[s-ss] = 0;
-while (isspace(*s)) s++;
+Uskip_whitespace(&s);
if (!tree_insertnode(anchorp, t))
log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN,
if (*s++ != '=') log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN,
"missing '=' after \"%s\"", t->name);
-while (isspace(*s)) s++;
+Uskip_whitespace(&s);
nb->string = read_string(s, t->name);
nb->cache_data = NULL;
/* Check nothing more on this line, then do the next loop iteration. */
- while (isspace(*s)) s++;
+ Uskip_whitespace(&s);
if (*s) extra_chars_error(s, US"driver name ", name, US"");
continue;
}
if (*p++ != ',') log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, "comma expected");
-while (isspace(*p)) p++;
+Uskip_whitespace(&p);
pp = p;
while (isalnum(*p) || (type == 1 && *p == '.')) p++;
rchain = &(next->rules);
next->pattern = string_dequote(&p);
- while (isspace(*p)) p++;
+ Uskip_whitespace(&p);
pp = p;
while (mac_isgraph(*p)) p++;
if (p - pp <= 0) log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN,
fudge. Anything that is not a retry rule starting "F," or "G," is treated as
an address list. */
- while (isspace(*p)) p++;
+ Uskip_whitespace(&p);
if (Ustrncmp(p, "senders", 7) == 0)
{
p += 7;
- while (isspace(*p)) p++;
+ Uskip_whitespace(&p);
if (*p++ != '=') log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN,
"\"=\" expected after \"senders\" in retry rule");
- while (isspace(*p)) p++;
+ Uskip_whitespace(&p);
next->senders = string_dequote(&p);
}
/* Now the retry rules. Keep the maximum timeout encountered. */
- while (isspace(*p)) p++;
+ Uskip_whitespace(&p);
- while (*p != 0)
+ while (*p)
{
retry_rule *rule = store_get(sizeof(retry_rule), FALSE);
*rchain = rule;
log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN,
"bad parameters for retry rule");
- while (isspace(*p)) p++;
- if (*p == ';')
+ if (Uskip_whitespace(&p) == ';')
{
p++;
- while (isspace(*p)) p++;
+ Uskip_whitespace(&p);
}
- else if (*p != 0)
+ else if (*p)
log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, "semicolon expected");
}
}
{
smtp_printf("%.3s-%.*s%.*s\r\n", TRUE, code, esclen, esc, (int)(nl - msg), msg);
msg = nl + 1;
- while (isspace(*msg)) msg++;
+ Uskip_whitespace(&msg);
}
}
}
return FALSE;
}
-while (isspace(*expint)) expint++;
-if (*expint == 0) return TRUE;
+Uskip_whitespace(&expint);
+if (!*expint) return TRUE;
while ((iface = string_nextinlist(&expint, &sep, big_buffer,
big_buffer_size)))
rest += sizeof("/no_check") - 1;
}
- while (isspace(*rest)) rest++;
+ Uskip_whitespace(&rest);
- if (*rest != 0)
+ if (*rest)
{
*errmsg = string_sprintf("Malformed value \"%s\" (expansion of \"%s\") "
"in %s transport", s, q, tblock->name);
colon = Ustrchr(h->text, ':');
s = colon + 1;
- while (isspace(*s)) s++;
+ Uskip_whitespace(&s);
/* Loop for multiple addresses in the header, enabling group syntax. Note
that we have to reset this after the header has been scanned. */
/* Advance to the next address */
s = ss + (terminator ? 1:0);
- while (isspace(*s)) s++;
+ Uskip_whitespace(&s);
} /* Next address */
f.parse_allow_group = FALSE;