summaryrefslogtreecommitdiffstats
path: root/common/utils.c
diff options
context:
space:
mode:
authorGravatar Martin Szulecki2013-07-13 16:37:05 +0200
committerGravatar Martin Szulecki2013-07-13 16:37:05 +0200
commit41b640d30dc12dbb5cebbf7316a191efdd6f2c74 (patch)
tree5ce003be6926143535018f7aa71bb420cb65ff98 /common/utils.c
parentb8169cbeda3699f3c0159267815cf9a011149950 (diff)
downloadlibimobiledevice-41b640d30dc12dbb5cebbf7316a191efdd6f2c74.tar.gz
libimobiledevice-41b640d30dc12dbb5cebbf7316a191efdd6f2c74.tar.bz2
common: Implement stpcpy() replacement for systems lacking it
Diffstat (limited to 'common/utils.c')
-rw-r--r--common/utils.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/common/utils.c b/common/utils.c
index b2b3768..bd2bf1f 100644
--- a/common/utils.c
+++ b/common/utils.c
@@ -29,6 +29,29 @@
#include "utils.h"
+#ifndef HAVE_STPCPY
+/**
+ * Copy characters from one string into another
+ *
+ * @note: The strings should not overlap, as the behavior is undefined.
+ *
+ * @s1: The source string.
+ * @s2: The destination string.
+ *
+ * @return a pointer to the terminating `\0' character of @s1,
+ * or NULL if @s1 or @s2 is NULL.
+ */
+char *stpcpy(char * s1, const char * s2)
+{
+ if (s1 == NULL || s2 == NULL)
+ return NULL;
+
+ strcpy(s1, s2);
+
+ return s1 + strlen(s2);
+}
+#endif
+
/**
* Concatenate strings into a newly allocated string
*