diff options
author | Russ Allbery <rra@stanford.edu> | 2010-02-21 17:45:56 -0800 |
---|---|---|
committer | Russ Allbery <rra@stanford.edu> | 2010-02-21 17:45:56 -0800 |
commit | ae14bea1375dd5923d4a73e167b27bee13feb7b7 (patch) | |
tree | c1222395732cf8ce2cca32f013f080d19736f474 /util/concat.h | |
parent | 57aba51dc26ebf0bdd034f6cb418a9ea5f1fc0be (diff) | |
parent | 60210334fa3dbd5dd168199063c6ee850d750d0c (diff) |
Merge commit 'upstream/0.10' into debian
Diffstat (limited to 'util/concat.h')
-rw-r--r-- | util/concat.h | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/util/concat.h b/util/concat.h new file mode 100644 index 0000000..ef8b38d --- /dev/null +++ b/util/concat.h @@ -0,0 +1,36 @@ +/* + * Prototypes for string concatenation with dynamic memory allocation. + * + * Written by Russ Allbery <rra@stanford.edu> + * This work is hereby placed in the public domain by its author. + */ + +#ifndef UTIL_CONCAT_H +#define UTIL_CONCAT_H 1 + +#include <config.h> +#include <portable/macros.h> + +BEGIN_DECLS + +/* Default to a hidden visibility for all util functions. */ +#pragma GCC visibility push(hidden) + +/* Concatenate NULL-terminated strings into a newly allocated string. */ +char *concat(const char *first, ...) + __attribute__((__malloc__, __nonnull__(1))); + +/* + * Given a base path and a file name, create a newly allocated path string. + * The name will be appended to base with a / between them. Exceptionally, if + * name begins with a slash, it will be strdup'd and returned as-is. + */ +char *concatpath(const char *base, const char *name) + __attribute__((__malloc__, __nonnull__(2))); + +/* Undo default visibility change. */ +#pragma GCC visibility pop + +END_DECLS + +#endif /* UTIL_CONCAT_H */ |