1 /*
2 **  OSSP lmtp2nntp - Mail to News Gateway
3 **  Copyright (c) 2002-2003 Ralf S. Engelschall <rse@engelschall.com>
4 **  Copyright (c) 2002-2003 The OSSP Project <http://www.ossp.org/>
5 **  Copyright (c) 2002-2003 Cable & Wireless Germany <http://www.cw.com/de/>
6 **
7 **  This file is part of OSSP lmtp2nntp, an LMTP speaking local
8 **  mailer which forwards mails as Usenet news articles via NNTP.
9 **  It can be found at http://www.ossp.org/pkg/tool/lmtp2nntp/.
10 **
11 **  This program is free software; you can redistribute it and/or
12 **  modify it under the terms of the GNU General Public  License
13 **  as published by the Free Software Foundation; either version
14 **  2.0 of the License, or (at your option) any later version.
15 **
16 **  This program is distributed in the hope that it will be useful,
17 **  but WITHOUT ANY WARRANTY; without even the implied warranty of
18 **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 **  General Public License for more details.
20 **
21 **  You should have received a copy of the GNU General Public License
22 **  along with this file; if not, write to the Free Software
23 **  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
24 **  USA, or contact the OSSP project <ossp@ossp.org>.
25 **
26 **  lmtp2nntp_common.h: common stuff
27 */
28 
29 #ifndef __LMTP2NNTP_COMMON_H__
30 #define __LMTP2NNTP_COMMON_H__
31 
32 #include <val.h>
33 #include <var.h>
34 #include <sa.h>
35 
36 struct acl {
37     char      *acl;
38     int        not;
39     size_t     prefixlen;
40     sa_addr_t *saa;
41 };
42 
43 #include "lmtp2nntp_nntp.h"
44 struct ns {
45     sa_addr_t      *saa;
46     sa_t           *sa;
47     nntp_t         *nntp;
48     nntp_rc_t       rc;
49     l2_channel_t   *l2;
50 };
51 
52 struct session {
53     int     lhlo_seen;
54     char   *lhlo_domain;
55 };
56 
57 #include <sys/utsname.h>
58 typedef struct {
59     l2_context_t    ctx;
60     val_t          *prival;
61     val_t          *val;
62     char           *progname;
63     int             option_groupmode;
64     int             option_operationmode;
65     char           *option_operationmodefakestatus;
66     char           *option_operationmodefakedsn;
67     int             option_maxmessagesize;
68     headerrule_t   *option_firstheaderrule;
69     int             option_timeout_lmtp_accept;
70     int             option_timeout_lmtp_read;
71     int             option_timeout_lmtp_write;
72     int             option_timeout_nntp_connect;
73     int             option_timeout_nntp_read;
74     int             option_timeout_nntp_write;
75     char           *option_nodename;
76     char           *option_mailfrom;
77     char           *option_restrictheader;
78     char           *option_pidfile;
79     int             option_killflag;
80     uid_t           option_uid;
81     int             option_daemon;
82     int             nacl; /* number of acl structures found at pacl */
83     struct acl     *pacl; /* pointer to an array of acl structures */
84     int             option_childsmax;
85     int             active_childs;
86     l2_env_t       *l2_env;
87     l2_channel_t   *l2;
88     sa_addr_t      *saaServerbind;
89     sa_t           *saServerbind;
90     sa_addr_t      *saaClientbind;
91     sa_t           *saClientbind;
92     sa_addr_t      *saaIO;
93     sa_t           *saIO;
94     int             fdIOi;
95     int             fdIOo;
96     int             nns; /* number of ns structures found at pns */
97     struct ns      *pns; /* pointer to an array of ns structures */
98     char           *azGroupargs;
99     size_t          asGroupargs;
100     struct          session session;
101     msg_t          *msg;
102     var_t          *config_varregex;
103     var_t          *config_varctx;
104     int             msgcount; /* number of messages processed, used for creating unique ids */
105 } lmtp2nntp_t;
106 
107 #define ERR_EXECUTION 1
108 #define ERR_DELIVERY -2
109 
110 enum {
111     GROUPMODE_UNDEF = 0,
112     GROUPMODE_ARG,
113     GROUPMODE_ENVELOPE,
114     GROUPMODE_HEADER
115 };
116 
117 enum {
118     OPERATIONMODE_UNDEF = 0,
119     OPERATIONMODE_FAKE,
120     OPERATIONMODE_POST,
121     OPERATIONMODE_FEED
122 };
123 
124 void msg_headermatrixbuildup(msg_t *msg);
125 void msg_headermatrixteardwn(msg_t *msg);
126 void headerrewrite(lmtp2nntp_t *ctx);
127 
128 #include "l2.h"
129 extern l2_handler_t l2_handler_var;
130 extern void logbook(l2_channel_t *, l2_level_t, const char *, ...);
131 
132 #endif /* __LMTP2NNTP_COMMON_H__ */
133