Commit 73895a52 73895a52221e74ddc2f5130eb6798ed7b24b250a by Alain Magloire

The exercise is to crank up the warnings from gcc and cleanup

	the code based on the hints generated by the compiler.  The usual
	errors:
	- signed vs unsigned, signedness or unsignedness problems.
	- printf() wrong formats
	- wrong prototypes declarations
	- and different buglets
	- "const char *" vs "char *"
	- unused variables
	- unused arguments.  Tell the compiler by typecasting to void
	 (void)var.
	- Some variable when shadowed, meaning in another block variable
	of the same name where reused.
	- atoi() is not an ANSI C function, we should use strtol().

	Changes to comply to GNU coding standards, and nuke trailing spaces.

	* mail/alias.c (alia_lookup): No prototypes and scope static.
	(hash_num, max_rehash, aliases): Scope static and unsigned.
	(hash): unsigned.
	(alias_rehash): i unsigned.
	(alias_lookup_or_install): slot variable unused.
	(alias_destroy): unsigned.
	* mail/copy.c (mail_copy0): fprintf wrong format.
	* mail/decode.c: dislay_message change prototype.
	(mail_decode): Cast when calling util_msgset_iterate().
	(display_message): Prototype change.
	(display_headers): unsigned issues.
	* mail/delete.c: Buglet was caling mail_delete0() instead of
	mail_delete.
	* mail/eq.c: Unused arguments.
	* mail/exit.c: Unused arguments.
	* mail/folders.c: Unused arguments.
	* mail/followup.c: Unused variables.
	* mail/from.c (mail_from): variable buffer was shadowing use variable
	name instead. snprintf() formatting issues.
* mail/headers.c: Unsigned issues.
	* mail/if.c: Unused arguments.
	* mail/inc.c: Unused arguments.
	* mail/list.c: Use const char *.
	* mail/mail.c: options[], argp[] initialised all elements.
	(mail_cmdline): Unused arguments.
	(main): Unsigned issues.
	(mail_warranty): Unused arguments.
	* mail/mail.h: function_t with complete prototype this necessary
	to let the compiler do proper checks.
	struct mail_command_entry rearrange the fields and a new field
	int (*escfunc) __P ((int, char **, struct send_environ *));
	Indentation rearrangements.
	* mail/mailline.c (ml_getc): Scope is static now.
	typecast for const char *.
	(ml_reread): Typecast.
	* mail/msgset.y: Declare yyerror() and yylex().
	(msgset_select): Change of prototpe to let the compiler do checks.
	(selec_sender): Unsused arguments.
	* mail/pipe.c: Rename variable pipe to tube.
	* mail/print.c: Unsigness and some shadow variables.
	* mail/quit.c: Shadow variables.
	* mail/send.c: Typecast when necessary. Use the second (escfunc)
	field now. Some shadow variables.
	* mail/shell.c: Unsigned.
	* mail/table.c: Readjust the table to correspond to the signature
	change in mail.h.
	* mail/tag.c: Prototype change.
	* mail/util.c (util_msglist_esccmd): New function.
	(util_find_entry): Prototype change.  And check return value
	of getenv().
	(util_screen_lines): Change atoi() to strtoul().
	(util_screen_columns): Change atoi() to strtoul().
	(util_find_env): Signedness.
	(util_fullpath): Prototype changed(const).
	(util_slist_to_string):Protorype changed (const).
	(util_strcat) :Protorype changed (const).
	(util_tempfile): const.
	* mail/var.c: Unsignedness, Unused arguments.
	(var_quote):  Use new function util_msglist_esccmd().
	* mail/version.c: Unused arguments.
	* mail/write.c: printf formats.
	* mail/z.c: Signedness.
