There are several more places where system() should be replaced.
As execprog() does not split strings into multiple arguments,
`listproc' could no longer contain ``show -file''. We need to
rework the concept of these `...proc' entries.
This commit fixes tests/whatnow/test-attach-detach.
/*
** This is the default program invoked by a "list" or "display" response
** at the "What now?" prompt. It will be given the absolute pathname of
-** the message to show. The string ``show -file'' is most likely what you
-** want to be you listproc.
+** the message to show.
*/
-char *listproc = "show -file";
+char *listproc = "show";
/*
** This is used by mhl as a front-end. It is also used
.RE
.PP
.BR listproc :
-show \-file
+show
.RS 5
This program is used to list the contents of a message in response
to the
struct node *first, *cur_node, *node, *last = NULL, *prev;
size_t folder_len;
int count, total = 0;
- char *command = NULL, *sequences_s = NULL;
+ char *sequences_s = NULL;
+ int argc = 0;
+ char *argv[MAXARGS];
+ char *cp;
+ char buf[BUFSIZ];
if (cur == NULL || cur[0] == '\0') {
cur = "inbox";
}
fflush(stdout);
- /*
- ** TODO: Split enough of scan.c out so that we can
- ** call it here.
- */
- command = concat("scan +", node->n_name, " ",
- sequences_s, (void *)NULL);
- system(command);
- free(command);
+ argc = 0;
+ argv[argc++] = "scan";
+ snprintf(buf, sizeof buf, "+%s", node->n_name);
+ argv[argc++] = buf;
+ for (cp=*sequences; *cp; cp++) {
+ argv[argc++] = cp;
+ }
+ argv[argc] = (char *)NULL;
+ execprog(*argv, argv);
} else {
if (node->n_field == NULL) {
continue;
/* add an attachment header */
char buffer[BUFSIZ];
- snprintf(buffer, sizeof buffer, "anno -append -nodate '%s' "
- "-comp '%s' -text '+%s %s'",
- drft,
- attach_hdr, mp->foldpath, m_name(mp->lowsel));
- if (system(buffer) != 0) {
+ snprintf(buffer, sizeof buffer, "+%s %s",
+ mp->foldpath, m_name(mp->lowsel));
+ if (execprogl("anno", "anno", "-append", "-nodate",
+ drft, "-comp", attach_hdr, "-text", buffer,
+ (char *)NULL) != 0) {
advise(NULL, "unable to add attachment header");
}
}
fclose(composition_file);
/* We're ready to roll! */
- sprintf(buf, "mhbuild %s", composition_file_name);
- if (system(buf) != 0) {
+ if (execprogl("mhbuild", "mhbuild", composition_file_name,
+ (char *)NULL) != 0) {
/* some problem */
clean_up_temporary_files();
return (NOTOK);
char buf[BUFSIZ];
int dosign = 0;
int doenc = 0;
+ int ret;
if (!(draft_file = fopen(draft_file_name, "r"))) {
adios(NULL, "can't open draft file `%s'.", draft_file_name);
strcpy(composition_file_name, draft_file_name);
/* We're ready to roll! */
- sprintf(buf, "mhsign -m%s '%s'", doenc ? " -e" : "",
- draft_file_name);
- if (system(buf) != 0) {
+ if (doenc) {
+ ret = execprogl("mhsign", "mhsign", "-m", "-e",
+ draft_file_name, (char *)NULL);
+ } else {
+ ret = execprogl("mhsign", "mhsign", "-m",
+ draft_file_name, (char *)NULL);
+ }
+ if (ret != 0) {
/* some problem */
return (NOTOK);
}
process_bccs(char *origmsg)
{
char *bccdraft = NULL;
- char buf[BUFSIZ];
struct mailname *mp = NULL;
FILE *out = NULL;
fprintf(out, "------------\n");
fclose(out);
- snprintf(buf, sizeof buf, "send %s", bccdraft);
- if (system(buf) != 0) {
+ if (execprogl("send", "send", bccdraft, (char *)NULL) != 0) {
admonish(invo_name, "Problems to send Bcc to %s",
mp->m_text);
unlink(bccdraft);
case DISPSW:
/* display the msg being replied to or distributed */
if ((cp = getenv("mhaltmsg")) && *cp) {
- snprintf(buf, sizeof buf, "%s '%s'",
- listproc, cp);
- system(buf);
+ execprogl(listproc, listproc, "-file", cp,
+ (char *)NULL);
} else {
advise(NULL, "no alternate message to display");
}
case LISTSW:
/* display the draft file */
- snprintf(buf, sizeof buf, "%s '%s'", listproc, drft);
- system(buf);
+ execprogl(listproc, listproc, "-file", drft,
+ (char *)NULL);
break;
case QUITSW:
/*
** List attachments on current draft.
*/
- snprintf(buf, sizeof buf, "anno -list -comp '%s' "
- "-number '%s'", attach_hdr, drft);
- if (system(buf) != 0) {
+ if (execprogl("anno", "anno", "-list", "-comp",
+ attach_hdr, "-number", drft,
+ (char *)NULL) != 0) {
advise(NULL, "Could not list attachment headers.");
}
break;
** Add the attachment annotation to the draft.
*/
if ((f = popen_in_dir(cwd, buf, "r"))) {
- char buf[BUFSIZ];
-
while (fgets(shell, sizeof(shell), f)) {
*(strchr(shell, '\n')) = '\0';
sprintf(file, "%s/%s", cwd,
shell);
}
- snprintf(buf, sizeof buf,
- "anno -nodate -append "
- "-comp '%s' -text '%s'"
- " '%s'",
- attach_hdr, file,
- drft);
- if (system(buf) != 0) {
+ if (execprogl("anno", "anno",
+ "-nodate",
+ "-append", "-comp",
+ attach_hdr, "-text",
+ file, drft,
+ (char *)NULL)
+ != 0) {
advise(NULL, "Could not add attachment header.");
}
}
** that the numbering stays correct.
*/
for (arguments=argp+1; *arguments; arguments++) {
- char buf[BUFSIZ];
int n;
if (**arguments == '\0') {
continue;
}
- n = atoi(*arguments);
- snprintf(buf, sizeof buf, "anno -delete "
- "-comp '%s' -number '%d' "
- "'%s'",
- attach_hdr, n, drft);
- if (system(buf) != 0) {
+ if (execprogl("anno", "anno", "-delete",
+ "-comp", attach_hdr,
+ "-number", *arguments, drft,
+ (char *)NULL) != 0) {
advise(NULL, "Could not delete attachment header.");
}
+ n = atoi(*arguments);
for (argp=arguments+1; *argp; argp++) {
if (atoi(*argp) > n) {
if (atoi(*argp) == 1) {
case WHOMSW:
/* list recipients */
- snprintf(buf, sizeof buf, "%s '%s'", "whom", drft);
- system(buf);
+ execprogl("whom", "whom", drft, (char *)NULL);
break;
default: