* complete copyright information.
*/
-#include <h/mh.h>
-#include <h/fmt_scan.h>
-#include <h/fmt_compile.h>
-#include <h/signals.h>
+#include "h/mh.h"
+#include "sbr/folder_read.h"
+#include "sbr/folder_free.h"
+#include "sbr/context_find.h"
+#include "sbr/brkstring.h"
+#include "sbr/pidstatus.h"
+#include "sbr/arglist.h"
+#include "sbr/error.h"
+#include "h/fmt_scan.h"
+#include "h/fmt_compile.h"
+#include "h/signals.h"
#include <setjmp.h>
#include <fcntl.h>
-#include <h/mime.h>
-#include <h/tws.h>
-#include <h/utils.h>
-#include <h/mts.h>
+#include "h/mime.h"
+#include "h/tws.h"
+#include "h/utils.h"
+#include "h/mts.h"
#ifdef HAVE_SYS_TIME_H
# include <sys/time.h>
#include <time.h>
#ifdef OAUTH_SUPPORT
-#include <h/oauth.h>
+#include "h/oauth.h"
#endif
+#include "h/done.h"
#include "sbr/m_maildir.h"
#include "sbr/m_mktemp.h"
#include "sbr/message_id.h"
#endif /* OAUTH_SUPPORT */
int debugsw = 0; /* global */
-int forwsw = 1;
+bool forwsw = true;
int inplace = 1;
-int pushsw = 0;
+bool pushsw;
int splitsw = -1;
-int unique = 0;
-int verbsw = 0;
+bool unique;
+bool verbsw;
char *altmsg = NULL; /* .. */
char *annotext = NULL;
execvp(buildprogram, buildvec);
fprintf(stderr, "unable to exec ");
perror(buildmimeproc);
- _exit(-1);
+ _exit(1);
break;
default:
break;
}
- done=armed_done;
+ set_done(armed_done);
switch (setjmp (env)) {
case OK:
/*
if (pushsw && unique) {
char *cp = m_mktemp2(drft, invo_name, NULL, NULL);
if (cp == NULL) {
- adios(NULL, "unable to create temporary file in %s",
- get_temp_dir());
+ die("unable to create temporary file");
}
if (rename (drft, strncpy(file, cp, sizeof(file))) == NOTOK)
adios (file, "unable to rename %s to", drft);
#ifdef OAUTH_SUPPORT
const char *errmsg;
if (setup_oauth_params(vec, nvecsp, auth_svc, &errmsg) != OK) {
- adios(NULL, "%s", errmsg);
+ die("%s", errmsg);
}
#else
- adios(NULL, "send built without OAUTH_SUPPORT, "
+ die("send built without OAUTH_SUPPORT, "
"so auth_svc %s is not supported", auth_svc);
#endif /* OAUTH_SUPPORT */
}
break;
}
- done=exit;
+ set_done(exit);
if (distfile)
(void) m_unlink (distfile);
case LENERR:
case FMTERR:
- adios (NULL, "message format error in component #%d", compnum);
+ die("message format error in component #%d", compnum);
default:
- adios (NULL, "getfld () returned %d", state);
+ die("getfld () returned %d", state);
}
break;
}
m_getfld_state_destroy (&gstate);
if (cp == NULL)
- adios (NULL, "headers missing from draft");
+ die("headers missing from draft");
nparts = 1;
pos = start;
char *cp = m_mktemp2(drft, invo_name, NULL, &out);
if (cp == NULL) {
- adios(NULL, "unable to create temporary file in %s",
- get_temp_dir());
+ die("unable to create temporary file");
}
strncpy(tmpdrf, cp, sizeof(tmpdrf));
if (!fgets (buffer, sizeof buffer, in)) {
if (partno == nparts)
break;
- adios (NULL, "premature eof");
+ die("premature eof");
}
if ((pos += (len = strlen (buffer))) > CPERMSG) {
execvp (program, vec);
fprintf (stderr, "unable to exec ");
perror (postproc);
- _exit (-1);
+ _exit(1);
default:
/*
execvp (program, arglist);
fprintf (stderr, "unable to exec ");
perror (mailproc);
- _exit (-1);
+ _exit(1);
default: /* no waiting... */
break;
}
-static
-void
-handle_sendfrom(char **vec, int *vecp, char *draft, const char *auth_svc) {
+static void
+handle_sendfrom(char **vec, int *vecp, char *draft, const char *auth_svc)
+{
const char *addr, *host;
const char *message;
if (strcmp(*vp, "xoauth2") == 0) {
#ifdef OAUTH_SUPPORT
if (setup_oauth_params(vec, vecp, auth_svc, &message) != OK) {
- adios(NULL, "%s", message);
+ die("%s", message);
}
break;
#else
NMH_UNUSED(auth_svc);
- adios(NULL, "send built without OAUTH_SUPPORT, "
+ die("send built without OAUTH_SUPPORT, "
"so -saslmech xoauth2 is not supported");
#endif /* OAUTH_SUPPORT */
}
*/
static int
setup_oauth_params(char *vec[], int *vecp, const char *auth_svc,
- const char **message) {
+ const char **message)
+{
const char *saslmech = NULL, *user = NULL;
mh_oauth_service_info svc;
char errbuf[256];
if (saslmech && ! strcasecmp(saslmech, "xoauth2")) {
if (! mh_oauth_get_service_info(auth_svc, &svc, errbuf,
sizeof(errbuf)))
- adios(NULL, "Unable to retrieve oauth profile entries: %s",
+ die("Unable to retrieve oauth profile entries: %s",
errbuf);
vec[(*vecp)++] = mh_xstrdup("-authservice");
vec[(*vecp)++] = mh_xstrdup(auth_svc);
vec[(*vecp)++] = mh_xstrdup("-oauthcredfile");
- vec[(*vecp)++] = mh_xstrdup(mh_oauth_cred_fn(auth_svc));
+ vec[(*vecp)++] = mh_oauth_cred_fn(auth_svc);
vec[(*vecp)++] = mh_xstrdup("-oauthclientid");
vec[(*vecp)++] = getcpy(svc.client_id);
vec[(*vecp)++] = mh_xstrdup("-oauthclientsecret");
/*
* Extract user and domain from From: header line in draft.
*/
-static
-int
-get_from_header_info(const char *filename, const char **addr, const char **host, const char **message) {
+static int
+get_from_header_info(const char *filename, const char **addr, const char **host, const char **message)
+{
struct stat st;
FILE *in;
* Get formatted information from header of a message.
* Adapted from process_single_file() in uip/fmttest.c.
*/
-static
-const char *
-get_message_header_info(FILE *in, char *format) {
+static const char *
+get_message_header_info(FILE *in, char *format)
+{
int dat[5];
struct format *fmt;
struct stat st;
- int parsing_header;
+ bool parsing_header;
m_getfld_state_t gstate;
charstring_t buffer = charstring_create(0);
char *retval;
* Read in the message and process the header.
*/
rewind (in);
- parsing_header = 1;
+ parsing_header = true;
gstate = m_getfld_state_init(in);
do {
char name[NAMESZ], rbuf[NMH_BUFSIZ];
break;
}
default:
- parsing_header = 0;
+ parsing_header = false;
}
} while (parsing_header);
m_getfld_state_destroy(&gstate);
* If no -server passed in from profile or commandline, could use smtp.<svc>.com for gmail,
* but that might not generalize for other svcs.
*/
-static
-void
-merge_profile_entry(const char *addr, const char *host, char *vec[], int *vecp) {
+static void
+merge_profile_entry(const char *addr, const char *host, char *vec[], int *vecp)
+{
char *addr_entry = concat("sendfrom-", addr, NULL);
char *profile_entry = context_find(addr_entry);