masqmail

diff src/masqmail.h @ 0:08114f7dcc23

this is masqmail-0.2.21 from oliver kurth
author meillo@marmaro.de
date Fri, 26 Sep 2008 17:05:23 +0200
parents
children 26e34ae9a3e3
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/masqmail.h	Fri Sep 26 17:05:23 2008 +0200
     1.3 @@ -0,0 +1,656 @@
     1.4 +/*  MasqMail
     1.5 +    Copyright (C) 1999-2001 Oliver Kurth
     1.6 +
     1.7 +    This program is free software; you can redistribute it and/or modify
     1.8 +    it under the terms of the GNU General Public License as published by
     1.9 +    the Free Software Foundation; either version 2 of the License, or
    1.10 +    (at your option) any later version.
    1.11 +
    1.12 +    This program is distributed in the hope that it will be useful,
    1.13 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.14 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1.15 +    GNU General Public License for more details.
    1.16 +
    1.17 +    You should have received a copy of the GNU General Public License
    1.18 +    along with this program; if not, write to the Free Software
    1.19 +    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
    1.20 +*/
    1.21 +#include <config.h>
    1.22 +
    1.23 +#include <stdio.h>
    1.24 +#include <stdarg.h>
    1.25 +#include <errno.h>
    1.26 +#include <stdlib.h>
    1.27 +#include <string.h>
    1.28 +#include <ctype.h>
    1.29 +#include <unistd.h>
    1.30 +#include <pwd.h>
    1.31 +#include <sys/types.h>
    1.32 +#include <sys/socket.h>
    1.33 +#include <netinet/in.h>
    1.34 +#include <time.h>
    1.35 +#include <sys/time.h>
    1.36 +#include <netinet/in.h>
    1.37 +#include <arpa/inet.h>
    1.38 +#include <netdb.h>
    1.39 +#include <syslog.h>
    1.40 +#include <signal.h>
    1.41 +#include <fcntl.h>
    1.42 +
    1.43 +#include <glib.h>
    1.44 +
    1.45 +#ifdef ENABLE_IDENT
    1.46 +#include "libident/ident.h"
    1.47 +#endif
    1.48 +
    1.49 +#include "lookup.h"
    1.50 +
    1.51 +typedef
    1.52 +struct _interface
    1.53 +{
    1.54 +  gchar *address;
    1.55 +  gint port;
    1.56 +} interface;
    1.57 +
    1.58 +#define ADDR_FLAG_DELIVERED 0x01
    1.59 +#define ADDR_FLAG_DEFERED 0x02
    1.60 +#define ADDR_FLAG_FAILED 0x04
    1.61 +#define ADDR_FLAG_LAST_ROUTE 0x40
    1.62 +#define ADDR_FLAG_NOEXPAND 0x80
    1.63 +
    1.64 +typedef struct _address
    1.65 +{
    1.66 +  gchar *address;
    1.67 +  gchar *local_part;
    1.68 +  gchar *domain;
    1.69 +  gint flags;
    1.70 +  GList *children;
    1.71 +  struct _address *parent;
    1.72 +} address;
    1.73 +
    1.74 +#define addr_mark_delivered(addr) { addr->flags |= ADDR_FLAG_DELIVERED; }
    1.75 +#define addr_unmark_delivered(addr) { addr->flags &= ~ADDR_FLAG_DELIVERED; }
    1.76 +#define addr_is_delivered(addr) ((addr->flags & ADDR_FLAG_DELIVERED) != 0 )
    1.77 +
    1.78 +#define addr_mark_defered(addr) { addr->flags |= ADDR_FLAG_DEFERED; }
    1.79 +#define addr_unmark_defered(addr) { addr->flags &= ~ADDR_FLAG_DEFERED; }
    1.80 +#define addr_is_defered(addr) ((addr->flags & ADDR_FLAG_DEFERED) != 0 )
    1.81 +
    1.82 +#define addr_mark_failed(addr) { addr->flags |= ADDR_FLAG_FAILED; }
    1.83 +#define addr_unmark_failed(addr) { addr->flags &= ~ADDR_FLAG_FAILED; }
    1.84 +#define addr_is_failed(addr) ((addr->flags & ADDR_FLAG_FAILED) != 0 )
    1.85 +
    1.86 +typedef
    1.87 +struct _connect_route
    1.88 +{
    1.89 +  gchar *name;
    1.90 +  gchar *filename;
    1.91 +
    1.92 +  gchar *protocol;
    1.93 +
    1.94 +  gboolean is_local_net;
    1.95 +  gboolean last_route;
    1.96 +
    1.97 +  GList *allowed_return_paths;
    1.98 +  GList *not_allowed_return_paths;
    1.99 +  GList *allowed_mail_locals;
   1.100 +  GList *not_allowed_mail_locals;
   1.101 +  GList *allowed_rcpt_domains;
   1.102 +  GList *not_allowed_rcpt_domains;
   1.103 +
   1.104 +  interface *mail_host;
   1.105 +  gchar *wrapper;
   1.106 +  gboolean connect_error_fail;
   1.107 +
   1.108 +  gchar *helo_name;
   1.109 +  gboolean do_correct_helo;
   1.110 +  gboolean do_pipelining;
   1.111 +
   1.112 +  gchar *set_h_from_domain;
   1.113 +  gchar *set_h_reply_to_domain;
   1.114 +  gchar *set_return_path_domain;
   1.115 +
   1.116 +  GList *map_h_from_addresses;
   1.117 +  GList *map_h_reply_to_addresses;
   1.118 +  GList *map_h_mail_followup_to_addresses;
   1.119 +  GList *map_return_path_addresses;
   1.120 +
   1.121 +  gboolean expand_h_sender_domain;
   1.122 +  gboolean expand_h_sender_address;
   1.123 +
   1.124 +  GList *resolve_list;
   1.125 +
   1.126 +  gchar *auth_name;
   1.127 +  gchar *auth_login;
   1.128 +  gchar *auth_secret;
   1.129 +
   1.130 +  gchar *pop3_login;
   1.131 +
   1.132 +  gchar *pipe;
   1.133 +  
   1.134 +  gboolean pipe_fromline;
   1.135 +  gboolean pipe_fromhack;
   1.136 +} connect_route;
   1.137 +
   1.138 +typedef struct _get_conf
   1.139 +{
   1.140 +  gchar *protocol;
   1.141 +  gchar *server_name;
   1.142 +  guint server_port;
   1.143 +  gchar *wrapper;
   1.144 +  gchar *login_user;
   1.145 +  gchar *login_pass;
   1.146 +  address *address;
   1.147 +  address *return_path;
   1.148 +  gboolean do_keep;
   1.149 +  gboolean do_uidl;
   1.150 +  gboolean do_uidl_dele;
   1.151 +  gint max_size;
   1.152 +  gboolean max_size_delete;
   1.153 +  gint max_count;
   1.154 +
   1.155 +  GList *resolve_list;
   1.156 +
   1.157 +} get_conf;
   1.158 +
   1.159 +typedef
   1.160 +struct _masqmail_conf
   1.161 +{
   1.162 +  gint mail_uid;
   1.163 +  gint mail_gid;
   1.164 +
   1.165 +  gint orig_uid;
   1.166 +  gint orig_gid;
   1.167 +
   1.168 +  gboolean run_as_user;
   1.169 +
   1.170 +  gchar *mail_dir;
   1.171 +  gchar *lock_dir;
   1.172 +  gchar *spool_dir;
   1.173 +  gchar *log_dir;
   1.174 +
   1.175 +  gint debug_level;
   1.176 +  gboolean use_syslog;
   1.177 +  guint log_max_pri;
   1.178 +
   1.179 +  gchar *host_name;
   1.180 +  GList *local_hosts;
   1.181 +  GList *local_addresses;
   1.182 +  GList *not_local_addresses;
   1.183 +  GList *local_nets;
   1.184 +  GList *listen_addresses;
   1.185 +
   1.186 +  guint remote_port;
   1.187 +
   1.188 +  gboolean do_save_envelope_to;
   1.189 +
   1.190 +  gboolean defer_all;
   1.191 +  gboolean do_relay;
   1.192 +
   1.193 +  GList *ident_trusted_nets;
   1.194 +
   1.195 +  gboolean do_queue;
   1.196 +
   1.197 +  gboolean do_verbose;
   1.198 +
   1.199 +  gchar *mbox_default;
   1.200 +  GList *mbox_users;
   1.201 +  GList *mda_users;
   1.202 +  GList *maildir_users;
   1.203 +
   1.204 +  gchar *mda;
   1.205 +  gboolean mda_fromline;
   1.206 +  gboolean mda_fromhack;
   1.207 +
   1.208 +  gboolean pipe_fromline;
   1.209 +  gboolean pipe_fromhack;
   1.210 +
   1.211 +  gchar *alias_file;
   1.212 +  int (*alias_local_cmp)(const char *, const char *);
   1.213 +
   1.214 +  GList *local_net_routes;
   1.215 +  GList *connect_routes; /* list of pairs which point to lists */
   1.216 +
   1.217 +  gchar *online_detect;
   1.218 +  gchar *online_file;
   1.219 +  gchar *online_pipe;
   1.220 +  interface *mserver_iface;
   1.221 +
   1.222 +  GList *get_names;
   1.223 +  GList *online_gets; /* list of pairs which point to lists */
   1.224 +
   1.225 +  gchar *errmsg_file;
   1.226 +  gchar *warnmsg_file;
   1.227 +  GList *warn_intervals;
   1.228 +  gint max_defer_time;
   1.229 +
   1.230 +  gchar *log_user;
   1.231 +} masqmail_conf;
   1.232 +
   1.233 +extern masqmail_conf conf;
   1.234 +
   1.235 +typedef
   1.236 +struct _table_pair
   1.237 +{
   1.238 +  gchar *key;
   1.239 +  gpointer *value;
   1.240 +} table_pair;
   1.241 +
   1.242 +
   1.243 +typedef
   1.244 +enum _prot_id
   1.245 +{
   1.246 +  PROT_LOCAL = 0,
   1.247 +  PROT_BSMTP,
   1.248 +  PROT_SMTP,
   1.249 +  PROT_ESMTP,
   1.250 +  PROT_POP3,
   1.251 +  PROT_APOP,
   1.252 +  PROT_NUM
   1.253 +}prot_id;
   1.254 +
   1.255 +extern gchar *prot_names[];
   1.256 +
   1.257 +typedef
   1.258 +enum _header_id
   1.259 +{
   1.260 +  HEAD_FROM = 0,
   1.261 +  HEAD_SENDER,
   1.262 +  HEAD_TO,
   1.263 +  HEAD_CC,
   1.264 +  HEAD_BCC,
   1.265 +  HEAD_DATE,
   1.266 +  HEAD_MESSAGE_ID,
   1.267 +  HEAD_REPLY_TO,
   1.268 +  HEAD_SUBJECT,
   1.269 +  HEAD_RETURN_PATH,
   1.270 +  HEAD_ENVELOPE_TO,
   1.271 +  HEAD_RECEIVED,
   1.272 +  HEAD_NUM_IDS,
   1.273 +  HEAD_STATUS,
   1.274 +  HEAD_UNKNOWN = HEAD_NUM_IDS,
   1.275 +  HEAD_NONE = -1,
   1.276 +}header_id;
   1.277 +
   1.278 +typedef
   1.279 +struct _header_name
   1.280 +{
   1.281 +  gchar *header;
   1.282 +  header_id id;
   1.283 +}header_name;
   1.284 +
   1.285 +typedef
   1.286 +struct _header
   1.287 +{
   1.288 +  header_id id;
   1.289 +  gchar *header;
   1.290 +  gchar *value;
   1.291 +}header;
   1.292 +
   1.293 +
   1.294 +typedef
   1.295 +struct _message
   1.296 +{
   1.297 +  gchar *uid;
   1.298 +
   1.299 +  gchar *received_host;
   1.300 +  prot_id received_prot;
   1.301 +  gchar *ident;
   1.302 +  gint transfer_id; /* for multiple messages per transfer */
   1.303 +
   1.304 +  address *return_path;
   1.305 +  GList *rcpt_list;
   1.306 +  GList *non_rcpt_list;
   1.307 +
   1.308 +  GList *hdr_list;
   1.309 +  GList *data_list;
   1.310 +
   1.311 +  gint data_size;
   1.312 +  time_t received_time;
   1.313 +  time_t warned_time;
   1.314 +
   1.315 +  gchar *full_sender_name;
   1.316 +}message;
   1.317 +
   1.318 +typedef
   1.319 +struct _msg_out
   1.320 +{
   1.321 +  message *msg;
   1.322 +  
   1.323 +  address *return_path;
   1.324 +  GList *rcpt_list;
   1.325 +
   1.326 +  GList *hdr_list;
   1.327 +  GList *xtra_hdr_list;
   1.328 +}msg_out;
   1.329 +
   1.330 +typedef
   1.331 +struct _msgout_perhost
   1.332 +{
   1.333 +  gchar *host;
   1.334 +  GList *msgout_list;
   1.335 +} msgout_perhost;
   1.336 +
   1.337 +/* flags for accept() */
   1.338 +/*#define ACC_LOCAL      0x01 (we better use received_host == NULL) */
   1.339 +#define ACC_HEAD_FROM_RCPT 0x01 /* create To: Header from rcpt_list (cmd line) */
   1.340 +#define ACC_DEL_RCPTS      0x02 /* -t option, delete rcpts */
   1.341 +#define ACC_DEL_BCC        0x04 /* -t option, delete Bcc header */
   1.342 +#define ACC_RCPT_FROM_HEAD 0x08 /* -t option, get rcpts from headers */
   1.343 +#define ACC_NODOT_TERM     0x10 /* a dot on a line itself does not end
   1.344 +				   the message (-oi option) */
   1.345 +#define ACC_NO_RECVD_HDR   0x20 /* do not create a Received: header */
   1.346 +#define ACC_MAIL_FROM_HEAD 0x40 /* get return path from header */
   1.347 +#define ACC_NODOT_RELAX    0x80 /* do not be picky if message ist not terminated by a dot on a line */
   1.348 +#define ACC_SAVE_ENVELOPE_TO 0x0100 /* save an existent Envelope-to header as X-Orig-Envelope-to */
   1.349 +
   1.350 +#define DLVR_LOCAL 0x01
   1.351 +#define DLVR_LAN 0x02
   1.352 +#define DLVR_ONLINE 0x04
   1.353 +#define DLVR_ALL (DLVR_LOCAL|DLVR_LAN|DLVR_ONLINE)
   1.354 +
   1.355 +/* transport flags */
   1.356 +#define MSGSTR_FROMLINE 0x01
   1.357 +#define MSGSTR_FROMHACK 0x02
   1.358 +
   1.359 +typedef
   1.360 +enum _accept_error
   1.361 +{
   1.362 +  AERR_OK = 0,
   1.363 +  AERR_TIMEOUT,
   1.364 +  AERR_EOF,
   1.365 +  AERR_OVERFLOW,
   1.366 +  AERR_SYNTAX,
   1.367 +  AERR_NOSPOOL,
   1.368 +  AERR_NORCPT,
   1.369 +  AERR_UNKNOWN
   1.370 +}accept_error;
   1.371 +
   1.372 +#define BUF_LEN 1024
   1.373 +#define MAX_ADDRESS 256
   1.374 +#define MAX_DATALINE 4096
   1.375 +
   1.376 +typedef
   1.377 +enum _smtp_cmd_id
   1.378 +{
   1.379 +  SMTP_HELO = 0,
   1.380 +  SMTP_EHLO,
   1.381 +  SMTP_MAIL_FROM,
   1.382 +  SMTP_RCPT_TO,
   1.383 +  SMTP_DATA,
   1.384 +  SMTP_QUIT,
   1.385 +  SMTP_RSET,
   1.386 +  SMTP_NOOP,
   1.387 +  SMTP_HELP,
   1.388 +  SMTP_NUM_IDS,
   1.389 +  SMTP_EOF = -1,
   1.390 +  SMTP_ERROR = -2,
   1.391 +} smtp_cmd_id;
   1.392 +
   1.393 +typedef
   1.394 +struct _smtp_cmd
   1.395 +{
   1.396 +  smtp_cmd_id id;
   1.397 +  gchar *cmd;
   1.398 +} smtp_cmd;
   1.399 +
   1.400 +typedef
   1.401 +struct _smtp_connection
   1.402 +{
   1.403 +  gchar *remote_host;
   1.404 +
   1.405 +  prot_id prot;
   1.406 +  gint next_id;
   1.407 +  
   1.408 +  gboolean helo_seen;
   1.409 +  gboolean from_seen;
   1.410 +  gboolean rcpt_seen;
   1.411 +
   1.412 +  message *msg;
   1.413 +}smtp_connection;
   1.414 +
   1.415 +/* alias.c*/
   1.416 +gboolean addr_is_local(address *addr);
   1.417 +GList *alias_expand(GList *alias_table, GList *rcpt_list, GList *non_rcpt_list);
   1.418 +
   1.419 +/* child.c */
   1.420 +int child(const char *command);
   1.421 +
   1.422 +/* conf.c */
   1.423 +void init_conf();
   1.424 +gboolean read_conf(gchar *filename);
   1.425 +connect_route *read_route(gchar *filename, gboolean is_local_net);
   1.426 +GList *read_route_list(GList *rf_list, gboolean is_local_net);
   1.427 +void destroy_route(connect_route *r);
   1.428 +void destroy_route_list(GList *list);
   1.429 +get_conf *read_get_conf(gchar *filename);
   1.430 +void destroy_get_conf(get_conf *gc);
   1.431 +connect_route *create_local_route();
   1.432 +
   1.433 +/* expand.c */
   1.434 +GList *var_table_rcpt(GList *var_table, address *rcpt);
   1.435 +GList *var_table_msg(GList *var_table, message *msg);
   1.436 +GList *var_table_conf(GList *var_table);
   1.437 +gint expand(GList *var_list, gchar *format, gchar *result, gint result_len);
   1.438 +
   1.439 +/* message.c */
   1.440 +message *create_message(void);
   1.441 +void destroy_message(message *msg);
   1.442 +void destroy_msg_list(GList *msg_list);
   1.443 +void msg_free_data(message *msg);
   1.444 +gint msg_calc_size(message *msg, gboolean is_smtp);
   1.445 +
   1.446 +msg_out *create_msg_out(message *msg);
   1.447 +msg_out *clone_msg_out(msg_out *msgout_orig);
   1.448 +GList *create_msg_out_list(GList *msg_list);
   1.449 +void destroy_msg_out(msg_out *msgout);
   1.450 +void destroy_msg_out_list(GList *msgout_list);
   1.451 +
   1.452 +/* address.c */
   1.453 +address *create_address(gchar *path, gboolean is_rfc821);
   1.454 +address *create_address_qualified(gchar *path, gboolean is_rfc821,
   1.455 +				  gchar *domain);
   1.456 +address *create_address_pipe(gchar *path);
   1.457 +void destroy_address(address *addr);
   1.458 +address *copy_modify_address(const address *orig, gchar *l_part, gchar *dom);
   1.459 +#define copy_address(addr) copy_modify_address(addr, NULL, NULL)
   1.460 +gboolean addr_isequal(address *addr1, address *addr2);
   1.461 +gboolean addr_isequal_parent(address *addr1, address *addr2);
   1.462 +address *addr_find_ancestor(address *addr);
   1.463 +gboolean addr_is_delivered_children(address *addr);
   1.464 +gboolean addr_is_finished_children(address *addr);
   1.465 +gchar *addr_string(address *addr);
   1.466 +gint addr_match(address *addr1, address *addr2);
   1.467 +
   1.468 +/* accept.c */
   1.469 +accept_error accept_message(FILE *in, message *msg,
   1.470 +			    guint flags);
   1.471 +accept_error accept_message_prepare(message *msg, guint flags);
   1.472 +
   1.473 +/* header.c */
   1.474 +gchar *rec_timestamp();
   1.475 +GList *find_header(GList *hdr_list, header_id id, gchar *hdr_str);
   1.476 +void header_unfold(header *hdr);
   1.477 +void header_fold(header *hdr);
   1.478 +header *create_header(header_id id, gchar *fmt, ...);
   1.479 +void destroy_header(header *hdr);
   1.480 +header *copy_header(header *hdr);
   1.481 +header *get_header(gchar *line);
   1.482 +
   1.483 +/* smtp_in.c */
   1.484 +void smtp_in(FILE *in, FILE *out, gchar *remote_host, gchar *ident);
   1.485 +
   1.486 +/* listen.c */
   1.487 +void listen_port(GList *addr_list, gint qival, char *argv[]);
   1.488 +
   1.489 +/* parse.c */
   1.490 +gboolean split_address(const gchar *path, gchar **local_part, gchar **domain,
   1.491 +		       gboolean is_rfc821);
   1.492 +gboolean parse_address_rfc822(gchar *string,
   1.493 +		       gchar **local_begin, gchar **local_end,
   1.494 +		       gchar **domain_begin, gchar **domain_end,
   1.495 +			      gchar **address_end);
   1.496 +gboolean parse_address_rfc821(gchar *string,
   1.497 +			      gchar **local_begin, gchar **local_end,
   1.498 +			      gchar **domain_begin, gchar **domain_end,
   1.499 +			      gchar **address_end);
   1.500 +address *_create_address(gchar *string, gchar **end, gboolean is_rfc821);
   1.501 +address *create_address_rfc821(gchar *string, gchar **end);
   1.502 +address *create_address_rfc822(gchar *string, gchar **end);
   1.503 +GList *addr_list_append_rfc822(GList *addr_list, gchar *string, gchar *domain);
   1.504 +gboolean addr_isequal(address *addr1, address *addr2);
   1.505 +
   1.506 +/* connect.c */
   1.507 +mxip_addr *connect_hostlist(int *psockfd, gchar *host, guint port,
   1.508 +			  GList *addr_list);
   1.509 +mxip_addr *connect_resolvelist(int *psockfd, gchar *host, guint port,
   1.510 +			     GList *res_funcs);
   1.511 +
   1.512 +/* deliver.c */
   1.513 +void msg_rcptlist_local(GList *rcpt_list, GList **, GList **);
   1.514 +gboolean deliver_local(msg_out *msgout);
   1.515 +gboolean deliver_msglist_host(connect_route *route, GList *msg_list, gchar *host, GList *res_list);
   1.516 +gboolean deliver_route_msgout_list(connect_route *route, GList *msgout_list);
   1.517 +gboolean deliver_route_msg_list(connect_route *route, GList *msgout_list);
   1.518 +gboolean deliver_finish(msg_out *msgout);
   1.519 +gboolean deliver_finish_list(GList *msgout_list);
   1.520 +gboolean deliver_msg_list(GList *msg_list, guint flags);
   1.521 +gboolean deliver(message *msg);
   1.522 +
   1.523 +/* fail_msg.c */
   1.524 +gboolean fail_msg(message *msg, gchar *template,
   1.525 +		  GList *failed_rcpts, gchar *err_fmt, va_list args);
   1.526 +gboolean warn_msg(message *msg, gchar *template,
   1.527 +		  GList *failed_rcpts, gchar *err_fmt, va_list args);
   1.528 +
   1.529 +/* get.c */
   1.530 +gboolean get_from_file(gchar *fname);
   1.531 +gboolean get_from_name(gchar *name);
   1.532 +gboolean get_all(void);
   1.533 +void get_online(void);
   1.534 +void get_daemon(gint gival, char *argv[]);
   1.535 +gboolean pop_before_smtp(gchar *fname);
   1.536 +
   1.537 +/* interface.c */
   1.538 +gboolean init_sockaddr(struct sockaddr_in *name, interface *iface);
   1.539 +int make_server_socket(interface *iface);
   1.540 +
   1.541 +/* local.c */
   1.542 +gboolean append_file(message *msg, GList *hdr_list, gchar *user);
   1.543 +gboolean maildir_out(message *msg, GList *hdr_list, gchar *user, guint flags);
   1.544 +gboolean pipe_out(message *msg, GList *hdr_list, address *rcpt, gchar *cmd, guint flags);
   1.545 +
   1.546 +/* log.c */
   1.547 +gchar *ext_strerror(int err);
   1.548 +gboolean logopen(void);
   1.549 +void logclose(void);
   1.550 +void vlogwrite(int pri, const char *fmt, va_list args);
   1.551 +void logwrite(int pri, const char *fmt, ...);
   1.552 +void debugf(const char *fmt, ...);
   1.553 +void vdebugf(const char *fmt, va_list args);
   1.554 +void maillog(const char *fmt, ...);
   1.555 +
   1.556 +/* spool.c */
   1.557 +gboolean spool_read_data(message *msg);
   1.558 +gboolean spool_read_data(message *msg);
   1.559 +message *msg_spool_read(gchar *uid, gboolean do_readdata);
   1.560 +gboolean spool_write(message *msg, gboolean do_writedata);
   1.561 +gboolean spool_lock(gchar *uid);
   1.562 +gboolean spool_unlock(gchar *uid);
   1.563 +gboolean spool_delete_all(message *msg);
   1.564 +
   1.565 +/* queue.c */
   1.566 +GList *read_queue(gboolean do_readdata);
   1.567 +gboolean queue_run(void);
   1.568 +gboolean queue_run_online(void);
   1.569 +void queue_list(void);
   1.570 +gboolean queue_delete(gchar *uid);
   1.571 +
   1.572 +/* online.c */
   1.573 +gchar *detect_online();
   1.574 +void set_online_name(gchar *name);
   1.575 +
   1.576 +/* permissions.c */
   1.577 +gboolean is_ingroup(uid_t uid, gid_t gid);
   1.578 +void set_euidgid(gint uid, gint gid, uid_t *old_uid, gid_t *old_gid);
   1.579 +void set_identity(uid_t old_uid, gchar *task_name);
   1.580 +
   1.581 +/* rewrite.c */
   1.582 +gboolean set_address_header_domain(header *hdr, gchar *domain);
   1.583 +gboolean map_address_header(header *hdr, GList *table);
   1.584 +
   1.585 +/* route.c */
   1.586 +msgout_perhost *create_msgout_perhost(gchar *host);
   1.587 +void destroy_msgout_perhost(msgout_perhost *mo_ph);
   1.588 +void rewrite_headers(msg_out *msgout, connect_route *route);
   1.589 +void rcptlist_with_one_of_hostlist(GList *rcpt_list, GList *host_list,
   1.590 +				     GList **, GList **);
   1.591 +void rcptlist_with_addr_is_local(GList *rcpt_list,
   1.592 +				   GList **p_rcpt_list, GList **p_non_rcpt_list);
   1.593 +gboolean route_strip_msgout(connect_route *route, msg_out *msgout);
   1.594 +msg_out *route_prepare_msgout(connect_route *route, msg_out *msgout);
   1.595 +GList *route_msgout_list(connect_route *route, GList *msgout_list);
   1.596 +gboolean route_is_allowed_return_path(connect_route *route, address *ret_path);
   1.597 +gboolean route_is_allowed_mail_local(connect_route *route, address *ret_path);
   1.598 +void msg_rcptlist_route(connect_route *route, GList *rcpt_list,
   1.599 +			GList **p_rcpt_list, GList **p_non_rcpt_list);
   1.600 +
   1.601 +/* tables.c */
   1.602 +table_pair *create_pair(gchar *key, gpointer value);
   1.603 +table_pair *create_pair_string(gchar *key, gpointer value);
   1.604 +table_pair *parse_table_pair(gchar *line, char delim);
   1.605 +gpointer *table_find_func(GList *table_list, gchar *key, int (*cmp_func)(const char *, const char *));
   1.606 +gpointer *table_find(GList *table_list, gchar *key);
   1.607 +gpointer *table_find_case(GList *table_list, gchar *key);
   1.608 +gpointer *table_find_fnmatch(GList *table_list, gchar *key);
   1.609 +GList *table_read(gchar *fname, gchar delim);
   1.610 +void destroy_table(GList *table);
   1.611 +
   1.612 +/* timeival.c */
   1.613 +gint time_interval(gchar *str, gint *pos);
   1.614 +
   1.615 +/* permissions.c */
   1.616 +gboolean is_privileged_user(uid_t uid);
   1.617 +
   1.618 +/* other things */
   1.619 +
   1.620 +#define foreach(list, node)\
   1.621 +for((node) = g_list_first(list);\
   1.622 +    (node);\
   1.623 +    (node) = g_list_next(node))
   1.624 +
   1.625 +#ifdef ENABLE_DEBUG
   1.626 +#define DEBUG(level) if(level <= conf.debug_level)
   1.627 +#else
   1.628 +/* hopefully the compiler optmizes this away... */
   1.629 +#define DEBUG(level) if(0)
   1.630 +#endif
   1.631 +
   1.632 +#define LOG_VERBOSE 0x100
   1.633 +
   1.634 +#ifndef HAVE_GETLINE
   1.635 +#define getline(buf, size, file) getdelim(buf, size, '\n', file)
   1.636 +#endif
   1.637 +
   1.638 +#ifndef HAVE_FDATASYNC
   1.639 +#define fdatasync(fd) fsync(fd)
   1.640 +#endif
   1.641 +
   1.642 +#ifndef CONF_DIR
   1.643 +#define CONF_DIR "/etc/masqmail"
   1.644 +#endif
   1.645 +
   1.646 +#define CONF_FILE CONF_DIR"/masqmail.conf"
   1.647 +
   1.648 +#define PIDFILEDIR "/var/run/masqmail/"
   1.649 +
   1.650 +#ifndef va_copy
   1.651 +#ifdef __va_copy
   1.652 +#define va_copy(ap1, ap2) __va_copy(ap1, ap2)
   1.653 +#else
   1.654 +#define va_copy(ap1, ap2) G_VA_COPY(ap1, ap2)
   1.655 +#endif
   1.656 +#endif
   1.657 +
   1.658 +/* *BSD needs this: */
   1.659 +extern char **environ;