-
-/*
- * whatnowsbr.c -- the WhatNow shell
+/* whatnowsbr.c -- the WhatNow shell
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
#include <fcntl.h>
#include <h/mime.h>
#include <h/utils.h>
-
#ifdef OAUTH_SUPPORT
# include <h/oauth.h>
#endif
+#include "h/done.h"
+#include "sbr/m_maildir.h"
+#include "sbr/m_mktemp.h"
+#include "sbr/mime_type.h"
#define WHATNOW_SWITCHES \
X("draftfolder +folder", 0, DFOLDSW) \
}
if (drft)
adios (NULL, "only one draft at a time!");
- else
- drft = cp;
+ drft = cp;
}
if ((drft == NULL && (drft = getenv ("mhdraft")) == NULL) || *drft == 0)
}
if (altmsg) {
if (mp)
- m_putenv ("mhfolder", mp->foldpath);
- m_putenv ("editalt", altpath);
+ setenv("mhfolder", mp->foldpath, 1);
+ setenv("editalt", altpath, 1);
}
vec = argsplit(*ed, &prog, &vecp);
execvp (prog, vec);
fprintf (stderr, "unable to exec ");
perror (*ed);
- _exit (-1);
+ _exit(1);
default:
if ((status = pidwait (pid, NOTOK))) {
sendfile (char **arg, char *file, int pushsw)
{
pid_t child_id;
- int i, vecp;
+ int vecp;
char *cp, *sp, **vec, *program;
/*
context_save (); /* save the context file */
fflush (stdout);
- for (i = 0; (child_id = fork()) == NOTOK && i < 5; i++)
- sleep (5);
+ child_id = fork();
switch (child_id) {
case NOTOK:
- inform("unable to fork, so sending directly...");
- /* FALLTHRU */
+ adios("fork", "failed:");
+
case OK:
vec = argsplit(sendproc, &program, &vecp);
if (pushsw)
execvp (program, vec);
fprintf (stderr, "unable to exec ");
perror (sendproc);
- _exit (-1);
+ _exit(1);
default:
if (pidwait(child_id, OK) == 0)
while (argp[i])
i++;
}
- args = (char **) mh_xmalloc((i + 2) * sizeof(char *));
+ args = mh_xmalloc((i + 2) * sizeof(char *));
/*
* For backward compatibility, we need to add -build
i = editfile (&ed, args, file, NOUSE, NULL, NULL, NULL, 0, 0);
free (args);
- return (i ? NOTOK : OK);
+ return i ? NOTOK : OK;
}
int snoop = 0;
struct stat st;
-#ifndef lint
- int distsw = 0;
-#endif
-
/*
* Make sure these are defined. In particular, we need
* savearg[1] to be NULL, in case "arg" is NULL below. It
inform("missing argument to %s", argp[-2]);
return;
}
- /* FALLTHRU */
+ continue;
case SNDRFSW:
continue;
}
if ((cp = getenv ("SIGNATURE")) == NULL || *cp == 0)
if ((cp = context_find ("signature")) && *cp)
- m_putenv ("SIGNATURE", cp);
+ setenv("SIGNATURE", cp, 1);
if ((annotext = getenv ("mhannotate")) == NULL || *annotext == 0)
annotext = NULL;
if ((cp = getenv ("mhdist"))
&& *cp
-#ifndef lint
- && (distsw = atoi (cp))
-#endif /* not lint */
+ && atoi(cp)
&& altmsg) {
vec[vecp++] = "-dist";
if ((cp = m_mktemp2(altmsg, invo_name, NULL, NULL)) == NULL) {
- adios(NULL, "unable to create temporary file in %s",
- get_temp_dir());
+ adios(NULL, "unable to create temporary file");
}
distfile = mh_xstrdup(cp);
(void) m_unlink(distfile);
execvp (program, vec);
fprintf (stderr, "unable to exec ");
perror (whomproc);
- _exit (-1); /* NOTREACHED */
+ _exit(1); /* NOTREACHED */
default:
- return (pidwait (pid, NOTOK) & 0377 ? 1 : 0);
+ return pidwait(pid, NOTOK) & 0377 ? 1 : 0;
}
}
checkmimeheader (char *drft)
{
FILE *f;
- m_getfld_state_t gstate = 0;
- char buf[BUFSIZ], name[NAMESZ];
+ m_getfld_state_t gstate;
+ char buf[NMH_BUFSIZ], name[NAMESZ];
int state, retval = 0;
if ((f = fopen(drft, "r")) == NULL) {
admonish(drft, "unable to read draft");
- return (0);
+ return 0;
}
+ gstate = m_getfld_state_init(f);
for (;;) {
int bufsz = sizeof(buf);
- switch (state = m_getfld(&gstate, name, buf, &bufsz, f)) {
+ switch (state = m_getfld2(&gstate, name, buf, &bufsz)) {
case FLD:
case FLDPLUS:
if (strcasecmp(name, VRSN_FIELD) == 0) {