char *cp, *mdlvr = NULL, buf[BUFSIZ];
char mailbox[BUFSIZ], tmpfil[BUFSIZ];
char **argp, **arguments;
char *cp, *mdlvr = NULL, buf[BUFSIZ];
char mailbox[BUFSIZ], tmpfil[BUFSIZ];
char **argp, **arguments;
-#ifdef LOCALE
- setlocale(LC_ALL, "");
-#endif
- invo_name = r1bindex (*argv, '/');
-
- /* foil search of user profile/context */
- if (context_foil (NULL) == -1)
- done (1);
+ if (nmh_init(argv[0], 0 /* use context_foil() */)) { return 1; }
arguments = getarguments (invo_name, argc, argv, 0);
argp = arguments;
arguments = getarguments (invo_name, argc, argv, 0);
argp = arguments;
if ((pw = getpwnam (user)) == NULL)
adios (NULL, "no such local user as %s", user);
if (chdir (pw->pw_dir) == -1)
if ((pw = getpwnam (user)) == NULL)
adios (NULL, "no such local user as %s", user);
if (chdir (pw->pw_dir) == -1)
if (debug)
debug_printf ("retrieving message from file \"%s\"\n", file);
if ((fd = copy_message (tempfd, tmpfil, 1)) == -1)
if (debug)
debug_printf ("retrieving message from file \"%s\"\n", file);
if ((fd = copy_message (tempfd, tmpfil, 1)) == -1)
close (tempfd);
} else {
/* getting message from stdin */
if (debug)
debug_printf ("retrieving message from stdin\n");
if ((fd = copy_message (fileno (stdin), tmpfil, 1)) == -1)
close (tempfd);
} else {
/* getting message from stdin */
if (debug)
debug_printf ("retrieving message from stdin\n");
if ((fd = copy_message (fileno (stdin), tmpfil, 1)) == -1)
thing would be to delay this unlink() until later if debug == 1, but I'll
leave that for someone who cares about the temp-file-accessing
functionality (they'll have to watch out for cases where we adios()). */
thing would be to delay this unlink() until later if debug == 1, but I'll
leave that for someone who cares about the temp-file-accessing
functionality (they'll have to watch out for cases where we adios()). */
if (!(fp = fdopen (fd, "r+")))
adios (NULL, "unable to access temporary file");
if (!(fp = fdopen (fd, "r+")))
adios (NULL, "unable to access temporary file");
int i, accept, status=1, won, vecp, next;
char *field, *pattern, *action, *result, *string;
char buffer[BUFSIZ], tmpbuf[BUFSIZ];
int i, accept, status=1, won, vecp, next;
char *field, *pattern, *action, *result, *string;
char buffer[BUFSIZ], tmpbuf[BUFSIZ];
/* split buffer into fields */
vecp = split (buffer, vec);
/* split buffer into fields */
vecp = split (buffer, vec);
continue; /* else fall */
case '^':
expand (tmpbuf, string, fd);
continue; /* else fall */
case '^':
expand (tmpbuf, string, fd);
status = usr_file (fd, string, MBOX_FORMAT);
break;
}
/* deliver to nmh folder */
status = usr_file (fd, string, MBOX_FORMAT);
break;
}
/* deliver to nmh folder */
continue; /* else fall */
case '+':
status = usr_folder (fd, string);
continue; /* else fall */
case '+':
status = usr_folder (fd, string);
if ((p = lookup (vars, "size"))) {
snprintf (buffer, sizeof(buffer), "%d",
fstat (fd, &st) != -1 ? (int) st.st_size : 0);
if ((p = lookup (vars, "size"))) {
snprintf (buffer, sizeof(buffer), "%d",
fstat (fd, &st) != -1 ? (int) st.st_size : 0);
}
if ((p = lookup (vars, "info")))
p->p_value = getcpy (info);
}
if ((p = lookup (vars, "info")))
p->p_value = getcpy (info);
lookup (struct pair *pairs, char *key)
{
for (; pairs->p_name; pairs++)
lookup (struct pair *pairs, char *key)
{
for (; pairs->p_name; pairs++)
-usr_pipe (int fd, char *cmd, char *pgm, char **vec, int suppress)
+usr_pipe (int fd_arg, char *cmd, char *pgm, char **vec, int suppress)
pid_t child_id;
int i, bytes, seconds, status;
struct stat st;
pid_t child_id;
int i, bytes, seconds, status;
struct stat st;
- freopen ("/dev/null", "w", stdout);
- freopen ("/dev/null", "w", stderr);
+ if (freopen ("/dev/null", "w", stdout) == NULL) {
+ advise ("stdout", "freopen");
+ }
+ if (freopen ("/dev/null", "w", stderr) == NULL) {
+ advise ("stderr", "freopen");
+ }
pidstatus (status, stdout, ", failed");
}
return (status == 0 ? 0 : -1);
pidstatus (status, stdout, ", failed");
}
return (status == 0 ? 0 : -1);
- } else {
- /*
- * Ruthlessly kill the child and anything
- * else in its process group.
- */
- killpg(child_id, SIGKILL);
- if (verbose)
- verbose_printf (", timed-out; terminated\n");
- return -1;
+ /*
+ * Ruthlessly kill the child and anything
+ * else in its process group.
+ */
+ killpg(child_id, SIGKILL);
+ if (verbose)
+ verbose_printf (", timed-out; terminated\n");
+ return -1;
strncpy (buffer, envelope + i, sizeof(buffer));
if ((cp = strchr(buffer, '\n'))) {
*cp = 0;
strncpy (buffer, envelope + i, sizeof(buffer));
if ((cp = strchr(buffer, '\n'))) {
*cp = 0;
tfile = m_mktemp2(NULL, invo_name, &fd1, NULL);
if (tfile == NULL) return -1;
tfile = m_mktemp2(NULL, invo_name, &fd1, NULL);
if (tfile == NULL) return -1;
while (fgets (buffer, sizeof(buffer), qfp)) {
if (first) {
first = 0;
if (!strncmp (buffer, "From ", i)) {
/* get copy of envelope information ("From " line) */
while (fgets (buffer, sizeof(buffer), qfp)) {
if (first) {
first = 0;
if (!strncmp (buffer, "From ", i)) {
/* get copy of envelope information ("From " line) */
int bufsz = sizeof buf;
state = m_getfld (&gstate, name, buf, &bufsz, in);
switch (state) {
case FLD:
case FLDPLUS:
/* Search for the message ID */
int bufsz = sizeof buf;
state = m_getfld (&gstate, name, buf, &bufsz, in);
switch (state) {
case FLD:
case FLDPLUS:
/* Search for the message ID */
while (state == FLDPLUS) {
bufsz = sizeof buf;
state = m_getfld (&gstate, name, buf, &bufsz, in);
while (state == FLDPLUS) {
bufsz = sizeof buf;
state = m_getfld (&gstate, name, buf, &bufsz, in);
- if ((lockfd = lkopendata(file, O_RDWR, 0)) == -1) {
+ if ((lockfd = lkopendata(file, O_RDWR, 0, &failed_to_lock))
+ == -1) {