commit 3e3a75bd6311c048d2d580334800e64a8d4552c0
parent b51e362bd39ee1d1e61584e02c74d2f66c5c34ff
Author: Christoph Lohmann <20h@r-36.net>
Date: Sat, 16 Aug 2014 18:21:18 +0200
Add nostarttls and fix some strings.
Diffstat:
4 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/imap.c b/imap.c
@@ -29,6 +29,7 @@ imap_new(char *netspec, char *user, char *pass)
imap->netspec = memdup(netspec, strlen(netspec)+1);
imap->user = memdup(user, strlen(user)+1);
imap->pass = memdup(pass, strlen(pass)+1);
+ imap->starttls = 1;
return imap;
}
@@ -574,6 +575,9 @@ imap_connect(imap_t *imap)
if (imap->fd == NULL)
return 1;
+ if (imap->fd->options && strstr(imap->fd->options, "nostarttls"))
+ imap->starttls = 0;
+
if (net_connect(imap->fd)) {
net_free(imap->fd);
imap->fd = NULL;
@@ -664,7 +668,7 @@ imap_init(imap_t *imap)
return 1;
result = llist_get(imap->caps, "STARTTLS");
- if (result != NULL) {
+ if (result != NULL && imap->starttls) {
if (imap_starttls(imap))
return 1;
}
@@ -935,7 +939,7 @@ imap_status(imap_t *imap, char *mb)
case 1:
if (elem->key == NULL)
goto imapstatusbadending;
- if (strcmp(elem->key, "string"))
+ if (strcmp(elem->key, "atom"))
goto imapstatusbadending;
llist_add(status, "mb", elem->data,
elem->datalen);
@@ -1004,7 +1008,7 @@ imap_listresponse(imap_t *imap, char *cmd)
slist = (llist_t *)elem->data;
if (slist->last->key == NULL)
continue;
- if (strcmp((char *)slist->last->key, "string"))
+ if (strcmp((char *)slist->last->key, "atom"))
continue;
if (slist->last->data == NULL)
continue;
diff --git a/imap.h b/imap.h
@@ -23,6 +23,8 @@ struct imap_t {
char *selected;
+ int starttls;
+
llist_t *caps;
parser_t *parser;
};
diff --git a/net.c b/net.c
@@ -77,6 +77,9 @@ net_new(char *desc)
case 2:
ret->service = memdup(tok, strlen(tok)+1);
break;
+ case 3:
+ ret->options = memdup(tok, strlen(tok)+1);
+ break;
default:
break;
}
diff --git a/net.h b/net.h
@@ -13,6 +13,7 @@ struct net_t {
char *net;
char *addr;
char *service;
+ char *options;
int type;
void *data[2];