void smtp_command_parser_set_stream(struct smtp_command_parser *parser,
struct istream *input);
+/* Returns 1 if a command was returned, 0 if more data is needed, -1 on error,
+ -2 if disconnected in SMTP_COMMAND_PARSE_STATE_INIT state. -2 is mainly for
+ unit tests - it can normally be treated the same as -1. */
int smtp_command_parse_next(struct smtp_command_parser *parser,
const char **cmd_name_r, const char **cmd_params_r,
enum smtp_command_parse_error *error_code_r, const char **error_r);
smtp_command_parse_data_with_dot(struct smtp_command_parser *parser);
bool smtp_command_parser_pending_data(struct smtp_command_parser *parser);
+/* Returns the same as smtp_command_parse_next() */
int smtp_command_parse_auth_response(struct smtp_command_parser *parser,
const char **line_r, enum smtp_command_parse_error *error_code_r,
const char **error_r);
while ((ret=smtp_command_parse_next(parser,
&cmd_name, &cmd_params, &error_code, &error)) > 0);
- test_out_reason("parse success", ret == 0, error);
+ test_out_reason("parse success", ret == -2, error);
if (ret == 0) {
/* verify last response only */
while ((ret=smtp_command_parse_next(parser,
&cmd_name, &cmd_params, &error_code, &error)) > 0);
test_out_reason(t_strdup_printf("parse(\"%s\")",
- str_sanitize(command_text, 28)), ret < 0, error);
+ str_sanitize(command_text, 28)), ret == -1, error);
test_out_quiet("error code",
error_code == test->error_code);
while ((ret=smtp_command_parse_auth_response(parser,
&line, &error_code, &error)) > 0);
- test_out_reason("parse success", ret == 0, error);
+ test_out_reason("parse success", ret == -2, error);
if (ret == 0) {
/* verify last response only */
while ((ret=smtp_command_parse_auth_response(parser,
&line, &error_code, &error)) > 0);
test_out_reason(t_strdup_printf("parse(\"%s\")",
- str_sanitize(response_text, 28)), ret < 0, error);
+ str_sanitize(response_text, 28)), ret == -1, error);
test_out_quiet("error code",
error_code == test->error_code);