summaryrefslogtreecommitdiffstats
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
parentb8169cbeda3699f3c0159267815cf9a011149950 (diff)
downloadlibimobiledevice-41b640d30dc12dbb5cebbf7316a191efdd6f2c74.tar.gz
libimobiledevice-41b640d30dc12dbb5cebbf7316a191efdd6f2c74.tar.bz2
common: Implement stpcpy() replacement for systems lacking it
-rw-r--r--common/utils.c23
-rw-r--r--common/utils.h3
2 files changed, 26 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 @@
29 29
30#include "utils.h" 30#include "utils.h"
31 31
32#ifndef HAVE_STPCPY
33/**
34 * Copy characters from one string into another
35 *
36 * @note: The strings should not overlap, as the behavior is undefined.
37 *
38 * @s1: The source string.
39 * @s2: The destination string.
40 *
41 * @return a pointer to the terminating `\0' character of @s1,
42 * or NULL if @s1 or @s2 is NULL.
43 */
44char *stpcpy(char * s1, const char * s2)
45{
46 if (s1 == NULL || s2 == NULL)
47 return NULL;
48
49 strcpy(s1, s2);
50
51 return s1 + strlen(s2);
52}
53#endif
54
32/** 55/**
33 * Concatenate strings into a newly allocated string 56 * Concatenate strings into a newly allocated string
34 * 57 *
diff --git a/common/utils.h b/common/utils.h
index 129f974..441d188 100644
--- a/common/utils.h
+++ b/common/utils.h
@@ -22,6 +22,9 @@
22#ifndef __UTILS_H 22#ifndef __UTILS_H
23#define __UTILS_H 23#define __UTILS_H
24 24
25#ifndef HAVE_STPCPY
26char *stpcpy(char * s1, const char * s2);
27#endif
25char *string_concat(const char *str, ...); 28char *string_concat(const char *str, ...);
26 29
27#endif 30#endif