aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2020-12-17 12:34:25 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2020-12-17 12:34:25 +0100
commitb6237c0657074e8a61b2123601df36389659b603 (patch)
tree29b0dedd34e238c187fb3c270bf2e4fc2f6522c1
parent25b2680056454dc4761ba3b2efde7c3414738f8c (diff)
downloadbusybox-w32-b6237c0657074e8a61b2123601df36389659b603.tar.gz
busybox-w32-b6237c0657074e8a61b2123601df36389659b603.tar.bz2
busybox-w32-b6237c0657074e8a61b2123601df36389659b603.zip
mail: commonalize send_r_n()
function old new delta send_mail_command 85 55 -30 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--mailutils/mail.c11
-rw-r--r--mailutils/mail.h1
-rw-r--r--mailutils/popmaildir.c1
-rw-r--r--mailutils/sendmail.c9
4 files changed, 12 insertions, 10 deletions
diff --git a/mailutils/mail.c b/mailutils/mail.c
index ce5267904..9735d48f6 100644
--- a/mailutils/mail.c
+++ b/mailutils/mail.c
@@ -69,6 +69,13 @@ void FAST_FUNC launch_helper(const char **argv)
69 // parent goes on 69 // parent goes on
70} 70}
71 71
72void FAST_FUNC send_r_n(const char *s)
73{
74 if (G.verbose)
75 bb_error_msg("send:'%s'", s);
76 printf("%s\r\n", s);
77}
78
72char* FAST_FUNC send_mail_command(const char *fmt, const char *param) 79char* FAST_FUNC send_mail_command(const char *fmt, const char *param)
73{ 80{
74 char *msg; 81 char *msg;
@@ -77,9 +84,7 @@ char* FAST_FUNC send_mail_command(const char *fmt, const char *param)
77 msg = (char*)fmt; 84 msg = (char*)fmt;
78 if (fmt) { 85 if (fmt) {
79 msg = xasprintf(fmt, param); 86 msg = xasprintf(fmt, param);
80 if (G.verbose) 87 send_r_n(msg);
81 bb_error_msg("send:'%s'", msg);
82 printf("%s\r\n", msg);
83 } 88 }
84 fflush_all(); 89 fflush_all();
85 return msg; 90 return msg;
diff --git a/mailutils/mail.h b/mailutils/mail.h
index 2fcd0802d..a07d535cf 100644
--- a/mailutils/mail.h
+++ b/mailutils/mail.h
@@ -28,6 +28,7 @@ struct globals {
28void launch_helper(const char **argv) FAST_FUNC; 28void launch_helper(const char **argv) FAST_FUNC;
29void get_cred_or_die(int fd) FAST_FUNC; 29void get_cred_or_die(int fd) FAST_FUNC;
30 30
31void send_r_n(const char *s) FAST_FUNC;
31char *send_mail_command(const char *fmt, const char *param) FAST_FUNC; 32char *send_mail_command(const char *fmt, const char *param) FAST_FUNC;
32 33
33void printbuf_base64(const char *buf, unsigned len) FAST_FUNC; 34void printbuf_base64(const char *buf, unsigned len) FAST_FUNC;
diff --git a/mailutils/popmaildir.c b/mailutils/popmaildir.c
index 4f2d4124d..1f2db2892 100644
--- a/mailutils/popmaildir.c
+++ b/mailutils/popmaildir.c
@@ -68,6 +68,7 @@
68static void pop3_checkr(const char *fmt, const char *param, char **ret) 68static void pop3_checkr(const char *fmt, const char *param, char **ret)
69{ 69{
70 char *msg = send_mail_command(fmt, param); 70 char *msg = send_mail_command(fmt, param);
71//FIXME: limit max len!!!
71 char *answer = xmalloc_fgetline(stdin); 72 char *answer = xmalloc_fgetline(stdin);
72 if (answer && '+' == answer[0]) { 73 if (answer && '+' == answer[0]) {
73 free(msg); 74 free(msg);
diff --git a/mailutils/sendmail.c b/mailutils/sendmail.c
index 4bb90d3e2..1a01b7110 100644
--- a/mailutils/sendmail.c
+++ b/mailutils/sendmail.c
@@ -102,13 +102,6 @@
102// set to 0 to not limit 102// set to 0 to not limit
103#define MAX_HEADERS 256 103#define MAX_HEADERS 256
104 104
105static void send_r_n(const char *s)
106{
107 if (G.verbose)
108 bb_error_msg("send:'%s'", s);
109 printf("%s\r\n", s);
110}
111
112static int smtp_checkp(const char *fmt, const char *param, int code) 105static int smtp_checkp(const char *fmt, const char *param, int code)
113{ 106{
114 char *answer; 107 char *answer;
@@ -119,6 +112,7 @@ static int smtp_checkp(const char *fmt, const char *param, int code)
119 // if code = -1 then just return this number 112 // if code = -1 then just return this number
120 // if code != -1 then checks whether the number equals the code 113 // if code != -1 then checks whether the number equals the code
121 // if not equal -> die saying msg 114 // if not equal -> die saying msg
115//FIXME: limit max len!!!
122 while ((answer = xmalloc_fgetline(stdin)) != NULL) { 116 while ((answer = xmalloc_fgetline(stdin)) != NULL) {
123 if (G.verbose) 117 if (G.verbose)
124 bb_error_msg("recv:'%.*s'", (int)(strchrnul(answer, '\r') - answer), answer); 118 bb_error_msg("recv:'%.*s'", (int)(strchrnul(answer, '\r') - answer), answer);
@@ -426,6 +420,7 @@ int sendmail_main(int argc UNUSED_PARAM, char **argv)
426 // this means we scan stdin for To:, Cc:, Bcc: lines until an empty line 420 // this means we scan stdin for To:, Cc:, Bcc: lines until an empty line
427 // and then use the rest of stdin as message body 421 // and then use the rest of stdin as message body
428 code = 0; // set "analyze headers" mode 422 code = 0; // set "analyze headers" mode
423//FIXME: limit max len!!!
429 while ((s = xmalloc_fgetline(G.fp0)) != NULL) { 424 while ((s = xmalloc_fgetline(G.fp0)) != NULL) {
430 dump: 425 dump:
431 // put message lines doubling leading dots 426 // put message lines doubling leading dots