b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch /* The command is sent to server before login (or is the login
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch command itself). Non-prelogin commands will be queued until login
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch is successful. */
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch /* This command may be positioned anywhere in a PIPELINING group. */
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch /* This command has priority and needs to be inserted before anything
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch else. This is e.g. used to make sure that the initial handshake
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch commands are sent before any other command that may already be
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch submitted to the connection. */
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch/* Called when reply is received for command. */
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Boschtypedef void smtp_client_command_callback_t(const struct smtp_reply *reply,
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Boschsmtp_client_command_new(struct smtp_client_connection *conn,
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch smtp_client_command_callback_t *callback, void *context);
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch#define smtp_client_command_new(conn, flags, callback, context) \
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch const struct smtp_reply *reply, typeof(context))), \
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch (smtp_client_command_callback_t *)callback, context)
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch/* Create a plug command, which is a dummy command that blocks the send queue.
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch This is used by transactions to prevent subsequently submitted
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch transactions from messing up the command sequence while the present
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch transaction is still submitting commands. The plug command is aborted once
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch the send queue is to be released. */
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Boschsmtp_client_command_plug(struct smtp_client_connection *conn,
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Boschvoid smtp_client_command_ref(struct smtp_client_command *cmd);
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Boschvoid smtp_client_command_unref(struct smtp_client_command **_cmd);
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Boschbool smtp_client_command_name_equals(struct smtp_client_command *cmd,
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch const char *name);
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch/* Lock the command; no commands after this one will be sent until this one
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Boschvoid smtp_client_command_lock(struct smtp_client_command *cmd);
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Boschvoid smtp_client_command_unlock(struct smtp_client_command *cmd);
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Boschvoid smtp_client_command_set_flags(struct smtp_client_command *cmd,
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Boschvoid smtp_client_command_set_stream(struct smtp_client_command *cmd,
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Boschvoid smtp_client_command_write(struct smtp_client_command *cmd,
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch const char *cmd_str);
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Boschvoid smtp_client_command_printf(struct smtp_client_command *cmd,
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Boschvoid smtp_client_command_vprintf(struct smtp_client_command *cmd,
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch const char *cmd_fmt, va_list args) ATTR_FORMAT(2, 0);
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Boschvoid smtp_client_command_submit_after(struct smtp_client_command *cmd,
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Boschvoid smtp_client_command_submit(struct smtp_client_command *cmd);
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Boschvoid smtp_client_command_abort(struct smtp_client_command **_cmd);
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Boschvoid smtp_client_command_set_abort_callback(struct smtp_client_command *cmd,
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch void (*callback)(void *context), void *context);
11142fd53e4dcd6e54322dc40b6bd42753a8b304Stephan Boschvoid smtp_client_command_set_sent_callback(struct smtp_client_command *cmd,
11142fd53e4dcd6e54322dc40b6bd42753a8b304Stephan Bosch void (*callback)(void *context), void *context);
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Boschvoid smtp_client_command_set_replies(struct smtp_client_command *cmd,
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch unsigned int replies);
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Boschsmtp_client_command_get_state(struct smtp_client_command *cmd) ATTR_PURE;
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch * Standard commands
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch/* send NOOP */
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch#define smtp_client_command_noop_submit_after(conn, \
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch smtp_client_command_noop_submit_after(conn, flags + \
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch const struct smtp_reply *reply, typeof(context))), after, \
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch (smtp_client_command_callback_t *)callback, context)
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch#define smtp_client_command_noop_submit(conn, \
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch smtp_client_command_noop_submit(conn, flags + \
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch const struct smtp_reply *reply, typeof(context))), \
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch (smtp_client_command_callback_t *)callback, context)
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch/* send VRFY <param> */
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch#define smtp_client_command_vrfy_submit_after(conn, \
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch smtp_client_command_vrfy_submit_after(conn, flags + \
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch const struct smtp_reply *reply, typeof(context))), \
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch (smtp_client_command_callback_t *)callback, context)
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch#define smtp_client_command_vrfy_submit(conn, \
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch smtp_client_command_vrfy_submit(conn, flags + \
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch const struct smtp_reply *reply, typeof(context))), \
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch param, (smtp_client_command_callback_t *)callback, context)
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch/* send RSET */
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch#define smtp_client_command_rset_submit_after(conn, \
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch smtp_client_command_rset_submit_after(conn, flags + \
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch const struct smtp_reply *reply, typeof(context))), \
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch after, (smtp_client_command_callback_t *)callback, context)
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch#define smtp_client_command_rset_submit(conn, \
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch smtp_client_command_rset_submit(conn, flags + \
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch const struct smtp_reply *reply, typeof(context))), \
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch (smtp_client_command_callback_t *)callback, context)
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch/* send MAIL FROM:<address> <params...> */
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch#define smtp_client_command_mail_submit_after(conn, \
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch flags, after, address, params, callback, context) \
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch smtp_client_command_mail_submit_after(conn, flags + \
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch const struct smtp_reply *reply, typeof(context))), \
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch (smtp_client_command_callback_t *)callback, context)
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch#define smtp_client_command_mail_submit(conn, \
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch smtp_client_command_mail_submit(conn, flags + \
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch const struct smtp_reply *reply, typeof(context))), \
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch (smtp_client_command_callback_t *)callback, context)
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch/* send RCPT TO:<address> parameters */
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch#define smtp_client_command_rcpt_submit_after(conn, \
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch flags, after, to, params, callback, context) \
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch smtp_client_command_rcpt_submit_after(conn, flags + \
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch const struct smtp_reply *reply, typeof(context))), \
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch (smtp_client_command_callback_t *)callback, context)
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch#define smtp_client_command_rcpt_submit(conn, \
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch smtp_client_command_rcpt_submit(conn, flags + \
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch const struct smtp_reply *reply, typeof(context))), \
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch (smtp_client_command_callback_t *)callback, context)
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch/* send message data using DATA or BDAT (preferred if supported)
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch handles DATA 354 response implicitly
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch#define smtp_client_command_data_submit_after(conn, \
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch smtp_client_command_data_submit_after(conn, flags + \
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch const struct smtp_reply *reply, typeof(context))), \
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch after, data, (smtp_client_command_callback_t *)callback, context)
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch#define smtp_client_command_data_submit(conn, \
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch smtp_client_command_data_submit(conn, flags + \
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch const struct smtp_reply *reply, typeof(context))), \