X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=browser.c;h=c46c89ef1650d931c92a8960a7a9e58d30988fa8;hp=1dbc64433aaf88cd408f9f97d28aa34a8faf6fac;hb=238b70e39b78f585c586bd51aef41988b3cc73d1;hpb=9c02039bb94c2fb846e0226c321c7dd79df455c4 diff --git a/browser.c b/browser.c index 1dbc644..c46c89e 100644 --- a/browser.c +++ b/browser.c @@ -11,25 +11,31 @@ # include "config.h" #endif +#include +#include +#include +#include + #include "mutt.h" +#include "enter.h" +#include "mx.h" #include "mutt_curses.h" #include "mutt_menu.h" #include "buffy.h" #include "mapping.h" #include "sort.h" -#include "mailbox.h" #include "browser.h" +#include "attach.h" + #ifdef USE_IMAP #include "imap.h" +#include "imap/mx_imap.h" #endif #ifdef USE_NNTP #include "nntp.h" #endif #include "sidebar.h" -#include "lib/mem.h" -#include "lib/intl.h" -#include "lib/str.h" #include "lib/list.h" #include @@ -45,7 +51,7 @@ static struct mapping_t FolderHelp[] = { {N_("Chdir"), OP_CHANGE_DIRECTORY}, {N_("Mask"), OP_ENTER_MASK}, {N_("Help"), OP_HELP}, - {NULL} + {NULL, OP_NULL} }; #ifdef USE_NNTP @@ -57,7 +63,7 @@ static struct mapping_t FolderNewsHelp[] = { {N_("Catchup"), OP_CATCHUP}, {N_("Mask"), OP_ENTER_MASK}, {N_("Help"), OP_HELP}, - {NULL} + {NULL, OP_NULL} }; #endif @@ -75,14 +81,14 @@ static void destroy_state (struct browser_state *state) int c; for (c = 0; c < state->entrylen; c++) { - FREE (&((state->entry)[c].name)); - FREE (&((state->entry)[c].desc)); - FREE (&((state->entry)[c].st)); + p_delete(&((state->entry)[c].name)); + p_delete(&((state->entry)[c].desc)); + p_delete(&((state->entry)[c].st)); } #ifdef USE_IMAP - FREE (&state->folder); + p_delete(&state->folder); #endif - FREE (&state->entry); + p_delete(&state->entry); } static int browser_compare_subject (const void *a, const void *b) @@ -90,7 +96,7 @@ static int browser_compare_subject (const void *a, const void *b) struct folder_file *pa = (struct folder_file *) a; struct folder_file *pb = (struct folder_file *) b; - int r = mutt_strcoll (pa->name, pb->name); + int r = strcoll(NONULL(pa->name), NONULL(pb->name)); return ((BrowserSort & SORT_REVERSE) ? -r : r); } @@ -149,7 +155,7 @@ static int link_is_dir (const char *folder, const char *path) struct stat st; char fullpath[_POSIX_PATH_MAX]; - mutt_concat_path (fullpath, folder, path, sizeof (fullpath)); + mutt_concat_path(fullpath, sizeof(fullpath), folder, path); if (stat (fullpath, &st) == 0) return (S_ISDIR (st.st_mode)); @@ -163,8 +169,8 @@ static const char *folder_format_str (char *dest, size_t destlen, char op, const char *elsestring, unsigned long data, format_flag flags) { - char fn[SHORT_STRING], tmp[SHORT_STRING], permission[11]; - char date[16], *t_fmt; + char fn[SHORT_STRING], tmp[SHORT_STRING], permission[11], date[16]; + const char *t_fmt; time_t tnow; FOLDER *folder = (FOLDER *) data; struct passwd *pw; @@ -193,7 +199,7 @@ static const char *folder_format_str (char *dest, size_t destlen, char op, case 'f': { - char *s; + const char *s; #ifdef USE_IMAP if (folder->ff->imap) @@ -271,7 +277,7 @@ static const char *folder_format_str (char *dest, size_t destlen, char op, case 'N': #ifdef USE_IMAP - if (mx_is_imap (folder->ff->desc)) { + if (imap_is_magic (folder->ff->desc, NULL) == M_IMAP) { if (!optional) { snprintf (tmp, sizeof (tmp), "%%%sd", fmt); snprintf (dest, destlen, tmp, folder->ff->new); @@ -344,7 +350,7 @@ static const char *newsgroup_format_str (char *dest, size_t destlen, char op, break; case 'f': - strncpy (fn, folder->ff->name, sizeof (fn) - 1); + m_strcpy(fn, sizeof(fn), folder->ff->name); snprintf (tmp, sizeof (tmp), "%%%ss", fmt); snprintf (dest, destlen, tmp, fn); break; @@ -423,26 +429,22 @@ static void add_folder (MUTTMENU * m, struct browser_state *state, { if (state->entrylen == state->entrymax) { /* need to allocate more space */ - safe_realloc (&state->entry, - sizeof (struct folder_file) * (state->entrymax += 256)); - memset (&state->entry[state->entrylen], 0, - sizeof (struct folder_file) * 256); + p_realloc(&state->entry, state->entrymax += 256); + p_clear(&state->entry[state->entrylen], 256); if (m) m->data = state->entry; } if (s != NULL) { - (state->entry)[state->entrylen].mode = s->st_mode; + (state->entry)[state->entrylen].mode = s->st_mode; (state->entry)[state->entrylen].mtime = s->st_mtime; - (state->entry)[state->entrylen].size = s->st_size; - - (state->entry)[state->entrylen].st = safe_malloc (sizeof (struct stat)); - memcpy ((state->entry)[state->entrylen].st, s, sizeof (struct stat)); + (state->entry)[state->entrylen].size = s->st_size; + (state->entry)[state->entrylen].st = p_dup(s, 1); } (state->entry)[state->entrylen].new = new; - (state->entry)[state->entrylen].name = safe_strdup (name); - (state->entry)[state->entrylen].desc = safe_strdup (name); + (state->entry)[state->entrylen].name = m_strdup(name); + (state->entry)[state->entrylen].desc = m_strdup(name); #ifdef USE_IMAP (state->entry)[state->entrylen].imap = 0; #endif @@ -457,9 +459,7 @@ static void init_state (struct browser_state *state, MUTTMENU * menu) { state->entrylen = 0; state->entrymax = 256; - state->entry = - (struct folder_file *) safe_calloc (state->entrymax, - sizeof (struct folder_file)); + state->entry = p_new(struct folder_file, state->entrymax); #ifdef USE_IMAP state->imap_browse = 0; #endif @@ -477,19 +477,21 @@ static int examine_directory (MUTTMENU * menu, struct browser_state *state, NNTP_DATA *data; NNTP_SERVER *news = CurrentNewsSrv; -/* mutt_buffy_check (0); */ +/* buffy_check (0); */ init_state (state, menu); for (tmp = news->list; tmp; tmp = tmp->next) { if (!(data = (NNTP_DATA *) tmp->data)) continue; + nntp_sync_sidebar (data); if (prefix && *prefix && strncmp (prefix, data->group, - mutt_strlen (prefix)) != 0) + m_strlen(prefix)) != 0) continue; if (!((regexec (Mask.rx, data->group, 0, NULL, 0) == 0) ^ Mask.not)) continue; add_folder (menu, state, data->group, NULL, data, data->new); } + sidebar_draw (CurrentMenu); } else #endif /* USE_NNTP */ @@ -519,7 +521,7 @@ static int examine_directory (MUTTMENU * menu, struct browser_state *state, return (-1); } - mutt_buffy_check (0); + buffy_check (0); if ((dp = opendir (d)) == NULL) { mutt_perror (d); @@ -529,16 +531,16 @@ static int examine_directory (MUTTMENU * menu, struct browser_state *state, init_state (state, menu); while ((de = readdir (dp)) != NULL) { - if (mutt_strcmp (de->d_name, ".") == 0) + if (m_strcmp(de->d_name, ".") == 0) continue; /* we don't need . */ if (prefix && *prefix - && mutt_strncmp (prefix, de->d_name, mutt_strlen (prefix)) != 0) + && m_strncmp(prefix, de->d_name, m_strlen(prefix)) != 0) continue; if (!((regexec (Mask.rx, de->d_name, 0, NULL, 0) == 0) ^ Mask.not)) continue; - mutt_concat_path (buffer, d, de->d_name, sizeof (buffer)); + mutt_concat_path(buffer, sizeof(buffer), d, de->d_name); if (lstat (buffer, &s) == -1) continue; @@ -568,18 +570,18 @@ static int examine_mailboxes (MUTTMENU * menu, struct browser_state *state) NNTP_DATA *data; NNTP_SERVER *news = CurrentNewsSrv; -/* mutt_buffy_check (0); */ +/* buffy_check (0); */ init_state (state, menu); for (tmp = news->list; tmp; tmp = tmp->next) { - if ((data = (NNTP_DATA *) tmp->data) != NULL && (data->new || - (data->subscribed - && - (!option - (OPTSHOWONLYUNREAD) - || data->unread)))) + if ((data = (NNTP_DATA*) tmp->data) == NULL) + continue; + nntp_sync_sidebar (data); + if ((data->new || (data->subscribed && + (!option (OPTSHOWONLYUNREAD)|| data->unread)))) add_folder (menu, state, data->group, NULL, data, data->new); } + sidebar_draw (CurrentMenu); } else #endif @@ -589,26 +591,27 @@ static int examine_mailboxes (MUTTMENU * menu, struct browser_state *state) if (!Incoming) return (-1); - mutt_buffy_check (0); + buffy_check (0); init_state (state, menu); for (i = 0; i < Incoming->length; i++) { tmp = (BUFFY*) Incoming->data[i]; + tmp->magic = mx_get_magic (tmp->path); #ifdef USE_IMAP - if (mx_is_imap (tmp->path)) { + if (tmp->magic == M_IMAP) { add_folder (menu, state, tmp->path, NULL, NULL, tmp->new); continue; } #endif #ifdef USE_POP - if (mx_is_pop (tmp->path)) { + if (tmp->magic == M_POP) { add_folder (menu, state, tmp->path, NULL, NULL, tmp->new); continue; } #endif #ifdef USE_NNTP - if (mx_is_nntp (tmp->path)) { + if (tmp->magic == M_NNTP) { add_folder (menu, state, tmp->path, NULL, NULL, tmp->new); continue; } @@ -620,7 +623,7 @@ static int examine_mailboxes (MUTTMENU * menu, struct browser_state *state) (!S_ISLNK (s.st_mode))) continue; - strfcpy (buffer, NONULL (tmp->path), sizeof (buffer)); + m_strcpy(buffer, sizeof(buffer), NONULL(tmp->path)); mutt_pretty_mailbox (buffer); add_folder (menu, state, buffer, &s, NULL, tmp->new); @@ -685,9 +688,9 @@ static void init_menu (struct browser_state *state, MUTTMENU * menu, else #endif if (buffy) - snprintf (title, titlelen, _("Mailboxes [%d]"), mutt_buffy_check (0)); + snprintf(title, titlelen, _("Mailboxes [%d]"), buffy_check(0)); else { - strfcpy (path, LastDir, sizeof (path)); + m_strcpy(path, sizeof(path), LastDir); mutt_pretty_mailbox (path); #ifdef USE_IMAP if (state->imap_browse && option (OPTIMAPLSUB)) @@ -736,15 +739,15 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, buffy = buffy && folder; - memset (&state, 0, sizeof (struct browser_state)); + p_clear(&state, 1); if (!folder) - strfcpy (LastDirBackup, LastDir, sizeof (LastDirBackup)); + m_strcpy(LastDirBackup, sizeof(LastDirBackup), LastDir); #ifdef USE_NNTP if (option (OPTNEWS)) { if (*f) - strfcpy (prefix, f, sizeof (prefix)); + m_strcpy(prefix, sizeof(prefix), f); else { LIST *list; @@ -765,26 +768,24 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, if (*f) { mutt_expand_path (f, flen); #ifdef USE_IMAP - if (mx_is_imap (f)) { + if (imap_is_magic (f, NULL) == M_IMAP) { init_state (&state, NULL); state.imap_browse = 1; - imap_browse (f, &state); - strfcpy (LastDir, state.folder, sizeof (LastDir)); + if (!imap_browse (f, &state)) + m_strcpy(LastDir, sizeof(LastDir), state.folder); } else { #endif - for (i = mutt_strlen (f) - 1; i > 0 && f[i] != '/'; i--); + for (i = m_strlen(f) - 1; i > 0 && f[i] != '/'; i--); if (i > 0) { if (f[0] == '/') { - if (i > sizeof (LastDir) - 1) - i = sizeof (LastDir) - 1; - strncpy (LastDir, f, i); - LastDir[i] = 0; + i = MIN(sizeof(LastDir) - 1, i); + m_strcpy(LastDir, sizeof(LastDir), f); } else { - getcwd (LastDir, sizeof (LastDir)); - safe_strcat (LastDir, sizeof (LastDir), "/"); - safe_strncat (LastDir, sizeof (LastDir), f, i); + getcwd(LastDir, sizeof(LastDir)); + m_strcat(LastDir, sizeof(LastDir), "/"); + m_strncat(LastDir, sizeof(LastDir), f, i); } } else { @@ -795,9 +796,9 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, } if (i <= 0 && f[0] != '/') - strfcpy (prefix, f, sizeof (prefix)); + m_strcpy(prefix, sizeof(prefix), f); else - strfcpy (prefix, f + i + 1, sizeof (prefix)); + m_strcpy(prefix, sizeof(prefix), f + i + 1); killPrefix = 1; #ifdef USE_IMAP } @@ -807,13 +808,14 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, if (!folder) getcwd (LastDir, sizeof (LastDir)); else if (!LastDir[0]) - strfcpy (LastDir, NONULL (Maildir), sizeof (LastDir)); + m_strcpy(LastDir, sizeof(LastDir), NONULL(Maildir)); #ifdef USE_IMAP - if (!buffy && mx_is_imap (LastDir)) { + if (!buffy && imap_is_magic (LastDir, NULL) == M_IMAP) { init_state (&state, NULL); state.imap_browse = 1; imap_browse (LastDir, &state); + browser_sort (&state); } #endif } @@ -848,7 +850,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, init_menu (&state, menu, title, sizeof (title), buffy); - FOREVER { + for (;;) { switch (i = mutt_menuLoop (menu)) { case OP_GENERIC_SELECT_ENTRY: @@ -867,17 +869,17 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, ) { /* make sure this isn't a MH or maildir mailbox */ if (buffy) { - strfcpy (buf, state.entry[menu->current].name, sizeof (buf)); + m_strcpy(buf, sizeof(buf), state.entry[menu->current].name); mutt_expand_path (buf, sizeof (buf)); } #ifdef USE_IMAP else if (state.imap_browse) { - strfcpy (buf, state.entry[menu->current].name, sizeof (buf)); + m_strcpy(buf, sizeof(buf), state.entry[menu->current].name); } #endif else - mutt_concat_path (buf, LastDir, state.entry[menu->current].name, - sizeof (buf)); + mutt_concat_path(buf, sizeof(buf), LastDir, + state.entry[menu->current].name); if ((mx_get_magic (buf) <= 0) #ifdef USE_IMAP @@ -887,10 +889,10 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, char OldLastDir[_POSIX_PATH_MAX]; /* save the old directory */ - strfcpy (OldLastDir, LastDir, sizeof (OldLastDir)); + m_strcpy(OldLastDir, sizeof(OldLastDir), LastDir); - if (mutt_strcmp (state.entry[menu->current].name, "..") == 0) { - if (mutt_strcmp ("..", LastDir + mutt_strlen (LastDir) - 2) == 0) + if (m_strcmp(state.entry[menu->current].name, "..") == 0) { + if (m_strcmp("..", LastDir + m_strlen(LastDir) - 2) == 0) strcat (LastDir, "/.."); /* __STRCAT_CHECKED__ */ else { char *p = strrchr (LastDir + 1, '/'); @@ -906,8 +908,8 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, } } else if (buffy) { - strfcpy (LastDir, state.entry[menu->current].name, - sizeof (LastDir)); + m_strcpy(LastDir, sizeof(LastDir), + state.entry[menu->current].name); mutt_expand_path (LastDir, sizeof (LastDir)); } #ifdef USE_IMAP @@ -915,10 +917,10 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, int n; ciss_url_t url; - strfcpy (LastDir, state.entry[menu->current].name, - sizeof (LastDir)); + m_strcpy(LastDir, sizeof(LastDir), + state.entry[menu->current].name); /* tack on delimiter here */ - n = mutt_strlen (LastDir) + 1; + n = m_strlen(LastDir) + 1; /* special case "" needs no delimiter */ url_parse_ciss (&url, state.entry[menu->current].name); @@ -933,9 +935,9 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, else { char tmp[_POSIX_PATH_MAX]; - mutt_concat_path (tmp, LastDir, state.entry[menu->current].name, - sizeof (tmp)); - strfcpy (LastDir, tmp, sizeof (LastDir)); + mutt_concat_path(tmp, sizeof(tmp), LastDir, + state.entry[menu->current].name); + m_strcpy(LastDir, sizeof(LastDir), tmp); } destroy_state (&state); @@ -949,15 +951,16 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, init_state (&state, NULL); state.imap_browse = 1; imap_browse (LastDir, &state); + browser_sort (&state); menu->data = state.entry; } else #endif if (examine_directory (menu, &state, LastDir, prefix) == -1) { /* try to restore the old values */ - strfcpy (LastDir, OldLastDir, sizeof (LastDir)); + m_strcpy(LastDir, sizeof(LastDir), OldLastDir); if (examine_directory (menu, &state, LastDir, prefix) == -1) { - strfcpy (LastDir, NONULL (Homedir), sizeof (LastDir)); + m_strcpy(LastDir, sizeof(LastDir), NONULL(Homedir)); goto bail; } } @@ -974,15 +977,15 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, if (buffy) #endif { - strfcpy (f, state.entry[menu->current].name, flen); + m_strcpy(f, flen, state.entry[menu->current].name); mutt_expand_path (f, flen); } #ifdef USE_IMAP else if (state.imap_browse) - strfcpy (f, state.entry[menu->current].name, flen); + m_strcpy(f, flen, state.entry[menu->current].name); #endif else - mutt_concat_path (f, LastDir, state.entry[menu->current].name, flen); + mutt_concat_path(f, flen, LastDir, state.entry[menu->current].name); /* Fall through to OP_EXIT */ @@ -994,24 +997,24 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, if (menu->tagged) { *numfiles = menu->tagged; - tfiles = safe_calloc (*numfiles, sizeof (char *)); + tfiles = p_new(char *, *numfiles); for (i = 0, j = 0; i < state.entrylen; i++) { struct folder_file ff = state.entry[i]; char full[_POSIX_PATH_MAX]; if (ff.tagged) { - mutt_concat_path (full, LastDir, ff.name, sizeof (full)); + mutt_concat_path(full, sizeof(full), LastDir, ff.name); mutt_expand_path (full, sizeof (full)); - tfiles[j++] = safe_strdup (full); + tfiles[j++] = m_strdup(full); } } *files = tfiles; } else if (f[0]) { /* no tagged entries. return selected entry */ *numfiles = 1; - tfiles = safe_calloc (*numfiles, sizeof (char *)); + tfiles = p_new(char *, *numfiles); mutt_expand_path (f, flen); - tfiles[0] = safe_strdup (f); + tfiles[0] = m_strdup(f); *files = tfiles; } } @@ -1047,6 +1050,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, init_state (&state, NULL); state.imap_browse = 1; imap_browse (LastDir, &state); + browser_sort (&state); menu->data = state.entry; menu->current = 0; menu->top = 0; @@ -1066,6 +1070,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, init_state (&state, NULL); state.imap_browse = 1; imap_browse (LastDir, &state); + browser_sort (&state); menu->data = state.entry; menu->current = 0; menu->top = 0; @@ -1089,8 +1094,8 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, if (mutt_yesorno (msg, M_NO) == M_YES) { if (!imap_delete_mailbox (Context, mx)) { /* free the mailbox from the browser */ - FREE (&((state.entry)[nentry].name)); - FREE (&((state.entry)[nentry].desc)); + p_delete(&((state.entry)[nentry].name)); + p_delete(&((state.entry)[nentry].desc)); /* and move all other entries up */ if (nentry + 1 < state.entrylen) memmove (state.entry + nentry, state.entry + nentry + 1, @@ -1105,7 +1110,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, } else mutt_message _("Mailbox not deleted."); - FREE (&mx.mbox); + p_delete(&mx.mbox); } break; #endif @@ -1117,13 +1122,13 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, break; #endif - strfcpy (buf, LastDir, sizeof (buf)); + m_strcpy(buf, sizeof(buf), LastDir); #ifdef USE_IMAP if (!state.imap_browse) #endif { /* add '/' at the end of the directory name if not already there */ - int len = mutt_strlen (LastDir); + int len = m_strlen(LastDir); if (len && LastDir[len - 1] != '/' && sizeof (buf) > len) buf[len] = '/'; @@ -1134,12 +1139,13 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, buffy = 0; mutt_expand_path (buf, sizeof (buf)); #ifdef USE_IMAP - if (mx_is_imap (buf)) { - strfcpy (LastDir, buf, sizeof (LastDir)); + if (imap_is_magic (buf, NULL) == M_IMAP) { + m_strcpy(LastDir, sizeof(LastDir), buf); destroy_state (&state); init_state (&state, NULL); state.imap_browse = 1; imap_browse (LastDir, &state); + browser_sort (&state); menu->data = state.entry; menu->current = 0; menu->top = 0; @@ -1151,7 +1157,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, if (S_ISDIR (st.st_mode)) { destroy_state (&state); if (examine_directory (menu, &state, buf, prefix) == 0) - strfcpy (LastDir, buf, sizeof (LastDir)); + m_strcpy(LastDir, sizeof(LastDir), buf); else { mutt_error _("Error scanning directory."); @@ -1175,16 +1181,16 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, case OP_ENTER_MASK: - strfcpy (buf, NONULL (Mask.pattern), sizeof (buf)); + m_strcpy(buf, sizeof(buf), NONULL(Mask.pattern)); if (mutt_get_field (_("File Mask: "), buf, sizeof (buf), 0) == 0) { - regex_t *rx = (regex_t *) safe_malloc (sizeof (regex_t)); + regex_t *rx = p_new(regex_t, 1); char *s = buf; int not = 0, err; buffy = 0; /* assume that the user wants to see everything */ if (!buf[0]) - strfcpy (buf, ".", sizeof (buf)); + m_strcpy(buf, sizeof(buf), "."); SKIPWS (s); if (*s == '!') { s++; @@ -1195,13 +1201,13 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, if ((err = REGCOMP (rx, s, REG_NOSUB)) != 0) { regerror (err, rx, buf, sizeof (buf)); regfree (rx); - FREE (&rx); + p_delete(&rx); mutt_error ("%s", buf); } else { - mutt_str_replace (&Mask.pattern, buf); + str_replace (&Mask.pattern, buf); regfree (Mask.rx); - FREE (&Mask.rx); + p_delete(&Mask.rx); Mask.rx = rx; Mask.not = not; @@ -1211,6 +1217,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, init_state (&state, NULL); state.imap_browse = 1; imap_browse (LastDir, &state); + browser_sort (&state); menu->data = state.entry; init_menu (&state, menu, title, sizeof (title), buffy); } @@ -1291,10 +1298,11 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, goto bail; } #ifdef USE_IMAP - else if (mx_is_imap (LastDir)) { + else if (imap_is_magic (LastDir, NULL) == M_IMAP) { init_state (&state, NULL); state.imap_browse = 1; imap_browse (LastDir, &state); + browser_sort (&state); menu->data = state.entry; } #endif @@ -1304,7 +1312,9 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, break; case OP_BUFFY_LIST: - mutt_buffy_list (); + if (option (OPTFORCEBUFFYCHECK)) + buffy_check (1); + buffy_list (); break; case OP_BROWSER_NEW_FILE: @@ -1312,7 +1322,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, snprintf (buf, sizeof (buf), "%s/", LastDir); if (mutt_get_field (_("New file name: "), buf, sizeof (buf), M_FILE) == 0) { - strfcpy (f, buf, flen); + m_strcpy(f, flen, buf); destroy_state (&state); mutt_menuDestroy (&menu); goto bail; @@ -1329,7 +1339,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, #ifdef USE_IMAP if (state.entry[menu->current].selectable) { - strfcpy (f, state.entry[menu->current].name, flen); + m_strcpy(f, flen, state.entry[menu->current].name); destroy_state (&state); mutt_menuDestroy (&menu); goto bail; @@ -1347,8 +1357,8 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, BODY *b; char buf[_POSIX_PATH_MAX]; - mutt_concat_path (buf, LastDir, state.entry[menu->current].name, - sizeof (buf)); + mutt_concat_path(buf, sizeof(buf), LastDir, + state.entry[menu->current].name); b = mutt_make_file_attach (buf); if (b != NULL) { mutt_view_attachment (NULL, b, M_REGULAR, NULL, NULL, 0); @@ -1382,11 +1392,11 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, folder.ff->st = NULL; folder.ff->is_new = nd->new; folder.ff->nd = nd; - FREE (&f->desc); + p_delete(&f->desc); mutt_FormatString (buffer, sizeof (buffer), NONULL(GroupFormat), newsgroup_format_str, (unsigned long) &folder, M_FORMAT_ARROWCURSOR); - f->desc = safe_strdup (buffer); */ + f->desc = m_strdup(buffer); */ if (menu->current + 1 < menu->max) menu->current++; menu->redraw = REDRAW_MOTION_RESYNCH; @@ -1426,7 +1436,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, case OP_SUBSCRIBE_PATTERN: case OP_UNSUBSCRIBE_PATTERN: if (option (OPTNEWS)) { - regex_t *rx = (regex_t *) safe_malloc (sizeof (regex_t)); + regex_t *rx = p_new(regex_t, 1); char *s = buf; int j = menu->current; NNTP_DATA *nd; @@ -1442,14 +1452,14 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, else snprintf (tmp, sizeof (tmp), _("Unsubscribe pattern: ")); if (mutt_get_field (tmp, buf, sizeof (buf), 0) != 0 || !buf[0]) { - FREE (&rx); + p_delete(&rx); break; } if ((err = REGCOMP (rx, s, REG_NOSUB)) != 0) { regerror (err, rx, buf, sizeof (buf)); regfree (rx); - FREE (&rx); + p_delete(&rx); mutt_error ("%s", buf); break; } @@ -1480,11 +1490,11 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, folder.f = NULL; folder.new = nd->new; folder.nd = nd; - FREE (&f->desc); + p_delete(&f->desc); mutt_FormatString (buffer, sizeof (buffer), NONULL(GroupFormat), newsgroup_format_str, (unsigned long) &folder, M_FORMAT_ARROWCURSOR); - f->desc = safe_strdup (buffer); + f->desc = m_strdup(buffer); } */ } if (i == OP_BROWSER_SUBSCRIBE || i == OP_BROWSER_UNSUBSCRIBE) { @@ -1514,7 +1524,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, nntp_clear_cacheindex (news); if (i != OP_BROWSER_SUBSCRIBE && i != OP_BROWSER_UNSUBSCRIBE) regfree (rx); - FREE (&rx); + p_delete(&rx); } #ifdef USE_IMAP else @@ -1534,6 +1544,6 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, bail: if (!folder) - strfcpy (LastDir, LastDirBackup, sizeof (LastDir)); + m_strcpy(LastDir, sizeof(LastDir), LastDirBackup); }