X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=browser.c;h=d91d0ef79d82059a22028b2d7426442ecea4cb4e;hp=6a9e6ecd50c7f36758eb1fcca1d321d09886554a;hb=a743b55a20cbf3a33699fdb24dcb8638e878cc46;hpb=617e7d83d14e14e6a520a48e75437211b16c8834 diff --git a/browser.c b/browser.c index 6a9e6ec..d91d0ef 100644 --- a/browser.c +++ b/browser.c @@ -12,6 +12,10 @@ #endif #include +#include +#include +#include +#include #include "mutt.h" #include "enter.h" @@ -19,7 +23,6 @@ #include "mutt_curses.h" #include "mutt_menu.h" #include "buffy.h" -#include "mapping.h" #include "sort.h" #include "browser.h" #include "attach.h" @@ -33,8 +36,6 @@ #endif #include "sidebar.h" -#include "lib/intl.h" -#include "lib/str.h" #include "lib/list.h" #include @@ -95,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 = str_coll (pa->name, pb->name); + int r = strcoll(NONULL(pa->name), NONULL(pb->name)); return ((BrowserSort & SORT_REVERSE) ? -r : r); } @@ -154,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)); @@ -349,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; @@ -442,8 +443,8 @@ static void add_folder (MUTTMENU * m, struct browser_state *state, } (state->entry)[state->entrylen].new = new; - (state->entry)[state->entrylen].name = str_dup (name); - (state->entry)[state->entrylen].desc = str_dup (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 @@ -484,7 +485,7 @@ static int examine_directory (MUTTMENU * menu, struct browser_state *state, continue; nntp_sync_sidebar (data); if (prefix && *prefix && strncmp (prefix, data->group, - str_len (prefix)) != 0) + m_strlen(prefix)) != 0) continue; if (!((regexec (Mask.rx, data->group, 0, NULL, 0) == 0) ^ Mask.not)) continue; @@ -530,16 +531,16 @@ static int examine_directory (MUTTMENU * menu, struct browser_state *state, init_state (state, menu); while ((de = readdir (dp)) != NULL) { - if (str_cmp (de->d_name, ".") == 0) + if (m_strcmp(de->d_name, ".") == 0) continue; /* we don't need . */ if (prefix && *prefix - && str_ncmp (prefix, de->d_name, str_len (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; @@ -622,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); @@ -687,9 +688,9 @@ static void init_menu (struct browser_state *state, MUTTMENU * menu, else #endif if (buffy) - snprintf (title, titlelen, _("Mailboxes [%d]"), 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)) @@ -738,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; @@ -771,22 +772,20 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, init_state (&state, NULL); state.imap_browse = 1; if (!imap_browse (f, &state)) - strfcpy (LastDir, state.folder, sizeof (LastDir)); + m_strcpy(LastDir, sizeof(LastDir), state.folder); } else { #endif - for (i = str_len (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)); - str_cat (LastDir, sizeof (LastDir), "/"); - str_ncat (LastDir, sizeof (LastDir), f, i); + getcwd(LastDir, sizeof(LastDir)); + m_strcat(LastDir, sizeof(LastDir), "/"); + m_strncat(LastDir, sizeof(LastDir), f, i); } } else { @@ -797,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 } @@ -809,7 +808,7 @@ 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 && imap_is_magic (LastDir, NULL) == M_IMAP) { @@ -851,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: @@ -870,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 @@ -890,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 (str_cmp (state.entry[menu->current].name, "..") == 0) { - if (str_cmp ("..", LastDir + str_len (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, '/'); @@ -909,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 @@ -918,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 = str_len (LastDir) + 1; + n = m_strlen(LastDir) + 1; /* special case "" needs no delimiter */ url_parse_ciss (&url, state.entry[menu->current].name); @@ -936,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); @@ -959,9 +958,9 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, #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; } } @@ -978,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 */ @@ -1004,9 +1003,9 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, 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++] = str_dup (full); + tfiles[j++] = m_strdup(full); } } *files = tfiles; @@ -1015,7 +1014,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, *numfiles = 1; tfiles = p_new(char *, *numfiles); mutt_expand_path (f, flen); - tfiles[0] = str_dup (f); + tfiles[0] = m_strdup(f); *files = tfiles; } } @@ -1123,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 = str_len (LastDir); + int len = m_strlen(LastDir); if (len && LastDir[len - 1] != '/' && sizeof (buf) > len) buf[len] = '/'; @@ -1141,7 +1140,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, mutt_expand_path (buf, sizeof (buf)); #ifdef USE_IMAP if (imap_is_magic (buf, NULL) == M_IMAP) { - strfcpy (LastDir, buf, sizeof (LastDir)); + m_strcpy(LastDir, sizeof(LastDir), buf); destroy_state (&state); init_state (&state, NULL); state.imap_browse = 1; @@ -1158,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."); @@ -1182,7 +1181,7 @@ 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 = p_new(regex_t, 1); char *s = buf; @@ -1191,11 +1190,10 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, buffy = 0; /* assume that the user wants to see everything */ if (!buf[0]) - strfcpy (buf, ".", sizeof (buf)); - SKIPWS (s); + m_strcpy(buf, sizeof(buf), "."); + s = vskipspaces(s); if (*s == '!') { - s++; - SKIPWS (s); + s = vskipspaces(s + 1); not = 1; } @@ -1206,7 +1204,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, mutt_error ("%s", buf); } else { - str_replace (&Mask.pattern, buf); + m_strreplace(&Mask.pattern, buf); regfree (Mask.rx); p_delete(&Mask.rx); Mask.rx = rx; @@ -1323,7 +1321,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; @@ -1340,7 +1338,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; @@ -1358,8 +1356,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); @@ -1397,7 +1395,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, mutt_FormatString (buffer, sizeof (buffer), NONULL(GroupFormat), newsgroup_format_str, (unsigned long) &folder, M_FORMAT_ARROWCURSOR); - f->desc = str_dup (buffer); */ + f->desc = m_strdup(buffer); */ if (menu->current + 1 < menu->max) menu->current++; menu->redraw = REDRAW_MOTION_RESYNCH; @@ -1495,7 +1493,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, mutt_FormatString (buffer, sizeof (buffer), NONULL(GroupFormat), newsgroup_format_str, (unsigned long) &folder, M_FORMAT_ARROWCURSOR); - f->desc = str_dup (buffer); + f->desc = m_strdup(buffer); } */ } if (i == OP_BROWSER_SUBSCRIBE || i == OP_BROWSER_UNSUBSCRIBE) { @@ -1545,6 +1543,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); }