1
1
#if !defined(lint) && !defined(DOS)
2
static char rcsid[] = "$Id: ablookup.c 1110 2008-07-11 22:01:11Z hubert@u.washington.edu $";
2
static char rcsid[] = "$Id: ablookup.c 1266 2009-07-14 18:39:12Z hubert@u.washington.edu $";
6
6
* ========================================================================
7
* Copyright 2006-2008 University of Washington
7
* Copyright 2006-2009 University of Washington
9
9
* Licensed under the Apache License, Version 2.0 (the "License");
10
10
* you may not use this file except in compliance with the License.
1053
1053
* that match the query string. The matches can be for the nickname,
1054
1054
* for the fullname, or for the address@host part of the address.
1055
1055
* All of the matches are at the starts of the strings, not a general
1056
* substring match. If flags has ALC_INCLUDE_LDAP defined then LDAP
1056
* substring match. This is not true anymore. Fullname matches can be
1057
* at the start of the fullname or starting after a space in the fullname.
1058
* If flags has ALC_INCLUDE_LDAP defined then LDAP
1057
1059
* entries are added to the end of the list. The LDAP queries are done
1058
1060
* only for those servers that have the 'impl' feature turned on, which
1059
1061
* means that lookups should be done implicitly. This feature also
1112
1114
/* build the return list */
1113
1115
for(list = biglist; list; list = list->next)
1114
1116
if(list->entrynum != NO_NEXT){
1115
1118
toaddr.type = Abe;
1116
1119
toaddr.arg.abe = adrbk_get_ae(list->ab, list->entrynum);
1117
if(our_build_address(toaddr, &newaddr, NULL, NULL, NULL) == 0){
1120
if(our_build_address(toaddr, &newaddr, NULL, &fcc, NULL) == 0){
1118
1121
char *reverse_fullname = NULL;
1159
1162
new = new_complete_s(toaddr.arg.abe ? toaddr.arg.abe->nickname : NULL,
1160
newaddr, simple_addr, reverse_fullname,
1163
newaddr, simple_addr, reverse_fullname, fcc,
1161
1164
list->matches_bitmap | ALC_ABOOK);
1163
1166
/* add to end of list */
1228
1231
/* from the envelope addresses */
1231
add_addr_to_return_list(env->from, ALC_CURR, query, flags, &return_list);
1234
add_addr_to_return_list(env->reply_to, ALC_CURR, query, flags, &return_list);
1237
add_addr_to_return_list(env->sender, ALC_CURR, query, flags, &return_list);
1240
add_addr_to_return_list(env->to, ALC_CURR, query, flags, &return_list);
1243
add_addr_to_return_list(env->cc, ALC_CURR, query, flags, &return_list);
1233
for(addr = env->from; addr; addr = addr->next)
1234
add_addr_to_return_list(addr, ALC_CURR, query, flags, &return_list);
1236
for(addr = env->reply_to; addr; addr = addr->next)
1237
add_addr_to_return_list(addr, ALC_CURR, query, flags, &return_list);
1239
for(addr = env->sender; addr; addr = addr->next)
1240
add_addr_to_return_list(addr, ALC_CURR, query, flags, &return_list);
1242
for(addr = env->to; addr; addr = addr->next)
1243
add_addr_to_return_list(addr, ALC_CURR, query, flags, &return_list);
1245
for(addr = env->cc; addr; addr = addr->next)
1246
add_addr_to_return_list(addr, ALC_CURR, query, flags, &return_list);
1246
1249
* May as well search the body for addresses.
1317
1320
char *newaddr = NULL;
1318
1321
char *simple_addr = NULL;
1319
1322
COMPLETE_S *new = NULL, *cp;
1321
1325
if(return_list && query && addr && addr->mailbox && addr->host){
1327
savenext = addr->next;
1323
1329
newaddr = addr_list_string(addr, NULL, 0);
1330
addr->next = savenext;
1326
1333
* If the start of the full_address actually matches the query
1346
* Require the bitmap match so that we don't include it
1347
* when we don't really know why it matches.
1353
* We used to require && bitmap & (ALC_FULL | ALC_ADDR) before
1354
* we would add a match but we think that we should match
1355
* other stuff that matches (like middle names), too, unless we
1356
* are adding an address from the current message.
1349
if(newaddr && newaddr[0] && bitmap & (ALC_FULL | ALC_ADDR)){
1350
new = new_complete_s(NULL, newaddr, simple_addr, NULL, bitmap);
1358
if((newaddr && newaddr[0])
1359
&& (!(bitmap & ALC_CURR) || bitmap & (ALC_FULL | ALC_ADDR))){
1360
new = new_complete_s(NULL, newaddr, simple_addr, NULL, NULL, bitmap);
1352
1362
/* add to end of list */
1353
1363
if(*return_list == NULL){
1376
1386
new_complete_s(char *nick, char *full, char *addr,
1377
char *rev_fullname, unsigned matches_bitmap)
1387
char *rev_fullname, char *fcc, unsigned matches_bitmap)
1379
1389
COMPLETE_S *new = NULL;
1384
1394
new->full_address = full ? cpystr(full) : NULL;
1385
1395
new->addr = addr ? cpystr(addr) : NULL;
1386
1396
new->rev_fullname = rev_fullname ? cpystr(rev_fullname) : NULL;
1397
new->fcc = fcc ? cpystr(fcc) : NULL;
1387
1398
new->matches_bitmap = matches_bitmap;