Skip to content

Commit 636fd66

Browse files
mhaggergitster
authored andcommitted
imap-send.c: fold struct store into struct imap_store
Signed-off-by: Michael Haggerty <[email protected]> Reviewed-by: Jonathan Nieder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9a08cbb commit 636fd66

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

imap-send.c

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,6 @@ typedef void *SSL;
3333
#include <openssl/hmac.h>
3434
#endif
3535

36-
struct store {
37-
/* currently open mailbox */
38-
const char *name; /* foreign! maybe preset? */
39-
int uidvalidity;
40-
};
41-
4236
static const char imap_send_usage[] = "git imap-send < <mbox>";
4337

4438
#undef DRV_OK
@@ -123,7 +117,9 @@ struct imap {
123117
};
124118

125119
struct imap_store {
126-
struct store gen;
120+
/* currently open mailbox */
121+
const char *name; /* foreign! maybe preset? */
122+
int uidvalidity;
127123
struct imap *imap;
128124
const char *prefix;
129125
};
@@ -618,7 +614,7 @@ static int parse_response_code(struct imap_store *ctx, struct imap_cmd_cb *cb,
618614
*p++ = 0;
619615
arg = next_arg(&s);
620616
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))) {
622618
fprintf(stderr, "IMAP error: malformed UIDVALIDITY status\n");
623619
return RESP_BAD;
624620
}
@@ -636,7 +632,7 @@ static int parse_response_code(struct imap_store *ctx, struct imap_cmd_cb *cb,
636632
for (; isspace((unsigned char)*p); p++);
637633
fprintf(stderr, "*** IMAP ALERT *** %s\n", p);
638634
} 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)) ||
640636
!(arg = next_arg(&s)) || !(*(int *)cb->ctx = atoi(arg))) {
641637
fprintf(stderr, "IMAP error: malformed APPENDUID status\n");
642638
return RESP_BAD;
@@ -1150,7 +1146,7 @@ static int imap_store_msg(struct imap_store *ctx, struct strbuf *msg)
11501146
cb.dlen = msg->len;
11511147
cb.data = strbuf_detach(msg, NULL);
11521148

1153-
box = ctx->gen.name;
1149+
box = ctx->name;
11541150
prefix = !strcmp(box, "INBOX") ? "" : ctx->prefix;
11551151
cb.create = 0;
11561152
ret = imap_exec_m(ctx, &cb, "APPEND \"%s%s\" ", prefix, box);
@@ -1362,7 +1358,7 @@ int main(int argc, char **argv)
13621358
}
13631359

13641360
fprintf(stderr, "sending %d message%s\n", total, (total != 1) ? "s" : "");
1365-
ctx->gen.name = imap_folder;
1361+
ctx->name = imap_folder;
13661362
while (1) {
13671363
unsigned percent = n * 100 / total;
13681364

0 commit comments

Comments
 (0)