home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / bsd_srcs / usr.sbin / sendmail / aux / addr.c next >
Encoding:
C/C++ Source or Header  |  1991-04-19  |  4.2 KB  |  163 lines

  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, with or without
  7.  * modification, are permitted provided that the following conditions
  8.  * are met:
  9.  * 1. Redistributions of source code must retain the above copyright
  10.  *    notice, this list of conditions and the following disclaimer.
  11.  * 2. Redistributions in binary form must reproduce the above copyright
  12.  *    notice, this list of conditions and the following disclaimer in the
  13.  *    documentation and/or other materials provided with the distribution.
  14.  * 3. All advertising materials mentioning features or use of this software
  15.  *    must display the following acknowledgement:
  16.  *    This product includes software developed by the University of
  17.  *    California, Berkeley and its contributors.
  18.  * 4. Neither the name of the University nor the names of its contributors
  19.  *    may be used to endorse or promote products derived from this software
  20.  *    without specific prior written permission.
  21.  *
  22.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  23.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  25.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  26.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  27.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  28.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  29.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  30.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  31.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  32.  * SUCH DAMAGE.
  33.  */
  34.  
  35. #ifndef lint
  36. char copyright[] =
  37. "@(#) Copyright (c) 1988 Regents of the University of California.\n\
  38.  All rights reserved.\n";
  39. #endif /* not lint */
  40.  
  41. #ifndef lint
  42. static char sccsid[] = "@(#)addr.c    5.3 (Berkeley) 6/1/90";
  43. #endif /* not lint */
  44.  
  45. # include "postbox.h"
  46.  
  47. /*
  48. **  PUTONQ -- put an address node on the end of a queue
  49. **
  50. **    Parameters:
  51. **        a -- the address to put on the queue.
  52. **        q -- the queue to put it on.
  53. **
  54. **    Returns:
  55. **        none
  56. **
  57. **    Side Effects:
  58. **        none
  59. **
  60. **    Called By:
  61. **        alias
  62. **        recipient
  63. */
  64.  
  65. putonq(a, q)
  66.     register ADDRESS *a;
  67.     register ADDRESS *q;
  68. {
  69.     if (q->q_prev == NULL)
  70.     {
  71.         q->q_prev = q->q_next = a;
  72.         a->q_prev = NULL;
  73.     }
  74.     else
  75.     {
  76.         a->q_prev = q->q_prev;
  77.         q->q_prev->q_next = a;
  78.         q->q_prev = a;
  79.     }
  80.     a->q_next = NULL;
  81. }
  82. /*
  83. **  TKOFFQ -- remove address node from queue
  84. **
  85. **    Takes a node off of a queue, from anyplace in the queue.
  86. **
  87. **    Parameters:
  88. **        a -- the node to remove.
  89. **        q -- the queue to remove it from.
  90. **
  91. **    Returns:
  92. **        none
  93. **
  94. **    Side Effects:
  95. **        none
  96. **
  97. **    Called By:
  98. **        alias
  99. */
  100.  
  101. tkoffq(a, q)
  102.     register ADDRESS *a;
  103.     register ADDRESS *q;
  104. {
  105.     if (a->q_prev != NULL)
  106.         a->q_prev->q_next = a->q_next;
  107.     else
  108.         q->q_next = a->q_next;
  109.     if (a->q_next != NULL)
  110.         a->q_next->q_prev = a->q_prev;
  111.     else
  112.         q->q_prev = a->q_prev;
  113. }
  114. /*
  115. **  SAMEADDR -- Determine if tow addresses are the same
  116. **
  117. **    This is not just a straight comparison -- if the mailer doesn't
  118. **    care about the host we just ignore it, etc.
  119. **
  120. **    Parameters:
  121. **        a, b -- pointers to the internal forms to compare.
  122. **        wildflg -- if TRUE, 'a' may have no user specified,
  123. **            in which case it is to match anything.
  124. **
  125. **    Returns:
  126. **        TRUE -- they represent the same mailbox.
  127. **        FALSE -- they don't.
  128. **
  129. **    Side Effects:
  130. **        none.
  131. **
  132. **    Called By:
  133. **        recipient
  134. **        alias
  135. */
  136.  
  137. bool
  138. sameaddr(a, b, wildflg)
  139.     register ADDRESS *a;
  140.     register ADDRESS *b;
  141.     bool wildflg;
  142. {
  143.     /* if they don't have the same mailer, forget it */
  144.     if (a->q_mailer != b->q_mailer)
  145.         return (FALSE);
  146.  
  147.     /* if the user isn't the same, we can drop out */
  148.     if ((!wildflg || a->q_user[0] != '\0') && strcmp(a->q_user, b->q_user) != 0)
  149.         return (FALSE);
  150.  
  151.     /* if the mailer ignores hosts, we have succeeded! */
  152.     if (bitset(M_NOHOST, Mailer[a->q_mailer]->m_flags))
  153.         return (TRUE);
  154.  
  155.     /* otherwise compare hosts (but be careful for NULL ptrs) */
  156.     if (a->q_host == NULL || b->q_host == NULL)
  157.         return (FALSE);
  158.     if (strcmp(a->q_host, b->q_host) != 0)
  159.         return (FALSE);
  160.  
  161.     return (TRUE);
  162. }
  163.