X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=imap-send.c;h=9992233b96ba50f5dec590e3cebb4e628f3d5c5a;hb=36612e4daf8b5b5eaf16315aa13c66925f878cd6;hp=fa703838cf3374a52f8a1b6fecf455fb0ca4fef9;hpb=80b5b6985510406dfb4016cada8013832078930c;p=git.git diff --git a/imap-send.c b/imap-send.c index fa703838c..9992233b9 100644 --- a/imap-send.c +++ b/imap-send.c @@ -41,28 +41,6 @@ struct store_conf { unsigned trash_remote_new:1, trash_only_new:1; }; -struct string_list { - struct string_list *next; - char string[1]; -}; - -struct channel_conf { - struct channel_conf *next; - char *name; - struct store_conf *master, *slave; - char *master_name, *slave_name; - char *sync_state; - struct string_list *patterns; - int mops, sops; - unsigned max_messages; /* for slave only */ -}; - -struct group_conf { - struct group_conf *next; - char *name; - struct string_list *channels; -}; - /* For message->status */ #define M_RECENT (1<<0) /* unsyncable flag; maildir_* depend on this being 1<<0 */ #define M_DEAD (1<<1) /* expunged */ @@ -70,7 +48,6 @@ struct group_conf { struct message { struct message *next; - /* struct string_list *keywords; */ size_t size; /* zero implies "not fetched" */ int uid; unsigned char flags, status; @@ -230,7 +207,7 @@ enum CAPABILITY { LITERALPLUS, NAMESPACE, STARTTLS, - AUTH_CRAM_MD5, + AUTH_CRAM_MD5 }; static const char *cap_list[] = { @@ -543,9 +520,13 @@ static struct imap_cmd *v_issue_imap_cmd(struct imap_store *ctx, while (imap->literal_pending) get_cmd_result(ctx, NULL); - bufl = nfsnprintf(buf, sizeof(buf), cmd->cb.data ? CAP(LITERALPLUS) ? - "%d %s{%d+}\r\n" : "%d %s{%d}\r\n" : "%d %s\r\n", - cmd->tag, cmd->cmd, cmd->cb.dlen); + if (!cmd->cb.data) + bufl = nfsnprintf(buf, sizeof(buf), "%d %s\r\n", cmd->tag, cmd->cmd); + else + bufl = nfsnprintf(buf, sizeof(buf), "%d %s{%d%s}\r\n", + cmd->tag, cmd->cmd, cmd->cb.dlen, + CAP(LITERALPLUS) ? "+" : ""); + if (Verbose) { if (imap->num_in_progress) printf("(%d in progress) ", imap->num_in_progress); @@ -1065,7 +1046,7 @@ static struct store *imap_open_store(struct imap_server_conf *srvc) if (srvc->tunnel) { const char *argv[] = { srvc->tunnel, NULL }; - struct child_process tunnel = {0}; + struct child_process tunnel = {NULL}; imap_info("Starting tunnel '%s'... ", srvc->tunnel); @@ -1086,7 +1067,7 @@ static struct store *imap_open_store(struct imap_server_conf *srvc) int gai; char portstr[6]; - snprintf(portstr, sizeof(portstr), "%hu", srvc->port); + snprintf(portstr, sizeof(portstr), "%d", srvc->port); memset(&hints, 0, sizeof(hints)); hints.ai_socktype = SOCK_STREAM; @@ -1189,13 +1170,13 @@ static struct store *imap_open_store(struct imap_server_conf *srvc) if (!preauth) { #ifndef NO_OPENSSL if (!srvc->use_ssl && CAP(STARTTLS)) { - if (imap_exec(ctx, 0, "STARTTLS") != RESP_OK) + if (imap_exec(ctx, NULL, "STARTTLS") != RESP_OK) goto bail; if (ssl_socket_connect(&imap->buf.sock, 1, srvc->ssl_verify)) goto bail; /* capabilities may have changed, so get the new capabilities */ - if (imap_exec(ctx, 0, "CAPABILITY") != RESP_OK) + if (imap_exec(ctx, NULL, "CAPABILITY") != RESP_OK) goto bail; } #endif @@ -1207,7 +1188,7 @@ static struct store *imap_open_store(struct imap_server_conf *srvc) if (!srvc->pass) { char prompt[80]; sprintf(prompt, "Password (%s@%s): ", srvc->user, srvc->host); - arg = getpass(prompt); + arg = git_getpass(prompt); if (!arg) { perror("getpass"); exit(1); @@ -1226,9 +1207,6 @@ static struct store *imap_open_store(struct imap_server_conf *srvc) fprintf(stderr, "Skipping account %s@%s, server forbids LOGIN\n", srvc->user, srvc->host); goto bail; } - if (!imap->buf.sock.ssl) - imap_warn("*** IMAP Warning *** Password is being " - "sent in the clear\n"); if (srvc->auth_method) { struct imap_cmd_cb cb; @@ -1253,6 +1231,9 @@ static struct store *imap_open_store(struct imap_server_conf *srvc) goto bail; } } else { + if (!imap->buf.sock.ssl) + imap_warn("*** IMAP Warning *** Password is being " + "sent in the clear\n"); if (imap_exec(ctx, NULL, "LOGIN \"%s\" \"%s\"", srvc->user, srvc->pass) != RESP_OK) { fprintf(stderr, "IMAP error: LOGIN failed\n"); goto bail; @@ -1431,8 +1412,14 @@ static int count_messages(struct msg_data *msg) while (1) { if (!prefixcmp(p, "From ")) { + p = strstr(p+5, "\nFrom: "); + if (!p) break; + p = strstr(p+7, "\nDate: "); + if (!p) break; + p = strstr(p+7, "\nSubject: "); + if (!p) break; + p += 10; count++; - p += 5; } p = strstr(p+5, "\nFrom "); if (!p)