X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/71458b3b2492943349f7693a46792756d5013c69..63621a81d16ab743de6b57d47578a9a2c670ad22:/uip/viamail.c diff --git a/uip/viamail.c b/uip/viamail.c index 13447382..db93066f 100644 --- a/uip/viamail.c +++ b/uip/viamail.c @@ -1,6 +1,4 @@ - -/* - * viamail.c -- send multiple files in a MIME message +/* viamail.c -- send multiple files in a MIME message * * This code is Copyright (c) 2002, by the authors of nmh. See the * COPYRIGHT file in the root directory of the nmh distribution for @@ -9,12 +7,14 @@ #include #include -#include #include #include #include #include #include +#include +#include "sbr/m_mktemp.h" +#include "sbr/base64.h" #define VIAMAIL_SWITCHES \ X("to mailpath", 0, TOSW) \ @@ -57,10 +57,7 @@ main (int argc, char **argv) char *cp, buf[BUFSIZ]; char **argp, **arguments; - setlocale(LC_ALL, ""); - invo_name = r1bindex (argv[0], '/'); - - context_read(); + if (nmh_init(argv[0], 2)) { return 1; } arguments = getarguments (invo_name, argc, argv, 0); argp = arguments; @@ -158,9 +155,9 @@ via_mail (char *mailsw, char *subjsw, char *parmsw, char *descsw, umask (~m_gmprot ()); - tfile = m_mktemp2(NULL, invo_name, NULL, &fp); - if (tfile == NULL) adios("viamail", "unable to create temporary file"); - chmod(tfile, 0600); + if ((tfile = m_mktemp2(NULL, invo_name, NULL, &fp)) == NULL) { + adios(NULL, "unable to create temporary file in %s", get_temp_dir()); + } strncpy (tmpfil, tfile, sizeof(tmpfil)); if (!strchr(mailsw, '@')) @@ -193,7 +190,7 @@ via_mail (char *mailsw, char *subjsw, char *parmsw, char *descsw, if (fflush (fp)) adios (tmpfil, "error writing to"); - writeBase64aux (stdin, fp); + writeBase64aux (stdin, fp, 0); if (fflush (fp)) adios (tmpfil, "error writing to"); @@ -217,7 +214,7 @@ via_mail (char *mailsw, char *subjsw, char *parmsw, char *descsw, vec[vecp++] = cp; } - switch (sendsbr (vec, vecp, program, tmpfil, &st, 0)) { + switch (sendsbr (vec, vecp, program, tmpfil, &st, 0, NULL)) { case DONE: case NOTOK: status++; @@ -227,8 +224,8 @@ via_mail (char *mailsw, char *subjsw, char *parmsw, char *descsw, } fclose (fp); - if (unlink (tmpfil) == -1) - advise (NULL, "unable to remove temp file %s", tmpfil); + if (m_unlink (tmpfil) == -1) + advise (tmpfil, "unable to remove temp file %s", tmpfil); done (status); return 1; }