Skip to content

Commit

Permalink
lib-smtp: client: Use the new smtp_capability_find_by_name() function.
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanbosch authored and cmouse committed Oct 9, 2018
1 parent 6ca6ecb commit ae86163
Showing 1 changed file with 22 additions and 34 deletions.
56 changes: 22 additions & 34 deletions src/lib-smtp/smtp-client-connection.c
Expand Up @@ -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");

Expand Down Expand Up @@ -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;

Expand All @@ -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++;
}

Expand Down

0 comments on commit ae86163

Please sign in to comment.