MCPcopy Create free account
hub / github.com/git/git / get_cmd_result

Function get_cmd_result

imap-send.c:730–848  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

728}
729
730static int get_cmd_result(struct imap_store *ctx, struct imap_cmd *tcmd)
731{
732 struct imap *imap = ctx->imap;
733 struct imap_cmd *cmdp, **pcmdp;
734 char *cmd;
735 const char *arg, *arg1;
736 int n, resp, resp2, tag;
737
738 for (;;) {
739 if (buffer_gets(&imap->buf, &cmd))
740 return RESP_BAD;
741
742 arg = next_arg(&cmd);
743 if (!arg) {
744 fprintf(stderr, "IMAP error: empty response\n");
745 return RESP_BAD;
746 }
747 if (*arg == '*') {
748 arg = next_arg(&cmd);
749 if (!arg) {
750 fprintf(stderr, "IMAP error: unable to parse untagged response\n");
751 return RESP_BAD;
752 }
753
754 if (!strcmp("NAMESPACE", arg)) {
755 /* rfc2342 NAMESPACE response. */
756 skip_list(&cmd); /* Personal mailboxes */
757 skip_list(&cmd); /* Others' mailboxes */
758 skip_list(&cmd); /* Shared mailboxes */
759 } else if (!strcmp("OK", arg) || !strcmp("BAD", arg) ||
760 !strcmp("NO", arg) || !strcmp("BYE", arg)) {
761 if ((resp = parse_response_code(ctx, NULL, cmd)) != RESP_OK)
762 return resp;
763 } else if (!strcmp("CAPABILITY", arg)) {
764 parse_capability(imap, cmd);
765 } else if ((arg1 = next_arg(&cmd))) {
766 ; /*
767 * Unhandled response-data with at least two words.
768 * Ignore it.
769 *
770 * NEEDSWORK: Previously this case handled '<num> EXISTS'
771 * and '<num> RECENT' but as a probably-unintended side
772 * effect it ignores other unrecognized two-word
773 * responses. imap-send doesn't ever try to read
774 * messages or mailboxes these days, so consider
775 * eliminating this case.
776 */
777 } else {
778 fprintf(stderr, "IMAP error: unable to parse untagged response\n");
779 return RESP_BAD;
780 }
781 } else if (!imap->in_progress) {
782 fprintf(stderr, "IMAP error: unexpected reply: %s %s\n", arg, cmd ? cmd : "");
783 return RESP_BAD;
784 } else if (*arg == '+') {
785 /* This can happen only with the last command underway, as
786 it enforces a round-trip. */
787 cmdp = (struct imap_cmd *)((char *)imap->in_progress_append -

Callers 3

issue_imap_cmdFunction · 0.85
imap_execFunction · 0.85
imap_exec_mFunction · 0.85

Calls 8

buffer_getsFunction · 0.85
next_argFunction · 0.85
skip_listFunction · 0.85
parse_response_codeFunction · 0.85
socket_writeFunction · 0.85
strtol_iFunction · 0.85
starts_withFunction · 0.85
parse_capabilityFunction · 0.70

Tested by

no test coverage detected