summaryrefslogtreecommitdiff
path: root/src/sendmail.c
diff options
context:
space:
mode:
authorJannis Hoffmann <jannis@fehcom.de>2024-07-03 15:52:39 +0200
committerJannis Hoffmann <jannis@fehcom.de>2024-07-03 15:52:39 +0200
commita6a7d6ce079cabdaf2fa502b2e2cf15e5428ac6f (patch)
treeb88cc7a8457658d67e0321718556ac807f6bccf3 /src/sendmail.c
parent00be7622c428f279872f84569f098ce16150f8a8 (diff)
format files
Diffstat (limited to 'src/sendmail.c')
-rw-r--r--src/sendmail.c81
1 files changed, 41 insertions, 40 deletions
diff --git a/src/sendmail.c b/src/sendmail.c
index 69971e3..801c019 100644
--- a/src/sendmail.c
+++ b/src/sendmail.c
@@ -1,26 +1,28 @@
#include <unistd.h>
-#include "getoptb.h"
-#include "buffer.h"
+
#include "alloc.h"
-#include "auto_qmail.h"
-#include "exit.h"
+#include "buffer.h"
#include "env.h"
-#include "str.h"
+#include "exit.h"
+#include "getoptb.h"
#include "logmsg.h"
+#include "str.h"
+
+#include "auto_qmail.h"
#define WHO "sendmail"
void nomem()
{
- logmsg(WHO,111,FATAL,"out of memory\n");
+ logmsg(WHO, 111, FATAL, "out of memory\n");
}
void die_usage()
{
- logmsg(WHO,100,USAGE,"sendmail [ -t ] [ -fsender ] [ -Fname ] [ -bp ] [ -bs ] [ arg ... ]\n");
+ logmsg(WHO, 100, USAGE, "sendmail [ -t ] [ -fsender ] [ -Fname ] [ -bp ] [ -bs ] [ arg ... ]\n");
}
-char *smtpdarg[] = { "bin/qmail-smtpd", 0 };
+char *smtpdarg[] = {"bin/qmail-smtpd", 0};
void smtpd()
{
@@ -36,15 +38,15 @@ void smtpd()
if (!env_puts("TCPREMOTEHOST=localhost")) nomem();
if (!env_puts("TCPREMOTEINFO=sendmail-bs")) nomem();
}
- execv(*smtpdarg,smtpdarg);
- logmsg(WHO,111,FATAL,"unable to run qmail-smtpd\n");
+ execv(*smtpdarg, smtpdarg);
+ logmsg(WHO, 111, FATAL, "unable to run qmail-smtpd\n");
}
-char *qreadarg[] = { "bin/qmail-qread", 0 };
+char *qreadarg[] = {"bin/qmail-qread", 0};
void mailq()
{
- execv(*qreadarg,qreadarg);
- logmsg(WHO,111,FATAL,"unable to run qmail-qread\n");
+ execv(*qreadarg, qreadarg);
+ logmsg(WHO, 111, FATAL, "unable to run qmail-qread\n");
}
void do_sender(const char *s)
@@ -61,20 +63,18 @@ void do_sender(const char *s)
env_unset("MAILHOST");
n = str_len(s);
- a = str_rchr(s,'@');
- if (a == n)
- {
- env_put("QMAILUSER",s);
+ a = str_rchr(s, '@');
+ if (a == n) {
+ env_put("QMAILUSER", s);
return;
}
- env_put("QMAILHOST",s + a + 1);
+ env_put("QMAILHOST", s + a + 1);
- x = (char *) alloc((a + 1) * sizeof(char));
+ x = (char *)alloc((a + 1) * sizeof(char));
if (!x) nomem();
- for (i = 0; i < a; i++)
- x[i] = s[i];
+ for (i = 0; i < a; i++) x[i] = s[i];
x[i] = 0;
- env_put("QMAILUSER",x);
+ env_put("QMAILUSER", x);
alloc_free(x);
}
@@ -87,21 +87,23 @@ int main(int argc, char **argv)
char **qiargv;
char **arg;
int i;
-
+
if (chdir(auto_qmail) == -1) {
- buffer_putsflush(buffer_2,"sendmail: fatal: unable to switch to qmail home directory\n");
+ buffer_putsflush(buffer_2, "sendmail: fatal: unable to switch to qmail home directory\n");
_exit(111);
}
flagh = 0;
sender = 0;
- while ((opt = getopt(argc,argv,"vimte:f:p:o:B:F:EJxb:")) != opteof) {
+ while ((opt = getopt(argc, argv, "vimte:f:p:o:B:F:EJxb:")) != opteof) {
switch (opt) {
case 'N': break; /* ignore DSN option */
case 'B': break;
case 't': flagh = 1; break;
case 'f': sender = optarg; break;
- case 'F': if (!env_put("MAILNAME",optarg)) nomem(); break;
+ case 'F':
+ if (!env_put("MAILNAME", optarg)) nomem();
+ break;
case 'p': break; /* could generate a Received line from optarg */
case 'v': break;
case 'i': break; /* what an absurd concept */
@@ -116,7 +118,8 @@ int main(int argc, char **argv)
case 'm': break; /* see 'm' above */
}
break;
- case 'E': case 'J': /* Sony NEWS-OS */
+ case 'E':
+ case 'J': /* Sony NEWS-OS */
while (argv[optind][optpos]) ++optpos; /* skip optional argument */
break;
case 'b':
@@ -124,26 +127,24 @@ int main(int argc, char **argv)
case 'm': break;
case 'p': mailq();
case 's': smtpd();
- default: die_usage();
+ default: die_usage();
}
break;
- default:
- die_usage();
+ default: die_usage();
}
}
argc -= optind;
argv += optind;
-
- if (str_equal(optprogname,"mailq"))
- mailq();
- if (str_equal(optprogname,"newaliases")) {
- logmsg(WHO,100,FATAL,"please use fastforward/newaliases instead\n");
+ if (str_equal(optprogname, "mailq")) mailq();
+
+ if (str_equal(optprogname, "newaliases")) {
+ logmsg(WHO, 100, FATAL, "please use fastforward/newaliases instead\n");
}
- qiargv = (char **) alloc((argc + 10) * sizeof(char *));
+ qiargv = (char **)alloc((argc + 10) * sizeof(char *));
if (!qiargv) nomem();
-
+
arg = qiargv;
*arg++ = "bin/qmail-inject";
*arg++ = (flagh ? "-H" : "-a");
@@ -155,7 +156,7 @@ int main(int argc, char **argv)
*arg++ = "--";
for (i = 0; i < argc; ++i) *arg++ = argv[i];
*arg = 0;
-
- execv(*qiargv,qiargv);
- logmsg(WHO,111,FATAL,"unable to run qmail-inject\n");
+
+ execv(*qiargv, qiargv);
+ logmsg(WHO, 111, FATAL, "unable to run qmail-inject\n");
}