Back to index

courier  0.68.2
Functions
lcrewrite.c File Reference
#include "courier.h"
#include "rw.h"
#include "rfc822.h"
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

Go to the source code of this file.

Functions

struct rfc822trw_rewrite_tokenize (const char *address)
void rw_rewrite_module (struct rw_transport *module, struct rw_info *rwi, void(*func)(struct rw_info *))
int rw_syntaxchk (struct rfc822token *t)
void rw_rewrite_print (struct rw_info *info)
static void do_rw_rewrite_chksyn_print (struct rw_info *info, struct rfc822token *t)
void rw_rewrite_chksyn_print (struct rw_info *info)
void rw_rewrite_chksyn_at_ok_print (struct rw_info *info)

Function Documentation

static void do_rw_rewrite_chksyn_print ( struct rw_info *  info,
struct rfc822token t 
) [static]

Definition at line 110 of file lcrewrite.c.

{
       if (rw_syntaxchk(t))
       {
       static const char errmsg[]="Syntax error: ";
       char   *addr=rfc822_gettok(info->ptr);
       char   *buf;

              if (!addr)    clog_msg_errno();
              buf=courier_malloc(strlen(addr)+sizeof(errmsg));
              strcat(strcpy(buf, errmsg), addr);
              free(addr);
              (*info->err_func)(553, buf, info);
              free(buf);
       }
       else
              rw_rewrite_print(info);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void rw_rewrite_chksyn_at_ok_print ( struct rw_info *  info)

Definition at line 135 of file lcrewrite.c.

{
       struct rfc822token *t=info->ptr;

       if (t && t->token == '@')
              t=t->next;

       do_rw_rewrite_chksyn_print(info, t);
}

Here is the call graph for this function:

void rw_rewrite_chksyn_print ( struct rw_info *  info)

Definition at line 130 of file lcrewrite.c.

Here is the call graph for this function:

void rw_rewrite_module ( struct rw_transport module,
struct rw_info *  rwi,
void(*)(struct rw_info *)  func 
)

Definition at line 33 of file lcrewrite.c.

{
       if (!module || !module->rw_ptr)
              (*rwi->err_func)(450, "Internal failure.", rwi);
       else if (module->rw_ptr->rewrite_del)
              (*module->rw_ptr->rewrite)(rwi, func);
       else
              (*rwi->err_func)(550, "Invalid address.", rwi);
}

Here is the caller graph for this function:

void rw_rewrite_print ( struct rw_info *  info)

Definition at line 101 of file lcrewrite.c.

{
char   *p=rfc822_gettok(info->ptr);

       if (!p)              clog_msg_errno();

       ( (struct rw_info_rewrite *)info->udata)->buf=p;
}

Here is the call graph for this function:

Here is the caller graph for this function:

struct rfc822t* rw_rewrite_tokenize ( const char *  address) [read]

Definition at line 20 of file lcrewrite.c.

{
struct rfc822t *tokens=rfc822t_alloc_new(address, NULL, NULL);
int    i;

       if (!tokens)  clog_msg_errno();
       for (i=1; i<tokens->ntokens; i++)
              tokens->tokens[i-1].next=tokens->tokens+i;
       return (tokens);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int rw_syntaxchk ( struct rfc822token t)

Definition at line 44 of file lcrewrite.c.

{
int    cnt;

       /*
       ** The following tokens:  ! @ % : . may NOT:
       **
       ** a) appear next to each other, and b) appear at the beginning or
       ** the end of the address.
       **
       */
       if (!t)       return (0);   /* <> envelope sender ok */

       cnt=1;

       while (t)
       {
              switch (t->token)    {
              case '<':
              case '>':
              case ';':
              case '(':
              case ')':
                     return (-1);  /* These cannot appear anywhere */
              case '!':
              case '@':
              case '%':
              case ':':
              case '.':
                     if (++cnt > 1)       return (-1);
                     break;
              case 0:
              case '"':
                     {
                            int i;

                            for (i=0; i<t->len; i++)
                            {
                                   unsigned char c=t->ptr[i];

                                   if (isspace((int)c) || c < ' ')
                                          return (-1);
                            }
                     }
              default:
                     cnt=0;
                     break;
              }
              t=t->next;
       }
       if (cnt)      return (-1);
       return (0);
}

Here is the caller graph for this function: