From: Michael Haggerty <mhagger@alum.mit.edu>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, Michael Haggerty <mhagger@alum.mit.edu>
Subject: [PATCH v2 09/14] imap-send.c: remove namespace fields from struct imap
Date: Tue, 15 Jan 2013 09:06:27 +0100 [thread overview]
Message-ID: <1358237193-8887-10-git-send-email-mhagger@alum.mit.edu> (raw)
In-Reply-To: <1358237193-8887-1-git-send-email-mhagger@alum.mit.edu>
They are unused, and their removal means that a bunch of list-related
infrastructure can be disposed of.
It might be that the "NAMESPACE" response that is now skipped over in
get_cmd_result() should never be sent by the server. But somebody
would have to check the IMAP protocol and how we interact with the
server to be sure. So for now I am leaving that branch of the "if"
statement there.
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
---
imap-send.c | 75 ++++++++-----------------------------------------------------
1 file changed, 9 insertions(+), 66 deletions(-)
diff --git a/imap-send.c b/imap-send.c
index 29e4037..ff44013 100644
--- a/imap-send.c
+++ b/imap-send.c
@@ -99,15 +99,6 @@ static struct imap_server_conf server = {
NULL, /* auth_method */
};
-#define NIL (void *)0x1
-#define LIST (void *)0x2
-
-struct imap_list {
- struct imap_list *next, *child;
- char *val;
- int len;
-};
-
struct imap_socket {
int fd[2];
SSL *ssl;
@@ -124,7 +115,6 @@ struct imap_cmd;
struct imap {
int uidnext; /* from SELECT responses */
- struct imap_list *ns_personal, *ns_other, *ns_shared; /* NAMESPACE info */
unsigned caps, rcaps; /* CAPABILITY results */
/* command queue */
int nexttag, num_in_progress, literal_pending;
@@ -554,34 +544,9 @@ static int imap_exec_m(struct imap_store *ctx, struct imap_cmd_cb *cb,
}
}
-static int is_atom(struct imap_list *list)
-{
- return list && list->val && list->val != NIL && list->val != LIST;
-}
-
-static int is_list(struct imap_list *list)
-{
- return list && list->val == LIST;
-}
-
-static void free_list(struct imap_list *list)
-{
- struct imap_list *tmp;
-
- for (; list; list = tmp) {
- tmp = list->next;
- if (is_list(list))
- free_list(list->child);
- else if (is_atom(list))
- free(list->val);
- free(list);
- }
-}
-
-static int parse_imap_list_l(char **sp, struct imap_list **curp, int level)
+static int skip_imap_list_l(char **sp, int level)
{
- struct imap_list *cur;
- char *s = *sp, *p;
+ char *s = *sp;
for (;;) {
while (isspace((unsigned char)*s))
@@ -590,36 +555,23 @@ static int parse_imap_list_l(char **sp, struct imap_list **curp, int level)
s++;
break;
}
- *curp = cur = xmalloc(sizeof(*cur));
- curp = &cur->next;
- cur->val = NULL; /* for clean bail */
if (*s == '(') {
/* sublist */
s++;
- cur->val = LIST;
- if (parse_imap_list_l(&s, &cur->child, level + 1))
+ if (skip_imap_list_l(&s, level + 1))
goto bail;
} else if (*s == '"') {
/* quoted string */
s++;
- p = s;
for (; *s != '"'; s++)
if (!*s)
goto bail;
- cur->len = s - p;
s++;
- cur->val = xmemdupz(p, cur->len);
} else {
/* atom */
- p = s;
for (; *s && !isspace((unsigned char)*s); s++)
if (level && *s == ')')
break;
- cur->len = s - p;
- if (cur->len == 3 && !memcmp("NIL", p, 3))
- cur->val = NIL;
- else
- cur->val = xmemdupz(p, cur->len);
}
if (!level)
@@ -628,22 +580,15 @@ static int parse_imap_list_l(char **sp, struct imap_list **curp, int level)
goto bail;
}
*sp = s;
- *curp = NULL;
return 0;
bail:
- *curp = NULL;
return -1;
}
-static struct imap_list *parse_list(char **sp)
+static void skip_list(char **sp)
{
- struct imap_list *head;
-
- if (!parse_imap_list_l(sp, &head, 0))
- return head;
- free_list(head);
- return NULL;
+ skip_imap_list_l(sp, 0);
}
static void parse_capability(struct imap *imap, char *cmd)
@@ -722,9 +667,10 @@ static int get_cmd_result(struct imap_store *ctx, struct imap_cmd *tcmd)
}
if (!strcmp("NAMESPACE", arg)) {
- imap->ns_personal = parse_list(&cmd);
- imap->ns_other = parse_list(&cmd);
- imap->ns_shared = parse_list(&cmd);
+ /* rfc2342 NAMESPACE response. */
+ skip_list(&cmd); /* Personal mailboxes */
+ skip_list(&cmd); /* Others' mailboxes */
+ skip_list(&cmd); /* Shared mailboxes */
} else if (!strcmp("OK", arg) || !strcmp("BAD", arg) ||
!strcmp("NO", arg) || !strcmp("BYE", arg)) {
if ((resp = parse_response_code(ctx, NULL, cmd)) != RESP_OK)
@@ -834,9 +780,6 @@ static void imap_close_server(struct imap_store *ictx)
imap_exec(ictx, NULL, "LOGOUT");
socket_shutdown(&imap->buf.sock);
}
- free_list(imap->ns_personal);
- free_list(imap->ns_other);
- free_list(imap->ns_shared);
free(imap);
}
--
1.8.0.3
next prev parent reply other threads:[~2013-01-15 8:07 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-15 8:06 [PATCH v2 00/14] Remove unused code from imap-send.c Michael Haggerty
2013-01-15 8:06 ` [PATCH v2 01/14] imap-send.c: remove msg_data::flags, which was always zero Michael Haggerty
2013-01-15 8:06 ` [PATCH v2 02/14] imap-send.c: remove struct msg_data Michael Haggerty
2013-01-15 8:06 ` [PATCH v2 03/14] iamp-send.c: remove unused struct imap_store_conf Michael Haggerty
2013-01-15 8:06 ` [PATCH v2 04/14] imap-send.c: remove struct store_conf Michael Haggerty
2013-01-15 8:06 ` [PATCH v2 05/14] imap-send.c: remove struct message Michael Haggerty
2013-01-15 8:06 ` [PATCH v2 06/14] imap-send.c: remove some unused fields from struct store Michael Haggerty
2013-01-15 20:32 ` Jonathan Nieder
2013-01-15 22:30 ` Junio C Hamano
2013-01-15 22:59 ` Jonathan Nieder
2013-01-16 8:23 ` Michael Haggerty
2013-01-15 8:06 ` [PATCH v2 07/14] imap-send.c: inline imap_parse_list() in imap_list() Michael Haggerty
2013-01-15 18:51 ` Matt Kraai
2013-01-16 8:26 ` Michael Haggerty
2013-01-16 15:34 ` Junio C Hamano
2013-01-17 4:43 ` Michael Haggerty
2013-01-15 8:06 ` [PATCH v2 08/14] imap-send.c: remove struct imap argument to parse_imap_list_l() Michael Haggerty
2013-01-15 8:06 ` Michael Haggerty [this message]
2013-01-15 8:06 ` [PATCH v2 10/14] imap-send.c: remove unused field imap_store::trashnc Michael Haggerty
2013-01-15 8:06 ` [PATCH v2 11/14] imap-send.c: use struct imap_store instead of struct store Michael Haggerty
2013-01-15 8:06 ` [PATCH v2 12/14] imap-send.c: remove unused field imap_store::uidvalidity Michael Haggerty
2013-01-15 8:06 ` [PATCH v2 13/14] imap-send.c: fold struct store into struct imap_store Michael Haggerty
2013-01-15 8:06 ` [PATCH v2 14/14] imap-send.c: simplify logic in lf_to_crlf() Michael Haggerty
2013-01-15 14:42 ` [PATCH v2 00/14] Remove unused code from imap-send.c Jeff King
2013-01-15 20:49 ` Jonathan Nieder
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1358237193-8887-10-git-send-email-mhagger@alum.mit.edu \
--to=mhagger@alum.mit.edu \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).