From f9dc5d65ca31cb79893e1296efe37727bf58f3f3 Mon Sep 17 00:00:00 2001 From: Bernhard Reiter Date: Wed, 13 Aug 2014 19:30:43 +0200 Subject: git-imap-send: simplify tunnel construction Signed-off-by: Bernhard Reiter Reviewed-by: Jeff King Signed-off-by: Junio C Hamano --- imap-send.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'imap-send.c') diff --git a/imap-send.c b/imap-send.c index 524fbabc96..fb01a9c9a5 100644 --- a/imap-send.c +++ b/imap-send.c @@ -961,17 +961,16 @@ static struct imap_store *imap_open_store(struct imap_server_conf *srvc) /* open connection to IMAP server */ if (srvc->tunnel) { - const char *argv[] = { srvc->tunnel, NULL }; struct child_process tunnel = {NULL}; imap_info("Starting tunnel '%s'... ", srvc->tunnel); - tunnel.argv = argv; + argv_array_push(&tunnel.args, srvc->tunnel); tunnel.use_shell = 1; tunnel.in = -1; tunnel.out = -1; if (start_command(&tunnel)) - die("cannot start proxy %s", argv[0]); + die("cannot start proxy %s", srvc->tunnel); imap->buf.sock.fd[0] = tunnel.out; imap->buf.sock.fd[1] = tunnel.in; -- cgit v1.2.3 From 3918057164a8060082b828c0ac1ce25ad6a86d38 Mon Sep 17 00:00:00 2001 From: Bernhard Reiter Date: Tue, 19 Aug 2014 23:27:11 +0200 Subject: imap-send.c: imap_folder -> imap_server_conf.folder Rename the imap_folder variable to folder and make it a member of struct imap_server_conf. Signed-off-by: Bernhard Reiter Signed-off-by: Junio C Hamano --- imap-send.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'imap-send.c') diff --git a/imap-send.c b/imap-send.c index fb01a9c9a5..05a02b51ca 100644 --- a/imap-send.c +++ b/imap-send.c @@ -69,6 +69,7 @@ struct imap_server_conf { char *tunnel; char *host; int port; + char *folder; char *user; char *pass; int use_ssl; @@ -82,6 +83,7 @@ static struct imap_server_conf server = { NULL, /* tunnel */ NULL, /* host */ 0, /* port */ + NULL, /* folder */ NULL, /* user */ NULL, /* pass */ 0, /* use_ssl */ @@ -1323,8 +1325,6 @@ static int split_msg(struct strbuf *all_msgs, struct strbuf *msg, int *ofs) return 1; } -static char *imap_folder; - static int git_imap_config(const char *key, const char *val, void *cb) { if (!skip_prefix(key, "imap.", &key)) @@ -1339,7 +1339,7 @@ static int git_imap_config(const char *key, const char *val, void *cb) return config_error_nonbool(key); if (!strcmp("folder", key)) { - imap_folder = xstrdup(val); + server.folder = xstrdup(val); } else if (!strcmp("host", key)) { if (starts_with(val, "imap:")) val += 5; @@ -1387,7 +1387,7 @@ int main(int argc, char **argv) if (!server.port) server.port = server.use_ssl ? 993 : 143; - if (!imap_folder) { + if (!server.folder) { fprintf(stderr, "no imap store specified\n"); return 1; } @@ -1424,7 +1424,7 @@ int main(int argc, char **argv) } fprintf(stderr, "sending %d message%s\n", total, (total != 1) ? "s" : ""); - ctx->name = imap_folder; + ctx->name = server.folder; while (1) { unsigned percent = n * 100 / total; -- cgit v1.2.3 From ba9b9e124276e5d27ecf0e7701df1dedab6375c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scharfe?= Date: Sat, 30 Aug 2014 18:14:24 +0200 Subject: imap-send: simplify v_issue_imap_cmd() and get_cmd_result() using starts_with() Use starts_with() instead of memcmp() to check if NUL-terminated strings match prefixes. This gets rid of some magic string length constants. Signed-off-by: Rene Scharfe Signed-off-by: Junio C Hamano --- imap-send.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'imap-send.c') diff --git a/imap-send.c b/imap-send.c index 05a02b51ca..44fd5249e2 100644 --- a/imap-send.c +++ b/imap-send.c @@ -526,7 +526,7 @@ static struct imap_cmd *v_issue_imap_cmd(struct imap_store *ctx, if (Verbose) { if (imap->num_in_progress) printf("(%d in progress) ", imap->num_in_progress); - if (memcmp(cmd->cmd, "LOGIN", 5)) + if (!starts_with(cmd->cmd, "LOGIN")) printf(">>> %s", buf); else printf(">>> %d LOGIN \n", cmd->tag); @@ -829,7 +829,7 @@ static int get_cmd_result(struct imap_store *ctx, struct imap_cmd *tcmd) } else /*if (!strcmp("BAD", arg))*/ resp = RESP_BAD; fprintf(stderr, "IMAP command '%s' returned response (%s) - %s\n", - memcmp(cmdp->cmd, "LOGIN", 5) ? + !starts_with(cmdp->cmd, "LOGIN") ? cmdp->cmd : "LOGIN ", arg, cmd ? cmd : ""); } -- cgit v1.2.3