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

Revision 12455, 1023 bytes 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.
Line 
1
2/*
3 * getarguments.c -- Get the argument vector ready to go.
4 *
5 * $Id: getarguments.c,v 1.1.1.1 1999-02-07 18:14:08 danw Exp $
6 */
7
8#include <h/mh.h>
9
10char **
11getarguments (char *invo_name, int argc, char **argv, int check_context)
12{
13    char *cp, **ap, **bp, **arguments;
14    int n = 0;
15
16    /*
17     * Check if profile/context specifies any arguments
18     */
19    if (check_context && (cp = context_find (invo_name))) {
20        cp = getcpy (cp);               /* make copy    */
21        ap = brkstring (cp, " ", "\n"); /* split string */
22
23        /* Count number of arguments split */
24        bp = ap;
25        while (*bp++)
26            n++;
27    }
28
29    if (!(arguments = (char **) malloc ((argc + n) * sizeof(*arguments))))
30        adios (NULL, "unable to malloc argument storage");
31    bp = arguments;
32
33    /* Copy any arguments from profile/context */
34    if (n > 0) {
35        while (*ap)
36            *bp++ = *ap++;
37     }
38
39    /* Copy arguments from command line */
40    argv++;
41    while (*argv)
42        *bp++ = *argv++;
43
44    /* Now NULL terminate the array */
45    *bp = NULL;
46
47    return arguments;
48}
Note: See TracBrowser for help on using the repository browser.