*************************************************/
/* Copyright (c) University of Cambridge 1995 - 2018 */
*************************************************/
/* Copyright (c) University of Cambridge 1995 - 2018 */
-FILE *f = Ufopen(filename, "rb");
-if (f == NULL)
- {
- int save_errno = errno;
- *errmsg = string_open_failed(errno, "%s for linear search", filename);
- errno = save_errno;
- return NULL;
- }
+FILE * f = Ufopen(filename, "rb");
+if (!f)
+ *errmsg = string_open_failed("%s for linear search", filename);
static int
internal_lsearch_find(void * handle, const uschar * filename,
const uschar * keystring, int length, uschar ** result, uschar ** errmsg,
static int
internal_lsearch_find(void * handle, const uschar * filename,
const uschar * keystring, int length, uschar ** result, uschar ** errmsg,
+if (opts)
+ {
+ int sep = ',';
+ uschar * ele;
+
+ while ((ele = string_nextinlist(&opts, &sep, NULL, 0)))
+ if (Ustrcmp(ele, "ret=full") == 0)
+ { ret_full = TRUE; break; }
+ }
+
/* Wildcard searches may use up some store, because of expansions. We don't
want them to fill up our search store. What we do is set the pool to the main
pool and get a point to reset to later. Wildcard searches could also issue
lookups, but internal_search_find will take care of that, and the cache will be
safely stored in the search pool again. */
/* Wildcard searches may use up some store, because of expansions. We don't
want them to fill up our search store. What we do is set the pool to the main
pool and get a point to reset to later. Wildcard searches could also issue
lookups, but internal_search_find will take care of that, and the cache will be
safely stored in the search pool again. */
Ufgets(buffer, sizeof(buffer), f) != NULL;
last_was_eol = this_is_eol)
{
Ufgets(buffer, sizeof(buffer), f) != NULL;
last_was_eol = this_is_eol)
{
- if (linekeylength != length || strncmpic(buffer, keystring, length) != 0)
- continue;
- break; /* Key matched */
+ if (linekeylength != length || strncmpic(buffer, keystring, length) != 0)
+ continue;
+ break; /* Key matched */
/* A wild lsearch treats each key as a possible wildcarded string; no
expansion is done for nwildlsearch. */
/* A wild lsearch treats each key as a possible wildcarded string; no
expansion is done for nwildlsearch. */
- /* The key has matched. If the search involved a regular expression, it
- might have caused numerical variables to be set. However, their values will
- be in the wrong storage pool for external use. Copying them to the standard
- pool is not feasible because of the caching of lookup results - a repeated
- lookup will not match the regular expression again. Therefore, we flatten
- all numeric variables at this point. */
+ /* The key has matched. If the search involved a regular expression, it
+ might have caused numerical variables to be set. However, their values will
+ be in the wrong storage pool for external use. Copying them to the standard
+ pool is not feasible because of the caching of lookup results - a repeated
+ lookup will not match the regular expression again. Therefore, we drop
+ all numeric variables at this point. */
/* Compare an ip address against a list of network/ip addresses. We have to
allow for the "*" case specially. */
case LSEARCH_IP:
/* Compare an ip address against a list of network/ip addresses. We have to
allow for the "*" case specially. */
case LSEARCH_IP:
- if (linekeylength == 1 && buffer[0] == '*')
- {
- if (length != 1 || keystring[0] != '*') continue;
- }
- else if (length == 1 && keystring[0] == '*') continue;
- else
- {
- int maskoffset;
- int save = buffer[linekeylength];
- buffer[linekeylength] = 0;
- if (string_is_ip_address(buffer, &maskoffset) == 0 ||
- !host_is_in_net(keystring, buffer, maskoffset)) continue;
- buffer[linekeylength] = save;
- }
- break; /* Key matched */
+ if (linekeylength == 1 && buffer[0] == '*')
+ {
+ if (length != 1 || keystring[0] != '*') continue;
+ }
+ else if (length == 1 && keystring[0] == '*') continue;
+ else
+ {
+ int maskoffset;
+ int save = buffer[linekeylength];
+ buffer[linekeylength] = 0;
+ if (string_is_ip_address(buffer, &maskoffset) == 0 ||
+ !host_is_in_net(keystring, buffer, maskoffset)) continue;
+ buffer[linekeylength] = save;
+ }
+ break; /* Key matched */
}
/* The key has matched. Skip spaces after the key, and allow an optional
colon after the spaces. This is an odd specification, but it's for
compatibility. */
}
/* The key has matched. Skip spaces after the key, and allow an optional
colon after the spaces. This is an odd specification, but it's for
compatibility. */
yield = string_cat(yield, s);
/* Now handle continuations */
yield = string_cat(yield, s);
/* Now handle continuations */
int length, uschar ** result, uschar ** errmsg, uint * do_cache,
const uschar * opts)
{
int length, uschar ** result, uschar ** errmsg, uint * do_cache,
const uschar * opts)
{
return internal_lsearch_find(handle, filename, keystring, length, result,
return internal_lsearch_find(handle, filename, keystring, length, result,
int length, uschar ** result, uschar ** errmsg, uint * do_cache,
const uschar * opts)
{
int length, uschar ** result, uschar ** errmsg, uint * do_cache,
const uschar * opts)
{
return internal_lsearch_find(handle, filename, keystring, length, result,
return internal_lsearch_find(handle, filename, keystring, length, result,
int length, uschar ** result, uschar ** errmsg, uint * do_cache,
const uschar * opts)
{
int length, uschar ** result, uschar ** errmsg, uint * do_cache,
const uschar * opts)
{
return internal_lsearch_find(handle, filename, keystring, length, result,
return internal_lsearch_find(handle, filename, keystring, length, result,
int length, uschar ** result, uschar ** errmsg, uint * do_cache,
const uschar * opts)
{
int length, uschar ** result, uschar ** errmsg, uint * do_cache,
const uschar * opts)
{
if ((length == 1 && keystring[0] == '*') ||
string_is_ip_address(keystring, NULL) != 0)
return internal_lsearch_find(handle, filename, keystring, length, result,
if ((length == 1 && keystring[0] == '*') ||
string_is_ip_address(keystring, NULL) != 0)
return internal_lsearch_find(handle, filename, keystring, length, result,
*errmsg = string_sprintf("\"%s\" is not a valid iplsearch key (an IP "
"address, with optional CIDR mask, is wanted): "
*errmsg = string_sprintf("\"%s\" is not a valid iplsearch key (an IP "
"address, with optional CIDR mask, is wanted): "