MilterClientContext: milter managerリファレンスマニュアル

## MilterClientContext MilterClientContext — milterプロトコルを処理します。 |

## Functions

GQuark | milter_client_context_error_quark ()
#define | MILTER_CLIENT_CONTEXT_STATE_IN_MESSAGE_PROCESSING()
MilterClientContext * | milter_client_context_new ()
gboolean | milter_client_context_feed ()
gpointer | milter_client_context_get_private_data ()
void | milter_client_context_set_private_data ()
gboolean | milter_client_context_set_reply ()
gchar * | milter_client_context_format_reply ()
gboolean | milter_client_context_add_header ()
gboolean | milter_client_context_insert_header ()
gboolean | milter_client_context_change_header ()
gboolean | milter_client_context_delete_header ()
gboolean | milter_client_context_change_from ()
gboolean | milter_client_context_add_recipient ()
gboolean | milter_client_context_delete_recipient ()
gboolean | milter_client_context_replace_body ()
gboolean | milter_client_context_replace_body_bytes ()
gboolean | milter_client_context_progress ()
gboolean | milter_client_context_quarantine ()
void | milter_client_context_set_timeout ()
guint | milter_client_context_get_timeout ()
void | milter_client_context_set_state ()
MilterClientContextState | milter_client_context_get_state ()
void | milter_client_context_set_quarantine_reason ()
const gchar * | milter_client_context_get_quarantine_reason ()
MilterClientContextState | milter_client_context_get_last_state ()
void | milter_client_context_set_status ()
MilterStatus | milter_client_context_get_status ()
void | milter_client_context_set_option ()
MilterOption * | milter_client_context_get_option ()
void | milter_client_context_set_socket_address ()
MilterGenericSocketAddress * | milter_client_context_get_socket_address ()
MilterMessageResult * | milter_client_context_get_message_result ()
void | milter_client_context_set_message_result ()
void | milter_client_context_reset_message_related_data ()
guint | milter_client_context_get_n_processing_sessions ()
void | milter_client_context_set_packet_buffer_size ()
guint | milter_client_context_get_packet_buffer_size ()
void | milter_client_context_set_use_bytes ()
gboolean | milter_client_context_get_use_bytes ()
void | milter_client_context_set_mail_transaction_shelf_value ()
const gchar * | milter_client_context_get_mail_transaction_shelf_value ()
GHashTable * | milter_client_context_get_mail_transaction_shelf ()
void | milter_client_context_clear_mail_transaction_shelf ()
void | (*MilterClientMailTransactionShelfFunc) ()
void | milter_client_context_mail_transaction_shelf_foreach ()

## プロパティ

MilterClient * | client | Read / Write / Construct Only
MilterMessageResult * | message-result | Read / Write
MilterOption * | option | Read / Write
guint | packet-buffer-size | Read / Write
char * | quarantine-reason | Read / Write
MilterClientContextState | state | Read / Write
MilterStatus | status | Read / Write
gboolean | use-bytes | Read / Write

## シグナル

MilterStatus | abort | Run Last
void | abort-response | Run Last
MilterStatus | body | Run Last
MilterStatus | body-bytes | Run Last
void | body-response | Run Last
MilterStatus | connect | Run Last
void | connect-response | Run Last
MilterStatus | data | Run Last
void | data-response | Run Last
void | define-macro | Run Last
MilterStatus | end-of-header | Run Last
void | end-of-header-response | Run Last
MilterStatus | end-of-message | Run Last
MilterStatus | end-of-message-bytes | Run Last
void | end-of-message-response | Run Last
MilterStatus | envelope-from | Run Last
void | envelope-from-response | Run Last
MilterStatus | envelope-recipient | Run Last
void | envelope-recipient-response | Run Last
MilterStatus | header | Run Last
void | header-response | Run Last
MilterStatus | helo | Run Last
void | helo-response | Run Last
void | message-processed | Run Last
MilterStatus | negotiate | Run Last
void | negotiate-response | Run Last
void | timeout | Run Last
MilterStatus | unknown | Run Last
void | unknown-response | Run Last

## Types and Values

#define | MILTER_CLIENT_CONTEXT_ERROR
enum | MilterClientContextError
enum | MilterClientContextState
#define | MILTER_TYPE_CLIENT_CONTEXT
struct | MilterClientContextClass
| MilterClientContext

## オブジェクト階層

    GObject
        ╰── MilterAgent
            ╰── MilterProtocolAgent
                ╰── MilterClientContext

## 実装されたインターフェイス

MilterClientContext implements

## 説明

`MilterClientContext`は1つのmilterプロトコルセッションを処理します。これは`MilterClientContext`インスタンスは各milterプロトコルセッション毎に生成されるということです。

各milterプロトコルコマンドを処理するために、`MilterClientContext`のシグナルに接続します。`MilterClientContext`にはmilterプロトコルのイベントに対応したシグナルがあります。

xxfi_negotiate | “negotiate”
xxfi_connect | “connect”
xxfi_helo | “helo”
xxfi_envfrom | “envelope-from”
xxfi_envrcpt | “envelope-recipient”
xxfi_data | “data”
xxfi_unknown | “unknown”
xxfi_header | “header”
xxfi_eoh | “end-of-header”
xxfi_body | “body”
xxfi_eom | “end-of-message”
xxfi_abort | “abort”

NOTE: You will need to check whether the current state is message processing or not. You can use `MILTER_CLIENT_CONTEXT_STATE_IN_MESSAGE_PROCESSING` for it.

xxfi_close | “finished”

