Commit 2613d48d 2613d48d056396600993c447ab9fe6b64896abe6 by Sergey Poznyakoff

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.
1 parent 76df98da
......@@ -37,7 +37,8 @@ void mu_stdstream_setup (void);
int mu_stdstream_strerr_create (mu_stream_t *str, int type, int facility,
int priority, const char *tag,
const char *fname);
int mu_printf (const char *fmt, ...);
#ifdef __cplusplus
}
#endif
......
......@@ -18,7 +18,7 @@
#ifndef _MAILUTILS_VERSION_H
#define _MAILUTILS_VERSION_H
#include <stdio.h>
#include <mailutils/types.h>
#ifdef __cplusplus
extern "C" {
......@@ -31,8 +31,9 @@ struct mu_conf_option
};
extern void mu_print_options (void);
extern void mu_fprint_options (FILE *fp, int verbose);
extern void mu_fprint_conf_option (FILE *fp, const struct mu_conf_option *opt,
extern void mu_format_options (mu_stream_t, int verbose);
extern void mu_format_conf_option (mu_stream_t,
const struct mu_conf_option *opt,
int verbose);
extern const struct mu_conf_option *mu_check_option (char *name);
......
......@@ -22,7 +22,11 @@
#include <mailutils/nls.h>
#include <mailutils/version.h>
#include <mailutils/cstr.h>
#include <mailutils/stream.h>
#include <mailutils/stdstream.h>
#include <mailutils/errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <confpaths.h>
......@@ -121,27 +125,41 @@ static struct mu_conf_option mu_conf_option[] = {
};
void
mu_fprint_conf_option (FILE *fp, const struct mu_conf_option *opt, int verbose)
mu_format_conf_option (mu_stream_t stream, const struct mu_conf_option *opt,
int verbose)
{
fprintf (fp, "%s", opt->name);
mu_stream_printf (stream, "%s", opt->name);
if (verbose && opt->descr)
fprintf (fp, " \t- %s", _(opt->descr));
fputc('\n', fp);
mu_stream_printf (stream, " \t- %s", _(opt->descr));
mu_stream_printf (stream, "\n");
}
void
mu_fprint_options (FILE *fp, int verbose)
mu_format_options (mu_stream_t stream, int verbose)
{
int i;
for (i = 0; mu_conf_option[i].name; i++)
mu_fprint_conf_option (fp, mu_conf_option + i, verbose);
mu_format_conf_option (stream, mu_conf_option + i, verbose);
}
void
mu_print_options ()
{
mu_fprint_options (stdout, 1);
if (mu_strout)
mu_stream_ref (mu_strout);
else
{
int rc = mu_stdio_stream_create (&mu_strout, MU_STDOUT_FD, 0);
if (rc)
{
fprintf (stderr, "mu_stdio_stream_create(%d): %s\n",
MU_STDOUT_FD, mu_strerror (rc));
abort ();
}
}
mu_format_options (mu_strout, 1);
mu_stream_unref (mu_strout);
}
const struct mu_conf_option *
......
......@@ -77,4 +77,17 @@ mu_stdstream_setup ()
if (mu_stdstream_strerr_create (&mu_strerr, MU_STRERR_STDERR, 0, 0,
NULL, NULL))
abort ();
/* FIXME: atexit (flushall) */
}
int
mu_printf (const char *fmt, ...)
{
int rc;
va_list ap;
va_start (ap, fmt);
rc = mu_stream_vprintf (mu_strout, fmt, ap);
va_end (ap);
return rc;
}
......
......@@ -163,7 +163,7 @@ mutool_acl (int argc, char **argv)
const char *ap = *argv++;
target_sa = parse_address (&target_salen, ap);
printf ("Testing %s:\n", ap);
mu_printf ("Testing %s:\n", ap);
rc = mu_acl_check_sockaddr (acl, target_sa, target_salen, &result);
if (rc)
{
......@@ -174,15 +174,15 @@ mutool_acl (int argc, char **argv)
switch (result)
{
case mu_acl_result_undefined:
printf ("%s: undefined\n", ap);
mu_printf ("%s: undefined\n", ap);
break;
case mu_acl_result_accept:
printf ("%s: accept\n", ap);
mu_printf ("%s: accept\n", ap);
break;
case mu_acl_result_deny:
printf ("%s: deny\n", ap);
mu_printf ("%s: deny\n", ap);
break;
}
}
......
......@@ -40,7 +40,7 @@ mutool_cflags (int argc, char **argv)
{
if (argp_parse (&cflags_argp, argc, argv, ARGP_IN_ORDER, NULL, NULL))
return 1;
printf ("%s\n", COMPILE_FLAGS);
mu_printf ("%s\n", COMPILE_FLAGS);
return 0;
}
......
......@@ -130,7 +130,7 @@ int
mutool_filter (int argc, char **argv)
{
int rc, index;
mu_stream_t in, out, flt;
mu_stream_t flt;
const char *fltname;
if (argp_parse (&filter_argp, argc, argv, ARGP_IN_ORDER, &index, NULL))
......@@ -156,25 +156,12 @@ mutool_filter (int argc, char **argv)
}
fltname = argv[0];
rc = mu_stdio_stream_create (&in, MU_STDIN_FD, 0);
if (rc)
{
mu_error (_("cannot open input stream: %s"), mu_strerror (rc));
return 1;
}
rc = mu_stdio_stream_create (&out, MU_STDOUT_FD, 0);
if (rc)
{
mu_error (_("cannot open output stream: %s"), mu_strerror (rc));
return 1;
}
if (line_length_option)
reset_line_length (fltname, line_length);
rc = mu_filter_create_args (&flt, in, fltname, argc, (const char **)argv,
rc = mu_filter_create_args (&flt, mu_strin, fltname,
argc, (const char **)argv,
filter_mode, MU_STREAM_READ);
if (rc)
{
......@@ -182,7 +169,7 @@ mutool_filter (int argc, char **argv)
return 1;
}
rc = mu_stream_copy (out, flt, 0, NULL);
rc = mu_stream_copy (mu_strout, flt, 0, NULL);
if (rc)
{
......@@ -191,9 +178,10 @@ mutool_filter (int argc, char **argv)
}
if (newline_option)
mu_stream_write (out, "\n", 1, NULL);
mu_stream_write (mu_strout, "\n", 1, NULL);
mu_stream_flush (out);
mu_stream_destroy (&flt);
mu_stream_flush (mu_strout);
return 0;
}
......
......@@ -88,7 +88,6 @@ int
mutool_flt2047 (int argc, char **argv)
{
int rc, index;
mu_stream_t in, out;
char *p;
if (argp_parse (&flt2047_argp, argc, argv, ARGP_IN_ORDER, &index, NULL))
......@@ -97,20 +96,6 @@ mutool_flt2047 (int argc, char **argv)
argc -= index;
argv += index;
rc = mu_stdio_stream_create (&in, MU_STDIN_FD, 0);
if (rc)
{
mu_error (_("cannot open input stream: %s"), mu_strerror (rc));
return 1;
}
rc = mu_stdio_stream_create (&out, MU_STDOUT_FD, 0);
if (rc)
{
mu_error (_("cannot open output stream: %s"), mu_strerror (rc));
return 1;
}
if (argc)
{
char *p;
......@@ -127,7 +112,7 @@ mutool_flt2047 (int argc, char **argv)
mu_error ("%s", mu_strerror (rc));
return 1;
}
mu_stream_printf (out, "%s\n", p);
mu_printf ("%s\n", p);
}
}
else
......@@ -135,7 +120,8 @@ mutool_flt2047 (int argc, char **argv)
size_t size = 0, n;
char *buf = NULL;
while ((rc = mu_stream_getline (in, &buf, &size, &n)) == 0 && n > 0)
while ((rc = mu_stream_getline (mu_strin, &buf, &size, &n)) == 0
&& n > 0)
{
mu_rtrim_class (buf, MU_CTYPE_SPACE);
if (decode_mode)
......@@ -147,10 +133,10 @@ mutool_flt2047 (int argc, char **argv)
mu_error ("%s", mu_strerror (rc));
return 1;
}
mu_stream_printf (out, "%s\n", p);
mu_printf ("%s\n", p);
}
}
mu_stream_flush (out);
mu_stream_flush (mu_strout);
return 0;
}
......
......@@ -284,12 +284,11 @@ com_logout (int argc MU_ARG_UNUSED, char **argv MU_ARG_UNUSED)
}
else
{
mu_stream_printf (mustrout, "Try 'exit' to leave %s\n",
mu_program_name);
mu_printf ("Try 'exit' to leave %s\n", mu_program_name);
}
}
else
mu_stream_printf (mustrout, "Try 'exit' to leave %s\n", mu_program_name);
mu_printf ("Try 'exit' to leave %s\n", mu_program_name);
return status;
}
......@@ -325,13 +324,13 @@ com_capability (int argc, char **argv)
{
case 0:
if (*elt)
mu_stream_printf (mustrout, "%s: %s\n", argv[i], elt);
mu_printf ("%s: %s\n", argv[i], elt);
else
mu_stream_printf (mustrout, "%s is set\n", argv[i]);
mu_printf ("%s is set\n", argv[i]);
break;
case MU_ERR_NOENT:
mu_stream_printf (mustrout, "%s is not set\n", argv[i]);
mu_printf ("%s is not set\n", argv[i]);
break;
default:
......@@ -350,7 +349,7 @@ com_capability (int argc, char **argv)
{
char *capa = NULL;
mu_iterator_current (iterator, (void **) &capa);
mu_stream_printf (mustrout, "CAPA: %s\n", capa ? capa : "");
mu_printf ("CAPA: %s\n", capa ? capa : "");
}
mu_iterator_destroy (&iterator);
}
......@@ -371,7 +370,7 @@ com_login (int argc, char **argv)
mu_error (_("login: password required"));
return 1;
}
status = mu_getpass (mustrin, mustrout, "Password:", &passbuf);
status = mu_getpass (mu_strin, mu_strout, "Password:", &passbuf);
if (status)
return status;
pwd = passbuf;
......@@ -400,7 +399,7 @@ static int
_print_id (void *item, void *data)
{
const char *id = item;
mu_stream_printf (mustrout, "ID: %s %s\n", id, id + strlen (id) + 1);
mu_printf ("ID: %s %s\n", id, id + strlen (id) + 1);
return 0;
}
......@@ -435,12 +434,11 @@ com_id (int argc, char **argv)
switch (rc)
{
case 0:
mu_stream_printf (mustrout, "%s: %s\n", test,
res + strlen (res) + 1);
mu_printf ("%s: %s\n", test, res + strlen (res) + 1);
break;
case MU_ERR_NOENT:
mu_stream_printf (mustrout, "%s is not set\n", test);
mu_printf ("%s is not set\n", test);
break;
default:
......
......@@ -74,7 +74,7 @@ mutool_info (int argc, char **argv)
argv += index;
if (argc == 0)
mu_fprint_options (stdout, verbose);
mu_format_options (mu_strout, verbose);
else
{
int i, found = 0;
......@@ -85,7 +85,7 @@ mutool_info (int argc, char **argv)
if (opt)
{
found++;
mu_fprint_conf_option (stdout, opt, verbose);
mu_format_conf_option (mu_strout, opt, verbose);
}
}
return found == argc ? 0 : 1;
......
......@@ -184,12 +184,12 @@ mutool_ldflags (int argc, char **argv)
sort_entries ();
/* At least one entry is always present */
printf ("%s", lib_entry[0].ptr);
mu_printf ("%s", lib_entry[0].ptr);
/* Print the rest of them separated by a space */
for (j = 1; j < nentry; j++)
printf (" %s", lib_entry[j].ptr);
putchar ('\n');
mu_printf (" %s", lib_entry[j].ptr);
mu_printf ("\n");
return 0;
}
......
......@@ -44,7 +44,7 @@ static struct argp_option logger_options[] = {
};
static char *input_file = NULL;
static int use_syslog = 0;
static int logger_type = MU_STRERR_STDERR;
static int log_severity = MU_LOG_ERROR;
static struct mu_locus locus;
static int syslog_facility = LOG_USER;
......@@ -61,11 +61,11 @@ logger_parse_opt (int key, char *arg, struct argp_state *state)
break;
case OPT_SYSLOG:
use_syslog = 1;
logger_type = MU_STRERR_SYSLOG;
break;
case OPT_STDERR:
use_syslog = 0;
logger_type = MU_STRERR_STDERR;
break;
case 's':
......@@ -96,7 +96,7 @@ logger_parse_opt (int key, char *arg, struct argp_state *state)
if (s &&
mu_string_to_syslog_priority (s, &syslog_priority))
argp_error (state, _("unknown priority: %s"), s);
use_syslog = 1;
logger_type = MU_STRERR_SYSLOG;
break;
}
......@@ -142,7 +142,7 @@ int
mutool_logger (int argc, char **argv)
{
int index;
mu_stream_t transport, logger;
mu_stream_t logger, input;
int rc, mode;
if (argp_parse (&logger_argp, argc, argv, ARGP_IN_ORDER, &index, NULL))
......@@ -158,49 +158,13 @@ mutool_logger (int argc, char **argv)
if (!syslog_tag)
syslog_tag = "mu-logger";
if (use_syslog)
if (mu_stdstream_strerr_create (&logger, logger_type,
syslog_facility, syslog_priority,
syslog_tag, NULL))
{
openlog (syslog_tag, LOG_PID, syslog_facility);
rc = mu_syslog_stream_create (&transport, syslog_priority);
if (rc)
{
mu_error (_("cannot create syslog stream: %s"),
mu_strerror (rc));
exit (1);
}
}
else
{
mu_stream_t str;
char *fltargs[3] = { "INLINE-COMMENT", };
rc = mu_stdio_stream_create (&str, MU_STDERR_FD, 0);
if (rc)
{
mu_error (_("cannot open error stream: %s"), mu_strerror (rc));
return 1;
}
mu_asprintf (&fltargs[1], "%s: ", syslog_tag);
fltargs[2] = NULL;
rc = mu_filter_create_args (&transport, str,
"INLINE-COMMENT", 2, (const char *)fltargs,
MU_FILTER_ENCODE, MU_STREAM_WRITE);
mu_stream_unref (str);
free (fltargs[1]);
if (rc)
{
mu_error (_("cannot open filter stream: %s"), mu_strerror (rc));
return 1;
}
}
rc = mu_log_stream_create (&logger, transport);
mu_stream_unref (transport);
if (rc)
{
mu_error (_("cannot open logger stream: %s"), mu_strerror (rc));
return 1;
mu_error (_("cannot create log stream: %s"),
mu_strerror (rc));
exit (1);
}
mode = MU_LOGMODE_SEVERITY | MU_LOGMODE_LOCUS;
......@@ -223,16 +187,12 @@ mutool_logger (int argc, char **argv)
}
else if (!input_file || strcmp (input_file, "-") == 0)
{
rc = mu_stdio_stream_create (&transport, MU_STDIN_FD, 0);
if (rc)
{
mu_error (_("cannot open input stream: %s"), mu_strerror (rc));
return 1;
}
mu_stream_ref (mu_strin);
input = mu_strin;
}
else
{
rc = mu_file_stream_create (&transport, input_file, MU_STREAM_READ);
rc = mu_file_stream_create (&input, input_file, MU_STREAM_READ);
if (rc)
{
mu_error (_("cannot open input stream %s: %s"),
......@@ -241,8 +201,8 @@ mutool_logger (int argc, char **argv)
}
}
rc = mu_stream_copy (logger, transport, 0, NULL);
mu_stream_unref (transport);
rc = mu_stream_copy (logger, input, 0, NULL);
mu_stream_unref (input);
mu_stream_unref (logger);
return !!rc;
}
......
......@@ -104,6 +104,8 @@ main (int argc, char **argv)
/* Native Language Support */
MU_APP_INIT_NLS ();
MU_AUTH_REGISTER_ALL_MODULES ();
mu_stdstream_setup ();
/* Register the desired mailbox formats. */
mu_register_all_mbox_formats ();
......
......@@ -33,7 +33,6 @@ struct mutool_command
extern char *mutool_shell_prompt;
extern char **mutool_prompt_env;
extern int mutool_shell_interactive;
extern mu_stream_t mustrin, mustrout;
int mutool_shell (const char *name, struct mutool_command *cmd);
mu_stream_t mutool_open_pager (void);
......
......@@ -186,7 +186,7 @@ com_apop (int argc, char **argv)
}
else
{
status = mu_getpass (mustrin, mustrout, "Password:", &passbuf);
status = mu_getpass (mu_strin, mu_strout, "Password:", &passbuf);
if (status)
return status;
pwd = passbuf;
......@@ -234,13 +234,13 @@ com_capa (int argc, char **argv)
{
case 0:
if (*elt)
mu_stream_printf (mustrout, "%s: %s\n", argv[i], elt);
mu_printf ("%s: %s\n", argv[i], elt);
else
mu_stream_printf (mustrout, "%s is set\n", argv[i]);
mu_printf ("%s is set\n", argv[i]);
break;
case MU_ERR_NOENT:
mu_stream_printf (mustrout, "%s is not set\n", argv[i]);
mu_printf ("%s is not set\n", argv[i]);
break;
default:
......@@ -259,7 +259,7 @@ com_capa (int argc, char **argv)
{
char *capa = NULL;
mu_iterator_current (iterator, (void **) &capa);
mu_stream_printf (mustrout, "CAPA: %s\n", capa ? capa : "");
mu_printf ("CAPA: %s\n", capa ? capa : "");
}
mu_iterator_destroy (&iterator);
}
......@@ -296,7 +296,7 @@ com_uidl (int argc, char **argv)
unsigned int msgno = strtoul (argv[1], NULL, 10);
status = mu_pop3_uidl (pop3, msgno, &uidl);
if (status == 0)
mu_stream_printf (mustrout, "Msg: %d UIDL: %s\n", msgno, uidl ? uidl : "");
mu_printf ("Msg: %d UIDL: %s\n", msgno, uidl ? uidl : "");
free (uidl);
}
return status;
......@@ -331,7 +331,7 @@ com_list (int argc, char **argv)
unsigned int msgno = strtoul (argv[1], NULL, 10);
status = mu_pop3_list (pop3, msgno, &size);
if (status == 0)
mu_stream_printf (mustrout, "Msg: %u Size: %lu\n", msgno, (unsigned long) size);
mu_printf ("Msg: %u Size: %lu\n", msgno, (unsigned long) size);
}
return status;
}
......@@ -355,7 +355,7 @@ com_pass (int argc, char **argv)
mu_error (_("pass: password required"));
return 1;
}
status = mu_getpass (mustrin, mustrout, "Password:", &passbuf);
status = mu_getpass (mu_strin, mu_strout, "Password:", &passbuf);
if (status)
return status;
pwd = passbuf;
......@@ -380,8 +380,8 @@ com_stat (int argc MU_ARG_UNUSED, char **argv MU_ARG_UNUSED)
int status = 0;
status = mu_pop3_stat (pop3, &count, &size);
mu_stream_printf (mustrout, "Mesgs: %lu Size %lu\n",
(unsigned long) count, (unsigned long) size);
mu_printf ("Mesgs: %lu Size %lu\n",
(unsigned long) count, (unsigned long) size);
return status;
}
......@@ -578,11 +578,11 @@ com_quit (int argc MU_ARG_UNUSED, char **argv MU_ARG_UNUSED)
}
else
{
mu_stream_printf (mustrout, "Try 'exit' to leave %s\n", mu_program_name);
mu_printf ("Try 'exit' to leave %s\n", mu_program_name);
}
}
else
mu_stream_printf (mustrout, "Try 'exit' to leave %s\n", mu_program_name);
mu_printf ("Try 'exit' to leave %s\n", mu_program_name);
return status;
}
......
......@@ -72,10 +72,9 @@ static struct argp query_argp = {
int
mutool_query (int argc, char **argv)
{
int rc, index;
int index;
mu_cfg_tree_t *tree = NULL;
int fmtflags = 0;
mu_stream_t stream;
if (argp_parse (&query_argp, argc, argv, ARGP_IN_ORDER, &index, NULL))
return 1;
......@@ -100,12 +99,6 @@ mutool_query (int argc, char **argv)
return 1;
if (!tree)
return 0;
rc = mu_stdio_stream_create (&stream, MU_STDOUT_FD, 0);
if (rc)
{
mu_error ("mu_stdio_stream_create: %s", mu_strerror (rc));
return 1;
}
if (verbose_option)
fmtflags = MU_CFG_FMT_LOCUS;
for ( ; argc > 0; argc--, argv++)
......@@ -114,7 +107,7 @@ mutool_query (int argc, char **argv)
mu_cfg_node_t *node;
if (mu_cfg_find_node (tree, path, &node) == 0)
mu_cfg_format_node (stream, node, fmtflags);
mu_cfg_format_node (mu_strout, node, fmtflags);
}
return 0;
}
......
......@@ -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;
}
......
......@@ -67,24 +67,24 @@ shell_verbose (int argc, char **argv,
{
if (QRY_VERBOSE ())
{
mu_stream_printf (mustrout, "verbose is on");
mu_printf ("verbose is on");
if (HAS_VERBOSE_MASK ())
{
char *delim = " (";
if (QRY_VERBOSE_MASK (MU_XSCRIPT_SECURE))
{
mu_stream_printf (mustrout, "%ssecure", delim);
mu_printf ("%ssecure", delim);
delim = ", ";
}
if (QRY_VERBOSE_MASK (MU_XSCRIPT_PAYLOAD))
mu_stream_printf (mustrout, "%spayload", delim);
mu_stream_printf (mustrout, ")");
mu_printf ("%spayload", delim);
mu_printf (")");
}
mu_stream_printf (mustrout, "\n");
mu_printf ("\n");
}
else
mu_stream_printf (mustrout, "verbose is off\n");
mu_printf ("verbose is off\n");
}
else
{
......
......@@ -103,16 +103,16 @@ wicket_match (mu_stream_t stream, const char *str)
ret = 0;
if (wicket_verbose)
{
printf ("%s: %s:%d", str, loc.file, loc.line);
mu_printf ("%s: %s:%d", str, loc.file, loc.line);
if (wicket_verbose > 1)
printf (": %s", mu_url_to_string (url));
putchar ('\n');
mu_printf (": %s", mu_url_to_string (url));
mu_printf ("\n");
}
break;
case MU_ERR_NOENT:
if (wicket_verbose)
printf ("%s: %s\n", str, _("not found"));
mu_printf ("%s: %s\n", str, _("not found"));
ret = 1;
break;
......