* docs/MAIL.FILTERING: added note on removing procmail -f or
[mmh] / sbr / concat.c
1
2 /*
3  * concat.c -- concatenate a variable number (minimum of 1)
4  *             of strings in managed memory
5  *
6  * $Id$
7  *
8  * This code is Copyright (c) 2002, by the authors of nmh.  See the
9  * COPYRIGHT file in the root directory of the nmh distribution for
10  * complete copyright information.
11  */
12
13 #include <h/mh.h>
14 #include <h/utils.h>
15
16
17 char *
18 concat (char *s1, ...)
19 {
20     char *cp, *dp, *sp;
21     size_t len;
22     va_list list;
23
24     len = strlen (s1) + 1;
25     va_start(list, s1); 
26     while ((cp = va_arg(list, char *)))
27         len += strlen (cp);
28     va_end(list);
29
30     dp = sp = mh_xmalloc(len);
31
32     sp = copy(s1, sp);
33
34     va_start(list, s1); 
35     while ((cp = va_arg (list, char *)))
36         sp = copy(cp, sp);
37     va_end(list);
38
39     return dp;
40 }