]>
diplodocus.org Git - nmh/blob - sbr/getarguments.c
1 /* getarguments.c -- Get the argument vector ready to go.
3 * This code is Copyright (c) 2002, by the authors of nmh. See the
4 * COPYRIGHT file in the root directory of the nmh distribution for
5 * complete copyright information.
9 #include "getarguments.h"
10 #include "context_find.h"
11 #include "brkstring.h"
15 getarguments (char *invo_name
, int argc
, char **argv
, int check_context
)
17 char *cp
= NULL
, **ap
= NULL
, **bp
= NULL
, **arguments
= NULL
;
21 * Check if profile/context specifies any arguments
23 if (check_context
&& (cp
= context_find (invo_name
))) {
24 cp
= mh_xstrdup(cp
); /* make copy */
25 ap
= brkstring (cp
, " ", "\n"); /* split string */
27 /* Count number of arguments split */
33 arguments
= mh_xmalloc ((argc
+ n
) * sizeof(*arguments
));
36 /* Copy any arguments from profile/context */
37 if (ap
!= NULL
&& n
> 0) {
42 /* Copy arguments from command line */
47 /* Now NULL terminate the array */