aboutsummaryrefslogtreecommitdiffstats
path: root/src/util.h
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2016-09-22 10:41:55 +0000
committerWerner Koch <[email protected]>2016-09-22 10:42:10 +0000
commitdc39552d01094eff2bef5f9fcd1c16928909d20e (patch)
treeb7f5e7eaf50d578e44e218fb36d3e373831d8666 /src/util.h
parenttests: Add test for cancellation (diff)
downloadgpgme-dc39552d01094eff2bef5f9fcd1c16928909d20e.tar.gz
gpgme-dc39552d01094eff2bef5f9fcd1c16928909d20e.zip
core: New helper function _gpgme_strconcat.
* src/conversion.c: Include stdarg.h. (do_strconcat): New. (_gpgme_strconcat): New. * src/util.h: Provide fallback for GPGRT_ATTR_SENTINEL. (_gpgme_strconcat): New with sentinel. * src/w32-util.c (find_program_in_dir): Replace malloc and stpcpy by _gpgme_strconcat. (find_program_at_standard_place): Ditto. (_gpgme_set_default_gpg_name): Ditto. (_gpgme_set_default_gpgconf_name): Ditto. (_gpgme_mkstemp): Ditto. (_gpgme_set_override_inst_dir): Repalce malloc and strcpy by strdup. -- The function has been taken from gnupg/common/stringhelp.c and license changed to LPGLv2.1+. I am the original author of that code. Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'src/util.h')
-rw-r--r--src/util.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/util.h b/src/util.h
index 88e77508..1474b411 100644
--- a/src/util.h
+++ b/src/util.h
@@ -49,6 +49,10 @@
# define GPG_ERR_FALSE 256
#endif
+#ifndef GPGRT_ATTR_SENTINEL
+# define GPGRT_ATTR_SENTINEL(a) /* */
+#endif
+
/*-- {posix,w32}-util.c --*/
@@ -102,6 +106,12 @@ int _gpgme_ttyname_r (int fd, char *buf, size_t buflen);
/*-- conversion.c --*/
+
+/* Concatenate the string S1 with all the following strings up to a
+ NULL. Returns a malloced buffer with the new string or NULL on a
+ malloc error or if too many arguments are given. */
+char *_gpgme_strconcat (const char *s1, ...) GPGRT_ATTR_SENTINEL(0);
+
/* Convert two hexadecimal digits from STR to the value they
represent. Returns -1 if one of the characters is not a
hexadecimal digit. */