From: Stephan Bosch Date: Wed, 26 Sep 2018 19:44:35 +0000 (+0200) Subject: lib-smtp: client: Use the new smtp_capability_find_by_name() function. X-Git-Tag: 2.3.9~1305 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ae86163a2e975a463726f7a0e56943cab907a30a;p=thirdparty%2Fdovecot%2Fcore.git lib-smtp: client: Use the new smtp_capability_find_by_name() function. --- diff --git a/src/lib-smtp/smtp-client-connection.c b/src/lib-smtp/smtp-client-connection.c index fd9de94d7e..5d07429ccc 100644 --- a/src/lib-smtp/smtp-client-connection.c +++ b/src/lib-smtp/smtp-client-connection.c @@ -871,7 +871,6 @@ smtp_client_connection_handshake_cb(const struct smtp_reply *reply, struct smtp_client_connection *conn) { const char *const *lines; - unsigned int j; smtp_client_connection_debug(conn, "Received handshake reply"); @@ -913,7 +912,7 @@ smtp_client_connection_handshake_cb(const struct smtp_reply *reply, /* capability lines */ while (*lines != NULL) { - const struct smtp_capability_name *cap = NULL; + enum smtp_capability cap; const char *const *params; const char *cap_name, *error; @@ -926,42 +925,31 @@ smtp_client_connection_handshake_cb(const struct smtp_reply *reply, continue; } - for (j = 0; smtp_capability_names[j].name != NULL; j++) { - cap = &smtp_capability_names[j]; - - if (strcasecmp(cap_name, cap->name) == 0) - break; - cap = NULL; - } - - if (cap != NULL) { - switch (cap->capability) { - case SMTP_CAPABILITY_AUTH: - conn->cap_auth_mechanisms = - p_strarray_dup(conn->cap_pool, params); - break; - case SMTP_CAPABILITY_SIZE: - if (params == NULL || *params == NULL) - break; - if (str_to_uoff(*params, &conn->cap_size) < 0) { - smtp_client_connection_warning(conn, - "Received invalid SIZE capability " - "in EHLO response line"); - cap = NULL; - } - break; - case SMTP_CAPABILITY_XCLIENT: - conn->cap_xclient_args = - p_strarray_dup(conn->cap_pool, params); - break; - default: + cap = smtp_capability_find_by_name(cap_name); + switch (cap) { + case SMTP_CAPABILITY_AUTH: + conn->cap_auth_mechanisms = + p_strarray_dup(conn->cap_pool, params); + break; + case SMTP_CAPABILITY_SIZE: + if (params == NULL || *params == NULL) break; + if (str_to_uoff(*params, &conn->cap_size) < 0) { + smtp_client_connection_warning(conn, + "Received invalid SIZE capability " + "in EHLO response line"); + cap = SMTP_CAPABILITY_NONE; } + break; + case SMTP_CAPABILITY_XCLIENT: + conn->cap_xclient_args = + p_strarray_dup(conn->cap_pool, params); + break; + default: + break; } - if (cap != NULL) - conn->capabilities |= cap->capability; - + conn->capabilities |= cap; lines++; }