diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2010-12-04 14:00:01 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2010-12-04 14:00:01 +0200 |
commit | 2613d48d056396600993c447ab9fe6b64896abe6 (patch) | |
tree | 1093bb45349855d45941594264f4e700383ea67b /mu/shell.c | |
parent | 76df98da17f576b71e6cbc83bbf527b685be1178 (diff) | |
download | mailutils-2613d48d056396600993c447ab9fe6b64896abe6.tar.gz mailutils-2613d48d056396600993c447ab9fe6b64896abe6.tar.bz2 |
mu: use stdstream functions.
* include/mailutils/stdstream.h (mu_printf): New prototype.
* include/mailutils/version.h: Include mailutils/types.h instead of
stdio.h
(mu_fprint_options, mu_fprint_conf_option): Remove protos.
(mu_format_options, mu_format_conf_option): New protos.
* libmailutils/base/version.c (mu_fprint_options): Replace
with mu_format_options, which outputs formatted data to a mu_stream_t.
(mu_fprint_conf_option): Ditto. Replaced by mu_format_conf_option.
(mu_print_options): Update accordingly.
* libmailutils/stdstream/basestr.c (mu_printf): New function.
* mu/acl.c: Replace stdio calls with stdstream ones.
* mu/cflags.c: Likewise.
* mu/filter.c: Likewise.
* mu/flt2047.c: Likewise.
* mu/imap.c: Likewise.
* mu/info.c: Likewise.
* mu/ldflags.c: Likewise.
* mu/logger.c: Likewise.
* mu/mu.c: Likewise.
* mu/mu.h: Likewise.
* mu/pop.c: Likewise.
* mu/query.c: Likewise.
* mu/shell.c: Likewise.
* mu/verbose.c: Likewise.
* mu/wicket.c: Likewise.
Diffstat (limited to 'mu/shell.c')
-rw-r--r-- | mu/shell.c | 50 |
1 files changed, 14 insertions, 36 deletions
diff --git a/mu/shell.c b/mu/shell.c index ab12fd46a..76bd2c604 100644 --- a/mu/shell.c +++ b/mu/shell.c @@ -33,7 +33,6 @@ char *mutool_shell_prompt; char **mutool_prompt_env; int mutool_shell_interactive; -mu_stream_t mustrin, mustrout; static int shell_exit (int, char **); @@ -161,16 +160,16 @@ list_commands (struct mutool_command *tab, const char *name) if (printed == 6) { printed = 0; - mu_stream_printf (mustrout, "\n"); + mu_printf ("\n"); } if (mu_c_strncasecmp (tab->name, name, namelen) == 0) { - mu_stream_printf (mustrout, "%s\t", tab->name); + mu_printf ("%s\t", tab->name); printed++; } } if (printed && printed < 6) - mu_stream_printf (mustrout, "\n"); + mu_printf ("\n"); } static struct mutool_command * @@ -204,12 +203,10 @@ shell_help (int argc, char **argv) struct mutool_command *com = find_command (argv[1]); if (com) - print_comtab (mustrout, com); + print_comtab (mu_strout, com); else { - mu_stream_printf (mustrout, - "No commands match `%s'. Possibilties are:\n", - name); + mu_printf ("No commands match `%s'. Possibilties are:\n", name); list_commands (shell_comtab, name); } } @@ -248,8 +245,8 @@ mutool_open_pager () return stream; mu_error (_("cannot start pager: %s"), mu_strerror (rc)); } - mu_stream_ref (mustrout); - return mustrout; + mu_stream_ref (mu_strout); + return mu_strout; } @@ -391,7 +388,7 @@ retrieve_history (char *str) return 1; case 2: - mu_stream_printf (mustrout, "%s\n", out); + mu_printf ("%s\n", out); free (out); return 1; } @@ -425,10 +422,10 @@ readline (char *prompt) if (prompt) { - mu_stream_printf (mustrout, "%s", prompt); - fflush (stdout); + mu_printf ("%s", prompt); + mu_stream_flush (mu_strout); } - if (mu_stream_getline (mustrin, &buf, &size, &n) || n == 0) + if (mu_stream_getline (mu_strin, &buf, &size, &n) || n == 0) { free (buf); buf = NULL; @@ -530,7 +527,7 @@ input_line_script () size_t size = 0, n; char *buf = NULL; - if (mu_stream_getline (mustrin, &buf, &size, &n) || n == 0) + if (mu_stream_getline (mu_strin, &buf, &size, &n) || n == 0) return NULL; return buf; } @@ -547,28 +544,9 @@ shell_exit (int argc MU_ARG_UNUSED, char **argv MU_ARG_UNUSED) int mutool_shell (const char *name, struct mutool_command *cmd) { - int rc; size_t n; char *(*input_line) (); - rc = mu_stdio_stream_create (&mustrin, MU_STDIN_FD, - MU_STREAM_READ); - if (rc) - { - mu_diag_funcall (MU_DIAG_ERROR, "mu_stdio_stream_create", - "MU_STDIN_FD", rc); - return 1; - } - - rc = mu_stdio_stream_create (&mustrout, MU_STDOUT_FD, - MU_STREAM_WRITE); - if (rc) - { - mu_diag_funcall (MU_DIAG_ERROR, "mu_stdio_stream_create", - "MU_STDOUT_FD", rc); - return 1; - } - mutool_shell_interactive = isatty (0); input_line = mutool_shell_interactive ? input_line_interactive : input_line_script; @@ -616,8 +594,8 @@ mutool_shell (const char *name, struct mutool_command *cmd) } if (mutool_shell_interactive) finish_readline (); - mu_stream_destroy (&mustrin); - mu_stream_destroy (&mustrout); + mu_stream_destroy (&mu_strin); + mu_stream_destroy (&mu_strout); return 0; } |