source: trunk/third/nmh/sbr/showfile.c @ 12455

Revision 12455, 1.1 KB checked in by danw, 26 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r12454, which included commits to RCS files with non-trunk default branches.
RevLine 
[12454]1
2/*
3 * showfile.c -- invoke the `lproc' command
4 *
5 * $Id: showfile.c,v 1.1.1.1 1999-02-07 18:14:10 danw Exp $
6 */
7
8#include <h/mh.h>
9
10
11int
12showfile (char **arg, char *file)
13{
14    pid_t pid;
15    int isdraft, vecp;
16    char *vec[MAXARGS];
17
18    context_save();     /* save the context file */
19    fflush(stdout);
20
21    /*
22     * If you have your lproc listed as "mhl",
23     * then really invoked the mhlproc instead
24     * (which is usually mhl anyway).
25     */
26    if (!strcmp (r1bindex (lproc, '/'), "mhl"))
27        lproc = mhlproc;
28
29    switch (pid = vfork()) {
30    case -1:
31        /* fork error */
32        advise ("fork", "unable to");
33        return 1;
34
35    case 0:
36        /* child */
37        vecp = 0;
38        vec[vecp++] = r1bindex (lproc, '/');
39        isdraft = 1;
40        if (arg) {
41            while (*arg) {
42                if (**arg != '-')
43                    isdraft = 0;
44                vec[vecp++] = *arg++;
45            }
46        }
47        if (isdraft) {
48            if (!strcmp (vec[0], "show"))
49                vec[vecp++] = "-file";
50            vec[vecp++] = file;
51        }
52        vec[vecp] = NULL;
53
54        execvp (lproc, vec);
55        fprintf (stderr, "unable to exec ");
56        perror (lproc);
57        _exit (-1);
58
59    default:
60        /* parent */
61        return (pidwait (pid, -1) & 0377 ? 1 : 0);
62    }
63
64    return 1;   /* NOT REACHED */
65}
Note: See TracBrowser for help on using the repository browser.