以下はシグナルに接続する例です。すべてのシグナルに接続して、各シグナルハンドラはイベント名を表示します。

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    static MilterStatus
    cb_negotiate (MilterClientContext *context, MilterOption *option,
                  gpointer user_data)
    {
        g_print("negotiate\n");
        return MILTER_STATUS_ALL_OPTIONS;
    }

    static MilterStatus
    cb_connect (MilterClientContext *context, const gchar *host_name,
                const struct sockaddr *address, socklen_t address_length,
                gpointer user_data)
    {
        g_print("connect\n");
        return MILTER_STATUS_CONTINUE;
    }

    static MilterStatus
    cb_helo (MilterClientContext *context, const gchar *fqdn, gpointer user_data)
    {
        g_print("helo\n");
        return MILTER_STATUS_CONTINUE;
    }

    static MilterStatus
    cb_envelope_from (MilterClientContext *context, const gchar *from,
                      gpointer user_data)
    {
        g_print("envelope-from\n");
        return MILTER_STATUS_CONTINUE;
    }

    static MilterStatus
    cb_envelope_recipient (MilterClientContext *context, const gchar *to,
                           gpointer user_data)
    {
        g_print("envelope-recipient\n");
        return MILTER_STATUS_CONTINUE;
    }

    static MilterStatus
    cb_data (MilterClientContext *context, gpointer user_data)
    {
        g_print("data\n");
        return MILTER_STATUS_CONTINUE;
    }

    static MilterStatus
    cb_header (MilterClientContext *context, const gchar *name, const gchar *value,
               gpointer user_data)
    {
        g_print("header\n");
        return MILTER_STATUS_CONTINUE;
    }

    static MilterStatus
    cb_end_of_header (MilterClientContext *context, gpointer user_data)
    {
        g_print("end-of-header\n");
        return MILTER_STATUS_CONTINUE;
    }

    static MilterStatus
    cb_body (MilterClientContext *context, const gchar *chunk, gsize length,
             gpointer user_data)
    {
        g_print("body\n");
        return MILTER_STATUS_CONTINUE;
    }

    static MilterStatus
    cb_end_of_message (MilterClientContext *context,
                       const gchar *chunk, gsize length,
                       gpointer user_data)
    {
        g_print("end-of-message\n");
        return MILTER_STATUS_CONTINUE;
    }

    static MilterStatus
    cb_abort (MilterClientContext *context, MilterClientContextState state,
              gpointer user_data)
    {
        g_print("abort\n");
        return MILTER_STATUS_CONTINUE;
    }

    static MilterStatus
    cb_unknown (MilterClientContext *context, const gchar *command,
                gpointer user_data)
    {
        g_print("unknown\n");
        return MILTER_STATUS_CONTINUE;
    }

    static void
    setup_context_signals (MilterClientContext *context)
    {
    #define CONNECT(name)                                                   \
        g_signal_connect(context, #name, G_CALLBACK(cb_ ## name), NULL)

        CONNECT(negotiate);
        CONNECT(connect);
        CONNECT(helo);
        CONNECT(envelope_from);
        CONNECT(envelope_recipient);
        CONNECT(data);
        CONNECT(header);
        CONNECT(end_of_header);
        CONNECT(body);
        CONNECT(end_of_message);
        CONNECT(abort);
        CONNECT(unknown);

    #undef CONNECT
    }

## Functions

### milter_client_context_error_quark ()

    GQuark
    milter_client_context_error_quark (void);

### MILTER_CLIENT_CONTEXT_STATE_IN_MESSAGE_PROCESSING()

    #define             MILTER_CLIENT_CONTEXT_STATE_IN_MESSAGE_PROCESSING(state)

### milter_client_context_new ()

    MilterClientContext *
    milter_client_context_new (MilterClient *client);

Creates a new context object. Normally, context object is created by `MilterClient` and passed by “connection-established” signal.

#### Parameters

client | context用の`MilterClient`オブジェクト。 | [nullable]

#### Returns

新しい`MilterClientContext`オブジェクト。

### milter_client_context_feed ()

    gboolean
    milter_client_context_feed (MilterClientContext *context,
                                const gchar *chunk,
                                gsize size,
                                GError **error);

Feeds a chunk to the `context` . You can use it for testing or debugging.

#### Parameters

context | A MilterClientContext. |
chunk | The string to be fed to `context` . | [array length=size][element-type guint8]
size | The size of `chunk` in bytes. |
error | Return location for an error, or `NULL`. | [nullable]

#### Returns

`TRUE` on success, `FALSE` otherwise.

### milter_client_context_get_private_data ()

    gpointer
    milter_client_context_get_private_data
                                   (MilterClientContext *context);

Gets the private data of the `context` .

#### Parameters

context | `MilterClientContext`。 |

#### Returns

`milter_client_context_set_private_data()`で設定したプライベートなデータ、あるいは`NULL`。

### milter_client_context_set_private_data ()

    void
    milter_client_context_set_private_data
                                   (MilterClientContext *context,
                                    gpointer data,
                                    GDestroyNotify destroy);

Sets the private data of the `context` . `data` is destroyed by `destroy` when `data` is unset. `data` is unset when new private data is set or `context` is destroyed.

#### Parameters

context | `MilterClientContext`。 |
data | プライベートなデータ。 |
destroy | `data`の破棄関数、あるいは`NULL`。 |

### milter_client_context_set_reply ()

    gboolean
    milter_client_context_set_reply (MilterClientContext *context,
                                     guint code,
                                     const gchar *extended_code,
                                     const gchar *message,
                                     GError **error);

エラー応答コードを設定します。`MILTER_REPLY_TEMPORARY_FAILURE`のときは4xx `code`を使います。`MILTER_REPLY_REJECT`のときは5xx `code`を使います。

milter.orgの smfi_setreplyも見てください。

#### Parameters

context | `MilterClientContext`。 |
code | 3桁のSMTPエラー応答コード。（RFC 2821）4xxと5xxだけが使えます。 |
extended_code | 拡張応答コード（RFC 1893/2034）、あるいは`NULL`。 |
message | SMTP応答のテキスト部分または`NULL`。 |
error | エラーを受け取る場所のアドレス、または`NULL`。 |

#### Returns

成功時は`TRUE`。

### milter_client_context_format_reply ()

    gchar *
    milter_client_context_format_reply (MilterClientContext *context);

`milter_client_context_set_reply()`で指定された現在のエラー応答コードを整形します。エラー応答コードが設定されていない場合は、`NULL`を返します。

#### Parameters

context | `MilterClientContext`。 |

#### Returns

整形された応答コード、あるいは`NULL`。

### milter_client_context_add_header ()

    gboolean
    milter_client_context_add_header (MilterClientContext *context,
                                      const gchar *name,
                                      const gchar *value,
                                      GError **error);

Adds a header to the current message's header list. This function can be called in “end-of-message” signal.

milter.orgの smfi_addheaderも見てください。

FIXME: `MILTER_ACTION_ADD_HEADERS`について書くこと。

#### Parameters

context | `MilterClientContext`。 |
name | ヘッダ名。 |
value | ヘッダ値。 |
error | エラーを受け取る場所のアドレス、または`NULL`。 |

#### Returns

成功時は`TRUE`。

### milter_client_context_insert_header ()

    gboolean
    milter_client_context_insert_header (MilterClientContext *context,
                                         guint32 index,
                                         const gchar *name,
                                         const gchar *value,
                                         GError **error);

Inserts a header into the current message's header lists at `index` . This function can be called in “end-of-message” signal. See also smfi_insheader on milter.org.

FIXME: MILTER_ACTION_ADD_HEADERSについて書くこと。

#### Parameters

context | `MilterClientContext`。 |
index | 挿入する位置。 |
name | ヘッダ名。 |
value | ヘッダ値。 |
error | エラーを受け取る場所のアドレス、または`NULL`。 |

#### Returns

成功時は`TRUE`。

### milter_client_context_change_header ()

    gboolean
    milter_client_context_change_header (MilterClientContext *context,
                                         const gchar *name,
                                         guint32 index,
                                         const gchar *value,
                                         GError **error);

Changes a header that is located at `index` in headers that all of them are named `name` . If `value` is `NULL`, the header is deleted. This function can be called in “end-of-message” signal.

milter.orgの smfi_chgheaderも見てください。

FIXME: MILTER_ACTION_CHANGE_HEADERSについて書くこと。

#### Parameters

context | `MilterClientContext`。 |
name | ヘッダ名。 |
index | the index of headers that all of them are named |
name. (1-based) FIXME | should change 0-based? |
value | ヘッダ値。ターゲットのヘッダを削除する場合は`NULL`を指定してください。 |
error | エラーを受け取る場所のアドレス、または`NULL`。 |

#### Returns

成功時は`TRUE`。

### milter_client_context_delete_header ()

    gboolean
    milter_client_context_delete_header (MilterClientContext *context,
                                         const gchar *name,
                                         guint32 index,
                                         GError **error);

Deletes a header that is located at `index` in headers that all of them are named `name` . This function can be called in “end-of-message” signal. This function works same as `milter_client_context_change_header()` with `NULL` as `value` .

FIXME: MILTER_ACTION_CHANGE_HEADERSについて書くこと。

#### Parameters

context | `MilterClientContext`。 |
name | ヘッダ名。 |
index | the index of headers that all of them are named |
name. (1-based) FIXME | should change 0-based? |
error | エラーを受け取る場所のアドレス、または`NULL`。 |

#### Returns

成功時は`TRUE`。

### milter_client_context_change_from ()

    gboolean
    milter_client_context_change_from (MilterClientContext *context,
                                       const gchar *from,
                                       const gchar *parameters,
                                       GError **error);

Changes the envelope from address of the current message. ESMTP's 'MAIL FROM' parameter can be set by `parameters` . `parameters` may be `NULL`. This function can be called in “end-of-message” signal. See also smfi_chgfrom on milter.org.

FIXME: MILTER_ACTION_CHANGE_FROMについて書くこと。

#### Parameters

context | A MilterClientContext. |
from | The new envelope from address. |
parameters | The ESMTP's 'MAIL FROM' parameter. | [nullable]
error | Return location for an error, or `NULL`. | [nullable]

#### Returns

`TRUE` on success, `FALSE` otherwise.

### milter_client_context_add_recipient ()

    gboolean
    milter_client_context_add_recipient (MilterClientContext *context,
                                         const gchar *recipient,
                                         const gchar *parameters,
                                         GError **error);

Adds a new envelope recipient address to the current message. ESMTP's 'RCPT TO' parameter can be set by `parameters` . `parameters` may be `NULL`. This function can be called in “end-of-message” signal. See also smfi_addrcpt and smfi_addrcpt_par on milter.org.

FIXME: MILTER_ACTION_ADD_RECIPIENTとMILTER_ACTION_ADD_ENVELOPE_RECIPIENT_WITH_PARAMETERSについて書くこと。

#### Parameters

context | A MilterClientContext. |
recipient | The new envelope recipient address. |
parameters | The ESMTP's 'RCPT TO' parameter. | [nullable]
error | Return location for an error, or `NULL`. | [nullable]

#### Returns

成功時は`TRUE`。

### milter_client_context_delete_recipient ()

    gboolean
    milter_client_context_delete_recipient
                                   (MilterClientContext *context,
                                    const gchar *recipient,
                                    GError **error);

Removes a envelope recipient that named `recipient` . This function can be called in “end-of-message” signal. See also smfi_delrcpt on milter.org.

FIXME: MILTER_ACTION_DELETE_RECIPIENTについて書くこと。

#### Parameters

context | `MilterClientContext`。 |
recipient | 削除する宛先アドレス。 |
error | エラーを受け取る場所のアドレス、または`NULL`。 |

#### Returns

成功時は`TRUE`。

### milter_client_context_replace_body ()

    gboolean
    milter_client_context_replace_body (MilterClientContext *context,
                                        const gchar *body,
                                        gsize body_size,
                                        GError **error);

This is a `const gchar *` version of `milter_client_context_replace_body_bytes()`.

[skip]

#### Parameters

context | A MilterClientContext. |
body | 新しい本文。 | [array length=body_size][element-type guint8]
body_size | The size of `body` . |
error | Return location for an error, or `NULL`. |

#### Returns

成功時は`TRUE`。

### milter_client_context_replace_body_bytes ()

    gboolean
    milter_client_context_replace_body_bytes
                                   (MilterClientContext *context,
                                    GBytes *body,
                                    GError **error);

Replaces the body of the current message with `body` . This function can be called in “end-of-message” signal. See also smfi_replacebody on milter.org.

FIXME: MILTER_ACTION_CHANGE_BODYについて書くこと。

[rename-to milter_client_context_replace_body]

#### Parameters

context | A MilterClientContext. |
body | The new body. |
error | Return location for an error, or `NULL`. |

#### Returns

成功時は`TRUE`。

Since: 2.1.6

### milter_client_context_progress ()

    gboolean
    milter_client_context_progress (MilterClientContext *context);

Notifies the MTA that this milter is still in progress. This function can be called in “end-of-message” signal. See also smfi_progress on milter.org.

#### Parameters

context | `MilterClientContext`。 |

#### Returns

成功時は`TRUE`。

### milter_client_context_quarantine ()

    gboolean
    milter_client_context_quarantine (MilterClientContext *context,
                                      const gchar *reason);

Quarantines the current message with `reason` . This function can be called in “end-of-message” signal. See also smfi_quarantine on milter.org.

FIXME: MILTER_ACTION_QUARANTINEについて書くこと。

#### Parameters

context | `MilterClientContext`。 |
reason | どうして現在のメッセージが隔離されるかの理由。 |

#### Returns

成功時は`TRUE`。

### milter_client_context_set_timeout ()

    void
    milter_client_context_set_timeout (MilterClientContext *context,
                                       guint timeout);

Sets the timeout by seconds. If MTA doesn't responses in `timeout` seconds, “timeout” signal is emitted. See also smfi_settimeout on milter.org.

#### Parameters

context | `MilterClientContext`。 |
timeout | 秒単位のタイムアウト。（既定値は7210秒） |

### milter_client_context_get_timeout ()

    guint
    milter_client_context_get_timeout (MilterClientContext *context);

秒単位でタイムアウトを取得します。

#### Parameters

context | `MilterClientContext`。 |

#### Returns

秒単位でのタイムアウト。

### milter_client_context_set_state ()

    void
    milter_client_context_set_state (MilterClientContext *context,
                                     MilterClientContextState state);

現在の状態を設定します。

This is for testing. Don't use it directory for normal use.

#### Parameters

context | `MilterClientContext`。 |
state | `MilterClientContextState`。 |

### milter_client_context_get_state ()

    MilterClientContextState
    milter_client_context_get_state (MilterClientContext *context);

現在の状態を取得します。

This is for testing. Don't use it directory for normal use.

#### Parameters

context | `MilterClientContext`。 |

#### Returns

現在の状態。

### milter_client_context_set_quarantine_reason ()

    void
    milter_client_context_set_quarantine_reason
                                   (MilterClientContext *context,
                                    const gchar *reason);

Sets the quarantine reason.

This is for testing. Don't use it directory for normal use.

#### Parameters

context | `MilterClientContext`。 |
reason | a quarantine reason. |

### milter_client_context_get_quarantine_reason ()

    const gchar *
    milter_client_context_get_quarantine_reason
                                   (MilterClientContext *context);

Gets the quarantine reason.

This is for testing. Don't use it directory for normal use.

#### Parameters

context | `MilterClientContext`。 |

#### Returns

隔離理由。

### milter_client_context_get_last_state ()

    MilterClientContextState
    milter_client_context_get_last_state (MilterClientContext *context);

Gets the last state. It's one of start, negotiate, connect, helo, envelope-from, envelope-recipient, data, unknown, header, end-of-header, body and end-of-message.

#### Parameters

context | `MilterClientContext`。 |

#### Returns

the last state.

### milter_client_context_set_status ()

    void
    milter_client_context_set_status (MilterClientContext *context,
                                      MilterStatus status);

Sets the current status.

#### Parameters

context | `MilterClientContext`。 |
status | a `MilterStatus`. |

### milter_client_context_get_status ()

    MilterStatus
    milter_client_context_get_status (MilterClientContext *context);

現在の状態を取得します。

#### Parameters

context | `MilterClientContext`。 |

#### Returns

現在の状態。

### milter_client_context_set_option ()

    void
    milter_client_context_set_option (MilterClientContext *context,
                                      MilterOption *option);

現在のコンテキストのオプションを取得します。

#### Parameters

context | `MilterClientContext`。 |
option | `MilterOption`。 |

### milter_client_context_get_option ()

    MilterOption *
    milter_client_context_get_option (MilterClientContext *context);

Gets the option for the context.

#### Parameters

context | `MilterClientContext`。 |

#### Returns

the option for the context.

[transfer none]

### milter_client_context_set_socket_address ()

    void
    milter_client_context_set_socket_address
                                   (MilterClientContext *context,
                                    MilterGenericSocketAddress *address);

Sets the socket address of connected server for the context.

#### Parameters

context | `MilterClientContext`。 |
address | a `MilterGenericSocketAddress`. |

### milter_client_context_get_socket_address ()

    MilterGenericSocketAddress *
    milter_client_context_get_socket_address
                                   (MilterClientContext *context);

コンテキストに接続しているサーバのソケットアドレスを取得します。

#### Parameters

context | `MilterClientContext`。 |

#### Returns

コンテキストに接続しているサーバのソケットアドレス。

### milter_client_context_get_message_result ()

    MilterMessageResult *
    milter_client_context_get_message_result
                                   (MilterClientContext *context);

Gets the message result of `context` .

#### Parameters

context | `MilterClientContext`。 |

#### Returns

the message result of `context` .

[transfer none]

### milter_client_context_set_message_result ()

    void
    milter_client_context_set_message_result
                                   (MilterClientContext *context,
                                    MilterMessageResult *result);

Sets the message result of `context` .

#### Parameters

context | `MilterClientContext`。 |
result | the message result. |

### milter_client_context_reset_message_related_data ()

    void
    milter_client_context_reset_message_related_data
                                   (MilterClientContext *context);

Resets message related data of `context` .

Normally, you don't need to call this function.

#### Parameters

context | `MilterClientContext`。 |

### milter_client_context_get_n_processing_sessions ()

    guint
    milter_client_context_get_n_processing_sessions
                                   (MilterClientContext *context);

Returns number of the current processing sessions.

#### Parameters

context | `MilterClientContext`。 |

#### Returns

number of the current processing sessions.

### milter_client_context_set_packet_buffer_size ()

    void
    milter_client_context_set_packet_buffer_size
                                   (MilterClientContext *context,
                                    guint size);

Sets the packet buffer size for the context. Packets on end-of-message are buffered until the buffer size is full. Packet buffering is for performance.

#### Parameters

context | `MilterClientContext`。 |
size | a packet buffer size in bytes. (The deafult is 0 bytes. It means buffering is disabled.) |

### milter_client_context_get_packet_buffer_size ()

    guint
    milter_client_context_get_packet_buffer_size
                                   (MilterClientContext *context);

Gets the packet buffer size for the context.

#### Parameters

context | `MilterClientContext`。 |

#### Returns

the packet buffer size for the context.

### milter_client_context_set_use_bytes ()

    void
    milter_client_context_set_use_bytes (MilterClientContext *context,
                                         gboolean use);

#### Parameters

context | A MilterClientContext. |
use | Whether “body-bytes” and “end-of-message-bytes” are used instead of “body” and “end-of-message”. |

Since: 2.1.6

### milter_client_context_get_use_bytes ()

    gboolean
    milter_client_context_get_use_bytes (MilterClientContext *context);

#### Parameters

context | A MilterClientContext. |

#### Returns

Whether “body-bytes” and “end-of-message-bytes” are used instead of “body” and “end-of-message”.

Since: 2.1.6

### milter_client_context_set_mail_transaction_shelf_value ()

    void
    milter_client_context_set_mail_transaction_shelf_value
                                   (MilterClientContext *context,
                                    const gchar *key,
                                    const gchar *value);

Sets the string for the mail_transaction_shelf.

#### Parameters

context | `MilterClientContext`。 |
key | a string |
value | a string |

### milter_client_context_get_mail_transaction_shelf_value ()

    const gchar *
    milter_client_context_get_mail_transaction_shelf_value
                                   (MilterClientContext *context,
                                    const gchar *key);

Gets the string for the mail_transaction_shelf.

#### Parameters

context | `MilterClientContext`。 |
key | a key |

#### Returns

the string for the mail_transaction_shelf.

### milter_client_context_get_mail_transaction_shelf ()

    GHashTable *
    milter_client_context_get_mail_transaction_shelf
                                   (MilterClientContext *context);

Gets the mail_transaction_shelf. This is a mail-transaction scope storage.

#### Parameters

context | `MilterClientContext`。 |

#### Returns

the GHashTable for the context.

[transfer none][element-type utf8 utf8]

### milter_client_context_clear_mail_transaction_shelf ()

    void
    milter_client_context_clear_mail_transaction_shelf
                                   (MilterClientContext *context);

Remove all keys and values from mail_transaction_shelf.

#### Parameters

context | `MilterClientContext`。 |

### MilterClientMailTransactionShelfFunc ()

    void
    (*MilterClientMailTransactionShelfFunc)
                                   (const gchar *key,
                                    const gchar *value,
                                    gpointer user_data);

It is called with each metadata associated with a mail transaction, together with the `user_data` parameter which is passed to `milter_client_context_mail_transaction_shelf_foreach()`.

#### Parameters

key | A key. |
value | A value. |
user_data | User data passed to `milter_client_context_mail_transaction_shelf_foreach()`. |

### milter_client_context_mail_transaction_shelf_foreach ()

    void
    milter_client_context_mail_transaction_shelf_foreach
                                   (MilterClientContext *context,
                                    MilterClientMailTransactionShelfFunc func,
                                    gpointer user_data);

A wrapper for `g_hash_table_foreach()`.

#### Parameters

context | a MilterClientContext. |
func | the function to call for each key/value pair. | [scope call]
user_data | user data to pass to the function |

## Types and Values

### MILTER_CLIENT_CONTEXT_ERROR

    #define MILTER_CLIENT_CONTEXT_ERROR           (milter_client_context_error_quark())

MilterClientContextのエラー用のGErrorクォークを取得するために使われます。

### enum MilterClientContextError

`MilterClientContext`の関数呼び出し中に発生するエラーを識別します。

#### Members

MILTER_CLIENT_CONTEXT_ERROR_INVALID_CODE | `milter_client_context_set_reply()`で指定されたステータスコードが不正であることを示します。 |
MILTER_CLIENT_CONTEXT_ERROR_IO_ERROR | milterプロトコルデータの読み書き時に発生した入出力エラーを示します。 |
MILTER_CLIENT_CONTEXT_ERROR_NULL | 予期しない場所で`NULL`が渡されたことを示します。 |
MILTER_CLIENT_CONTEXT_ERROR_INVALID_STATE | 現在の`MilterClientContextState`で予期しない操作が要求されたことを示します。 |
MILTER_CLIENT_CONTEXT_ERROR_INVALID_ACTION | コンテキストの`MilterActionFlags`で予期しない操作が要求されたことを示します。 |
MILTER_CLIENT_CONTEXT_ERROR_EMPTY | Indicates unexpected empty value is passed. |

### enum MilterClientContextState

`MilterClientContext`の状態を識別します。

#### Members

MILTER_CLIENT_CONTEXT_STATE_INVALID | 不正な状態。 |
MILTER_CLIENT_CONTEXT_STATE_START | はじまったばかり。 |
MILTER_CLIENT_CONTEXT_STATE_NEGOTIATE | ネゴシエーションを開始。 |
MILTER_CLIENT_CONTEXT_STATE_NEGOTIATE_REPLIED | ネゴシエーション応答を受信した |
MILTER_CLIENT_CONTEXT_STATE_CONNECT | 接続情報を送信しました。 |
MILTER_CLIENT_CONTEXT_STATE_CONNECT_REPLIED | 接続情報への応答を受信した。 |
MILTER_CLIENT_CONTEXT_STATE_HELO | HELOコマンドの開始。 |
MILTER_CLIENT_CONTEXT_STATE_HELO_REPLIED | HELOコマンドへの応答を受信した。 |
MILTER_CLIENT_CONTEXT_STATE_ENVELOPE_FROM | MAIL FROMコマンド開始。 |
MILTER_CLIENT_CONTEXT_STATE_ENVELOPE_FROM_REPLIED | MAIL FROMコマンドへの応答を受信した。 |
MILTER_CLIENT_CONTEXT_STATE_ENVELOPE_RECIPIENT | RCPT TOコマンドの開始。 |
MILTER_CLIENT_CONTEXT_STATE_ENVELOPE_RECIPIENT_REPLIED | RCPT TOコマンドへの応答を受信した。 |
MILTER_CLIENT_CONTEXT_STATE_DATA | DATAコマンドの開始。 |
MILTER_CLIENT_CONTEXT_STATE_DATA_REPLIED | DATAコマンドへの応答を受信した。 |
MILTER_CLIENT_CONTEXT_STATE_UNKNOWN | 未知のSMTPコマンドの受信。 |
MILTER_CLIENT_CONTEXT_STATE_UNKNOWN_REPLIED | 未知のSMTPコマンドへの応答を受信した。 |
MILTER_CLIENT_CONTEXT_STATE_HEADER | ヘッダを送信した。 |
MILTER_CLIENT_CONTEXT_STATE_HEADER_REPLIED | ヘッダへの応答を受信した。 |
MILTER_CLIENT_CONTEXT_STATE_END_OF_HEADER | すべてのヘッダを送信した。 |
MILTER_CLIENT_CONTEXT_STATE_END_OF_HEADER_REPLIED | ヘッダ終了への応答を受信した。 |
MILTER_CLIENT_CONTEXT_STATE_BODY | 本体のかたまりの送信。 |
MILTER_CLIENT_CONTEXT_STATE_BODY_REPLIED | 本体への応答を受信した。 |
MILTER_CLIENT_CONTEXT_STATE_END_OF_MESSAGE | すべての本文を送信した。 |
MILTER_CLIENT_CONTEXT_STATE_END_OF_MESSAGE_REPLIED | メッセージ終了への応答を受信した。 |
MILTER_CLIENT_CONTEXT_STATE_QUIT | 正常終了の開始。 |
MILTER_CLIENT_CONTEXT_STATE_QUIT_REPLIED | 正常終了への応答を受信した。 |
MILTER_CLIENT_CONTEXT_STATE_ABORT | 異常終了の開始。 |
MILTER_CLIENT_CONTEXT_STATE_ABORT_REPLIED | 異常終了への応答を受信した。 |
MILTER_CLIENT_CONTEXT_STATE_FINISHED | 終了した。 |

### MILTER_TYPE_CLIENT_CONTEXT

    #define MILTER_TYPE_CLIENT_CONTEXT            (milter_client_context_get_type())

### struct MilterClientContextClass

    struct MilterClientContextClass {
        MilterProtocolAgentClass parent_class;

        MilterStatus (*negotiate)          (MilterClientContext *context,
                                            MilterOption  *option,
                                            MilterMacrosRequests *macros_requests);
        void         (*negotiate_response) (MilterClientContext *context,
                                            MilterOption  *option,
                                            MilterMacrosRequests *macros_requests,
                                            MilterStatus   status);
        void         (*define_macro)       (MilterClientContext *context,
                                            MilterCommand command,
                                            GHashTable *macros);
        MilterStatus (*connect)            (MilterClientContext *context,
                                            const gchar   *host_name,
                                            struct sockaddr *address,
                                            socklen_t      address_length);
        void         (*connect_response)   (MilterClientContext *context,
                                            MilterStatus         status);
        MilterStatus (*helo)               (MilterClientContext *context,
                                            const gchar   *fqdn);
        void         (*helo_response)      (MilterClientContext *context,
                                            MilterStatus         status);
        MilterStatus (*envelope_from)      (MilterClientContext *context,
                                            const gchar   *from);
        void         (*envelope_from_response)
                                           (MilterClientContext *context,
                                            MilterStatus         status);
        MilterStatus (*envelope_recipient) (MilterClientContext *context,
                                            const gchar   *recipient);
        void         (*envelope_recipient_response)
                                           (MilterClientContext *context,
                                            MilterStatus         status);
        MilterStatus (*data)               (MilterClientContext *context);
        void         (*data_response)      (MilterClientContext *context,
                                            MilterStatus         status);
        MilterStatus (*unknown)            (MilterClientContext *context,
                                            const gchar   *command);
        void         (*unknown_response)   (MilterClientContext *context,
                                            MilterStatus         status);
        MilterStatus (*header)             (MilterClientContext *context,
                                            const gchar   *name,
                                            const gchar   *value);
        void         (*header_response)    (MilterClientContext *context,
                                            MilterStatus         status);
        MilterStatus (*end_of_header)      (MilterClientContext *context);
        void         (*end_of_header_response)
                                           (MilterClientContext *context,
                                            MilterStatus         status);
        MilterStatus (*body)               (MilterClientContext *context,
                                            const gchar         *chunk,
                                            gsize                size);
        MilterStatus (*body_bytes)         (MilterClientContext *context,
                                            GBytes              *chunk);
        void         (*body_response)      (MilterClientContext *context,
                                            MilterStatus         status);
        MilterStatus (*end_of_message)     (MilterClientContext *context,
                                            const gchar         *chunk,
                                            gsize                size);
        MilterStatus (*end_of_message_bytes)
                                           (MilterClientContext *context,
                                            GBytes              *chunk);
        void         (*end_of_message_response)
                                           (MilterClientContext *context,
                                            MilterStatus         status);
        MilterStatus (*abort)              (MilterClientContext *context,
                                            MilterClientContextState state);
        void         (*abort_response)     (MilterClientContext *context,
                                            MilterStatus         status);
        void         (*timeout)            (MilterClientContext *context);

        void         (*message_processed)  (MilterClientContext *context,
                                            MilterMessageResult *result);
    };

### MilterClientContext

    typedef struct _MilterClientContext MilterClientContext;

## プロパティ詳細

### The `“client”` property

    “client”                   MilterClient *

コンテキストのクライアント。

Owner: MilterClientContext

Flags: Read / Write / Construct Only

### The `“message-result”` property

    “message-result”           MilterMessageResult *

クライアントコンテキストのメッセージの処理結果。

Owner: MilterClientContext

Flags: Read / Write

### The `“option”` property

    “option”                   MilterOption *

クライントコンテキストのオプション。

Owner: MilterClientContext

Flags: Read / Write

### The `“packet-buffer-size”` property

    “packet-buffer-size”       guint

クライアントコンテキストのパケットバッファサイズ。

Owner: MilterClientContext

Flags: Read / Write

デフォルト値: 0

### The `“quarantine-reason”` property

    “quarantine-reason”        char *

クライアントコンテキストの隔離理由。

Owner: MilterClientContext

Flags: Read / Write

デフォルト値: NULL

### The `“state”` property

    “state”                    MilterClientContextState

クライアントコンテキストの状態。

Owner: MilterClientContext

Flags: Read / Write

デフォルト値: MILTER_CLIENT_CONTEXT_STATE_INVALID

### The `“status”` property

    “status”                   MilterStatus

クライアントコンテキストのステータス。

Owner: MilterClientContext

Flags: Read / Write

デフォルト値: MILTER_STATUS_DEFAULT

### The `“use-bytes”` property

    “use-bytes”                gboolean

Owner: MilterClientContext

Flags: Read / Write

Default value: FALSE

## シグナル詳細

### The `“abort”` signal

    MilterStatus
    user_function (MilterClientContext     *context,
                   MilterClientContextState state,
                   gpointer                 user_data)

This signal may be emitted at any time between “envelope-from” and “end-of-message”. This signal is only emitted if the milter causes an internal error and the message processing isn't completed. For example, if the milter has already returned `MILTER_STATUS_ACCEPT`, `MILTER_STATUS_REJECT`, `MILTER_STATUS_DISCARD` and `MILTER_STATUS_TEMPORARY_FAILURE`, this signal will not emitted.

If the milter has any resources allocated for the message between “envelope-from” and “end-of-message”, should be freed in this signal. But any resources allocated for the connection should not be freed in this signal. It should be freed in “finished”.

すべての利用可能な応答ステータスは以下の通りです。

`MILTER_STATUS_CONTINUE` | 現在のメッセージに対する処理を続けます。
`MILTER_STATUS_DISCARD` | Accepts the current message and discards it silently. “abort” is not emitted.
`MILTER_STATUS_ACCEPT` | Accepts the current message without further more processing. “abort” is not emitted.
`MILTER_STATUS_TEMPORARY_FAILURE` | Rejects the current message with temporary failure. (i.e. 4xx status code in SMTP) “abort” is not emitted.
`MILTER_STATUS_PROGRESS` | It means that the processing in callback is in progress and returning response status is pending. The main loop for the milter is continued. If you returns this status, you need to emit “end-of-message-response” signal by yourself with one of the above `MilterStatus`es. This status may be used for a milter that has IO wait. (e.g. The milter may need to connect to the its server like clamav-milter) Normally, this status will not be used.

milter.orgの xxfi_abortも見てください。

#### Parameters

context | The context that received the signal. |
state | The state aborted on. |
user_data | user data set when the signal handler was connected. |

#### Returns

応答ステータス。

Flags: Run Last

### The `“abort-response”` signal

    void
    user_function (MilterClientContext *context,
                   MilterStatus         status,
                   gpointer             user_data)

This signal is emitted implicitly after “abort” returns a status except `MILTER_STATUS_PROGRESS`. This signal's default handler replies a response to MTA. You don't need to connect this signal.

If you returns `MILTER_STATUS_PROGRESS` in “abort”, you need to emit this signal to `context` by yourself.

#### Parameters

context | シグナルを受け取るコンテキスト。 |
status | 応答ステータス。 |
user_data | user data set when the signal handler was connected. |

Flags: Run Last

### The `“body”` signal

    MilterStatus
    user_function (MilterClientContext *context,
                   char                *chunk,
                   guint64              size,
                   gpointer             user_data)

This signal is emitted on body data is received. This signal is emitted zero or more times between “end-of-header” and “end-of-message”.

すべての利用可能な応答ステータスは以下の通りです。

`MILTER_STATUS_CONTINUE` | 現在のメッセージに対する処理を続けます。
`MILTER_STATUS_REJECT` | Rejects the current message. “abort” is not emitted.
`MILTER_STATUS_DISCARD` | Accepts the current message and discards it silently. “abort” is not emitted.
`MILTER_STATUS_ACCEPT` | Accepts the current message without further more processing. “abort” is not emitted.
`MILTER_STATUS_TEMPORARY_FAILURE` | Rejects the current message with temporary failure. (i.e. 4xx status code in SMTP) “abort” is not emitted.
`MILTER_STATUS_SKIP` | Skips further body processing. “end-of-message” is emitted.
`MILTER_STATUS_NO_REPLY` | Doesn't send a reply back to MTA. The milter must set `MILTER_STEP_NO_REPLY_BODY` in “negotiate” handler.
`MILTER_STATUS_PROGRESS` | It means that the processing in callback is in progress and returning response status is pending. The main loop for the milter is continued. If you returns this status, you need to emit “body-response” signal by yourself with one of the above `MilterStatus`es. This status may be used for a milter that has IO wait. (e.g. The milter may need to connect to the its server like clamav-milter) Normally, this status will not be used.

milter.orgの xxfi_bodyも見てください。

#### Parameters

context | The context that received the signal. |
chunk | The body chunk. |
size | The size of `chunk` . |
user_data | user data set when the signal handler was connected. |

#### Returns

応答ステータス。

Flags: Run Last

### The `“body-bytes”` signal

    MilterStatus
    user_function (MilterClientContext *context,
                   GBytes              *chunk,
                   gpointer             user_data)

You can use this signal instead of “body-bytes” by calling `milter_client_context_use_bytes(TRUE)`.

#### Parameters

context | The context that received the signal. |
chunk | The body chunk. |
user_data | user data set when the signal handler was connected. |

#### Returns

応答ステータス。

Flags: Run Last

Since: 2.1.6.

### The `“body-response”` signal

    void
    user_function (MilterClientContext *context,
                   MilterStatus         status,
                   gpointer             user_data)

This signal is emitted implicitly after “body” returns a status except `MILTER_STATUS_PROGRESS`. This signal's default handler replies a response to MTA. You don't need to connect this signal.

If you returns `MILTER_STATUS_PROGRESS` in “body”, you need to emit this signal to `context` by yourself.

#### Parameters

context | シグナルを受け取るコンテキスト。 |
status | 応答ステータス。 |
user_data | user data set when the signal handler was connected. |

Flags: Run Last

### The `“connect”` signal

    MilterStatus
    user_function (MilterClientContext *context,
                   char                *host_name,
                   gpointer             address,
                   guint                address_size,
                   gpointer             user_data)

This signal is emitted on SMTP client is connected to MTA.

すべての利用可能な応答ステータスは以下の通りです。

`MILTER_STATUS_CONTINUE` | 現在の接続に対する処理を続行します。
`MILTER_STATUS_REJECT` | Rejects the current connection. “finished” will be emitted.
`MILTER_STATUS_ACCEPT` | Accepts the current connection without further more processing. “finished” will be emitted.
`MILTER_STATUS_TEMPORARY_FAILURE` | Rejects the current connection with a temporary failure. (i.e. 4xx status code in SMTP) “finished” will be emitted.
`MILTER_STATUS_NO_REPLY` | Doesn't send a reply back to MTA. The milter must set `MILTER_STEP_NO_REPLY_CONNECT` in “negotiate” handler.
`MILTER_STATUS_PROGRESS` | It means that the processing in callback is in progress and returning response status is pending. The main loop for the milter is continued. If you returns this status, you need to emit “connect-response” signal by yourself with one of the above `MilterStatus`es. This status may be used for a milter that has IO wait. (e.g. The milter may need to connect to the its server like clamav-milter) Normally, this status will not be used.

milter.orgのxxfi_connectも見てください。

#### Parameters

context | シグナルを受け取るコンテキスト。 |
host_name | 接続してきたSMTPクライアントのホスト名。 |
address | 接続してきたSMTPクライアントのアドレス。（struct sockaddr） |
address_size | the size of `address` . (socklen_t) |
user_data | user data set when the signal handler was connected. |

#### Returns

応答ステータス。

Flags: Run Last

### The `“connect-response”` signal

    void
    user_function (MilterClientContext *context,
                   MilterStatus         status,
                   gpointer             user_data)

This signal is emitted implicitly after “connect” returns a status except `MILTER_STATUS_PROGRESS`. This signal's default handler replies a response to MTA. You don't need to connect this signal.

If you returns `MILTER_STATUS_PROGRESS` in “connect”, you need to emit this signal to `context` by yourself.

#### Parameters

context | シグナルを受け取るコンテキスト。 |
status | 応答ステータス。 |
user_data | user data set when the signal handler was connected. |

Flags: Run Last

### The `“data”` signal

    MilterStatus
    user_function (MilterClientContext *context,
                   gpointer             user_data)

このシグナルはSMTPの"DATA"コマンドのときに発行されます。

すべての利用可能な応答ステータスは以下の通りです。

`MILTER_STATUS_CONTINUE` | 現在のメッセージに対する処理を続けます。
`MILTER_STATUS_REJECT` | Rejects the current message. “abort” is not emitted.
`MILTER_STATUS_DISCARD` | Accepts the current message and discards it silently. “abort” is not emitted.
`MILTER_STATUS_TEMPORARY_FAILURE` | Rejects the current message with temporary failure. (i.e. 4xx status code in SMTP) “abort” is not emitted.
`MILTER_STATUS_NO_REPLY` | Doesn't send a reply back to MTA. The milter must set `MILTER_STEP_NO_REPLY_DATA` in “negotiate” handler.
`MILTER_STATUS_PROGRESS` | It means that the processing in callback is in progress and returning response status is pending. The main loop for the milter is continued. If you returns this status, you need to emit “data-response” signal by yourself with one of the above `MilterStatus`es. This status may be used for a milter that has IO wait. (e.g. The milter may need to connect to the its server like clamav-milter) Normally, this status will not be used.

milter.orgの xxfi_dataも見てください。

#### Parameters

context | シグナルを受け取るコンテキスト。 |
user_data | user data set when the signal handler was connected. |

#### Returns

応答ステータス。

Flags: Run Last

### The `“data-response”` signal

    void
    user_function (MilterClientContext *context,
                   MilterStatus         status,
                   gpointer             user_data)

This signal is emitted implicitly after “data” returns a status except `MILTER_STATUS_PROGRESS`. This signal's default handler replies a response to MTA. You don't need to connect this signal.

If you returns `MILTER_STATUS_PROGRESS` in “data”, you need to emit this signal to `context` by yourself.

#### Parameters

context | シグナルを受け取るコンテキスト。 |
status | 応答ステータス。 |
user_data | user data set when the signal handler was connected. |

Flags: Run Last

### The `“define-macro”` signal

    void
    user_function (MilterClientContext *context,
                   MilterCommand        command,
                   gpointer             macros,
                   gpointer             user_data)

This signal is emitted when macro definition is received. Normally, this signal isn't needed to be connected.

#### Parameters

context | シグナルを受け取るコンテキスト。 |
command | マクロが定義されるコマンド。 |
macros | マクロ定義。 |
user_data | user data set when the signal handler was connected. |

Flags: Run Last

### The `“end-of-header”` signal

    MilterStatus
    user_function (MilterClientContext *context,
                   gpointer             user_data)

このシグナルはすべてのヘッダが処理されたときに呼ばれます。

すべての利用可能な応答ステータスは以下の通りです。

`MILTER_STATUS_CONTINUE` | 現在のメッセージに対する処理を続けます。
`MILTER_STATUS_REJECT` | Rejects the current message. “abort” is not emitted.
`MILTER_STATUS_DISCARD` | Accepts the current message and discards it silently. “abort” is not emitted.
`MILTER_STATUS_ACCEPT` | Accepts the current message without further more processing. “abort” is not emitted.
`MILTER_STATUS_TEMPORARY_FAILURE` | Rejects the current message with temporary failure. (i.e. 4xx status code in SMTP) “abort” is not emitted.
`MILTER_STATUS_NO_REPLY` | Doesn't send a reply back to MTA. The milter must set `MILTER_STEP_NO_REPLY_END_OF_HEADER` in “negotiate” handler.
`MILTER_STATUS_PROGRESS` | It means that the processing in callback is in progress and returning response status is pending. The main loop for the milter is continued. If you returns this status, you need to emit “end-of-header-response” signal by yourself with one of the above `MilterStatus`es. This status may be used for a milter that has IO wait. (e.g. The milter may need to connect to the its server like clamav-milter) Normally, this status will not be used.

milter.orgの xxfi_eofも見てください。

#### Parameters

context | シグナルを受け取るコンテキスト。 |
user_data | user data set when the signal handler was connected. |

#### Returns

応答ステータス。

Flags: Run Last

### The `“end-of-header-response”` signal

    void
    user_function (MilterClientContext *context,
                   MilterStatus         status,
                   gpointer             user_data)

This signal is emitted implicitly after “end-of-header” returns a status except `MILTER_STATUS_PROGRESS`. This signal's default handler replies a response to MTA. You don't need to connect this signal.

If you returns `MILTER_STATUS_PROGRESS` in “end-of-header”, you need to emit this signal to `context` by yourself.

#### Parameters

context | シグナルを受け取るコンテキスト。 |
status | 応答ステータス。 |
user_data | user data set when the signal handler was connected. |

Flags: Run Last

### The `“end-of-message”` signal

    MilterStatus
    user_function (MilterClientContext *context,
                   char                *chunk,
                   guint64              size,
                   gpointer             user_data)

This signal is emitted after all “body” are emitted. All message modifications can be done only in this signal handler. The modifications can be done with `milter_client_context_add_header()`, `milter_client_context_change_from()` and so on.

すべての利用可能な応答ステータスは以下の通りです。

`MILTER_STATUS_CONTINUE` | 現在のメッセージに対する処理を続けます。
`MILTER_STATUS_DISCARD` | Accepts the current message and discards it silently. “abort” is not emitted.
`MILTER_STATUS_ACCEPT` | Accepts the current message without further more processing. “abort” is not emitted.
`MILTER_STATUS_TEMPORARY_FAILURE` | Rejects the current message with temporary failure. (i.e. 4xx status code in SMTP) “abort” is not emitted.
`MILTER_STATUS_PROGRESS` | It means that the processing in callback is in progress and returning response status is pending. The main loop for the milter is continued. If you returns this status, you need to emit “end-of-message-response” signal by yourself with one of the above `MilterStatus`es. This status may be used for a milter that has IO wait. (e.g. The milter may need to connect to the its server like clamav-milter) Normally, this status will not be used.

milter.orgの xxfi_eomも見てください。

#### Parameters

context | The context that received the signal. |
chunk | The last chunk of the current email. | [nullable]
size | The size of the `chunk` . |
user_data | user data set when the signal handler was connected. |

#### Returns

応答ステータス。

Flags: Run Last

### The `“end-of-message-bytes”` signal

    MilterStatus
    user_function (MilterClientContext *context,
                   GBytes              *chunk,
                   gpointer             user_data)

You can use this signal instead of “end-of-message-bytes” by calling `milter_client_context_use_bytes(TRUE)`.

#### Parameters

context | The context that received the signal. |
chunk | The last chunk of the current email. | [nullable]
user_data | user data set when the signal handler was connected. |

#### Returns

応答ステータス。

Flags: Run Last

Since: 2.1.6.

### The `“end-of-message-response”` signal

    void
    user_function (MilterClientContext *context,
                   MilterStatus         status,
                   gpointer             user_data)

This signal is emitted implicitly after “end-of-message” returns a status except `MILTER_STATUS_PROGRESS`. This signal's default handler replies a response to MTA. You don't need to connect this signal.

If you returns `MILTER_STATUS_PROGRESS` in “end-of-message”, you need to emit this signal to `context` by yourself.

#### Parameters

context | シグナルを受け取るコンテキスト。 |
status | 応答ステータス。 |
user_data | user data set when the signal handler was connected. |

Flags: Run Last

### The `“envelope-from”` signal

    MilterStatus
    user_function (MilterClientContext *context,
                   char                *from,
                   gpointer             user_data)

このシグナルはSMTPの"MAIL FROM"コマンドのときに呼ばれます。

すべての利用可能な応答ステータスは以下の通りです。

`MILTER_STATUS_CONTINUE` | 現在のメッセージに対する処理を続けます。
`MILTER_STATUS_REJECT` | Rejects the current envelope from address and message. A new envelope from may be specified. “abort” is not emitted.
`MILTER_STATUS_DISCARD` | Accepts the current message and discards it silently. “abort” is not emitted.
`MILTER_STATUS_ACCEPT` | Accepts the current message without further more processing. “abort” is not emitted.
`MILTER_STATUS_TEMPORARY_FAILURE` | Rejects the current envelope from address and message with temporary failure. (i.e. 4xx status code in SMTP) A new envelope from address may be specified. “abort” is not emitted.
`MILTER_STATUS_NO_REPLY` | Doesn't send a reply back to MTA. The milter must set `MILTER_STEP_NO_REPLY_ENVELOPE_FROM` in “negotiate” handler.
`MILTER_STATUS_PROGRESS` | It means that the processing in callback is in progress and returning response status is pending. The main loop for the milter is continued. If you returns this status, you need to emit “envelope-from-response” signal by yourself with one of the above `MilterStatus`es. This status may be used for a milter that has IO wait. (e.g. The milter may need to connect to the its server like clamav-milter) Normally, this status will not be used.

milter.orgの xxfi_envfromも見てください。

#### Parameters

context | シグナルを受け取るコンテキスト。 |
from | SMTPの"MAIL FROM"コマンドの送信アドレス。 |
user_data | user data set when the signal handler was connected. |

#### Returns

応答ステータス。

Flags: Run Last

### The `“envelope-from-response”` signal

    void
    user_function (MilterClientContext *context,
                   MilterStatus         status,
                   gpointer             user_data)

This signal is emitted implicitly after “envelope-from” returns a status except `MILTER_STATUS_PROGRESS`. This signal's default handler replies a response to MTA. You don't need to connect this signal.

If you returns `MILTER_STATUS_PROGRESS` in “envelope-from”, you need to emit this signal to `context` by yourself.

#### Parameters

context | シグナルを受け取るコンテキスト。 |
status | 応答ステータス。 |
user_data | user data set when the signal handler was connected. |

Flags: Run Last

### The `“envelope-recipient”` signal

    MilterStatus
    user_function (MilterClientContext *context,
                   char                *recipient,
                   gpointer             user_data)

このシグナルはSMTPの"RCPT TO"コマンドのときに発行されます。

すべての利用可能な応答ステータスは以下の通りです。

`MILTER_STATUS_CONTINUE` | 現在のメッセージに対する処理を続けます。
`MILTER_STATUS_REJECT` | Rejects the current envelope recipient address. Processing the current messages is continued. “abort” is not emitted.
`MILTER_STATUS_DISCARD` | Accepts the current message and discards it silently. “abort” is not emitted.
`MILTER_STATUS_ACCEPT` | Accepts the current envelope recipient. “abort” is not emitted.
`MILTER_STATUS_TEMPORARY_FAILURE` | Rejects the current envelope recipient address with temporary failure. (i.e. 4xx status code in SMTP) Processing the current message is continued. “abort” is not emitted.
`MILTER_STATUS_NO_REPLY` | Doesn't send a reply back to MTA. The milter must set `MILTER_STEP_NO_REPLY_ENVELOPE_RECIPIENT` in “negotiate” handler.
`MILTER_STATUS_PROGRESS` | It means that the processing in callback is in progress and returning response status is pending. The main loop for the milter is continued. If you returns this status, you need to emit “envelope-recipient-response” signal by yourself with one of the above `MilterStatus`es. This status may be used for a milter that has IO wait. (e.g. The milter may need to connect to the its server like clamav-milter) Normally, this status will not be used.

milter.orgの xxfi_envrcptも見てください。

#### Parameters

context | シグナルを受け取るコンテキスト。 |
recipient | SMTPの"RCPT TO"コマンドの宛先アドレス。 |
user_data | user data set when the signal handler was connected. |

#### Returns

応答ステータス。

Flags: Run Last

### The `“envelope-recipient-response”` signal

    void
    user_function (MilterClientContext *context,
                   MilterStatus         status,
                   gpointer             user_data)

This signal is emitted implicitly after “envelope-recipient” returns a status except `MILTER_STATUS_PROGRESS`. This signal's default handler replies a response to MTA. You don't need to connect this signal.

If you returns `MILTER_STATUS_PROGRESS` in “envelope-recipient”, you need to emit this signal to `context` by yourself.

#### Parameters

context | シグナルを受け取るコンテキスト。 |
status | 応答ステータス。 |
user_data | user data set when the signal handler was connected. |

Flags: Run Last

### The `“header”` signal

    MilterStatus
    user_function (MilterClientContext *context,
                   char                *name,
                   char                *value,
                   gpointer             user_data)

This signal is emitted on each header. If `MILTER_STEP_HEADER_LEADING_SPACE` is set in “negotiate”, `value` have spaces after header name and value separator ":".

例:

    1
    2
    3
    From: from <from@example.com>
    To: recipient <recipient@example.com>
    Subject:a subject

`MILTER_STEP_HEADER_VALUE_WITH_LEADING_SPACE`あり:

    1
    2
    3
    4
    5
    "From", " from <from@example.com
    >"
    "To", " recipient <recipient@example.com
    >"
    "Subject", "a subject"

`MILTER_STEP_HEADER_VALUE_WITH_LEADING_SPACE`なし:

    1
    2
    3
    4
    5
    "From", "from <from@example.com
    >"
    "To", "recipient <recipient@example.com
    >"
    "Subject", "a subject"

すべての利用可能な応答ステータスは以下の通りです。

`MILTER_STATUS_CONTINUE` | 現在のメッセージに対する処理を続けます。
`MILTER_STATUS_REJECT` | Rejects the current message. “abort” is not emitted.
`MILTER_STATUS_DISCARD` | Accepts the current message and discards it silently. “abort” is not emitted.
`MILTER_STATUS_ACCEPT` | Accepts the current message without further more processing. “abort” is not emitted.
`MILTER_STATUS_TEMPORARY_FAILURE` | Rejects the current message with temporary failure. (i.e. 4xx status code in SMTP) “abort” is not emitted.
`MILTER_STATUS_NO_REPLY` | Doesn't send a reply back to MTA. The milter must set `MILTER_STEP_NO_REPLY_HEADER` in “negotiate” handler.
`MILTER_STATUS_PROGRESS` | It means that the processing in callback is in progress and returning response status is pending. The main loop for the milter is continued. If you returns this status, you need to emit “header-response” signal by yourself with one of the above `MilterStatus`es. This status may be used for a milter that has IO wait. (e.g. The milter may need to connect to the its server like clamav-milter) Normally, this status will not be used.

milter.orgの xxfi_headerも見てください。

#### Parameters

context | シグナルを受け取るコンテキスト。 |
name | ヘッダ名。 |
value | ヘッダ値。`value`は折り返し時に挿入された空白を含むかもしれません。 |
user_data | user data set when the signal handler was connected. |

#### Returns

応答ステータス。

Flags: Run Last

### The `“header-response”` signal

    void
    user_function (MilterClientContext *context,
                   MilterStatus         status,
                   gpointer             user_data)

This signal is emitted implicitly after “header” returns a status except `MILTER_STATUS_PROGRESS`. This signal's default handler replies a response to MTA. You don't need to connect this signal.

If you returns `MILTER_STATUS_PROGRESS` in “header”, you need to emit this signal to `context` by yourself.

#### Parameters

context | シグナルを受け取るコンテキスト。 |
status | 応答ステータス。 |
user_data | user data set when the signal handler was connected. |

Flags: Run Last

### The `“helo”` signal

    MilterStatus
    user_function (MilterClientContext *context,
                   char                *fqdn,
                   gpointer             user_data)

このシグナルはSMTPの"HELO"/"EHLO"コマンドのときに発行されます。

すべての利用可能な応答ステータスは以下の通りです。

`MILTER_STATUS_CONTINUE` | 現在の接続に対する処理を続行します。
`MILTER_STATUS_REJECT` | Rejects the current connection. “finished” will be emitted.
`MILTER_STATUS_ACCEPT` | Accepts the current connection without further more processing. “finished” will be emitted.
`MILTER_STATUS_TEMPORARY_FAILURE` | Rejects the current connection with a temporary failure. (i.e. 4xx status code in SMTP) “finished” will be emitted.
`MILTER_STATUS_NO_REPLY` | Doesn't send a reply back to MTA. The milter must set `MILTER_STEP_NO_REPLY_HELO` in “negotiate” handler.
`MILTER_STATUS_PROGRESS` | It means that the processing in callback is in progress and returning response status is pending. The main loop for the milter is continued. If you returns this status, you need to emit “helo-response” signal by yourself with one of the above `MilterStatus`es. This status may be used for a milter that has IO wait. (e.g. The milter may need to connect to the its server like clamav-milter) Normally, this status will not be used.

milter.orgの xxfi_heloも見てください。

#### Parameters

context | シグナルを受け取るコンテキスト。 |
fqdn | SMTPの"HELO"/"EHLO"コマンドでのFQDN。 |
user_data | user data set when the signal handler was connected. |

#### Returns

応答ステータス。

Flags: Run Last

### The `“helo-response”` signal

    void
    user_function (MilterClientContext *context,
                   MilterStatus         status,
                   gpointer             user_data)

This signal is emitted implicitly after “helo” returns a status except `MILTER_STATUS_PROGRESS`. This signal's default handler replies a response to MTA. You don't need to connect this signal.

If you returns `MILTER_STATUS_PROGRESS` in “helo”, you need to emit this signal to `context` by yourself.

#### Parameters

context | シグナルを受け取るコンテキスト。 |
status | 応答ステータス。 |
user_data | user data set when the signal handler was connected. |

Flags: Run Last

### The `“message-processed”` signal

    void
    user_function (MilterClientContext *milterclientcontext,
                   MilterMessageResult *arg1,
                   gpointer             user_data)

Flags: Run Last

### The `“negotiate”` signal

    MilterStatus
    user_function (MilterClientContext  *context,
                   MilterOption         *option,
                   MilterMacrosRequests *macros_requests,
                   gpointer              user_data)

This signal is emitted on negotiate request from MTA. If you want to modify actions (`MilterActionFlags`) and steps (`MilterStepFlags`), you modify `option` . If you want to add macros that you want to receive, you modify `macros_requests` .

すべての利用可能な応答ステータスは以下の通りです。

`MILTER_STATUS_ALL_OPTIONS` | すべての利用可能なアクションとステップを有効にします。
`MILTER_STATUS_REJECT` | 現在のセッションを拒否します。
`MILTER_STATUS_CONTINUE` | `option`と`macros_requests`で指定されたアクション、ステップ、要求マクロリストを使って現在のセッションの処理を続けます
`MILTER_STATUS_PROGRESS` | It means that the processing in callback is in progress and returning response status is pending. The main loop for the milter is continued. If you returns this status, you need to emit “negotiate-response” signal by yourself with one of the above `MilterStatus`es. This status may be used for a milter that has IO wait. (e.g. The milter may need to connect to the its server like clamav-milter) Normally, this status will not be used.

milter.orgの xxfi_negotiateも見てください。

#### Parameters

context | シグナルを受け取るコンテキスト。 |
option | MTAからのネゴシエーションのオプション。 |
macros_requests | 要求マクロリスト。 |
user_data | user data set when the signal handler was connected. |

#### Returns

応答ステータス。

Flags: Run Last

### The `“negotiate-response”` signal

    void
    user_function (MilterClientContext  *context,
                   MilterOption         *option,
                   MilterMacrosRequests *macros_requests,
                   MilterStatus          status,
                   gpointer              user_data)

This signal is emitted implicitly after “negotiate” returns a status except `MILTER_STATUS_PROGRESS`. This signal's default handler replies a response to MTA. You don't need to connect this signal.

If you returns `MILTER_STATUS_PROGRESS` in “negotiate” handler, you need to emit this signal to `context` by yourself.

#### Parameters

context | シグナルを受け取るコンテキスト。 |
option | MTAからのネゴシエーションのオプション。 |
macros_requests | 要求マクロリスト。 |
status | 応答ステータス。 |
user_data | user data set when the signal handler was connected. |

Flags: Run Last

### The `“timeout”` signal

    void
    user_function (MilterClientContext *context,
                   gpointer             user_data)

This signal is emitted if MTA doesn't return the next command within `milter_client_context_get_timeout()` seconds. If “timeout” is emitted, the current connection is aborted and “finished” are emitted. “abort” may be emitted before “finished” if the milter is processing a message.

#### Parameters

context | シグナルを受け取るコンテキスト。 |
user_data | user data set when the signal handler was connected. |

Flags: Run Last

### The `“unknown”` signal

    MilterStatus
    user_function (MilterClientContext *context,
                   char                *command,
                   gpointer             user_data)

このシグナルは未知のSMTPコマンドまたは未実装のSMTPコマンドが送られてきた場合に発行されます。

すべての利用可能な応答ステータスは以下の通りです。

`MILTER_STATUS_REJECT` | Rejects the current message. “abort” is not emitted.
`MILTER_STATUS_TEMPORARY_FAILURE` | Rejects the current message with temporary failure. (i.e. 4xx status code in SMTP) “abort” is not emitted.
`MILTER_STATUS_NO_REPLY` | Doesn't send a reply back to MTA. The milter must set `MILTER_STEP_NO_REPLY_DATA` in “negotiate” handler.
`MILTER_STATUS_PROGRESS` | It means that the processing in callback is in progress and returning response status is pending. The main loop for the milter is continued. If you returns this status, you need to emit “unknown-response” signal by yourself with one of the above `MilterStatus`es. This status may be used for a milter that has IO wait. (e.g. The milter may need to connect to the its server like clamav-milter) Normally, this status will not be used.

MTAは、未知のSMTPコマンドまたは未実装のSMTPコマンドは常に拒否することに中してください。

milter.orgの xxfi_unknownも見てください。

#### Parameters

context | シグナルを受け取るコンテキスト。 |
command | 未知のSMTPコマンド。 |
user_data | user data set when the signal handler was connected. |

#### Returns

応答ステータス。

Flags: Run Last

### The `“unknown-response”` signal

    void
    user_function (MilterClientContext *context,
                   MilterStatus         status,
                   gpointer             user_data)

This signal is emitted implicitly after “unknown” returns a status except `MILTER_STATUS_PROGRESS`. This signal's default handler replies a response to MTA. You don't need to connect this signal.

If you returns `MILTER_STATUS_PROGRESS` in “unknown”, you need to emit this signal to `context` by yourself.

#### Parameters

context | シグナルを受け取るコンテキスト。 |
status | 応答ステータス。 |
user_data | user data set when the signal handler was connected. |

Flags: Run Last