[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnurl] 53/256: imap: use defined names for response codes
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnurl] 53/256: imap: use defined names for response codes |
Date: |
Fri, 06 Oct 2017 19:42:24 +0200 |
This is an automated email from the git hooks/post-receive script.
ng0 pushed a commit to branch master
in repository gnurl.
commit dff069fdf511bffed3a38bd78da32f89e47ab56e
Author: Daniel Stenberg <address@hidden>
AuthorDate: Thu Aug 24 13:39:07 2017 +0200
imap: use defined names for response codes
When working on this code I found the previous setup a bit weird while
using proper defines increases readability.
Closes #1824
---
lib/imap.c | 38 ++++++++++++++++++--------------------
1 file changed, 18 insertions(+), 20 deletions(-)
diff --git a/lib/imap.c b/lib/imap.c
index 417d48055..21fe0870f 100644
--- a/lib/imap.c
+++ b/lib/imap.c
@@ -162,11 +162,15 @@ const struct Curl_handler Curl_handler_imaps = {
};
#endif
+#define IMAP_RESP_OK 1
+#define IMAP_RESP_NOT_OK 2
+#define IMAP_RESP_PREAUTH 3
+
/* SASL parameters for the imap protocol */
static const struct SASLproto saslimap = {
"imap", /* The service name */
'+', /* Code received when continuation is expected */
- 'O', /* Code to receive upon authentication success */
+ IMAP_RESP_OK, /* Code to receive upon authentication success */
0, /* Maximum initial response length (no max) */
imap_perform_authenticate, /* Send authentication command */
imap_continue_authenticate, /* Send authentication continuation */
@@ -249,17 +253,11 @@ static bool imap_endofresp(struct connectdata *conn, char
*line, size_t len,
len -= id_len + 1;
if(len >= 2 && !memcmp(line, "OK", 2))
- *resp = 'O';
- else if(len >= 2 && !memcmp(line, "NO", 2))
- *resp = 'N';
- else if(len >= 3 && !memcmp(line, "BAD", 3))
- *resp = 'B';
+ *resp = IMAP_RESP_OK;
else if(len >= 7 && !memcmp(line, "PREAUTH", 7))
- *resp = 'P';
- else {
- failf(conn->data, "Bad tagged response");
- *resp = -1;
- }
+ *resp = IMAP_RESP_PREAUTH;
+ else
+ *resp = IMAP_RESP_NOT_OK;
return TRUE;
}
@@ -795,13 +793,13 @@ static CURLcode imap_state_servergreet_resp(struct
connectdata *conn,
struct Curl_easy *data = conn->data;
(void)instate; /* no use for this yet */
- if(imapcode == 'P') {
+ if(imapcode == IMAP_RESP_PREAUTH) {
/* PREAUTH */
struct imap_conn *imapc = &conn->proto.imapc;
imapc->preauth = TRUE;
infof(data, "PREAUTH connection, already authenticated!\n");
}
- else if(imapcode != 'O') {
+ else if(imapcode != IMAP_RESP_OK) {
failf(data, "Got unexpected imap-server response");
return CURLE_WEIRD_SERVER_REPLY;
}
@@ -873,7 +871,7 @@ static CURLcode imap_state_capability_resp(struct
connectdata *conn,
line += wordlen;
}
}
- else if(imapcode == 'O') {
+ else if(imapcode == IMAP_RESP_OK) {
if(data->set.use_ssl && !conn->ssl[FIRSTSOCKET].use) {
/* We don't have a SSL/TLS connection yet, but SSL is requested */
if(imapc->tls_supported)
@@ -906,7 +904,7 @@ static CURLcode imap_state_starttls_resp(struct connectdata
*conn,
(void)instate; /* no use for this yet */
- if(imapcode != 'O') {
+ if(imapcode != IMAP_RESP_OK) {
if(data->set.use_ssl != CURLUSESSL_TRY) {
failf(data, "STARTTLS denied");
result = CURLE_USE_SSL_FAILED;
@@ -964,7 +962,7 @@ static CURLcode imap_state_login_resp(struct connectdata
*conn,
(void)instate; /* no use for this yet */
- if(imapcode != 'O') {
+ if(imapcode != IMAP_RESP_OK) {
failf(data, "Access denied. %c", imapcode);
result = CURLE_LOGIN_DENIED;
}
@@ -992,7 +990,7 @@ static CURLcode imap_state_listsearch_resp(struct
connectdata *conn,
result = Curl_client_write(conn, CLIENTWRITE_BODY, line, len + 1);
line[len] = '\0';
}
- else if(imapcode != 'O')
+ else if(imapcode != IMAP_RESP_OK)
result = CURLE_QUOTE_ERROR; /* TODO: Fix error code */
else
/* End of DO phase */
@@ -1021,7 +1019,7 @@ static CURLcode imap_state_select_resp(struct connectdata
*conn, int imapcode,
imapc->mailbox_uidvalidity = strdup(tmp);
}
}
- else if(imapcode == 'O') {
+ else if(imapcode == IMAP_RESP_OK) {
/* Check if the UIDVALIDITY has been specified and matches */
if(imap->uidvalidity && imapc->mailbox_uidvalidity &&
strcmp(imap->uidvalidity, imapc->mailbox_uidvalidity)) {
@@ -1153,7 +1151,7 @@ static CURLcode imap_state_fetch_final_resp(struct
connectdata *conn,
(void)instate; /* No use for this yet */
- if(imapcode != 'O')
+ if(imapcode != IMAP_RESP_OK)
result = CURLE_WEIRD_SERVER_REPLY;
else
/* End of DONE phase */
@@ -1197,7 +1195,7 @@ static CURLcode imap_state_append_final_resp(struct
connectdata *conn,
(void)instate; /* No use for this yet */
- if(imapcode != 'O')
+ if(imapcode != IMAP_RESP_OK)
result = CURLE_UPLOAD_FAILED;
else
/* End of DONE phase */
--
To stop receiving notification emails like this one, please contact
address@hidden
- [GNUnet-SVN] [gnurl] 31/256: http: Don't wait on CONNECT when there is no proxy, (continued)
- [GNUnet-SVN] [gnurl] 31/256: http: Don't wait on CONNECT when there is no proxy, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 24/256: ftp: fix CWD when doing multicwd then nocwd on same connection, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 26/256: cmake: sizeof curl_off_t, remove unused detections, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 28/256: lib557: no longer use CURL_SIZEOF_* defines, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 51/256: imap: support PREAUTH, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 32/256: curl/system.h: check for __ppc__ as well, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 34/256: http2_recv: return error better on fatal h2 errors, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 39/256: runtests: fixed case insensitive matching of keywords, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 41/256: curl/system.h: fix build for hppa, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 38/256: tests: Make sure libtests call curl_global_cleanup(), gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 53/256: imap: use defined names for response codes,
gnunet <=
- [GNUnet-SVN] [gnurl] 33/256: KNOWN_BUGS: HTTP test server 'connection-monitor' problems, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 58/256: system.h: include sys/poll.h for AIX, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 48/256: config-dos: add missing defines, SIZEOF_* and two others, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 55/256: fuzz/Makefile.am: remove curlbuild.h leftovers, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 82/256: curl_ntlm_core: don't complain but #include OpenSSL header if needed, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 63/256: vtls: make sure all _data_pending() functions return bool, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 62/256: vtls: make sure all _cleanup() functions return void, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 91/256: version: if built with more than one SSL backend, report all of them, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 88/256: docs/examples: demonstrate how to select SSL backends, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 61/256: vtls: use consistent signature for _random() implementations, gnunet, 2017/10/06