#endif
#include "mutt.h"
+#include "enter.h"
#include "mutt_menu.h"
#include "mutt_curses.h"
#include "pager.h"
return (ret);
}
-int mutt_get_password (char *msg, char *buf, size_t buflen)
+int mutt_get_field_unbuffered (char *msg, char *buf, size_t buflen, int flags)
{
int rc;
- CLEARLINE (LINES - 1);
- addstr (msg);
set_option (OPTUNBUFFEREDINPUT);
- rc = mutt_enter_string (buf, buflen, LINES - 1, safe_strlen (msg), M_PASS);
+ rc = mutt_get_field (msg, buf, buflen, flags);
unset_option (OPTUNBUFFEREDINPUT);
- CLEARLINE (LINES - 1);
+
return (rc);
}
CLEARLINE (LINES - 1);
}
-static void fix_end_of_file (const char *data)
-{
- FILE *fp;
- int c;
-
- if ((fp = safe_fopen (data, "a+")) == NULL)
- return;
- fseek (fp, -1, SEEK_END);
- if ((c = fgetc (fp)) != '\n')
- fputc ('\n', fp);
- safe_fclose (&fp);
-}
-
void mutt_edit_file (const char *editor, const char *data)
{
char cmd[LONG_STRING];
mutt_expand_file_fmt (cmd, sizeof (cmd), editor, data);
if (mutt_system (cmd) == -1)
mutt_error (_("Error running \"%s\"!"), cmd);
- fix_end_of_file (data);
keypad (stdscr, TRUE);
clearok (stdscr, TRUE);
}
* ensure there is enough room for the answer and truncate the question
* to fit.
*/
- answer_string = safe_malloc (COLS + 1);
+ answer_string = mem_malloc (COLS + 1);
snprintf (answer_string, COLS + 1, " ([%s]/%s): ", def == M_YES ? yes : no,
def == M_YES ? no : yes);
- answer_string_len = safe_strlen (answer_string);
+ answer_string_len = str_len (answer_string);
printw ("%.*s%s", COLS - answer_string_len, msg, answer_string);
- FREE (&answer_string);
+ mem_free (&answer_string);
FOREVER {
mutt_refresh ();
if (Timeout)
timeout (-1); /* restore blocking operation */
if (mutt_yesorno (_("Exit Mutt-ng?"), M_YES) == M_YES) {
- endwin ();
+ mutt_endwin (NULL);
exit (1);
}
mutt_clear_error ();
set_option (OPTMSGERR);
}
+#ifdef USE_SOCKET
+void mutt_progress_bar (progress_t* progress, long pos) {
+ char posstr[SHORT_STRING];
+
+ if (!pos) {
+ if (!NetInc)
+ mutt_message (progress->msg);
+ else {
+ if (progress->size)
+ mutt_pretty_size (progress->sizestr, sizeof (progress->sizestr),
+ progress->size);
+ progress->pos = 0;
+ }
+ }
+
+ if (!NetInc)
+ return;
+
+ if (pos >= progress->pos + (NetInc << 10)) {
+ progress->pos = pos;
+ pos = pos / (NetInc << 10) * (NetInc << 10);
+ mutt_pretty_size (posstr, sizeof (posstr), pos);
+ if (progress->size)
+ mutt_message ("%s %s/%s", progress->msg, posstr, progress->sizestr);
+ else
+ mutt_message ("%s %s", progress->msg, posstr);
+ }
+}
+#endif
+
void mutt_curses_message (const char *fmt, ...)
{
char TmpErrorbuf[STRING];
{
int rc;
- if (!Pager || safe_strcmp (Pager, "builtin") == 0)
+ if (!Pager || str_cmp (Pager, "builtin") == 0)
rc = mutt_pager (banner, tempfile, do_color, info);
else {
char cmd[STRING];
*redraw = REDRAW_FULL;
}
else {
- char *pc = safe_malloc (safe_strlen (prompt) + 3);
+ char *pc = mem_malloc (str_len (prompt) + 3);
sprintf (pc, "%s: ", prompt); /* __SPRINTF_CHECKED__ */
mutt_ungetch (ch.op ? 0 : ch.ch, ch.op ? ch.op : 0);
!= 0)
buf[0] = 0;
MAYBE_REDRAW (*redraw);
- FREE (&pc);
+ mem_free (&pc);
}
return 0;
tmp.op = op;
if (UngetCount >= UngetBufLen)
- safe_realloc (&KeyEvent, (UngetBufLen += 128) * sizeof (event_t));
+ mem_realloc (&KeyEvent, (UngetBufLen += 128) * sizeof (event_t));
KeyEvent[UngetCount++] = tmp;
}
}
else if (ch.ch <= '9' && ch.ch > '0') {
choice = ch.ch - '0';
- if (choice <= safe_strlen (letters))
+ if (choice <= str_len (letters))
break;
}
}
}
mutt_format_string (dest, destlen, min_width, max_width,
- right_justify, ' ', s, safe_strlen (s), arboreal);
+ right_justify, ' ', s, str_len (s), arboreal);
}
void mutt_format_s (char *dest,
wchar_t wc;
int w;
size_t k;
- size_t len = safe_strlen (s);
+ size_t len = str_len (s);
mbstate_t mbstate;
memset (&mbstate, 0, sizeof (mbstate));
}
/*
- * mutt_strwidth is like safe_strlen except that it returns the width
+ * mutt_strwidth is like str_len except that it returns the width
* refering to the number of characters cells.
*/
if (!s)
return 0;
- n = safe_strlen (s);
+ n = str_len (s);
memset (&mbstate, 0, sizeof (mbstate));
for (w = 0; n && (k = mbrtowc (&wc, s, n, &mbstate)); s += k, n -= k) {