imap-send.c: fold struct store into struct imap_store

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Michael Haggerty committed Jan 15, 2013 at 09:06 UTC 636fd66bc18d7563b9260485a9974da67a805514
1 file changed +7 -11
imap-send.c
+7 -11
@@ -33,12 +33,6 @@ typedef void *SSL;
33 #include <openssl/hmac.h>
34 #endif
35
36 -struct store {
37 - /* currently open mailbox */
38 - const char *name; /* foreign! maybe preset? */
39 - int uidvalidity;
40 -};
41 -
36 static const char imap_send_usage[] = "git imap-send < <mbox>";
37
38 #undef DRV_OK
@@ -123,7 +117,9 @@ struct imap {
117 };
118
119 struct imap_store {
126 - struct store gen;
120 + /* currently open mailbox */
121 + const char *name; /* foreign! maybe preset? */
122 + int uidvalidity;
123 struct imap *imap;
124 const char *prefix;
125 };
@@ -618,7 +614,7 @@ static int parse_response_code(struct imap_store *ctx, struct imap_cmd_cb *cb,
614 *p++ = 0;
615 arg = next_arg(&s);
616 if (!strcmp("UIDVALIDITY", arg)) {
621 - if (!(arg = next_arg(&s)) || !(ctx->gen.uidvalidity = atoi(arg))) {
617 + if (!(arg = next_arg(&s)) || !(ctx->uidvalidity = atoi(arg))) {
618 fprintf(stderr, "IMAP error: malformed UIDVALIDITY status\n");
619 return RESP_BAD;
620 }
@@ -636,7 +632,7 @@ static int parse_response_code(struct imap_store *ctx, struct imap_cmd_cb *cb,
632 for (; isspace((unsigned char)*p); p++);
633 fprintf(stderr, "*** IMAP ALERT *** %s\n", p);
634 } else if (cb && cb->ctx && !strcmp("APPENDUID", arg)) {
639 - if (!(arg = next_arg(&s)) || !(ctx->gen.uidvalidity = atoi(arg)) ||
635 + if (!(arg = next_arg(&s)) || !(ctx->uidvalidity = atoi(arg)) ||
636 !(arg = next_arg(&s)) || !(*(int *)cb->ctx = atoi(arg))) {
637 fprintf(stderr, "IMAP error: malformed APPENDUID status\n");
638 return RESP_BAD;
@@ -1150,7 +1146,7 @@ static int imap_store_msg(struct imap_store *ctx, struct strbuf *msg)
1146 cb.dlen = msg->len;
1147 cb.data = strbuf_detach(msg, NULL);
1148
1153 - box = ctx->gen.name;
1149 + box = ctx->name;
1150 prefix = !strcmp(box, "INBOX") ? "" : ctx->prefix;
1151 cb.create = 0;
1152 ret = imap_exec_m(ctx, &cb, "APPEND \"%s%s\" ", prefix, box);
@@ -1362,7 +1358,7 @@ int main(int argc, char **argv)
1358 }
1359
1360 fprintf(stderr, "sending %d message%s\n", total, (total != 1) ? "s" : "");
1365 - ctx->gen.name = imap_folder;
1361 + ctx->name = imap_folder;
1362 while (1) {
1363 unsigned percent = n * 100 / total;
1364