File: getexeca.c

package info (click to toggle)
icmake 6.22-2
  • links: PTS
  • area: main
  • in suites: woody
  • size: 2,120 kB
  • ctags: 1,045
  • sloc: ansic: 9,241; makefile: 1,138; asm: 126; sh: 124
file content (55 lines) | stat: -rw-r--r-- 1,152 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
\funcref{getexecarg}{char $*$getexecarg (\params)}
    {
        {int} {n} {{\em n}-th argument to retrieve}
        {int} {*increment} {address of counter increment}
    }
    {argument in string format}
    {xstrdup(), getarg(), xrealloc()}
    {}
    {getexeca.c}
    {

        This function performs a similar function as {\em getarg()} but
        prefixes the retrieved argument with the string {\em arghead} and
        postfixes the argument with the string {\em argtail}. {\bf Note that}
        the return value always points to allocated memory which should be
        freed when no longer required.

        See further {\em getarg()}.

    }
*/

#include "icm-exec.h"

char *getexecarg (n, flag)
int n;
int *flag;
{
    register char
        *arg,
        *start,
        *ret;

    arg = getarg (n, flag);

    if (strlen (arghead))
    {
        start = xstrdup (arghead);
        start = xstrcat (start, arg);
        xrealloc (arg, 0);
    }
    else
        start = arg;

    if (strlen (argtail))
    {
        ret = xstrcat (start, argtail);
        xrealloc (start, 0);
    }
    else
        ret = start;

    return (ret);
}