/* Copyright 2005 The Apache Software Foundation or its licensors, as
 * applicable.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#ifndef SMTP_H
#define SMTP_H

#include "apreq2/apreq_parser.h"

#include "mod_smtpd.h"

#ifdef __cplusplus
extern "C" {
#endif

/* SMTP handlers registration */
#define HANDLER_PROTOTYPE smtpd_session_rec *scr, char *buffer, \
smtpd_return_data *in_data, void *data

#define HANDLER_FUNC(name)  smtpd_handler_##name
#define HANDLER_DECLARE(name) SMTPD_DECLARE(int) HANDLER_FUNC(name) \
(HANDLER_PROTOTYPE)

    typedef SMTPD_DECLARE(int) smtpd_handler(HANDLER_PROTOTYPE);

    typedef struct {
        int bEnabled; /* Is SMTP Enabled? */
        const char *sId; /* Server ID String */
        apr_size_t max_data;
    } smtpd_svr_config_rec;

    typedef struct {
        int headers_parsed;
        smtpd_session_rec *scr;
        apreq_parser_t *rfc822_parser;
        apr_bucket_brigade *bb;
    } smtpd_header_filter_ctx;

    void smtpd_process_connection_internal(smtpd_session_rec *str);
    
    void smtpd_clear_envelope_rec(smtpd_session_rec *);

    void smtpd_bounce_unqueued(smtpd_session_rec *scr);

#ifdef __cplusplus
}
#endif

#endif
