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
1 2001-04-15 Alain Magloire 1 2001-04-15 Alain Magloire
2 2
3 The FILE* stream "stdout" is not an lvalue so it is an error to
4 attempt to assign to it. To be able to redirect at will stdout
5 we need to assign it. In GNU lib C, it was not error since stdout
6 stderr, and stdin are variables, but to be portable we can not
7 assume this. The way out is to always use fprintf () and have
8 a global varialbe "ofile" pointing to stdout.
9
10 * mail/*: All the files under mail been change to use fprintf()
11 and ofile as the default stdout.
12 Copyright updated.
13
14 2001-04-15 Alain Magloire
15
3 Create a argp directory, it contains the necessary 16 Create a argp directory, it contains the necessary
4 files to build a standalone libargp.a 17 files to build a standalone libargp.a
5 18
......
...@@ -2,7 +2,7 @@ AUTOMAKE_OPTIONS = ../lib/ansi2knr ...@@ -2,7 +2,7 @@ AUTOMAKE_OPTIONS = ../lib/ansi2knr
2 2
3 INCLUDES = -I${top_srcdir}/lib 3 INCLUDES = -I${top_srcdir}/lib
4 4
5 noinst_LIBRARIES = @ARGPLIBS@ 5 noinst_LIBRARIES = @ARGPLIB@
6 6
7 libargp_a_SOURCES = argp-ba.c argp-eexst.c argp-fmtstream.c argp-fs-xinl.c \ 7 libargp_a_SOURCES = argp-ba.c argp-eexst.c argp-fmtstream.c argp-fs-xinl.c \
8 argp-help.c argp-parse.c argp-pv.c argp-pvh.c argp-xinl.c pin.c 8 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) ...@@ -89,7 +89,7 @@ __argp_fmtstream_free (argp_fmtstream_t fs)
89 { 89 {
90 __argp_fmtstream_update (fs); 90 __argp_fmtstream_update (fs);
91 if (fs->p > fs->buf) 91 if (fs->p > fs->buf)
92 fwrite_unlocked (fs->buf, 1, fs->p - fs->buf, fs->stream); 92 fwrite (fs->buf, 1, fs->p - fs->buf, fs->stream);
93 free (fs->buf); 93 free (fs->buf);
94 free (fs); 94 free (fs);
95 } 95 }
...@@ -129,7 +129,7 @@ __argp_fmtstream_update (argp_fmtstream_t fs) ...@@ -129,7 +129,7 @@ __argp_fmtstream_update (argp_fmtstream_t fs)
129 /* No buffer space for spaces. Must flush. */ 129 /* No buffer space for spaces. Must flush. */
130 size_t i; 130 size_t i;
131 for (i = 0; i < pad; i++) 131 for (i = 0; i < pad; i++)
132 putc_unlocked (' ', fs->stream); 132 putc (' ', fs->stream);
133 } 133 }
134 fs->point_col = pad; 134 fs->point_col = pad;
135 } 135 }
...@@ -263,8 +263,8 @@ __argp_fmtstream_update (argp_fmtstream_t fs) ...@@ -263,8 +263,8 @@ __argp_fmtstream_update (argp_fmtstream_t fs)
263 /* Output the first line so we can use the space. */ 263 /* Output the first line so we can use the space. */
264 { 264 {
265 if (nl > fs->buf) 265 if (nl > fs->buf)
266 fwrite_unlocked (fs->buf, 1, nl - fs->buf, fs->stream); 266 fwrite (fs->buf, 1, nl - fs->buf, fs->stream);
267 putc_unlocked ('\n', fs->stream); 267 putc ('\n', fs->stream);
268 len += buf - fs->buf; 268 len += buf - fs->buf;
269 nl = buf = fs->buf; 269 nl = buf = fs->buf;
270 } 270 }
...@@ -281,7 +281,7 @@ __argp_fmtstream_update (argp_fmtstream_t fs) ...@@ -281,7 +281,7 @@ __argp_fmtstream_update (argp_fmtstream_t fs)
281 *nl++ = ' '; 281 *nl++ = ' ';
282 else 282 else
283 for (i = 0; i < fs->wmargin; ++i) 283 for (i = 0; i < fs->wmargin; ++i)
284 putc_unlocked (' ', fs->stream); 284 putc (' ', fs->stream);
285 285
286 /* Copy the tail of the original buffer into the current buffer 286 /* Copy the tail of the original buffer into the current buffer
287 position. */ 287 position. */
...@@ -318,7 +318,7 @@ __argp_fmtstream_ensure (struct argp_fmtstream *fs, size_t amount) ...@@ -318,7 +318,7 @@ __argp_fmtstream_ensure (struct argp_fmtstream *fs, size_t amount)
318 /* Flush FS's buffer. */ 318 /* Flush FS's buffer. */
319 __argp_fmtstream_update (fs); 319 __argp_fmtstream_update (fs);
320 320
321 wrote = fwrite_unlocked (fs->buf, 1, fs->p - fs->buf, fs->stream); 321 wrote = fwrite (fs->buf, 1, fs->p - fs->buf, fs->stream);
322 if (wrote == fs->p - fs->buf) 322 if (wrote == fs->p - fs->buf)
323 { 323 {
324 fs->p = fs->buf; 324 fs->p = fs->buf;
......
...@@ -75,9 +75,11 @@ dnl Check for libraries ...@@ -75,9 +75,11 @@ dnl Check for libraries
75 AC_CHECK_FUNCS(argp_parse) 75 AC_CHECK_FUNCS(argp_parse)
76 if test x"$ac_cv_func_argp_parse" != xyes; then 76 if test x"$ac_cv_func_argp_parse" != xyes; then
77 AC_REPLACE_FUNCS(strndup strnlen strchrnul) 77 AC_REPLACE_FUNCS(strndup strnlen strchrnul)
78 ARGPLIBS="libargp.a" 78 ARGPLIBS="../argp/libargp.a"
79 ARGPLIB="libargp.a"
79 ARGPINCS="-I../argp" 80 ARGPINCS="-I../argp"
80 AC_SUBST(ARGPLIBS) 81 AC_SUBST(ARGPLIBS)
82 AC_SUBST(ARGPLIB)
81 AC_SUBST(ARGPINCS) 83 AC_SUBST(ARGPINCS)
82 fi 84 fi
83 85
......
1 info_TEXINFOS = \ 1 info_TEXINFOS = \
2 mailutils.texi 2 mailutils.texi
3 3
4 EXTRA_DIST = \ 4 EXTRA_DIST = \
5 rfc1734.txt \ 5 rfc1734.txt \
...@@ -7,6 +7,7 @@ EXTRA_DIST = \ ...@@ -7,6 +7,7 @@ EXTRA_DIST = \
7 rfc1957.txt \ 7 rfc1957.txt \
8 rfc2060.txt \ 8 rfc2060.txt \
9 rfc2449.txt \ 9 rfc2449.txt \
10 address.texi \
10 attribute.texi \ 11 attribute.texi \
11 auth.texi \ 12 auth.texi \
12 body.texi \ 13 body.texi \
...@@ -15,6 +16,7 @@ EXTRA_DIST = \ ...@@ -15,6 +16,7 @@ EXTRA_DIST = \
15 locker.texi \ 16 locker.texi \
16 mailbox.texi \ 17 mailbox.texi \
17 mailer.texi \ 18 mailer.texi \
19 message.texi \
18 sfrom.c.texi \ 20 sfrom.c.texi \
19 stream.texi \ 21 stream.texi \
20 url.texi \ 22 url.texi \
......
1 /* GNU mailutils - a suite of utilities for electronic mail 1 /* GNU mailutils - a suite of utilities for electronic mail
2 Copyright (C) 1999 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2001 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
25 int 25 int
26 mail_alias (int argc, char **argv) 26 mail_alias (int argc, char **argv)
27 { 27 {
28 printf ("Function not implemented in %s line %d\n", __FILE__, __LINE__); 28 fprintf (ofile, "Function not implemented in %s line %d\n",
29 __FILE__, __LINE__);
29 return 1; 30 return 1;
30 } 31 }
......
1 /* GNU mailutils - a suite of utilities for electronic mail 1 /* GNU mailutils - a suite of utilities for electronic mail
2 Copyright (C) 1999 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2001 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
24 int 24 int
25 mail_alt (int argc, char **argv) 25 mail_alt (int argc, char **argv)
26 { 26 {
27 printf ("Function not implemented in %s line %d\n", __FILE__, __LINE__); 27 fprintf (ofile, "Function not implemented in %s line %d\n",
28 __FILE__, __LINE__);
28 return 1; 29 return 1;
29 } 30 }
......
1 /* GNU mailutils - a suite of utilities for electronic mail 1 /* GNU mailutils - a suite of utilities for electronic mail
2 Copyright (C) 1999 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2001 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
...@@ -36,7 +36,7 @@ mail_copy (int argc, char **argv) ...@@ -36,7 +36,7 @@ mail_copy (int argc, char **argv)
36 int *msglist = NULL; 36 int *msglist = NULL;
37 int num = 0, i = 0; 37 int num = 0, i = 0;
38 int sender = 0; 38 int sender = 0;
39 39
40 if (isupper (argv[0][0])) 40 if (isupper (argv[0][0]))
41 sender = 1; 41 sender = 1;
42 else if (argc >= 2) 42 else if (argc >= 2)
...@@ -57,7 +57,7 @@ mail_copy (int argc, char **argv) ...@@ -57,7 +57,7 @@ mail_copy (int argc, char **argv)
57 57
58 mailbox_create (&mbx, filename); 58 mailbox_create (&mbx, filename);
59 mailbox_open (mbx, MU_STREAM_WRITE | MU_STREAM_CREAT); 59 mailbox_open (mbx, MU_STREAM_WRITE | MU_STREAM_CREAT);
60 60
61 if (num > 0) 61 if (num > 0)
62 { 62 {
63 for (i=0; i < num; i++) 63 for (i=0; i < num; i++)
......
1 /* GNU mailutils - a suite of utilities for electronic mail 1 /* GNU mailutils - a suite of utilities for electronic mail
2 Copyright (C) 1999 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2001 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
......
1 /* GNU mailutils - a suite of utilities for electronic mail 1 /* GNU mailutils - a suite of utilities for electronic mail
2 Copyright (C) 1999 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2001 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
25 int 25 int
26 mail_discard (int argc, char **argv) 26 mail_discard (int argc, char **argv)
27 { 27 {
28 printf ("Function not implemented in %s line %d\n", __FILE__, __LINE__); 28 fprintf (ofile, "Function not implemented in %s line %d\n",
29 __FILE__, __LINE__);
29 return 1; 30 return 1;
30 } 31 }
......
1 /* GNU mailutils - a suite of utilities for electronic mail 1 /* GNU mailutils - a suite of utilities for electronic mail
2 Copyright (C) 1999 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2001 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
......
1 /* GNU mailutils - a suite of utilities for electronic mail 1 /* GNU mailutils - a suite of utilities for electronic mail
2 Copyright (C) 1999 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2001 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
...@@ -28,8 +28,8 @@ mail_echo (int argc, char **argv) ...@@ -28,8 +28,8 @@ mail_echo (int argc, char **argv)
28 if (argc > 1) 28 if (argc > 1)
29 { 29 {
30 for (i = 1; i < argc - 1; i++) 30 for (i = 1; i < argc - 1; i++)
31 printf ("%s ", argv[i]); 31 fprintf (ofile, "%s ", argv[i]);
32 printf ("%s\n", argv[argc - 1]); 32 fprintf (ofile, "%s\n", argv[argc - 1]);
33 } 33 }
34 return 0; 34 return 0;
35 } 35 }
......
1 /* GNU mailutils - a suite of utilities for electronic mail 1 /* GNU mailutils - a suite of utilities for electronic mail
2 Copyright (C) 1999, 2000 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
......
1 /* GNU mailutils - a suite of utilities for electronic mail 1 /* GNU mailutils - a suite of utilities for electronic mail
2 Copyright (C) 1999 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2001 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
...@@ -24,6 +24,6 @@ ...@@ -24,6 +24,6 @@
24 int 24 int
25 mail_eq (int argc, char **argv) 25 mail_eq (int argc, char **argv)
26 { 26 {
27 printf ("%d\n", realcursor); 27 fprintf (ofile, "%d\n", realcursor);
28 return 0; 28 return 0;
29 } 29 }
......
1 /* GNU mailutils - a suite of utilities for electronic mail 1 /* GNU mailutils - a suite of utilities for electronic mail
2 Copyright (C) 1999 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2001 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
......
1 /* GNU mailutils - a suite of utilities for electronic mail 1 /* GNU mailutils - a suite of utilities for electronic mail
2 Copyright (C) 1999 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2001 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
......
1 /* GNU mailutils - a suite of utilities for electronic mail 1 /* GNU mailutils - a suite of utilities for electronic mail
2 Copyright (C) 1999 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2001 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
24 int 24 int
25 mail_folders (int argc, char **argv) 25 mail_folders (int argc, char **argv)
26 { 26 {
27 printf ("Function not implemented in %s line %d\n", __FILE__, __LINE__); 27 fprintf (ofile, "Function not implemented in %s line %d\n",
28 __FILE__, __LINE__);
28 return 1; 29 return 1;
29 } 30 }
......
1 /* GNU mailutils - a suite of utilities for electronic mail 1 /* GNU mailutils - a suite of utilities for electronic mail
2 Copyright (C) 1999 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2001 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
25 int 25 int
26 mail_followup (int argc, char **argv) 26 mail_followup (int argc, char **argv)
27 { 27 {
28 printf ("Function not implemented in %s line %d\n", __FILE__, __LINE__); 28 fprintf (ofile, "Function not implemented in %s line %d\n",
29 __FILE__, __LINE__);
29 return 1; 30 return 1;
30 } 31 }
......
1 /* GNU mailutils - a suite of utilities for electronic mail 1 /* GNU mailutils - a suite of utilities for electronic mail
2 Copyright (C) 1999, 2000 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
...@@ -61,7 +61,8 @@ mail_from (int argc, char **argv) ...@@ -61,7 +61,8 @@ mail_from (int argc, char **argv)
61 header_get_value (hdr, MU_HEADER_SUBJECT, subj, subjl, NULL); 61 header_get_value (hdr, MU_HEADER_SUBJECT, subj, subjl, NULL);
62 62
63 snprintf (format, 64, "%%c%%2d %%-%ds%%-%ds\n", froml, subjl); 63 snprintf (format, 64, "%%c%%2d %%-%ds%%-%ds\n", froml, subjl);
64 printf (format, cursor == realcursor ? '>' : ' ', cursor, from, subj); 64 fprintf (ofile, format, cursor == realcursor ? '>' : ' ', cursor,
65 from, subj);
65 66
66 free (from); 67 free (from);
67 free (subj); 68 free (subj);
......
1 /* GNU mailutils - a suite of utilities for electronic mail 1 /* GNU mailutils - a suite of utilities for electronic mail
2 Copyright (C) 1999, 2000 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
...@@ -57,7 +57,7 @@ mail_headers (int argc, char **argv) ...@@ -57,7 +57,7 @@ mail_headers (int argc, char **argv)
57 low = high - lines; 57 low = high - lines;
58 } 58 }
59 } 59 }
60 60
61 memset (buf, '\0', 64); 61 memset (buf, '\0', 64);
62 snprintf (buf, 64, "from %d-%d", low, high); 62 snprintf (buf, 64, "from %d-%d", low, high);
63 util_do_command (buf); 63 util_do_command (buf);
......
1 /* GNU mailutils - a suite of utilities for electronic mail 1 /* GNU mailutils - a suite of utilities for electronic mail
2 Copyright (C) 1999 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2001 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
...@@ -29,7 +29,7 @@ mail_help (int argc, char **argv) ...@@ -29,7 +29,7 @@ mail_help (int argc, char **argv)
29 { 29 {
30 int i = 0; 30 int i = 0;
31 while (mail_command_table[i].synopsis != 0) 31 while (mail_command_table[i].synopsis != 0)
32 printf ("%s\n", mail_command_table[i++].synopsis); 32 fprintf (ofile, "%s\n", mail_command_table[i++].synopsis);
33 return 0; 33 return 0;
34 } 34 }
35 else 35 else
...@@ -39,11 +39,11 @@ mail_help (int argc, char **argv) ...@@ -39,11 +39,11 @@ mail_help (int argc, char **argv)
39 { 39 {
40 struct mail_command_entry entry = util_find_entry (argv[cmd]); 40 struct mail_command_entry entry = util_find_entry (argv[cmd]);
41 if (entry.synopsis != NULL) 41 if (entry.synopsis != NULL)
42 printf ("%s\n", entry.synopsis); 42 fprintf (ofile, "%s\n", entry.synopsis);
43 else 43 else
44 { 44 {
45 status = 1; 45 status = 1;
46 printf ("Unknown command: %s\n", argv[cmd]); 46 fprintf (ofile, "Unknown command: %s\n", argv[cmd]);
47 } 47 }
48 } 48 }
49 return status; 49 return status;
......
1 /* GNU mailutils - a suite of utilities for electronic mail 1 /* GNU mailutils - a suite of utilities for electronic mail
2 Copyright (C) 1999 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2001 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
25 int 25 int
26 mail_hold (int argc, char **argv) 26 mail_hold (int argc, char **argv)
27 { 27 {
28 printf ("Function not implemented in %s line %d\n", __FILE__, __LINE__); 28 fprintf (ofile, "Function not implemented in %s line %d\n",
29 __FILE__, __LINE__);
29 return 1; 30 return 1;
30 } 31 }
......
1 /* GNU mailutils - a suite of utilities for electronic mail 1 /* GNU mailutils - a suite of utilities for electronic mail
2 Copyright (C) 1999 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2001 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
30 int 30 int
31 mail_if (int argc, char **argv) 31 mail_if (int argc, char **argv)
32 { 32 {
33 printf ("Function not implemented in %s line %d\n", __FILE__, __LINE__); 33 fprintf (ofile, "Function not implemented in %s line %d\n",
34 __FILE__, __LINE__);
34 return 1; 35 return 1;
35 } 36 }
......
1 /* GNU mailutils - a suite of utilities for electronic mail 1 /* GNU mailutils - a suite of utilities for electronic mail
2 Copyright (C) 1999 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2001 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
...@@ -45,11 +45,11 @@ mail_list (int argc, char **argv) ...@@ -45,11 +45,11 @@ mail_list (int argc, char **argv)
45 if (pos >= cols) 45 if (pos >= cols)
46 { 46 {
47 pos = len + 1; 47 pos = len + 1;
48 printf ("\n%s ", cmd); 48 fprintf (ofile, "\n%s ", cmd);
49 } 49 }
50 else 50 else
51 printf ("%s ", cmd); 51 fprintf (ofile, "%s ", cmd);
52 } 52 }
53 printf ("\n"); 53 fprintf (ofile, "\n");
54 return 0; 54 return 0;
55 } 55 }
......
...@@ -126,6 +126,7 @@ main (int argc, char **argv) ...@@ -126,6 +126,7 @@ main (int argc, char **argv)
126 int modelen = 0; 126 int modelen = 0;
127 struct arguments args; 127 struct arguments args;
128 128
129 ofile = stdout;
129 cursor = 1; 130 cursor = 1;
130 realcursor = cursor; 131 realcursor = cursor;
131 132
...@@ -221,12 +222,12 @@ main (int argc, char **argv) ...@@ -221,12 +222,12 @@ main (int argc, char **argv)
221 /* Interactive mode */ 222 /* Interactive mode */
222 if (!(util_find_env("quiet"))->set) 223 if (!(util_find_env("quiet"))->set)
223 { 224 {
224 printf ("%s, Copyright (C) 2001 Free Software Foundation, Inc.\n" 225 fprintf (ofile, "%s, Copyright (C) 2001 Free Software Foundation, Inc.\n"
225 "mail comes with ABSOLUTELY NO WARRANTY; for details type\n" 226 "mail comes with ABSOLUTELY NO WARRANTY; for details type\n"
226 "'warranty'. This is free software, and you are welcome to\n" 227 "'warranty'. This is free software, and you are welcome to\n"
227 "redistribute it under certain conditions; type 'copying'\n" 228 "redistribute it under certain conditions; type 'copying'\n"
228 "for details.\n", 229 "for details.\n",
229 argp_program_version); 230 argp_program_version);
230 } 231 }
231 232
232 /* Mode is just sending */ 233 /* Mode is just sending */
......
...@@ -84,6 +84,7 @@ mailbox_t mbox; ...@@ -84,6 +84,7 @@ mailbox_t mbox;
84 unsigned int cursor; 84 unsigned int cursor;
85 unsigned int realcursor; 85 unsigned int realcursor;
86 unsigned int total; 86 unsigned int total;
87 FILE *ofile;
87 extern const struct mail_command_entry mail_command_table[]; 88 extern const struct mail_command_entry mail_command_table[];
88 89
89 /* Functions */ 90 /* Functions */
......
1 /* GNU mailutils - a suite of utilities for electronic mail 1 /* GNU mailutils - a suite of utilities for electronic mail
2 Copyright (C) 1999 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2001 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
24 int 24 int
25 mail_mbox (int argc, char **argv) 25 mail_mbox (int argc, char **argv)
26 { 26 {
27 printf ("Function not implemented in %s line %d\n", __FILE__, __LINE__); 27 fprintf (ofile, "Function not implemented in %s line %d\n",
28 __FILE__, __LINE__);
28 return 1; 29 return 1;
29 } 30 }
......
1 /* GNU mailutils - a suite of utilities for electronic mail 1 /* GNU mailutils - a suite of utilities for electronic mail
2 Copyright (C) 1999 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2001 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
18 #include "mail.h" 18 #include "mail.h"
19 19
20 /* 20 /*
21 * n[ext] [message] 21 * n[ext] [message]
22 * + 22 * +
23 */ 23 */
24 24
......
1 /* GNU mailutils - a suite of utilities for electronic mail 1 /* GNU mailutils - a suite of utilities for electronic mail
2 Copyright (C) 1999 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2001 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
...@@ -74,7 +74,7 @@ mail_pipe (int argc, char **argv) ...@@ -74,7 +74,7 @@ mail_pipe (int argc, char **argv)
74 off += n; 74 off += n;
75 } 75 }
76 } 76 }
77 77
78 free (list); 78 free (list);
79 pclose (pipe); 79 pclose (pipe);
80 return 0; 80 return 0;
......
1 /* GNU mailutils - a suite of utilities for electronic mail 1 /* GNU mailutils - a suite of utilities for electronic mail
2 Copyright (C) 1999 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2001 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
......
1 /* GNU mailutils - a suite of utilities for electronic mail 1 /* GNU mailutils - a suite of utilities for electronic mail
2 Copyright (C) 1999, 2000 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
...@@ -39,7 +39,7 @@ mail_print (int argc, char **argv) ...@@ -39,7 +39,7 @@ mail_print (int argc, char **argv)
39 char buffer[BUFSIZ]; 39 char buffer[BUFSIZ];
40 off_t off = 0; 40 off_t off = 0;
41 size_t n = 0, lines = 0; 41 size_t n = 0, lines = 0;
42 FILE *out = stdout; 42 FILE *out = ofile;
43 43
44 if (mailbox_get_message (mbox, cursor, &mesg) != 0) 44 if (mailbox_get_message (mbox, cursor, &mesg) != 0)
45 return 1; 45 return 1;
...@@ -73,15 +73,15 @@ mail_print (int argc, char **argv) ...@@ -73,15 +73,15 @@ mail_print (int argc, char **argv)
73 } 73 }
74 else 74 else
75 message_get_stream (mesg, &stream); 75 message_get_stream (mesg, &stream);
76 76
77 while (stream_read (stream, buffer, sizeof (buffer) - 1, off, &n) == 0 77 while (stream_read (stream, buffer, sizeof (buffer) - 1, off, &n) == 0
78 && n != 0) 78 && n != 0)
79 { 79 {
80 buffer[n] = '\0'; 80 buffer[n] = '\0';
81 fprintf (out, "%s", buffer); 81 fprintf (out, "%s", buffer);
82 off += n; 82 off += n;
83 } 83 }
84 if (out != stdout) 84 if (out != ofile)
85 pclose (out); 85 pclose (out);
86 return 0; 86 return 0;
87 } 87 }
......
1 /* GNU mailutils - a suite of utilities for electronic mail 1 /* GNU mailutils - a suite of utilities for electronic mail
2 Copyright (C) 1999 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2001 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
......
1 /* GNU mailutils - a suite of utilities for electronic mail 1 /* GNU mailutils - a suite of utilities for electronic mail
2 Copyright (C) 1999 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2001 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
27 int 27 int
28 mail_reply (int argc, char **argv) 28 mail_reply (int argc, char **argv)
29 { 29 {
30 printf ("Function not implemented in %s line %d\n", __FILE__, __LINE__); 30 fprintf (ofile, "Function not implemented in %s line %d\n",
31 __FILE__, __LINE__);
31 return 1; 32 return 1;
32 } 33 }
......
1 /* GNU mailutils - a suite of utilities for electronic mail 1 /* GNU mailutils - a suite of utilities for electronic mail
2 Copyright (C) 1999 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2001 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
24 int 24 int
25 mail_retain (int argc, char **argv) 25 mail_retain (int argc, char **argv)
26 { 26 {
27 printf ("Function not implemented in %s line %d\n", __FILE__, __LINE__); 27 fprintf (ofile, "Function not implemented in %s line %d\n",
28 __FILE__, __LINE__);
28 return 1; 29 return 1;
29 } 30 }
......
1 /* GNU mailutils - a suite of utilities for electronic mail 1 /* GNU mailutils - a suite of utilities for electronic mail
2 Copyright (C) 1999 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2001 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
......
...@@ -84,8 +84,8 @@ mail_send (int argc, char **argv) ...@@ -84,8 +84,8 @@ mail_send (int argc, char **argv)
84 { 84 {
85 if (buf[0] == (util_find_env("escape"))->value[0]) 85 if (buf[0] == (util_find_env("escape"))->value[0])
86 { 86 {
87 FILE *ostdout = stdout; 87 FILE *ostdout = ofile;
88 stdout = file; 88 ofile = file;
89 buf[strlen(buf)-1] = '\0'; 89 buf[strlen(buf)-1] = '\0';
90 switch (buf[1]) 90 switch (buf[1])
91 { 91 {
...@@ -103,10 +103,10 @@ mail_send (int argc, char **argv) ...@@ -103,10 +103,10 @@ mail_send (int argc, char **argv)
103 /* escape help */ 103 /* escape help */
104 break; 104 break;
105 case 'A': 105 case 'A':
106 printf ("%s", (util_find_env("Sign"))->value); 106 fprintf (ofile, "%s", (util_find_env("Sign"))->value);
107 break; 107 break;
108 case 'a': 108 case 'a':
109 printf ("%s", (util_find_env("sign"))->value); 109 fprintf (ofile, "%s", (util_find_env("sign"))->value);
110 break; 110 break;
111 case 'b': 111 case 'b':
112 bcc = realloc (bcc, (strlen(bcc) + strlen(buf) - 1) * 112 bcc = realloc (bcc, (strlen(bcc) + strlen(buf) - 1) *
...@@ -131,10 +131,10 @@ mail_send (int argc, char **argv) ...@@ -131,10 +131,10 @@ mail_send (int argc, char **argv)
131 break; 131 break;
132 case 'e': 132 case 'e':
133 fclose (file); 133 fclose (file);
134 stdout = ostdout; 134 ofile = ostdout;
135 util_do_command ("!%s %s", getenv("EDITOR"), filename); 135 util_do_command ("!%s %s", getenv("EDITOR"), filename);
136 file = fopen (filename, "a"); 136 file = fopen (filename, "a");
137 stdout = file; 137 ofile = file;
138 break; 138 break;
139 case 'f': 139 case 'f':
140 util_do_command ("print %s", &buf[3]); 140 util_do_command ("print %s", &buf[3]);
...@@ -156,13 +156,13 @@ mail_send (int argc, char **argv) ...@@ -156,13 +156,13 @@ mail_send (int argc, char **argv)
156 break; 156 break;
157 case 'p': 157 case 'p':
158 fclose (file); 158 fclose (file);
159 stdout = ostdout; 159 ofile = ostdout;
160 if (/* numlines (filename) > */ util_getlines()) 160 if (/* numlines (filename) > */ util_getlines())
161 util_do_command ("!%s %s", getenv("PAGER"), filename); 161 util_do_command ("!%s %s", getenv("PAGER"), filename);
162 else 162 else
163 /* dump filename */; 163 /* dump filename */;
164 file = fopen (filename, "a"); 164 file = fopen (filename, "a");
165 stdout = file; 165 ofile = file;
166 break; 166 break;
167 case 'q': 167 case 'q':
168 fclose (file); 168 fclose (file);
...@@ -185,10 +185,10 @@ mail_send (int argc, char **argv) ...@@ -185,10 +185,10 @@ mail_send (int argc, char **argv)
185 break; 185 break;
186 case 'v': 186 case 'v':
187 fclose (file); 187 fclose (file);
188 stdout = ostdout; 188 ofile = ostdout;
189 util_do_command ("!%s %s", getenv("VISUAL"), filename); 189 util_do_command ("!%s %s", getenv("VISUAL"), filename);
190 file = fopen (filename, "a"); 190 file = fopen (filename, "a");
191 stdout = file; 191 ofile = file;
192 break; 192 break;
193 case 'w': 193 case 'w':
194 { 194 {
...@@ -207,7 +207,7 @@ mail_send (int argc, char **argv) ...@@ -207,7 +207,7 @@ mail_send (int argc, char **argv)
207 fprintf (stderr, "Unknown escape %c\n", buf[0]); 207 fprintf (stderr, "Unknown escape %c\n", buf[0]);
208 break; 208 break;
209 } 209 }
210 stdout = ostdout; 210 ofile = ostdout;
211 } 211 }
212 else 212 else
213 fprintf (file, "%s", buf); 213 fprintf (file, "%s", buf);
......
1 /* GNU mailutils - a suite of utilities for electronic mail 1 /* GNU mailutils - a suite of utilities for electronic mail
2 Copyright (C) 1999 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2001 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
...@@ -46,17 +46,17 @@ mail_shell (int argc, char **argv) ...@@ -46,17 +46,17 @@ mail_shell (int argc, char **argv)
46 { 46 {
47 char **argvec; 47 char **argvec;
48 char *buf = NULL; 48 char *buf = NULL;
49 49
50 /* 1(shell) + 1 (-c) + 1(arg) + 1 (null) = 4 */ 50 /* 1(shell) + 1 (-c) + 1(arg) + 1 (null) = 4 */
51 argvec = malloc (4 * (sizeof (char *))); 51 argvec = malloc (4 * (sizeof (char *)));
52 52
53 argcv_string (argc-1, &argv[1], &buf); 53 argcv_string (argc-1, &argv[1], &buf);
54 54
55 argvec[0] = getenv("SHELL"); 55 argvec[0] = getenv("SHELL");
56 argvec[1] = "-c"; 56 argvec[1] = "-c";
57 argvec[2] = buf; 57 argvec[2] = buf;
58 argvec[3] = NULL; 58 argvec[3] = NULL;
59 59
60 execvp (argvec[0], argvec); 60 execvp (argvec[0], argvec);
61 free (buf); /* Being cute, nuke it when finish testing. */ 61 free (buf); /* Being cute, nuke it when finish testing. */
62 free (argvec); 62 free (argvec);
......
1 /* GNU mailutils - a suite of utilities for electronic mail 1 /* GNU mailutils - a suite of utilities for electronic mail
2 Copyright (C) 1999 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2001 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
...@@ -36,7 +36,8 @@ mail_size (int argc, char **argv) ...@@ -36,7 +36,8 @@ mail_size (int argc, char **argv)
36 return 1; 36 return 1;
37 } 37 }
38 message_size (msg, &s); 38 message_size (msg, &s);
39 printf ("%c%2d %d\n", cursor == realcursor ? '>' : ' ', cursor, s); 39 fprintf (ofile, "%c%2d %d\n", cursor == realcursor ? '>' : ' ',
40 cursor, s);
40 return 0; 41 return 0;
41 } 42 }
42 return 1; 43 return 1;
......
...@@ -39,7 +39,7 @@ mail_source (int argc, char **argv) ...@@ -39,7 +39,7 @@ mail_source (int argc, char **argv)
39 util_do_command("%s", buf); 39 util_do_command("%s", buf);
40 free (buf); 40 free (buf);
41 buf = NULL; 41 buf = NULL;
42 } 42 }
43 fclose (rc); 43 fclose (rc);
44 return 0; 44 return 0;
45 } 45 }
......
1 /* GNU mailutils - a suite of utilities for electronic mail 1 /* GNU mailutils - a suite of utilities for electronic mail
2 Copyright (C) 1999 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2001 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
......
1 /* GNU mailutils - a suite of utilities for electronic mail 1 /* GNU mailutils - a suite of utilities for electronic mail
2 Copyright (C) 1999, 2000 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
...@@ -50,7 +50,7 @@ mail_top (int argc, char **argv) ...@@ -50,7 +50,7 @@ mail_top (int argc, char **argv)
50 int status = stream_readline (stream, buf, sizeof (buf), off, &n); 50 int status = stream_readline (stream, buf, sizeof (buf), off, &n);
51 if (status != 0 || n == 0) 51 if (status != 0 || n == 0)
52 break; 52 break;
53 printf ("%s", buf); 53 fprintf (ofile, "%s", buf);
54 } 54 }
55 return 0; 55 return 0;
56 } 56 }
......
1 /* GNU mailutils - a suite of utilities for electronic mail 1 /* GNU mailutils - a suite of utilities for electronic mail
2 Copyright (C) 1999 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2001 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
24 int 24 int
25 mail_touch (int argc, char **argv) 25 mail_touch (int argc, char **argv)
26 { 26 {
27 printf ("Function not implemented in %s line %d\n", __FILE__, __LINE__); 27 fprintf (ofile, "Function not implemented in %s line %d\n",
28 __FILE__, __LINE__);
28 return 1; 29 return 1;
29 } 30 }
......
1 /* GNU mailutils - a suite of utilities for electronic mail 1 /* GNU mailutils - a suite of utilities for electronic mail
2 Copyright (C) 1999 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2001 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
24 int 24 int
25 mail_unalias (int argc, char **argv) 25 mail_unalias (int argc, char **argv)
26 { 26 {
27 printf ("Function not implemented in %s line %d\n", __FILE__, __LINE__); 27 fprintf (ofile, "Function not implemented in %s line %d\n",
28 __FILE__, __LINE__);
28 return 1; 29 return 1;
29 } 30 }
......
1 /* GNU mailutils - a suite of utilities for electronic mail 1 /* GNU mailutils - a suite of utilities for electronic mail
2 Copyright (C) 1999, 2000 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
...@@ -32,7 +32,7 @@ mail_undelete (int argc, char **argv) ...@@ -32,7 +32,7 @@ mail_undelete (int argc, char **argv)
32 attribute_t attr; 32 attribute_t attr;
33 if (mailbox_get_message (mbox, cursor, &msg) != 0) 33 if (mailbox_get_message (mbox, cursor, &msg) != 0)
34 { 34 {
35 fprintf (stderr, "Meessage %d does not exist\n", cursor); 35 fprintf (stderr, "Meessage %d does not exist\n", cursor);
36 return 1; 36 return 1;
37 } 37 }
38 message_get_attribute (msg, &attr); 38 message_get_attribute (msg, &attr);
......
1 /* GNU mailutils - a suite of utilities for electronic mail 1 /* GNU mailutils - a suite of utilities for electronic mail
2 Copyright (C) 1999 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2001 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
......
...@@ -250,7 +250,7 @@ util_do_command (const char *c, ...) ...@@ -250,7 +250,7 @@ util_do_command (const char *c, ...)
250 status = command (argc, argv); 250 status = command (argc, argv);
251 else 251 else
252 { 252 {
253 printf ("Unknown command: %s\n", argv[0]); 253 fprintf (ofile, "Unknown command: %s\n", argv[0]);
254 status = 1; 254 status = 1;
255 } 255 }
256 256
...@@ -418,10 +418,10 @@ util_printenv (int set) ...@@ -418,10 +418,10 @@ util_printenv (int set)
418 { 418 {
419 if (env_cursor->env_entry.set == set) 419 if (env_cursor->env_entry.set == set)
420 { 420 {
421 printf ("%s", env_cursor->env_entry.var); 421 fprintf (ofile, "%s", env_cursor->env_entry.var);
422 if (env_cursor->env_entry.value != NULL) 422 if (env_cursor->env_entry.value != NULL)
423 printf ("=%s", env_cursor->env_entry.value); 423 fprintf (ofile, "=%s", env_cursor->env_entry.value);
424 printf ("\n"); 424 fprintf (ofile, "\n");
425 } 425 }
426 } 426 }
427 return 0; 427 return 0;
...@@ -489,51 +489,50 @@ readline (const char *prompt) ...@@ -489,51 +489,50 @@ readline (const char *prompt)
489 { 489 {
490 char *line; 490 char *line;
491 char *p; 491 char *p;
492 size_t linelen, total; 492 size_t alloclen, linelen;
493 493
494 if (prompt) 494 if (prompt)
495 { 495 {
496 printf ("%s",prompt); 496 fprintf (ofile, "%s",prompt);
497 fflush(stdout); 497 fflush (ofile);
498 } 498 }
499 499
500 p = line = calloc (1, 255); 500 p = line = calloc (1, 255);
501 linelen = 255; 501 alloclen = 255;
502 total = 0; 502 linelen = 0;
503 for (;;) 503 for (;;)
504 { 504 {
505 size_t len; 505 size_t n;
506 p = fgets (p, linelen, stdin); 506 p = fgets (p, alloclen - linelen, stdin);
507 len = (p) ? strlen (p) : 0; 507 n = (p) ? strlen (p) : 0;
508 508
509 total += len; 509 linelen += n;
510 510
511 /* Error. */ 511 /* Error. */
512 if (total == 0) 512 if (linelen == 0)
513 { 513 {
514 free (line); 514 free (line);
515 return NULL; 515 return NULL;
516 } 516 }
517 517
518 /* Ok. */ 518 /* Ok. */
519 if (line[total - 1] == '\n') 519 if (line[linelen - 1] == '\n')
520 { 520 {
521 line[total - 1] = '\0'; 521 line[linelen - 1] = '\0';
522 return line; 522 return line;
523 } 523 }
524 else 524 else
525 { 525 {
526 char *tmp; 526 char *tmp;
527 linelen *= 2; 527 alloclen *= 2;
528 tmp = realloc (line, linelen); 528 tmp = realloc (line, alloclen);
529 if (tmp == NULL) 529 if (tmp == NULL)
530 { 530 {
531 free (line); 531 free (line);
532 return NULL; 532 return NULL;
533 } 533 }
534 line = tmp; 534 line = tmp;
535 p = line + total; 535 p = line + linelen;
536 total += len;
537 } 536 }
538 } 537 }
539 } 538 }
......
1 /* GNU mailutils - a suite of utilities for electronic mail 1 /* GNU mailutils - a suite of utilities for electronic mail
2 Copyright (C) 1999 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2001 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
......
1 /* GNU mailutils - a suite of utilities for electronic mail 1 /* GNU mailutils - a suite of utilities for electronic mail
2 Copyright (C) 1999 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2001 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
...@@ -41,7 +41,7 @@ mail_write (int argc, char **argv) ...@@ -41,7 +41,7 @@ mail_write (int argc, char **argv)
41 int *msglist = NULL; 41 int *msglist = NULL;
42 int num = 0, i = 0; 42 int num = 0, i = 0;
43 int sender = 0; 43 int sender = 0;
44 44
45 if (isupper (argv[0][0])) 45 if (isupper (argv[0][0]))
46 sender = 1; 46 sender = 1;
47 else if (argc >= 2) 47 else if (argc >= 2)
......
1 /* GNU mailutils - a suite of utilities for electronic mail 1 /* GNU mailutils - a suite of utilities for electronic mail
2 Copyright (C) 1999 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2001 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
24 int 24 int
25 mail_z (int argc, char **argv) 25 mail_z (int argc, char **argv)
26 { 26 {
27 printf ("Function not implemented in %s line %d\n", __FILE__, __LINE__); 27 fprintf (ofile, "Function not implemented in %s line %d\n",
28 __FILE__, __LINE__);
28 return 1; 29 return 1;
29 } 30 }
......