~ubuntu-branches/debian/stretch/alpine/stretch

« back to all changes in this revision

Viewing changes to pith/ablookup.c

  • Committer: Bazaar Package Importer
  • Author(s): Asheesh Laroia
  • Date: 2010-10-03 15:31:55 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20101003153155-2exypc96j1e8tw0p
Tags: 2.02-1
* New upstream release, based on re-alpine project
* Updated debian/copyright to reflect this fact
* re-alpine removed the non-free from the tarball, so now
  we do not repack the upstream tarball. (Yay!)

Show diffs side-by-side

added added

removed removed

Lines of Context:
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 $";
3
3
#endif
4
4
 
5
5
/*
6
6
 * ========================================================================
7
 
 * Copyright 2006-2008 University of Washington
 
7
 * Copyright 2006-2009 University of Washington
8
8
 *
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
1077
1079
    BuildTo toaddr;
1078
1080
    ADDRESS *addr;
1079
1081
    char buf[1000];
1080
 
    char *newaddr = NULL, *simple_addr = NULL;
 
1082
    char *newaddr = NULL, *simple_addr = NULL, *fcc = NULL;
1081
1083
    ENVELOPE *env = NULL;
1082
1084
    BODY *body = NULL;
1083
1085
 
1112
1114
    /* build the return list */
1113
1115
    for(list = biglist; list; list = list->next)
1114
1116
      if(list->entrynum != NO_NEXT){
 
1117
          fcc = NULL;
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;
1119
1122
 
1120
1123
              /*
1157
1160
              }
1158
1161
 
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);
1162
1165
 
1163
1166
              /* add to end of list */
1227
1230
 
1228
1231
    /* from the envelope addresses */
1229
1232
    if(env){
1230
 
        if(env->from)
1231
 
          add_addr_to_return_list(env->from, ALC_CURR, query, flags, &return_list);
1232
 
 
1233
 
        if(env->reply_to)
1234
 
          add_addr_to_return_list(env->reply_to, ALC_CURR, query, flags, &return_list);
1235
 
 
1236
 
        if(env->sender)
1237
 
          add_addr_to_return_list(env->sender, ALC_CURR, query, flags, &return_list);
1238
 
 
1239
 
        if(env->to)
1240
 
          add_addr_to_return_list(env->to, ALC_CURR, query, flags, &return_list);
1241
 
 
1242
 
        if(env->cc)
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);
 
1235
 
 
1236
        for(addr = env->reply_to; addr; addr = addr->next)
 
1237
          add_addr_to_return_list(addr, ALC_CURR, query, flags, &return_list);
 
1238
 
 
1239
        for(addr = env->sender; addr; addr = addr->next)
 
1240
          add_addr_to_return_list(addr, ALC_CURR, query, flags, &return_list);
 
1241
 
 
1242
        for(addr = env->to; addr; addr = addr->next)
 
1243
          add_addr_to_return_list(addr, ALC_CURR, query, flags, &return_list);
 
1244
 
 
1245
        for(addr = env->cc; addr; addr = addr->next)
 
1246
          add_addr_to_return_list(addr, ALC_CURR, query, flags, &return_list);
1244
1247
 
1245
1248
        /*
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;
 
1323
    ADDRESS *savenext;
1320
1324
 
1321
1325
    if(return_list && query && addr && addr->mailbox && addr->host){
1322
1326
 
 
1327
        savenext = addr->next;
 
1328
        addr->next = NULL;
1323
1329
        newaddr = addr_list_string(addr, NULL, 0);
 
1330
        addr->next = savenext;
1324
1331
 
1325
1332
        /*
1326
1333
         * If the start of the full_address actually matches the query
1343
1350
        }
1344
1351
 
1345
1352
        /*
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.
1348
1357
         */
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);
1351
1361
 
1352
1362
            /* add to end of list */
1353
1363
            if(*return_list == NULL){
1374
1384
 */
1375
1385
COMPLETE_S *
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)
1378
1388
{
1379
1389
    COMPLETE_S *new = NULL;
1380
1390
 
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;
1388
1399
 
1389
1400
    return(new);
1409
1420
        if((*compptr)->rev_fullname)
1410
1421
          fs_give((void **) &(*compptr)->rev_fullname);
1411
1422
 
 
1423
        if((*compptr)->fcc)
 
1424
          fs_give((void **) &(*compptr)->fcc);
 
1425
 
1412
1426
        fs_give((void **) compptr);
1413
1427
    }
1414
1428
}