"Fossies" - the Fresh Open Source Software Archive

Member "amavisd-milter-1.7.2/amavisd-milter/amavisd-milter.h" (2 Feb 2019, 6224 Bytes) of package /linux/privat/amavisd-milter-1.7.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "amavisd-milter.h" see the Fossies "Dox" file reference documentation.

    1 /*
    2  * Copyright (c) 2005, Petr Rehor <rx@rx.cz>. All rights reserved.
    3  *
    4  * Redistribution and use in source and binary forms, with or without
    5  * modification, are permitted provided that the following conditions
    6  * are met:
    7  * 1. Redistributions of source code must retain the above copyright
    8  *    notice, this list of conditions and the following disclaimer.
    9  * 2. Redistributions in binary form must reproduce the above copyright
   10  *    notice, this list of conditions and the following disclaimer in the
   11  *    documentation and/or other materials provided with the distribution.
   12  * 3. Neither the name of the copyright holders nor the names of its
   13  *    contributors may be used to endorse or promote products derived from
   14  *    this software without specific prior written permission.
   15  *
   16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
   17  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
   18  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
   19  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
   20  * OWNERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   21  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
   22  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
   23  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
   24  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
   25  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
   26  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   27  */
   28 
   29 #ifndef _AMAVISD_MILTER_H
   30 #define _AMAVISD_MILTER_H
   31 
   32 #include "compat.h"
   33 
   34 /* AM.PDP protocol version */
   35 #define AMPDP_VERSION   2
   36 
   37 /* Maximum message buffers length */
   38 #define MAXLOGBUF       1024    /* syslog message buffer */
   39 #define MAXAMABUF       65536   /* amavisd communication buffer */
   40 #define AMABUFCHUNK     2048    /* amavisd buffer reallocation step */
   41 
   42 /* Timeouts */
   43 #define SMFI_PROGRESS_TRIGGER   60      /* smfi_progress trigger */
   44 
   45 struct mlfiCtx;
   46 
   47 /* Address list */
   48 struct mlfiAddress {
   49     struct      mlfiAddress *q_next;    /* next recipient */
   50     char        q_paddr[1];             /* recipient */
   51 };
   52 
   53 /* Milter private data structure */
   54 struct mlfiCtx {
   55     char       *mlfi_daemon_name;       /* sendmail daemon name */
   56     char       *mlfi_hostname;          /* sendmail hostname */
   57     char       *mlfi_client_addr;       /* remote host address */
   58     char       *mlfi_client_host;       /* remote host name or address */
   59     char       *mlfi_client_name;       /* remote host name */
   60     char       *mlfi_helo;              /* remote host helo */
   61     char       *mlfi_protocol;          /* communication protocol */
   62     char       *mlfi_qid;               /* queue id */
   63     char       *mlfi_prev_qid;          /* previous queue id */
   64     char       *mlfi_from;              /* mail sender */
   65     struct      mlfiAddress *mlfi_rcpt; /* mail recipients */
   66     char        mlfi_wrkdir[MAXPATHLEN];/* working directory */
   67     char        mlfi_fname[MAXPATHLEN]; /* mail file name */
   68     FILE       *mlfi_fp;                /* mail file handler */
   69     int         mlfi_max_sem_locked;    /* connections semaphore locked */
   70     char       *mlfi_amabuf;            /* amavisd communication buffer */
   71     size_t      mlfi_amabuf_length;     /* amavisd buffer length */
   72     int         mlfi_amasd;             /* amavisd socket descriptor */
   73     char       *mlfi_policy_bank;       /* policy bank names */
   74     int         mlfi_cr_flag;           /* CR at the end of the body chunk */
   75 };
   76 
   77 /* Get private data from libmilter */
   78 #define         MLFICTX(ctx) ((struct mlfiCtx *)smfi_getpriv(ctx))
   79 
   80 /* Milter description */
   81 extern struct   smfiDesc smfilter;
   82 
   83 /* Milter functions */
   84 extern sfsistat mlfi_connect(SMFICTX *, char *, _SOCK_ADDR *);
   85 extern sfsistat mlfi_helo(SMFICTX *, char *);
   86 extern sfsistat mlfi_envfrom(SMFICTX *, char **);
   87 extern sfsistat mlfi_envrcpt(SMFICTX *, char **);
   88 extern sfsistat mlfi_header(SMFICTX *, char *, char *);
   89 extern sfsistat mlfi_eoh(SMFICTX *);
   90 extern sfsistat mlfi_body(SMFICTX *, unsigned char *, size_t);
   91 extern sfsistat mlfi_eom(SMFICTX *);
   92 extern sfsistat mlfi_close(SMFICTX *);
   93 extern sfsistat mlfi_abort(SMFICTX *);
   94 
   95 /* Global variables */
   96 extern int      policybank_from_daemon_name; /* Select Policybank from Miltermacro daemon_name */
   97 extern int      daemonize;              /* run as daemon */
   98 extern int      daemonized;             /* is daemon */
   99 extern int      debug_level;            /* max debug level */
  100 extern int      max_conns;              /* max amavisd connections */
  101 extern int      max_wait;               /* max wait for connection */
  102 extern sem_t   *max_sem;                /* amavisd connections semaphore */
  103 extern const char *pid_file;            /* pid file name */
  104 extern char    *mlfi_socket;            /* sendmail milter socket */
  105 #ifdef HAVE_SMFI_SETBACKLOG
  106 extern int      mlfi_socket_backlog;    /* milter socket backlog */
  107 #endif
  108 extern long     mlfi_timeout;           /* connection timeout */
  109 extern const char *amavisd_socket;      /* amavisd socket */
  110 extern long     amavisd_timeout;        /* connection timeout */
  111 extern int      ignore_amavisd_error;   /* pass through when amavisd failed */
  112 extern const char *working_dir;         /* working ditectory name */
  113 extern const char *delivery_care_of;    /* delivery mechanism */
  114 
  115 /* Amavisd communication */
  116 extern int      amavisd_connect(struct mlfiCtx *, struct sockaddr_un *,
  117                     time_t timeout);
  118 extern int      amavisd_request(struct mlfiCtx *, const char *, const char *);
  119 extern int      amavisd_response(struct mlfiCtx *);
  120 extern void     amavisd_close(struct mlfiCtx *);
  121 
  122 /* errno value if amavisd_connect() timed out. */
  123 #ifdef HAVE_SEM_TIMEDWAIT
  124 # define AMAVISD_CONNECT_TIMEDOUT_ERRNO ETIMEDOUT
  125 #else
  126 # define AMAVISD_CONNECT_TIMEDOUT_ERRNO EAGAIN
  127 #endif
  128 
  129 /* Log message */
  130 extern void     logmsg(int, const char *, ...);
  131 extern void     logqidmsg(struct mlfiCtx *, int, const char *, ...);
  132 
  133 /* Macros */
  134 
  135 #ifndef MAX
  136 #define MAX(a,b) (((a)>(b))?(a):(b))
  137 #endif
  138 
  139 #ifndef MIN
  140 #define MIN(a,b) (((a)<(b))?(a):(b))
  141 #endif
  142 
  143 #endif /* _AMAVISD_MILTER_H */