masqmail

annotate src/masqmail.h @ 398:b033fd9b96e4

Typographic rework in man page and line-breaking.
author markus schnalke <meillo@marmaro.de>
date Tue, 21 Feb 2012 14:44:00 +0100
parents a408411ff8df
children 8fedb93e9b72
rev   line source
meillo@367 1 /*
meillo@367 2 ** MasqMail
meillo@367 3 ** Copyright (C) 1999-2001 Oliver Kurth
meillo@367 4 ** Copyright (C) 2010 markus schnalke <meillo@marmaro.de>
meillo@367 5 **
meillo@367 6 ** This program is free software; you can redistribute it and/or modify
meillo@367 7 ** it under the terms of the GNU General Public License as published by
meillo@367 8 ** the Free Software Foundation; either version 2 of the License, or
meillo@367 9 ** (at your option) any later version.
meillo@367 10 **
meillo@367 11 ** This program is distributed in the hope that it will be useful,
meillo@367 12 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
meillo@367 13 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
meillo@367 14 ** GNU General Public License for more details.
meillo@367 15 **
meillo@367 16 ** You should have received a copy of the GNU General Public License
meillo@367 17 ** along with this program; if not, write to the Free Software
meillo@367 18 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
meillo@0 19 */
meillo@0 20 #include <config.h>
meillo@0 21
meillo@0 22 #include <stdio.h>
meillo@0 23 #include <stdarg.h>
meillo@0 24 #include <errno.h>
meillo@0 25 #include <stdlib.h>
meillo@0 26 #include <string.h>
meillo@0 27 #include <ctype.h>
meillo@0 28 #include <unistd.h>
meillo@0 29 #include <pwd.h>
meillo@0 30 #include <sys/types.h>
meillo@0 31 #include <sys/socket.h>
meillo@0 32 #include <netinet/in.h>
meillo@0 33 #include <time.h>
meillo@0 34 #include <sys/time.h>
meillo@0 35 #include <netinet/in.h>
meillo@0 36 #include <arpa/inet.h>
meillo@0 37 #include <netdb.h>
meillo@0 38 #include <syslog.h>
meillo@0 39 #include <signal.h>
meillo@0 40 #include <fcntl.h>
meillo@0 41
meillo@0 42 #include <glib.h>
meillo@0 43
meillo@0 44 #include "lookup.h"
meillo@0 45
meillo@10 46 typedef struct _interface {
meillo@10 47 gchar *address;
meillo@10 48 gint port;
meillo@0 49 } interface;
meillo@0 50
meillo@0 51 #define ADDR_FLAG_DELIVERED 0x01
meillo@0 52 #define ADDR_FLAG_DEFERED 0x02
meillo@0 53 #define ADDR_FLAG_FAILED 0x04
meillo@0 54 #define ADDR_FLAG_LAST_ROUTE 0x40
meillo@0 55
meillo@10 56 typedef struct _address {
meillo@10 57 gchar *address;
meillo@10 58 gchar *local_part;
meillo@10 59 gchar *domain;
meillo@10 60 gint flags;
meillo@10 61 GList *children;
meillo@10 62 struct _address *parent;
meillo@0 63 } address;
meillo@0 64
meillo@0 65 #define addr_mark_delivered(addr) { addr->flags |= ADDR_FLAG_DELIVERED; }
meillo@0 66 #define addr_unmark_delivered(addr) { addr->flags &= ~ADDR_FLAG_DELIVERED; }
meillo@0 67 #define addr_is_delivered(addr) ((addr->flags & ADDR_FLAG_DELIVERED) != 0 )
meillo@0 68
meillo@0 69 #define addr_mark_defered(addr) { addr->flags |= ADDR_FLAG_DEFERED; }
meillo@0 70 #define addr_unmark_defered(addr) { addr->flags &= ~ADDR_FLAG_DEFERED; }
meillo@0 71 #define addr_is_defered(addr) ((addr->flags & ADDR_FLAG_DEFERED) != 0 )
meillo@0 72
meillo@0 73 #define addr_mark_failed(addr) { addr->flags |= ADDR_FLAG_FAILED; }
meillo@0 74 #define addr_unmark_failed(addr) { addr->flags &= ~ADDR_FLAG_FAILED; }
meillo@0 75 #define addr_is_failed(addr) ((addr->flags & ADDR_FLAG_FAILED) != 0 )
meillo@0 76
meillo@10 77 typedef struct _connect_route {
meillo@10 78 gchar *name;
meillo@10 79 gchar *filename;
meillo@0 80
meillo@354 81 gboolean is_perma;
meillo@10 82 gboolean last_route;
meillo@0 83
meillo@317 84 GList *allowed_senders;
meillo@317 85 GList *denied_senders;
meillo@317 86 GList *allowed_recipients;
meillo@317 87 GList *denied_recipients;
meillo@0 88
meillo@10 89 interface *mail_host;
meillo@10 90 gboolean connect_error_fail;
meillo@320 91 GList *resolve_list;
meillo@10 92 gchar *helo_name;
meillo@10 93 gboolean do_correct_helo;
meillo@222 94 gboolean instant_helo;
meillo@10 95 gboolean do_pipelining;
meillo@320 96 gchar *auth_name;
meillo@320 97 gchar *auth_login;
meillo@320 98 gchar *auth_secret;
meillo@320 99 gchar *wrapper;
meillo@0 100
meillo@10 101 gchar *set_h_from_domain;
meillo@10 102 gchar *set_h_reply_to_domain;
meillo@10 103 gchar *set_return_path_domain;
meillo@10 104 GList *map_h_from_addresses;
meillo@10 105 GList *map_h_reply_to_addresses;
meillo@10 106 GList *map_h_mail_followup_to_addresses;
meillo@10 107 GList *map_return_path_addresses;
meillo@10 108 gboolean expand_h_sender_domain;
meillo@10 109 gboolean expand_h_sender_address;
meillo@0 110
meillo@10 111 gchar *pipe;
meillo@10 112 gboolean pipe_fromline;
meillo@10 113 gboolean pipe_fromhack;
meillo@0 114 } connect_route;
meillo@0 115
meillo@10 116 typedef struct _masqmail_conf {
meillo@10 117 gint mail_uid;
meillo@10 118 gint mail_gid;
meillo@0 119
meillo@10 120 gint orig_uid;
meillo@10 121 gint orig_gid;
meillo@0 122
meillo@10 123 gboolean run_as_user;
meillo@0 124
meillo@10 125 gchar *mail_dir;
meillo@10 126 gchar *lock_dir;
meillo@10 127 gchar *spool_dir;
meillo@10 128 gchar *log_dir;
meillo@0 129
meillo@10 130 gint debug_level;
meillo@10 131 gboolean use_syslog;
meillo@0 132
meillo@10 133 gchar *host_name;
meillo@10 134 GList *local_hosts;
meillo@10 135 GList *local_addresses;
meillo@10 136 GList *not_local_addresses;
meillo@10 137 GList *listen_addresses;
meillo@0 138
meillo@367 139 /*
meillo@367 140 ** ANSI C defines unsigned long to be at least 32bit
meillo@367 141 ** i.e. ca. 4GB max; that should be enough.
meillo@367 142 */
meillo@117 143 gulong max_msg_size;
meillo@117 144
meillo@10 145 gboolean do_save_envelope_to;
meillo@0 146
meillo@10 147 gboolean defer_all;
meillo@10 148 gboolean do_relay;
meillo@0 149
meillo@10 150 gboolean do_queue;
meillo@0 151
meillo@10 152 gboolean do_verbose;
meillo@0 153
meillo@10 154 gchar *mbox_default;
meillo@10 155 GList *mbox_users;
meillo@10 156 GList *mda_users;
meillo@0 157
meillo@10 158 gchar *mda;
meillo@10 159 gboolean mda_fromline;
meillo@10 160 gboolean mda_fromhack;
meillo@0 161
meillo@10 162 gboolean pipe_fromline;
meillo@10 163 gboolean pipe_fromhack;
meillo@0 164
meillo@10 165 gchar *alias_file;
meillo@244 166 int (*localpartcmp) (const char *, const char *);
meillo@387 167 gchar *globalias_file;
meillo@0 168
meillo@354 169 GList *perma_routes;
meillo@354 170 GList *query_routes; /* list of pairs which point to lists */
meillo@0 171
meillo@310 172 gchar *online_query;
meillo@0 173
meillo@10 174 gchar *errmsg_file;
meillo@10 175 gchar *warnmsg_file;
meillo@10 176 GList *warn_intervals;
meillo@10 177 gint max_defer_time;
meillo@0 178
meillo@10 179 gchar *log_user;
meillo@0 180 } masqmail_conf;
meillo@0 181
meillo@0 182 extern masqmail_conf conf;
meillo@0 183
meillo@10 184 typedef struct _table_pair {
meillo@10 185 gchar *key;
meillo@10 186 gpointer *value;
meillo@0 187 } table_pair;
meillo@0 188
meillo@0 189
meillo@299 190 /* must match the contents of prot_names[] in accept.c */
meillo@10 191 typedef enum _prot_id {
meillo@10 192 PROT_LOCAL = 0,
meillo@10 193 PROT_SMTP,
meillo@10 194 PROT_ESMTP,
meillo@10 195 PROT_NUM
meillo@10 196 } prot_id;
meillo@0 197
meillo@0 198 extern gchar *prot_names[];
meillo@0 199
meillo@10 200 typedef enum _header_id {
meillo@10 201 HEAD_FROM = 0,
meillo@10 202 HEAD_SENDER,
meillo@10 203 HEAD_TO,
meillo@10 204 HEAD_CC,
meillo@10 205 HEAD_BCC,
meillo@10 206 HEAD_DATE,
meillo@10 207 HEAD_MESSAGE_ID,
meillo@10 208 HEAD_REPLY_TO,
meillo@10 209 HEAD_SUBJECT,
meillo@10 210 HEAD_RETURN_PATH,
meillo@10 211 HEAD_ENVELOPE_TO,
meillo@10 212 HEAD_RECEIVED,
meillo@10 213 HEAD_NUM_IDS,
meillo@10 214 HEAD_STATUS,
meillo@10 215 HEAD_UNKNOWN = HEAD_NUM_IDS,
meillo@10 216 HEAD_NONE = -1,
meillo@10 217 } header_id;
meillo@0 218
meillo@10 219 typedef struct _header_name {
meillo@10 220 gchar *header;
meillo@10 221 header_id id;
meillo@10 222 } header_name;
meillo@0 223
meillo@10 224 typedef struct _header {
meillo@10 225 header_id id;
meillo@10 226 gchar *header;
meillo@10 227 gchar *value;
meillo@10 228 } header;
meillo@0 229
meillo@0 230
meillo@10 231 typedef struct _message {
meillo@10 232 gchar *uid;
meillo@0 233
meillo@10 234 gchar *received_host;
meillo@10 235 prot_id received_prot;
meillo@10 236 gchar *ident;
meillo@10 237 gint transfer_id; /* for multiple messages per transfer */
meillo@0 238
meillo@10 239 address *return_path;
meillo@10 240 GList *rcpt_list;
meillo@10 241 GList *non_rcpt_list;
meillo@0 242
meillo@10 243 GList *hdr_list;
meillo@10 244 GList *data_list;
meillo@0 245
meillo@10 246 gint data_size;
meillo@10 247 time_t received_time;
meillo@10 248 time_t warned_time;
meillo@0 249
meillo@10 250 gchar *full_sender_name;
meillo@10 251 } message;
meillo@0 252
meillo@10 253 typedef struct _msg_out {
meillo@10 254 message *msg;
meillo@0 255
meillo@10 256 address *return_path;
meillo@10 257 GList *rcpt_list;
meillo@0 258
meillo@10 259 GList *hdr_list;
meillo@354 260 GList *xtra_hdr_list; /* rewritten headers */
meillo@10 261 } msg_out;
meillo@10 262
meillo@10 263 typedef struct _msgout_perhost {
meillo@10 264 gchar *host;
meillo@10 265 GList *msgout_list;
meillo@0 266 } msgout_perhost;
meillo@0 267
meillo@0 268 /* flags for accept() */
meillo@10 269 #define ACC_RCPT_FROM_HEAD 0x08 /* -t option, get rcpts from headers */
meillo@110 270 #define ACC_DOT_IGNORE 0x10 /* a dot on a line itself does not end the message (-oi option) */
meillo@10 271 #define ACC_MAIL_FROM_HEAD 0x40 /* get return path from header */
meillo@10 272 #define ACC_NODOT_RELAX 0x80 /* do not be picky if message ist not terminated by a dot on a line */
meillo@10 273 #define ACC_SAVE_ENVELOPE_TO 0x0100 /* save an existent Envelope-to header as X-Orig-Envelope-to */
meillo@0 274
meillo@0 275 #define DLVR_LOCAL 0x01
meillo@356 276 #define DLVR_ONLINE 0x02
meillo@356 277 #define DLVR_ALL (DLVR_LOCAL|DLVR_ONLINE)
meillo@0 278
meillo@0 279 /* transport flags */
meillo@0 280 #define MSGSTR_FROMLINE 0x01
meillo@0 281 #define MSGSTR_FROMHACK 0x02
meillo@0 282
meillo@10 283 typedef enum _accept_error {
meillo@10 284 AERR_OK = 0,
meillo@10 285 AERR_TIMEOUT,
meillo@10 286 AERR_EOF,
meillo@10 287 AERR_OVERFLOW,
meillo@10 288 AERR_SYNTAX,
meillo@10 289 AERR_NOSPOOL,
meillo@10 290 AERR_NORCPT,
meillo@117 291 AERR_SIZE, /* max msg size exeeded (SMTP SIZE) */
meillo@10 292 AERR_UNKNOWN
meillo@10 293 } accept_error;
meillo@0 294
meillo@0 295 #define BUF_LEN 1024
meillo@0 296 #define MAX_ADDRESS 256
meillo@0 297 #define MAX_DATALINE 4096
meillo@0 298
meillo@10 299 typedef enum _smtp_cmd_id {
meillo@10 300 SMTP_HELO = 0,
meillo@10 301 SMTP_EHLO,
meillo@10 302 SMTP_MAIL_FROM,
meillo@10 303 SMTP_RCPT_TO,
meillo@10 304 SMTP_DATA,
meillo@10 305 SMTP_QUIT,
meillo@10 306 SMTP_RSET,
meillo@10 307 SMTP_NOOP,
meillo@10 308 SMTP_HELP,
meillo@10 309 SMTP_NUM_IDS,
meillo@10 310 SMTP_EOF = -1,
meillo@10 311 SMTP_ERROR = -2,
meillo@0 312 } smtp_cmd_id;
meillo@0 313
meillo@10 314 typedef struct _smtp_cmd {
meillo@10 315 smtp_cmd_id id;
meillo@10 316 gchar *cmd;
meillo@0 317 } smtp_cmd;
meillo@0 318
meillo@10 319 typedef struct _smtp_connection {
meillo@10 320 gchar *remote_host;
meillo@0 321
meillo@10 322 prot_id prot;
meillo@10 323 gint next_id;
meillo@0 324
meillo@10 325 gboolean helo_seen;
meillo@10 326 gboolean from_seen;
meillo@10 327 gboolean rcpt_seen;
meillo@10 328
meillo@10 329 message *msg;
meillo@10 330 } smtp_connection;
meillo@0 331
meillo@0 332 /* alias.c*/
meillo@366 333 gboolean addr_is_local(address *addr);
meillo@387 334 GList *alias_expand(GList *alias_table, GList *rcpt_list, GList *non_rcpt_list,
meillo@387 335 int doglob);
meillo@0 336
meillo@0 337 /* child.c */
meillo@0 338 int child(const char *command);
meillo@0 339
meillo@0 340 /* conf.c */
meillo@0 341 void init_conf();
meillo@366 342 gboolean read_conf(gchar *filename);
meillo@366 343 connect_route *read_route(gchar *filename, gboolean is_perma);
meillo@366 344 GList *read_route_list(GList *rf_list, gboolean is_perma);
meillo@366 345 void destroy_route(connect_route *r);
meillo@366 346 void destroy_route_list(GList *list);
meillo@0 347
meillo@0 348 /* expand.c */
meillo@366 349 GList *var_table_rcpt(GList *var_table, address *rcpt);
meillo@366 350 GList *var_table_msg(GList *var_table, message *msg);
meillo@366 351 GList *var_table_conf(GList *var_table);
meillo@366 352 gint expand(GList *var_list, gchar *format, gchar *result, gint result_len);
meillo@0 353
meillo@0 354 /* message.c */
meillo@0 355 message *create_message(void);
meillo@366 356 void destroy_message(message *msg);
meillo@366 357 void destroy_msg_list(GList *msg_list);
meillo@366 358 void msg_free_data(message *msg);
meillo@366 359 gint msg_calc_size(message *msg, gboolean is_smtp);
meillo@0 360
meillo@366 361 msg_out *create_msg_out(message *msg);
meillo@366 362 msg_out *clone_msg_out(msg_out *msgout_orig);
meillo@366 363 void destroy_msg_out(msg_out *msgout);
meillo@366 364 void destroy_msg_out_list(GList *msgout_list);
meillo@0 365
meillo@0 366 /* address.c */
meillo@366 367 address *create_address(gchar *path, gboolean is_rfc821);
meillo@366 368 address *create_address_qualified(gchar *path, gboolean is_rfc821, gchar *domain);
meillo@366 369 address *create_address_pipe(gchar *path);
meillo@366 370 void destroy_address(address *addr);
meillo@366 371 address *copy_modify_address(const address *orig, gchar *l_part, gchar *dom);
meillo@0 372 #define copy_address(addr) copy_modify_address(addr, NULL, NULL)
meillo@366 373 gboolean addr_isequal(address *addr1, address *addr2, int (*cmpfunc) (const char*, const char*));
meillo@366 374 gboolean addr_isequal_parent(address *addr1, address *addr2, int (*cmpfunc) (const char*, const char*));
meillo@366 375 address *addr_find_ancestor(address *addr);
meillo@366 376 gboolean addr_is_delivered_children(address *addr);
meillo@366 377 gboolean addr_is_finished_children(address *addr);
meillo@366 378 gchar *addr_string(address *addr);
meillo@0 379
meillo@0 380 /* accept.c */
meillo@366 381 accept_error accept_message(FILE *in, message *msg, guint flags);
meillo@366 382 accept_error accept_message_prepare(message *msg, guint flags);
meillo@0 383
meillo@0 384 /* header.c */
meillo@0 385 gchar *rec_timestamp();
meillo@366 386 GList *find_header(GList *hdr_list, header_id id, gchar *hdr_str);
meillo@366 387 void header_unfold(header *hdr);
meillo@366 388 void header_fold(header *hdr, unsigned int maxlen);
meillo@366 389 header *create_header(header_id id, gchar *fmt, ...);
meillo@366 390 void destroy_header(header *hdr);
meillo@366 391 header *copy_header(header *hdr);
meillo@366 392 header *get_header(gchar *line);
meillo@0 393
meillo@0 394 /* smtp_in.c */
meillo@366 395 void smtp_in(FILE *in, FILE *out, gchar *remote_host, gchar *ident);
meillo@0 396
meillo@0 397 /* listen.c */
meillo@366 398 void listen_port(GList *addr_list, gint qival, char *argv[]);
meillo@0 399
meillo@0 400 /* parse.c */
meillo@366 401 gboolean split_address(const gchar *path, gchar **local_part, gchar **domain, gboolean is_rfc821);
meillo@366 402 gboolean parse_address_rfc822(gchar *string, gchar **local_begin, gchar **local_end, gchar **domain_begin, gchar **domain_end, gchar **address_end);
meillo@366 403 gboolean parse_address_rfc821(gchar *string, gchar **local_begin, gchar **local_end, gchar **domain_begin, gchar **domain_end, gchar **address_end);
meillo@366 404 address *_create_address(gchar *string, gchar **end, gboolean is_rfc821);
meillo@366 405 address *create_address_rfc821(gchar *string, gchar **end);
meillo@366 406 address *create_address_rfc822(gchar *string, gchar **end);
meillo@366 407 GList *addr_list_append_rfc822(GList *addr_list, gchar *string, gchar *domain);
meillo@0 408
meillo@0 409 /* connect.c */
meillo@366 410 mxip_addr *connect_hostlist(int *psockfd, gchar *host, guint port, GList *addr_list);
meillo@366 411 mxip_addr *connect_resolvelist(int *psockfd, gchar *host, guint port, GList *res_funcs);
meillo@0 412
meillo@0 413 /* deliver.c */
meillo@366 414 void msg_rcptlist_local(GList *rcpt_list, GList **, GList **);
meillo@366 415 gboolean deliver_local(msg_out *msgout);
meillo@366 416 gboolean deliver_msglist_host(connect_route *route, GList *msg_list, gchar *host, GList *res_list);
meillo@366 417 gboolean deliver_route_msgout_list(connect_route *route, GList *msgout_list);
meillo@366 418 gboolean deliver_route_msg_list(connect_route *route, GList *msgout_list);
meillo@366 419 gboolean deliver_finish(msg_out *msgout);
meillo@366 420 gboolean deliver_msg_list(GList *msg_list, guint flags);
meillo@366 421 gboolean deliver(message *msg);
meillo@0 422
meillo@0 423 /* fail_msg.c */
meillo@366 424 gboolean fail_msg(message *msg, gchar *template, GList *failed_rcpts, gchar *err_fmt, va_list args);
meillo@366 425 gboolean warn_msg(message *msg, gchar *template, GList *failed_rcpts, gchar *err_fmt, va_list args);
meillo@0 426
meillo@0 427 /* interface.c */
meillo@366 428 gboolean init_sockaddr(struct sockaddr_in *name, interface *iface);
meillo@366 429 int make_server_socket(interface *iface);
meillo@0 430
meillo@0 431 /* local.c */
meillo@366 432 gboolean append_file(message *msg, GList *hdr_list, gchar *user);
meillo@366 433 gboolean pipe_out(message *msg, GList *hdr_list, address *rcpt, gchar *cmd, guint flags);
meillo@0 434
meillo@0 435 /* log.c */
meillo@0 436 gchar *ext_strerror(int err);
meillo@0 437 gboolean logopen(void);
meillo@0 438 void logclose(void);
meillo@0 439 void vlogwrite(int pri, const char *fmt, va_list args);
meillo@0 440 void logwrite(int pri, const char *fmt, ...);
meillo@0 441 void debugf(const char *fmt, ...);
meillo@0 442 void vdebugf(const char *fmt, va_list args);
meillo@0 443 void maillog(const char *fmt, ...);
meillo@0 444
meillo@0 445 /* spool.c */
meillo@366 446 gboolean spool_read_data(message *msg);
meillo@366 447 message *msg_spool_read(gchar *uid);
meillo@366 448 gboolean spool_write(message *msg, gboolean do_writedata);
meillo@366 449 gboolean spool_lock(gchar *uid);
meillo@366 450 gboolean spool_unlock(gchar *uid);
meillo@366 451 gboolean spool_delete_all(message *msg);
meillo@0 452
meillo@0 453 /* queue.c */
meillo@348 454 GList *read_queue(void);
meillo@0 455 gboolean queue_run(void);
meillo@0 456 gboolean queue_run_online(void);
meillo@0 457 void queue_list(void);
meillo@366 458 gboolean queue_delete(gchar *uid);
meillo@0 459
meillo@0 460 /* online.c */
meillo@310 461 gchar *online_query();
meillo@0 462
meillo@0 463 /* permissions.c */
meillo@0 464 gboolean is_ingroup(uid_t uid, gid_t gid);
meillo@366 465 void set_euidgid(gint uid, gint gid, uid_t *old_uid, gid_t *old_gid);
meillo@366 466 void set_identity(uid_t old_uid, gchar *task_name);
meillo@0 467
meillo@0 468 /* rewrite.c */
meillo@366 469 gboolean set_address_header_domain(header *hdr, gchar *domain);
meillo@366 470 gboolean map_address_header(header *hdr, GList *table);
meillo@0 471
meillo@0 472 /* route.c */
meillo@366 473 msgout_perhost *create_msgout_perhost(gchar *host);
meillo@366 474 void destroy_msgout_perhost(msgout_perhost *mo_ph);
meillo@366 475 void rewrite_headers(msg_out *msgout, connect_route *route);
meillo@366 476 void split_rcpts(GList *rcpt_list, GList *localnets, GList **rl_local, GList **rl_localnet, GList **rl_others);
meillo@366 477 GList *local_rcpts(GList *rcpt_list);
meillo@366 478 GList *remote_rcpts(GList *rcpt_list);
meillo@366 479 gboolean route_strip_msgout(connect_route *route, msg_out *msgout);
meillo@366 480 msg_out *route_prepare_msgout(connect_route *route, msg_out *msgout);
meillo@366 481 GList *route_msgout_list(connect_route *route, GList *msgout_list);
meillo@366 482 gboolean route_sender_is_allowed(connect_route *route, address *ret_path);
meillo@366 483 void route_split_rcpts(connect_route *route, GList *rcpt_list, GList **p_rcpt_list, GList **p_non_rcpt_list);
meillo@0 484
meillo@0 485 /* tables.c */
meillo@366 486 table_pair *create_pair(gchar *key, gpointer value);
meillo@366 487 table_pair *create_pair_string(gchar *key, gpointer value);
meillo@366 488 table_pair *parse_table_pair(gchar *line, char delim);
meillo@366 489 gpointer *table_find_func(GList *table_list, gchar *key, int (*cmp_func) (const char *, const char *));
meillo@366 490 gpointer *table_find(GList *table_list, gchar *key);
meillo@366 491 gpointer *table_find_case(GList *table_list, gchar *key);
meillo@366 492 gpointer *table_find_fnmatch(GList *table_list, gchar *key);
meillo@366 493 GList *table_read(gchar *fname, gchar delim);
meillo@366 494 void destroy_table(GList *table);
meillo@0 495
meillo@0 496 /* timeival.c */
meillo@366 497 gint time_interval(gchar *str);
meillo@0 498
meillo@0 499 /* permissions.c */
meillo@0 500 gboolean is_privileged_user(uid_t uid);
meillo@0 501
meillo@0 502 /* other things */
meillo@0 503
meillo@0 504 #define foreach(list, node)\
meillo@0 505 for((node) = g_list_first(list);\
meillo@0 506 (node);\
meillo@0 507 (node) = g_list_next(node))
meillo@0 508
meillo@0 509 #ifdef ENABLE_DEBUG
meillo@0 510 #define DEBUG(level) if(level <= conf.debug_level)
meillo@0 511 #else
meillo@0 512 /* hopefully the compiler optmizes this away... */
meillo@0 513 #define DEBUG(level) if(0)
meillo@0 514 #endif
meillo@0 515
meillo@0 516 #define LOG_VERBOSE 0x100
meillo@0 517
meillo@0 518 #ifndef HAVE_GETLINE
meillo@0 519 #define getline(buf, size, file) getdelim(buf, size, '\n', file)
meillo@0 520 #endif
meillo@0 521
meillo@0 522 #ifndef HAVE_FDATASYNC
meillo@0 523 #define fdatasync(fd) fsync(fd)
meillo@0 524 #endif
meillo@0 525
meillo@0 526 #ifndef CONF_DIR
meillo@0 527 #define CONF_DIR "/etc/masqmail"
meillo@0 528 #endif
meillo@0 529
meillo@0 530 #define CONF_FILE CONF_DIR"/masqmail.conf"
meillo@0 531
meillo@0 532 #define PIDFILEDIR "/var/run/masqmail/"
meillo@0 533
meillo@0 534 #ifndef va_copy
meillo@0 535 #ifdef __va_copy
meillo@0 536 #define va_copy(ap1, ap2) __va_copy(ap1, ap2)
meillo@0 537 #else
meillo@0 538 #define va_copy(ap1, ap2) G_VA_COPY(ap1, ap2)
meillo@0 539 #endif
meillo@0 540 #endif
meillo@0 541
meillo@0 542 /* *BSD needs this: */
meillo@0 543 extern char **environ;