"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/search.c" between
exim-4.91.tar.xz and exim-4.92.tar.xz

About: Exim is a message transfer agent (MTA).

search.c  (exim-4.91.tar.xz):search.c  (exim-4.92.tar.xz)
skipping to change at line 452 skipping to change at line 452
Returns: a pointer to a dynamic string containing the answer, Returns: a pointer to a dynamic string containing the answer,
or NULL if the query failed or was deferred; in the or NULL if the query failed or was deferred; in the
latter case, search_find_defer is set TRUE; after an unusual latter case, search_find_defer is set TRUE; after an unusual
failure, there may be a message in search_error_message. failure, there may be a message in search_error_message.
*/ */
static uschar * static uschar *
internal_search_find(void *handle, uschar *filename, uschar *keystring) internal_search_find(void *handle, uschar *filename, uschar *keystring)
{ {
tree_node *t = (tree_node *)handle; tree_node * t = (tree_node *)handle;
search_cache *c = (search_cache *)(t->data.ptr); search_cache * c = (search_cache *)(t->data.ptr);
expiring_data *e; expiring_data * e = NULL; /* compiler quietening */
uschar *data = NULL; uschar * data = NULL;
int search_type = t->name[0] - '0'; int search_type = t->name[0] - '0';
int old_pool = store_pool; int old_pool = store_pool;
/* Lookups that return DEFER may not always set an error message. So that /* Lookups that return DEFER may not always set an error message. So that
the callers don't have to test for NULL, set an empty string. */ the callers don't have to test for NULL, set an empty string. */
search_error_message = US""; search_error_message = US"";
search_find_defer = FALSE; f.search_find_defer = FALSE;
DEBUG(D_lookup) debug_printf("internal_search_find: file=\"%s\"\n " DEBUG(D_lookup) debug_printf("internal_search_find: file=\"%s\"\n "
"type=%s key=\"%s\"\n", filename, "type=%s key=\"%s\"\n", filename,
lookup_list[search_type]->name, keystring); lookup_list[search_type]->name, keystring);
/* Insurance. If the keystring is empty, just fail. */ /* Insurance. If the keystring is empty, just fail. */
if (keystring[0] == 0) return NULL; if (keystring[0] == 0) return NULL;
/* Use the special store pool for search data */ /* Use the special store pool for search data */
skipping to change at line 509 skipping to change at line 509
keystring, keystring,
filename ? US"\n in " : US"", filename ? filename : US""); filename ? US"\n in " : US"", filename ? filename : US"");
} }
/* Call the code for the different kinds of search. DEFER is handled /* Call the code for the different kinds of search. DEFER is handled
like FAIL, except that search_find_defer is set so the caller can like FAIL, except that search_find_defer is set so the caller can
distinguish if necessary. */ distinguish if necessary. */
if (lookup_list[search_type]->find(c->handle, filename, keystring, keylength, if (lookup_list[search_type]->find(c->handle, filename, keystring, keylength,
&data, &search_error_message, &do_cache) == DEFER) &data, &search_error_message, &do_cache) == DEFER)
search_find_defer = TRUE; f.search_find_defer = TRUE;
/* A record that has been found is now in data, which is either NULL /* A record that has been found is now in data, which is either NULL
or points to a bit of dynamic store. Cache the result of the lookup if or points to a bit of dynamic store. Cache the result of the lookup if
caching is permitted. Lookups can disable caching, when they did something caching is permitted. Lookups can disable caching, when they did something
that changes their data. The mysql and pgsql lookups do this when an that changes their data. The mysql and pgsql lookups do this when an
UPDATE/INSERT query was executed. */ UPDATE/INSERT query was executed. */
else if (do_cache) else if (do_cache)
{ {
int len = keylength + 1; int len = keylength + 1;
skipping to change at line 552 skipping to change at line 552
{ {
DEBUG(D_lookup) debug_printf("lookup forced cache cleanup\n"); DEBUG(D_lookup) debug_printf("lookup forced cache cleanup\n");
c->item_cache = NULL; c->item_cache = NULL;
} }
} }
DEBUG(D_lookup) DEBUG(D_lookup)
{ {
if (data) if (data)
debug_printf("lookup yielded: %s\n", data); debug_printf("lookup yielded: %s\n", data);
else if (search_find_defer) else if (f.search_find_defer)
debug_printf("lookup deferred: %s\n", search_error_message); debug_printf("lookup deferred: %s\n", search_error_message);
else debug_printf("lookup failed\n"); else debug_printf("lookup failed\n");
} }
/* Return it in new dynamic store in the regular pool */ /* Return it in new dynamic store in the regular pool */
store_pool = old_pool; store_pool = old_pool;
return data ? string_copy(data) : NULL; return data ? string_copy(data) : NULL;
} }
skipping to change at line 654 skipping to change at line 654
debug_printf(" %s\n", t->name); debug_printf(" %s\n", t->name);
if (t == open_bot) debug_printf(" End\n"); if (t == open_bot) debug_printf(" End\n");
t = c->down; t = c->down;
} }
} }
/* First of all, try to match the key string verbatim. If matched a complete /* First of all, try to match the key string verbatim. If matched a complete
entry but could have been partial, flag to set up variables. */ entry but could have been partial, flag to set up variables. */
yield = internal_search_find(handle, filename, keystring); yield = internal_search_find(handle, filename, keystring);
if (search_find_defer) return NULL; if (f.search_find_defer) return NULL;
if (yield != NULL) { if (partial >= 0) set_null_wild = TRUE; } if (yield != NULL) { if (partial >= 0) set_null_wild = TRUE; }
/* Not matched a complete entry; handle partial lookups, but only if the full /* Not matched a complete entry; handle partial lookups, but only if the full
search didn't defer. Don't use string_sprintf() to construct the initial key, search didn't defer. Don't use string_sprintf() to construct the initial key,
just in case the original key is too long for the string_sprintf() buffer (it just in case the original key is too long for the string_sprintf() buffer (it
*has* happened!). The case of a zero-length affix has to be treated specially. *has* happened!). The case of a zero-length affix has to be treated specially.
*/ */
else if (partial >= 0) else if (partial >= 0)
{ {
skipping to change at line 677 skipping to change at line 677
/* Try with the affix on the front, except for a zero-length affix */ /* Try with the affix on the front, except for a zero-length affix */
if (affixlen == 0) keystring2 = keystring; else if (affixlen == 0) keystring2 = keystring; else
{ {
keystring2 = store_get(len + affixlen + 1); keystring2 = store_get(len + affixlen + 1);
Ustrncpy(keystring2, affix, affixlen); Ustrncpy(keystring2, affix, affixlen);
Ustrcpy(keystring2 + affixlen, keystring); Ustrcpy(keystring2 + affixlen, keystring);
DEBUG(D_lookup) debug_printf("trying partial match %s\n", keystring2); DEBUG(D_lookup) debug_printf("trying partial match %s\n", keystring2);
yield = internal_search_find(handle, filename, keystring2); yield = internal_search_find(handle, filename, keystring2);
if (search_find_defer) return NULL; if (f.search_find_defer) return NULL;
} }
/* The key in its entirety did not match a wild entry; try chopping off /* The key in its entirety did not match a wild entry; try chopping off
leading components. */ leading components. */
if (yield == NULL) if (yield == NULL)
{ {
int dotcount = 0; int dotcount = 0;
uschar *keystring3 = keystring2 + affixlen; uschar *keystring3 = keystring2 + affixlen;
uschar *s = keystring3; uschar *s = keystring3;
skipping to change at line 715 skipping to change at line 715
keystring3 = keystring2; keystring3 = keystring2;
} }
else else
{ {
keystring3 -= affixlen - 1; keystring3 -= affixlen - 1;
if (affixlen > 0) Ustrncpy(keystring3, affix, affixlen); if (affixlen > 0) Ustrncpy(keystring3, affix, affixlen);
} }
DEBUG(D_lookup) debug_printf("trying partial match %s\n", keystring3); DEBUG(D_lookup) debug_printf("trying partial match %s\n", keystring3);
yield = internal_search_find(handle, filename, keystring3); yield = internal_search_find(handle, filename, keystring3);
if (search_find_defer) return NULL; if (f.search_find_defer) return NULL;
if (yield != NULL) if (yield != NULL)
{ {
/* First variable is the wild part; second is the fixed part. Take care /* First variable is the wild part; second is the fixed part. Take care
to get it right when keystring3 is just "*". */ to get it right when keystring3 is just "*". */
if (expand_setup != NULL && *expand_setup >= 0) if (expand_setup != NULL && *expand_setup >= 0)
{ {
int fixedlength = Ustrlen(keystring3) - affixlen; int fixedlength = Ustrlen(keystring3) - affixlen;
int wildlength = Ustrlen(keystring) - fixedlength - 1; int wildlength = Ustrlen(keystring) - fixedlength - 1;
*expand_setup += 1; *expand_setup += 1;
skipping to change at line 757 skipping to change at line 757
uschar *atat = Ustrrchr(keystring, '@'); uschar *atat = Ustrrchr(keystring, '@');
if (atat != NULL && atat > keystring) if (atat != NULL && atat > keystring)
{ {
int savechar; int savechar;
savechar = *(--atat); savechar = *(--atat);
*atat = '*'; *atat = '*';
DEBUG(D_lookup) debug_printf("trying default match %s\n", atat); DEBUG(D_lookup) debug_printf("trying default match %s\n", atat);
yield = internal_search_find(handle, filename, atat); yield = internal_search_find(handle, filename, atat);
*atat = savechar; *atat = savechar;
if (search_find_defer) return NULL; if (f.search_find_defer) return NULL;
if (yield != NULL && expand_setup != NULL && *expand_setup >= 0) if (yield != NULL && expand_setup != NULL && *expand_setup >= 0)
{ {
*expand_setup += 1; *expand_setup += 1;
expand_nstring[*expand_setup] = keystring; expand_nstring[*expand_setup] = keystring;
expand_nlength[*expand_setup] = atat - keystring + 1; expand_nlength[*expand_setup] = atat - keystring + 1;
*expand_setup += 1; *expand_setup += 1;
expand_nstring[*expand_setup] = keystring; expand_nstring[*expand_setup] = keystring;
expand_nlength[*expand_setup] = 0; expand_nlength[*expand_setup] = 0;
} }
 End of changes. 8 change blocks. 
11 lines changed or deleted 11 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)