concat, vconcat - concatenate strings into a buffer

char *concat(buf, buflen, str1, str2, ..., NULL);
char *buf;
int buflen;
char *str1, *str2, ...;

#include <varargs.h>

char *vconcat(buf, buflen, ap)
char *buf;
int buflen;
va_list ap;

Concat takes a list of string pointers and concatenates them into a
buffer. The string pointers are terminated by a NULL (0) string
pointer. Buf should be a buffer of length buflen that will contain
the concatenation of the string pointers.

Concat will return NULL if buf is NULL, if buflen is <= 0, or if
the concatenation of the string pointers did not fit into buf. In
all other cases, concat will terminate the concatenation with a
null (0) byte and return a pointer to the null byte.

Vconcat is a varargs version of concat which may be used by
routines to concatenate their string pointer argument list into a

end = concat(buf, buflen, dir, "/", file, NULL);

could be used to generate a file path from a directory name and a
file name, returning a pointer to the end of the path.

concat(end, buf+buflen-end, ".", ext, NULL);

could then be used to add an extension to the file path.

strcat(3), strcpy(3), sprintf(3)