aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2020-12-17 12:24:50 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2020-12-17 12:24:50 +0100
commit25b2680056454dc4761ba3b2efde7c3414738f8c (patch)
tree5fc9e7fd30b948a8edba34df429224e9c887eea5
parent91e330a53fc8052addec941a9e1e6fcd4b68702b (diff)
downloadbusybox-w32-25b2680056454dc4761ba3b2efde7c3414738f8c.tar.gz
busybox-w32-25b2680056454dc4761ba3b2efde7c3414738f8c.tar.bz2
busybox-w32-25b2680056454dc4761ba3b2efde7c3414738f8c.zip
mail: move "opts" from globals
function old new delta popmaildir_main 812 823 +11 sendmail_main 1295 1301 +6 makemime_main 291 288 -3 parse 970 966 -4 reformime_main 107 100 -7 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/3 up/down: 17/-14) Total: 3 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--mailutils/mail.c6
-rw-r--r--mailutils/mail.h4
-rw-r--r--mailutils/makemime.c1
-rw-r--r--mailutils/popmaildir.c5
-rw-r--r--mailutils/reformime.c5
-rw-r--r--mailutils/sendmail.c9
6 files changed, 15 insertions, 15 deletions
diff --git a/mailutils/mail.c b/mailutils/mail.c
index 3a1fd6949..ce5267904 100644
--- a/mailutils/mail.c
+++ b/mailutils/mail.c
@@ -72,12 +72,12 @@ void FAST_FUNC launch_helper(const char **argv)
72char* FAST_FUNC send_mail_command(const char *fmt, const char *param) 72char* FAST_FUNC send_mail_command(const char *fmt, const char *param)
73{ 73{
74 char *msg; 74 char *msg;
75 if (timeout) 75 if (G.timeout)
76 alarm(timeout); 76 alarm(G.timeout);
77 msg = (char*)fmt; 77 msg = (char*)fmt;
78 if (fmt) { 78 if (fmt) {
79 msg = xasprintf(fmt, param); 79 msg = xasprintf(fmt, param);
80 if (verbose) 80 if (G.verbose)
81 bb_error_msg("send:'%s'", msg); 81 bb_error_msg("send:'%s'", msg);
82 printf("%s\r\n", msg); 82 printf("%s\r\n", msg);
83 } 83 }
diff --git a/mailutils/mail.h b/mailutils/mail.h
index b14228a4a..2fcd0802d 100644
--- a/mailutils/mail.h
+++ b/mailutils/mail.h
@@ -11,7 +11,6 @@ struct globals {
11 pid_t helper_pid; 11 pid_t helper_pid;
12 unsigned timeout; 12 unsigned timeout;
13 unsigned verbose; 13 unsigned verbose;
14 unsigned opts;
15 char *user; 14 char *user;
16 char *pass; 15 char *pass;
17 FILE *fp0; // initial stdin 16 FILE *fp0; // initial stdin
@@ -19,9 +18,6 @@ struct globals {
19}; 18};
20 19
21#define G (*ptr_to_globals) 20#define G (*ptr_to_globals)
22#define timeout (G.timeout )
23#define verbose (G.verbose )
24#define opts (G.opts )
25#define INIT_G() do { \ 21#define INIT_G() do { \
26 SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \ 22 SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
27 G.opt_charset = (char *)CONFIG_FEATURE_MIME_CHARSET; \ 23 G.opt_charset = (char *)CONFIG_FEATURE_MIME_CHARSET; \
diff --git a/mailutils/makemime.c b/mailutils/makemime.c
index 53a1820f1..1ff2012d5 100644
--- a/mailutils/makemime.c
+++ b/mailutils/makemime.c
@@ -173,6 +173,7 @@ Content-Transfer-Encoding: 7bit
173int makemime_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 173int makemime_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
174int makemime_main(int argc UNUSED_PARAM, char **argv) 174int makemime_main(int argc UNUSED_PARAM, char **argv)
175{ 175{
176 unsigned opts;
176 llist_t *opt_headers = NULL, *l; 177 llist_t *opt_headers = NULL, *l;
177 const char *opt_output; 178 const char *opt_output;
178 const char *content_type = "application/octet-stream"; 179 const char *content_type = "application/octet-stream";
diff --git a/mailutils/popmaildir.c b/mailutils/popmaildir.c
index c5522f1b7..4f2d4124d 100644
--- a/mailutils/popmaildir.c
+++ b/mailutils/popmaildir.c
@@ -71,7 +71,7 @@ static void pop3_checkr(const char *fmt, const char *param, char **ret)
71 char *answer = xmalloc_fgetline(stdin); 71 char *answer = xmalloc_fgetline(stdin);
72 if (answer && '+' == answer[0]) { 72 if (answer && '+' == answer[0]) {
73 free(msg); 73 free(msg);
74 if (timeout) 74 if (G.timeout)
75 alarm(0); 75 alarm(0);
76 if (ret) { 76 if (ret) {
77 // skip "+OK " 77 // skip "+OK "
@@ -92,6 +92,7 @@ static void pop3_check(const char *fmt, const char *param)
92int popmaildir_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 92int popmaildir_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
93int popmaildir_main(int argc UNUSED_PARAM, char **argv) 93int popmaildir_main(int argc UNUSED_PARAM, char **argv)
94{ 94{
95 unsigned opts;
95 char *buf; 96 char *buf;
96 unsigned nmsg; 97 unsigned nmsg;
97 char *hostname; 98 char *hostname;
@@ -128,7 +129,7 @@ int popmaildir_main(int argc UNUSED_PARAM, char **argv)
128 opts = getopt32(argv, "^" 129 opts = getopt32(argv, "^"
129 "bdmVcasTkt:+" "R:+Z:L:+H:+" IF_FEATURE_POPMAILDIR_DELIVERY("M:F:") 130 "bdmVcasTkt:+" "R:+Z:L:+H:+" IF_FEATURE_POPMAILDIR_DELIVERY("M:F:")
130 "\0" "-1:dd", 131 "\0" "-1:dd",
131 &timeout, NULL, NULL, NULL, &opt_nlines 132 &G.timeout, NULL, NULL, NULL, &opt_nlines
132 IF_FEATURE_POPMAILDIR_DELIVERY(, &delivery, &delivery) // we treat -M and -F the same 133 IF_FEATURE_POPMAILDIR_DELIVERY(, &delivery, &delivery) // we treat -M and -F the same
133 ); 134 );
134 //argc -= optind; 135 //argc -= optind;
diff --git a/mailutils/reformime.c b/mailutils/reformime.c
index 307656a15..a1d3f4e8b 100644
--- a/mailutils/reformime.c
+++ b/mailutils/reformime.c
@@ -166,7 +166,7 @@ static int parse(const char *boundary, char **argv)
166 else 166 else
167 filename = bb_get_last_path_component_strip(xstrdup(filename)); 167 filename = bb_get_last_path_component_strip(xstrdup(filename));
168 168
169 if (opts & OPT_X) { 169 if (option_mask32 & OPT_X) {
170 int fd[2]; 170 int fd[2];
171 171
172 /* start external helper */ 172 /* start external helper */
@@ -219,7 +219,7 @@ static int parse(const char *boundary, char **argv)
219 fclose(fp); 219 fclose(fp);
220 220
221 /* Wait for child */ 221 /* Wait for child */
222 if (opts & OPT_X) { 222 if (option_mask32 & OPT_X) {
223 int rc; 223 int rc;
224 signal(SIGPIPE, SIG_DFL); 224 signal(SIGPIPE, SIG_DFL);
225 rc = (wait4pid(pid) & 0xff); 225 rc = (wait4pid(pid) & 0xff);
@@ -275,6 +275,7 @@ Usage: reformime [options]
275int reformime_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 275int reformime_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
276int reformime_main(int argc UNUSED_PARAM, char **argv) 276int reformime_main(int argc UNUSED_PARAM, char **argv)
277{ 277{
278 unsigned opts;
278 const char *opt_prefix = ""; 279 const char *opt_prefix = "";
279 280
280 INIT_G(); 281 INIT_G();
diff --git a/mailutils/sendmail.c b/mailutils/sendmail.c
index 1bdc1c300..4bb90d3e2 100644
--- a/mailutils/sendmail.c
+++ b/mailutils/sendmail.c
@@ -104,7 +104,7 @@
104 104
105static void send_r_n(const char *s) 105static void send_r_n(const char *s)
106{ 106{
107 if (verbose) 107 if (G.verbose)
108 bb_error_msg("send:'%s'", s); 108 bb_error_msg("send:'%s'", s);
109 printf("%s\r\n", s); 109 printf("%s\r\n", s);
110} 110}
@@ -120,7 +120,7 @@ static int smtp_checkp(const char *fmt, const char *param, int code)
120 // if code != -1 then checks whether the number equals the code 120 // if code != -1 then checks whether the number equals the code
121 // if not equal -> die saying msg 121 // if not equal -> die saying msg
122 while ((answer = xmalloc_fgetline(stdin)) != NULL) { 122 while ((answer = xmalloc_fgetline(stdin)) != NULL) {
123 if (verbose) 123 if (G.verbose)
124 bb_error_msg("recv:'%.*s'", (int)(strchrnul(answer, '\r') - answer), answer); 124 bb_error_msg("recv:'%.*s'", (int)(strchrnul(answer, '\r') - answer), answer);
125 if (strlen(answer) <= 3 || '-' != answer[3]) 125 if (strlen(answer) <= 3 || '-' != answer[3])
126 break; 126 break;
@@ -128,7 +128,7 @@ static int smtp_checkp(const char *fmt, const char *param, int code)
128 } 128 }
129 if (answer) { 129 if (answer) {
130 int n = atoi(answer); 130 int n = atoi(answer);
131 if (timeout) 131 if (G.timeout)
132 alarm(0); 132 alarm(0);
133 free(answer); 133 free(answer);
134 if (-1 == code || n == code) { 134 if (-1 == code || n == code) {
@@ -223,6 +223,7 @@ static void rcptto_list(const char *list)
223int sendmail_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 223int sendmail_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
224int sendmail_main(int argc UNUSED_PARAM, char **argv) 224int sendmail_main(int argc UNUSED_PARAM, char **argv)
225{ 225{
226 unsigned opts;
226 char *opt_connect; 227 char *opt_connect;
227 char *opt_from = NULL; 228 char *opt_from = NULL;
228 char *s; 229 char *s;
@@ -276,7 +277,7 @@ int sendmail_main(int argc UNUSED_PARAM, char **argv)
276 // -v is a counter, -H and -S are mutually exclusive, -a is a list 277 // -v is a counter, -H and -S are mutually exclusive, -a is a list
277 "vv:H--S:S--H", 278 "vv:H--S:S--H",
278 &opt_from, NULL, 279 &opt_from, NULL,
279 &timeout, &opt_connect, &opt_connect, &list, &verbose 280 &G.timeout, &opt_connect, &opt_connect, &list, &G.verbose
280 ); 281 );
281 //argc -= optind; 282 //argc -= optind;
282 argv += optind; 283 argv += optind;