#endif
#include "mutt.h"
+#include "enter.h"
#include "mx.h"
#include "mutt_curses.h"
#include "mutt_menu.h"
#include "mapping.h"
#include "sort.h"
#include "browser.h"
+#include "attach.h"
+
#ifdef USE_IMAP
#include "imap.h"
#include "imap/mx_imap.h"
int c;
for (c = 0; c < state->entrylen; c++) {
- FREE (&((state->entry)[c].name));
- FREE (&((state->entry)[c].desc));
- FREE (&((state->entry)[c].st));
+ mem_free (&((state->entry)[c].name));
+ mem_free (&((state->entry)[c].desc));
+ mem_free (&((state->entry)[c].st));
}
#ifdef USE_IMAP
- FREE (&state->folder);
+ mem_free (&state->folder);
#endif
- FREE (&state->entry);
+ mem_free (&state->entry);
}
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 = safe_strcoll (pa->name, pb->name);
+ int r = str_coll (pa->name, pb->name);
return ((BrowserSort & SORT_REVERSE) ? -r : r);
}
{
if (state->entrylen == state->entrymax) {
/* need to allocate more space */
- safe_realloc (&state->entry,
+ mem_realloc (&state->entry,
sizeof (struct folder_file) * (state->entrymax += 256));
memset (&state->entry[state->entrylen], 0,
sizeof (struct folder_file) * 256);
(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));
+ (state->entry)[state->entrylen].st = mem_malloc (sizeof (struct stat));
memcpy ((state->entry)[state->entrylen].st, s, sizeof (struct stat));
}
(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 = str_dup (name);
+ (state->entry)[state->entrylen].desc = str_dup (name);
#ifdef USE_IMAP
(state->entry)[state->entrylen].imap = 0;
#endif
state->entrylen = 0;
state->entrymax = 256;
state->entry =
- (struct folder_file *) safe_calloc (state->entrymax,
+ (struct folder_file *) mem_calloc (state->entrymax,
sizeof (struct folder_file));
#ifdef USE_IMAP
state->imap_browse = 0;
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,
- safe_strlen (prefix)) != 0)
+ str_len (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 */
return (-1);
}
- mutt_buffy_check (0);
+ buffy_check (0);
if ((dp = opendir (d)) == NULL) {
mutt_perror (d);
init_state (state, menu);
while ((de = readdir (dp)) != NULL) {
- if (safe_strcmp (de->d_name, ".") == 0)
+ if (str_cmp (de->d_name, ".") == 0)
continue; /* we don't need . */
if (prefix && *prefix
- && safe_strncmp (prefix, de->d_name, safe_strlen (prefix)) != 0)
+ && str_ncmp (prefix, de->d_name, str_len (prefix)) != 0)
continue;
if (!((regexec (Mask.rx, de->d_name, 0, NULL, 0) == 0) ^ Mask.not))
continue;
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
if (!Incoming)
return (-1);
- mutt_buffy_check (0);
+ buffy_check (0);
init_state (state, 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));
mutt_pretty_mailbox (path);
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))
+ strfcpy (LastDir, state.folder, sizeof (LastDir));
}
else {
#endif
- for (i = safe_strlen (f) - 1; i > 0 && f[i] != '/'; i--);
+ for (i = str_len (f) - 1; i > 0 && f[i] != '/'; i--);
if (i > 0) {
if (f[0] == '/') {
if (i > sizeof (LastDir) - 1)
}
else {
getcwd (LastDir, sizeof (LastDir));
- safe_strcat (LastDir, sizeof (LastDir), "/");
- safe_strncat (LastDir, sizeof (LastDir), f, i);
+ str_cat (LastDir, sizeof (LastDir), "/");
+ str_ncat (LastDir, sizeof (LastDir), f, i);
}
}
else {
/* save the old directory */
strfcpy (OldLastDir, LastDir, sizeof (OldLastDir));
- if (safe_strcmp (state.entry[menu->current].name, "..") == 0) {
- if (safe_strcmp ("..", LastDir + safe_strlen (LastDir) - 2) == 0)
+ if (str_cmp (state.entry[menu->current].name, "..") == 0) {
+ if (str_cmp ("..", LastDir + str_len (LastDir) - 2) == 0)
strcat (LastDir, "/.."); /* __STRCAT_CHECKED__ */
else {
char *p = strrchr (LastDir + 1, '/');
strfcpy (LastDir, state.entry[menu->current].name,
sizeof (LastDir));
/* tack on delimiter here */
- n = safe_strlen (LastDir) + 1;
+ n = str_len (LastDir) + 1;
/* special case "" needs no delimiter */
url_parse_ciss (&url, state.entry[menu->current].name);
if (menu->tagged) {
*numfiles = menu->tagged;
- tfiles = safe_calloc (*numfiles, sizeof (char *));
+ tfiles = mem_calloc (*numfiles, sizeof (char *));
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_expand_path (full, sizeof (full));
- tfiles[j++] = safe_strdup (full);
+ tfiles[j++] = str_dup (full);
}
}
*files = tfiles;
}
else if (f[0]) { /* no tagged entries. return selected entry */
*numfiles = 1;
- tfiles = safe_calloc (*numfiles, sizeof (char *));
+ tfiles = mem_calloc (*numfiles, sizeof (char *));
mutt_expand_path (f, flen);
- tfiles[0] = safe_strdup (f);
+ tfiles[0] = str_dup (f);
*files = tfiles;
}
}
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));
+ mem_free (&((state.entry)[nentry].name));
+ mem_free (&((state.entry)[nentry].desc));
/* and move all other entries up */
if (nentry + 1 < state.entrylen)
memmove (state.entry + nentry, state.entry + nentry + 1,
}
else
mutt_message _("Mailbox not deleted.");
- FREE (&mx.mbox);
+ mem_free (&mx.mbox);
}
break;
#endif
#endif
{
/* add '/' at the end of the directory name if not already there */
- int len = safe_strlen (LastDir);
+ int len = str_len (LastDir);
if (len && LastDir[len - 1] != '/' && sizeof (buf) > len)
buf[len] = '/';
strfcpy (buf, NONULL (Mask.pattern), sizeof (buf));
if (mutt_get_field (_("File Mask: "), buf, sizeof (buf), 0) == 0) {
- regex_t *rx = (regex_t *) safe_malloc (sizeof (regex_t));
+ regex_t *rx = (regex_t *) mem_malloc (sizeof (regex_t));
char *s = buf;
int not = 0, err;
if ((err = REGCOMP (rx, s, REG_NOSUB)) != 0) {
regerror (err, rx, buf, sizeof (buf));
regfree (rx);
- FREE (&rx);
+ mem_free (&rx);
mutt_error ("%s", buf);
}
else {
str_replace (&Mask.pattern, buf);
regfree (Mask.rx);
- FREE (&Mask.rx);
+ mem_free (&Mask.rx);
Mask.rx = rx;
Mask.not = not;
break;
case OP_BUFFY_LIST:
- mutt_buffy_list ();
+ if (option (OPTFORCEBUFFYCHECK))
+ buffy_check (1);
+ buffy_list ();
break;
case OP_BROWSER_NEW_FILE:
folder.ff->st = NULL;
folder.ff->is_new = nd->new;
folder.ff->nd = nd;
- FREE (&f->desc);
+ mem_free (&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 = str_dup (buffer); */
if (menu->current + 1 < menu->max)
menu->current++;
menu->redraw = REDRAW_MOTION_RESYNCH;
case OP_SUBSCRIBE_PATTERN:
case OP_UNSUBSCRIBE_PATTERN:
if (option (OPTNEWS)) {
- regex_t *rx = (regex_t *) safe_malloc (sizeof (regex_t));
+ regex_t *rx = (regex_t *) mem_malloc (sizeof (regex_t));
char *s = buf;
int j = menu->current;
NNTP_DATA *nd;
else
snprintf (tmp, sizeof (tmp), _("Unsubscribe pattern: "));
if (mutt_get_field (tmp, buf, sizeof (buf), 0) != 0 || !buf[0]) {
- FREE (&rx);
+ mem_free (&rx);
break;
}
if ((err = REGCOMP (rx, s, REG_NOSUB)) != 0) {
regerror (err, rx, buf, sizeof (buf));
regfree (rx);
- FREE (&rx);
+ mem_free (&rx);
mutt_error ("%s", buf);
break;
}
folder.f = NULL;
folder.new = nd->new;
folder.nd = nd;
- FREE (&f->desc);
+ mem_free (&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 = str_dup (buffer);
} */
}
if (i == OP_BROWSER_SUBSCRIBE || i == OP_BROWSER_UNSUBSCRIBE) {
nntp_clear_cacheindex (news);
if (i != OP_BROWSER_SUBSCRIBE && i != OP_BROWSER_UNSUBSCRIBE)
regfree (rx);
- FREE (&rx);
+ mem_free (&rx);
}
#ifdef USE_IMAP
else