⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 browse.c

📁 mutt-1.5.12 源代码。linux 下邮件接受的工具。
💻 C
📖 第 1 页 / 共 2 页
字号:
}int imap_mailbox_rename(const char* mailbox){  IMAP_DATA* idata;  IMAP_MBOX mx;  char buf[LONG_STRING];  char newname[SHORT_STRING];  if (imap_parse_path (mailbox, &mx) < 0)  {    dprint (1, (debugfile, "imap_mailbox_rename: Bad source mailbox %s\n",      mailbox));    return -1;  }  if (!(idata = imap_conn_find (&mx.account, M_IMAP_CONN_NONEW)))  {    dprint (1, (debugfile, "imap_mailbox_rename: Couldn't find open connection to %s", mx.account.host));    goto fail;  }  snprintf(buf, sizeof (buf), _("Rename mailbox %s to: "), mx.mbox);   if (mutt_get_field (buf, newname, sizeof (newname), M_FILE) < 0)    goto fail;  if (!mutt_strlen (newname))  {    mutt_error (_("Mailbox must have a name."));    mutt_sleep (1);    goto fail;  }  if (imap_rename_mailbox (idata, &mx, newname) < 0) {    mutt_error (_("Rename failed: %s"), imap_get_qualifier (idata->buf));    mutt_sleep (1);    goto fail;  }  mutt_message (_("Mailbox renamed."));  mutt_sleep (0);  FREE (&mx.mbox);  return 0; fail:  FREE (&mx.mbox);  return -1;}static int browse_add_list_result (IMAP_DATA* idata, const char* cmd,  struct browser_state* state, short isparent){  IMAP_LIST list;  IMAP_MBOX mx;  int rc;  if (imap_parse_path (state->folder, &mx))  {    dprint (2, (debugfile,      "browse_add_list_result: current folder %s makes no sense\n", state->folder));    return -1;  }  imap_cmd_start (idata, cmd);  idata->cmddata = &list;  do  {    rc = imap_cmd_step (idata);    if (rc == IMAP_CMD_CONTINUE && list.name)    {      /* Let a parent folder never be selectable for navigation */      if (isparent)        list.noselect = 1;      /* prune current folder from output */      if (isparent || mutt_strncmp (list.name, mx.mbox, strlen (list.name)))        imap_add_folder (list.delim, list.name, list.noselect, list.noinferiors,                         state, isparent);    }  }  while (rc == IMAP_CMD_CONTINUE);  idata->cmddata = NULL;  FREE (&mx.mbox);  return rc == IMAP_CMD_OK ? 0 : -1;}/* imap_add_folder: add a folder name to the browser list, formatting it as *   necessary. */static void imap_add_folder (char delim, char *folder, int noselect,  int noinferiors, struct browser_state *state, short isparent){  char tmp[LONG_STRING];  char relpath[LONG_STRING];  IMAP_MBOX mx;  if (imap_parse_path (state->folder, &mx))    return;  imap_unmunge_mbox_name (folder);  if (state->entrylen + 1 == state->entrymax)  {    safe_realloc (&state->entry,      sizeof (struct folder_file) * (state->entrymax += 256));    memset (state->entry + state->entrylen, 0,      (sizeof (struct folder_file) * (state->entrymax - state->entrylen)));  }  /* render superiors as unix-standard ".." */  if (isparent)    strfcpy (relpath, "../", sizeof (relpath));  /* strip current folder from target, to render a relative path */  else if (!mutt_strncmp (mx.mbox, folder, mutt_strlen (mx.mbox)))    strfcpy (relpath, folder + mutt_strlen (mx.mbox), sizeof (relpath));  else    strfcpy (relpath, folder, sizeof (relpath));  /* apply filemask filter. This should really be done at menu setup rather   * than at scan, since it's so expensive to scan. But that's big changes   * to browser.c */  if (!((regexec (Mask.rx, relpath, 0, NULL, 0) == 0) ^ Mask.not))  {    FREE (&mx.mbox);    return;  }  imap_qualify_path (tmp, sizeof (tmp), &mx, folder);  (state->entry)[state->entrylen].name = safe_strdup (tmp);  /* mark desc with delim in browser if it can have subfolders */  if (!isparent && !noinferiors && strlen (relpath) < sizeof (relpath) - 1)  {    relpath[strlen (relpath) + 1] = '\0';    relpath[strlen (relpath)] = delim;  }    (state->entry)[state->entrylen].desc = safe_strdup (relpath);  (state->entry)[state->entrylen].imap = 1;  /* delimiter at the root is useless. */  if (folder[0] == '\0')    delim = '\0';  (state->entry)[state->entrylen].delim = delim;  (state->entry)[state->entrylen].selectable = !noselect;  (state->entry)[state->entrylen].inferiors = !noinferiors;  (state->entrylen)++;  FREE (&mx.mbox);}static int compare_names(struct folder_file *a, struct folder_file *b) {  return mutt_strcmp(a->name, b->name);}static int browse_get_namespace (IMAP_DATA* idata, char* nsbuf, int nsblen,  IMAP_NAMESPACE_INFO* nsi, int nsilen, int* nns){  char *s;  int n;  char ns[LONG_STRING];  char delim = '/';  int type;  int nsbused = 0;  int rc;  *nns = 0;  nsbuf[nsblen-1] = '\0';  imap_cmd_start (idata, "NAMESPACE");    do   {    if ((rc = imap_cmd_step (idata)) != IMAP_CMD_CONTINUE)      break;    s = imap_next_word (idata->buf);    if (ascii_strncasecmp ("NAMESPACE", s, 9) == 0)    {      /* There are three sections to the response, User, Other, Shared,       * and maybe more by extension */      for (type = IMAP_NS_PERSONAL; *s; type++)      {	s = imap_next_word (s);	if (*s && ascii_strncasecmp (s, "NIL", 3))	{	  s++;	  while (*s && *s != ')')	  {	    s++; /* skip ( */	    /* copy namespace */	    n = 0;	    delim = '\0';	    if (*s == '\"')	    {	      s++;	      while (*s && *s != '\"' && n < sizeof (ns) - 1) 	      {		if (*s == '\\')		  s++;		ns[n++] = *s;		s++;	      }	      if (*s)		s++;	    }	    else	      while (*s && !ISSPACE (*s) && n < sizeof (ns) - 1)	      {		ns[n++] = *s;		s++;	      }	    ns[n] = '\0';	    if (n == sizeof (ns) - 1)	      dprint (1, (debugfile, "browse_get_namespace: too long: [%s]\n", ns));	    /* delim? */	    s = imap_next_word (s);	    /* delimiter is meaningless if namespace is "". Why does	     * Cyrus provide one?! */	    if (n && *s && *s == '\"')	    {	      if (s[1] && s[2] == '\"')		delim = s[1];	      else if (s[1] && s[1] == '\\' && s[2] && s[3] == '\"')		delim = s[2];	    }	    /* skip "" namespaces, they are already listed at the root */	    if ((ns[0] != '\0') && (nsbused < nsblen) && (*nns < nsilen))	    {	      dprint (3, (debugfile, "browse_get_namespace: adding %s\n", ns));	      nsi->type = type;	      /* Cyrus doesn't append the delimiter to the namespace,	       * but UW-IMAP does. We'll strip it here and add it back	       * as if it were a normal directory, from the browser */	      if (n && (ns[n-1] == delim))		ns[--n] = '\0';	      strncpy (nsbuf+nsbused,ns,nsblen-nsbused-1);	      nsi->prefix = nsbuf+nsbused;	      nsbused += n+1;	      nsi->delim = delim;	      nsi++;	      (*nns)++;	    }	    while (*s && *s != ')') 	      s++;	    if (*s)	      s++;	  }	}      }    }  }  while (rc == IMAP_CMD_CONTINUE);  if (rc != IMAP_CMD_OK)    return -1;  return 0;}/* Check which namespaces have contents */static int browse_verify_namespace (IMAP_DATA* idata,  IMAP_NAMESPACE_INFO *nsi, int nns){  char buf[LONG_STRING];  IMAP_LIST list;  int i = 0;  int rc;  for (i = 0; i < nns; i++, nsi++)  {    /* Cyrus gives back nothing if the % isn't added. This may return lots     * of data in some cases, I guess, but I currently feel that's better     * than invisible namespaces */    if (nsi->delim)      snprintf (buf, sizeof (buf), "%s \"\" \"%s%c%%\"",		option (OPTIMAPLSUB) ? "LSUB" : "LIST", nsi->prefix,		nsi->delim);    else      snprintf (buf, sizeof (buf), "%s \"\" \"%s%%\"",		option (OPTIMAPLSUB) ? "LSUB" : "LIST", nsi->prefix);    imap_cmd_start (idata, buf);    idata->cmddata = &list;    nsi->listable = 0;    nsi->home_namespace = 0;    do     {      rc = imap_cmd_step (idata);      if (rc == IMAP_CMD_CONTINUE && list.name)        nsi->listable |= (list.name[0] != '\0');    }    while (rc == IMAP_CMD_CONTINUE);    idata->cmddata = NULL;    if (rc != IMAP_CMD_OK)      return -1;  }  return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -