/* libspawner, an implementation of the MTA side of Sendmail's Milter protocol. Copyright (C) 2005-07 Hilko Bengen This library is free software; you can redistribute it and/or modify it under the terms of version 2.1 of the GNU Lesser General Public License as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _SPAWNER_H #include #include /** \return Return codes */ #define SPAWNER_OK 0 /**< No error */ #define SPAWNER_ERROR -1 /**< Probably Indicates bug in libspawner */ #define SPAWNER_ERROR_ARG -2 /**< Invalid argument */ #define SPAWNER_ERROR_STATE -3 /**< Wrong state */ #define SPAWNER_ERROR_IO -4 /**< Problem with socket */ #define SPAWNER_ERROR_PROTO -5 /**< Milter send nonsenical message */ #define SPAWNER_CONTINUE 0 /**< Equivalent to 2xx SMTP response */ #define SPAWNER_ACCEPT 1 /**< Accept message */ #define SPAWNER_TEMPFAIL 2 /**< Equivalent to 4xx SMTP response */ #define SPAWNER_REJECT 3 /**< Equivalent to 5xx SMTP response */ #define SPAWNER_DISCARD 4 /**< Discard message */ /** \brief Actions that may be performed by the mail filter */ #define SMFIF_ADDHDRS 0x01 /**< Add header(s) */ #define SMFIF_CHGBODY 0x02 /**< Change body */ #define SMFIF_ADDRCPT 0x04 /**< Add recipient(s) */ #define SMFIF_DELRCPT 0x08 /**< Delete recipient(s) */ /* v2 and above */ #define SMFIF_CHGHDRS 0x10 /**< Change (or remove) header(s) */ #define SMFIF_QUARANTINE 0x20 /**< Quarantine message */ /** \brief Protocol steps that are to be skipped in communication between MTA and mail filter */ #define SMFIP_NOCONNECT 0x01 /**< spawner_new_connection'() */ #define SMFIP_NOHELO 0x02 /**< spawner_helo() can be skipped */ #define SMFIP_NOMAIL 0x04 /**< spawner_set_from() can be skipped */ #define SMFIP_NORCPT 0x08 /**< spawner_add_rcpt() can be skipped */ #define SMFIP_NOBODY 0x10 /**< spawner_send_body_chunk() and related functions can be skipped */ #define SMFIP_NOHDRS 0x20 /**< spawner_send_header() can be skipped */ #define SMFIP_NOEOH 0x40 /**< spawner_send_eoh() can be skipped */ /* Each connection to a mail filter is represented by an instance of the spawner structure */ typedef struct spawner spawner; spawner* spawner_init(); void spawner_destory(spawner*); void spawner_set_timeout(spawner*, unsigned int, unsigned int, unsigned int, unsigned int); void spawner_set_strict_state(spawner *sp, int strict); int spawner_get_strict_state(spawner *sp); int spawner_set_flags(spawner *sp, u_int32_t flags); u_int32_t spawner_get_flags(spawner *sp); void spawner_set_name(spawner *sp, char *name); char* spawner_get_name(spawner *sp); int spawner_set_spec(spawner *sp, char *spec); char* spawner_get_spec(spawner *sp); int spawner_callback_add_rcpt(spawner *sp, void (*add_rcpt)(spawner*, char*)); int spawner_callback_del_rcpt(spawner *sp, void (*del_rcpt)(spawner*, char*)); int spawner_callback_add_header(spawner *sp, void (*add_header)(spawner*, char*, char*)); int spawner_callback_change_header(spawner *sp, void (*func)(spawner*, int, char*, char*)); int spawner_callback_replace_body(spawner *sp, void (*func)(spawner*, int, char*)); int spawner_callback_quarantine(spawner *sp, void (*quarantine)(spawner*, char*)); void spawner_callback_debug(spawner *sp, void(*debug_print)(spawner*, int, char*)); u_int32_t spawner_get_actions(spawner *sp); int spawner_set_spec(spawner *sp, char *spec); int spawner_open(spawner *sp); int spawner_close(spawner *sp); int spawner_send_macros(spawner *sp, char state, char **nameval); int spawner_new_connection(spawner *sp, char hostname[], int family, u_int16_t port, char address[]); int spawner_helo(spawner *sp, char *helostr); int spawner_set_from(spawner *sp, char *sender, char *extra); int spawner_add_rcpt(spawner *sp, char *rcpt, char *extra); int spawner_send_header(spawner *sp, char *name, char *body); int spawner_send_eoh(spawner *sp); int spawner_send_body_chunk(spawner *sp, int size, char *buf); int spawner_send_eom(spawner *sp); int spawner_send_body_fd(spawner *sp, int fd); int spawner_send_body_fh(spawner *sp, FILE *fh); int spawner_reset(spawner *sp); #define _SPAWNER_H #endif /* Local Variables: c-file-style: "bsd" c-basic-offset: 8 indent-tabs-mode: nil End: */