(mh_spawnp): New function.
Showing
1 changed file
with
34 additions
and
0 deletions
... | @@ -379,3 +379,37 @@ mh_iterate (mailbox_t mbox, mh_msgset_t *msgset, | ... | @@ -379,3 +379,37 @@ mh_iterate (mailbox_t mbox, mh_msgset_t *msgset, |
379 | 379 | ||
380 | return 0; | 380 | return 0; |
381 | } | 381 | } |
382 | |||
383 | int | ||
384 | mh_spawnp (const char *prog, const char *file) | ||
385 | { | ||
386 | int argc, i, rc, status; | ||
387 | char **argv, **xargv; | ||
388 | |||
389 | if (argcv_get (prog, "", "#", &argc, &argv)) | ||
390 | { | ||
391 | mh_error (_("cannot split line %s"), prog); | ||
392 | argcv_free (argc, argv); | ||
393 | return 1; | ||
394 | } | ||
395 | |||
396 | xargv = calloc (argc + 2, sizeof (*xargv)); | ||
397 | if (!xargv) | ||
398 | { | ||
399 | mh_error (_("not enough memory")); | ||
400 | argcv_free (argc, argv); | ||
401 | return 1; | ||
402 | } | ||
403 | |||
404 | for (i = 0; i < argc; i++) | ||
405 | xargv[i] = argv[i]; | ||
406 | xargv[i++] = (char*) file; | ||
407 | xargv[i++] = NULL; | ||
408 | |||
409 | rc = mu_spawnvp (xargv[0], (const char**) xargv, &status); | ||
410 | |||
411 | free (xargv); | ||
412 | argcv_free (argc, argv); | ||
413 | |||
414 | return rc; | ||
415 | } | ... | ... |
-
Please register or sign in to post a comment