1 parent 068a9ac3
...@@ -17,9 +17,10 @@ ...@@ -17,9 +17,10 @@
17 17
18 #include "mail.h" 18 #include "mail.h"
19 19
20 static void alias_print __P((char *name)); 20 static void alias_print __P ((char *name));
21 static void alias_print_group __P((char *name, list_t list)); 21 static void alias_print_group __P ((char *name, list_t list));
22 static int alias_create __P((char *name, list_t *plist)); 22 static int alias_create __P ((char *name, list_t *plist));
23 static int alias_lookup __P ((char *name, list_t *plist));
23 24
24 /* 25 /*
25 * a[lias] [alias [address...]] 26 * a[lias] [alias [address...]]
...@@ -60,16 +61,16 @@ struct _alias ...@@ -60,16 +61,16 @@ struct _alias
60 pair of them grows exponentially, starting from 64. 61 pair of them grows exponentially, starting from 64.
61 Hopefully no one will need more than 32797 aliases, and even if 62 Hopefully no one will need more than 32797 aliases, and even if
62 someone will, it is easy enough to add more numbers to the sequence. */ 63 someone will, it is easy enough to add more numbers to the sequence. */
63 size_t hash_size[] = 64 static unsigned int hash_size[] =
64 { 65 {
65 37, 101, 229, 487, 1009, 2039, 4091, 8191, 16411, 32797, 66 37, 101, 229, 487, 1009, 2039, 4091, 8191, 16411, 32797,
66 }; 67 };
67 /* Maximum number of re-hashes: */ 68 /* Maximum number of re-hashes: */
68 int max_rehash = sizeof (hash_size) / sizeof (hash_size[0]); 69 static unsigned int max_rehash = sizeof (hash_size) / sizeof (hash_size[0]);
69 alias_t *aliases; /* Table of aliases */ 70 static alias_t *aliases; /* Table of aliases */
70 size_t hash_num; /* Index to hash_size table */ 71 static unsigned int hash_num; /* Index to hash_size table */
71 72
72 static unsigned hash __P((char *name)); 73 static unsigned int hash __P((char *name));
73 static int alias_rehash __P((void)); 74 static int alias_rehash __P((void));
74 static alias_t *alias_lookup_or_install __P((char *name, int install)); 75 static alias_t *alias_lookup_or_install __P((char *name, int install));
75 static void alias_print_group __P((char *name, list_t list)); 76 static void alias_print_group __P((char *name, list_t list));
...@@ -91,7 +92,7 @@ alias_rehash() ...@@ -91,7 +92,7 @@ alias_rehash()
91 { 92 {
92 alias_t *old_aliases = aliases; 93 alias_t *old_aliases = aliases;
93 alias_t *ap; 94 alias_t *ap;
94 int i; 95 unsigned int i;
95 96
96 if (++hash_num >= max_rehash) 97 if (++hash_num >= max_rehash)
97 { 98 {
...@@ -120,7 +121,6 @@ alias_t * ...@@ -120,7 +121,6 @@ alias_t *
120 alias_lookup_or_install(char *name, int install) 121 alias_lookup_or_install(char *name, int install)
121 { 122 {
122 unsigned i, pos; 123 unsigned i, pos;
123 alias_t *slot = NULL;
124 124
125 if (!aliases) 125 if (!aliases)
126 { 126 {
...@@ -157,7 +157,7 @@ alias_lookup_or_install(char *name, int install) ...@@ -157,7 +157,7 @@ alias_lookup_or_install(char *name, int install)
157 return alias_lookup_or_install(name, install); 157 return alias_lookup_or_install(name, install);
158 } 158 }
159 159
160 int 160 static int
161 alias_lookup(char *name, list_t *plist) 161 alias_lookup(char *name, list_t *plist)
162 { 162 {
163 alias_t *ap = alias_lookup_or_install(name, 0); 163 alias_t *ap = alias_lookup_or_install(name, 0);
...@@ -174,7 +174,7 @@ alias_print(char *name) ...@@ -174,7 +174,7 @@ alias_print(char *name)
174 { 174 {
175 if (!name) 175 if (!name)
176 { 176 {
177 int i; 177 unsigned int i;
178 178
179 if (!aliases) 179 if (!aliases)
180 return; 180 return;
...@@ -231,7 +231,7 @@ alias_print_group(char *name, list_t list) ...@@ -231,7 +231,7 @@ alias_print_group(char *name, list_t list)
231 void 231 void
232 alias_destroy(char *name) 232 alias_destroy(char *name)
233 { 233 {
234 int i, j, r; 234 unsigned int i, j, r;
235 alias_t *alias = alias_lookup_or_install(name, 0); 235 alias_t *alias = alias_lookup_or_install(name, 0);
236 if (!alias) 236 if (!alias)
237 return; 237 return;
...@@ -265,4 +265,3 @@ alias_expand(char *name) ...@@ -265,4 +265,3 @@ alias_expand(char *name)
265 return strdup (name); 265 return strdup (name);
266 return util_slist_to_string(list, ","); 266 return util_slist_to_string(list, ",");
267 } 267 }
268
......
...@@ -89,7 +89,7 @@ mail_copy0 (int argc, char **argv, int mark) ...@@ -89,7 +89,7 @@ mail_copy0 (int argc, char **argv, int mark)
89 } 89 }
90 } 90 }
91 91
92 fprintf (ofile, "\"%s\" %3ld/%-5ld\n", filename, total_lines, total_size); 92 fprintf (ofile, "\"%s\" %3d/%-5d\n", filename, total_lines, total_size);
93 93
94 mailbox_close (mbx); 94 mailbox_close (mbx);
95 mailbox_destroy (&mbx); 95 mailbox_destroy (&mbx);
......
...@@ -29,8 +29,7 @@ struct decode_closure ...@@ -29,8 +29,7 @@ struct decode_closure
29 }; 29 };
30 30
31 static int print_stream __P ((stream_t, FILE *)); 31 static int print_stream __P ((stream_t, FILE *));
32 static int display_message __P ((message_t, msgset_t *msgset, 32 static int display_message __P ((message_t, msgset_t *msgset, void *closure));
33 struct decode_closure *closure));
34 static int display_message0 __P ((FILE *, message_t, const msgset_t *, int)); 33 static int display_message0 __P ((FILE *, message_t, const msgset_t *, int));
35 static int mailcap_lookup __P ((const char *)); 34 static int mailcap_lookup __P ((const char *));
36 static int get_content_encoding __P ((header_t hdr, char **value)); 35 static int get_content_encoding __P ((header_t hdr, char **value));
...@@ -46,24 +45,24 @@ mail_decode (int argc, char **argv) ...@@ -46,24 +45,24 @@ mail_decode (int argc, char **argv)
46 45
47 decode_closure.select_hdr = islower (argv[0][0]); 46 decode_closure.select_hdr = islower (argv[0][0]);
48 47
49 util_msgset_iterate (msgset, display_message, &decode_closure); 48 util_msgset_iterate (msgset, display_message, (void *)&decode_closure);
50 49
51 msgset_free (msgset); 50 msgset_free (msgset);
52 return 0; 51 return 0;
53 } 52 }
54 53
55 int 54 int
56 display_message (message_t mesg, msgset_t *msgset, 55 display_message (message_t mesg, msgset_t *msgset, void *arg)
57 struct decode_closure *closure)
58 { 56 {
59 FILE *out; 57 FILE *out;
60 size_t lines = 0; 58 size_t lines = 0;
59 struct decode_closure *closure = arg;
61 60
62 if (util_isdeleted (msgset->msg_part[0])) 61 if (util_isdeleted (msgset->msg_part[0]))
63 return 1; 62 return 1;
64 63
65 message_lines (mesg, &lines); 64 message_lines (mesg, &lines);
66 if ((util_find_env("crt"))->set && lines > util_getlines ()) 65 if ((util_find_env("crt"))->set && (int)lines > util_getlines ())
67 out = popen (getenv("PAGER"), "w"); 66 out = popen (getenv("PAGER"), "w");
68 else 67 else
69 out = ofile; 68 out = ofile;
...@@ -88,6 +87,8 @@ display_headers (FILE *out, message_t mesg, const msgset_t *msgset, ...@@ -88,6 +87,8 @@ display_headers (FILE *out, message_t mesg, const msgset_t *msgset,
88 int select_hdr) 87 int select_hdr)
89 { 88 {
90 header_t hdr = NULL; 89 header_t hdr = NULL;
90
91 (void)msgset;
91 /* Print the selected headers only. */ 92 /* Print the selected headers only. */
92 if (select_hdr) 93 if (select_hdr)
93 { 94 {
...@@ -119,15 +120,15 @@ display_headers (FILE *out, message_t mesg, const msgset_t *msgset, ...@@ -119,15 +120,15 @@ display_headers (FILE *out, message_t mesg, const msgset_t *msgset,
119 } 120 }
120 } 121 }
121 122
122 void 123 static void
123 display_part_header (FILE *out, const msgset_t *msgset, 124 display_part_header (FILE *out, const msgset_t *msgset,
124 char *type, char *encoding) 125 char *type, char *encoding)
125 { 126 {
126 int size = util_screen_columns () - 3; 127 int size = util_screen_columns () - 3;
127 int i; 128 unsigned int i;
128 129
129 fputc ('+', out); 130 fputc ('+', out);
130 for (i = 0; i <= size; i++) 131 for (i = 0; (int)i <= size; i++)
131 fputc ('-', out); 132 fputc ('-', out);
132 fputc ('+', out); 133 fputc ('+', out);
133 fputc ('\n', out); 134 fputc ('\n', out);
...@@ -141,7 +142,7 @@ display_part_header (FILE *out, const msgset_t *msgset, ...@@ -141,7 +142,7 @@ display_part_header (FILE *out, const msgset_t *msgset,
141 fprintf (out, "| Type=%s\n", type); 142 fprintf (out, "| Type=%s\n", type);
142 fprintf (out, "| encoding=%s\n", encoding); 143 fprintf (out, "| encoding=%s\n", encoding);
143 fputc ('+', out); 144 fputc ('+', out);
144 for (i = 0; i <= size; i++) 145 for (i = 0; (int)i <= size; i++)
145 fputc ('-', out); 146 fputc ('-', out);
146 fputc ('+', out); 147 fputc ('+', out);
147 fputc ('\n', out); 148 fputc ('\n', out);
...@@ -164,7 +165,7 @@ display_message0 (FILE *out, message_t mesg, const msgset_t *msgset, ...@@ -164,7 +165,7 @@ display_message0 (FILE *out, message_t mesg, const msgset_t *msgset,
164 message_is_multipart (mesg, &ismime); 165 message_is_multipart (mesg, &ismime);
165 if (ismime) 166 if (ismime)
166 { 167 {
167 int j; 168 unsigned int j;
168 169
169 message_get_num_parts (mesg, &nparts); 170 message_get_num_parts (mesg, &nparts);
170 171
......
...@@ -21,8 +21,8 @@ ...@@ -21,8 +21,8 @@
21 * d[elete] [msglist] 21 * d[elete] [msglist]
22 */ 22 */
23 23
24 int 24 static int
25 mail_delete0 () 25 mail_delete0 (void)
26 { 26 {
27 message_t msg; 27 message_t msg;
28 attribute_t attr; 28 attribute_t attr;
...@@ -39,13 +39,14 @@ mail_delete (int argc, char **argv) ...@@ -39,13 +39,14 @@ mail_delete (int argc, char **argv)
39 int rc = 0; 39 int rc = 0;
40 40
41 if (argc > 1) 41 if (argc > 1)
42 rc = util_msglist_command (mail_delete0, argc, argv, 0); 42 rc = util_msglist_command (mail_delete, argc, argv, 0);
43 else 43 else
44 rc = mail_delete0 (); 44 rc = mail_delete0 ();
45 45
46 /* Reajust the realcursor to no point to the deleted messages. */
46 if (cursor == realcursor) 47 if (cursor == realcursor)
47 { 48 {
48 int here = realcursor; 49 unsigned int here = realcursor;
49 do 50 do
50 { 51 {
51 message_t msg; 52 message_t msg;
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
24 int 24 int
25 mail_eq (int argc, char **argv) 25 mail_eq (int argc, char **argv)
26 { 26 {
27 (void)argc; (void)argv;
27 fprintf (ofile, "%d\n", realcursor); 28 fprintf (ofile, "%d\n", realcursor);
28 return 0; 29 return 0;
29 } 30 }
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
20 int 20 int
21 mail_exit (int argc, char **argv) 21 mail_exit (int argc, char **argv)
22 { 22 {
23 (void)argc; (void)argv;
23 mailbox_close (mbox); 24 mailbox_close (mbox);
24 exit (0); 25 exit (0);
25 } 26 }
......
...@@ -27,6 +27,8 @@ mail_folders (int argc, char **argv) ...@@ -27,6 +27,8 @@ mail_folders (int argc, char **argv)
27 char *path; 27 char *path;
28 struct mail_env_entry *env = util_find_env ("folder"); 28 struct mail_env_entry *env = util_find_env ("folder");
29 29
30 (void)argc; (void)argv;
31
30 if (!env->set) 32 if (!env->set)
31 { 33 {
32 util_error("No value set for \"folder\""); 34 util_error("No value set for \"folder\"");
......
...@@ -28,7 +28,6 @@ mail_followup (int argc, char **argv) ...@@ -28,7 +28,6 @@ mail_followup (int argc, char **argv)
28 message_t msg; 28 message_t msg;
29 header_t hdr; 29 header_t hdr;
30 char *str; 30 char *str;
31 int i;
32 msgset_t *msglist, *mp; 31 msgset_t *msglist, *mp;
33 struct send_environ env; 32 struct send_environ env;
34 int status; 33 int status;
......
...@@ -54,13 +54,13 @@ mail_from (int argc, char **argv) ...@@ -54,13 +54,13 @@ mail_from (int argc, char **argv)
54 address_t address = NULL; 54 address_t address = NULL;
55 if (address_create (&address, from) == 0) 55 if (address_create (&address, from) == 0)
56 { 56 {
57 char p[128]; 57 char name[128];
58 size_t len = strlen (from); 58 size_t len = strlen (from);
59 *p = '\0'; 59 *name = '\0';
60 address_get_personal (address, 1, p, sizeof p, NULL); 60 address_get_personal (address, 1, name, sizeof name, NULL);
61 if (*p && len) 61 if (*name && len)
62 { 62 {
63 strncpy (from, p, len - 1); 63 strncpy (from, name, len - 1);
64 from[len - 1] = '\0'; 64 from[len - 1] = '\0';
65 } 65 }
66 else 66 else
...@@ -103,7 +103,7 @@ mail_from (int argc, char **argv) ...@@ -103,7 +103,7 @@ mail_from (int argc, char **argv)
103 message_size (msg, &m_size); 103 message_size (msg, &m_size);
104 message_lines (msg, &m_lines); 104 message_lines (msg, &m_lines);
105 105
106 snprintf (st, sizeof(st), "%3ld/%-5ld", m_lines, m_size); 106 snprintf (st, sizeof(st), "%3d/%-5d", m_lines, m_size);
107 107
108 /* The "From" field will take a third of the screen. 108 /* The "From" field will take a third of the screen.
109 Subject will take the rest. 109 Subject will take the rest.
......
...@@ -45,13 +45,13 @@ mail_headers (int argc, char **argv) ...@@ -45,13 +45,13 @@ mail_headers (int argc, char **argv)
45 if (lines < 0) 45 if (lines < 0)
46 lines = util_screen_lines (); 46 lines = util_screen_lines ();
47 47
48 if (lines < total) 48 if ((unsigned int)lines < total)
49 { 49 {
50 low = list->msg_part[0] - (lines / 2); 50 low = list->msg_part[0] - (lines / 2);
51 if (low < 1) 51 if (low < 1)
52 low = 1; 52 low = 1;
53 high = low + lines; 53 high = low + lines;
54 if (high > total) 54 if ((unsigned int)high > total)
55 { 55 {
56 high = total; 56 high = total;
57 low = high - lines; 57 low = high - lines;
......
...@@ -131,6 +131,7 @@ int ...@@ -131,6 +131,7 @@ int
131 mail_else (int argc, char **argv) 131 mail_else (int argc, char **argv)
132 { 132 {
133 int cond; 133 int cond;
134 (void)argc; (void)argv;
134 if (_cond_level == 0) 135 if (_cond_level == 0)
135 { 136 {
136 util_error("else without matching if"); 137 util_error("else without matching if");
...@@ -146,6 +147,7 @@ mail_else (int argc, char **argv) ...@@ -146,6 +147,7 @@ mail_else (int argc, char **argv)
146 int 147 int
147 mail_endif (int argc, char **argv) 148 mail_endif (int argc, char **argv)
148 { 149 {
150 (void)argc; (void)argv;
149 if (_cond_level == 0) 151 if (_cond_level == 0)
150 { 152 {
151 util_error("endif without matching if"); 153 util_error("endif without matching if");
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
24 int 24 int
25 mail_inc (int argc, char **argv) 25 mail_inc (int argc, char **argv)
26 { 26 {
27 (void)argc; (void)argv;
27 if (!mailbox_is_updated (mbox)) 28 if (!mailbox_is_updated (mbox))
28 { 29 {
29 mailbox_messages_count (mbox, &total); 30 mailbox_messages_count (mbox, &total);
......
...@@ -25,10 +25,12 @@ ...@@ -25,10 +25,12 @@
25 int 25 int
26 mail_list (int argc, char **argv) 26 mail_list (int argc, char **argv)
27 { 27 {
28 char *cmd = NULL; 28 const char *cmd = NULL;
29 int i = 0, pos = 0, len = 0; 29 int i = 0, pos = 0, len = 0;
30 int cols = util_getcols (); 30 int cols = util_getcols ();
31 31
32 (void)argc; (void)argv;
33
32 for (i=0; mail_command_table[i].shortname != 0; i++) 34 for (i=0; mail_command_table[i].shortname != 0; i++)
33 { 35 {
34 len = strlen (mail_command_table[i].longname); 36 len = strlen (mail_command_table[i].longname);
......
...@@ -31,21 +31,21 @@ static char doc[] = "GNU mail -- the standard /bin/mail interface"; ...@@ -31,21 +31,21 @@ static char doc[] = "GNU mail -- the standard /bin/mail interface";
31 static char args_doc[] = "[address...]"; 31 static char args_doc[] = "[address...]";
32 32
33 static struct argp_option options[] = { 33 static struct argp_option options[] = {
34 {"exist", 'e', 0, 0, "Return true if mail exists"}, 34 {"exist", 'e', 0, 0, "Return true if mail exists", 0},
35 {"file", 'f', "FILE", OPTION_ARG_OPTIONAL, 35 {"file", 'f', "FILE", OPTION_ARG_OPTIONAL,
36 "Operate on mailbox FILE (default ~/mbox)"}, 36 "Operate on mailbox FILE (default ~/mbox)", 0},
37 {"byname", 'F', 0, 0, "Save messages according to sender"}, 37 {"byname", 'F', 0, 0, "Save messages according to sender", 0},
38 {"headers", 'H', 0, 0, "Write a header summary and exit"}, 38 {"headers", 'H', 0, 0, "Write a header summary and exit", 0},
39 {"ignore", 'i', 0, 0, "Ignore interrupts"}, 39 {"ignore", 'i', 0, 0, "Ignore interrupts", 0},
40 {"norc", 'n', 0, 0, "Do not read the system mailrc file"}, 40 {"norc", 'n', 0, 0, "Do not read the system mailrc file", 0},
41 {"nosum", 'N', 0, 0, "Do not display initial header summary"}, 41 {"nosum", 'N', 0, 0, "Do not display initial header summary", 0},
42 {"print", 'p', 0, 0, "Print all mail to standard output"}, 42 {"print", 'p', 0, 0, "Print all mail to standard output", 0},
43 {"quit", 'q', 0, 0, "Cause interrupts to terminate program"}, 43 {"quit", 'q', 0, 0, "Cause interrupts to terminate program", 0},
44 {"read", 'r', 0, 0, "Same as -p"}, 44 {"read", 'r', 0, 0, "Same as -p", 0},
45 {"subject", 's', "SUBJ", 0, "Send a message with a Subject of SUBJ"}, 45 {"subject", 's', "SUBJ", 0, "Send a message with a Subject of SUBJ", 0},
46 {"to", 't', 0, 0, "Precede message by a list of addresses"}, 46 {"to", 't', 0, 0, "Precede message by a list of addresses", 0},
47 {"user", 'u', "USER", 0, "Operate on USER's mailbox"}, 47 {"user", 'u', "USER", 0, "Operate on USER's mailbox", 0},
48 { 0 } 48 { NULL, 0, NULL, 0, NULL, 0 }
49 }; 49 };
50 50
51 struct arguments 51 struct arguments
...@@ -124,7 +124,7 @@ parse_opt (int key, char *arg, struct argp_state *state) ...@@ -124,7 +124,7 @@ parse_opt (int key, char *arg, struct argp_state *state)
124 return 0; 124 return 0;
125 } 125 }
126 126
127 static struct argp argp = { options, parse_opt, args_doc, doc }; 127 static struct argp argp = { options, parse_opt, args_doc, doc, NULL, NULL, NULL };
128 128
129 static char * 129 static char *
130 mail_cmdline(void *closure, int cont) 130 mail_cmdline(void *closure, int cont)
...@@ -133,6 +133,8 @@ mail_cmdline(void *closure, int cont) ...@@ -133,6 +133,8 @@ mail_cmdline(void *closure, int cont)
133 char *prompt = NULL; 133 char *prompt = NULL;
134 char *rc; 134 char *rc;
135 135
136 (void)cont;
137
136 while (1) 138 while (1)
137 { 139 {
138 if (util_find_env ("autoinc")->set && !mailbox_is_updated (mbox)) 140 if (util_find_env ("autoinc")->set && !mailbox_is_updated (mbox))
...@@ -142,7 +144,7 @@ mail_cmdline(void *closure, int cont) ...@@ -142,7 +144,7 @@ mail_cmdline(void *closure, int cont)
142 } 144 }
143 145
144 if (interactive) 146 if (interactive)
145 prompt = pev->set && pev->value != NULL ? pev->value : "? "; 147 prompt = pev->set && pev->value != NULL ? pev->value : (char *)"? ";
146 148
147 rc = readline (prompt); 149 rc = readline (prompt);
148 150
...@@ -167,7 +169,7 @@ int ...@@ -167,7 +169,7 @@ int
167 main (int argc, char **argv) 169 main (int argc, char **argv)
168 { 170 {
169 struct mail_env_entry *mode = NULL, *prompt = NULL; 171 struct mail_env_entry *mode = NULL, *prompt = NULL;
170 int modelen = 0; 172 size_t modelen = 0;
171 struct arguments args; 173 struct arguments args;
172 174
173 ofile = stdout; 175 ofile = stdout;
...@@ -445,8 +447,7 @@ Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.\n\ ...@@ -445,8 +447,7 @@ Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.\n\
445 int 447 int
446 mail_warranty(int argc, char **argv) 448 mail_warranty(int argc, char **argv)
447 { 449 {
450 (void)argc; (void)argv;
448 fprintf (ofile, "%s", warranty_stmt); 451 fprintf (ofile, "%s", warranty_stmt);
449 return 0; 452 return 0;
450 } 453 }
451
452
......
...@@ -80,7 +80,7 @@ extern "C" { ...@@ -80,7 +80,7 @@ extern "C" {
80 80
81 /* Type definitions */ 81 /* Type definitions */
82 #ifndef function_t 82 #ifndef function_t
83 typedef int function_t (); 83 typedef int function_t __P ((int, char **));
84 #endif 84 #endif
85 85
86 /* Values for mail_command_entry.flags */ 86 /* Values for mail_command_entry.flags */
...@@ -88,20 +88,6 @@ typedef int function_t (); ...@@ -88,20 +88,6 @@ typedef int function_t ();
88 #define EF_FLOW 0x01 /* Flow control command */ 88 #define EF_FLOW 0x01 /* Flow control command */
89 #define EF_SEND 0x02 /* Send command */ 89 #define EF_SEND 0x02 /* Send command */
90 90
91 struct mail_command_entry {
92 char *shortname;
93 char *longname;
94 int flags;
95 function_t *func;
96 char *synopsis;
97 };
98
99 struct mail_env_entry {
100 char *var;
101 int set;
102 char *value;
103 };
104
105 struct send_environ 91 struct send_environ
106 { 92 {
107 char *to; 93 char *to;
...@@ -116,13 +102,28 @@ struct send_environ ...@@ -116,13 +102,28 @@ struct send_environ
116 int nfiles; 102 int nfiles;
117 }; 103 };
118 104
105 struct mail_command_entry {
106 const char *shortname;
107 const char *longname;
108 const char *synopsis;
109 int flags;
110 int (*func) __P ((int, char **));
111 int (*escfunc) __P ((int, char **, struct send_environ *));
112 };
113
114 struct mail_env_entry {
115 char *var;
116 int set;
117 char *value;
118 };
119
119 typedef struct message_set msgset_t; 120 typedef struct message_set msgset_t;
120 121
121 struct message_set 122 struct message_set
122 { 123 {
123 msgset_t *next; /* Link to the next message set */ 124 msgset_t *next; /* Link to the next message set */
124 int npart; /* Number of parts in this set */ 125 unsigned int npart; /* Number of parts in this set */
125 int *msg_part; /* Array of part numbers: msg_part[0] is the message 126 unsigned int *msg_part;/* Array of part numbers: msg_part[0] is the message
126 number */ 127 number */
127 }; 128 };
128 129
...@@ -137,146 +138,150 @@ extern const struct mail_command_entry mail_command_table[]; ...@@ -137,146 +138,150 @@ extern const struct mail_command_entry mail_command_table[];
137 extern const struct mail_command_entry mail_escape_table[]; 138 extern const struct mail_command_entry mail_escape_table[];
138 139
139 /* Functions */ 140 /* Functions */
140 int mail_alias __P((int argc, char **argv)); 141 extern int mail_alias __P ((int argc, char **argv));
141 int mail_alt __P((int argc, char **argv)); /* command alternates */ 142 extern int mail_alt __P ((int argc, char **argv)); /* command alternates */
142 int mail_cd __P((int argc, char **argv)); 143 extern int mail_cd __P ((int argc, char **argv));
143 int mail_copy __P((int argc, char **argv)); 144 extern int mail_copy __P ((int argc, char **argv));
144 int mail_decode __P((int argc, char **argv)); 145 extern int mail_decode __P ((int argc, char **argv));
145 int mail_delete __P((int argc, char **argv)); 146 extern int mail_delete __P ((int argc, char **argv));
146 int mail_discard __P((int argc, char **argv)); 147 extern int mail_discard __P ((int argc, char **argv));
147 int mail_dp __P((int argc, char **argv)); 148 extern int mail_dp __P ((int argc, char **argv));
148 int mail_echo __P((int argc, char **argv)); 149 extern int mail_echo __P ((int argc, char **argv));
149 int mail_edit __P((int argc, char **argv)); 150 extern int mail_edit __P ((int argc, char **argv));
150 int mail_else __P((int argc, char **argv)); 151 extern int mail_else __P ((int argc, char **argv));
151 int mail_endif __P((int argc, char **argv)); 152 extern int mail_endif __P ((int argc, char **argv));
152 int mail_exit __P((int argc, char **argv)); 153 extern int mail_exit __P ((int argc, char **argv));
153 int mail_file __P((int argc, char **argv)); 154 extern int mail_file __P ((int argc, char **argv));
154 int mail_folders __P((int argc, char **argv)); 155 extern int mail_folders __P ((int argc, char **argv));
155 int mail_followup __P((int argc, char **argv)); 156 extern int mail_followup __P ((int argc, char **argv));
156 int mail_from __P((int argc, char **argv)); 157 extern int mail_from __P ((int argc, char **argv));
157 int mail_headers __P((int argc, char **argv)); 158 extern int mail_headers __P ((int argc, char **argv));
158 int mail_hold __P((int argc, char **argv)); 159 extern int mail_hold __P ((int argc, char **argv));
159 int mail_help __P((int argc, char **argv)); 160 extern int mail_help __P ((int argc, char **argv));
160 int mail_if __P((int argc, char **argv)); 161 extern int mail_if __P ((int argc, char **argv));
161 int mail_inc __P((int argc, char **argv)); 162 extern int mail_inc __P ((int argc, char **argv));
162 int mail_list __P((int argc, char **argv)); 163 extern int mail_list __P ((int argc, char **argv));
163 int mail_send __P((int argc, char **argv)); /* command mail */ 164 extern int mail_send __P ((int argc, char **argv)); /* command mail */
164 int mail_mbox __P((int argc, char **argv)); 165 extern int mail_mbox __P ((int argc, char **argv));
165 int mail_next __P((int argc, char **argv)); 166 extern int mail_next __P ((int argc, char **argv));
166 int mail_pipe __P((int argc, char **argv)); 167 extern int mail_pipe __P ((int argc, char **argv));
167 int mail_previous __P((int argc, char **argv)); 168 extern int mail_previous __P ((int argc, char **argv));
168 int mail_print __P((int argc, char **argv)); 169 extern int mail_print __P ((int argc, char **argv));
169 int mail_quit __P((int argc, char **argv)); 170 extern int mail_quit __P ((int argc, char **argv));
170 int mail_reply __P((int argc, char **argv)); 171 extern int mail_reply __P ((int argc, char **argv));
171 int mail_retain __P((int argc, char **argv)); 172 extern int mail_retain __P ((int argc, char **argv));
172 int mail_save __P((int argc, char **argv)); 173 extern int mail_save __P ((int argc, char **argv));
173 int mail_set __P((int argc, char **argv)); 174 extern int mail_set __P ((int argc, char **argv));
174 int mail_shell __P((int argc, char **argv)); 175 extern int mail_shell __P ((int argc, char **argv));
175 int mail_size __P((int argc, char **argv)); 176 extern int mail_size __P ((int argc, char **argv));
176 int mail_source __P((int argc, char **argv)); 177 extern int mail_source __P ((int argc, char **argv));
177 int mail_summary __P((int argc, char **argv)); 178 extern int mail_summary __P ((int argc, char **argv));
178 int mail_tag __P((int argc, char **argv)); 179 extern int mail_tag __P ((int argc, char **argv));
179 int mail_top __P((int argc, char **argv)); 180 extern int mail_top __P ((int argc, char **argv));
180 int mail_touch __P((int argc, char **argv)); 181 extern int mail_touch __P ((int argc, char **argv));
181 int mail_unalias __P((int argc, char **argv)); 182 extern int mail_unalias __P ((int argc, char **argv));
182 int mail_undelete __P((int argc, char **argv)); 183 extern int mail_undelete __P ((int argc, char **argv));
183 int mail_unset __P((int argc, char **argv)); 184 extern int mail_unset __P ((int argc, char **argv));
184 int mail_version __P((int argc, char **argv)); 185 extern int mail_version __P ((int argc, char **argv));
185 int mail_visual __P((int argc, char **argv)); 186 extern int mail_visual __P ((int argc, char **argv));
186 int mail_warranty __P((int argc, char **argv)); 187 extern int mail_warranty __P ((int argc, char **argv));
187 int mail_write __P((int argc, char **argv)); 188 extern int mail_write __P ((int argc, char **argv));
188 int mail_z __P((int argc, char **argv)); 189 extern int mail_z __P ((int argc, char **argv));
189 int mail_eq __P((int argc, char **argv)); /* command = */ 190 extern int mail_eq __P ((int argc, char **argv)); /* command = */
190 191
191 int if_cond __P((void)); 192 extern int if_cond __P ((void));
192 193
193 void mail_mainloop __P((char *(*input) __P((void *, int)), void *closure, int do_history)); 194 extern void mail_mainloop __P ((char *(*input) __P((void *, int)), void *closure, int do_history));
194 int mail_copy0 __P((int argc, char **argv, int mark)); 195 extern int mail_copy0 __P ((int argc, char **argv, int mark));
195 int mail_send0 __P((struct send_environ *env, int save_to)); 196 extern int mail_send0 __P ((struct send_environ *env, int save_to));
196 void free_env_headers __P((struct send_environ *env)); 197 extern void free_env_headers __P ((struct send_environ *env));
197 198
198 /*void print_message __P((message_t mesg, char *prefix, int all_headers, FILE *file));*/ 199 /*extern void print_message __P((message_t mesg, char *prefix, int all_headers, FILE *file));*/
199 200
200 int mail_mbox_commit __P((void)); 201 extern int mail_mbox_commit __P ((void));
201 int mail_is_my_name __P((char *name)); 202 extern int mail_is_my_name __P ((char *name));
202 void mail_set_my_name __P((char *name)); 203 extern void mail_set_my_name __P ((char *name));
203 char *mail_whoami __P((void)); 204 extern char *mail_whoami __P ((void));
204 int mail_header_is_visible __P((char *str)); 205 extern int mail_header_is_visible __P ((char *str));
205 int mail_mbox_close __P((void)); 206 extern int mail_mbox_close __P ((void));
206 207
207 int var_shell __P((int argc, char **argv, struct send_environ *env)); 208 extern int var_shell __P ((int argc, char **argv, struct send_environ *env));
208 int var_command __P((int argc, char **argv, struct send_environ *env)); 209 extern int var_command __P ((int argc, char **argv, struct send_environ *env));
209 int var_help __P((int argc, char **argv, struct send_environ *env)); 210 extern int var_help __P ((int argc, char **argv, struct send_environ *env));
210 int var_sign __P((int argc, char **argv, struct send_environ *env)); 211 extern int var_sign __P ((int argc, char **argv, struct send_environ *env));
211 int var_bcc __P((int argc, char **argv, struct send_environ *env)); 212 extern int var_bcc __P ((int argc, char **argv, struct send_environ *env));
212 int var_cc __P((int argc, char **argv, struct send_environ *env)); 213 extern int var_cc __P ((int argc, char **argv, struct send_environ *env));
213 int var_deadletter __P((int argc, char **argv, struct send_environ *env)); 214 extern int var_deadletter __P ((int argc, char **argv, struct send_environ *env));
214 int var_editor __P((int argc, char **argv, struct send_environ *env)); 215 extern int var_editor __P ((int argc, char **argv, struct send_environ *env));
215 int var_print __P((int argc, char **argv, struct send_environ *env)); 216 extern int var_print __P ((int argc, char **argv, struct send_environ *env));
216 int var_headers __P((int argc, char **argv, struct send_environ *env)); 217 extern int var_headers __P ((int argc, char **argv, struct send_environ *env));
217 int var_insert __P((int argc, char **argv, struct send_environ *env)); 218 extern int var_insert __P ((int argc, char **argv, struct send_environ *env));
218 int var_quote __P((int argc, char **argv, struct send_environ *env)); 219 extern int var_quote __P ((int argc, char **argv, struct send_environ *env));
219 int var_type_input __P((int argc, char **argv, struct send_environ *env)); 220 extern int var_type_input __P ((int argc, char **argv, struct send_environ *env));
220 int var_read __P((int argc, char **argv, struct send_environ *env)); 221 extern int var_read __P ((int argc, char **argv, struct send_environ *env));
221 int var_subj __P((int argc, char **argv, struct send_environ *env)); 222 extern int var_subj __P ((int argc, char **argv, struct send_environ *env));
222 int var_to __P((int argc, char **argv, struct send_environ *env)); 223 extern int var_to __P ((int argc, char **argv, struct send_environ *env));
223 int var_visual __P((int argc, char **argv, struct send_environ *env)); 224 extern int var_visual __P ((int argc, char **argv, struct send_environ *env));
224 int var_write __P((int argc, char **argv, struct send_environ *env)); 225 extern int var_write __P ((int argc, char **argv, struct send_environ *env));
225 int var_exit __P((int argc, char **argv, struct send_environ *env)); 226 extern int var_exit __P ((int argc, char **argv, struct send_environ *env));
226 int var_pipe __P((int argc, char **argv, struct send_environ *env)); 227 extern int var_pipe __P ((int argc, char **argv, struct send_environ *env));
227 228
228 /* msgsets */ 229 /* msgsets */
229 void msgset_free __P((msgset_t *msg_set)); 230 extern void msgset_free __P ((msgset_t *msg_set));
230 msgset_t *msgset_make_1 __P((int number)); 231 extern msgset_t *msgset_make_1 __P ((int number));
231 msgset_t *msgset_append __P((msgset_t *one, msgset_t *two)); 232 extern msgset_t *msgset_append __P ((msgset_t *one, msgset_t *two));
232 msgset_t *msgset_range __P((int low, int high)); 233 extern msgset_t *msgset_range __P ((int low, int high));
233 msgset_t *msgset_expand __P((msgset_t *set, msgset_t *expand_by)); 234 extern msgset_t *msgset_expand __P ((msgset_t *set, msgset_t *expand_by));
234 msgset_t * msgset_dup __P((const msgset_t *set)); 235 extern msgset_t *msgset_dup __P ((const msgset_t *set));
235 int parse_msgset __P((const int argc, char **argv, msgset_t **mset)); 236 extern int msgset_parse __P ((const int argc, char **argv, msgset_t **mset));
236 237
237 int util_do_command __P((const char *cmd, ...)); 238 extern int util_do_command __P ((const char *cmd, ...));
238 int util_msglist_command __P((function_t *func, int argc, char **argv, int set_cursor)); 239 extern int util_msglist_command __P ((function_t *func, int argc, char **argv, int set_cursor));
239 function_t* util_command_get __P((char *cmd)); 240 extern int util_msglist_esccmd
240 char *util_stripwhite __P((char *string)); 241 __P ((int (*escfunc) __P ((int, char **, struct send_environ *)),
241 struct mail_command_entry util_find_entry __P((const struct mail_command_entry *table, char *cmd)); 242 int argc, char **argv, struct send_environ *env, int set_cursor));
242 int util_getcols __P((void)); 243 extern function_t* util_command_get __P ((const char *cmd));
243 int util_getlines __P((void)); 244 extern char *util_stripwhite __P ((char *string));
244 int util_screen_lines __P((void)); 245 extern struct mail_command_entry util_find_entry __P ((const struct mail_command_entry *table, const char *cmd));
245 int util_screen_columns __P((void)); 246 extern int util_getcols __P ((void));
246 struct mail_env_entry *util_find_env __P((const char *var)); 247 extern int util_getlines __P ((void));
247 int util_printenv __P((int set)); 248 extern int util_screen_lines __P ((void));
248 int util_setenv __P((const char *name, const char *value, int overwrite)); 249 extern int util_screen_columns __P ((void));
249 int util_isdeleted __P((int message)); 250 extern struct mail_env_entry *util_find_env __P ((const char *var));
250 char *util_get_homedir __P((void)); 251 extern int util_printenv __P ((int set));
251 char *util_fullpath __P((char *inpath)); 252 extern int util_setenv __P ((const char *name, const char *value, int overwrite));
252 char *util_get_sender __P((int msgno, int strip)); 253 extern int util_isdeleted __P ((int message));
253 254 extern char *util_get_homedir __P ((void));
254 void util_slist_print __P((list_t list, int nl)); 255 extern char *util_fullpath __P ((const char *inpath));
255 int util_slist_lookup __P((list_t list, char *str)); 256 extern char *util_get_sender __P ((int msgno, int strip));
256 void util_slist_add __P((list_t *list, char *value)); 257
257 void util_slist_destroy __P((list_t *list)); 258 extern void util_slist_print __P ((list_t list, int nl));
258 char *util_slist_to_string __P((list_t list, char *delim)); 259 extern int util_slist_lookup __P ((list_t list, char *str));
259 void util_strcat __P((char **dest, char *str)); 260 extern void util_slist_add __P ((list_t *list, char *value));
260 void util_strupper __P((char *str)); 261 extern void util_slist_destroy __P ((list_t *list));
261 void util_escape_percent __P((char **str)); 262 extern char *util_slist_to_string __P ((list_t list, const char *delim));
262 char *util_outfolder_name __P((char *str)); 263 extern void util_strcat __P ((char **dest, const char *str));
263 void util_save_outgoing __P((message_t msg, char *savefile)); 264 extern void util_strupper __P ((char *str));
264 void util_error __P((const char *format, ...)); 265 extern void util_escape_percent __P ((char **str));
265 int util_help __P((const struct mail_command_entry *table, char *word)); 266 extern char *util_outfolder_name __P ((char *str));
266 int util_tempfile __P((char **namep)); 267 extern void util_save_outgoing __P ((message_t msg, char *savefile));
267 void util_msgset_iterate __P((msgset_t *msgset, int (*fun)(), void *closure)); 268 extern void util_error __P ((const char *format, ...));
268 int util_get_content_type __P((header_t hdr, char **value)); 269 extern int util_help __P ((const struct mail_command_entry *table, char *word));
269 270 extern int util_tempfile __P ((char **namep));
270 int ml_got_interrupt __P((void)); 271 extern void util_msgset_iterate __P ((msgset_t *msgset, int (*fun) __P ((message_t, msgset_t *, void *)), void *closure));
271 void ml_clear_interrupt __P((void)); 272 extern int util_get_content_type __P ((header_t hdr, char **value));
272 void ml_readline_init __P((void)); 273 extern int util_get_hdr_value __P ((header_t hdr, const char *name, char **value));
273 int ml_reread __P((char *prompt, char **text)); 274
274 275 extern int ml_got_interrupt __P ((void));
275 char *alias_expand __P((char *name)); 276 extern void ml_clear_interrupt __P ((void));
276 void alias_destroy __P((char *name)); 277 extern void ml_readline_init __P ((void));
278 extern int ml_reread __P ((const char *prompt, char **text));
279
280 extern char *alias_expand __P ((char *name));
281 extern void alias_destroy __P ((char *name));
277 282
278 #ifndef HAVE_READLINE_READLINE_H 283 #ifndef HAVE_READLINE_READLINE_H
279 char *readline __P((const char *prompt)); 284 extern char *readline __P ((const char *prompt));
280 #endif 285 #endif
281 286
282 #ifndef _PATH_SENDMAIL 287 #ifndef _PATH_SENDMAIL
...@@ -293,4 +298,3 @@ char *readline __P((const char *prompt)); ...@@ -293,4 +298,3 @@ char *readline __P((const char *prompt));
293 #endif 298 #endif
294 299
295 #endif /* _MAIL_H */ 300 #endif /* _MAIL_H */
296
......
...@@ -58,7 +58,7 @@ ml_got_interrupt () ...@@ -58,7 +58,7 @@ ml_got_interrupt ()
58 return rc; 58 return rc;
59 } 59 }
60 60
61 int 61 static int
62 ml_getc (FILE *stream) 62 ml_getc (FILE *stream)
63 { 63 {
64 unsigned char c; 64 unsigned char c;
...@@ -86,7 +86,7 @@ ml_readline_init () ...@@ -86,7 +86,7 @@ ml_readline_init ()
86 return; 86 return;
87 87
88 #ifdef WITH_READLINE 88 #ifdef WITH_READLINE
89 rl_readline_name = "mail"; 89 rl_readline_name = (char *)"mail";
90 rl_attempted_completion_function = (CPPFunction*)ml_command_completion; 90 rl_attempted_completion_function = (CPPFunction*)ml_command_completion;
91 rl_getc_function = ml_getc; 91 rl_getc_function = ml_getc;
92 #endif 92 #endif
...@@ -114,7 +114,7 @@ ml_readline_init () ...@@ -114,7 +114,7 @@ ml_readline_init ()
114 static char *insert_text; 114 static char *insert_text;
115 115
116 static int 116 static int
117 ml_insert_hook () 117 ml_insert_hook (void)
118 { 118 {
119 if (insert_text) 119 if (insert_text)
120 rl_insert_text (insert_text); 120 rl_insert_text (insert_text);
...@@ -122,14 +122,14 @@ ml_insert_hook () ...@@ -122,14 +122,14 @@ ml_insert_hook ()
122 } 122 }
123 123
124 int 124 int
125 ml_reread (char *prompt, char **text) 125 ml_reread (const char *prompt, char **text)
126 { 126 {
127 char *s; 127 char *s;
128 128
129 ml_clear_interrupt (); 129 ml_clear_interrupt ();
130 insert_text = *text; 130 insert_text = *text;
131 rl_startup_hook = ml_insert_hook; 131 rl_startup_hook = ml_insert_hook;
132 s = readline (prompt); 132 s = readline ((char *)prompt);
133 if (!ml_got_interrupt ()) 133 if (!ml_got_interrupt ())
134 { 134 {
135 if (*text) 135 if (*text)
...@@ -150,6 +150,7 @@ ml_reread (char *prompt, char **text) ...@@ -150,6 +150,7 @@ ml_reread (char *prompt, char **text)
150 char ** 150 char **
151 ml_command_completion (char *cmd, int start, int end) 151 ml_command_completion (char *cmd, int start, int end)
152 { 152 {
153 (void)end;
153 if (start == 0) 154 if (start == 0)
154 return completion_matches (cmd, ml_command_generator); 155 return completion_matches (cmd, ml_command_generator);
155 return NULL; 156 return NULL;
...@@ -162,7 +163,7 @@ char * ...@@ -162,7 +163,7 @@ char *
162 ml_command_generator (char *text, int state) 163 ml_command_generator (char *text, int state)
163 { 164 {
164 static int i, len; 165 static int i, len;
165 char *name; 166 const char *name;
166 167
167 if (!state) 168 if (!state)
168 { 169 {
......
...@@ -29,13 +29,17 @@ struct header_data ...@@ -29,13 +29,17 @@ struct header_data
29 char *expr; 29 char *expr;
30 }; 30 };
31 31
32 static msgset_t *msgset_select (int (*sel)(), void *closure, int rev, 32 static msgset_t *msgset_select __P ((int (*sel) __P ((message_t, void *)),
33 int max_matches); 33 void *closure, int rev,
34 static int select_header (message_t msg, void *closure); 34 unsigned int max_matches));
35 static int select_body (message_t msg, void *closure); 35 static int select_header __P ((message_t msg, void *closure));
36 static int select_type (message_t msg, void *closure); 36 static int select_body __P ((message_t msg, void *closure));
37 static int select_sender (message_t msg, void *closure); 37 static int select_type __P ((message_t msg, void *closure));
38 static int select_deleted (message_t msg, void *closure); 38 static int select_sender __P ((message_t msg, void *closure));
39 static int select_deleted __P ((message_t msg, void *closure));
40
41 int yyerror __P ((const char *));
42 int yylex __P ((void));
39 43
40 static msgset_t *result; 44 static msgset_t *result;
41 %} 45 %}
...@@ -170,7 +174,6 @@ range : number ...@@ -170,7 +174,6 @@ range : number
170 } 174 }
171 else 175 else
172 { 176 {
173 msgset_t *mp;
174 $$ = msgset_range ($1, $3->msg_part[0]-1); 177 $$ = msgset_range ($1, $3->msg_part[0]-1);
175 if (!$$) 178 if (!$$)
176 YYERROR; 179 YYERROR;
...@@ -209,7 +212,7 @@ static int cur_ind; ...@@ -209,7 +212,7 @@ static int cur_ind;
209 static char *cur_p; 212 static char *cur_p;
210 213
211 int 214 int
212 yyerror (char *s) 215 yyerror (const char *s)
213 { 216 {
214 fprintf (stderr, "%s: ", xargv[0]); 217 fprintf (stderr, "%s: ", xargv[0]);
215 fprintf (stderr, "%s", s); 218 fprintf (stderr, "%s", s);
...@@ -226,6 +229,7 @@ yyerror (char *s) ...@@ -226,6 +229,7 @@ yyerror (char *s)
226 else 229 else
227 fprintf (stderr, " near %s", cur_p); 230 fprintf (stderr, " near %s", cur_p);
228 fprintf (stderr, "\n"); 231 fprintf (stderr, "\n");
232 return 0;
229 } 233 }
230 234
231 int 235 int
...@@ -324,7 +328,6 @@ msgset_parse (const int argc, char **argv, msgset_t **mset) ...@@ -324,7 +328,6 @@ msgset_parse (const int argc, char **argv, msgset_t **mset)
324 void 328 void
325 msgset_free (msgset_t *msg_set) 329 msgset_free (msgset_t *msg_set)
326 { 330 {
327 int i;
328 msgset_t *next; 331 msgset_t *next;
329 332
330 if (!msg_set) 333 if (!msg_set)
...@@ -382,7 +385,7 @@ msgset_t * ...@@ -382,7 +385,7 @@ msgset_t *
382 msgset_range (int low, int high) 385 msgset_range (int low, int high)
383 { 386 {
384 int i; 387 int i;
385 msgset_t *mp, *first = NULL, *last; 388 msgset_t *mp, *first = NULL, *last = NULL;
386 389
387 if (low == high) 390 if (low == high)
388 return msgset_make_1 (low); 391 return msgset_make_1 (low);
...@@ -409,7 +412,7 @@ msgset_t * ...@@ -409,7 +412,7 @@ msgset_t *
409 msgset_expand (msgset_t *set, msgset_t *expand_by) 412 msgset_expand (msgset_t *set, msgset_t *expand_by)
410 { 413 {
411 msgset_t *i, *j; 414 msgset_t *i, *j;
412 msgset_t *first = NULL, *last, *mp; 415 msgset_t *first = NULL, *last = NULL, *mp;
413 416
414 for (i = set; i; i = i->next) 417 for (i = set; i; i = i->next)
415 for (j = expand_by; j; j = j->next) 418 for (j = expand_by; j; j = j->next)
...@@ -432,10 +435,11 @@ msgset_expand (msgset_t *set, msgset_t *expand_by) ...@@ -432,10 +435,11 @@ msgset_expand (msgset_t *set, msgset_t *expand_by)
432 } 435 }
433 436
434 msgset_t * 437 msgset_t *
435 msgset_select (int (*sel)(), void *closure, int rev, int max_matches) 438 msgset_select (int (*sel) __P ((message_t, void *)), void *closure, int rev,
439 unsigned int max_matches)
436 { 440 {
437 size_t i, match_count = 0; 441 size_t i, match_count = 0;
438 msgset_t *first = NULL, *last, *mp; 442 msgset_t *first = NULL, *last = NULL, *mp;
439 message_t msg = NULL; 443 message_t msg = NULL;
440 444
441 if (max_matches == 0) 445 if (max_matches == 0)
...@@ -486,7 +490,7 @@ select_header (message_t msg, void *closure) ...@@ -486,7 +490,7 @@ select_header (message_t msg, void *closure)
486 struct header_data *hd = (struct header_data *)closure; 490 struct header_data *hd = (struct header_data *)closure;
487 header_t hdr; 491 header_t hdr;
488 char *contents; 492 char *contents;
489 char *header = hd->header ? hd->header : MU_HEADER_SUBJECT; 493 const char *header = hd->header ? hd->header : MU_HEADER_SUBJECT;
490 494
491 message_get_header (msg, &hdr); 495 message_get_header (msg, &hdr);
492 if (header_aget_value (hdr, header, &contents) == 0) 496 if (header_aget_value (hdr, header, &contents) == 0)
...@@ -572,10 +576,11 @@ select_body (message_t msg, void *closure) ...@@ -572,10 +576,11 @@ select_body (message_t msg, void *closure)
572 int 576 int
573 select_sender (message_t msg, void *closure) 577 select_sender (message_t msg, void *closure)
574 { 578 {
575 char *sender = (char*) closure; 579 /* char *sender = (char*) closure; */
576 /* FIXME: all messages from sender argv[i] */ 580 /* FIXME: all messages from sender argv[i] */
577 /* Annoying we can use address_create() for that 581 /* Annoying we can use address_create() for that
578 but to compare against what? The email ? */ 582 but to compare against what? The email ? */
583 (void)msg; (void)closure;
579 return 0; 584 return 0;
580 } 585 }
581 586
...@@ -613,6 +618,7 @@ select_deleted (message_t msg, void *closure) ...@@ -613,6 +618,7 @@ select_deleted (message_t msg, void *closure)
613 attribute_t attr= NULL; 618 attribute_t attr= NULL;
614 int rc; 619 int rc;
615 620
621 (void)closure;
616 message_get_attribute (msg, &attr); 622 message_get_attribute (msg, &attr);
617 rc = attribute_is_deleted (attr); 623 rc = attribute_is_deleted (attr);
618 return strcmp (xargv[0], "undelete") == 0 ? rc : !rc; 624 return strcmp (xargv[0], "undelete") == 0 ? rc : !rc;
...@@ -636,7 +642,7 @@ int ...@@ -636,7 +642,7 @@ int
636 main(int argc, char **argv) 642 main(int argc, char **argv)
637 { 643 {
638 msgset_t *mset = NULL; 644 msgset_t *mset = NULL;
639 int rc = parse_msgset (argc, argv, &mset); 645 int rc = msgset_parse (argc, argv, &mset);
640 646
641 for (; mset; mset = mset->next) 647 for (; mset; mset = mset->next)
642 msgset_print (mset); 648 msgset_print (mset);
......
...@@ -28,7 +28,7 @@ mail_pipe (int argc, char **argv) ...@@ -28,7 +28,7 @@ mail_pipe (int argc, char **argv)
28 message_t msg; 28 message_t msg;
29 stream_t stream; 29 stream_t stream;
30 char *cmd; 30 char *cmd;
31 FILE *pipe; 31 FILE *tube;
32 msgset_t *list, *mp; 32 msgset_t *list, *mp;
33 char buffer[512]; 33 char buffer[512];
34 off_t off = 0; 34 off_t off = 0;
...@@ -44,7 +44,7 @@ mail_pipe (int argc, char **argv) ...@@ -44,7 +44,7 @@ mail_pipe (int argc, char **argv)
44 if (msgset_parse (argc, argv, &list)) 44 if (msgset_parse (argc, argv, &list))
45 return 1; 45 return 1;
46 46
47 pipe = popen (cmd, "w"); 47 tube = popen (cmd, "w");
48 48
49 for (mp = list; mp; mp = mp->next) 49 for (mp = list; mp; mp = mp->next)
50 { 50 {
...@@ -56,15 +56,15 @@ mail_pipe (int argc, char **argv) ...@@ -56,15 +56,15 @@ mail_pipe (int argc, char **argv)
56 &n) == 0 && n != 0) 56 &n) == 0 && n != 0)
57 { 57 {
58 buffer[n] = '\0'; 58 buffer[n] = '\0';
59 fprintf (pipe, "%s", buffer); 59 fprintf (tube, "%s", buffer);
60 off += n; 60 off += n;
61 } 61 }
62 if ((util_find_env("page"))->set && mp->next) 62 if ((util_find_env("page"))->set && mp->next)
63 fprintf (pipe, "\f\n"); 63 fprintf (tube, "\f\n");
64 } 64 }
65 } 65 }
66 66
67 msgset_free (list); 67 msgset_free (list);
68 pclose (pipe); 68 pclose (tube);
69 return 0; 69 return 0;
70 } 70 }
......
...@@ -49,26 +49,25 @@ mail_print (int argc, char **argv) ...@@ -49,26 +49,25 @@ mail_print (int argc, char **argv)
49 49
50 message_lines (mesg, &lines); 50 message_lines (mesg, &lines);
51 51
52 if ((util_find_env("crt"))->set && lines > util_getlines ()) 52 if ((util_find_env("crt"))->set && lines > (size_t)util_getlines ())
53 out = popen (getenv("PAGER"), "w"); 53 out = popen (getenv("PAGER"), "w");
54 54
55 if (islower (argv[0][0])) 55 if (islower (argv[0][0]))
56 { 56 {
57 size_t i, num = 0; 57 size_t i, num = 0;
58 char buffer[512]; 58 char buf[512];
59 59
60 message_get_header (mesg, &hdr); 60 message_get_header (mesg, &hdr);
61 header_get_field_count (hdr, &num); 61 header_get_field_count (hdr, &num);
62 62
63 for (i = 1; i <= num; i++) 63 for (i = 1; i <= num; i++)
64 { 64 {
65 header_get_field_name (hdr, i, buffer, sizeof(buffer), NULL); 65 header_get_field_name (hdr, i, buf, sizeof buf, NULL);
66 if (mail_header_is_visible (buffer)) 66 if (mail_header_is_visible (buf))
67 { 67 {
68 fprintf (out, "%s: ", buffer); 68 fprintf (out, "%s: ", buf);
69 header_get_field_value (hdr, i, buffer, sizeof(buffer), 69 header_get_field_value (hdr, i, buf, sizeof buf, NULL);
70 NULL); 70 fprintf (out, "%s\n", buf);
71 fprintf (out, "%s\n", buffer);
72 } 71 }
73 } 72 }
74 fprintf (out, "\n"); 73 fprintf (out, "\n");
...@@ -78,7 +77,7 @@ mail_print (int argc, char **argv) ...@@ -78,7 +77,7 @@ mail_print (int argc, char **argv)
78 else 77 else
79 message_get_stream (mesg, &stream); 78 message_get_stream (mesg, &stream);
80 79
81 while (stream_read (stream, buffer, sizeof (buffer) - 1, off, &n) == 0 80 while (stream_read (stream, buffer, sizeof buffer - 1, off, &n) == 0
82 && n != 0) 81 && n != 0)
83 { 82 {
84 if (ml_got_interrupt()) 83 if (ml_got_interrupt())
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
25 int 25 int
26 mail_quit (int argc, char **argv) 26 mail_quit (int argc, char **argv)
27 { 27 {
28 (void)argc; (void)argv;
28 if (mail_mbox_close ()) 29 if (mail_mbox_close ())
29 return 1; 30 return 1;
30 exit (0); 31 exit (0);
...@@ -54,7 +55,7 @@ mail_mbox_close () ...@@ -54,7 +55,7 @@ mail_mbox_close ()
54 int 55 int
55 mail_mbox_commit () 56 mail_mbox_commit ()
56 { 57 {
57 int i; 58 unsigned int i;
58 mailbox_t dest_mbox = NULL; 59 mailbox_t dest_mbox = NULL;
59 int saved_count = 0; 60 int saved_count = 0;
60 message_t msg; 61 message_t msg;
...@@ -119,11 +120,11 @@ mail_mbox_commit () ...@@ -119,11 +120,11 @@ mail_mbox_commit ()
119 120
120 if (saved_count) 121 if (saved_count)
121 { 122 {
122 url_t url = NULL; 123 url_t u = NULL;
123 124
124 mailbox_get_url (dest_mbox, &url); 125 mailbox_get_url (dest_mbox, &u);
125 fprintf(ofile, "Saved %d messages in %s\n", saved_count, 126 fprintf(ofile, "Saved %d messages in %s\n", saved_count,
126 url_to_string (url)); 127 url_to_string (u));
127 mailbox_close (dest_mbox); 128 mailbox_close (dest_mbox);
128 mailbox_destroy (&dest_mbox); 129 mailbox_destroy (&dest_mbox);
129 } 130 }
......
...@@ -48,7 +48,7 @@ mail_send (int argc, char **argv) ...@@ -48,7 +48,7 @@ mail_send (int argc, char **argv)
48 env.outfiles = NULL; env.nfiles = 0; 48 env.outfiles = NULL; env.nfiles = 0;
49 49
50 if (argc < 2) 50 if (argc < 2)
51 env.to = readline ("To: "); 51 env.to = readline ((char *)"To: ");
52 else 52 else
53 { 53 {
54 while (--argc) 54 while (--argc)
...@@ -75,12 +75,12 @@ mail_send (int argc, char **argv) ...@@ -75,12 +75,12 @@ mail_send (int argc, char **argv)
75 } 75 }
76 76
77 if ((util_find_env ("askcc"))->set) 77 if ((util_find_env ("askcc"))->set)
78 env.cc = readline ("Cc: "); 78 env.cc = readline ((char *)"Cc: ");
79 if ((util_find_env ("askbcc"))->set) 79 if ((util_find_env ("askbcc"))->set)
80 env.bcc = readline ("Bcc: "); 80 env.bcc = readline ((char *)"Bcc: ");
81 81
82 if ((util_find_env ("asksub"))->set) 82 if ((util_find_env ("asksub"))->set)
83 env.subj = readline ("Subject: "); 83 env.subj = readline ((char *)"Subject: ");
84 else 84 else
85 env.subj = (util_find_env ("subject"))->value; 85 env.subj = (util_find_env ("subject"))->value;
86 86
...@@ -155,7 +155,7 @@ mail_send0 (struct send_environ *env, int save_to) ...@@ -155,7 +155,7 @@ mail_send0 (struct send_environ *env, int save_to)
155 while (!done) 155 while (!done)
156 { 156 {
157 char *buf; 157 char *buf;
158 buf = readline (" \b"); 158 buf = readline ((char *)" \b");
159 159
160 if (ml_got_interrupt ()) 160 if (ml_got_interrupt ())
161 { 161 {
...@@ -210,8 +210,10 @@ mail_send0 (struct send_environ *env, int save_to) ...@@ -210,8 +210,10 @@ mail_send0 (struct send_environ *env, int save_to)
210 struct mail_command_entry entry; 210 struct mail_command_entry entry;
211 entry = util_find_entry (mail_escape_table, argv[0]); 211 entry = util_find_entry (mail_escape_table, argv[0]);
212 212
213 if (entry.func) 213 if (entry.escfunc)
214 status = (*entry.func)(argc, argv, env); 214 {
215 status = (*entry.escfunc)(argc, argv, env);
216 }
215 else 217 else
216 util_error ("Unknown escape %s", argv[0]); 218 util_error ("Unknown escape %s", argv[0]);
217 } 219 }
...@@ -247,7 +249,7 @@ mail_send0 (struct send_environ *env, int save_to) ...@@ -247,7 +249,7 @@ mail_send0 (struct send_environ *env, int save_to)
247 else 249 else
248 { 250 {
249 char *buf = NULL; 251 char *buf = NULL;
250 int n; 252 unsigned int n;
251 rewind (env->file); 253 rewind (env->file);
252 while (getline (&buf, &n, env->file) > 0) 254 while (getline (&buf, &n, env->file) > 0)
253 fputs (buf, fp); 255 fputs (buf, fp);
...@@ -269,7 +271,6 @@ mail_send0 (struct send_environ *env, int save_to) ...@@ -269,7 +271,6 @@ mail_send0 (struct send_environ *env, int save_to)
269 { 271 {
270 mailer_t mailer; 272 mailer_t mailer;
271 message_t msg = NULL; 273 message_t msg = NULL;
272 int status;
273 message_create (&msg, NULL); 274 message_create (&msg, NULL);
274 275
275 /* Fill the header. */ 276 /* Fill the header. */
...@@ -366,7 +367,7 @@ mail_send0 (struct send_environ *env, int save_to) ...@@ -366,7 +367,7 @@ mail_send0 (struct send_environ *env, int save_to)
366 if (util_find_env ("sendmail")->set) 367 if (util_find_env ("sendmail")->set)
367 { 368 {
368 char *sendmail = util_find_env ("sendmail")->value; 369 char *sendmail = util_find_env ("sendmail")->value;
369 status = mailer_create (&mailer, sendmail); 370 int status = mailer_create (&mailer, sendmail);
370 if (status == 0) 371 if (status == 0)
371 { 372 {
372 if (util_find_env ("verbose")->set) 373 if (util_find_env ("verbose")->set)
...@@ -422,9 +423,9 @@ msg_to_pipe (const char *cmd, message_t msg) ...@@ -422,9 +423,9 @@ msg_to_pipe (const char *cmd, message_t msg)
422 stream_t stream = NULL; 423 stream_t stream = NULL;
423 char buffer[512]; 424 char buffer[512];
424 off_t off = 0; 425 off_t off = 0;
425 int n = 0; 426 unsigned int n = 0;
426 message_get_stream (msg, &stream); 427 message_get_stream (msg, &stream);
427 while (stream_read (stream, buffer, sizeof (buffer) - 1, off, &n) == 0 428 while (stream_read (stream, buffer, sizeof buffer - 1, off, &n) == 0
428 && n != 0) 429 && n != 0)
429 { 430 {
430 buffer[n] = '\0'; 431 buffer[n] = '\0';
......
...@@ -53,7 +53,7 @@ mail_shell (int argc, char **argv) ...@@ -53,7 +53,7 @@ mail_shell (int argc, char **argv)
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] = (char *)"-c";
57 argvec[2] = buf; 57 argvec[2] = buf;
58 argvec[3] = NULL; 58 argvec[3] = NULL;
59 59
......
...@@ -26,11 +26,12 @@ mail_summary (int argc, char **argv) ...@@ -26,11 +26,12 @@ mail_summary (int argc, char **argv)
26 { 26 {
27 message_t msg; 27 message_t msg;
28 attribute_t attr; 28 attribute_t attr;
29 int msgno; 29 size_t msgno;
30 size_t count = 0; 30 size_t count = 0;
31 int mseen = 0, mnew = 0, mdelete = 0; 31 int mseen = 0, mnew = 0, mdelete = 0;
32 int first_new = 0, first_unread = 0; 32 int first_new = 0, first_unread = 0;
33 33
34 (void)argc; (void)argv;
34 mailbox_messages_count (mbox, &count); 35 mailbox_messages_count (mbox, &count);
35 for (msgno = 1; msgno <= count; msgno++) 36 for (msgno = 1; msgno <= count; msgno++)
36 { 37 {
...@@ -74,4 +75,5 @@ mail_summary (int argc, char **argv) ...@@ -74,4 +75,5 @@ mail_summary (int argc, char **argv)
74 /* Set the cursor. */ 75 /* Set the cursor. */
75 cursor = realcursor = (first_new == 0) ? ((first_unread == 0) ? 76 cursor = realcursor = (first_new == 0) ? ((first_unread == 0) ?
76 1 : first_unread) : first_new ; 77 1 : first_unread) : first_new ;
78 return 0;
77 } 79 }
......
...@@ -18,112 +18,109 @@ ...@@ -18,112 +18,109 @@
18 #include "mail.h" 18 #include "mail.h"
19 19
20 const struct mail_command_entry mail_command_table[] = { 20 const struct mail_command_entry mail_command_table[] = {
21 { "a", "alias", 0, mail_alias, 21 { "a", "alias", "a[lias] [alias [address...]]", 0, mail_alias, 0 },
22 "a[lias] [alias [address...]]" }, 22 { "alt", "alternates", "alt[ernates] name...", 0, mail_alt, 0 },
23 { "alt", "alternates", 0, mail_alt, "alt[ernates] name..." }, 23 { "C", "Copy", "C[opy] [msglist]", 0, mail_copy, 0 },
24 { "C", "Copy", 0, mail_copy, "C[opy] [msglist]" }, 24 { "cd", "cd", "cd [directory]", 0, mail_cd, 0 },
25 { "cd", "cd", 0, mail_cd, "cd [directory]" }, 25 { "ch", "chdir", "ch[dir] directory", 0, mail_cd, 0 },
26 { "ch", "chdir", 0, mail_cd, "ch[dir] directory" }, 26 { "c", "copy", "c[opy] [[msglist] file]", 0, mail_copy, 0 },
27 { "c", "copy", 0, mail_copy, "c[opy] [[msglist] file]" }, 27 { "dec", "decode", "dec[ode] [msglist]", 0, mail_decode, 0 },
28 { "dec", "decode", 0, mail_decode, "dec[ode] [msglist]" }, 28 { "d", "delete", "d[elete] [msglist]", 0, mail_delete, 0 },
29 { "d", "delete", 0, mail_delete, "d[elete] [msglist]" }, 29 { "di", "discard", "di[scard] [header-field...]", 0, mail_discard, 0 },
30 { "di", "discard", 0, mail_discard, 30 { "dp", "dp", "dp [msglist]", 0, mail_dp, 0 },
31 "di[scard] [header-field...]" }, 31 { "dt", "dt", "dt [msglist]", 0, mail_dp, 0 },
32 { "dp", "dp", 0, mail_dp, "dp [msglist]" }, 32 { "ec", "echo", "ec[ho] string ...", 0, mail_echo, 0 },
33 { "dt", "dt", 0, mail_dp, "dt [msglist]" }, 33 { "e", "edit", "e[dit] [msglist]", 0, mail_edit, 0 },
34 { "ec", "echo", 0, mail_echo, "ec[ho] string ..." }, 34 { "el", "else", "el[se]", EF_FLOW, mail_else, 0 },
35 { "e", "edit", 0, mail_edit, "e[dit] [msglist]" }, 35 { "en", "endif", "en[dif]", EF_FLOW, mail_endif, 0 },
36 { "el", "else", EF_FLOW, mail_else, "el[se]" }, 36 { "ex", "exit", "ex[it]", 0, mail_exit, 0 },
37 { "en", "endif", EF_FLOW, mail_endif, "en[dif]" }, 37 { "F", "Followup", "F[ollowup] [msglist]", EF_SEND, mail_followup, 0 },
38 { "ex", "exit", 0, mail_exit, "ex[it]" }, 38 { "fi", "file", "fi[le] [file]", 0, mail_file, 0 },
39 { "F", "Followup", EF_SEND, mail_followup,"F[ollowup] [msglist]" }, 39 { "fold", "folder", "fold[er] [file]", 0, mail_file, 0 },
40 { "fi", "file", 0, mail_file, "fi[le] [file]" }, 40 { "folders", "folders", "folders", 0, mail_folders, 0 },
41 { "fold", "folder", 0, mail_file, "fold[er] [file]" }, 41 { "fo", "followup", "fo[llowup] [msglist]", EF_SEND, mail_followup, 0 },
42 { "folders", "folders", 0, mail_folders,"folders" }, 42 { "f", "from", "f[rom] [msglist]", 0, mail_from, 0 },
43 { "fo", "followup", EF_SEND, mail_followup,"fo[llowup] [msglist]" }, 43 { "g", "group", "g[roup] [alias [address...]]", 0, mail_alias, 0 },
44 { "f", "from", 0, mail_from, "f[rom] [msglist]" }, 44 { "h", "headers", "h[eaders] [msglist]", 0, mail_headers, 0 },
45 { "g", "group", 0, mail_alias, 45 { "hel", "help", "hel[p] [command...]", 0, mail_help, 0 },
46 "g[roup] [alias [address...]]" }, 46 { "ho", "hold", "ho[ld] [msglist]", 0, mail_hold, 0 },
47 { "h", "headers", 0, mail_headers,"h[eaders] [msglist]" }, 47 { "i", "if", "i[f] s|r|t", EF_FLOW, mail_if, 0 },
48 { "hel", "help", 0, mail_help, "hel[p] [command...]" }, 48 { "ig", "ignore", "ig[nore] [header-field...]", 0, mail_discard, 0 },
49 { "ho", "hold", 0, mail_hold, "ho[ld] [msglist]" }, 49 { "inc", "incorporate", "inc[orporate]", 0, mail_inc, 0 },
50 { "i", "if", EF_FLOW, mail_if, "i[f] s|r|t" }, 50 { "l", "list", "l[ist]", 0, mail_list, 0 },
51 { "ig", "ignore", 0, mail_discard,"ig[nore] [header-field...]" }, 51 { "m", "mail", "m[ail] [address...]", EF_SEND, mail_send, 0 },
52 { "inc", "incorporate", 0, mail_inc, "inc[orporate]" }, 52 { "mb", "mbox", "mb[ox] [msglist]", 0, mail_mbox, 0 },
53 { "l", "list", 0, mail_list, "l[ist]" }, 53 { "n", "next", "n[ext] [message]", 0, mail_next, 0 },
54 { "m", "mail", EF_SEND, mail_send, "m[ail] [address...]" }, 54 { "P", "Print", "P[rint] [msglist]", 0, mail_print, 0 },
55 { "mb", "mbox", 0, mail_mbox, "mb[ox] [msglist]" }, 55 { "pi", "pipe", "pi[pe] [[msglist] command]", 0, mail_pipe, 0 },
56 { "n", "next", 0, mail_next, "n[ext] [message]" }, 56 { "pre", "preserve", "pre[serve] [msglist]", 0, mail_hold, 0 },
57 { "P", "Print", 0, mail_print, "P[rint] [msglist]" }, 57 { "prev", "previous", "prev[ious] [message]", 0, mail_previous, 0 },
58 { "pi", "pipe", 0, mail_pipe, "pi[pe] [[msglist] command]" }, 58 { "p", "print", "p[rint] [msglist]", 0, mail_print, 0 },
59 { "pre", "preserve", 0, mail_hold, "pre[serve] [msglist]" }, 59 { "q", "quit", "q[uit]", 0, mail_quit, 0 },
60 { "prev", "previous", 0, mail_previous,"prev[ious] [message]" }, 60 { "R", "Reply", "R[eply] [msglist]", EF_SEND, mail_reply, 0 },
61 { "p", "print", 0, mail_print, "p[rint] [msglist]" }, 61 { "R", "Respond", "R[espond] [msglist]", EF_SEND, mail_reply, 0 },
62 { "q", "quit", 0, mail_quit, "q[uit]" }, 62 { "r", "reply", "r[eply] [msglist]", EF_SEND, mail_reply, 0 },
63 { "R", "Reply", EF_SEND, mail_reply, "R[eply] [msglist]" }, 63 { "r", "respond", "r[espond] [msglist]", EF_SEND, mail_reply, 0 },
64 { "R", "Respond", EF_SEND, mail_reply, "R[espond] [msglist]" }, 64 { "ret", "retain", "ret[ain] [header-field]", 0, mail_retain, 0 },
65 { "r", "reply", EF_SEND, mail_reply, "r[eply] [msglist]" }, 65 { "S", "Save", "S[ave] [msglist]", 0, mail_save, 0 },
66 { "r", "respond", EF_SEND, mail_reply, "r[espond] [msglist]" }, 66 { "s", "save", "s[ave] [[msglist] file]", 0, mail_save, 0 },
67 { "ret", "retain", 0, mail_retain, "ret[ain] [header-field]" }, 67 { "se", "set", "se[t] [name[=[string]]...] [name=number...] [noname...]",
68 { "S", "Save", 0, mail_save, "S[ave] [msglist]" }, 68 0, mail_set, 0 },
69 { "s", "save", 0, mail_save, "s[ave] [[msglist] file]" }, 69 { "sh", "shell", "sh[ell] [command]", 0, mail_shell, 0 },
70 { "se", "set", 0, mail_set, 70 { "si", "size", "si[ze] [msglist]", 0, mail_size, 0 },
71 "se[t] [name[=[string]]...] [name=number...] [noname...]" }, 71 { "so", "source", "so[urce] file", 0, mail_source, 0 },
72 { "sh", "shell", 0, mail_shell, "sh[ell] [command]" }, 72 { "su", "summary", "su[mmary]", 0, mail_summary, 0 },
73 { "si", "size", 0, mail_size, "si[ze] [msglist]" }, 73 { "T", "Type", "T[ype] [msglist]", 0, mail_print, 0 },
74 { "so", "source", 0, mail_source, "so[urce] file" }, 74 { "ta", "tag", "ta[g] [msglist]", 0, mail_tag, 0 },
75 { "su", "summary", 0, mail_summary, "su[mmary]" }, 75 { "to", "top", "to[p] [msglist]", 0, mail_top, 0 },
76 { "T", "Type", 0, mail_print, "T[ype] [msglist]" }, 76 { "tou", "touch", "tou[ch] [msglist]", 0, mail_touch, 0 },
77 { "ta", "tag", 0, mail_tag, "ta[g] [msglist]" }, 77 { "t", "type", "t[ype] [msglist]", 0, mail_print, 0 },
78 { "to", "top", 0, mail_top, "to[p] [msglist]" }, 78 { "una", "unalias", "una[lias] [alias]...", 0, mail_unalias, 0 },
79 { "tou", "touch", 0, mail_touch, "tou[ch] [msglist]" }, 79 { "u", "undelete", "u[ndelete] [msglist]", 0, mail_undelete, 0 },
80 { "t", "type", 0, mail_print, "t[ype] [msglist]" }, 80 { "uns", "unset", "uns[et] name...", 0, mail_unset, 0 },
81 { "una", "unalias", 0, mail_unalias,"una[lias] [alias]..." }, 81 { "unt", "untag", "unt[ag] [msglist]", 0, mail_tag, 0 },
82 { "u", "undelete", 0, mail_undelete,"u[ndelete] [msglist]" }, 82 { "ve", "version", "ve[rsion]", 0, mail_version, 0 },
83 { "uns", "unset", 0, mail_unset, "uns[et] name..." }, 83 { "v", "visual", "v[isual] [msglist]", 0, mail_visual, 0 },
84 { "unt", "untag", 0, mail_tag, "unt[ag] [msglist]" }, 84 { "wa", "warranty", "wa[rranty]", 0, mail_warranty, 0 },
85 { "ve", "version", 0, mail_version, "ve[rsion]" }, 85 { "W", "Write", "W[rite] [msglist]", 0, mail_write, 0 },
86 { "v", "visual", 0, mail_visual, "v[isual] [msglist]" }, 86 { "w", "write", "w[rite] [[msglist] file]", 0, mail_write, 0 },
87 { "wa", "warranty", 0, mail_warranty,"wa[rranty]" }, 87 { "x", "xit", "x[it]", 0, mail_exit, 0 },
88 { "W", "Write", 0, mail_write, "W[rite] [msglist]" }, 88 { "z", "", "z[+|-|. [count]]", 0, mail_z, 0 },
89 { "w", "write", 0, mail_write, "w[rite] [[msglist] file]" }, 89 { "?", "?", "? [command...]", 0, mail_help, 0 },
90 { "x", "xit", 0, mail_exit, "x[it]" }, 90 { "!", "", "![command]", 0, mail_shell, 0 },
91 { "z", "", 0, mail_z, "z[+|-|. [count]]" }, 91 { "=", "=", "=", 0, mail_eq, 0 },
92 { "?", "?", 0, mail_help, "? [command...]" }, 92 { "#", "#", "# comment", 0, NULL, 0 },
93 { "!", "", 0, mail_shell, "![command]" }, 93 { "*", "*", "*", 0, mail_list, 0 },
94 { "=", "=", 0, mail_eq, "=" }, 94 { "+", "+", "+ [message]", 0, mail_next, 0 },
95 { "#", "#", 0, NULL, "# comment" }, 95 { "|", "|", "| [[msglist] command]", 0, mail_pipe, 0 },
96 { "*", "*", 0, mail_list, "*" }, 96 { "-", "-", "- [message]", 0, mail_previous, 0 },
97 { "+", "+", 0, mail_next, "+ [message]" }, 97 { 0, 0, 0, 0, 0, 0}
98 { "|", "|", 0, mail_pipe, "| [[msglist] command]" },
99 { "-", "-", 0, mail_previous,"- [message]" },
100 { 0, 0, 0, 0, 0}
101 }; 98 };
102 99
103 const struct mail_command_entry mail_escape_table[] = { 100 const struct mail_command_entry mail_escape_table[] = {
104 {"!", "!", 0, var_shell, "![shell-command]"}, 101 {"!", "!", "![shell-command]", 0, 0, var_shell },
105 {":", ":", 0, var_command, ":[mail-command]"}, 102 {":", ":", ":[mail-command]", 0, 0, var_command },
106 {"-", "-", 0, var_command, "-[mail-command]"}, 103 {"-", "-", "-[mail-command]", 0, 0, var_command },
107 {"?", "?", 0, var_help, "?"}, 104 {"?", "?", "?", 0, 0, var_help },
108 {"A", "A", 0, var_sign, "A"}, 105 {"A", "A", "A", 0, 0, var_sign },
109 {"a", "a", 0, var_sign, "a"}, 106 {"a", "a", "a", 0, 0, var_sign },
110 {"b", "b", 0, var_bcc, "b[bcc-list]"}, 107 {"b", "b", "b[bcc-list]", 0, 0, var_bcc },
111 {"c", "c", 0, var_cc, "c[cc-list]"}, 108 {"c", "c", "c[cc-list]", 0, 0, var_cc },
112 {"d", "d", 0, var_deadletter, "d"}, 109 {"d", "d", "d", 0, 0, var_deadletter },
113 {"e", "e", 0, var_editor, "e"}, 110 {"e", "e", "e", 0, 0, var_editor },
114 {"f", "f", 0, var_print, "f[mesg-list]"}, 111 {"f", "f", "f[mesg-list]", 0, 0, var_print },
115 {"F", "F", 0, var_print, "F[mesg-list]"}, 112 {"F", "F", "F[mesg-list]", 0, 0, var_print },
116 {"h", "h", 0, var_headers, "h"}, 113 {"h", "h", "h", 0, 0, var_headers },
117 {"i", "i", 0, var_insert, "i[var-name]"}, 114 {"i", "i", "i[var-name]", 0, 0, var_insert },
118 {"m", "m", 0, var_quote, "m[mesg-list]"}, 115 {"m", "m", "m[mesg-list]", 0, 0, var_quote },
119 {"M", "M", 0, var_quote, "M[mesg-list]"}, 116 {"M", "M", "M[mesg-list]", 0, 0, var_quote },
120 {"p", "p", 0, var_type_input,"p"}, 117 {"p", "p", "p", 0, 0, var_type_input },
121 {"r", "<", 0, var_read, "r[filename]"}, 118 {"r", "<", "r[filename]", 0, 0, var_read },
122 {"s", "s", 0, var_subj, "s[string]"}, 119 {"s", "s", "s[string]", 0, 0, var_subj },
123 {"t", "t", 0, var_to, "t[name-list]"}, 120 {"t", "t", "t[name-list]", 0, 0, var_to },
124 {"v", "v", 0, var_visual, "v"}, 121 {"v", "v", "v", 0, 0, var_visual },
125 {"w", "w", 0, var_write, "w[filename]"}, 122 {"w", "w", "w[filename]", 0, 0, var_write },
126 {"x", "x", 0, var_exit, "x"}, 123 {"x", "x", "x", 0, 0, var_exit },
127 {"|", "|", 0, var_pipe, "|[shell-command]"}, 124 {"|", "|", "|[shell-command]", 0, 0, var_pipe },
128 {0, 0, 0, 0} 125 {0, 0, 0, 0, 0, 0}
129 }; 126 };
......
...@@ -21,10 +21,12 @@ ...@@ -21,10 +21,12 @@
21 /* unt[ag] [msglist] */ 21 /* unt[ag] [msglist] */
22 22
23 static int 23 static int
24 tag_message (message_t mesg, msgset_t *msgset, int *action) 24 tag_message (message_t mesg, msgset_t *msgset, void *arg)
25 { 25 {
26 attribute_t attr; 26 attribute_t attr;
27 int *action = arg;
27 28
29 (void)msgset;
28 message_get_attribute (mesg, &attr); 30 message_get_attribute (mesg, &attr);
29 if (*action) 31 if (*action)
30 attribute_set_userflag (attr, MAIL_ATTRIBUTE_TAGGED); 32 attribute_set_userflag (attr, MAIL_ATTRIBUTE_TAGGED);
...@@ -42,7 +44,7 @@ mail_tag (int argc, char **argv) ...@@ -42,7 +44,7 @@ mail_tag (int argc, char **argv)
42 if (msgset_parse (argc, argv, &msgset)) 44 if (msgset_parse (argc, argv, &msgset))
43 return 1; 45 return 1;
44 46
45 util_msgset_iterate (msgset, tag_message, &action); 47 util_msgset_iterate (msgset, tag_message, (void *)&action);
46 48
47 msgset_free (msgset); 49 msgset_free (msgset);
48 return 0; 50 return 0;
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
22 # include <termios.h> 22 # include <termios.h>
23 #endif 23 #endif
24 #include <sys/ioctl.h> 24 #include <sys/ioctl.h>
25 #include <sys/stat.h>
25 26
26 #ifdef HAVE_FCNTL_H 27 #ifdef HAVE_FCNTL_H
27 # include <fcntl.h> 28 # include <fcntl.h>
...@@ -104,7 +105,7 @@ util_do_command (const char *c, ...) ...@@ -104,7 +105,7 @@ util_do_command (const char *c, ...)
104 105
105 entry = util_find_entry (mail_command_table, argv[0]); 106 entry = util_find_entry (mail_command_table, argv[0]);
106 107
107 if (if_cond() == 0 && (entry.flags & EF_FLOW) == 0) 108 if (if_cond () == 0 && (entry.flags & EF_FLOW) == 0)
108 { 109 {
109 argcv_free (argc, argv); 110 argcv_free (argc, argv);
110 return 0; 111 return 0;
...@@ -166,11 +167,46 @@ util_msglist_command (function_t *func, int argc, char **argv, int set_cursor) ...@@ -166,11 +167,46 @@ util_msglist_command (function_t *func, int argc, char **argv, int set_cursor)
166 return status; 167 return status;
167 } 168 }
168 169
170 /* Same as util_msglis_command but the function comes from the escape
171 cmd table, so will have a different argument signature. */
172 int
173 util_msglist_esccmd (int (*escfunc)
174 __P ((int, char **, struct send_environ *)),
175 int argc, char **argv, struct send_environ *env,
176 int set_cursor)
177 {
178 msgset_t *list = NULL, *mp;
179 int status = 0;
180
181 if (msgset_parse (argc, argv, &list))
182 return 1;
183
184 realcursor = cursor;
185
186 for (mp = list; mp; mp = mp->next)
187 {
188 cursor = mp->msg_part[0];
189 /* NOTE: Should we bail on error also? */
190 if (escfunc (1, argv, env) != 0)
191 status = 1;
192 /* Bail out if we receive an interrupt. */
193 if (ml_got_interrupt () != 0)
194 break;
195 }
196 msgset_free (list);
197
198 if (set_cursor)
199 realcursor = cursor;
200 else
201 cursor = realcursor;
202 return status;
203 }
204
169 /* 205 /*
170 * returns the function to run for command 206 * returns the function to run for command
171 */ 207 */
172 function_t * 208 function_t *
173 util_command_get (char *cmd) 209 util_command_get (const char *cmd)
174 { 210 {
175 struct mail_command_entry entry = util_find_entry (mail_command_table, cmd); 211 struct mail_command_entry entry = util_find_entry (mail_command_table, cmd);
176 return entry.func; 212 return entry.func;
...@@ -180,7 +216,7 @@ util_command_get (char *cmd) ...@@ -180,7 +216,7 @@ util_command_get (char *cmd)
180 * returns the mail_command_entry structure for the command matching cmd 216 * returns the mail_command_entry structure for the command matching cmd
181 */ 217 */
182 struct mail_command_entry 218 struct mail_command_entry
183 util_find_entry (const struct mail_command_entry *table, char *cmd) 219 util_find_entry (const struct mail_command_entry *table, const char *cmd)
184 { 220 {
185 int i = 0, ll = 0, sl = 0; 221 int i = 0, ll = 0, sl = 0;
186 int len = strlen (cmd); 222 int len = strlen (cmd);
...@@ -228,9 +264,12 @@ util_getcols (void) ...@@ -228,9 +264,12 @@ util_getcols (void)
228 struct winsize ws; 264 struct winsize ws;
229 265
230 ws.ws_col = ws.ws_row = 0; 266 ws.ws_col = ws.ws_row = 0;
231 if ((ioctl(1, TIOCGWINSZ, (char *) &ws) < 0) 267 if ((ioctl(1, TIOCGWINSZ, (char *) &ws) < 0) || ws.ws_row == 0)
232 || ws.ws_row == 0) 268 {
233 ws.ws_col = strtol (getenv("COLUMNS"), NULL, 10); 269 const char *columns = getenv ("COLUMNS");
270 if (columns)
271 ws.ws_col = strtol (columns, NULL, 10);
272 }
234 273
235 /* FIXME: Should we exit()/abort() if col <= 0 ? */ 274 /* FIXME: Should we exit()/abort() if col <= 0 ? */
236 return ws.ws_col; 275 return ws.ws_col;
...@@ -246,9 +285,12 @@ util_getlines (void) ...@@ -246,9 +285,12 @@ util_getlines (void)
246 struct winsize ws; 285 struct winsize ws;
247 286
248 ws.ws_col = ws.ws_row = 0; 287 ws.ws_col = ws.ws_row = 0;
249 if ((ioctl(1, TIOCGWINSZ, (char *) &ws) < 0) 288 if ((ioctl(1, TIOCGWINSZ, (char *) &ws) < 0) || ws.ws_row == 0)
250 || ws.ws_row == 0) 289 {
251 ws.ws_row = strtol (getenv("LINES"), NULL, 10); 290 const char *lines = getenv ("LINES");
291 if (lines)
292 ws.ws_row = strtol (lines, NULL, 10);
293 }
252 294
253 /* FIXME: Should we exit()/abort() if row <= 0 ? */ 295 /* FIXME: Should we exit()/abort() if row <= 0 ? */
254 296
...@@ -257,12 +299,12 @@ util_getlines (void) ...@@ -257,12 +299,12 @@ util_getlines (void)
257 } 299 }
258 300
259 int 301 int
260 util_screen_lines() 302 util_screen_lines ()
261 { 303 {
262 struct mail_env_entry *ep = util_find_env("screen"); 304 struct mail_env_entry *ep = util_find_env ("screen");
263 size_t n; 305 size_t n;
264 306
265 if (ep && ep->set && (n = atoi(ep->value)) != 0) 307 if (ep && ep->set && (n = strtoul (ep->value, NULL, 10)) != 0)
266 return n; 308 return n;
267 n = util_getlines(); 309 n = util_getlines();
268 util_do_command ("set screen=%d", n); 310 util_do_command ("set screen=%d", n);
...@@ -270,12 +312,12 @@ util_screen_lines() ...@@ -270,12 +312,12 @@ util_screen_lines()
270 } 312 }
271 313
272 int 314 int
273 util_screen_columns() 315 util_screen_columns ()
274 { 316 {
275 struct mail_env_entry *ep = util_find_env("columns"); 317 struct mail_env_entry *ep = util_find_env("columns");
276 size_t n; 318 size_t n;
277 319
278 if (ep && ep->set && (n = atoi(ep->value)) != 0) 320 if (ep && ep->set && (n = strtoul (ep->value, NULL, 10)) != 0)
279 return n; 321 return n;
280 n = util_getcols(); 322 n = util_getcols();
281 util_do_command ("set columns=%d", n); 323 util_do_command ("set columns=%d", n);
...@@ -295,7 +337,7 @@ util_find_env (const char *variable) ...@@ -295,7 +337,7 @@ util_find_env (const char *variable)
295 /* Annoying, variable "ask" is equivalent to "asksub". */ 337 /* Annoying, variable "ask" is equivalent to "asksub". */
296 static const char *asksub = "asksub"; 338 static const char *asksub = "asksub";
297 const char *var = variable; 339 const char *var = variable;
298 int len = strlen (var); 340 size_t len = strlen (var);
299 node *t; 341 node *t;
300 342
301 if (len < 1) 343 if (len < 1)
...@@ -425,7 +467,7 @@ util_get_homedir() ...@@ -425,7 +467,7 @@ util_get_homedir()
425 } 467 }
426 468
427 char * 469 char *
428 util_fullpath(char *inpath) 470 util_fullpath(const char *inpath)
429 { 471 {
430 return mu_tilde_expansion(inpath, "/", NULL); 472 return mu_tilde_expansion(inpath, "/", NULL);
431 } 473 }
...@@ -548,7 +590,7 @@ util_slist_destroy (list_t *list) ...@@ -548,7 +590,7 @@ util_slist_destroy (list_t *list)
548 } 590 }
549 591
550 char * 592 char *
551 util_slist_to_string (list_t list, char *delim) 593 util_slist_to_string (list_t list, const char *delim)
552 { 594 {
553 iterator_t itr; 595 iterator_t itr;
554 char *name; 596 char *name;
...@@ -569,7 +611,7 @@ util_slist_to_string (list_t list, char *delim) ...@@ -569,7 +611,7 @@ util_slist_to_string (list_t list, char *delim)
569 } 611 }
570 612
571 void 613 void
572 util_strcat(char **dest, char *str) 614 util_strcat(char **dest, const char *str)
573 { 615 {
574 if (!*dest) 616 if (!*dest)
575 *dest = strdup (str); 617 *dest = strdup (str);
...@@ -593,10 +635,10 @@ util_strupper (char *s) ...@@ -593,10 +635,10 @@ util_strupper (char *s)
593 { 635 {
594 if (s) 636 if (s)
595 { 637 {
596 int i; 638 size_t i;
597 int len = strlen (s); 639 size_t len = strlen (s);
598 for (i = 0; i < len; i++) 640 for (i = 0; i < len; i++)
599 s[i] = toupper ((int)s[i]); 641 s[i] = toupper ((unsigned int)(s[i]));
600 } 642 }
601 } 643 }
602 644
...@@ -623,7 +665,7 @@ util_escape_percent (char **str) ...@@ -623,7 +665,7 @@ util_escape_percent (char **str)
623 /* and escape percent signs */ 665 /* and escape percent signs */
624 p = newstr; 666 p = newstr;
625 q = *str; 667 q = *str;
626 while (*p = *q++) 668 while ((*p = *q++))
627 { 669 {
628 if (*p == '%') 670 if (*p == '%')
629 *++p = '%'; 671 *++p = '%';
...@@ -679,7 +721,7 @@ util_save_outgoing (message_t msg, char *savefile) ...@@ -679,7 +721,7 @@ util_save_outgoing (message_t msg, char *savefile)
679 } 721 }
680 else 722 else
681 { 723 {
682 char *buf; 724 char *buf = NULL;
683 size_t bsize = 0; 725 size_t bsize = 0;
684 726
685 message_size (msg, &bsize); 727 message_size (msg, &bsize);
...@@ -786,7 +828,7 @@ int ...@@ -786,7 +828,7 @@ int
786 util_tempfile(char **namep) 828 util_tempfile(char **namep)
787 { 829 {
788 char *filename; 830 char *filename;
789 char *tmpdir; 831 const char *tmpdir;
790 int fd; 832 int fd;
791 833
792 /* We have to be extra careful about opening temporary files, since we 834 /* We have to be extra careful about opening temporary files, since we
...@@ -829,15 +871,15 @@ util_tempfile(char **namep) ...@@ -829,15 +871,15 @@ util_tempfile(char **namep)
829 return fd; 871 return fd;
830 } 872 }
831 873
832 int 874 static int
833 util_descend_subparts (message_t mesg, msgset_t *msgset, message_t *part) 875 util_descend_subparts (message_t mesg, msgset_t *msgset, message_t *part)
834 { 876 {
835 int i; 877 unsigned int i;
836 878
837 for (i = 1; i < msgset->npart; i++) 879 for (i = 1; i < msgset->npart; i++)
838 { 880 {
839 message_t submsg = NULL; 881 message_t submsg = NULL;
840 int nparts = 0; 882 unsigned int nparts = 0;
841 char *type = NULL; 883 char *type = NULL;
842 header_t hdr = NULL; 884 header_t hdr = NULL;
843 885
...@@ -876,7 +918,9 @@ util_descend_subparts (message_t mesg, msgset_t *msgset, message_t *part) ...@@ -876,7 +918,9 @@ util_descend_subparts (message_t mesg, msgset_t *msgset, message_t *part)
876 } 918 }
877 919
878 void 920 void
879 util_msgset_iterate (msgset_t *msgset, int (*fun)(), void *closure) 921 util_msgset_iterate (msgset_t *msgset,
922 int (*fun) __P ((message_t, msgset_t *, void *)),
923 void *closure)
880 { 924 {
881 for (; msgset; msgset = msgset->next) 925 for (; msgset; msgset = msgset->next)
882 { 926 {
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
21 #include <sys/stat.h> 21 #include <sys/stat.h>
22 22
23 static void 23 static void
24 var_continue() 24 var_continue (void)
25 { 25 {
26 fprintf(stdout, "(continue)\n"); 26 fprintf(stdout, "(continue)\n");
27 } 27 }
...@@ -82,6 +82,7 @@ var_command(int argc, char **argv, struct send_environ *env) ...@@ -82,6 +82,7 @@ var_command(int argc, char **argv, struct send_environ *env)
82 int 82 int
83 var_help(int argc, char **argv, struct send_environ *env) 83 var_help(int argc, char **argv, struct send_environ *env)
84 { 84 {
85 (void)env;
85 if (argc < 2) 86 if (argc < 2)
86 return util_help(mail_escape_table, NULL); 87 return util_help(mail_escape_table, NULL);
87 else 88 else
...@@ -102,6 +103,9 @@ int ...@@ -102,6 +103,9 @@ int
102 var_sign(int argc, char **argv, struct send_environ *env) 103 var_sign(int argc, char **argv, struct send_environ *env)
103 { 104 {
104 struct mail_env_entry *p; 105 struct mail_env_entry *p;
106
107 (void)argc; (void)env;
108
105 if (isupper(argv[0][0])) 109 if (isupper(argv[0][0]))
106 p = util_find_env("Sign"); 110 p = util_find_env("Sign");
107 else 111 else
...@@ -163,6 +167,8 @@ var_deadletter(int argc, char **argv, struct send_environ *env) ...@@ -163,6 +167,8 @@ var_deadletter(int argc, char **argv, struct send_environ *env)
163 FILE *dead = fopen(getenv("DEAD"), "r"); 167 FILE *dead = fopen(getenv("DEAD"), "r");
164 int c; 168 int c;
165 169
170 (void)argc; (void)argv; (void)env;
171
166 while ((c = fgetc(dead)) != EOF) 172 while ((c = fgetc(dead)) != EOF)
167 fputc(c, ofile); 173 fputc(c, ofile);
168 fclose(dead); 174 fclose(dead);
...@@ -172,6 +178,7 @@ var_deadletter(int argc, char **argv, struct send_environ *env) ...@@ -172,6 +178,7 @@ var_deadletter(int argc, char **argv, struct send_environ *env)
172 static int 178 static int
173 var_run_editor(char *ed, int argc, char **argv, struct send_environ *env) 179 var_run_editor(char *ed, int argc, char **argv, struct send_environ *env)
174 { 180 {
181 (void)argc; (void)argv;
175 fclose(env->file); 182 fclose(env->file);
176 ofile = env->ofile; 183 ofile = env->ofile;
177 util_do_command("!%s %s", ed, env->filename); 184 util_do_command("!%s %s", ed, env->filename);
...@@ -200,6 +207,7 @@ var_visual(int argc, char **argv, struct send_environ *env) ...@@ -200,6 +207,7 @@ var_visual(int argc, char **argv, struct send_environ *env)
200 int 207 int
201 var_print(int argc, char **argv, struct send_environ *env) 208 var_print(int argc, char **argv, struct send_environ *env)
202 { 209 {
210 (void)env;
203 return mail_print(argc, argv); 211 return mail_print(argc, argv);
204 } 212 }
205 213
...@@ -207,6 +215,7 @@ var_print(int argc, char **argv, struct send_environ *env) ...@@ -207,6 +215,7 @@ var_print(int argc, char **argv, struct send_environ *env)
207 int 215 int
208 var_headers(int argc, char **argv, struct send_environ *env) 216 var_headers(int argc, char **argv, struct send_environ *env)
209 { 217 {
218 (void)argc; (void)argv;
210 ml_reread("To: ", &env->to); 219 ml_reread("To: ", &env->to);
211 ml_reread("Cc: ", &env->cc); 220 ml_reread("Cc: ", &env->cc);
212 ml_reread("Bcc: ", &env->bcc); 221 ml_reread("Bcc: ", &env->bcc);
...@@ -219,6 +228,7 @@ var_headers(int argc, char **argv, struct send_environ *env) ...@@ -219,6 +228,7 @@ var_headers(int argc, char **argv, struct send_environ *env)
219 int 228 int
220 var_insert(int argc, char **argv, struct send_environ *env) 229 var_insert(int argc, char **argv, struct send_environ *env)
221 { 230 {
231 (void)env;
222 if (var_check_args (argc, argv)) 232 if (var_check_args (argc, argv))
223 return 1; 233 return 1;
224 fprintf(ofile, "%s", util_find_env(argv[1])->value); 234 fprintf(ofile, "%s", util_find_env(argv[1])->value);
...@@ -231,7 +241,7 @@ int ...@@ -231,7 +241,7 @@ int
231 var_quote(int argc, char **argv, struct send_environ *env) 241 var_quote(int argc, char **argv, struct send_environ *env)
232 { 242 {
233 if (argc > 1) 243 if (argc > 1)
234 return util_msglist_command(var_quote, argc, argv, 0); 244 return util_msglist_esccmd (var_quote, argc, argv, env, 0);
235 else 245 else
236 { 246 {
237 message_t mesg; 247 message_t mesg;
...@@ -251,20 +261,19 @@ var_quote(int argc, char **argv, struct send_environ *env) ...@@ -251,20 +261,19 @@ var_quote(int argc, char **argv, struct send_environ *env)
251 if (islower(argv[0][0])) 261 if (islower(argv[0][0]))
252 { 262 {
253 size_t i, num = 0; 263 size_t i, num = 0;
254 char buffer[512]; 264 char buf[512];
255 265
256 message_get_header(mesg, &hdr); 266 message_get_header(mesg, &hdr);
257 header_get_field_count(hdr, &num); 267 header_get_field_count(hdr, &num);
258 268
259 for (i = 1; i <= num; i++) 269 for (i = 1; i <= num; i++)
260 { 270 {
261 header_get_field_name(hdr, i, buffer, sizeof(buffer), NULL); 271 header_get_field_name(hdr, i, buf, sizeof buf, NULL);
262 if (mail_header_is_visible(buffer)) 272 if (mail_header_is_visible(buf))
263 { 273 {
264 fprintf(ofile, "%s%s: ", prefix, buffer); 274 fprintf(ofile, "%s%s: ", prefix, buf);
265 header_get_field_value(hdr, i, buffer, sizeof(buffer), 275 header_get_field_value(hdr, i, buf, sizeof buf, NULL);
266 NULL); 276 fprintf(ofile, "%s\n", buf);
267 fprintf(ofile, "%s\n", buffer);
268 } 277 }
269 } 278 }
270 fprintf(ofile, "\n"); 279 fprintf(ofile, "\n");
...@@ -274,7 +283,7 @@ var_quote(int argc, char **argv, struct send_environ *env) ...@@ -274,7 +283,7 @@ var_quote(int argc, char **argv, struct send_environ *env)
274 else 283 else
275 message_get_stream(mesg, &stream); 284 message_get_stream(mesg, &stream);
276 285
277 while (stream_readline(stream, buffer, sizeof(buffer) - 1, off, &n) == 0 286 while (stream_readline(stream, buffer, sizeof buffer - 1, off, &n) == 0
278 && n != 0) 287 && n != 0)
279 { 288 {
280 buffer[n] = '\0'; 289 buffer[n] = '\0';
...@@ -292,6 +301,8 @@ var_type_input(int argc, char **argv, struct send_environ *env) ...@@ -292,6 +301,8 @@ var_type_input(int argc, char **argv, struct send_environ *env)
292 { 301 {
293 char buf[512]; 302 char buf[512];
294 303
304 (void)argc; (void)argv;
305
295 fprintf(env->ofile, "Message contains:\n"); 306 fprintf(env->ofile, "Message contains:\n");
296 307
297 if (env->to) 308 if (env->to)
...@@ -321,6 +332,8 @@ var_read(int argc, char **argv, struct send_environ *env) ...@@ -321,6 +332,8 @@ var_read(int argc, char **argv, struct send_environ *env)
321 size_t size, lines; 332 size_t size, lines;
322 char buf[512]; 333 char buf[512];
323 334
335 (void)env;
336
324 if (var_check_args (argc, argv)) 337 if (var_check_args (argc, argv))
325 return 1; 338 return 1;
326 filename = util_fullpath(argv[1]); 339 filename = util_fullpath(argv[1]);
...@@ -405,6 +418,7 @@ var_write(int argc, char **argv, struct send_environ *env) ...@@ -405,6 +418,7 @@ var_write(int argc, char **argv, struct send_environ *env)
405 int 418 int
406 var_exit(int argc, char **argv, struct send_environ *env) 419 var_exit(int argc, char **argv, struct send_environ *env)
407 { 420 {
421 (void)argc; (void)argv; (void)env;
408 return util_do_command("quit"); 422 return util_do_command("quit");
409 } 423 }
410 424
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
21 * ve[rsion] 21 * ve[rsion]
22 */ 22 */
23 23
24 static char *with_defs[] = 24 static const char *with_defs[] =
25 { 25 {
26 #ifdef WITH_PTHREAD 26 #ifdef WITH_PTHREAD
27 "PTHREAD", 27 "PTHREAD",
...@@ -39,6 +39,7 @@ static char *with_defs[] = ...@@ -39,6 +39,7 @@ static char *with_defs[] =
39 int 39 int
40 mail_version (int argc, char **argv) 40 mail_version (int argc, char **argv)
41 { 41 {
42 (void)argc; (void)argv;
42 fprintf (ofile, "%s", argp_program_version); 43 fprintf (ofile, "%s", argp_program_version);
43 if (with_defs[0] != NULL) 44 if (with_defs[0] != NULL)
44 { 45 {
......
...@@ -102,7 +102,7 @@ mail_write (int argc, char **argv) ...@@ -102,7 +102,7 @@ mail_write (int argc, char **argv)
102 attribute_set_userflag (attr, MAIL_ATTRIBUTE_SAVED); 102 attribute_set_userflag (attr, MAIL_ATTRIBUTE_SAVED);
103 } 103 }
104 104
105 fprintf (ofile, "\"%s\" %3ld/%-5ld\n", filename, total_lines, total_size); 105 fprintf (ofile, "\"%s\" %3d/%-5d\n", filename, total_lines, total_size);
106 106
107 free (filename); 107 free (filename);
108 fclose (output); 108 fclose (output);
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
31 */ 31 */
32 32
33 static int 33 static int
34 z_parse_args(int argc, char **argv, int *return_count, int *return_dir) 34 z_parse_args(int argc, char **argv, unsigned int *return_count, int *return_dir)
35 { 35 {
36 int count = 1; 36 int count = 1;
37 int mul = 1; 37 int mul = 1;
...@@ -87,7 +87,7 @@ z_parse_args(int argc, char **argv, int *return_count, int *return_dir) ...@@ -87,7 +87,7 @@ z_parse_args(int argc, char **argv, int *return_count, int *return_dir)
87 return 1; 87 return 1;
88 } 88 }
89 89
90 if ((mul = atoi(argp)) == 0) 90 if ((mul = strtoul (argp, NULL, 10)) == 0)
91 { 91 {
92 util_error("Bad number of pages"); 92 util_error("Bad number of pages");
93 return 1; 93 return 1;
...@@ -107,7 +107,7 @@ mail_z (int argc, char **argv) ...@@ -107,7 +107,7 @@ mail_z (int argc, char **argv)
107 { 107 {
108 unsigned int i, nlines; 108 unsigned int i, nlines;
109 unsigned int pagelines = util_screen_lines(); 109 unsigned int pagelines = util_screen_lines();
110 int count; 110 unsigned int count;
111 int dir; 111 int dir;
112 112
113 if (z_parse_args(argc, argv, &count, &dir)) 113 if (z_parse_args(argc, argv, &count, &dir))
...@@ -161,7 +161,7 @@ mail_z (int argc, char **argv) ...@@ -161,7 +161,7 @@ mail_z (int argc, char **argv)
161 int lastpage = total - pagelines + 1; 161 int lastpage = total - pagelines + 1;
162 if (lastpage <= 0) 162 if (lastpage <= 0)
163 lastpage = 1; 163 lastpage = 1;
164 if (cursor > lastpage) 164 if (cursor > (unsigned int)lastpage)
165 { 165 {
166 realcursor = cursor; 166 realcursor = cursor;
167 cursor = lastpage; 167 cursor = lastpage;
......