Skip to content

Commit daa2589

Browse files
committed
Merge branch 'jk/imap-send-unused-variable-cleanup'
"imap-send" codepaths got cleaned up to get rid of unused parameters. * jk/imap-send-unused-variable-cleanup: imap-send: drop unused fields from imap_cmd_cb imap-send: drop unused parameter from imap_cmd_cb callback imap-send: use server conf argument in setup_curl()
2 parents ce36dea + d378637 commit daa2589

File tree

1 file changed

+15
-19
lines changed

1 file changed

+15
-19
lines changed

imap-send.c

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,10 @@ struct imap_store {
137137
};
138138

139139
struct imap_cmd_cb {
140-
int (*cont)(struct imap_store *ctx, struct imap_cmd *cmd, const char *prompt);
141-
void (*done)(struct imap_store *ctx, struct imap_cmd *cmd, int response);
140+
int (*cont)(struct imap_store *ctx, const char *prompt);
142141
void *ctx;
143142
char *data;
144143
int dlen;
145-
int uid;
146144
};
147145

148146
struct imap_cmd {
@@ -786,7 +784,7 @@ static int get_cmd_result(struct imap_store *ctx, struct imap_cmd *tcmd)
786784
if (n != (int)cmdp->cb.dlen)
787785
return RESP_BAD;
788786
} else if (cmdp->cb.cont) {
789-
if (cmdp->cb.cont(ctx, cmdp, cmd))
787+
if (cmdp->cb.cont(ctx, cmd))
790788
return RESP_BAD;
791789
} else {
792790
fprintf(stderr, "IMAP error: unexpected command continuation request\n");
@@ -828,8 +826,6 @@ static int get_cmd_result(struct imap_store *ctx, struct imap_cmd *tcmd)
828826
}
829827
if ((resp2 = parse_response_code(ctx, &cmdp->cb, cmd)) > resp)
830828
resp = resp2;
831-
if (cmdp->cb.done)
832-
cmdp->cb.done(ctx, cmdp, resp);
833829
free(cmdp->cb.data);
834830
free(cmdp->cmd);
835831
free(cmdp);
@@ -917,7 +913,7 @@ static char *cram(const char *challenge_64, const char *user, const char *pass)
917913

918914
#endif
919915

920-
static int auth_cram_md5(struct imap_store *ctx, struct imap_cmd *cmd, const char *prompt)
916+
static int auth_cram_md5(struct imap_store *ctx, const char *prompt)
921917
{
922918
int ret;
923919
char *response;
@@ -1416,42 +1412,42 @@ static CURL *setup_curl(struct imap_server_conf *srvc, struct credential *cred)
14161412
if (!curl)
14171413
die("curl_easy_init failed");
14181414

1419-
server_fill_credential(&server, cred);
1420-
curl_easy_setopt(curl, CURLOPT_USERNAME, server.user);
1421-
curl_easy_setopt(curl, CURLOPT_PASSWORD, server.pass);
1415+
server_fill_credential(srvc, cred);
1416+
curl_easy_setopt(curl, CURLOPT_USERNAME, srvc->user);
1417+
curl_easy_setopt(curl, CURLOPT_PASSWORD, srvc->pass);
14221418

1423-
strbuf_addstr(&path, server.use_ssl ? "imaps://" : "imap://");
1424-
strbuf_addstr(&path, server.host);
1419+
strbuf_addstr(&path, srvc->use_ssl ? "imaps://" : "imap://");
1420+
strbuf_addstr(&path, srvc->host);
14251421
if (!path.len || path.buf[path.len - 1] != '/')
14261422
strbuf_addch(&path, '/');
14271423

1428-
uri_encoded_folder = curl_easy_escape(curl, server.folder, 0);
1424+
uri_encoded_folder = curl_easy_escape(curl, srvc->folder, 0);
14291425
if (!uri_encoded_folder)
14301426
die("failed to encode server folder");
14311427
strbuf_addstr(&path, uri_encoded_folder);
14321428
curl_free(uri_encoded_folder);
14331429

14341430
curl_easy_setopt(curl, CURLOPT_URL, path.buf);
14351431
strbuf_release(&path);
1436-
curl_easy_setopt(curl, CURLOPT_PORT, server.port);
1432+
curl_easy_setopt(curl, CURLOPT_PORT, srvc->port);
14371433

1438-
if (server.auth_method) {
1434+
if (srvc->auth_method) {
14391435
#ifndef GIT_CURL_HAVE_CURLOPT_LOGIN_OPTIONS
14401436
warning("No LOGIN_OPTIONS support in this cURL version");
14411437
#else
14421438
struct strbuf auth = STRBUF_INIT;
14431439
strbuf_addstr(&auth, "AUTH=");
1444-
strbuf_addstr(&auth, server.auth_method);
1440+
strbuf_addstr(&auth, srvc->auth_method);
14451441
curl_easy_setopt(curl, CURLOPT_LOGIN_OPTIONS, auth.buf);
14461442
strbuf_release(&auth);
14471443
#endif
14481444
}
14491445

1450-
if (!server.use_ssl)
1446+
if (!srvc->use_ssl)
14511447
curl_easy_setopt(curl, CURLOPT_USE_SSL, (long)CURLUSESSL_TRY);
14521448

1453-
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, server.ssl_verify);
1454-
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, server.ssl_verify);
1449+
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, srvc->ssl_verify);
1450+
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, srvc->ssl_verify);
14551451

14561452
curl_easy_setopt(curl, CURLOPT_READFUNCTION, fread_buffer);
14571453

0 commit comments

Comments
 (0)