+static void cmd_parse_lsub (IMAP_DATA* idata, char* s) {
+ char buf[STRING];
+ char errstr[STRING];
+ BUFFER err, token;
+ ciss_url_t url;
+ char *ep;
+
+ if (!option (OPTIMAPCHECKSUBSCRIBED))
+ return;
+
+ s = imap_next_word (s); /* flags */
+
+ if (*s != '(') {
+ debug_print (1, ("Bad LSUB response\n"));
+ return;
+ }
+
+ s++;
+ ep = s;
+ for (ep = s; *ep && *ep != ')'; ep++);
+ do {
+ if (!ascii_strncasecmp (s, "\\NoSelect", 9))
+ return;
+ while (s < ep && *s != ' ' && *s != ')')
+ s++;
+ if (*s == ' ')
+ s++;
+ } while (s != ep);
+
+ s = imap_next_word (s); /* delim */
+ s = imap_next_word (s); /* name */
+
+ if (s) {
+ imap_unmunge_mbox_name (s);
+ debug_print (2, ("Subscribing to %s\n", s));
+
+ strfcpy (buf, "mailboxes \"", sizeof (buf));
+ mutt_account_tourl (&idata->conn->account, &url);
+ url.path = s;
+ if (!str_cmp (url.user, ImapUser))
+ url.user = NULL;
+ url_ciss_tostring (&url, buf + 11, sizeof (buf) - 10, 0);
+ str_cat (buf, sizeof (buf), "\"");
+ memset (&token, 0, sizeof (token));
+ err.data = errstr;
+ err.dsize = sizeof (errstr);
+ if (mutt_parse_rc_line (buf, &token, &err))
+ debug_print (1, ("Error adding subscribed mailbox: %s\n", errstr));
+ mem_free (&token.data);
+ }
+ else
+ debug_print (1, ("Bad LSUB response\n"));
+}
+