Back to index

courier  0.68.2
addrlower.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 #include      "courier.h"
00007 #include      <ctype.h>
00008 #include      <stdlib.h>
00009 #include      <string.h>
00010 #if    HAVE_UNISTD_H
00011 #include      <unistd.h>
00012 #endif
00013 
00014 /* Convert address to consistent lowercase */
00015 
00016 void domainlower(char *c)
00017 {
00018        if ((c=strchr(c, '@')) != 0)
00019        {
00020               while (*c)
00021               {
00022                      *c=tolower((int)(unsigned char)*c);
00023                      ++c;
00024               }
00025        }
00026 }
00027 
00028 void locallower(char *c)
00029 {
00030 static int islocallower=0;
00031 
00032        if (islocallower == 0)
00033        {
00034        char   *s=config_localfilename("locallowercase");
00035 
00036               islocallower = access(s, 0) == 0 ? 1:-1;
00037               free(s);
00038        }
00039 
00040        if ( islocallower > 0 || (
00041 #if     HAVE_STRNCASECMP
00042               strncasecmp(c, "postmaster", 10)
00043 #else
00044               strnicmp(c, "postmaster", 10)
00045 #endif
00046                      == 0 && (c[10] == '\0' || c[10] == '@')))
00047        {
00048               while (*c)
00049               {
00050                      *c=tolower((int)(unsigned char)*c);
00051                      if (*c++ == '@')     break;
00052               }
00053        }
00054 }