Skip to content

Commit

Permalink
lib-imap: imap-parser: Made the fatal result parameter of imap_parser…
Browse files Browse the repository at this point in the history
…_get_error() optional.
  • Loading branch information
stephanbosch committed May 29, 2016
1 parent 468440f commit 7bb3714
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 10 deletions.
3 changes: 1 addition & 2 deletions src/lib-imap-client/imapc-connection.c
Expand Up @@ -567,7 +567,6 @@ imapc_connection_read_line_more(struct imapc_connection *conn,
const struct imap_arg **imap_args_r)
{
uoff_t literal_size;
bool fatal;
int ret;

if ((ret = imapc_connection_read_literal(conn)) <= 0)
Expand All @@ -584,7 +583,7 @@ imapc_connection_read_line_more(struct imapc_connection *conn,
}
if (ret < 0) {
imapc_connection_input_error(conn, "Error parsing input: %s",
imap_parser_get_error(conn->parser, &fatal));
imap_parser_get_error(conn->parser, NULL));
return -1;
}

Expand Down
6 changes: 2 additions & 4 deletions src/lib-imap/imap-bodystructure.c
Expand Up @@ -825,7 +825,6 @@ int imap_bodystructure_parse(const char *bodystructure, pool_t pool,
struct imap_parser *parser;
const struct imap_arg *args;
int ret;
bool fatal;

i_assert(parts != NULL);
i_assert(parts->next == NULL);
Expand All @@ -838,7 +837,7 @@ int imap_bodystructure_parse(const char *bodystructure, pool_t pool,
IMAP_PARSE_FLAG_LITERAL_TYPE, &args);
if (ret < 0) {
*error_r = t_strdup_printf("IMAP parser failed: %s",
imap_parser_get_error(parser, &fatal));
imap_parser_get_error(parser, NULL));
} else if (ret == 0) {
*error_r = "Empty bodystructure";
ret = -1;
Expand Down Expand Up @@ -985,7 +984,6 @@ int imap_body_parse_from_bodystructure(const char *bodystructure,
struct istream *input;
struct imap_parser *parser;
const struct imap_arg *args;
bool fatal;
int ret;

input = i_stream_create_from_data(bodystructure, strlen(bodystructure));
Expand All @@ -996,7 +994,7 @@ int imap_body_parse_from_bodystructure(const char *bodystructure,
IMAP_PARSE_FLAG_LITERAL_TYPE, &args);
if (ret < 0) {
*error_r = t_strdup_printf("IMAP parser failed: %s",
imap_parser_get_error(parser, &fatal));
imap_parser_get_error(parser, NULL));
} else if (ret == 0) {
*error_r = "Empty bodystructure";
ret = -1;
Expand Down
3 changes: 2 additions & 1 deletion src/lib-imap/imap-parser.c
Expand Up @@ -137,7 +137,8 @@ void imap_parser_set_streams(struct imap_parser *parser, struct istream *input,

const char *imap_parser_get_error(struct imap_parser *parser, bool *fatal)
{
*fatal = parser->fatal_error;
if (fatal != NULL)
*fatal = parser->fatal_error;
return parser->error_msg;
}

Expand Down
3 changes: 2 additions & 1 deletion src/lib-imap/imap-parser.h
Expand Up @@ -58,7 +58,8 @@ void imap_parser_set_streams(struct imap_parser *parser, struct istream *input,
/* Return the last error in parser. fatal is set to TRUE if there's no way to
continue parsing, currently only if too large non-sync literal size was
given. */
const char *imap_parser_get_error(struct imap_parser *parser, bool *fatal);
const char *imap_parser_get_error(struct imap_parser *parser, bool *fatal)
ATTR_NULL(2);

/* Read a number of arguments. This function doesn't call i_stream_read(), you
need to do that. Returns number of arguments read (may be less than count
Expand Down
3 changes: 1 addition & 2 deletions src/plugins/virtual/virtual-config.c
Expand Up @@ -43,7 +43,6 @@ virtual_search_args_parse(const string_t *rule, const char **error_r)
struct mail_search_parser *parser;
struct mail_search_args *sargs;
const char *charset = "UTF-8";
bool fatal;
int ret;

if (str_len(rule) == 0) {
Expand All @@ -59,7 +58,7 @@ virtual_search_args_parse(const string_t *rule, const char **error_r)
ret = imap_parser_finish_line(imap_parser, 0, 0, &args);
if (ret < 0) {
sargs = NULL;
*error_r = t_strdup(imap_parser_get_error(imap_parser, &fatal));
*error_r = t_strdup(imap_parser_get_error(imap_parser, NULL));
} else {
parser = mail_search_parser_init_imap(args);
if (mail_search_build(mail_search_register_get_imap(),
Expand Down

0 comments on commit 7bb3714

Please sign in to comment.