Commit 9221152b 9221152b3ac3aef5728923837a4ade51ac78b47c by Alain Magloire

The FILE* stream "stdout" is not an lvalue so it is an error to

        attempt to assign to it.  To be able to redirect at will stdout
        we need to assign it.  In GNU lib C, it was not error since stdout
        stderr, and stdin are variables, but to be portable we can not
        assume this.  The way out is to always use fprintf () and have
        a global varialbe "ofile" pointing to stdout.

        * mail/*: All the files under mail been change to use fprintf()
        and ofile as the default stdout.
        Copyright updated.
1 parent b13877db
2001-04-15 Alain Magloire
The FILE* stream "stdout" is not an lvalue so it is an error to
attempt to assign to it. To be able to redirect at will stdout
we need to assign it. In GNU lib C, it was not error since stdout
stderr, and stdin are variables, but to be portable we can not
assume this. The way out is to always use fprintf () and have
a global varialbe "ofile" pointing to stdout.
* mail/*: All the files under mail been change to use fprintf()
and ofile as the default stdout.
Copyright updated.
2001-04-15 Alain Magloire
Create a argp directory, it contains the necessary
files to build a standalone libargp.a
......
......@@ -2,7 +2,7 @@ AUTOMAKE_OPTIONS = ../lib/ansi2knr
INCLUDES = -I${top_srcdir}/lib
noinst_LIBRARIES = @ARGPLIBS@
noinst_LIBRARIES = @ARGPLIB@
libargp_a_SOURCES = argp-ba.c argp-eexst.c argp-fmtstream.c argp-fs-xinl.c \
argp-help.c argp-parse.c argp-pv.c argp-pvh.c argp-xinl.c pin.c
......
......@@ -89,7 +89,7 @@ __argp_fmtstream_free (argp_fmtstream_t fs)
{
__argp_fmtstream_update (fs);
if (fs->p > fs->buf)
fwrite_unlocked (fs->buf, 1, fs->p - fs->buf, fs->stream);
fwrite (fs->buf, 1, fs->p - fs->buf, fs->stream);
free (fs->buf);
free (fs);
}
......@@ -129,7 +129,7 @@ __argp_fmtstream_update (argp_fmtstream_t fs)
/* No buffer space for spaces. Must flush. */
size_t i;
for (i = 0; i < pad; i++)
putc_unlocked (' ', fs->stream);
putc (' ', fs->stream);
}
fs->point_col = pad;
}
......@@ -263,8 +263,8 @@ __argp_fmtstream_update (argp_fmtstream_t fs)
/* Output the first line so we can use the space. */
{
if (nl > fs->buf)
fwrite_unlocked (fs->buf, 1, nl - fs->buf, fs->stream);
putc_unlocked ('\n', fs->stream);
fwrite (fs->buf, 1, nl - fs->buf, fs->stream);
putc ('\n', fs->stream);
len += buf - fs->buf;
nl = buf = fs->buf;
}
......@@ -281,7 +281,7 @@ __argp_fmtstream_update (argp_fmtstream_t fs)
*nl++ = ' ';
else
for (i = 0; i < fs->wmargin; ++i)
putc_unlocked (' ', fs->stream);
putc (' ', fs->stream);
/* Copy the tail of the original buffer into the current buffer
position. */
......@@ -318,7 +318,7 @@ __argp_fmtstream_ensure (struct argp_fmtstream *fs, size_t amount)
/* Flush FS's buffer. */
__argp_fmtstream_update (fs);
wrote = fwrite_unlocked (fs->buf, 1, fs->p - fs->buf, fs->stream);
wrote = fwrite (fs->buf, 1, fs->p - fs->buf, fs->stream);
if (wrote == fs->p - fs->buf)
{
fs->p = fs->buf;
......
......@@ -75,9 +75,11 @@ dnl Check for libraries
AC_CHECK_FUNCS(argp_parse)
if test x"$ac_cv_func_argp_parse" != xyes; then
AC_REPLACE_FUNCS(strndup strnlen strchrnul)
ARGPLIBS="libargp.a"
ARGPLIBS="../argp/libargp.a"
ARGPLIB="libargp.a"
ARGPINCS="-I../argp"
AC_SUBST(ARGPLIBS)
AC_SUBST(ARGPLIB)
AC_SUBST(ARGPINCS)
fi
......
info_TEXINFOS = \
mailutils.texi
mailutils.texi
EXTRA_DIST = \
rfc1734.txt \
......@@ -7,6 +7,7 @@ EXTRA_DIST = \
rfc1957.txt \
rfc2060.txt \
rfc2449.txt \
address.texi \
attribute.texi \
auth.texi \
body.texi \
......@@ -15,6 +16,7 @@ EXTRA_DIST = \
locker.texi \
mailbox.texi \
mailer.texi \
message.texi \
sfrom.c.texi \
stream.texi \
url.texi \
......
/* GNU mailutils - a suite of utilities for electronic mail
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -25,6 +25,7 @@
int
mail_alias (int argc, char **argv)
{
printf ("Function not implemented in %s line %d\n", __FILE__, __LINE__);
fprintf (ofile, "Function not implemented in %s line %d\n",
__FILE__, __LINE__);
return 1;
}
......
/* GNU mailutils - a suite of utilities for electronic mail
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -24,6 +24,7 @@
int
mail_alt (int argc, char **argv)
{
printf ("Function not implemented in %s line %d\n", __FILE__, __LINE__);
fprintf (ofile, "Function not implemented in %s line %d\n",
__FILE__, __LINE__);
return 1;
}
......
/* GNU mailutils - a suite of utilities for electronic mail
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -36,7 +36,7 @@ mail_copy (int argc, char **argv)
int *msglist = NULL;
int num = 0, i = 0;
int sender = 0;
if (isupper (argv[0][0]))
sender = 1;
else if (argc >= 2)
......@@ -57,7 +57,7 @@ mail_copy (int argc, char **argv)
mailbox_create (&mbx, filename);
mailbox_open (mbx, MU_STREAM_WRITE | MU_STREAM_CREAT);
if (num > 0)
{
for (i=0; i < num; i++)
......
/* GNU mailutils - a suite of utilities for electronic mail
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......
/* GNU mailutils - a suite of utilities for electronic mail
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -25,6 +25,7 @@
int
mail_discard (int argc, char **argv)
{
printf ("Function not implemented in %s line %d\n", __FILE__, __LINE__);
fprintf (ofile, "Function not implemented in %s line %d\n",
__FILE__, __LINE__);
return 1;
}
......
/* GNU mailutils - a suite of utilities for electronic mail
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......
/* GNU mailutils - a suite of utilities for electronic mail
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -28,8 +28,8 @@ mail_echo (int argc, char **argv)
if (argc > 1)
{
for (i = 1; i < argc - 1; i++)
printf ("%s ", argv[i]);
printf ("%s\n", argv[argc - 1]);
fprintf (ofile, "%s ", argv[i]);
fprintf (ofile, "%s\n", argv[argc - 1]);
}
return 0;
}
......
/* GNU mailutils - a suite of utilities for electronic mail
Copyright (C) 1999, 2000 Free Software Foundation, Inc.
Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......
/* GNU mailutils - a suite of utilities for electronic mail
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -24,6 +24,6 @@
int
mail_eq (int argc, char **argv)
{
printf ("%d\n", realcursor);
fprintf (ofile, "%d\n", realcursor);
return 0;
}
......
/* GNU mailutils - a suite of utilities for electronic mail
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......
/* GNU mailutils - a suite of utilities for electronic mail
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......
/* GNU mailutils - a suite of utilities for electronic mail
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -24,6 +24,7 @@
int
mail_folders (int argc, char **argv)
{
printf ("Function not implemented in %s line %d\n", __FILE__, __LINE__);
fprintf (ofile, "Function not implemented in %s line %d\n",
__FILE__, __LINE__);
return 1;
}
......
/* GNU mailutils - a suite of utilities for electronic mail
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -25,6 +25,7 @@
int
mail_followup (int argc, char **argv)
{
printf ("Function not implemented in %s line %d\n", __FILE__, __LINE__);
fprintf (ofile, "Function not implemented in %s line %d\n",
__FILE__, __LINE__);
return 1;
}
......
/* GNU mailutils - a suite of utilities for electronic mail
Copyright (C) 1999, 2000 Free Software Foundation, Inc.
Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -61,7 +61,8 @@ mail_from (int argc, char **argv)
header_get_value (hdr, MU_HEADER_SUBJECT, subj, subjl, NULL);
snprintf (format, 64, "%%c%%2d %%-%ds%%-%ds\n", froml, subjl);
printf (format, cursor == realcursor ? '>' : ' ', cursor, from, subj);
fprintf (ofile, format, cursor == realcursor ? '>' : ' ', cursor,
from, subj);
free (from);
free (subj);
......
/* GNU mailutils - a suite of utilities for electronic mail
Copyright (C) 1999, 2000 Free Software Foundation, Inc.
Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -57,7 +57,7 @@ mail_headers (int argc, char **argv)
low = high - lines;
}
}
memset (buf, '\0', 64);
snprintf (buf, 64, "from %d-%d", low, high);
util_do_command (buf);
......
/* GNU mailutils - a suite of utilities for electronic mail
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -29,7 +29,7 @@ mail_help (int argc, char **argv)
{
int i = 0;
while (mail_command_table[i].synopsis != 0)
printf ("%s\n", mail_command_table[i++].synopsis);
fprintf (ofile, "%s\n", mail_command_table[i++].synopsis);
return 0;
}
else
......@@ -39,11 +39,11 @@ mail_help (int argc, char **argv)
{
struct mail_command_entry entry = util_find_entry (argv[cmd]);
if (entry.synopsis != NULL)
printf ("%s\n", entry.synopsis);
fprintf (ofile, "%s\n", entry.synopsis);
else
{
status = 1;
printf ("Unknown command: %s\n", argv[cmd]);
fprintf (ofile, "Unknown command: %s\n", argv[cmd]);
}
}
return status;
......
/* GNU mailutils - a suite of utilities for electronic mail
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -25,6 +25,7 @@
int
mail_hold (int argc, char **argv)
{
printf ("Function not implemented in %s line %d\n", __FILE__, __LINE__);
fprintf (ofile, "Function not implemented in %s line %d\n",
__FILE__, __LINE__);
return 1;
}
......
/* GNU mailutils - a suite of utilities for electronic mail
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -30,6 +30,7 @@
int
mail_if (int argc, char **argv)
{
printf ("Function not implemented in %s line %d\n", __FILE__, __LINE__);
fprintf (ofile, "Function not implemented in %s line %d\n",
__FILE__, __LINE__);
return 1;
}
......
/* GNU mailutils - a suite of utilities for electronic mail
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -45,11 +45,11 @@ mail_list (int argc, char **argv)
if (pos >= cols)
{
pos = len + 1;
printf ("\n%s ", cmd);
fprintf (ofile, "\n%s ", cmd);
}
else
printf ("%s ", cmd);
fprintf (ofile, "%s ", cmd);
}
printf ("\n");
fprintf (ofile, "\n");
return 0;
}
......
......@@ -126,6 +126,7 @@ main (int argc, char **argv)
int modelen = 0;
struct arguments args;
ofile = stdout;
cursor = 1;
realcursor = cursor;
......@@ -221,12 +222,12 @@ main (int argc, char **argv)
/* Interactive mode */
if (!(util_find_env("quiet"))->set)
{
printf ("%s, Copyright (C) 2001 Free Software Foundation, Inc.\n"
"mail comes with ABSOLUTELY NO WARRANTY; for details type\n"
"'warranty'. This is free software, and you are welcome to\n"
"redistribute it under certain conditions; type 'copying'\n"
"for details.\n",
argp_program_version);
fprintf (ofile, "%s, Copyright (C) 2001 Free Software Foundation, Inc.\n"
"mail comes with ABSOLUTELY NO WARRANTY; for details type\n"
"'warranty'. This is free software, and you are welcome to\n"
"redistribute it under certain conditions; type 'copying'\n"
"for details.\n",
argp_program_version);
}
/* Mode is just sending */
......
......@@ -84,6 +84,7 @@ mailbox_t mbox;
unsigned int cursor;
unsigned int realcursor;
unsigned int total;
FILE *ofile;
extern const struct mail_command_entry mail_command_table[];
/* Functions */
......
/* GNU mailutils - a suite of utilities for electronic mail
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -24,6 +24,7 @@
int
mail_mbox (int argc, char **argv)
{
printf ("Function not implemented in %s line %d\n", __FILE__, __LINE__);
fprintf (ofile, "Function not implemented in %s line %d\n",
__FILE__, __LINE__);
return 1;
}
......
/* GNU mailutils - a suite of utilities for electronic mail
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -18,7 +18,7 @@
#include "mail.h"
/*
* n[ext] [message]
* n[ext] [message]
* +
*/
......
/* GNU mailutils - a suite of utilities for electronic mail
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -74,7 +74,7 @@ mail_pipe (int argc, char **argv)
off += n;
}
}
free (list);
pclose (pipe);
return 0;
......
/* GNU mailutils - a suite of utilities for electronic mail
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......
/* GNU mailutils - a suite of utilities for electronic mail
Copyright (C) 1999, 2000 Free Software Foundation, Inc.
Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -39,7 +39,7 @@ mail_print (int argc, char **argv)
char buffer[BUFSIZ];
off_t off = 0;
size_t n = 0, lines = 0;
FILE *out = stdout;
FILE *out = ofile;
if (mailbox_get_message (mbox, cursor, &mesg) != 0)
return 1;
......@@ -73,15 +73,15 @@ mail_print (int argc, char **argv)
}
else
message_get_stream (mesg, &stream);
while (stream_read (stream, buffer, sizeof (buffer) - 1, off, &n) == 0
&& n != 0)
{
buffer[n] = '\0';
fprintf (out, "%s", buffer);
fprintf (out, "%s", buffer);
off += n;
}
if (out != stdout)
if (out != ofile)
pclose (out);
return 0;
}
......
/* GNU mailutils - a suite of utilities for electronic mail
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......
/* GNU mailutils - a suite of utilities for electronic mail
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -27,6 +27,7 @@
int
mail_reply (int argc, char **argv)
{
printf ("Function not implemented in %s line %d\n", __FILE__, __LINE__);
fprintf (ofile, "Function not implemented in %s line %d\n",
__FILE__, __LINE__);
return 1;
}
......
/* GNU mailutils - a suite of utilities for electronic mail
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -24,6 +24,7 @@
int
mail_retain (int argc, char **argv)
{
printf ("Function not implemented in %s line %d\n", __FILE__, __LINE__);
fprintf (ofile, "Function not implemented in %s line %d\n",
__FILE__, __LINE__);
return 1;
}
......
/* GNU mailutils - a suite of utilities for electronic mail
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......
......@@ -84,8 +84,8 @@ mail_send (int argc, char **argv)
{
if (buf[0] == (util_find_env("escape"))->value[0])
{
FILE *ostdout = stdout;
stdout = file;
FILE *ostdout = ofile;
ofile = file;
buf[strlen(buf)-1] = '\0';
switch (buf[1])
{
......@@ -103,10 +103,10 @@ mail_send (int argc, char **argv)
/* escape help */
break;
case 'A':
printf ("%s", (util_find_env("Sign"))->value);
fprintf (ofile, "%s", (util_find_env("Sign"))->value);
break;
case 'a':
printf ("%s", (util_find_env("sign"))->value);
fprintf (ofile, "%s", (util_find_env("sign"))->value);
break;
case 'b':
bcc = realloc (bcc, (strlen(bcc) + strlen(buf) - 1) *
......@@ -131,10 +131,10 @@ mail_send (int argc, char **argv)
break;
case 'e':
fclose (file);
stdout = ostdout;
ofile = ostdout;
util_do_command ("!%s %s", getenv("EDITOR"), filename);
file = fopen (filename, "a");
stdout = file;
ofile = file;
break;
case 'f':
util_do_command ("print %s", &buf[3]);
......@@ -156,13 +156,13 @@ mail_send (int argc, char **argv)
break;
case 'p':
fclose (file);
stdout = ostdout;
ofile = ostdout;
if (/* numlines (filename) > */ util_getlines())
util_do_command ("!%s %s", getenv("PAGER"), filename);
else
/* dump filename */;
file = fopen (filename, "a");
stdout = file;
ofile = file;
break;
case 'q':
fclose (file);
......@@ -185,10 +185,10 @@ mail_send (int argc, char **argv)
break;
case 'v':
fclose (file);
stdout = ostdout;
ofile = ostdout;
util_do_command ("!%s %s", getenv("VISUAL"), filename);
file = fopen (filename, "a");
stdout = file;
ofile = file;
break;
case 'w':
{
......@@ -207,7 +207,7 @@ mail_send (int argc, char **argv)
fprintf (stderr, "Unknown escape %c\n", buf[0]);
break;
}
stdout = ostdout;
ofile = ostdout;
}
else
fprintf (file, "%s", buf);
......
/* GNU mailutils - a suite of utilities for electronic mail
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -46,17 +46,17 @@ mail_shell (int argc, char **argv)
{
char **argvec;
char *buf = NULL;
/* 1(shell) + 1 (-c) + 1(arg) + 1 (null) = 4 */
argvec = malloc (4 * (sizeof (char *)));
argcv_string (argc-1, &argv[1], &buf);
argvec[0] = getenv("SHELL");
argvec[1] = "-c";
argvec[2] = buf;
argvec[3] = NULL;
execvp (argvec[0], argvec);
free (buf); /* Being cute, nuke it when finish testing. */
free (argvec);
......
/* GNU mailutils - a suite of utilities for electronic mail
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -36,7 +36,8 @@ mail_size (int argc, char **argv)
return 1;
}
message_size (msg, &s);
printf ("%c%2d %d\n", cursor == realcursor ? '>' : ' ', cursor, s);
fprintf (ofile, "%c%2d %d\n", cursor == realcursor ? '>' : ' ',
cursor, s);
return 0;
}
return 1;
......
......@@ -39,7 +39,7 @@ mail_source (int argc, char **argv)
util_do_command("%s", buf);
free (buf);
buf = NULL;
}
}
fclose (rc);
return 0;
}
......
/* GNU mailutils - a suite of utilities for electronic mail
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......
/* GNU mailutils - a suite of utilities for electronic mail
Copyright (C) 1999, 2000 Free Software Foundation, Inc.
Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -50,7 +50,7 @@ mail_top (int argc, char **argv)
int status = stream_readline (stream, buf, sizeof (buf), off, &n);
if (status != 0 || n == 0)
break;
printf ("%s", buf);
fprintf (ofile, "%s", buf);
}
return 0;
}
......
/* GNU mailutils - a suite of utilities for electronic mail
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -24,6 +24,7 @@
int
mail_touch (int argc, char **argv)
{
printf ("Function not implemented in %s line %d\n", __FILE__, __LINE__);
fprintf (ofile, "Function not implemented in %s line %d\n",
__FILE__, __LINE__);
return 1;
}
......
/* GNU mailutils - a suite of utilities for electronic mail
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -24,6 +24,7 @@
int
mail_unalias (int argc, char **argv)
{
printf ("Function not implemented in %s line %d\n", __FILE__, __LINE__);
fprintf (ofile, "Function not implemented in %s line %d\n",
__FILE__, __LINE__);
return 1;
}
......
/* GNU mailutils - a suite of utilities for electronic mail
Copyright (C) 1999, 2000 Free Software Foundation, Inc.
Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -32,7 +32,7 @@ mail_undelete (int argc, char **argv)
attribute_t attr;
if (mailbox_get_message (mbox, cursor, &msg) != 0)
{
fprintf (stderr, "Meessage %d does not exist\n", cursor);
fprintf (stderr, "Meessage %d does not exist\n", cursor);
return 1;
}
message_get_attribute (msg, &attr);
......
/* GNU mailutils - a suite of utilities for electronic mail
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......
......@@ -250,7 +250,7 @@ util_do_command (const char *c, ...)
status = command (argc, argv);
else
{
printf ("Unknown command: %s\n", argv[0]);
fprintf (ofile, "Unknown command: %s\n", argv[0]);
status = 1;
}
......@@ -418,10 +418,10 @@ util_printenv (int set)
{
if (env_cursor->env_entry.set == set)
{
printf ("%s", env_cursor->env_entry.var);
fprintf (ofile, "%s", env_cursor->env_entry.var);
if (env_cursor->env_entry.value != NULL)
printf ("=%s", env_cursor->env_entry.value);
printf ("\n");
fprintf (ofile, "=%s", env_cursor->env_entry.value);
fprintf (ofile, "\n");
}
}
return 0;
......@@ -489,51 +489,50 @@ readline (const char *prompt)
{
char *line;
char *p;
size_t linelen, total;
size_t alloclen, linelen;
if (prompt)
{
printf ("%s",prompt);
fflush(stdout);
fprintf (ofile, "%s",prompt);
fflush (ofile);
}
p = line = calloc (1, 255);
linelen = 255;
total = 0;
alloclen = 255;
linelen = 0;
for (;;)
{
size_t len;
p = fgets (p, linelen, stdin);
len = (p) ? strlen (p) : 0;
size_t n;
p = fgets (p, alloclen - linelen, stdin);
n = (p) ? strlen (p) : 0;
total += len;
linelen += n;
/* Error. */
if (total == 0)
if (linelen == 0)
{
free (line);
return NULL;
}
/* Ok. */
if (line[total - 1] == '\n')
if (line[linelen - 1] == '\n')
{
line[total - 1] = '\0';
line[linelen - 1] = '\0';
return line;
}
else
{
char *tmp;
linelen *= 2;
tmp = realloc (line, linelen);
alloclen *= 2;
tmp = realloc (line, alloclen);
if (tmp == NULL)
{
free (line);
return NULL;
}
line = tmp;
p = line + total;
total += len;
p = line + linelen;
}
}
}
......
/* GNU mailutils - a suite of utilities for electronic mail
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......
/* GNU mailutils - a suite of utilities for electronic mail
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -41,7 +41,7 @@ mail_write (int argc, char **argv)
int *msglist = NULL;
int num = 0, i = 0;
int sender = 0;
if (isupper (argv[0][0]))
sender = 1;
else if (argc >= 2)
......
/* GNU mailutils - a suite of utilities for electronic mail
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -24,6 +24,7 @@
int
mail_z (int argc, char **argv)
{
printf ("Function not implemented in %s line %d\n", __FILE__, __LINE__);
fprintf (ofile, "Function not implemented in %s line %d\n",
__FILE__, __LINE__);
return 1;
}
......