Annotation of 43BSDReno/usr.sbin/sendmail/aux/addr.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 1983 Eric P. Allman
                      3:  * Copyright (c) 1988 Regents of the University of California.
                      4:  * All rights reserved.
                      5:  *
                      6:  * Redistribution and use in source and binary forms are permitted provided
                      7:  * that: (1) source distributions retain this entire copyright notice and
                      8:  * comment, and (2) distributions including binaries display the following
                      9:  * acknowledgement:  ``This product includes software developed by the
                     10:  * University of California, Berkeley and its contributors'' in the
                     11:  * documentation or other materials provided with the distribution and in
                     12:  * all advertising materials mentioning features or use of this software.
                     13:  * Neither the name of the University nor the names of its contributors may
                     14:  * be used to endorse or promote products derived from this software without
                     15:  * specific prior written permission.
                     16:  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
                     17:  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
                     18:  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
                     19:  */
                     20: 
                     21: #ifndef lint
                     22: char copyright[] =
                     23: "@(#) Copyright (c) 1988 Regents of the University of California.\n\
                     24:  All rights reserved.\n";
                     25: #endif /* not lint */
                     26: 
                     27: #ifndef lint
                     28: static char sccsid[] = "@(#)addr.c     5.3 (Berkeley) 6/1/90";
                     29: #endif /* not lint */
                     30: 
                     31: # include "postbox.h"
                     32: 
                     33: /*
                     34: **  PUTONQ -- put an address node on the end of a queue
                     35: **
                     36: **     Parameters:
                     37: **             a -- the address to put on the queue.
                     38: **             q -- the queue to put it on.
                     39: **
                     40: **     Returns:
                     41: **             none
                     42: **
                     43: **     Side Effects:
                     44: **             none
                     45: **
                     46: **     Called By:
                     47: **             alias
                     48: **             recipient
                     49: */
                     50: 
                     51: putonq(a, q)
                     52:        register ADDRESS *a;
                     53:        register ADDRESS *q;
                     54: {
                     55:        if (q->q_prev == NULL)
                     56:        {
                     57:                q->q_prev = q->q_next = a;
                     58:                a->q_prev = NULL;
                     59:        }
                     60:        else
                     61:        {
                     62:                a->q_prev = q->q_prev;
                     63:                q->q_prev->q_next = a;
                     64:                q->q_prev = a;
                     65:        }
                     66:        a->q_next = NULL;
                     67: }
                     68: /*
                     69: **  TKOFFQ -- remove address node from queue
                     70: **
                     71: **     Takes a node off of a queue, from anyplace in the queue.
                     72: **
                     73: **     Parameters:
                     74: **             a -- the node to remove.
                     75: **             q -- the queue to remove it from.
                     76: **
                     77: **     Returns:
                     78: **             none
                     79: **
                     80: **     Side Effects:
                     81: **             none
                     82: **
                     83: **     Called By:
                     84: **             alias
                     85: */
                     86: 
                     87: tkoffq(a, q)
                     88:        register ADDRESS *a;
                     89:        register ADDRESS *q;
                     90: {
                     91:        if (a->q_prev != NULL)
                     92:                a->q_prev->q_next = a->q_next;
                     93:        else
                     94:                q->q_next = a->q_next;
                     95:        if (a->q_next != NULL)
                     96:                a->q_next->q_prev = a->q_prev;
                     97:        else
                     98:                q->q_prev = a->q_prev;
                     99: }
                    100: /*
                    101: **  SAMEADDR -- Determine if tow addresses are the same
                    102: **
                    103: **     This is not just a straight comparison -- if the mailer doesn't
                    104: **     care about the host we just ignore it, etc.
                    105: **
                    106: **     Parameters:
                    107: **             a, b -- pointers to the internal forms to compare.
                    108: **             wildflg -- if TRUE, 'a' may have no user specified,
                    109: **                     in which case it is to match anything.
                    110: **
                    111: **     Returns:
                    112: **             TRUE -- they represent the same mailbox.
                    113: **             FALSE -- they don't.
                    114: **
                    115: **     Side Effects:
                    116: **             none.
                    117: **
                    118: **     Called By:
                    119: **             recipient
                    120: **             alias
                    121: */
                    122: 
                    123: bool
                    124: sameaddr(a, b, wildflg)
                    125:        register ADDRESS *a;
                    126:        register ADDRESS *b;
                    127:        bool wildflg;
                    128: {
                    129:        /* if they don't have the same mailer, forget it */
                    130:        if (a->q_mailer != b->q_mailer)
                    131:                return (FALSE);
                    132: 
                    133:        /* if the user isn't the same, we can drop out */
                    134:        if ((!wildflg || a->q_user[0] != '\0') && strcmp(a->q_user, b->q_user) != 0)
                    135:                return (FALSE);
                    136: 
                    137:        /* if the mailer ignores hosts, we have succeeded! */
                    138:        if (bitset(M_NOHOST, Mailer[a->q_mailer]->m_flags))
                    139:                return (TRUE);
                    140: 
                    141:        /* otherwise compare hosts (but be careful for NULL ptrs) */
                    142:        if (a->q_host == NULL || b->q_host == NULL)
                    143:                return (FALSE);
                    144:        if (strcmp(a->q_host, b->q_host) != 0)
                    145:                return (FALSE);
                    146: 
                    147:        return (TRUE);
                    148: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.