Back to index

courier  0.68.2
rwdefaulthost.c
Go to the documentation of this file.
00001 /*
00002 ** Copyright 2000 Double Precision, Inc.
00003 ** See COPYING for distribution information.
00004 */
00005 
00006 #include      "courier.h"
00007 #include      "rw.h"
00008 #include      "rfc822/rfc822.h"
00009 #include      <string.h>
00010 
00011 void rw_local_defaulthost(struct rw_info *p, void (*func)(struct rw_info *))
00012 {
00013 struct rfc822token *q, **ptr;
00014 struct rfc822token at, name;
00015 
00016        if (p->ptr && p->ptr->token == 0 && p->ptr->len == 0)
00017               p->ptr=p->ptr->next;
00018 
00019        if (p->ptr == 0)            /* Address is <> */
00020        {
00021               (*func)(p);
00022               return;
00023        }
00024 
00025        /*
00026        ** Do not append the default domain to a UUCP address.
00027        */
00028 
00029        for (q=p->ptr; q; q=q->next)
00030               if (q->token == '!')
00031               {
00032                      (*func)(p);
00033                      return;
00034               }
00035 
00036        for (q=*(ptr=&p->ptr); q; q= *(ptr= &q->next))
00037               if (q->token == '@')
00038               {
00039                      (*func)(p);
00040                      return;
00041               }
00042 
00043        *ptr= &at;
00044 
00045        at.next= &name;
00046        at.token= '@';
00047        at.ptr=0;
00048        at.len=0;
00049 
00050        name.next=0;
00051        name.token=0;
00052        name.ptr=config_defaultdomain();
00053        name.len=strlen(name.ptr);
00054        (*func)(p);
00055 }