Back to index

courier  0.68.2
cdomaincmp.c
Go to the documentation of this file.
00001 /*
00002 ** Copyright 1998 - 1999 Double Precision, Inc.
00003 ** See COPYING for distribution information.
00004 */
00005 
00006 #if    HAVE_CONFIG_H
00007 #include      "courier.h"
00008 #endif
00009 #include      "rw.h"
00010 #include      "rfc822.h"
00011 #include      <string.h>
00012 #include      <stdlib.h>
00013 
00014 /* Compare domains */
00015 
00016 int config_domaincmp(const char *address, const char *domain, unsigned domainl)
00017 {
00018 unsigned l;
00019 
00020        if (!domainl) return (1);
00021        l=strlen(address);
00022 
00023        if (*domain == '.')  /* Subdomain wildcard */
00024        {
00025               if (l >= domainl)
00026                      return (
00027 #if    HAVE_STRNCASECMP
00028                             strncasecmp(address+(l-domainl), domain,
00029                                    domainl)
00030 #else
00031                             strnicmp(address+(l-domainl), domain,
00032                                    domainl)
00033 #endif
00034                             );
00035               return (1);
00036        }
00037 
00038        if (l != domainl)    return (1);
00039 
00040        return (
00041 #if    HAVE_STRNCASECMP
00042                      strncasecmp(address, domain, domainl)
00043 #else
00044                      strnicmp(address, domain, domainl)
00045 #endif
00046               );
00047 }